Commit 3347db83 authored by Cyril Chemparathy's avatar Cyril Chemparathy Committed by Kevin Hilman

Davinci: jtag_id - use ioremap()

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: default avatarCyril Chemparathy <cyril@ti.com>
Signed-off-by: default avatarKevin Hilman <khilman@deeprootsystems.com>
parent db6db5d8
...@@ -37,26 +37,43 @@ void davinci_get_mac_addr(struct memory_accessor *mem_acc, void *context) ...@@ -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); 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; int i;
struct davinci_id *dip; struct davinci_id *dip;
u8 variant = (jtag_id & 0xf0000000) >> 28; u8 variant;
u16 part_no = (jtag_id & 0x0ffff000) >> 12; 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++) i++, dip++)
/* Don't care about the manufacturer right now */ /* Don't care about the manufacturer right now */
if ((dip->part_no == part_no) && (dip->variant == variant)) if ((dip->part_no == part_no) && (dip->variant == variant)) {
return dip; soc_info->cpu_id = dip->cpu_id;
pr_info("DaVinci %s variant 0x%x\n", dip->name,
return NULL; 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) void __init davinci_common_init(struct davinci_soc_info *soc_info)
{ {
int ret; int ret;
struct davinci_id *dip;
if (!soc_info) { if (!soc_info) {
ret = -EINVAL; ret = -EINVAL;
...@@ -84,18 +101,9 @@ void __init davinci_common_init(struct davinci_soc_info *soc_info) ...@@ -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. * We want to check CPU revision early for cpu_is_xxxx() macros.
* IO space mapping must be initialized before we can do that. * IO space mapping must be initialized before we can do that.
*/ */
davinci_soc_info.jtag_id = __raw_readl(davinci_soc_info.jtag_id_base); ret = davinci_init_id(&davinci_soc_info);
if (ret < 0)
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);
goto err; 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) { if (davinci_soc_info.cpu_clks) {
ret = davinci_clk_init(davinci_soc_info.cpu_clks); ret = davinci_clk_init(davinci_soc_info.cpu_clks);
......
...@@ -1188,6 +1188,7 @@ static struct davinci_timer_info da830_timer_info = { ...@@ -1188,6 +1188,7 @@ static struct davinci_timer_info da830_timer_info = {
static struct davinci_soc_info davinci_soc_info_da830 = { static struct davinci_soc_info davinci_soc_info_da830 = {
.io_desc = da830_io_desc, .io_desc = da830_io_desc,
.io_desc_num = ARRAY_SIZE(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 = da830_ids,
.ids_num = ARRAY_SIZE(da830_ids), .ids_num = ARRAY_SIZE(da830_ids),
.cpu_clks = da830_clks, .cpu_clks = da830_clks,
...@@ -1215,8 +1216,6 @@ void __init da830_init(void) ...@@ -1215,8 +1216,6 @@ void __init da830_init(void)
if (WARN(!da8xx_syscfg0_base, "Unable to map syscfg0 module")) if (WARN(!da8xx_syscfg0_base, "Unable to map syscfg0 module"))
return; 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_soc_info_da830.pinmux_base = DA8XX_SYSCFG0_VIRT(0x120);
davinci_common_init(&davinci_soc_info_da830); davinci_common_init(&davinci_soc_info_da830);
......
...@@ -1073,6 +1073,7 @@ no_ddrpll_mem: ...@@ -1073,6 +1073,7 @@ no_ddrpll_mem:
static struct davinci_soc_info davinci_soc_info_da850 = { static struct davinci_soc_info davinci_soc_info_da850 = {
.io_desc = da850_io_desc, .io_desc = da850_io_desc,
.io_desc_num = ARRAY_SIZE(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 = da850_ids,
.ids_num = ARRAY_SIZE(da850_ids), .ids_num = ARRAY_SIZE(da850_ids),
.cpu_clks = da850_clks, .cpu_clks = da850_clks,
...@@ -1108,8 +1109,6 @@ void __init da850_init(void) ...@@ -1108,8 +1109,6 @@ void __init da850_init(void)
if (WARN(!da8xx_syscfg1_base, "Unable to map syscfg1 module")) if (WARN(!da8xx_syscfg1_base, "Unable to map syscfg1 module"))
return; 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_soc_info_da850.pinmux_base = DA8XX_SYSCFG0_VIRT(0x120);
davinci_common_init(&davinci_soc_info_da850); davinci_common_init(&davinci_soc_info_da850);
......
...@@ -840,7 +840,7 @@ static struct platform_device dm355_serial_device = { ...@@ -840,7 +840,7 @@ static struct platform_device dm355_serial_device = {
static struct davinci_soc_info davinci_soc_info_dm355 = { static struct davinci_soc_info davinci_soc_info_dm355 = {
.io_desc = dm355_io_desc, .io_desc = dm355_io_desc,
.io_desc_num = ARRAY_SIZE(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 = dm355_ids,
.ids_num = ARRAY_SIZE(dm355_ids), .ids_num = ARRAY_SIZE(dm355_ids),
.cpu_clks = dm355_clks, .cpu_clks = dm355_clks,
......
...@@ -1045,7 +1045,7 @@ static struct platform_device dm365_serial_device = { ...@@ -1045,7 +1045,7 @@ static struct platform_device dm365_serial_device = {
static struct davinci_soc_info davinci_soc_info_dm365 = { static struct davinci_soc_info davinci_soc_info_dm365 = {
.io_desc = dm365_io_desc, .io_desc = dm365_io_desc,
.io_desc_num = ARRAY_SIZE(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 = dm365_ids,
.ids_num = ARRAY_SIZE(dm365_ids), .ids_num = ARRAY_SIZE(dm365_ids),
.cpu_clks = dm365_clks, .cpu_clks = dm365_clks,
......
...@@ -731,7 +731,7 @@ static struct platform_device dm644x_serial_device = { ...@@ -731,7 +731,7 @@ static struct platform_device dm644x_serial_device = {
static struct davinci_soc_info davinci_soc_info_dm644x = { static struct davinci_soc_info davinci_soc_info_dm644x = {
.io_desc = dm644x_io_desc, .io_desc = dm644x_io_desc,
.io_desc_num = ARRAY_SIZE(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 = dm644x_ids,
.ids_num = ARRAY_SIZE(dm644x_ids), .ids_num = ARRAY_SIZE(dm644x_ids),
.cpu_clks = dm644x_clks, .cpu_clks = dm644x_clks,
......
...@@ -815,7 +815,7 @@ static struct platform_device dm646x_serial_device = { ...@@ -815,7 +815,7 @@ static struct platform_device dm646x_serial_device = {
static struct davinci_soc_info davinci_soc_info_dm646x = { static struct davinci_soc_info davinci_soc_info_dm646x = {
.io_desc = dm646x_io_desc, .io_desc = dm646x_io_desc,
.io_desc_num = ARRAY_SIZE(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 = dm646x_ids,
.ids_num = ARRAY_SIZE(dm646x_ids), .ids_num = ARRAY_SIZE(dm646x_ids),
.cpu_clks = dm646x_clks, .cpu_clks = dm646x_clks,
......
...@@ -45,7 +45,7 @@ struct davinci_soc_info { ...@@ -45,7 +45,7 @@ struct davinci_soc_info {
unsigned long io_desc_num; unsigned long io_desc_num;
u32 cpu_id; u32 cpu_id;
u32 jtag_id; u32 jtag_id;
void __iomem *jtag_id_base; u32 jtag_id_reg;
struct davinci_id *ids; struct davinci_id *ids;
unsigned long ids_num; unsigned long ids_num;
struct clk_lookup *cpu_clks; struct clk_lookup *cpu_clks;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment