2 * linux/arch/arm/mach-tcc8k/devices.c
4 * Copyright (C) Telechips, Inc.
5 * Copyright (C) 2009 Hans J. Koch <hjk@linutronix.de>
7 * Licensed under the terms of GPL v2.
11 #include <linux/dma-mapping.h>
12 #include <linux/init.h>
14 #include <linux/kernel.h>
15 #include <linux/module.h>
17 #include <asm/mach/map.h>
19 #include <mach/tcc8k-regs.h>
20 #include <mach/irqs.h>
24 static u64 tcc8k_dmamask
= DMA_BIT_MASK(32);
26 #ifdef CONFIG_MTD_NAND_TCC
28 static struct resource tcc_nand_resources
[] = {
30 .start
= (resource_size_t
)NFC_BASE
,
31 .end
= (resource_size_t
)NFC_BASE
+ 0x7f,
32 .flags
= IORESOURCE_MEM
,
36 .flags
= IORESOURCE_IRQ
,
40 struct platform_device tcc_nand_device
= {
43 .num_resources
= ARRAY_SIZE(tcc_nand_resources
),
44 .resource
= tcc_nand_resources
,
48 #ifdef CONFIG_MMC_TCC8K
50 static struct resource tcc8k_mmc0_resource
[] = {
54 .flags
= IORESOURCE_IRQ
,
58 static struct resource tcc8k_mmc1_resource
[] = {
62 .flags
= IORESOURCE_IRQ
,
66 struct platform_device tcc8k_mmc0_device
= {
69 .num_resources
= ARRAY_SIZE(tcc8k_mmc0_resource
),
70 .resource
= tcc8k_mmc0_resource
,
72 .dma_mask
= &tcc8k_dmamask
,
73 .coherent_dma_mask
= DMA_BIT_MASK(32),
77 struct platform_device tcc8k_mmc1_device
= {
80 .num_resources
= ARRAY_SIZE(tcc8k_mmc1_resource
),
81 .resource
= tcc8k_mmc1_resource
,
83 .dma_mask
= &tcc8k_dmamask
,
84 .coherent_dma_mask
= DMA_BIT_MASK(32),
88 static inline void tcc8k_init_mmc(void)
90 u32 reg
= __raw_readl(GPIOPS_BASE
+ GPIOPS_FS1_OFFS
);
92 reg
|= GPIOPS_FS1_SDH0_BITS
| GPIOPS_FS1_SDH1_BITS
;
93 __raw_writel(reg
, GPIOPS_BASE
+ GPIOPS_FS1_OFFS
);
95 platform_device_register(&tcc8k_mmc0_device
);
96 platform_device_register(&tcc8k_mmc1_device
);
99 static inline void tcc8k_init_mmc(void) { }
102 #ifdef CONFIG_USB_OHCI_HCD
103 static int tcc8k_ohci_init(struct device
*dev
)
107 /* Use GPIO PK19 as VBUS control output */
108 reg
= __raw_readl(GPIOPK_BASE
+ GPIOPK_FS0_OFFS
);
110 __raw_writel(reg
, GPIOPK_BASE
+ GPIOPK_FS0_OFFS
);
111 reg
= __raw_readl(GPIOPK_BASE
+ GPIOPK_FS1_OFFS
);
113 __raw_writel(reg
, GPIOPK_BASE
+ GPIOPK_FS1_OFFS
);
115 reg
= __raw_readl(GPIOPK_BASE
+ GPIOPK_DOE_OFFS
);
117 __raw_writel(reg
, GPIOPK_BASE
+ GPIOPK_DOE_OFFS
);
119 reg
= __raw_readl(GPIOPK_BASE
+ GPIOPK_DAT_OFFS
);
121 __raw_writel(reg
, GPIOPK_BASE
+ GPIOPK_DAT_OFFS
);
126 static struct resource tcc8k_ohci0_resources
[] = {
128 .start
= (resource_size_t
)USBH0_BASE
,
129 .end
= (resource_size_t
)USBH0_BASE
+ 0x5c,
130 .flags
= IORESOURCE_MEM
,
135 .flags
= IORESOURCE_IRQ
,
139 static struct resource tcc8k_ohci1_resources
[] = {
141 .start
= (resource_size_t
)USBH1_BASE
,
142 .end
= (resource_size_t
)USBH1_BASE
+ 0x5c,
143 .flags
= IORESOURCE_MEM
,
148 .flags
= IORESOURCE_IRQ
,
152 static struct tccohci_platform_data tcc8k_ohci0_platform_data
= {
154 .port_mode
= PMM_PERPORT_MODE
,
155 .init
= tcc8k_ohci_init
,
158 static struct tccohci_platform_data tcc8k_ohci1_platform_data
= {
160 .port_mode
= PMM_PERPORT_MODE
,
161 .init
= tcc8k_ohci_init
,
164 static struct platform_device ohci0_device
= {
168 .dma_mask
= &tcc8k_dmamask
,
169 .coherent_dma_mask
= DMA_BIT_MASK(32),
170 .platform_data
= &tcc8k_ohci0_platform_data
,
172 .num_resources
= ARRAY_SIZE(tcc8k_ohci0_resources
),
173 .resource
= tcc8k_ohci0_resources
,
176 static struct platform_device ohci1_device
= {
180 .dma_mask
= &tcc8k_dmamask
,
181 .coherent_dma_mask
= DMA_BIT_MASK(32),
182 .platform_data
= &tcc8k_ohci1_platform_data
,
184 .num_resources
= ARRAY_SIZE(tcc8k_ohci1_resources
),
185 .resource
= tcc8k_ohci1_resources
,
188 static void __init
tcc8k_init_usbhost(void)
190 platform_device_register(&ohci0_device
);
191 platform_device_register(&ohci1_device
);
194 static void __init
tcc8k_init_usbhost(void) { }
197 /* USB device controller*/
198 #ifdef CONFIG_USB_GADGET_TCC8K
199 static struct resource udc_resources
[] = {
203 .flags
= IORESOURCE_IRQ
,
208 .flags
= IORESOURCE_IRQ
,
212 static struct platform_device tcc8k_udc_device
= {
215 .resource
= udc_resources
,
216 .num_resources
= ARRAY_SIZE(udc_resources
),
218 .dma_mask
= &tcc8k_dmamask
,
219 .coherent_dma_mask
= DMA_BIT_MASK(32),
223 static void __init
tcc8k_init_usb_gadget(void)
225 platform_device_register(&tcc8k_udc_device
);
228 static void __init
tcc8k_init_usb_gadget(void) { }
229 #endif /* CONFIG_USB_GADGET_TCC83X */
231 static int __init
tcc8k_init_devices(void)
234 tcc8k_init_usbhost();
235 tcc8k_init_usb_gadget();
239 arch_initcall(tcc8k_init_devices
);