Davinci: jtag_id - use ioremap()
authorCyril Chemparathy <cyril@ti.com>
Fri, 7 May 2010 21:06:34 +0000 (17:06 -0400)
committerKevin Hilman <khilman@deeprootsystems.com>
Thu, 13 May 2010 17:05:24 +0000 (10:05 -0700)
This patch replaces the jtag id base info in davinci_soc_info with a physical
address which is then ioremap()ed within common code.

This patch (in combination with a similar change for PSC) will allow us to
eliminate the SYSCFG nastiness in DA8xx code.

Signed-off-by: Cyril Chemparathy <cyril@ti.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
arch/arm/mach-davinci/common.c
arch/arm/mach-davinci/da830.c
arch/arm/mach-davinci/da850.c
arch/arm/mach-davinci/dm355.c
arch/arm/mach-davinci/dm365.c
arch/arm/mach-davinci/dm644x.c
arch/arm/mach-davinci/dm646x.c
arch/arm/mach-davinci/include/mach/common.h

index f8221c5ee380b9eb66c6ce590094b2063aab1314..65e073df5bc931b92b031c321bb4e9a0eeddf3c3 100644 (file)
@@ -37,26 +37,43 @@ void davinci_get_mac_addr(struct memory_accessor *mem_acc, void *context)
                pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr);
 }
 
