summaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2016-11-18 09:53:55 -0800
committerOlof Johansson <olof@lixom.net>2016-11-18 09:53:55 -0800
commit555b2b5d254d60c8b7b8ec566d2f8226f2441a5e (patch)
treed5fa887cda974512f5e557fd21140ad0ac105b1e /drivers/misc
parente87c077ff6d519676cf40f7090d74828be878a2a (diff)
parent2ae2e28852f21ec9efc527c1f3ecc5f7c7e27e42 (diff)
downloadop-kernel-dev-555b2b5d254d60c8b7b8ec566d2f8226f2441a5e.zip
op-kernel-dev-555b2b5d254d60c8b7b8ec566d2f8226f2441a5e.tar.gz
Merge tag 'at91-ab-4.10-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux into next/drivers
Drivers for 4.10: - few fixes for the memory drivers - minimal security module driver - support for the Secure SRAM * tag 'at91-ab-4.10-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: misc: sram: add Atmel securam support misc: sram: document new compatible ARM: at91: add secumod register definitions Documentation: dt: atmel-at91: Document secumod bindings memory: atmel-sdramc: use builtin_platform_driver to simplify the code memory: atmel-ebi: fix return value check in at91_ebi_dev_disable() Signed-off-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/sram.c42
1 files changed, 35 insertions, 7 deletions
diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
index f84b53d..b0d4dd9 100644
--- a/drivers/misc/sram.c
+++ b/drivers/misc/sram.c
@@ -19,12 +19,17 @@
*/
#include <linux/clk.h>
+#include <linux/delay.h>
#include <linux/genalloc.h>
#include <linux/io.h>
#include <linux/list_sort.h>
#include <linux/of_address.h>
+#include <linux/of_device.h>
#include <linux/platform_device.h>
+#include <linux/regmap.h>
#include <linux/slab.h>
+#include <linux/mfd/syscon.h>
+#include <soc/at91/atmel-secumod.h>
#define SRAM_GRANULARITY 32
@@ -334,12 +339,35 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res)
return ret;
}
+static int atmel_securam_wait(void)
+{
+ struct regmap *regmap;
+ u32 val;
+
+ regmap = syscon_regmap_lookup_by_compatible("atmel,sama5d2-secumod");
+ if (IS_ERR(regmap))
+ return -ENODEV;
+
+ return regmap_read_poll_timeout(regmap, AT91_SECUMOD_RAMRDY, val,
+ val & AT91_SECUMOD_RAMRDY_READY,
+ 10000, 500000);
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id sram_dt_ids[] = {
+ { .compatible = "mmio-sram" },
+ { .compatible = "atmel,sama5d2-securam", .data = atmel_securam_wait },
+ {}
+};
+#endif
+
static int sram_probe(struct platform_device *pdev)
{
struct sram_dev *sram;
struct resource *res;
size_t size;
int ret;
+ int (*init_func)(void);
sram = devm_kzalloc(&pdev->dev, sizeof(*sram), GFP_KERNEL);
if (!sram)
@@ -384,6 +412,13 @@ static int sram_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, sram);
+ init_func = of_device_get_match_data(&pdev->dev);
+ if (init_func) {
+ ret = init_func();
+ if (ret)
+ return ret;
+ }
+
dev_dbg(sram->dev, "SRAM pool: %zu KiB @ 0x%p\n",
gen_pool_size(sram->pool) / 1024, sram->virt_base);
@@ -405,13 +440,6 @@ static int sram_remove(struct platform_device *pdev)
return 0;
}
-#ifdef CONFIG_OF
-static const struct of_device_id sram_dt_ids[] = {
- { .compatible = "mmio-sram" },
- {}
-};
-#endif
-
static struct platform_driver sram_driver = {
.driver = {
.name = "sram",
OpenPOWER on IntegriCloud