Skip to content

Commit 08ff97b

Browse files
author
Uwe Kleine-König
committed
ARM: imx: use MXxy_IO_P2V macros to setup static mappings
This makes less code rely on the virtual constants. To further simplify code and reduce the needed boilerplate when defining the static mappings a new helper macro is defined in mach/hardware.h. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
1 parent f5d7a13 commit 08ff97b

File tree

8 files changed

+56
-166
lines changed

8 files changed

+56
-166
lines changed

arch/arm/mach-imx/mm-imx1.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@
2525
#include <mach/hardware.h>
2626

2727
static struct map_desc imx_io_desc[] __initdata = {
28-
{
29-
.virtual = MX1_IO_BASE_ADDR_VIRT,
30-
.pfn = __phys_to_pfn(MX1_IO_BASE_ADDR),
31-
.length = MX1_IO_SIZE,
32-
.type = MT_DEVICE
33-
}
28+
imx_map_entry(MX1, IO, MT_DEVICE),
3429
};
3530

3631
void __init mx1_map_io(void)

arch/arm/mach-imx/mm-imx21.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,33 +35,18 @@ static struct map_desc imx21_io_desc[] __initdata = {
3535
* - ROM Patch
3636
* - and some reserved space
3737
*/
38-
{
39-
.virtual = MX21_AIPI_BASE_ADDR_VIRT,
40-
.pfn = __phys_to_pfn(MX21_AIPI_BASE_ADDR),
41-
.length = MX21_AIPI_SIZE,
42-
.type = MT_DEVICE
43-
},
38+
imx_map_entry(MX21, AIPI, MT_DEVICE),
4439
/*
4540
* this fixed mapping covers:
4641
* - CSI
4742
* - ATA
4843
*/
49-
{
50-
.virtual = MX21_SAHB1_BASE_ADDR_VIRT,
51-
.pfn = __phys_to_pfn(MX21_SAHB1_BASE_ADDR),
52-
.length = MX21_SAHB1_SIZE,
53-
.type = MT_DEVICE
54-
},
44+
imx_map_entry(MX21, SAHB1, MT_DEVICE),
5545
/*
5646
* this fixed mapping covers:
5747
* - EMI
5848
*/
59-
{
60-
.virtual = MX21_X_MEMC_BASE_ADDR_VIRT,
61-
.pfn = __phys_to_pfn(MX21_X_MEMC_BASE_ADDR),
62-
.length = MX21_X_MEMC_SIZE,
63-
.type = MT_DEVICE
64-
},
49+
imx_map_entry(MX21, X_MEMC, MT_DEVICE),
6550
};
6651

6752
/*

arch/arm/mach-imx/mm-imx27.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,33 +35,18 @@ static struct map_desc imx27_io_desc[] __initdata = {
3535
* - ROM Patch
3636
* - and some reserved space
3737
*/
38-
{
39-
.virtual = MX27_AIPI_BASE_ADDR_VIRT,
40-
.pfn = __phys_to_pfn(MX27_AIPI_BASE_ADDR),
41-
.length = MX27_AIPI_SIZE,
42-
.type = MT_DEVICE
43-
},
38+
imx_map_entry(MX27, AIPI, MT_DEVICE),
4439
/*
4540
* this fixed mapping covers:
4641
* - CSI
4742
* - ATA
4843
*/
49-
{
50-
.virtual = MX27_SAHB1_BASE_ADDR_VIRT,
51-
.pfn = __phys_to_pfn(MX27_SAHB1_BASE_ADDR),
52-
.length = MX27_SAHB1_SIZE,
53-
.type = MT_DEVICE
54-
},
44+
imx_map_entry(MX27, SAHB1, MT_DEVICE),
5545
/*
5646
* this fixed mapping covers:
5747
* - EMI
5848
*/
59-
{
60-
.virtual = MX27_X_MEMC_BASE_ADDR_VIRT,
61-
.pfn = __phys_to_pfn(MX27_X_MEMC_BASE_ADDR),
62-
.length = MX27_X_MEMC_SIZE,
63-
.type = MT_DEVICE
64-
},
49+
imx_map_entry(MX27, X_MEMC, MT_DEVICE),
6550
};
6651

