2 * arch/arm/mach-ep93xx/core.c
3 * Core routines for Cirrus EP93xx chips.
5 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
6 * Copyright (C) 2007 Herbert Valerio Riedel <hvr@gnu.org>
8 * Thanks go to Michael Burian and Ray Lehtiniemi for their key
9 * role in the ep93xx linux community.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or (at
14 * your option) any later version.
17 #define pr_fmt(fmt) "ep93xx " KBUILD_MODNAME ": " fmt
19 #include <linux/kernel.h>
20 #include <linux/init.h>
21 #include <linux/platform_device.h>
22 #include <linux/interrupt.h>
23 #include <linux/dma-mapping.h>
24 #include <linux/sys_soc.h>
25 #include <linux/irq.h>
27 #include <linux/gpio.h>
28 #include <linux/leds.h>
29 #include <linux/termios.h>
30 #include <linux/amba/bus.h>
31 #include <linux/amba/serial.h>
32 #include <linux/mtd/physmap.h>
33 #include <linux/i2c.h>
34 #include <linux/i2c-gpio.h>
35 #include <linux/spi/spi.h>
36 #include <linux/export.h>
37 #include <linux/irqchip/arm-vic.h>
38 #include <linux/reboot.h>
39 #include <linux/usb/ohci_pdriver.h>
41 #include <mach/hardware.h>
42 #include <linux/platform_data/video-ep93xx.h>
43 #include <linux/platform_data/keypad-ep93xx.h>
44 #include <linux/platform_data/spi-ep93xx.h>
45 #include <mach/gpio-ep93xx.h>
47 #include <asm/mach/arch.h>
48 #include <asm/mach/map.h>
52 /*************************************************************************
53 * Static I/O mappings that are needed for all EP93xx platforms
54 *************************************************************************/
55 static struct map_desc ep93xx_io_desc
[] __initdata
= {
57 .virtual = EP93XX_AHB_VIRT_BASE
,
58 .pfn
= __phys_to_pfn(EP93XX_AHB_PHYS_BASE
),
59 .length
= EP93XX_AHB_SIZE
,
62 .virtual = EP93XX_APB_VIRT_BASE
,
63 .pfn
= __phys_to_pfn(EP93XX_APB_PHYS_BASE
),
64 .length
= EP93XX_APB_SIZE
,
69 void __init
ep93xx_map_io(void)
71 iotable_init(ep93xx_io_desc
, ARRAY_SIZE(ep93xx_io_desc
));
74 /*************************************************************************
76 *************************************************************************/
77 void __init
ep93xx_init_irq(void)
79 vic_init(EP93XX_VIC1_BASE
, 0, EP93XX_VIC1_VALID_IRQ_MASK
, 0);
80 vic_init(EP93XX_VIC2_BASE
, 32, EP93XX_VIC2_VALID_IRQ_MASK
, 0);
84 /*************************************************************************
85 * EP93xx System Controller Software Locked register handling
86 *************************************************************************/
89 * syscon_swlock prevents anything else from writing to the syscon
90 * block while a software locked register is being written.
92 static DEFINE_SPINLOCK(syscon_swlock
);
94 void ep93xx_syscon_swlocked_write(unsigned int val
, void __iomem
*reg
)
98 spin_lock_irqsave(&syscon_swlock
, flags
);
100 __raw_writel(0xaa, EP93XX_SYSCON_SWLOCK
);
101 __raw_writel(val
, reg
);
103 spin_unlock_irqrestore(&syscon_swlock
, flags
);
106 void ep93xx_devcfg_set_clear(unsigned int set_bits
, unsigned int clear_bits
)
111 spin_lock_irqsave(&syscon_swlock
, flags
);
113 val
= __raw_readl(EP93XX_SYSCON_DEVCFG
);
116 __raw_writel(0xaa, EP93XX_SYSCON_SWLOCK
);
117 __raw_writel(val
, EP93XX_SYSCON_DEVCFG
);
119 spin_unlock_irqrestore(&syscon_swlock
, flags
);
123 * ep93xx_chip_revision() - returns the EP93xx chip revision
125 * See <mach/platform.h> for more information.
127 unsigned int ep93xx_chip_revision(void)
131 v
= __raw_readl(EP93XX_SYSCON_SYSCFG
);
132 v
&= EP93XX_SYSCON_SYSCFG_REV_MASK
;
133 v
>>= EP93XX_SYSCON_SYSCFG_REV_SHIFT
;
136 EXPORT_SYMBOL_GPL(ep93xx_chip_revision
);
138 /*************************************************************************
140 *************************************************************************/
141 static struct resource ep93xx_gpio_resource
[] = {
142 DEFINE_RES_MEM(EP93XX_GPIO_PHYS_BASE
, 0xcc),
145 static struct platform_device ep93xx_gpio_device
= {
146 .name
= "gpio-ep93xx",
148 .num_resources
= ARRAY_SIZE(ep93xx_gpio_resource
),
149 .resource
= ep93xx_gpio_resource
,
152 /*************************************************************************
153 * EP93xx peripheral handling
154 *************************************************************************/
155 #define EP93XX_UART_MCR_OFFSET (0x0100)
157 static void ep93xx_uart_set_mctrl(struct amba_device
*dev
,
158 void __iomem
*base
, unsigned int mctrl
)
163 if (mctrl
& TIOCM_RTS
)
165 if (mctrl
& TIOCM_DTR
)
168 __raw_writel(mcr
, base
+ EP93XX_UART_MCR_OFFSET
);
171 static struct amba_pl010_data ep93xx_uart_data
= {
172 .set_mctrl
= ep93xx_uart_set_mctrl
,
175 static AMBA_APB_DEVICE(uart1
, "apb:uart1", 0x00041010, EP93XX_UART1_PHYS_BASE
,
176 { IRQ_EP93XX_UART1
}, &ep93xx_uart_data
);
178 static AMBA_APB_DEVICE(uart2
, "apb:uart2", 0x00041010, EP93XX_UART2_PHYS_BASE
,
179 { IRQ_EP93XX_UART2
}, NULL
);
181 static AMBA_APB_DEVICE(uart3
, "apb:uart3", 0x00041010, EP93XX_UART3_PHYS_BASE
,
182 { IRQ_EP93XX_UART3
}, &ep93xx_uart_data
);
184 static struct resource ep93xx_rtc_resource
[] = {
185 DEFINE_RES_MEM(EP93XX_RTC_PHYS_BASE
, 0x10c),
188 static struct platform_device ep93xx_rtc_device
= {
189 .name
= "ep93xx-rtc",
191 .num_resources
= ARRAY_SIZE(ep93xx_rtc_resource
),
192 .resource
= ep93xx_rtc_resource
,
195 /*************************************************************************
196 * EP93xx OHCI USB Host
197 *************************************************************************/
199 static struct clk
*ep93xx_ohci_host_clock
;
201 static int ep93xx_ohci_power_on(struct platform_device
*pdev
)
203 if (!ep93xx_ohci_host_clock
) {
204 ep93xx_ohci_host_clock
= devm_clk_get(&pdev
->dev
, NULL
);
205 if (IS_ERR(ep93xx_ohci_host_clock
))
206 return PTR_ERR(ep93xx_ohci_host_clock
);
209 return clk_enable(ep93xx_ohci_host_clock
);
212 static void ep93xx_ohci_power_off(struct platform_device
*pdev
)
214 clk_disable(ep93xx_ohci_host_clock
);
217 static struct usb_ohci_pdata ep93xx_ohci_pdata
= {
218 .power_on
= ep93xx_ohci_power_on
,
219 .power_off
= ep93xx_ohci_power_off
,
220 .power_suspend
= ep93xx_ohci_power_off
,
223 static struct resource ep93xx_ohci_resources
[] = {
224 DEFINE_RES_MEM(EP93XX_USB_PHYS_BASE
, 0x1000),
225 DEFINE_RES_IRQ(IRQ_EP93XX_USB
),
228 static u64 ep93xx_ohci_dma_mask
= DMA_BIT_MASK(32);
230 static struct platform_device ep93xx_ohci_device
= {
231 .name
= "ohci-platform",
233 .num_resources
= ARRAY_SIZE(ep93xx_ohci_resources
),
234 .resource
= ep93xx_ohci_resources
,
236 .dma_mask
= &ep93xx_ohci_dma_mask
,
237 .coherent_dma_mask
= DMA_BIT_MASK(32),
238 .platform_data
= &ep93xx_ohci_pdata
,
242 /*************************************************************************
243 * EP93xx physmap'ed flash
244 *************************************************************************/
245 static struct physmap_flash_data ep93xx_flash_data
;
247 static struct resource ep93xx_flash_resource
= {
248 .flags
= IORESOURCE_MEM
,
251 static struct platform_device ep93xx_flash
= {
252 .name
= "physmap-flash",
255 .platform_data
= &ep93xx_flash_data
,
258 .resource
= &ep93xx_flash_resource
,
262 * ep93xx_register_flash() - Register the external flash device.
263 * @width: bank width in octets
264 * @start: resource start address
265 * @size: resource size
267 void __init
ep93xx_register_flash(unsigned int width
,
268 resource_size_t start
, resource_size_t size
)
270 ep93xx_flash_data
.width
= width
;
272 ep93xx_flash_resource
.start
= start
;
273 ep93xx_flash_resource
.end
= start
+ size
- 1;
275 platform_device_register(&ep93xx_flash
);
279 /*************************************************************************
280 * EP93xx ethernet peripheral handling
281 *************************************************************************/
282 static struct ep93xx_eth_data ep93xx_eth_data
;
284 static struct resource ep93xx_eth_resource
[] = {
285 DEFINE_RES_MEM(EP93XX_ETHERNET_PHYS_BASE
, 0x10000),
286 DEFINE_RES_IRQ(IRQ_EP93XX_ETHERNET
),
289 static u64 ep93xx_eth_dma_mask
= DMA_BIT_MASK(32);
291 static struct platform_device ep93xx_eth_device
= {
292 .name
= "ep93xx-eth",
295 .platform_data
= &ep93xx_eth_data
,
296 .coherent_dma_mask
= DMA_BIT_MASK(32),
297 .dma_mask
= &ep93xx_eth_dma_mask
,
299 .num_resources
= ARRAY_SIZE(ep93xx_eth_resource
),
300 .resource
= ep93xx_eth_resource
,
304 * ep93xx_register_eth - Register the built-in ethernet platform device.
305 * @data: platform specific ethernet configuration (__initdata)
306 * @copy_addr: flag indicating that the MAC address should be copied
307 * from the IndAd registers (as programmed by the bootloader)
309 void __init
ep93xx_register_eth(struct ep93xx_eth_data
*data
, int copy_addr
)
312 memcpy_fromio(data
->dev_addr
, EP93XX_ETHERNET_BASE
+ 0x50, 6);
314 ep93xx_eth_data
= *data
;
315 platform_device_register(&ep93xx_eth_device
);
319 /*************************************************************************
320 * EP93xx i2c peripheral handling
321 *************************************************************************/
322 static struct i2c_gpio_platform_data ep93xx_i2c_data
;
324 static struct platform_device ep93xx_i2c_device
= {
328 .platform_data
= &ep93xx_i2c_data
,
333 * ep93xx_register_i2c - Register the i2c platform device.
334 * @data: platform specific i2c-gpio configuration (__initdata)
335 * @devices: platform specific i2c bus device information (__initdata)
336 * @num: the number of devices on the i2c bus
338 void __init
ep93xx_register_i2c(struct i2c_gpio_platform_data
*data
,
339 struct i2c_board_info
*devices
, int num
)
342 * Set the EEPROM interface pin drive type control.
343 * Defines the driver type for the EECLK and EEDAT pins as either
344 * open drain, which will require an external pull-up, or a normal
347 if (data
->sda_is_open_drain
&& data
->sda_pin
!= EP93XX_GPIO_LINE_EEDAT
)
348 pr_warning("sda != EEDAT, open drain has no effect\n");
349 if (data
->scl_is_open_drain
&& data
->scl_pin
!= EP93XX_GPIO_LINE_EECLK
)
350 pr_warning("scl != EECLK, open drain has no effect\n");
352 __raw_writel((data
->sda_is_open_drain
<< 1) |
353 (data
->scl_is_open_drain
<< 0),
354 EP93XX_GPIO_EEDRIVE
);
356 ep93xx_i2c_data
= *data
;
357 i2c_register_board_info(0, devices
, num
);
358 platform_device_register(&ep93xx_i2c_device
);
361 /*************************************************************************
362 * EP93xx SPI peripheral handling
363 *************************************************************************/
364 static struct ep93xx_spi_info ep93xx_spi_master_data
;
366 static struct resource ep93xx_spi_resources
[] = {
367 DEFINE_RES_MEM(EP93XX_SPI_PHYS_BASE
, 0x18),
368 DEFINE_RES_IRQ(IRQ_EP93XX_SSP
),
371 static u64 ep93xx_spi_dma_mask
= DMA_BIT_MASK(32);
373 static struct platform_device ep93xx_spi_device
= {
374 .name
= "ep93xx-spi",
377 .platform_data
= &ep93xx_spi_master_data
,
378 .coherent_dma_mask
= DMA_BIT_MASK(32),
379 .dma_mask
= &ep93xx_spi_dma_mask
,
381 .num_resources
= ARRAY_SIZE(ep93xx_spi_resources
),
382 .resource
= ep93xx_spi_resources
,
386 * ep93xx_register_spi() - registers spi platform device
387 * @info: ep93xx board specific spi master info (__initdata)
388 * @devices: SPI devices to register (__initdata)
389 * @num: number of SPI devices to register
391 * This function registers platform device for the EP93xx SPI controller and
392 * also makes sure that SPI pins are muxed so that I2S is not using those pins.
394 void __init
ep93xx_register_spi(struct ep93xx_spi_info
*info
,
395 struct spi_board_info
*devices
, int num
)
398 * When SPI is used, we need to make sure that I2S is muxed off from
401 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_I2SONSSP
);
403 ep93xx_spi_master_data
= *info
;
404 spi_register_board_info(devices
, num
);
405 platform_device_register(&ep93xx_spi_device
);
408 /*************************************************************************
410 *************************************************************************/
411 static const struct gpio_led ep93xx_led_pins
[] __initconst
= {
413 .name
= "platform:grled",
414 .gpio
= EP93XX_GPIO_LINE_GRLED
,
416 .name
= "platform:rdled",
417 .gpio
= EP93XX_GPIO_LINE_RDLED
,
421 static const struct gpio_led_platform_data ep93xx_led_data __initconst
= {
422 .num_leds
= ARRAY_SIZE(ep93xx_led_pins
),
423 .leds
= ep93xx_led_pins
,
426 /*************************************************************************
427 * EP93xx pwm peripheral handling
428 *************************************************************************/
429 static struct resource ep93xx_pwm0_resource
[] = {
430 DEFINE_RES_MEM(EP93XX_PWM_PHYS_BASE
, 0x10),
433 static struct platform_device ep93xx_pwm0_device
= {
434 .name
= "ep93xx-pwm",
436 .num_resources
= ARRAY_SIZE(ep93xx_pwm0_resource
),
437 .resource
= ep93xx_pwm0_resource
,
440 static struct resource ep93xx_pwm1_resource
[] = {
441 DEFINE_RES_MEM(EP93XX_PWM_PHYS_BASE
+ 0x20, 0x10),
444 static struct platform_device ep93xx_pwm1_device
= {
445 .name
= "ep93xx-pwm",
447 .num_resources
= ARRAY_SIZE(ep93xx_pwm1_resource
),
448 .resource
= ep93xx_pwm1_resource
,
451 void __init
ep93xx_register_pwm(int pwm0
, int pwm1
)
454 platform_device_register(&ep93xx_pwm0_device
);
456 /* NOTE: EP9307 does not have PWMOUT1 (pin EGPIO14) */
458 platform_device_register(&ep93xx_pwm1_device
);
461 int ep93xx_pwm_acquire_gpio(struct platform_device
*pdev
)
467 } else if (pdev
->id
== 1) {
468 err
= gpio_request(EP93XX_GPIO_LINE_EGPIO14
,
469 dev_name(&pdev
->dev
));
472 err
= gpio_direction_output(EP93XX_GPIO_LINE_EGPIO14
, 0);
476 /* PWM 1 output on EGPIO[14] */
477 ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_PONG
);
485 gpio_free(EP93XX_GPIO_LINE_EGPIO14
);
488 EXPORT_SYMBOL(ep93xx_pwm_acquire_gpio
);
490 void ep93xx_pwm_release_gpio(struct platform_device
*pdev
)
493 gpio_direction_input(EP93XX_GPIO_LINE_EGPIO14
);
494 gpio_free(EP93XX_GPIO_LINE_EGPIO14
);
496 /* EGPIO[14] used for GPIO */
497 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_PONG
);
500 EXPORT_SYMBOL(ep93xx_pwm_release_gpio
);
503 /*************************************************************************
504 * EP93xx video peripheral handling
505 *************************************************************************/
506 static struct ep93xxfb_mach_info ep93xxfb_data
;
508 static struct resource ep93xx_fb_resource
[] = {
509 DEFINE_RES_MEM(EP93XX_RASTER_PHYS_BASE
, 0x800),
512 static struct platform_device ep93xx_fb_device
= {
516 .platform_data
= &ep93xxfb_data
,
517 .coherent_dma_mask
= DMA_BIT_MASK(32),
518 .dma_mask
= &ep93xx_fb_device
.dev
.coherent_dma_mask
,
520 .num_resources
= ARRAY_SIZE(ep93xx_fb_resource
),
521 .resource
= ep93xx_fb_resource
,
524 /* The backlight use a single register in the framebuffer's register space */
525 #define EP93XX_RASTER_REG_BRIGHTNESS 0x20
527 static struct resource ep93xx_bl_resources
[] = {
528 DEFINE_RES_MEM(EP93XX_RASTER_PHYS_BASE
+
529 EP93XX_RASTER_REG_BRIGHTNESS
, 0x04),
532 static struct platform_device ep93xx_bl_device
= {
535 .num_resources
= ARRAY_SIZE(ep93xx_bl_resources
),
536 .resource
= ep93xx_bl_resources
,
540 * ep93xx_register_fb - Register the framebuffer platform device.
541 * @data: platform specific framebuffer configuration (__initdata)
543 void __init
ep93xx_register_fb(struct ep93xxfb_mach_info
*data
)
545 ep93xxfb_data
= *data
;
546 platform_device_register(&ep93xx_fb_device
);
547 platform_device_register(&ep93xx_bl_device
);
551 /*************************************************************************
552 * EP93xx matrix keypad peripheral handling
553 *************************************************************************/
554 static struct ep93xx_keypad_platform_data ep93xx_keypad_data
;
556 static struct resource ep93xx_keypad_resource
[] = {
557 DEFINE_RES_MEM(EP93XX_KEY_MATRIX_PHYS_BASE
, 0x0c),
558 DEFINE_RES_IRQ(IRQ_EP93XX_KEY
),
561 static struct platform_device ep93xx_keypad_device
= {
562 .name
= "ep93xx-keypad",
565 .platform_data
= &ep93xx_keypad_data
,
567 .num_resources
= ARRAY_SIZE(ep93xx_keypad_resource
),
568 .resource
= ep93xx_keypad_resource
,
572 * ep93xx_register_keypad - Register the keypad platform device.
573 * @data: platform specific keypad configuration (__initdata)
575 void __init
ep93xx_register_keypad(struct ep93xx_keypad_platform_data
*data
)
577 ep93xx_keypad_data
= *data
;
578 platform_device_register(&ep93xx_keypad_device
);
581 int ep93xx_keypad_acquire_gpio(struct platform_device
*pdev
)
586 for (i
= 0; i
< 8; i
++) {
587 err
= gpio_request(EP93XX_GPIO_LINE_C(i
), dev_name(&pdev
->dev
));
590 err
= gpio_request(EP93XX_GPIO_LINE_D(i
), dev_name(&pdev
->dev
));
595 /* Enable the keypad controller; GPIO ports C and D used for keypad */
596 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_KEYS
|
597 EP93XX_SYSCON_DEVCFG_GONK
);
602 gpio_free(EP93XX_GPIO_LINE_C(i
));
604 for (--i
; i
>= 0; --i
) {
605 gpio_free(EP93XX_GPIO_LINE_C(i
));
606 gpio_free(EP93XX_GPIO_LINE_D(i
));
610 EXPORT_SYMBOL(ep93xx_keypad_acquire_gpio
);
612 void ep93xx_keypad_release_gpio(struct platform_device
*pdev
)
616 for (i
= 0; i
< 8; i
++) {
617 gpio_free(EP93XX_GPIO_LINE_C(i
));
618 gpio_free(EP93XX_GPIO_LINE_D(i
));
621 /* Disable the keypad controller; GPIO ports C and D used for GPIO */
622 ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_KEYS
|
623 EP93XX_SYSCON_DEVCFG_GONK
);
625 EXPORT_SYMBOL(ep93xx_keypad_release_gpio
);
627 /*************************************************************************
628 * EP93xx I2S audio peripheral handling
629 *************************************************************************/
630 static struct resource ep93xx_i2s_resource
[] = {
631 DEFINE_RES_MEM(EP93XX_I2S_PHYS_BASE
, 0x100),
634 static struct platform_device ep93xx_i2s_device
= {
635 .name
= "ep93xx-i2s",
637 .num_resources
= ARRAY_SIZE(ep93xx_i2s_resource
),
638 .resource
= ep93xx_i2s_resource
,
641 static struct platform_device ep93xx_pcm_device
= {
642 .name
= "ep93xx-pcm-audio",
646 void __init
ep93xx_register_i2s(void)
648 platform_device_register(&ep93xx_i2s_device
);
649 platform_device_register(&ep93xx_pcm_device
);
652 #define EP93XX_SYSCON_DEVCFG_I2S_MASK (EP93XX_SYSCON_DEVCFG_I2SONSSP | \
653 EP93XX_SYSCON_DEVCFG_I2SONAC97)
655 #define EP93XX_I2SCLKDIV_MASK (EP93XX_SYSCON_I2SCLKDIV_ORIDE | \
656 EP93XX_SYSCON_I2SCLKDIV_SPOL)
658 int ep93xx_i2s_acquire(void)
662 ep93xx_devcfg_set_clear(EP93XX_SYSCON_DEVCFG_I2SONAC97
,
663 EP93XX_SYSCON_DEVCFG_I2S_MASK
);
666 * This is potentially racy with the clock api for i2s_mclk, sclk and
667 * lrclk. Since the i2s driver is the only user of those clocks we
668 * rely on it to prevent parallel use of this function and the
669 * clock api for the i2s clocks.
671 val
= __raw_readl(EP93XX_SYSCON_I2SCLKDIV
);
672 val
&= ~EP93XX_I2SCLKDIV_MASK
;
673 val
|= EP93XX_SYSCON_I2SCLKDIV_ORIDE
| EP93XX_SYSCON_I2SCLKDIV_SPOL
;
674 ep93xx_syscon_swlocked_write(val
, EP93XX_SYSCON_I2SCLKDIV
);
678 EXPORT_SYMBOL(ep93xx_i2s_acquire
);
680 void ep93xx_i2s_release(void)
682 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_I2S_MASK
);
684 EXPORT_SYMBOL(ep93xx_i2s_release
);
686 /*************************************************************************
687 * EP93xx AC97 audio peripheral handling
688 *************************************************************************/
689 static struct resource ep93xx_ac97_resources
[] = {
690 DEFINE_RES_MEM(EP93XX_AAC_PHYS_BASE
, 0xac),
691 DEFINE_RES_IRQ(IRQ_EP93XX_AACINTR
),
694 static struct platform_device ep93xx_ac97_device
= {
695 .name
= "ep93xx-ac97",
697 .num_resources
= ARRAY_SIZE(ep93xx_ac97_resources
),
698 .resource
= ep93xx_ac97_resources
,
701 void __init
ep93xx_register_ac97(void)
704 * Make sure that the AC97 pins are not used by I2S.
706 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_I2SONAC97
);
708 platform_device_register(&ep93xx_ac97_device
);
709 platform_device_register(&ep93xx_pcm_device
);
712 /*************************************************************************
714 *************************************************************************/
715 static struct resource ep93xx_wdt_resources
[] = {
716 DEFINE_RES_MEM(EP93XX_WATCHDOG_PHYS_BASE
, 0x08),
719 static struct platform_device ep93xx_wdt_device
= {
720 .name
= "ep93xx-wdt",
722 .num_resources
= ARRAY_SIZE(ep93xx_wdt_resources
),
723 .resource
= ep93xx_wdt_resources
,
726 /*************************************************************************
728 *************************************************************************/
729 static struct resource ep93xx_ide_resources
[] = {
730 DEFINE_RES_MEM(EP93XX_IDE_PHYS_BASE
, 0x38),
731 DEFINE_RES_IRQ(IRQ_EP93XX_EXT3
),
734 static struct platform_device ep93xx_ide_device
= {
735 .name
= "ep93xx-ide",
738 .dma_mask
= &ep93xx_ide_device
.dev
.coherent_dma_mask
,
739 .coherent_dma_mask
= DMA_BIT_MASK(32),
741 .num_resources
= ARRAY_SIZE(ep93xx_ide_resources
),
742 .resource
= ep93xx_ide_resources
,
745 void __init
ep93xx_register_ide(void)
747 platform_device_register(&ep93xx_ide_device
);
750 int ep93xx_ide_acquire_gpio(struct platform_device
*pdev
)
755 err
= gpio_request(EP93XX_GPIO_LINE_EGPIO2
, dev_name(&pdev
->dev
));
758 err
= gpio_request(EP93XX_GPIO_LINE_EGPIO15
, dev_name(&pdev
->dev
));
761 for (i
= 2; i
< 8; i
++) {
762 err
= gpio_request(EP93XX_GPIO_LINE_E(i
), dev_name(&pdev
->dev
));
766 for (i
= 4; i
< 8; i
++) {
767 err
= gpio_request(EP93XX_GPIO_LINE_G(i
), dev_name(&pdev
->dev
));
771 for (i
= 0; i
< 8; i
++) {
772 err
= gpio_request(EP93XX_GPIO_LINE_H(i
), dev_name(&pdev
->dev
));
777 /* GPIO ports E[7:2], G[7:4] and H used by IDE */
778 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_EONIDE
|
779 EP93XX_SYSCON_DEVCFG_GONIDE
|
780 EP93XX_SYSCON_DEVCFG_HONIDE
);
784 for (--i
; i
>= 0; --i
)
785 gpio_free(EP93XX_GPIO_LINE_H(i
));
788 for (--i
; i
>= 4; --i
)
789 gpio_free(EP93XX_GPIO_LINE_G(i
));
792 for (--i
; i
>= 2; --i
)
793 gpio_free(EP93XX_GPIO_LINE_E(i
));
794 gpio_free(EP93XX_GPIO_LINE_EGPIO15
);
796 gpio_free(EP93XX_GPIO_LINE_EGPIO2
);
799 EXPORT_SYMBOL(ep93xx_ide_acquire_gpio
);
801 void ep93xx_ide_release_gpio(struct platform_device
*pdev
)
805 for (i
= 2; i
< 8; i
++)
806 gpio_free(EP93XX_GPIO_LINE_E(i
));
807 for (i
= 4; i
< 8; i
++)
808 gpio_free(EP93XX_GPIO_LINE_G(i
));
809 for (i
= 0; i
< 8; i
++)
810 gpio_free(EP93XX_GPIO_LINE_H(i
));
811 gpio_free(EP93XX_GPIO_LINE_EGPIO15
);
812 gpio_free(EP93XX_GPIO_LINE_EGPIO2
);
815 /* GPIO ports E[7:2], G[7:4] and H used by GPIO */
816 ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_EONIDE
|
817 EP93XX_SYSCON_DEVCFG_GONIDE
|
818 EP93XX_SYSCON_DEVCFG_HONIDE
);
820 EXPORT_SYMBOL(ep93xx_ide_release_gpio
);
822 /*************************************************************************
823 * EP93xx Security peripheral
824 *************************************************************************/
827 * The Maverick Key is 256 bits of micro fuses blown at the factory during
828 * manufacturing to uniquely identify a part.
830 * See: http://arm.cirrus.com/forum/viewtopic.php?t=486&highlight=maverick+key
832 #define EP93XX_SECURITY_REG(x) (EP93XX_SECURITY_BASE + (x))
833 #define EP93XX_SECURITY_SECFLG EP93XX_SECURITY_REG(0x2400)
834 #define EP93XX_SECURITY_FUSEFLG EP93XX_SECURITY_REG(0x2410)
835 #define EP93XX_SECURITY_UNIQID EP93XX_SECURITY_REG(0x2440)
836 #define EP93XX_SECURITY_UNIQCHK EP93XX_SECURITY_REG(0x2450)
837 #define EP93XX_SECURITY_UNIQVAL EP93XX_SECURITY_REG(0x2460)
838 #define EP93XX_SECURITY_SECID1 EP93XX_SECURITY_REG(0x2500)
839 #define EP93XX_SECURITY_SECID2 EP93XX_SECURITY_REG(0x2504)
840 #define EP93XX_SECURITY_SECCHK1 EP93XX_SECURITY_REG(0x2520)
841 #define EP93XX_SECURITY_SECCHK2 EP93XX_SECURITY_REG(0x2524)
842 #define EP93XX_SECURITY_UNIQID2 EP93XX_SECURITY_REG(0x2700)
843 #define EP93XX_SECURITY_UNIQID3 EP93XX_SECURITY_REG(0x2704)
844 #define EP93XX_SECURITY_UNIQID4 EP93XX_SECURITY_REG(0x2708)
845 #define EP93XX_SECURITY_UNIQID5 EP93XX_SECURITY_REG(0x270c)
847 static char ep93xx_soc_id
[33];
849 static const char __init
*ep93xx_get_soc_id(void)
851 unsigned int id
, id2
, id3
, id4
, id5
;
853 if (__raw_readl(EP93XX_SECURITY_UNIQVAL
) != 1)
854 return "bad Hamming code";
856 id
= __raw_readl(EP93XX_SECURITY_UNIQID
);
857 id2
= __raw_readl(EP93XX_SECURITY_UNIQID2
);
858 id3
= __raw_readl(EP93XX_SECURITY_UNIQID3
);
859 id4
= __raw_readl(EP93XX_SECURITY_UNIQID4
);
860 id5
= __raw_readl(EP93XX_SECURITY_UNIQID5
);
865 snprintf(ep93xx_soc_id
, sizeof(ep93xx_soc_id
),
866 "%08x%08x%08x%08x", id2
, id3
, id4
, id5
);
868 return ep93xx_soc_id
;
871 static const char __init
*ep93xx_get_soc_rev(void)
873 int rev
= ep93xx_chip_revision();
876 case EP93XX_CHIP_REV_D0
:
878 case EP93XX_CHIP_REV_D1
:
880 case EP93XX_CHIP_REV_E0
:
882 case EP93XX_CHIP_REV_E1
:
884 case EP93XX_CHIP_REV_E2
:
891 static const char __init
*ep93xx_get_machine_name(void)
893 return kasprintf(GFP_KERNEL
,"%s", machine_desc
->name
);
896 static struct device __init
*ep93xx_init_soc(void)
898 struct soc_device_attribute
*soc_dev_attr
;
899 struct soc_device
*soc_dev
;
901 soc_dev_attr
= kzalloc(sizeof(*soc_dev_attr
), GFP_KERNEL
);
905 soc_dev_attr
->machine
= ep93xx_get_machine_name();
906 soc_dev_attr
->family
= "Cirrus Logic EP93xx";
907 soc_dev_attr
->revision
= ep93xx_get_soc_rev();
908 soc_dev_attr
->soc_id
= ep93xx_get_soc_id();
910 soc_dev
= soc_device_register(soc_dev_attr
);
911 if (IS_ERR(soc_dev
)) {
912 kfree(soc_dev_attr
->machine
);
917 return soc_device_to_device(soc_dev
);
920 struct device __init
*ep93xx_init_devices(void)
922 struct device
*parent
;
924 /* Disallow access to MaverickCrunch initially */
925 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_CPENA
);
927 /* Default all ports to GPIO */
928 ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_KEYS
|
929 EP93XX_SYSCON_DEVCFG_GONK
|
930 EP93XX_SYSCON_DEVCFG_EONIDE
|
931 EP93XX_SYSCON_DEVCFG_GONIDE
|
932 EP93XX_SYSCON_DEVCFG_HONIDE
);
934 parent
= ep93xx_init_soc();
936 /* Get the GPIO working early, other devices need it */
937 platform_device_register(&ep93xx_gpio_device
);
939 amba_device_register(&uart1_device
, &iomem_resource
);
940 amba_device_register(&uart2_device
, &iomem_resource
);
941 amba_device_register(&uart3_device
, &iomem_resource
);
943 platform_device_register(&ep93xx_rtc_device
);
944 platform_device_register(&ep93xx_ohci_device
);
945 platform_device_register(&ep93xx_wdt_device
);
947 gpio_led_register_device(-1, &ep93xx_led_data
);
952 void ep93xx_restart(enum reboot_mode mode
, const char *cmd
)
955 * Set then clear the SWRST bit to initiate a software reset
957 ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_SWRST
);
958 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_SWRST
);
964 void __init
ep93xx_init_late(void)