aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Miao <eric.miao@linaro.org>2012-01-11 21:05:30 +0800
committerEric Miao <eric.miao@linaro.org>2012-01-11 21:05:30 +0800
commit0aea43bf004cabab7548668106bfe1376288a68c (patch)
tree9fe889dab3515491037b662c878e4872d2afd7c9
parent651d6a8fcedaafcf13990e75457df371a7d62aa0 (diff)
downloadlinux-linaro-0aea43bf004cabab7548668106bfe1376288a68c.tar.gz
imx6q: add device tree support for OCOTP driver
Signed-off-by: Eric Miao <eric.miao@linaro.org>
-rw-r--r--arch/arm/boot/dts/imx6q.dtsi6
-rw-r--r--arch/arm/mach-imx/clock-imx6q.c1
-rw-r--r--drivers/char/Kconfig2
-rw-r--r--drivers/char/fsl_otp.c58
-rw-r--r--drivers/char/fsl_otp.h19
-rw-r--r--drivers/char/mxs_viim.c2
-rw-r--r--include/linux/fsl_devices.h1
7 files changed, 68 insertions, 21 deletions
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index c269da61154..72b5ca0375b 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -510,6 +510,12 @@
ocotp@021bc000 {
compatible = "fsl,imx6q-ocotp";
+ reg = <0x021bc000 0x8000>;
+ interrupts = <0 21 0x04>;
+ };
+
+ viim@021bc000 {
+ compatible = "fsl,imx6q-viim";
reg = <0x021bc000 0x4000>,
<0x021c0000 0x4000>;
interrupts = <0 21 0x04>;
diff --git a/arch/arm/mach-imx/clock-imx6q.c b/arch/arm/mach-imx/clock-imx6q.c
index b347a847c64..29ddc49342e 100644
--- a/arch/arm/mach-imx/clock-imx6q.c
+++ b/arch/arm/mach-imx/clock-imx6q.c
@@ -1912,6 +1912,7 @@ static struct clk_lookup lookups[] = {
_REGISTER_CLOCK(NULL, "gpmi_io_clk", gpmi_io_clk),
_REGISTER_CLOCK(NULL, "usboh3_clk", usboh3_clk),
_REGISTER_CLOCK(NULL, "sata_clk", sata_clk),
+ _REGISTER_CLOCK(NULL, "ocotp_clk", iim_clk),
};
int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode)
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index cb2a6e0c28f..96251d48435 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -616,7 +616,7 @@ config MXS_VIIM
config FSL_OTP
tristate "Freescale On-Chip OTP Memory Support"
- depends on (ARCH_MX23 || ARCH_MX28 || ARCH_MX50 || ARCH_MX6)
+ depends on (ARCH_MX23 || ARCH_MX28 || ARCH_MX50 || SOC_IMX6Q)
default n
help
If you say Y here, you will get support for a character device
diff --git a/drivers/char/fsl_otp.c b/drivers/char/fsl_otp.c
index 05ad55e9d6a..26ff68fcdaf 100644
--- a/drivers/char/fsl_otp.c
+++ b/drivers/char/fsl_otp.c
@@ -31,6 +31,8 @@
#include <linux/slab.h>
#include <linux/platform_device.h>
#include <linux/fsl_devices.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
#include "fsl_otp.h"
@@ -169,20 +171,23 @@ error_out:
return -ENOMEM;
}
+static const struct of_device_id ocotp_dt_ids[];
+
static int __devinit fsl_otp_probe(struct platform_device *pdev)
{
int retval;
struct mxc_otp_platform_data *pdata;
+ const struct of_device_id *of_id =
+ of_match_device(ocotp_dt_ids, &pdev->dev);
- pdata = pdev->dev.platform_data;
+ pdata = of_id ? of_id->data : pdev->dev.platform_data;
if (pdata == NULL)
return -ENODEV;
/* Enable clock */
- if (pdata->clock_name) {
- otp_clk = clk_get(&pdev->dev, pdata->clock_name);
+ otp_clk = clk_get(&pdev->dev, "ocotp_clk");
+ if (otp_clk)
clk_enable(otp_clk);
- }
retval = alloc_otp_attr(pdata);
if (retval)
@@ -203,6 +208,7 @@ static int __devinit fsl_otp_probe(struct platform_device *pdev)
goto error;
mutex_init(&otp_mutex);
+ dev_info(&pdev->dev, "initialized\n");
return 0;
error:
kobject_put(otp_kobj);
@@ -226,7 +232,7 @@ static int otp_remove(struct platform_device *pdev)
free_otp_attr();
unmap_ocotp_addr();
- if (pdata->clock_name) {
+ if (otp_clk) {
clk_disable(otp_clk);
clk_put(otp_clk);
}
@@ -234,12 +240,54 @@ static int otp_remove(struct platform_device *pdev)
return 0;
}
+#define BANK(a, b, c, d, e, f, g, h) \
+{\
+ ("HW_OCOTP_"#a), ("HW_OCOTP_"#b), ("HW_OCOTP_"#c), ("HW_OCOTP_"#d), \
+ ("HW_OCOTP_"#e), ("HW_OCOTP_"#f), ("HW_OCOTP_"#g), ("HW_OCOTP_"#h) \
+}
+
+static char *imx6q_ocotp_fuse_names[16][8] = {
+ BANK(LOCK, CFG0, CFG1, CFG2, CFG3, CFG4, CFG5, CFG6),
+ BANK(MEM0, MEM1, MEM2, MEM3, MEM4, ANA0, ANA1, ANA2),
+ BANK(OTPMK0, SOTPMK1, OTPMK2, OTPMK3, OTPMK4, OTPMK5, OTPMK6, OTPMK7),
+ BANK(SRK0, SRK1, SRK2, SRK3, SRK4, SRK5, SRK6, SRK7),
+ BANK(RESP0, HSJC_RESP1, MAC0, MAC1, HDCP_KSV0, HDCP_KSV1, GP1, GP2),
+ BANK(DTCP_KEY0, DTCP_KEY1, DTCP_KEY2, DTCP_KEY3, DTCP_KEY4, MISC_CONF, FIELD_RETURN, SRK_REVOKE),
+ BANK(HDCP_KEY0, HDCP_KEY1, HDCP_KEY2, HDCP_KEY3, HDCP_KEY4, HDCP_KEY5, HDCP_KEY6, HDCP_KEY7),
+ BANK(HDCP_KEY8, HDCP_KEY9, HDCP_KEY10, HDCP_KEY11, HDCP_KEY12, HDCP_KEY13, HDCP_KEY14, HDCP_KEY15),
+ BANK(HDCP_KEY16, HDCP_KEY17, HDCP_KEY18, HDCP_KEY19, HDCP_KEY20, HDCP_KEY21, HDCP_KEY22, HDCP_KEY23),
+ BANK(HDCP_KEY24, HDCP_KEY25, HDCP_KEY26, HDCP_KEY27, HDCP_KEY28, HDCP_KEY29, HDCP_KEY30, HDCP_KEY31),
+ BANK(HDCP_KEY32, HDCP_KEY33, HDCP_KEY34, HDCP_KEY35, HDCP_KEY36, HDCP_KEY37, HDCP_KEY38, HDCP_KEY39),
+ BANK(HDCP_KEY40, HDCP_KEY41, HDCP_KEY42, HDCP_KEY43, HDCP_KEY44, HDCP_KEY45, HDCP_KEY46, HDCP_KEY47),
+ BANK(HDCP_KEY48, HDCP_KEY49, HDCP_KEY50, HDCP_KEY51, HDCP_KEY52, HDCP_KEY53, HDCP_KEY54, HDCP_KEY55),
+ BANK(HDCP_KEY56, HDCP_KEY57, HDCP_KEY58, HDCP_KEY59, HDCP_KEY60, HDCP_KEY61, HDCP_KEY62, HDCP_KEY63),
+ BANK(HDCP_KEY64, HDCP_KEY65, HDCP_KEY66, HDCP_KEY67, HDCP_KEY68, HDCP_KEY69, HDCP_KEY70, HDCP_KEY71),
+ BANK(CRC0, CRC1, CRC2, CRC3, CRC4, CRC5, CRC6, CRC7),
+};
+
+enum {
+ IMX6Q_OCOTP,
+};
+
+static struct mxc_otp_platform_data ocotp_data[] = {
+ [IMX6Q_OCOTP] = {
+ .fuse_name = (char **)imx6q_ocotp_fuse_names,
+ .fuse_num = 16 * 8,
+ }
+};
+
+static const struct of_device_id ocotp_dt_ids[] = {
+ { .compatible = "fsl,imx6q-ocotp", .data = &ocotp_data[IMX6Q_OCOTP], },
+ { /* sentinel */ }
+};
+
static struct platform_driver ocotp_driver = {
.probe = fsl_otp_probe,
.remove = otp_remove,
.driver = {
.name = "imx-ocotp",
.owner = THIS_MODULE,
+ .of_match_table = ocotp_dt_ids,
},
};
diff --git a/drivers/char/fsl_otp.h b/drivers/char/fsl_otp.h
index 5f779e53e41..255f0b02ecb 100644
--- a/drivers/char/fsl_otp.h
+++ b/drivers/char/fsl_otp.h
@@ -23,6 +23,7 @@
static u32 otp_voltage_saved;
struct regulator *regu;
+static struct clk *otp_clk;
static int otp_wait_busy(u32 flags);
@@ -238,7 +239,7 @@ static void unmap_ocotp_addr(void)
otp_base = NULL;
}
-#elif defined(CONFIG_ARCH_MX6) /* IMX6 below ============================= */
+#elif defined(CONFIG_SOC_IMX6Q) /* IMX6 below ============================= */
#include <mach/hardware.h>
#include <linux/ioport.h>
@@ -257,21 +258,11 @@ static void *otp_base;
static int set_otp_timing(struct mxc_otp_platform_data *otp_data)
{
- struct clk *ocotp_clk;
unsigned long clk_rate = 0;
unsigned long strobe_read, relex, strobe_prog;
u32 timing = 0;
- /* [1] get the clock. It needs the IPG clock,though doc writes IPG.*/
- if (!otp_data->clock_name)
- return -1;
-
- ocotp_clk = clk_get(NULL, otp_data->clock_name);
- if (IS_ERR(ocotp_clk)) {
- log("we can not find the clock");
- return -1;
- }
- clk_rate = clk_get_rate(ocotp_clk);
+ clk_rate = clk_get_rate(otp_clk);
/* do optimization for too many zeros */
relex = clk_rate / (1000000000 / DEF_RELEX) - 1;
@@ -299,6 +290,7 @@ static int otp_read_prepare(struct mxc_otp_platform_data *otp_data)
return ret;
}
+
static int otp_read_post(struct mxc_otp_platform_data *otp_data)
{
return 0;
@@ -330,6 +322,7 @@ static int otp_write_prepare(struct mxc_otp_platform_data *otp_data)
return ret;
}
+
static int otp_write_post(struct mxc_otp_platform_data *otp_data)
{
/* restore the clock and voltage */
@@ -364,6 +357,6 @@ static void unmap_ocotp_addr(void)
iounmap(otp_base);
otp_base = NULL;
}
-#endif /* CONFIG_ARCH_MX6 */
+#endif /* CONFIG_SOC_IMX6Q */
#endif
diff --git a/drivers/char/mxs_viim.c b/drivers/char/mxs_viim.c
index 2a076a10a74..ae04b0bd8cc 100644
--- a/drivers/char/mxs_viim.c
+++ b/drivers/char/mxs_viim.c
@@ -151,7 +151,7 @@ static int mxs_viim_remove(struct platform_device *pdev)
}
static const struct of_device_id mxs_viim_dt_ids[] = {
- { .compatible = "fsl,imx6q-ocotp", },
+ { .compatible = "fsl,imx6q-viim", },
{ /* sentinel */ }
};
diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
index 7607808fb43..76a8c67cda0 100644
--- a/include/linux/fsl_devices.h
+++ b/include/linux/fsl_devices.h
@@ -106,7 +106,6 @@ struct fsl_usb2_platform_data {
struct mxc_otp_platform_data {
char **fuse_name;
char *regulator_name;
- char *clock_name;
unsigned int min_volt;
unsigned int max_volt;
unsigned int fuse_num;