aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2011-05-09 15:20:09 -0400
committerArnd Bergmann <arnd@arndb.de>2011-07-28 11:07:29 -0400
commitf0051d82a68abcf35418d49db1c82e6f0e514d78 (patch)
tree5a14645bdefe2a3c4671f456d4eb6595956c68ca /arch
parent51ddec7617bd0d4c73c44a8862faac5d7d97eb03 (diff)
at91: factorize sram init
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Cc: Nicolas Ferre <nicolas.ferre@atmel.com> Cc: Patrice Vilchez <patrice.vilchez@atmel.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-at91/at91cap9.c11
-rw-r--r--arch/arm/mach-at91/at91rm9200.c6
-rw-r--r--arch/arm/mach-at91/at91sam9260.c53
-rw-r--r--arch/arm/mach-at91/at91sam9261.c22
-rw-r--r--arch/arm/mach-at91/at91sam9263.c17
-rw-r--r--arch/arm/mach-at91/at91sam9g45.c11
-rw-r--r--arch/arm/mach-at91/at91sam9rl.c12
-rw-r--r--arch/arm/mach-at91/generic.h2
-rw-r--r--arch/arm/mach-at91/setup.c20
9 files changed, 39 insertions, 115 deletions
diff --git a/arch/arm/mach-at91/at91cap9.c b/arch/arm/mach-at91/at91cap9.c
index 8fabf91fe2e5..bfc684441ef8 100644
--- a/arch/arm/mach-at91/at91cap9.c
+++ b/arch/arm/mach-at91/at91cap9.c
@@ -29,15 +29,6 @@
29#include "generic.h" 29#include "generic.h"
30#include "clock.h" 30#include "clock.h"
31 31
32static struct map_desc at91cap9_sram_desc[] __initdata = {
33 {
34 .virtual = AT91_IO_VIRT_BASE - AT91CAP9_SRAM_SIZE,
35 .pfn = __phys_to_pfn(AT91CAP9_SRAM_BASE),
36 .length = AT91CAP9_SRAM_SIZE,
37 .type = MT_DEVICE,
38 },
39};
40
41/* -------------------------------------------------------------------- 32/* --------------------------------------------------------------------
42 * Clocks 33 * Clocks
43 * -------------------------------------------------------------------- */ 34 * -------------------------------------------------------------------- */
@@ -337,7 +328,7 @@ static void at91cap9_poweroff(void)
337 328
338static void __init at91cap9_map_io(void) 329static void __init at91cap9_map_io(void)
339{ 330{
340 iotable_init(at91cap9_sram_desc, ARRAY_SIZE(at91cap9_sram_desc)); 331 at91_init_sram(0, AT91CAP9_SRAM_BASE, AT91CAP9_SRAM_SIZE);
341} 332}
342 333
343static void __init at91cap9_initialize(void) 334static void __init at91cap9_initialize(void)
diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c
index 010407802cdc..f73302dbc6a5 100644
--- a/arch/arm/mach-at91/at91rm9200.c
+++ b/arch/arm/mach-at91/at91rm9200.c
@@ -30,11 +30,6 @@ static struct map_desc at91rm9200_io_desc[] __initdata = {
30 .pfn = __phys_to_pfn(AT91RM9200_BASE_EMAC), 30 .pfn = __phys_to_pfn(AT91RM9200_BASE_EMAC),
31 .length = SZ_16K, 31 .length = SZ_16K,
32 .type = MT_DEVICE, 32 .type = MT_DEVICE,
33 }, {
34 .virtual = AT91_IO_VIRT_BASE - AT91RM9200_SRAM_SIZE,
35 .pfn = __phys_to_pfn(AT91RM9200_SRAM_BASE),
36 .length = AT91RM9200_SRAM_SIZE,
37 .type = MT_DEVICE,
38 }, 33 },
39}; 34};
40 35
@@ -306,6 +301,7 @@ static void at91rm9200_reset(void)
306static void __init at91rm9200_map_io(void) 301static void __init at91rm9200_map_io(void)
307{ 302{
308 /* Map peripherals */ 303 /* Map peripherals */
304 at91_init_sram(0, AT91RM9200_SRAM_BASE, AT91RM9200_SRAM_SIZE);
309 iotable_init(at91rm9200_io_desc, ARRAY_SIZE(at91rm9200_io_desc)); 305 iotable_init(at91rm9200_io_desc, ARRAY_SIZE(at91rm9200_io_desc));
310} 306}
311 307
diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index 1addfef73b6c..cb397be14448 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -27,41 +27,6 @@
27#include "generic.h" 27#include "generic.h"
28#include "clock.h" 28#include "clock.h"
29 29
30static struct map_desc at91sam9260_sram_desc[] __initdata = {
31 {
32 .virtual = AT91_IO_VIRT_BASE - AT91SAM9260_SRAM0_SIZE,
33 .pfn = __phys_to_pfn(AT91SAM9260_SRAM0_BASE),
34 .length = AT91SAM9260_SRAM0_SIZE,
35 .type = MT_DEVICE,
36 }, {
37 .virtual = AT91_IO_VIRT_BASE - AT91SAM9260_SRAM0_SIZE - AT91SAM9260_SRAM1_SIZE,
38 .pfn = __phys_to_pfn(AT91SAM9260_SRAM1_BASE),
39 .length = AT91SAM9260_SRAM1_SIZE,
40 .type = MT_DEVICE,
41 }
42};
43
44static struct map_desc at91sam9g20_sram_desc[] __initdata = {
45 {
46 .virtual = AT91_IO_VIRT_BASE - AT91SAM9G20_SRAM0_SIZE,
47 .pfn = __phys_to_pfn(AT91SAM9G20_SRAM0_BASE),
48 .length = AT91SAM9G20_SRAM0_SIZE,
49 .type = MT_DEVICE,
50 }, {
51 .virtual = AT91_IO_VIRT_BASE - AT91SAM9G20_SRAM0_SIZE - AT91SAM9G20_SRAM1_SIZE,
52 .pfn = __phys_to_pfn(AT91SAM9G20_SRAM1_BASE),
53 .length = AT91SAM9G20_SRAM1_SIZE,
54 .type = MT_DEVICE,
55 }
56};
57
58static struct map_desc at91sam9xe_sram_desc[] __initdata = {
59 {
60 .pfn = __phys_to_pfn(AT91SAM9XE_SRAM_BASE),
61 .type = MT_DEVICE,
62 }
63};
64
65/* -------------------------------------------------------------------- 30/* --------------------------------------------------------------------
66 * Clocks 31 * Clocks
67 * -------------------------------------------------------------------- */ 32 * -------------------------------------------------------------------- */
@@ -334,20 +299,20 @@ static void __init at91sam9xe_map_io(void)
334 sram_size = SZ_16K; 299 sram_size = SZ_16K;
335 } 300 }
336 301
337 at91sam9xe_sram_desc->virtual = AT91_IO_VIRT_BASE - sram_size; 302 at91_init_sram(0, AT91SAM9XE_SRAM_BASE, sram_size);
338 at91sam9xe_sram_desc->length = sram_size;
339
340 iotable_init(at91sam9xe_sram_desc, ARRAY_SIZE(at91sam9xe_sram_desc));
341} 303}
342 304
343static void __init at91sam9260_map_io(void) 305static void __init at91sam9260_map_io(void)
344{ 306{
345 if (cpu_is_at91sam9xe()) 307 if (cpu_is_at91sam9xe()) {
346 at91sam9xe_map_io(); 308 at91sam9xe_map_io();
347 else if (cpu_is_at91sam9g20()) 309 } else if (cpu_is_at91sam9g20()) {
348 iotable_init(at91sam9g20_sram_desc, ARRAY_SIZE(at91sam9g20_sram_desc)); 310 at91_init_sram(0, AT91SAM9G20_SRAM0_BASE, AT91SAM9G20_SRAM0_SIZE);
349 else 311 at91_init_sram(1, AT91SAM9G20_SRAM1_BASE, AT91SAM9G20_SRAM1_SIZE);
350 iotable_init(at91sam9260_sram_desc, ARRAY_SIZE(at91sam9260_sram_desc)); 312 } else {
313 at91_init_sram(0, AT91SAM9260_SRAM0_BASE, AT91SAM9260_SRAM0_SIZE);
314 at91_init_sram(1, AT91SAM9260_SRAM1_BASE, AT91SAM9260_SRAM1_SIZE);
315 }
351} 316}
352 317
353static void __init at91sam9260_initialize(void) 318static void __init at91sam9260_initialize(void)
diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c
index 8f97bd4a5268..d522b47e30b5 100644
--- a/arch/arm/mach-at91/at91sam9261.c
+++ b/arch/arm/mach-at91/at91sam9261.c
@@ -26,24 +26,6 @@
26#include "generic.h" 26#include "generic.h"
27#include "clock.h" 27#include "clock.h"
28 28
29static struct map_desc at91sam9261_sram_desc[] __initdata = {
30 {
31 .virtual = AT91_IO_VIRT_BASE - AT91SAM9261_SRAM_SIZE,
32 .pfn = __phys_to_pfn(AT91SAM9261_SRAM_BASE),
33 .length = AT91SAM9261_SRAM_SIZE,
34 .type = MT_DEVICE,
35 },
36};
37
38static struct map_desc at91sam9g10_sram_desc[] __initdata = {
39 {
40 .virtual = AT91_IO_VIRT_BASE - AT91SAM9G10_SRAM_SIZE,
41 .pfn = __phys_to_pfn(AT91SAM9G10_SRAM_BASE),
42 .length = AT91SAM9G10_SRAM_SIZE,
43 .type = MT_DEVICE,
44 },
45};
46
47/* -------------------------------------------------------------------- 29/* --------------------------------------------------------------------
48 * Clocks 30 * Clocks
49 * -------------------------------------------------------------------- */ 31 * -------------------------------------------------------------------- */
@@ -297,9 +279,9 @@ static void at91sam9261_poweroff(void)
297static void __init at91sam9261_map_io(void) 279static void __init at91sam9261_map_io(void)
298{ 280{
299 if (cpu_is_at91sam9g10()) 281 if (cpu_is_at91sam9g10())
300 iotable_init(at91sam9g10_sram_desc, ARRAY_SIZE(at91sam9g10_sram_desc)); 282 at91_init_sram(0, AT91SAM9G10_SRAM_BASE, AT91SAM9G10_SRAM_SIZE);
301 else 283 else
302 iotable_init(at91sam9261_sram_desc, ARRAY_SIZE(at91sam9261_sram_desc)); 284 at91_init_sram(0, AT91SAM9261_SRAM_BASE, AT91SAM9261_SRAM_SIZE);
303} 285}
304 286
305static void __init at91sam9261_initialize(void) 287static void __init at91sam9261_initialize(void)
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index da13f02acf51..044f3c927e64 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -25,20 +25,6 @@
25#include "generic.h" 25#include "generic.h"
26#include "clock.h" 26#include "clock.h"
27 27
28static struct map_desc at91sam9263_sram_desc[] __initdata = {
29 {
30 .virtual = AT91_IO_VIRT_BASE - AT91SAM9263_SRAM0_SIZE,
31 .pfn = __phys_to_pfn(AT91SAM9263_SRAM0_BASE),
32 .length = AT91SAM9263_SRAM0_SIZE,
33 .type = MT_DEVICE,
34 }, {
35 .virtual = AT91_IO_VIRT_BASE - AT91SAM9263_SRAM0_SIZE - AT91SAM9263_SRAM1_SIZE,
36 .pfn = __phys_to_pfn(AT91SAM9263_SRAM1_BASE),
37 .length = AT91SAM9263_SRAM1_SIZE,
38 .type = MT_DEVICE,
39 },
40};
41
42/* -------------------------------------------------------------------- 28/* --------------------------------------------------------------------
43 * Clocks 29 * Clocks
44 * -------------------------------------------------------------------- */ 30 * -------------------------------------------------------------------- */
@@ -311,7 +297,8 @@ static void at91sam9263_poweroff(void)
311 297
312static void __init at91sam9263_map_io(void) 298static void __init at91sam9263_map_io(void)
313{ 299{
314 iotable_init(at91sam9263_sram_desc, ARRAY_SIZE(at91sam9263_sram_desc)); 300 at91_init_sram(0, AT91SAM9263_SRAM0_BASE, AT91SAM9263_SRAM0_SIZE);
301 at91_init_sram(1, AT91SAM9263_SRAM1_BASE, AT91SAM9263_SRAM1_SIZE);
315} 302}
316 303
317static void __init at91sam9263_initialize(void) 304static void __init at91sam9263_initialize(void)
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index cbc06451a45f..e04c5fb6f1ee 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -26,15 +26,6 @@
26#include "generic.h" 26#include "generic.h"
27#include "clock.h" 27#include "clock.h"
28 28
29static struct map_desc at91sam9g45_sram_desc[] __initdata = {
30 {
31 .virtual = AT91_IO_VIRT_BASE - AT91SAM9G45_SRAM_SIZE,
32 .pfn = __phys_to_pfn(AT91SAM9G45_SRAM_BASE),
33 .length = AT91SAM9G45_SRAM_SIZE,
34 .type = MT_DEVICE,
35 }
36};
37
38/* -------------------------------------------------------------------- 29/* --------------------------------------------------------------------
39 * Clocks 30 * Clocks
40 * -------------------------------------------------------------------- */ 31 * -------------------------------------------------------------------- */
@@ -327,7 +318,7 @@ static void at91sam9g45_poweroff(void)
327 318
328static void __init at91sam9g45_map_io(void) 319static void __init at91sam9g45_map_io(void)
329{ 320{
330 iotable_init(at91sam9g45_sram_desc, ARRAY_SIZE(at91sam9g45_sram_desc)); 321 at91_init_sram(0, AT91SAM9G45_SRAM_BASE, AT91SAM9G45_SRAM_SIZE);
331} 322}
332 323
333static void __init at91sam9g45_initialize(void) 324static void __init at91sam9g45_initialize(void)
diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c
index 55ee7d0a9bf4..a238105d2c11 100644
--- a/arch/arm/mach-at91/at91sam9rl.c
+++ b/arch/arm/mach-at91/at91sam9rl.c
@@ -26,13 +26,6 @@
26#include "generic.h" 26#include "generic.h"
27#include "clock.h" 27#include "clock.h"
28 28
29static struct map_desc at91sam9rl_sram_desc[] __initdata = {
30 {
31 .pfn = __phys_to_pfn(AT91SAM9RL_SRAM_BASE),
32 .type = MT_DEVICE,
33 }
34};
35
36/* -------------------------------------------------------------------- 29/* --------------------------------------------------------------------
37 * Clocks 30 * Clocks
38 * -------------------------------------------------------------------- */ 31 * -------------------------------------------------------------------- */
@@ -293,11 +286,8 @@ static void __init at91sam9rl_map_io(void)
293 sram_size = SZ_16K; 286 sram_size = SZ_16K;
294 } 287 }
295 288
296 at91sam9rl_sram_desc->virtual = AT91_IO_VIRT_BASE - sram_size;
297 at91sam9rl_sram_desc->length = sram_size;
298
299 /* Map SRAM */ 289 /* Map SRAM */
300 iotable_init(at91sam9rl_sram_desc, ARRAY_SIZE(at91sam9rl_sram_desc)); 290 at91_init_sram(0, AT91SAM9RL_SRAM_BASE, sram_size);
301} 291}
302 292
303static void __init at91sam9rl_initialize(void) 293static void __init at91sam9rl_initialize(void)
diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
index a9d6ed4dbbc8..938b34f57741 100644
--- a/arch/arm/mach-at91/generic.h
+++ b/arch/arm/mach-at91/generic.h
@@ -12,6 +12,8 @@
12 12
13 /* Map io */ 13 /* Map io */
14extern void __init at91_map_io(void); 14extern void __init at91_map_io(void);
15extern void __init at91_init_sram(int bank, unsigned long base,
16 unsigned int length);
15 17
16 /* Processors */ 18 /* Processors */
17extern void __init at91rm9200_set_type(int type); 19extern void __init at91rm9200_set_type(int type);
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
index 43251efd90d4..816599fce55b 100644
--- a/arch/arm/mach-at91/setup.c
+++ b/arch/arm/mach-at91/setup.c
@@ -45,6 +45,26 @@ void __init at91_init_interrupts(unsigned int *priority)
45 at91_gpio_irq_setup(); 45 at91_gpio_irq_setup();
46} 46}
47 47
48static struct map_desc sram_desc[2] __initdata;
49
50void __init at91_init_sram(int bank, unsigned long base, unsigned int length)
51{
52 struct map_desc *desc = &sram_desc[bank];
53
54 desc->virtual = AT91_IO_VIRT_BASE - length;
55 if (bank > 0)
56 desc->virtual -= sram_desc[bank - 1].length;
57
58 desc->pfn = __phys_to_pfn(base);
59 desc->length = length;
60 desc->type = MT_DEVICE;
61
62 pr_info("AT91: sram at 0x%lx of 0x%x mapped at 0x%lx\n",
63 base, length, desc->virtual);
64
65 iotable_init(desc, 1);
66}
67
48static struct map_desc at91_io_desc __initdata = { 68static struct map_desc at91_io_desc __initdata = {
49 .virtual = AT91_VA_BASE_SYS, 69 .virtual = AT91_VA_BASE_SYS,
50 .pfn = __phys_to_pfn(AT91_BASE_SYS), 70 .pfn = __phys_to_pfn(AT91_BASE_SYS),