6752
/*

arch/arm/mach-mx25/mm.c

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,12 @@
3030

3131
/*
3232
* This table defines static virtual address mappings for I/O regions.
33-
* These are the mappings common across all MX3 boards.
33+
* These are the mappings common across all MX25 boards.
3434
*/
35-
static struct map_desc mxc_io_desc[] __initdata = {
36-
{
37-
.virtual = MX25_AVIC_BASE_ADDR_VIRT,
38-
.pfn = __phys_to_pfn(MX25_AVIC_BASE_ADDR),
39-
.length = MX25_AVIC_SIZE,
40-
.type = MT_DEVICE_NONSHARED
41-
}, {
42-
.virtual = MX25_AIPS1_BASE_ADDR_VIRT,
43-
.pfn = __phys_to_pfn(MX25_AIPS1_BASE_ADDR),
44-
.length = MX25_AIPS1_SIZE,
45-
.type = MT_DEVICE_NONSHARED
46-
}, {
47-
.virtual = MX25_AIPS2_BASE_ADDR_VIRT,
48-
.pfn = __phys_to_pfn(MX25_AIPS2_BASE_ADDR),
49-
.length = MX25_AIPS2_SIZE,
50-
.type = MT_DEVICE_NONSHARED
51-
},
35+
static struct map_desc mx25_io_desc[] __initdata = {
36+
imx_map_entry(MX25, AVIC, MT_DEVICE_NONSHARED),
37+
imx_map_entry(MX25, AIPS1, MT_DEVICE_NONSHARED),
38+
imx_map_entry(MX25, AIPS2, MT_DEVICE_NONSHARED),
5239
};
5340

5441
/*
@@ -62,7 +49,7 @@ void __init mx25_map_io(void)
6249
mxc_iomux_v3_init(MX25_IO_ADDRESS(MX25_IOMUXC_BASE_ADDR));
6350
mxc_arch_reset_init(MX25_IO_ADDRESS(MX25_WDOG_BASE_ADDR));
6451

65-
iotable_init(mxc_io_desc, ARRAY_SIZE(mxc_io_desc));
52+
iotable_init(mx25_io_desc, ARRAY_SIZE(mx25_io_desc));
6653
}
6754

6855
int imx25_register_gpios(void);

arch/arm/mach-mx3/mm.c

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -36,40 +36,16 @@
3636
* @ingroup Memory
3737
*/
3838

39-
/*!
40-
* This table defines static virtual address mappings for I/O regions.
41-
* These are the mappings common across all MX3 boards.
42-
*/
43-
static struct map_desc mxc_io_desc[] __initdata = {
44-
{
45-
.virtual = MX3x_X_MEMC_BASE_ADDR_VIRT,
46-
.pfn = __phys_to_pfn(MX3x_X_MEMC_BASE_ADDR),
47-
.length = MX3x_X_MEMC_SIZE,
48-
.type = MT_DEVICE
49-
}, {
50-
.virtual = MX3x_AVIC_BASE_ADDR_VIRT,
51-
.pfn = __phys_to_pfn(MX3x_AVIC_BASE_ADDR),
52-
.length = MX3x_AVIC_SIZE,
53-
.type = MT_DEVICE_NONSHARED
54-
}, {
55-
.virtual = MX3x_AIPS1_BASE_ADDR_VIRT,
56-
.pfn = __phys_to_pfn(MX3x_AIPS1_BASE_ADDR),
57-
.length = MX3x_AIPS1_SIZE,
58-
.type = MT_DEVICE_NONSHARED
59-
}, {
60-
.virtual = MX3x_AIPS2_BASE_ADDR_VIRT,
61-
.pfn = __phys_to_pfn(MX3x_AIPS2_BASE_ADDR),
62-
.length = MX3x_AIPS2_SIZE,
63-
.type = MT_DEVICE_NONSHARED
64-
}, {
65-
.virtual = MX3x_SPBA0_BASE_ADDR_VIRT,
66-
.pfn = __phys_to_pfn(MX3x_SPBA0_BASE_ADDR),
67-
.length = MX3x_SPBA0_SIZE,
68-
.type = MT_DEVICE_NONSHARED
69-
},
39+
#ifdef CONFIG_ARCH_MX31
40+
static struct map_desc mx31_io_desc[] __initdata = {
41+
imx_map_entry(MX31, X_MEMC, MT_DEVICE),
42+
imx_map_entry(MX31, AVIC, MT_DEVICE_NONSHARED),
43+
imx_map_entry(MX31, AIPS1, MT_DEVICE_NONSHARED),
44+
imx_map_entry(MX31, AIPS2, MT_DEVICE_NONSHARED),
45+
imx_map_entry(MX31, SPBA0, MT_DEVICE_NONSHARED),
7046
};
7147

72-
/*!
48+
/*
7349
* This function initializes the memory map. It is called during the
7450
* system startup to create static physical to virtual memory mappings
7551
* for the IO modules.
@@ -79,17 +55,26 @@ void __init mx31_map_io(void)
7955
mxc_set_cpu_type(MXC_CPU_MX31);
8056
mxc_arch_reset_init(MX31_IO_ADDRESS(MX31_WDOG_BASE_ADDR));
8157

82-
iotable_init(mxc_io_desc, ARRAY_SIZE(mxc_io_desc));
58+
iotable_init(mx31_io_desc, ARRAY_SIZE(mx31_io_desc));
8359
}
60+
#endif
8461

8562
#ifdef CONFIG_ARCH_MX35
63+
static struct map_desc mx35_io_desc[] __initdata = {
64+
imx_map_entry(MX35, X_MEMC, MT_DEVICE),
65+
imx_map_entry(MX35, AVIC, MT_DEVICE_NONSHARED),
66+
imx_map_entry(MX35, AIPS1, MT_DEVICE_NONSHARED),
67+
imx_map_entry(MX35, AIPS2, MT_DEVICE_NONSHARED),
68+
imx_map_entry(MX35, SPBA0, MT_DEVICE_NONSHARED),
69+
};
70+
8671
void __init mx35_map_io(void)
8772
{
8873
mxc_set_cpu_type(MXC_CPU_MX35);
8974
mxc_iomux_v3_init(MX35_IO_ADDRESS(MX35_IOMUXC_BASE_ADDR));
9075
mxc_arch_reset_init(MX35_IO_ADDRESS(MX3x_WDOG_BASE_ADDR));
9176

92-
iotable_init(mxc_io_desc, ARRAY_SIZE(mxc_io_desc));
77+
iotable_init(mx35_io_desc, ARRAY_SIZE(mx35_io_desc));
9378
}
9479
#endif
9580

arch/arm/mach-mx5/mm.c

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,12 @@
2323
/*
2424
* Define the MX51 memory map.
2525
*/
26-
static struct map_desc mxc_io_desc[] __initdata = {
27-
{
28-
.virtual = MX51_IRAM_BASE_ADDR_VIRT,
29-
.pfn = __phys_to_pfn(MX51_IRAM_BASE_ADDR),
30-
.length = MX51_IRAM_SIZE,
31-
.type = MT_DEVICE
32-
}, {
33-
.virtual = MX51_DEBUG_BASE_ADDR_VIRT,
34-
.pfn = __phys_to_pfn(MX51_DEBUG_BASE_ADDR),
35-
.length = MX51_DEBUG_SIZE,
36-
.type = MT_DEVICE
37-
}, {
38-
.virtual = MX51_AIPS1_BASE_ADDR_VIRT,
39-
.pfn = __phys_to_pfn(MX51_AIPS1_BASE_ADDR),
40-
.length = MX51_AIPS1_SIZE,
41-
.type = MT_DEVICE
42-
}, {
43-
.virtual = MX51_SPBA0_BASE_ADDR_VIRT,
44-
.pfn = __phys_to_pfn(MX51_SPBA0_BASE_ADDR),
45-
.length = MX51_SPBA0_SIZE,
46-
.type = MT_DEVICE
47-
}, {
48-
.virtual = MX51_AIPS2_BASE_ADDR_VIRT,
49-
.pfn = __phys_to_pfn(MX51_AIPS2_BASE_ADDR),
50-
.length = MX51_AIPS2_SIZE,
51-
.type = MT_DEVICE
52-
},
26+
static struct map_desc mx51_io_desc[] __initdata = {
27+
imx_map_entry(MX51, IRAM, MT_DEVICE),
28+
imx_map_entry(MX51, DEBUG, MT_DEVICE),
29+
imx_map_entry(MX51, AIPS1, MT_DEVICE),
30+
imx_map_entry(MX51, SPBA0, MT_DEVICE),
31+
imx_map_entry(MX51, AIPS2, MT_DEVICE),
5332
};
5433

5534
/*
@@ -62,7 +41,7 @@ void __init mx51_map_io(void)
6241
mxc_set_cpu_type(MXC_CPU_MX51);
6342
mxc_iomux_v3_init(MX51_IO_ADDRESS(MX51_IOMUXC_BASE_ADDR));
6443
mxc_arch_reset_init(MX51_IO_ADDRESS(MX51_WDOG_BASE_ADDR));
65-
iotable_init(mxc_io_desc, ARRAY_SIZE(mxc_io_desc));
44+
iotable_init(mx51_io_desc, ARRAY_SIZE(mx51_io_desc));
6645
}
6746

6847
int imx51_register_gpios(void);

arch/arm/mach-mxc91231/mm.c

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -27,48 +27,15 @@
2727
/*
2828
* This structure defines the MXC memory map.
2929
*/
30-
static struct map_desc mxc_io_desc[] __initdata = {
31-
{
32-
.virtual = MXC91231_L2CC_BASE_ADDR_VIRT,
33-
.pfn = __phys_to_pfn(MXC91231_L2CC_BASE_ADDR),
34-
.length = MXC91231_L2CC_SIZE,
35-
.type = MT_DEVICE,
36-
}, {
37-
.virtual = MXC91231_X_MEMC_BASE_ADDR_VIRT,
38-
.pfn = __phys_to_pfn(MXC91231_X_MEMC_BASE_ADDR),
39-
.length = MXC91231_X_MEMC_SIZE,
40-
.type = MT_DEVICE,
41-
}, {
42-
.virtual = MXC91231_ROMP_BASE_ADDR_VIRT,
43-
.pfn = __phys_to_pfn(MXC91231_ROMP_BASE_ADDR),
44-
.length = MXC91231_ROMP_SIZE,
45-
.type = MT_DEVICE,
46-
}, {
47-
.virtual = MXC91231_AVIC_BASE_ADDR_VIRT,
48-
.pfn = __phys_to_pfn(MXC91231_AVIC_BASE_ADDR),
49-
.length = MXC91231_AVIC_SIZE,
50-
.type = MT_DEVICE,
51-
}, {
52-
.virtual = MXC91231_AIPS1_BASE_ADDR_VIRT,
53-
.pfn = __phys_to_pfn(MXC91231_AIPS1_BASE_ADDR),
54-
.length = MXC91231_AIPS1_SIZE,
55-
.type = MT_DEVICE,
56-
}, {
57-
.virtual = MXC91231_SPBA0_BASE_ADDR_VIRT,
58-
.pfn = __phys_to_pfn(MXC91231_SPBA0_BASE_ADDR),
59-
.length = MXC91231_SPBA0_SIZE,
60-
.type = MT_DEVICE,
61-
}, {
62-
.virtual = MXC91231_SPBA1_BASE_ADDR_VIRT,
63-
.pfn = __phys_to_pfn(MXC91231_SPBA1_BASE_ADDR),
64-
.length = MXC91231_SPBA1_SIZE,
65-
.type = MT_DEVICE,
66-
}, {
67-
.virtual = MXC91231_AIPS2_BASE_ADDR_VIRT,
68-
.pfn = __phys_to_pfn(MXC91231_AIPS2_BASE_ADDR),
69-
.length = MXC91231_AIPS2_SIZE,
70-
.type = MT_DEVICE,
71-
},
30+
static struct map_desc mxc91231_io_desc[] __initdata = {
31+
imx_map_entry(MXC91231, L2CC, MT_DEVICE),
32+
imx_map_entry(MXC91231, X_MEMC, MT_DEVICE),
33+
imx_map_entry(MXC91231, ROMP, MT_DEVICE),
34+
imx_map_entry(MXC91231, AVIC, MT_DEVICE),
35+
imx_map_entry(MXC91231, AIPS1, MT_DEVICE),
36+
imx_map_entry(MXC91231, SPBA0, MT_DEVICE),
37+
imx_map_entry(MXC91231, SPBA1, MT_DEVICE),
38+
imx_map_entry(MXC91231, AIPS2, MT_DEVICE),
7239
};
7340

7441
/*
@@ -80,7 +47,7 @@ void __init mxc91231_map_io(void)
8047
{
8148
mxc_set_cpu_type(MXC_CPU_MXC91231);
8249

83-
iotable_init(mxc_io_desc, ARRAY_SIZE(mxc_io_desc));
50+
iotable_init(mxc91231_io_desc, ARRAY_SIZE(mxc91231_io_desc));
8451
}
8552

8653
int mxc91231_register_gpios(void);

arch/arm/plat-mxc/include/mach/hardware.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,11 @@
6666

6767
#include <mach/mxc.h>
6868

69+
#define imx_map_entry(soc, name, _type) { \
70+
.virtual = soc ## _IO_P2V(soc ## _ ## name ## _BASE_ADDR), \
71+
.pfn = __phys_to_pfn(soc ## _ ## name ## _BASE_ADDR), \
72+
.length = soc ## _ ## name ## _SIZE, \
73+
.type = _type, \
74+
}
75+
6976
#endif /* __ASM_ARCH_MXC_HARDWARE_H__ */

0 commit comments

Comments
 (0)