-static struct davinci_id * __init davinci_get_id(u32 jtag_id)
+static int __init davinci_init_id(struct davinci_soc_info *soc_info)
 {
-       int i;
-       struct davinci_id *dip;
-       u8 variant = (jtag_id & 0xf0000000) >> 28;
-       u16 part_no = (jtag_id & 0x0ffff000) >> 12;
+       int                     i;
+       struct davinci_id       *dip;
+       u8                      variant;
+       u16                     part_no;
+       void __iomem            *base;
+
+       base = ioremap(soc_info->jtag_id_reg, SZ_4K);
+       if (!base) {
+               pr_err("Unable to map JTAG ID register\n");
+               return -ENOMEM;
+       }
+
+       soc_info->jtag_id = __raw_readl(base);
+       iounmap(base);
 
-       for (i = 0, dip = davinci_soc_info.ids; i < davinci_soc_info.ids_num;
+       variant = (soc_info->jtag_id & 0xf0000000) >> 28;
+       part_no = (soc_info->jtag_id & 0x0ffff000) >> 12;
+
+       for (i = 0, dip = soc_info->ids; i < soc_info->ids_num;
                        i++, dip++)
                /* Don't care about the manufacturer right now */
-               if ((dip->part_no == part_no) && (dip->variant == variant))
-                       return dip;
-
-       return NULL;
+               if ((dip->part_no == part_no) && (dip->variant == variant)) {
+                       soc_info->cpu_id = dip->cpu_id;
+                       pr_info("DaVinci %s variant 0x%x\n", dip->name,
+                                       dip->variant);
+                       return 0;
+               }
+
+       pr_err("Unknown DaVinci JTAG ID 0x%x\n", soc_info->jtag_id);
+       return -EINVAL;
 }
 
 void __init davinci_common_init(struct davinci_soc_info *soc_info)
 {
        int ret;
-       struct davinci_id *dip;
 
        if (!soc_info) {
                ret = -EINVAL;
@@ -84,18 +101,9 @@ void __init davinci_common_init(struct davinci_soc_info *soc_info)
         * We want to check CPU revision early for cpu_is_xxxx() macros.
         * IO space mapping must be initialized before we can do that.
         */
-       davinci_soc_info.jtag_id = __raw_readl(davinci_soc_info.jtag_id_base);
-
-       dip = davinci_get_id(davinci_soc_info.jtag_id);
-       if (!dip) {
-               ret = -EINVAL;
-               pr_err("Unknown DaVinci JTAG ID 0x%x\n",
-                                               davinci_soc_info.jtag_id);
+       ret = davinci_init_id(&davinci_soc_info);
+       if (ret < 0)
                goto err;
-       }
-
-       davinci_soc_info.cpu_id = dip->cpu_id;
-       pr_info("DaVinci %s variant 0x%x\n", dip->name, dip->variant);
 
        if (davinci_soc_info.cpu_clks) {
                ret = davinci_clk_init(davinci_soc_info.cpu_clks);
index 4f5727f0dd11062179ed302d0ae23532f92a53d0..c5600b89f6283eb4c8e00c5455123d8f0e4e8d3c 100644 (file)
@@ -1188,6 +1188,7 @@ static struct davinci_timer_info da830_timer_info = {
 static struct davinci_soc_info davinci_soc_info_da830 = {
        .io_desc                = da830_io_desc,
        .io_desc_num            = ARRAY_SIZE(da830_io_desc),
+       .jtag_id_reg            = DA8XX_SYSCFG0_BASE + DA8XX_JTAG_ID_REG,
        .ids                    = da830_ids,
        .ids_num                = ARRAY_SIZE(da830_ids),
        .cpu_clks               = da830_clks,
@@ -1215,8 +1216,6 @@ void __init da830_init(void)
        if (WARN(!da8xx_syscfg0_base, "Unable to map syscfg0 module"))
                return;
 
-       davinci_soc_info_da830.jtag_id_base =
-                                       DA8XX_SYSCFG0_VIRT(DA8XX_JTAG_ID_REG);
        davinci_soc_info_da830.pinmux_base = DA8XX_SYSCFG0_VIRT(0x120);
 
        davinci_common_init(&davinci_soc_info_da830);
index cb7f66300525b584df17240d2bd4c0aa426db064..fcf701628590f8d85b98702d80003c8bf25db287 100644 (file)
@@ -1073,6 +1073,7 @@ no_ddrpll_mem:
 static struct davinci_soc_info davinci_soc_info_da850 = {
        .io_desc                = da850_io_desc,
        .io_desc_num            = ARRAY_SIZE(da850_io_desc),
+       .jtag_id_reg            = DA8XX_SYSCFG0_BASE + DA8XX_JTAG_ID_REG,
        .ids                    = da850_ids,
        .ids_num                = ARRAY_SIZE(da850_ids),
        .cpu_clks               = da850_clks,
@@ -1108,8 +1109,6 @@ void __init da850_init(void)
        if (WARN(!da8xx_syscfg1_base, "Unable to map syscfg1 module"))
                return;
 
-       davinci_soc_info_da850.jtag_id_base =
-                                       DA8XX_SYSCFG0_VIRT(DA8XX_JTAG_ID_REG);
        davinci_soc_info_da850.pinmux_base = DA8XX_SYSCFG0_VIRT(0x120);
 
        davinci_common_init(&davinci_soc_info_da850);
index 277041dcd9a164fd2d5adb419c78a9b622b2b4fd..228b6d1460e5af7e9122b1f98d41b7ee277dd32d 100644 (file)
@@ -840,7 +840,7 @@ static struct platform_device dm355_serial_device = {
 static struct davinci_soc_info davinci_soc_info_dm355 = {
        .io_desc                = dm355_io_desc,
        .io_desc_num            = ARRAY_SIZE(dm355_io_desc),
-       .jtag_id_base           = IO_ADDRESS(0x01c40028),
+       .jtag_id_reg            = 0x01c40028,
        .ids                    = dm355_ids,
        .ids_num                = ARRAY_SIZE(dm355_ids),
        .cpu_clks               = dm355_clks,
index ecdbc676b4dd2146a893128b90e89c110a2e780e..b396d58f130acc70e80b6cc4249303aacab488f0 100644 (file)
@@ -1045,7 +1045,7 @@ static struct platform_device dm365_serial_device = {
 static struct davinci_soc_info davinci_soc_info_dm365 = {
        .io_desc                = dm365_io_desc,
        .io_desc_num            = ARRAY_SIZE(dm365_io_desc),
-       .jtag_id_base           = IO_ADDRESS(0x01c40028),
+       .jtag_id_reg            = 0x01c40028,
        .ids                    = dm365_ids,
        .ids_num                = ARRAY_SIZE(dm365_ids),
        .cpu_clks               = dm365_clks,
index beb315c04b7598700ae04e4271f7d43cf89a82cb..9859567788c9eef8ded2f1e34f5acf12d66cbb24 100644 (file)
@@ -731,7 +731,7 @@ static struct platform_device dm644x_serial_device = {
 static struct davinci_soc_info davinci_soc_info_dm644x = {
        .io_desc                = dm644x_io_desc,
        .io_desc_num            = ARRAY_SIZE(dm644x_io_desc),
-       .jtag_id_base           = IO_ADDRESS(0x01c40028),
+       .jtag_id_reg            = 0x01c40028,
        .ids                    = dm644x_ids,
        .ids_num                = ARRAY_SIZE(dm644x_ids),
        .cpu_clks               = dm644x_clks,
index 95fc981e45af241a0830e4805df362c14b02ffa1..f9a8cc46eafdffab3b47f11f83c6caf0cbb8ee7b 100644 (file)
@@ -815,7 +815,7 @@ static struct platform_device dm646x_serial_device = {
 static struct davinci_soc_info davinci_soc_info_dm646x = {
        .io_desc                = dm646x_io_desc,
        .io_desc_num            = ARRAY_SIZE(dm646x_io_desc),
-       .jtag_id_base           = IO_ADDRESS(0x01c40028),
+       .jtag_id_reg            = 0x01c40028,
        .ids                    = dm646x_ids,
        .ids_num                = ARRAY_SIZE(dm646x_ids),
        .cpu_clks               = dm646x_clks,
index 2dd2226507a765292c6e91a7243451ee1d6ce2ff..1078458bdd54ab46908f4246ba47c2bfefbb28ef 100644 (file)
@@ -45,7 +45,7 @@ struct davinci_soc_info {
        unsigned long                   io_desc_num;
        u32                             cpu_id;
        u32                             jtag_id;
-       void __iomem                    *jtag_id_base;
+       u32                             jtag_id_reg;
        struct davinci_id               *ids;
        unsigned long                   ids_num;
        struct clk_lookup               *cpu_clks;