3 * arch/arm/mach-u300/core.c
6 * Copyright (C) 2007-2009 ST-Ericsson AB
7 * License terms: GNU General Public License (GPL) version 2
8 * Core platform support, IRQ handling and device definitions.
9 * Author: Linus Walleij <linus.walleij@stericsson.com>
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/spinlock.h>
14 #include <linux/interrupt.h>
15 #include <linux/bitops.h>
16 #include <linux/device.h>
18 #include <linux/termios.h>
19 #include <linux/amba/bus.h>
20 #include <linux/platform_device.h>
21 #include <linux/gpio.h>
23 #include <asm/types.h>
24 #include <asm/setup.h>
25 #include <asm/memory.h>
26 #include <asm/hardware/vic.h>
27 #include <asm/mach/map.h>
28 #include <asm/mach/irq.h>
30 #include <mach/hardware.h>
31 #include <mach/syscon.h>
39 * Static I/O mappings that are needed for booting the U300 platforms. The
40 * only things we need are the areas where we find the timer, syscon and
41 * intcon, since the remaining device drivers will map their own memory
42 * physical to virtual as the need arise.
44 static struct map_desc u300_io_desc
[] __initdata
= {
46 .virtual = U300_SLOW_PER_VIRT_BASE
,
47 .pfn
= __phys_to_pfn(U300_SLOW_PER_PHYS_BASE
),
52 .virtual = U300_AHB_PER_VIRT_BASE
,
53 .pfn
= __phys_to_pfn(U300_AHB_PER_PHYS_BASE
),
58 .virtual = U300_FAST_PER_VIRT_BASE
,
59 .pfn
= __phys_to_pfn(U300_FAST_PER_PHYS_BASE
),
64 .virtual = 0xffff2000, /* TCM memory */
65 .pfn
= __phys_to_pfn(0xffff2000),
71 * This overlaps with the IRQ vectors etc at 0xffff0000, so these
72 * may have to be moved to 0x00000000 in order to use the ROM.
76 .virtual = U300_BOOTROM_VIRT_BASE,
77 .pfn = __phys_to_pfn(U300_BOOTROM_PHYS_BASE),
84 void __init
u300_map_io(void)
86 iotable_init(u300_io_desc
, ARRAY_SIZE(u300_io_desc
));
90 * Declaration of devices found on the U300 board and
91 * their respective memory locations.
93 static struct amba_device uart0_device
= {
95 .init_name
= "uart0", /* Slow device at 0x3000 offset */
96 .platform_data
= NULL
,
99 .start
= U300_UART0_BASE
,
100 .end
= U300_UART0_BASE
+ SZ_4K
- 1,
101 .flags
= IORESOURCE_MEM
,
103 .irq
= { IRQ_U300_UART0
, NO_IRQ
},
106 /* The U335 have an additional UART1 on the APP CPU */
107 #ifdef CONFIG_MACH_U300_BS335
108 static struct amba_device uart1_device
= {
110 .init_name
= "uart1", /* Fast device at 0x7000 offset */
111 .platform_data
= NULL
,
114 .start
= U300_UART1_BASE
,
115 .end
= U300_UART1_BASE
+ SZ_4K
- 1,
116 .flags
= IORESOURCE_MEM
,
118 .irq
= { IRQ_U300_UART1
, NO_IRQ
},
122 static struct amba_device pl172_device
= {
124 .init_name
= "pl172", /* AHB device at 0x4000 offset */
125 .platform_data
= NULL
,
128 .start
= U300_EMIF_CFG_BASE
,
129 .end
= U300_EMIF_CFG_BASE
+ SZ_4K
- 1,
130 .flags
= IORESOURCE_MEM
,
136 * Everything within this next ifdef deals with external devices connected to
139 static struct amba_device pl022_device
= {
141 .coherent_dma_mask
= ~0,
142 .init_name
= "pl022", /* Fast device at 0x6000 offset */
145 .start
= U300_SPI_BASE
,
146 .end
= U300_SPI_BASE
+ SZ_4K
- 1,
147 .flags
= IORESOURCE_MEM
,
149 .irq
= {IRQ_U300_SPI
, NO_IRQ
},
151 * This device has a DMA channel but the Linux driver does not use
156 static struct amba_device mmcsd_device
= {
158 .init_name
= "mmci", /* Fast device at 0x1000 offset */
159 .platform_data
= NULL
, /* Added later */
162 .start
= U300_MMCSD_BASE
,
163 .end
= U300_MMCSD_BASE
+ SZ_4K
- 1,
164 .flags
= IORESOURCE_MEM
,
166 .irq
= {IRQ_U300_MMCSD_MCIINTR0
, IRQ_U300_MMCSD_MCIINTR1
},
168 * This device has a DMA channel but the Linux driver does not use
174 * The order of device declaration may be important, since some devices
175 * have dependencies on other devices being initialized first.
177 static struct amba_device
*amba_devs
[] __initdata
= {
179 #ifdef CONFIG_MACH_U300_BS335
187 /* Here follows a list of all hw resources that the platform devices
188 * allocate. Note, clock dependencies are not included
191 static struct resource gpio_resources
[] = {
193 .start
= U300_GPIO_BASE
,
194 .end
= (U300_GPIO_BASE
+ SZ_4K
- 1),
195 .flags
= IORESOURCE_MEM
,
199 .start
= IRQ_U300_GPIO_PORT0
,
200 .end
= IRQ_U300_GPIO_PORT0
,
201 .flags
= IORESOURCE_IRQ
,
205 .start
= IRQ_U300_GPIO_PORT1
,
206 .end
= IRQ_U300_GPIO_PORT1
,
207 .flags
= IORESOURCE_IRQ
,
211 .start
= IRQ_U300_GPIO_PORT2
,
212 .end
= IRQ_U300_GPIO_PORT2
,
213 .flags
= IORESOURCE_IRQ
,
215 #ifdef U300_COH901571_3
218 .start
= IRQ_U300_GPIO_PORT3
,
219 .end
= IRQ_U300_GPIO_PORT3
,
220 .flags
= IORESOURCE_IRQ
,
224 .start
= IRQ_U300_GPIO_PORT4
,
225 .end
= IRQ_U300_GPIO_PORT4
,
226 .flags
= IORESOURCE_IRQ
,
228 #ifdef CONFIG_MACH_U300_BS335
231 .start
= IRQ_U300_GPIO_PORT5
,
232 .end
= IRQ_U300_GPIO_PORT5
,
233 .flags
= IORESOURCE_IRQ
,
237 .start
= IRQ_U300_GPIO_PORT6
,
238 .end
= IRQ_U300_GPIO_PORT6
,
239 .flags
= IORESOURCE_IRQ
,
241 #endif /* CONFIG_MACH_U300_BS335 */
242 #endif /* U300_COH901571_3 */
245 static struct resource keypad_resources
[] = {
247 .start
= U300_KEYPAD_BASE
,
248 .end
= U300_KEYPAD_BASE
+ SZ_4K
- 1,
249 .flags
= IORESOURCE_MEM
,
252 .name
= "coh901461-press",
253 .start
= IRQ_U300_KEYPAD_KEYBF
,
254 .end
= IRQ_U300_KEYPAD_KEYBF
,
255 .flags
= IORESOURCE_IRQ
,
258 .name
= "coh901461-release",
259 .start
= IRQ_U300_KEYPAD_KEYBR
,
260 .end
= IRQ_U300_KEYPAD_KEYBR
,
261 .flags
= IORESOURCE_IRQ
,
265 static struct resource rtc_resources
[] = {
267 .start
= U300_RTC_BASE
,
268 .end
= U300_RTC_BASE
+ SZ_4K
- 1,
269 .flags
= IORESOURCE_MEM
,
272 .start
= IRQ_U300_RTC
,
274 .flags
= IORESOURCE_IRQ
,
279 * Fsmc does have IRQs: #43 and #44 (NFIF and NFIF2)
280 * but these are not yet used by the driver.
282 static struct resource fsmc_resources
[] = {
284 .start
= U300_NAND_IF_PHYS_BASE
,
285 .end
= U300_NAND_IF_PHYS_BASE
+ SZ_4K
- 1,
286 .flags
= IORESOURCE_MEM
,
290 static struct resource i2c0_resources
[] = {
292 .start
= U300_I2C0_BASE
,
293 .end
= U300_I2C0_BASE
+ SZ_4K
- 1,
294 .flags
= IORESOURCE_MEM
,
297 .start
= IRQ_U300_I2C0
,
298 .end
= IRQ_U300_I2C0
,
299 .flags
= IORESOURCE_IRQ
,
303 static struct resource i2c1_resources
[] = {
305 .start
= U300_I2C1_BASE
,
306 .end
= U300_I2C1_BASE
+ SZ_4K
- 1,
307 .flags
= IORESOURCE_MEM
,
310 .start
= IRQ_U300_I2C1
,
311 .end
= IRQ_U300_I2C1
,
312 .flags
= IORESOURCE_IRQ
,
317 static struct resource wdog_resources
[] = {
319 .start
= U300_WDOG_BASE
,
320 .end
= U300_WDOG_BASE
+ SZ_4K
- 1,
321 .flags
= IORESOURCE_MEM
,
324 .start
= IRQ_U300_WDOG
,
325 .end
= IRQ_U300_WDOG
,
326 .flags
= IORESOURCE_IRQ
,
330 /* TODO: These should be protected by suitable #ifdef's */
331 static struct resource ave_resources
[] = {
333 .name
= "AVE3e I/O Area",
334 .start
= U300_VIDEOENC_BASE
,
335 .end
= U300_VIDEOENC_BASE
+ SZ_512K
- 1,
336 .flags
= IORESOURCE_MEM
,
339 .name
= "AVE3e IRQ0",
340 .start
= IRQ_U300_VIDEO_ENC_0
,
341 .end
= IRQ_U300_VIDEO_ENC_0
,
342 .flags
= IORESOURCE_IRQ
,
345 .name
= "AVE3e IRQ1",
346 .start
= IRQ_U300_VIDEO_ENC_1
,
347 .end
= IRQ_U300_VIDEO_ENC_1
,
348 .flags
= IORESOURCE_IRQ
,
351 .name
= "AVE3e Physmem Area",
352 .start
= 0, /* 0 will be remapped to reserved memory */
354 .flags
= IORESOURCE_MEM
,
357 * The AVE3e requires two regions of 256MB that it considers
358 * "invisible". The hardware will not be able to access these
359 * adresses, so they should never point to system RAM.
362 .name
= "AVE3e Reserved 0",
364 .end
= 0xd0000000 + SZ_256M
- 1,
365 .flags
= IORESOURCE_MEM
,
368 .name
= "AVE3e Reserved 1",
370 .end
= 0xe0000000 + SZ_256M
- 1,
371 .flags
= IORESOURCE_MEM
,
375 static struct platform_device wdog_device
= {
378 .num_resources
= ARRAY_SIZE(wdog_resources
),
379 .resource
= wdog_resources
,
382 static struct platform_device i2c0_device
= {
385 .num_resources
= ARRAY_SIZE(i2c0_resources
),
386 .resource
= i2c0_resources
,
389 static struct platform_device i2c1_device
= {
392 .num_resources
= ARRAY_SIZE(i2c1_resources
),
393 .resource
= i2c1_resources
,
396 static struct platform_device gpio_device
= {
399 .num_resources
= ARRAY_SIZE(gpio_resources
),
400 .resource
= gpio_resources
,
403 static struct platform_device keypad_device
= {
406 .num_resources
= ARRAY_SIZE(keypad_resources
),
407 .resource
= keypad_resources
,
410 static struct platform_device rtc_device
= {
413 .num_resources
= ARRAY_SIZE(rtc_resources
),
414 .resource
= rtc_resources
,
417 static struct platform_device fsmc_device
= {
420 .num_resources
= ARRAY_SIZE(fsmc_resources
),
421 .resource
= fsmc_resources
,
424 static struct platform_device ave_device
= {
427 .num_resources
= ARRAY_SIZE(ave_resources
),
428 .resource
= ave_resources
,
432 * Notice that AMBA devices are initialized before platform devices.
435 static struct platform_device
*platform_devs
[] __initdata
= {
448 * Interrupts: the U300 platforms have two pl190 ARM PrimeCells connected
449 * together so some interrupts are connected to the first one and some
452 void __init
u300_init_irq(void)
454 u32 mask
[2] = {0, 0};
457 for (i
= 0; i
< NR_IRQS
; i
++)
458 set_bit(i
, (unsigned long *) &mask
[0]);
459 u300_enable_intcon_clock();
460 vic_init((void __iomem
*) U300_INTCON0_VBASE
, 0, mask
[0], mask
[0]);
461 vic_init((void __iomem
*) U300_INTCON1_VBASE
, 32, mask
[1], mask
[1]);
466 * U300 platforms peripheral handling
474 * This is a list of the Digital Baseband chips used in the U300 platform.
476 static struct db_chip db_chips
[] __initdata
= {
503 .name
= "DB3350 P1x",
507 .name
= "DB3350 P2x",
510 .chipid
= 0x0000, /* List terminator */
515 static void __init
u300_init_check_chip(void)
519 struct db_chip
*chip
;
520 const char *chipname
;
521 const char unknown
[] = "UNKNOWN";
523 /* Read out and print chip ID */
524 val
= readw(U300_SYSCON_VBASE
+ U300_SYSCON_CIDR
);
525 /* This is in funky bigendian order... */
526 val
= (val
& 0xFFU
) << 8 | (val
>> 8);
530 for ( ; chip
->chipid
; chip
++) {
531 if (chip
->chipid
== (val
& 0xFF00U
)) {
532 chipname
= chip
->name
;
536 printk(KERN_INFO
"Initializing U300 system on %s baseband chip " \
537 "(chip ID 0x%04x)\n", chipname
, val
);
539 #ifdef CONFIG_MACH_U300_BS26
540 if ((val
& 0xFF00U
) != 0xc800) {
541 printk(KERN_ERR
"Platform configured for BS25/BS26 " \
542 "with DB3150 but %s detected, expect problems!",
546 #ifdef CONFIG_MACH_U300_BS330
547 if ((val
& 0xFF00U
) != 0xd800) {
548 printk(KERN_ERR
"Platform configured for BS330 " \
549 "with DB3200 but %s detected, expect problems!",
553 #ifdef CONFIG_MACH_U300_BS335
554 if ((val
& 0xFF00U
) != 0xf000 && (val
& 0xFF00U
) != 0xf100) {
555 printk(KERN_ERR
"Platform configured for BS365 " \
556 " with DB3350 but %s detected, expect problems!",
560 #ifdef CONFIG_MACH_U300_BS365
561 if ((val
& 0xFF00U
) != 0xe800) {
562 printk(KERN_ERR
"Platform configured for BS365 " \
563 "with DB3210 but %s detected, expect problems!",
572 * Some devices and their resources require reserved physical memory from
573 * the end of the available RAM. This function traverses the list of devices
574 * and assigns actual adresses to these.
576 static void __init
u300_assign_physmem(void)
578 unsigned long curr_start
= __pa(high_memory
);
581 for (i
= 0; i
< ARRAY_SIZE(platform_devs
); i
++) {
582 for (j
= 0; j
< platform_devs
[i
]->num_resources
; j
++) {
583 struct resource
*const res
=
584 &platform_devs
[i
]->resource
[j
];
586 if (IORESOURCE_MEM
== res
->flags
&&
588 res
->start
= curr_start
;
589 res
->end
+= curr_start
;
590 curr_start
+= (res
->end
- res
->start
+ 1);
592 printk(KERN_INFO
"core.c: Mapping RAM " \
593 "%#x-%#x to device %s:%s\n",
594 res
->start
, res
->end
,
595 platform_devs
[i
]->name
, res
->name
);
601 void __init
u300_init_devices(void)
606 /* Check what platform we run and print some status information */
607 u300_init_check_chip();
609 /* Set system to run at PLL208, max performance, a known state. */
610 val
= readw(U300_SYSCON_VBASE
+ U300_SYSCON_CCR
);
611 val
&= ~U300_SYSCON_CCR_CLKING_PERFORMANCE_MASK
;
612 writew(val
, U300_SYSCON_VBASE
+ U300_SYSCON_CCR
);
613 /* Wait for the PLL208 to lock if not locked in yet */
614 while (!(readw(U300_SYSCON_VBASE
+ U300_SYSCON_CSR
) &
615 U300_SYSCON_CSR_PLL208_LOCK_IND
));
616 /* Initialize SPI device with some board specifics */
617 u300_spi_init(&pl022_device
);
619 /* Register the AMBA devices in the AMBA bus abstraction layer */
620 u300_clock_primecells();
621 for (i
= 0; i
< ARRAY_SIZE(amba_devs
); i
++) {
622 struct amba_device
*d
= amba_devs
[i
];
623 amba_device_register(d
, &iomem_resource
);
625 u300_unclock_primecells();
627 u300_assign_physmem();
629 /* Register subdevices on the I2C buses */
630 u300_i2c_register_board_devices();
632 /* Register subdevices on the SPI bus */
633 u300_spi_register_board_devices();
635 /* Register the platform devices */
636 platform_add_devices(platform_devs
, ARRAY_SIZE(platform_devs
));
638 #ifndef CONFIG_MACH_U300_SEMI_IS_SHARED
640 * Enable SEMI self refresh. Self-refresh of the SDRAM is entered when
641 * both subsystems are requesting this mode.
642 * If we not share the Acc SDRAM, this is never the case. Therefore
643 * enable it here from the App side.
645 val
= readw(U300_SYSCON_VBASE
+ U300_SYSCON_SMCR
) |
646 U300_SYSCON_SMCR_SEMI_SREFREQ_ENABLE
;
647 writew(val
, U300_SYSCON_VBASE
+ U300_SYSCON_SMCR
);
648 #endif /* CONFIG_MACH_U300_SEMI_IS_SHARED */
651 static int core_module_init(void)
654 * This needs to be initialized later: it needs the input framework
655 * to be initialized first.
657 return mmc_init(&mmcsd_device
);
659 module_init(core_module_init
);