]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/arm/mach-shmobile/board-g3evm.c
ARM: mach-shmobile: G3EVM USBHS support
[karo-tx-linux.git] / arch / arm / mach-shmobile / board-g3evm.c
1 /*
2  * G3EVM board support
3  *
4  * Copyright (C) 2010  Magnus Damm
5  * Copyright (C) 2008  Yoshihiro Shimoda
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; version 2 of the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  */
20 #include <linux/kernel.h>
21 #include <linux/init.h>
22 #include <linux/interrupt.h>
23 #include <linux/irq.h>
24 #include <linux/platform_device.h>
25 #include <linux/delay.h>
26 #include <linux/mtd/mtd.h>
27 #include <linux/mtd/partitions.h>
28 #include <linux/mtd/physmap.h>
29 #include <linux/usb/r8a66597.h>
30 #include <linux/io.h>
31 #include <linux/gpio.h>
32 #include <mach/sh7367.h>
33 #include <mach/common.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
37
38 static struct mtd_partition nor_flash_partitions[] = {
39         {
40                 .name           = "loader",
41                 .offset         = 0x00000000,
42                 .size           = 512 * 1024,
43         },
44         {
45                 .name           = "bootenv",
46                 .offset         = MTDPART_OFS_APPEND,
47                 .size           = 512 * 1024,
48         },
49         {
50                 .name           = "kernel_ro",
51                 .offset         = MTDPART_OFS_APPEND,
52                 .size           = 8 * 1024 * 1024,
53                 .mask_flags     = MTD_WRITEABLE,
54         },
55         {
56                 .name           = "kernel",
57                 .offset         = MTDPART_OFS_APPEND,
58                 .size           = 8 * 1024 * 1024,
59         },
60         {
61                 .name           = "data",
62                 .offset         = MTDPART_OFS_APPEND,
63                 .size           = MTDPART_SIZ_FULL,
64         },
65 };
66
67 static struct physmap_flash_data nor_flash_data = {
68         .width          = 2,
69         .parts          = nor_flash_partitions,
70         .nr_parts       = ARRAY_SIZE(nor_flash_partitions),
71 };
72
73 static struct resource nor_flash_resources[] = {
74         [0]     = {
75                 .start  = 0x00000000,
76                 .end    = 0x08000000 - 1,
77                 .flags  = IORESOURCE_MEM,
78         }
79 };
80
81 static struct platform_device nor_flash_device = {
82         .name           = "physmap-flash",
83         .dev            = {
84                 .platform_data  = &nor_flash_data,
85         },
86         .num_resources  = ARRAY_SIZE(nor_flash_resources),
87         .resource       = nor_flash_resources,
88 };
89
90 /* USBHS */
91 void usb_host_port_power(int port, int power)
92 {
93         if (!power) /* only power-on supported for now */
94                 return;
95
96         /* set VBOUT/PWEN and EXTLP0 in DVSTCTR */
97         __raw_writew(__raw_readw(0xe6890008) | 0x600, 0xe6890008);
98 }
99
100 static struct r8a66597_platdata usb_host_data = {
101         .on_chip = 1,
102         .port_power = usb_host_port_power,
103 };
104
105 static struct resource usb_host_resources[] = {
106         [0] = {
107                 .name   = "USBHS",
108                 .start  = 0xe6890000,
109                 .end    = 0xe68900e5,
110                 .flags  = IORESOURCE_MEM,
111         },
112         [1] = {
113                 .start  = 65,
114                 .flags  = IORESOURCE_IRQ,
115         },
116 };
117
118 static struct platform_device usb_host_device = {
119         .name           = "r8a66597_hcd",
120         .id             = 0,
121         .dev = {
122                 .platform_data          = &usb_host_data,
123                 .dma_mask               = NULL,
124                 .coherent_dma_mask      = 0xffffffff,
125         },
126         .num_resources  = ARRAY_SIZE(usb_host_resources),
127         .resource       = usb_host_resources,
128 };
129
130 static struct platform_device *g3evm_devices[] __initdata = {
131         &nor_flash_device,
132         &usb_host_device,
133 };
134
135 static struct map_desc g3evm_io_desc[] __initdata = {
136         /* create a 1:1 entity map for 0xe6xxxxxx
137          * used by CPGA, INTC and PFC.
138          */
139         {
140                 .virtual        = 0xe6000000,
141                 .pfn            = __phys_to_pfn(0xe6000000),
142                 .length         = 256 << 20,
143                 .type           = MT_DEVICE_NONSHARED
144         },
145 };
146
147 static void __init g3evm_map_io(void)
148 {
149         iotable_init(g3evm_io_desc, ARRAY_SIZE(g3evm_io_desc));
150
151         /* setup early devices, clocks and console here as well */
152         sh7367_add_early_devices();
153         sh7367_clock_init();
154         shmobile_setup_console();
155 }
156
157 static void __init g3evm_init(void)
158 {
159         sh7367_pinmux_init();
160
161         /* Lit DS4 LED */
162         gpio_request(GPIO_PORT22, NULL);
163         gpio_direction_output(GPIO_PORT22, 1);
164         gpio_export(GPIO_PORT22, 0);
165
166         /* Lit DS8 LED */
167         gpio_request(GPIO_PORT23, NULL);
168         gpio_direction_output(GPIO_PORT23, 1);
169         gpio_export(GPIO_PORT23, 0);
170
171         /* Lit DS3 LED */
172         gpio_request(GPIO_PORT24, NULL);
173         gpio_direction_output(GPIO_PORT24, 1);
174         gpio_export(GPIO_PORT24, 0);
175
176         /* SCIFA1 */
177         gpio_request(GPIO_FN_SCIFA1_TXD, NULL);
178         gpio_request(GPIO_FN_SCIFA1_RXD, NULL);
179         gpio_request(GPIO_FN_SCIFA1_CTS, NULL);
180         gpio_request(GPIO_FN_SCIFA1_RTS, NULL);
181
182         /* USBHS */
183         gpio_request(GPIO_FN_VBUS0, NULL);
184         gpio_request(GPIO_FN_PWEN, NULL);
185         gpio_request(GPIO_FN_OVCN, NULL);
186         gpio_request(GPIO_FN_OVCN2, NULL);
187         gpio_request(GPIO_FN_EXTLP, NULL);
188         gpio_request(GPIO_FN_IDIN, NULL);
189
190         /* enable clock in SYMSTPCR2 */
191         __raw_writel(__raw_readl(0xe6158048) & ~(1 << 22), 0xe6158048);
192
193         /* setup USB phy */
194         __raw_writew(0x0300, 0xe605810a);       /* USBCR1 */
195         __raw_writew(0x00e0, 0xe60581c0);       /* CPFCH */
196         __raw_writew(0x6010, 0xe60581c6);       /* CGPOSR */
197         __raw_writew(0x8a0a, 0xe605810c);       /* USBCR2 */
198
199         sh7367_add_standard_devices();
200
201         platform_add_devices(g3evm_devices, ARRAY_SIZE(g3evm_devices));
202 }
203
204 MACHINE_START(G3EVM, "g3evm")
205         .phys_io        = 0xe6000000,
206         .io_pg_offst    = ((0xe6000000) >> 18) & 0xfffc,
207         .map_io         = g3evm_map_io,
208         .init_irq       = sh7367_init_irq,
209         .init_machine   = g3evm_init,
210         .timer          = &shmobile_timer,
211 MACHINE_END