ARM: mach-shmobile: kzm9g: add MMCIF support
[deliverable/linux.git] / arch / arm / mach-shmobile / board-kzm9g.c
CommitLineData
9b93e244
KM
1/*
2 * KZM-A9-GT board support
3 *
4 * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
26786111
KM
19
20#include <linux/delay.h>
9b93e244
KM
21#include <linux/gpio.h>
22#include <linux/io.h>
23#include <linux/irq.h>
407c0526 24#include <linux/i2c.h>
cc2512bc
KM
25#include <linux/mmc/host.h>
26#include <linux/mmc/sh_mmcif.h>
9b93e244 27#include <linux/platform_device.h>
c15c4257 28#include <linux/smsc911x.h>
dd818180 29#include <linux/usb/r8a66597.h>
26786111 30#include <linux/videodev2.h>
c15c4257 31#include <mach/irqs.h>
9b93e244
KM
32#include <mach/sh73a0.h>
33#include <mach/common.h>
34#include <asm/hardware/cache-l2x0.h>
35#include <asm/hardware/gic.h>
36#include <asm/mach-types.h>
37#include <asm/mach/arch.h>
26786111 38#include <video/sh_mobile_lcdc.h>
9b93e244 39
c15c4257
KM
40/* SMSC 9221 */
41static struct resource smsc9221_resources[] = {
42 [0] = {
43 .start = 0x10000000, /* CS4 */
44 .end = 0x100000ff,
45 .flags = IORESOURCE_MEM,
46 },
47 [1] = {
48 .start = intcs_evt2irq(0x260), /* IRQ3 */
49 .flags = IORESOURCE_IRQ,
50 },
51};
52
53static struct smsc911x_platform_config smsc9221_platdata = {
54 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
55 .phy_interface = PHY_INTERFACE_MODE_MII,
56 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
57 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
58};
59
60static struct platform_device smsc_device = {
61 .name = "smsc911x",
62 .dev = {
63 .platform_data = &smsc9221_platdata,
64 },
65 .resource = smsc9221_resources,
66 .num_resources = ARRAY_SIZE(smsc9221_resources),
67};
68
dd818180
KM
69/* USB external chip */
70static struct r8a66597_platdata usb_host_data = {
71 .on_chip = 0,
72 .xtal = R8A66597_PLATDATA_XTAL_48MHZ,
73};
74
75static struct resource usb_resources[] = {
76 [0] = {
77 .start = 0x10010000,
78 .end = 0x1001ffff - 1,
79 .flags = IORESOURCE_MEM,
80 },
81 [1] = {
82 .start = intcs_evt2irq(0x220), /* IRQ1 */
83 .flags = IORESOURCE_IRQ,
84 },
85};
86
87static struct platform_device usb_host_device = {
88 .name = "r8a66597_hcd",
89 .dev = {
90 .platform_data = &usb_host_data,
91 .dma_mask = NULL,
92 .coherent_dma_mask = 0xffffffff,
93 },
94 .num_resources = ARRAY_SIZE(usb_resources),
95 .resource = usb_resources,
96};
97
26786111
KM
98/* LCDC */
99static struct fb_videomode kzm_lcdc_mode = {
100 .name = "WVGA Panel",
101 .xres = 800,
102 .yres = 480,
103 .left_margin = 220,
104 .right_margin = 110,
105 .hsync_len = 70,
106 .upper_margin = 20,
107 .lower_margin = 5,
108 .vsync_len = 5,
109 .sync = 0,
110};
111
112static struct sh_mobile_lcdc_info lcdc_info = {
113 .clock_source = LCDC_CLK_BUS,
114 .ch[0] = {
115 .chan = LCDC_CHAN_MAINLCD,
116 .fourcc = V4L2_PIX_FMT_RGB565,
117 .interface_type = RGB24,
118 .lcd_modes = &kzm_lcdc_mode,
119 .num_modes = 1,
120 .clock_divider = 5,
121 .flags = 0,
122 .panel_cfg = {
123 .width = 152,
124 .height = 91,
125 },
126 }
127};
128
129static struct resource lcdc_resources[] = {
130 [0] = {
131 .name = "LCDC",
132 .start = 0xfe940000,
133 .end = 0xfe943fff,
134 .flags = IORESOURCE_MEM,
135 },
136 [1] = {
137 .start = intcs_evt2irq(0x580),
138 .flags = IORESOURCE_IRQ,
139 },
140};
141
142static struct platform_device lcdc_device = {
143 .name = "sh_mobile_lcdc_fb",
144 .num_resources = ARRAY_SIZE(lcdc_resources),
145 .resource = lcdc_resources,
146 .dev = {
147 .platform_data = &lcdc_info,
148 .coherent_dma_mask = ~0,
149 },
150};
151
cc2512bc
KM
152/* MMCIF */
153static struct resource sh_mmcif_resources[] = {
154 [0] = {
155 .name = "MMCIF",
156 .start = 0xe6bd0000,
157 .end = 0xe6bd00ff,
158 .flags = IORESOURCE_MEM,
159 },
160 [1] = {
161 .start = gic_spi(141),
162 .flags = IORESOURCE_IRQ,
163 },
164 [2] = {
165 .start = gic_spi(140),
166 .flags = IORESOURCE_IRQ,
167 },
168};
169
170static struct sh_mmcif_plat_data sh_mmcif_platdata = {
171 .ocr = MMC_VDD_165_195,
172 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
173};
174
175static struct platform_device mmc_device = {
176 .name = "sh_mmcif",
177 .dev = {
178 .dma_mask = NULL,
179 .coherent_dma_mask = 0xffffffff,
180 .platform_data = &sh_mmcif_platdata,
181 },
182 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
183 .resource = sh_mmcif_resources,
184};
185
407c0526
KM
186static struct i2c_board_info i2c1_devices[] = {
187 {
188 I2C_BOARD_INFO("st1232-ts", 0x55),
189 .irq = intcs_evt2irq(0x300), /* IRQ8 */
190 },
191};
192
9b93e244 193static struct platform_device *kzm_devices[] __initdata = {
c15c4257 194 &smsc_device,
dd818180 195 &usb_host_device,
26786111 196 &lcdc_device,
cc2512bc 197 &mmc_device,
9b93e244
KM
198};
199
26786111
KM
200/*
201 * FIXME
202 *
203 * This is quick hack for enabling LCDC backlight
204 */
205static int __init as3711_enable_lcdc_backlight(void)
206{
207 struct i2c_adapter *a = i2c_get_adapter(0);
208 struct i2c_msg msg;
209 int i, ret;
210 __u8 magic[] = {
211 0x40, 0x2a,
212 0x43, 0x3c,
213 0x44, 0x3c,
214 0x45, 0x3c,
215 0x54, 0x03,
216 0x51, 0x00,
217 0x51, 0x01,
218 0xff, 0x00, /* wait */
219 0x43, 0xf0,
220 0x44, 0xf0,
221 0x45, 0xf0,
222 };
223
224 if (!machine_is_kzm9g())
225 return 0;
226
227 if (!a)
228 return 0;
229
230 msg.addr = 0x40;
231 msg.len = 2;
232 msg.flags = 0;
233
234 for (i = 0; i < ARRAY_SIZE(magic); i += 2) {
235 msg.buf = magic + i;
236
237 if (0xff == msg.buf[0]) {
238 udelay(500);
239 continue;
240 }
241
242 ret = i2c_transfer(a, &msg, 1);
243 if (ret < 0) {
244 pr_err("i2c transfer fail\n");
245 break;
246 }
247 }
248
249 return 0;
250}
251device_initcall(as3711_enable_lcdc_backlight);
252
9b93e244
KM
253static void __init kzm_init(void)
254{
255 sh73a0_pinmux_init();
256
257 /* enable SCIFA4 */
258 gpio_request(GPIO_FN_SCIFA4_TXD, NULL);
259 gpio_request(GPIO_FN_SCIFA4_RXD, NULL);
260 gpio_request(GPIO_FN_SCIFA4_RTS_, NULL);
261 gpio_request(GPIO_FN_SCIFA4_CTS_, NULL);
262
c15c4257
KM
263 /* CS4 for SMSC/USB */
264 gpio_request(GPIO_FN_CS4_, NULL); /* CS4 */
265
266 /* SMSC */
267 gpio_request(GPIO_PORT224, NULL); /* IRQ3 */
268 gpio_direction_input(GPIO_PORT224);
269
26786111
KM
270 /* LCDC */
271 gpio_request(GPIO_FN_LCDD23, NULL);
272 gpio_request(GPIO_FN_LCDD22, NULL);
273 gpio_request(GPIO_FN_LCDD21, NULL);
274 gpio_request(GPIO_FN_LCDD20, NULL);
275 gpio_request(GPIO_FN_LCDD19, NULL);
276 gpio_request(GPIO_FN_LCDD18, NULL);
277 gpio_request(GPIO_FN_LCDD17, NULL);
278 gpio_request(GPIO_FN_LCDD16, NULL);
279 gpio_request(GPIO_FN_LCDD15, NULL);
280 gpio_request(GPIO_FN_LCDD14, NULL);
281 gpio_request(GPIO_FN_LCDD13, NULL);
282 gpio_request(GPIO_FN_LCDD12, NULL);
283 gpio_request(GPIO_FN_LCDD11, NULL);
284 gpio_request(GPIO_FN_LCDD10, NULL);
285 gpio_request(GPIO_FN_LCDD9, NULL);
286 gpio_request(GPIO_FN_LCDD8, NULL);
287 gpio_request(GPIO_FN_LCDD7, NULL);
288 gpio_request(GPIO_FN_LCDD6, NULL);
289 gpio_request(GPIO_FN_LCDD5, NULL);
290 gpio_request(GPIO_FN_LCDD4, NULL);
291 gpio_request(GPIO_FN_LCDD3, NULL);
292 gpio_request(GPIO_FN_LCDD2, NULL);
293 gpio_request(GPIO_FN_LCDD1, NULL);
294 gpio_request(GPIO_FN_LCDD0, NULL);
295 gpio_request(GPIO_FN_LCDDISP, NULL);
296 gpio_request(GPIO_FN_LCDDCK, NULL);
297
601df616
KM
298 gpio_request(GPIO_PORT222, NULL); /* LCDCDON */
299 gpio_request(GPIO_PORT226, NULL); /* SC */
26786111 300 gpio_direction_output(GPIO_PORT222, 1);
601df616 301 gpio_direction_output(GPIO_PORT226, 1);
26786111 302
407c0526
KM
303 /* Touchscreen */
304 gpio_request(GPIO_PORT223, NULL); /* IRQ8 */
305 gpio_direction_input(GPIO_PORT223);
306
cc2512bc
KM
307 /* enable MMCIF */
308 gpio_request(GPIO_FN_MMCCLK0, NULL);
309 gpio_request(GPIO_FN_MMCCMD0_PU, NULL);
310 gpio_request(GPIO_FN_MMCD0_0_PU, NULL);
311 gpio_request(GPIO_FN_MMCD0_1_PU, NULL);
312 gpio_request(GPIO_FN_MMCD0_2_PU, NULL);
313 gpio_request(GPIO_FN_MMCD0_3_PU, NULL);
314 gpio_request(GPIO_FN_MMCD0_4_PU, NULL);
315 gpio_request(GPIO_FN_MMCD0_5_PU, NULL);
316 gpio_request(GPIO_FN_MMCD0_6_PU, NULL);
317 gpio_request(GPIO_FN_MMCD0_7_PU, NULL);
318
9b93e244
KM
319#ifdef CONFIG_CACHE_L2X0
320 /* Early BRESP enable, Shared attribute override enable, 64K*8way */
321 l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff);
322#endif
323
407c0526
KM
324 i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices));
325
9b93e244
KM
326 sh73a0_add_standard_devices();
327 platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices));
328}
329
330MACHINE_START(KZM9G, "kzm9g")
331 .map_io = sh73a0_map_io,
332 .init_early = sh73a0_add_early_devices,
333 .nr_irqs = NR_IRQS_LEGACY,
334 .init_irq = sh73a0_init_irq,
335 .handle_irq = gic_handle_irq,
336 .init_machine = kzm_init,
337 .timer = &shmobile_timer,
338MACHINE_END
This page took 0.074052 seconds and 5 git commands to generate.