Commit | Line | Data |
---|---|---|
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 | 21 | #include <linux/gpio.h> |
1e354641 | 22 | #include <linux/gpio_keys.h> |
9b93e244 KM |
23 | #include <linux/io.h> |
24 | #include <linux/irq.h> | |
407c0526 | 25 | #include <linux/i2c.h> |
1e354641 KM |
26 | #include <linux/i2c/pcf857x.h> |
27 | #include <linux/input.h> | |
520f7bd7 | 28 | #include <linux/irqchip/arm-gic.h> |
cc2512bc KM |
29 | #include <linux/mmc/host.h> |
30 | #include <linux/mmc/sh_mmcif.h> | |
7775a933 KM |
31 | #include <linux/mmc/sh_mobile_sdhi.h> |
32 | #include <linux/mfd/tmio.h> | |
f3202e1b | 33 | #include <linux/pinctrl/machine.h> |
9b93e244 | 34 | #include <linux/platform_device.h> |
44a4244e GL |
35 | #include <linux/regulator/fixed.h> |
36 | #include <linux/regulator/machine.h> | |
c15c4257 | 37 | #include <linux/smsc911x.h> |
dd818180 | 38 | #include <linux/usb/r8a66597.h> |
77bcefd9 | 39 | #include <linux/usb/renesas_usbhs.h> |
26786111 | 40 | #include <linux/videodev2.h> |
accb90c8 KM |
41 | #include <sound/sh_fsi.h> |
42 | #include <sound/simple_card.h> | |
c15c4257 | 43 | #include <mach/irqs.h> |
9b93e244 KM |
44 | #include <mach/sh73a0.h> |
45 | #include <mach/common.h> | |
46 | #include <asm/hardware/cache-l2x0.h> | |
9b93e244 KM |
47 | #include <asm/mach-types.h> |
48 | #include <asm/mach/arch.h> | |
26786111 | 49 | #include <video/sh_mobile_lcdc.h> |
9b93e244 | 50 | |
1e354641 KM |
51 | /* |
52 | * external GPIO | |
53 | */ | |
54 | #define GPIO_PCF8575_BASE (GPIO_NR) | |
55 | #define GPIO_PCF8575_PORT10 (GPIO_NR + 8) | |
56 | #define GPIO_PCF8575_PORT11 (GPIO_NR + 9) | |
57 | #define GPIO_PCF8575_PORT12 (GPIO_NR + 10) | |
58 | #define GPIO_PCF8575_PORT13 (GPIO_NR + 11) | |
59 | #define GPIO_PCF8575_PORT14 (GPIO_NR + 12) | |
60 | #define GPIO_PCF8575_PORT15 (GPIO_NR + 13) | |
61 | #define GPIO_PCF8575_PORT16 (GPIO_NR + 14) | |
62 | ||
44a4244e GL |
63 | /* Dummy supplies, where voltage doesn't matter */ |
64 | static struct regulator_consumer_supply dummy_supplies[] = { | |
65 | REGULATOR_SUPPLY("vddvario", "smsc911x"), | |
66 | REGULATOR_SUPPLY("vdd33a", "smsc911x"), | |
67 | }; | |
68 | ||
accb90c8 KM |
69 | /* |
70 | * FSI-AK4648 | |
71 | * | |
72 | * this command is required when playback. | |
73 | * | |
74 | * # amixer set "LINEOUT Mixer DACL" on | |
75 | */ | |
76 | ||
c15c4257 KM |
77 | /* SMSC 9221 */ |
78 | static struct resource smsc9221_resources[] = { | |
79 | [0] = { | |
80 | .start = 0x10000000, /* CS4 */ | |
81 | .end = 0x100000ff, | |
82 | .flags = IORESOURCE_MEM, | |
83 | }, | |
84 | [1] = { | |
85 | .start = intcs_evt2irq(0x260), /* IRQ3 */ | |
86 | .flags = IORESOURCE_IRQ, | |
87 | }, | |
88 | }; | |
89 | ||
90 | static struct smsc911x_platform_config smsc9221_platdata = { | |
91 | .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS, | |
92 | .phy_interface = PHY_INTERFACE_MODE_MII, | |
93 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, | |
94 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, | |
95 | }; | |
96 | ||
97 | static struct platform_device smsc_device = { | |
98 | .name = "smsc911x", | |
99 | .dev = { | |
100 | .platform_data = &smsc9221_platdata, | |
101 | }, | |
102 | .resource = smsc9221_resources, | |
103 | .num_resources = ARRAY_SIZE(smsc9221_resources), | |
104 | }; | |
105 | ||
dd818180 KM |
106 | /* USB external chip */ |
107 | static struct r8a66597_platdata usb_host_data = { | |
108 | .on_chip = 0, | |
109 | .xtal = R8A66597_PLATDATA_XTAL_48MHZ, | |
110 | }; | |
111 | ||
112 | static struct resource usb_resources[] = { | |
113 | [0] = { | |
114 | .start = 0x10010000, | |
115 | .end = 0x1001ffff - 1, | |
116 | .flags = IORESOURCE_MEM, | |
117 | }, | |
118 | [1] = { | |
119 | .start = intcs_evt2irq(0x220), /* IRQ1 */ | |
120 | .flags = IORESOURCE_IRQ, | |
121 | }, | |
122 | }; | |
123 | ||
124 | static struct platform_device usb_host_device = { | |
125 | .name = "r8a66597_hcd", | |
126 | .dev = { | |
127 | .platform_data = &usb_host_data, | |
128 | .dma_mask = NULL, | |
129 | .coherent_dma_mask = 0xffffffff, | |
130 | }, | |
131 | .num_resources = ARRAY_SIZE(usb_resources), | |
132 | .resource = usb_resources, | |
133 | }; | |
134 | ||
77bcefd9 KM |
135 | /* USB Func CN17 */ |
136 | struct usbhs_private { | |
0a4b04dc AB |
137 | void __iomem *phy; |
138 | void __iomem *cr2; | |
77bcefd9 KM |
139 | struct renesas_usbhs_platform_info info; |
140 | }; | |
141 | ||
142 | #define IRQ15 intcs_evt2irq(0x03e0) | |
143 | #define USB_PHY_MODE (1 << 4) | |
144 | #define USB_PHY_INT_EN ((1 << 3) | (1 << 2)) | |
145 | #define USB_PHY_ON (1 << 1) | |
146 | #define USB_PHY_OFF (1 << 0) | |
147 | #define USB_PHY_INT_CLR (USB_PHY_ON | USB_PHY_OFF) | |
148 | ||
149 | #define usbhs_get_priv(pdev) \ | |
150 | container_of(renesas_usbhs_get_info(pdev), struct usbhs_private, info) | |
151 | ||
152 | static int usbhs_get_vbus(struct platform_device *pdev) | |
153 | { | |
154 | struct usbhs_private *priv = usbhs_get_priv(pdev); | |
155 | ||
156 | return !((1 << 7) & __raw_readw(priv->cr2)); | |
157 | } | |
158 | ||
159 | static void usbhs_phy_reset(struct platform_device *pdev) | |
160 | { | |
161 | struct usbhs_private *priv = usbhs_get_priv(pdev); | |
162 | ||
163 | /* init phy */ | |
164 | __raw_writew(0x8a0a, priv->cr2); | |
165 | } | |
166 | ||
167 | static int usbhs_get_id(struct platform_device *pdev) | |
168 | { | |
169 | return USBHS_GADGET; | |
170 | } | |
171 | ||
172 | static irqreturn_t usbhs_interrupt(int irq, void *data) | |
173 | { | |
174 | struct platform_device *pdev = data; | |
175 | struct usbhs_private *priv = usbhs_get_priv(pdev); | |
176 | ||
177 | renesas_usbhs_call_notify_hotplug(pdev); | |
178 | ||
179 | /* clear status */ | |
180 | __raw_writew(__raw_readw(priv->phy) | USB_PHY_INT_CLR, priv->phy); | |
181 | ||
182 | return IRQ_HANDLED; | |
183 | } | |
184 | ||
185 | static int usbhs_hardware_init(struct platform_device *pdev) | |
186 | { | |
187 | struct usbhs_private *priv = usbhs_get_priv(pdev); | |
188 | int ret; | |
189 | ||
190 | /* clear interrupt status */ | |
191 | __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->phy); | |
192 | ||
193 | ret = request_irq(IRQ15, usbhs_interrupt, IRQF_TRIGGER_HIGH, | |
194 | dev_name(&pdev->dev), pdev); | |
195 | if (ret) { | |
196 | dev_err(&pdev->dev, "request_irq err\n"); | |
197 | return ret; | |
198 | } | |
199 | ||
200 | /* enable USB phy interrupt */ | |
201 | __raw_writew(USB_PHY_MODE | USB_PHY_INT_EN, priv->phy); | |
202 | ||
203 | return 0; | |
204 | } | |
205 | ||
206 | static void usbhs_hardware_exit(struct platform_device *pdev) | |
207 | { | |
208 | struct usbhs_private *priv = usbhs_get_priv(pdev); | |
209 | ||
210 | /* clear interrupt status */ | |
211 | __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->phy); | |
212 | ||
213 | free_irq(IRQ15, pdev); | |
214 | } | |
215 | ||
216 | static u32 usbhs_pipe_cfg[] = { | |
217 | USB_ENDPOINT_XFER_CONTROL, | |
218 | USB_ENDPOINT_XFER_ISOC, | |
219 | USB_ENDPOINT_XFER_ISOC, | |
220 | USB_ENDPOINT_XFER_BULK, | |
221 | USB_ENDPOINT_XFER_BULK, | |
222 | USB_ENDPOINT_XFER_BULK, | |
223 | USB_ENDPOINT_XFER_INT, | |
224 | USB_ENDPOINT_XFER_INT, | |
225 | USB_ENDPOINT_XFER_INT, | |
226 | USB_ENDPOINT_XFER_BULK, | |
227 | USB_ENDPOINT_XFER_BULK, | |
228 | USB_ENDPOINT_XFER_BULK, | |
229 | USB_ENDPOINT_XFER_BULK, | |
230 | USB_ENDPOINT_XFER_BULK, | |
231 | USB_ENDPOINT_XFER_BULK, | |
232 | USB_ENDPOINT_XFER_BULK, | |
233 | }; | |
234 | ||
235 | static struct usbhs_private usbhs_private = { | |
0a4b04dc AB |
236 | .phy = IOMEM(0xe60781e0), /* USBPHYINT */ |
237 | .cr2 = IOMEM(0xe605810c), /* USBCR2 */ | |
77bcefd9 KM |
238 | .info = { |
239 | .platform_callback = { | |
240 | .hardware_init = usbhs_hardware_init, | |
241 | .hardware_exit = usbhs_hardware_exit, | |
242 | .get_id = usbhs_get_id, | |
243 | .phy_reset = usbhs_phy_reset, | |
244 | .get_vbus = usbhs_get_vbus, | |
245 | }, | |
246 | .driver_param = { | |
247 | .buswait_bwait = 4, | |
248 | .has_otg = 1, | |
249 | .pipe_type = usbhs_pipe_cfg, | |
250 | .pipe_size = ARRAY_SIZE(usbhs_pipe_cfg), | |
251 | }, | |
252 | }, | |
253 | }; | |
254 | ||
255 | static struct resource usbhs_resources[] = { | |
256 | [0] = { | |
257 | .start = 0xE6890000, | |
258 | .end = 0xE68900e6 - 1, | |
259 | .flags = IORESOURCE_MEM, | |
260 | }, | |
261 | [1] = { | |
262 | .start = gic_spi(62), | |
263 | .end = gic_spi(62), | |
264 | .flags = IORESOURCE_IRQ, | |
265 | }, | |
266 | }; | |
267 | ||
268 | static struct platform_device usbhs_device = { | |
269 | .name = "renesas_usbhs", | |
270 | .id = -1, | |
271 | .dev = { | |
272 | .dma_mask = NULL, | |
273 | .coherent_dma_mask = 0xffffffff, | |
274 | .platform_data = &usbhs_private.info, | |
275 | }, | |
276 | .num_resources = ARRAY_SIZE(usbhs_resources), | |
277 | .resource = usbhs_resources, | |
278 | }; | |
279 | ||
26786111 KM |
280 | /* LCDC */ |
281 | static struct fb_videomode kzm_lcdc_mode = { | |
282 | .name = "WVGA Panel", | |
283 | .xres = 800, | |
284 | .yres = 480, | |
285 | .left_margin = 220, | |
286 | .right_margin = 110, | |
287 | .hsync_len = 70, | |
288 | .upper_margin = 20, | |
289 | .lower_margin = 5, | |
290 | .vsync_len = 5, | |
291 | .sync = 0, | |
292 | }; | |
293 | ||
294 | static struct sh_mobile_lcdc_info lcdc_info = { | |
295 | .clock_source = LCDC_CLK_BUS, | |
296 | .ch[0] = { | |
297 | .chan = LCDC_CHAN_MAINLCD, | |
298 | .fourcc = V4L2_PIX_FMT_RGB565, | |
299 | .interface_type = RGB24, | |
300 | .lcd_modes = &kzm_lcdc_mode, | |
301 | .num_modes = 1, | |
302 | .clock_divider = 5, | |
303 | .flags = 0, | |
304 | .panel_cfg = { | |
305 | .width = 152, | |
306 | .height = 91, | |
307 | }, | |
308 | } | |
309 | }; | |
310 | ||
311 | static struct resource lcdc_resources[] = { | |
312 | [0] = { | |
313 | .name = "LCDC", | |
314 | .start = 0xfe940000, | |
315 | .end = 0xfe943fff, | |
316 | .flags = IORESOURCE_MEM, | |
317 | }, | |
318 | [1] = { | |
319 | .start = intcs_evt2irq(0x580), | |
320 | .flags = IORESOURCE_IRQ, | |
321 | }, | |
322 | }; | |
323 | ||
324 | static struct platform_device lcdc_device = { | |
325 | .name = "sh_mobile_lcdc_fb", | |
326 | .num_resources = ARRAY_SIZE(lcdc_resources), | |
327 | .resource = lcdc_resources, | |
328 | .dev = { | |
329 | .platform_data = &lcdc_info, | |
330 | .coherent_dma_mask = ~0, | |
331 | }, | |
332 | }; | |
333 | ||
44a4244e GL |
334 | /* Fixed 1.8V regulator to be used by MMCIF */ |
335 | static struct regulator_consumer_supply fixed1v8_power_consumers[] = | |
336 | { | |
337 | REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"), | |
338 | REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"), | |
339 | }; | |
340 | ||
cc2512bc KM |
341 | /* MMCIF */ |
342 | static struct resource sh_mmcif_resources[] = { | |
343 | [0] = { | |
344 | .name = "MMCIF", | |
345 | .start = 0xe6bd0000, | |
346 | .end = 0xe6bd00ff, | |
347 | .flags = IORESOURCE_MEM, | |
348 | }, | |
349 | [1] = { | |
a704835d | 350 | .start = gic_spi(140), |
cc2512bc KM |
351 | .flags = IORESOURCE_IRQ, |
352 | }, | |
353 | [2] = { | |
a704835d | 354 | .start = gic_spi(141), |
cc2512bc KM |
355 | .flags = IORESOURCE_IRQ, |
356 | }, | |
357 | }; | |
358 | ||
359 | static struct sh_mmcif_plat_data sh_mmcif_platdata = { | |
360 | .ocr = MMC_VDD_165_195, | |
361 | .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE, | |
a1ca8f49 KM |
362 | .slave_id_tx = SHDMA_SLAVE_MMCIF_TX, |
363 | .slave_id_rx = SHDMA_SLAVE_MMCIF_RX, | |
cc2512bc KM |
364 | }; |
365 | ||
366 | static struct platform_device mmc_device = { | |
367 | .name = "sh_mmcif", | |
368 | .dev = { | |
369 | .dma_mask = NULL, | |
370 | .coherent_dma_mask = 0xffffffff, | |
371 | .platform_data = &sh_mmcif_platdata, | |
372 | }, | |
373 | .num_resources = ARRAY_SIZE(sh_mmcif_resources), | |
374 | .resource = sh_mmcif_resources, | |
375 | }; | |
376 | ||
11b8e452 | 377 | /* Fixed 2.8V regulators to be used by SDHI0 and SDHI2 */ |
44a4244e GL |
378 | static struct regulator_consumer_supply fixed2v8_power_consumers[] = |
379 | { | |
380 | REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"), | |
381 | REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"), | |
11b8e452 GL |
382 | REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.2"), |
383 | REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.2"), | |
44a4244e GL |
384 | }; |
385 | ||
7775a933 KM |
386 | /* SDHI */ |
387 | static struct sh_mobile_sdhi_info sdhi0_info = { | |
bd9e2e71 TK |
388 | .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, |
389 | .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX, | |
7775a933 KM |
390 | .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT, |
391 | .tmio_caps = MMC_CAP_SD_HIGHSPEED, | |
392 | .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29, | |
393 | }; | |
394 | ||
395 | static struct resource sdhi0_resources[] = { | |
396 | [0] = { | |
397 | .name = "SDHI0", | |
398 | .start = 0xee100000, | |
399 | .end = 0xee1000ff, | |
400 | .flags = IORESOURCE_MEM, | |
401 | }, | |
402 | [1] = { | |
403 | .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT, | |
404 | .start = gic_spi(83), | |
405 | .flags = IORESOURCE_IRQ, | |
406 | }, | |
407 | [2] = { | |
408 | .name = SH_MOBILE_SDHI_IRQ_SDCARD, | |
409 | .start = gic_spi(84), | |
410 | .flags = IORESOURCE_IRQ, | |
411 | }, | |
412 | [3] = { | |
413 | .name = SH_MOBILE_SDHI_IRQ_SDIO, | |
414 | .start = gic_spi(85), | |
415 | .flags = IORESOURCE_IRQ, | |
416 | }, | |
417 | }; | |
418 | ||
419 | static struct platform_device sdhi0_device = { | |
420 | .name = "sh_mobile_sdhi", | |
421 | .num_resources = ARRAY_SIZE(sdhi0_resources), | |
422 | .resource = sdhi0_resources, | |
423 | .dev = { | |
424 | .platform_data = &sdhi0_info, | |
425 | }, | |
426 | }; | |
427 | ||
425d6940 KM |
428 | /* Micro SD */ |
429 | static struct sh_mobile_sdhi_info sdhi2_info = { | |
bd9e2e71 TK |
430 | .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX, |
431 | .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX, | |
425d6940 KM |
432 | .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | |
433 | TMIO_MMC_USE_GPIO_CD | | |
434 | TMIO_MMC_WRPROTECT_DISABLE, | |
435 | .tmio_caps = MMC_CAP_SD_HIGHSPEED, | |
436 | .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29, | |
b58e5fac | 437 | .cd_gpio = 13, |
425d6940 KM |
438 | }; |
439 | ||
440 | static struct resource sdhi2_resources[] = { | |
441 | [0] = { | |
442 | .name = "SDHI2", | |
443 | .start = 0xee140000, | |
444 | .end = 0xee1400ff, | |
445 | .flags = IORESOURCE_MEM, | |
446 | }, | |
447 | [1] = { | |
448 | .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT, | |
449 | .start = gic_spi(103), | |
450 | .flags = IORESOURCE_IRQ, | |
451 | }, | |
452 | [2] = { | |
453 | .name = SH_MOBILE_SDHI_IRQ_SDCARD, | |
454 | .start = gic_spi(104), | |
455 | .flags = IORESOURCE_IRQ, | |
456 | }, | |
457 | [3] = { | |
458 | .name = SH_MOBILE_SDHI_IRQ_SDIO, | |
459 | .start = gic_spi(105), | |
460 | .flags = IORESOURCE_IRQ, | |
461 | }, | |
462 | }; | |
463 | ||
464 | static struct platform_device sdhi2_device = { | |
465 | .name = "sh_mobile_sdhi", | |
466 | .id = 2, | |
467 | .num_resources = ARRAY_SIZE(sdhi2_resources), | |
468 | .resource = sdhi2_resources, | |
469 | .dev = { | |
470 | .platform_data = &sdhi2_info, | |
471 | }, | |
472 | }; | |
473 | ||
1e354641 KM |
474 | /* KEY */ |
475 | #define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 } | |
476 | ||
477 | static struct gpio_keys_button gpio_buttons[] = { | |
478 | GPIO_KEY(KEY_BACK, GPIO_PCF8575_PORT10, "SW3"), | |
479 | GPIO_KEY(KEY_RIGHT, GPIO_PCF8575_PORT11, "SW2-R"), | |
480 | GPIO_KEY(KEY_LEFT, GPIO_PCF8575_PORT12, "SW2-L"), | |
481 | GPIO_KEY(KEY_ENTER, GPIO_PCF8575_PORT13, "SW2-P"), | |
482 | GPIO_KEY(KEY_UP, GPIO_PCF8575_PORT14, "SW2-U"), | |
483 | GPIO_KEY(KEY_DOWN, GPIO_PCF8575_PORT15, "SW2-D"), | |
484 | GPIO_KEY(KEY_HOME, GPIO_PCF8575_PORT16, "SW1"), | |
485 | }; | |
486 | ||
487 | static struct gpio_keys_platform_data gpio_key_info = { | |
488 | .buttons = gpio_buttons, | |
489 | .nbuttons = ARRAY_SIZE(gpio_buttons), | |
1e354641 KM |
490 | }; |
491 | ||
492 | static struct platform_device gpio_keys_device = { | |
ee6691d7 | 493 | .name = "gpio-keys", |
1e354641 KM |
494 | .dev = { |
495 | .platform_data = &gpio_key_info, | |
496 | }, | |
497 | }; | |
498 | ||
accb90c8 KM |
499 | /* FSI-AK4648 */ |
500 | static struct sh_fsi_platform_info fsi_info = { | |
501 | .port_a = { | |
76b80329 | 502 | .tx_id = SHDMA_SLAVE_FSI2A_TX, |
accb90c8 KM |
503 | }, |
504 | }; | |
505 | ||
506 | static struct resource fsi_resources[] = { | |
507 | [0] = { | |
508 | .name = "FSI", | |
509 | .start = 0xEC230000, | |
510 | .end = 0xEC230400 - 1, | |
511 | .flags = IORESOURCE_MEM, | |
512 | }, | |
513 | [1] = { | |
514 | .start = gic_spi(146), | |
515 | .flags = IORESOURCE_IRQ, | |
516 | }, | |
517 | }; | |
518 | ||
519 | static struct platform_device fsi_device = { | |
520 | .name = "sh_fsi2", | |
521 | .id = -1, | |
522 | .num_resources = ARRAY_SIZE(fsi_resources), | |
523 | .resource = fsi_resources, | |
524 | .dev = { | |
525 | .platform_data = &fsi_info, | |
526 | }, | |
527 | }; | |
528 | ||
accb90c8 KM |
529 | static struct asoc_simple_card_info fsi2_ak4648_info = { |
530 | .name = "AK4648", | |
531 | .card = "FSI2A-AK4648", | |
accb90c8 KM |
532 | .codec = "ak4642-codec.0-0012", |
533 | .platform = "sh_fsi2", | |
a4a2992c KM |
534 | .daifmt = SND_SOC_DAIFMT_LEFT_J, |
535 | .cpu_dai = { | |
536 | .name = "fsia-dai", | |
537 | .fmt = SND_SOC_DAIFMT_CBS_CFS, | |
538 | }, | |
539 | .codec_dai = { | |
540 | .name = "ak4642-hifi", | |
541 | .fmt = SND_SOC_DAIFMT_CBM_CFM, | |
542 | .sysclk = 11289600, | |
543 | }, | |
accb90c8 KM |
544 | }; |
545 | ||
546 | static struct platform_device fsi_ak4648_device = { | |
547 | .name = "asoc-simple-card", | |
548 | .dev = { | |
549 | .platform_data = &fsi2_ak4648_info, | |
550 | }, | |
551 | }; | |
552 | ||
7775a933 | 553 | /* I2C */ |
1e354641 KM |
554 | static struct pcf857x_platform_data pcf8575_pdata = { |
555 | .gpio_base = GPIO_PCF8575_BASE, | |
556 | }; | |
557 | ||
accb90c8 KM |
558 | static struct i2c_board_info i2c0_devices[] = { |
559 | { | |
560 | I2C_BOARD_INFO("ak4648", 0x12), | |
080e0d13 TK |
561 | }, |
562 | { | |
563 | I2C_BOARD_INFO("r2025sd", 0x32), | |
8cec0123 TK |
564 | }, |
565 | { | |
566 | I2C_BOARD_INFO("ak8975", 0x0c), | |
567 | .irq = intcs_evt2irq(0x3380), /* IRQ28 */ | |
568 | }, | |
608c5620 TK |
569 | { |
570 | I2C_BOARD_INFO("adxl34x", 0x1d), | |
571 | .irq = intcs_evt2irq(0x3340), /* IRQ26 */ | |
572 | }, | |
accb90c8 KM |
573 | }; |
574 | ||
407c0526 KM |
575 | static struct i2c_board_info i2c1_devices[] = { |
576 | { | |
577 | I2C_BOARD_INFO("st1232-ts", 0x55), | |
578 | .irq = intcs_evt2irq(0x300), /* IRQ8 */ | |
579 | }, | |
580 | }; | |
581 | ||
1e354641 KM |
582 | static struct i2c_board_info i2c3_devices[] = { |
583 | { | |
584 | I2C_BOARD_INFO("pcf8575", 0x20), | |
805f864e | 585 | .irq = intcs_evt2irq(0x3260), /* IRQ19 */ |
1e354641 KM |
586 | .platform_data = &pcf8575_pdata, |
587 | }, | |
588 | }; | |
589 | ||
9b93e244 | 590 | static struct platform_device *kzm_devices[] __initdata = { |
c15c4257 | 591 | &smsc_device, |
dd818180 | 592 | &usb_host_device, |
77bcefd9 | 593 | &usbhs_device, |
26786111 | 594 | &lcdc_device, |
cc2512bc | 595 | &mmc_device, |
7775a933 | 596 | &sdhi0_device, |
425d6940 | 597 | &sdhi2_device, |
1e354641 | 598 | &gpio_keys_device, |
accb90c8 KM |
599 | &fsi_device, |
600 | &fsi_ak4648_device, | |
9b93e244 KM |
601 | }; |
602 | ||
f3202e1b LP |
603 | static const struct pinctrl_map kzm_pinctrl_map[] = { |
604 | /* LCD */ | |
605 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-sh73a0", | |
606 | "lcd_data24", "lcd"), | |
607 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-sh73a0", | |
608 | "lcd_sync", "lcd"), | |
5606ed9c LP |
609 | /* SCIFA4 */ |
610 | PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-sh73a0", | |
611 | "scifa4_data", "scifa4"), | |
612 | PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.4", "pfc-sh73a0", | |
613 | "scifa4_ctrl", "scifa4"), | |
f3202e1b LP |
614 | }; |
615 | ||
26786111 KM |
616 | /* |
617 | * FIXME | |
618 | * | |
619 | * This is quick hack for enabling LCDC backlight | |
620 | */ | |
621 | static int __init as3711_enable_lcdc_backlight(void) | |
622 | { | |
623 | struct i2c_adapter *a = i2c_get_adapter(0); | |
624 | struct i2c_msg msg; | |
625 | int i, ret; | |
626 | __u8 magic[] = { | |
627 | 0x40, 0x2a, | |
628 | 0x43, 0x3c, | |
629 | 0x44, 0x3c, | |
630 | 0x45, 0x3c, | |
631 | 0x54, 0x03, | |
632 | 0x51, 0x00, | |
633 | 0x51, 0x01, | |
634 | 0xff, 0x00, /* wait */ | |
635 | 0x43, 0xf0, | |
636 | 0x44, 0xf0, | |
637 | 0x45, 0xf0, | |
638 | }; | |
639 | ||
cf244505 | 640 | if (!of_machine_is_compatible("renesas,kzm9g")) |
26786111 KM |
641 | return 0; |
642 | ||
643 | if (!a) | |
644 | return 0; | |
645 | ||
646 | msg.addr = 0x40; | |
647 | msg.len = 2; | |
648 | msg.flags = 0; | |
649 | ||
650 | for (i = 0; i < ARRAY_SIZE(magic); i += 2) { | |
651 | msg.buf = magic + i; | |
652 | ||
653 | if (0xff == msg.buf[0]) { | |
654 | udelay(500); | |
655 | continue; | |
656 | } | |
657 | ||
658 | ret = i2c_transfer(a, &msg, 1); | |
659 | if (ret < 0) { | |
660 | pr_err("i2c transfer fail\n"); | |
661 | break; | |
662 | } | |
663 | } | |
664 | ||
665 | return 0; | |
666 | } | |
667 | device_initcall(as3711_enable_lcdc_backlight); | |
668 | ||
9b93e244 KM |
669 | static void __init kzm_init(void) |
670 | { | |
44a4244e GL |
671 | regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers, |
672 | ARRAY_SIZE(fixed1v8_power_consumers), 1800000); | |
673 | regulator_register_always_on(1, "fixed-2.8V", fixed2v8_power_consumers, | |
674 | ARRAY_SIZE(fixed2v8_power_consumers), 2800000); | |
675 | regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies)); | |
676 | ||
f3202e1b LP |
677 | pinctrl_register_mappings(kzm_pinctrl_map, ARRAY_SIZE(kzm_pinctrl_map)); |
678 | ||
9b93e244 KM |
679 | sh73a0_pinmux_init(); |
680 | ||
c15c4257 KM |
681 | /* CS4 for SMSC/USB */ |
682 | gpio_request(GPIO_FN_CS4_, NULL); /* CS4 */ | |
683 | ||
684 | /* SMSC */ | |
b58e5fac | 685 | gpio_request_one(224, GPIOF_IN, NULL); /* IRQ3 */ |
c15c4257 | 686 | |
26786111 | 687 | /* LCDC */ |
b58e5fac GL |
688 | gpio_request_one(222, GPIOF_OUT_INIT_HIGH, NULL); /* LCDCDON */ |
689 | gpio_request_one(226, GPIOF_OUT_INIT_HIGH, NULL); /* SC */ | |
26786111 | 690 | |
407c0526 | 691 | /* Touchscreen */ |
b58e5fac | 692 | gpio_request_one(223, GPIOF_IN, NULL); /* IRQ8 */ |
407c0526 | 693 | |
cc2512bc KM |
694 | /* enable MMCIF */ |
695 | gpio_request(GPIO_FN_MMCCLK0, NULL); | |
696 | gpio_request(GPIO_FN_MMCCMD0_PU, NULL); | |
697 | gpio_request(GPIO_FN_MMCD0_0_PU, NULL); | |
698 | gpio_request(GPIO_FN_MMCD0_1_PU, NULL); | |
699 | gpio_request(GPIO_FN_MMCD0_2_PU, NULL); | |
700 | gpio_request(GPIO_FN_MMCD0_3_PU, NULL); | |
701 | gpio_request(GPIO_FN_MMCD0_4_PU, NULL); | |
702 | gpio_request(GPIO_FN_MMCD0_5_PU, NULL); | |
703 | gpio_request(GPIO_FN_MMCD0_6_PU, NULL); | |
704 | gpio_request(GPIO_FN_MMCD0_7_PU, NULL); | |
705 | ||
7775a933 KM |
706 | /* enable SD */ |
707 | gpio_request(GPIO_FN_SDHIWP0, NULL); | |
708 | gpio_request(GPIO_FN_SDHICD0, NULL); | |
709 | gpio_request(GPIO_FN_SDHICMD0, NULL); | |
710 | gpio_request(GPIO_FN_SDHICLK0, NULL); | |
711 | gpio_request(GPIO_FN_SDHID0_3, NULL); | |
712 | gpio_request(GPIO_FN_SDHID0_2, NULL); | |
713 | gpio_request(GPIO_FN_SDHID0_1, NULL); | |
714 | gpio_request(GPIO_FN_SDHID0_0, NULL); | |
715 | gpio_request(GPIO_FN_SDHI0_VCCQ_MC0_ON, NULL); | |
b58e5fac | 716 | gpio_request_one(15, GPIOF_OUT_INIT_HIGH, NULL); /* power */ |
7775a933 | 717 | |
425d6940 KM |
718 | /* enable Micro SD */ |
719 | gpio_request(GPIO_FN_SDHID2_0, NULL); | |
720 | gpio_request(GPIO_FN_SDHID2_1, NULL); | |
721 | gpio_request(GPIO_FN_SDHID2_2, NULL); | |
722 | gpio_request(GPIO_FN_SDHID2_3, NULL); | |
723 | gpio_request(GPIO_FN_SDHICMD2, NULL); | |
724 | gpio_request(GPIO_FN_SDHICLK2, NULL); | |
b58e5fac | 725 | gpio_request_one(14, GPIOF_OUT_INIT_HIGH, NULL); /* power */ |
425d6940 | 726 | |
1e354641 KM |
727 | /* I2C 3 */ |
728 | gpio_request(GPIO_FN_PORT27_I2C_SCL3, NULL); | |
729 | gpio_request(GPIO_FN_PORT28_I2C_SDA3, NULL); | |
730 | ||
accb90c8 KM |
731 | /* enable FSI2 port A (ak4648) */ |
732 | gpio_request(GPIO_FN_FSIACK, NULL); | |
733 | gpio_request(GPIO_FN_FSIAILR, NULL); | |
734 | gpio_request(GPIO_FN_FSIAIBT, NULL); | |
735 | gpio_request(GPIO_FN_FSIAISLD, NULL); | |
736 | gpio_request(GPIO_FN_FSIAOSLD, NULL); | |
737 | ||
77bcefd9 KM |
738 | /* enable USB */ |
739 | gpio_request(GPIO_FN_VBUS_0, NULL); | |
740 | ||
9b93e244 KM |
741 | #ifdef CONFIG_CACHE_L2X0 |
742 | /* Early BRESP enable, Shared attribute override enable, 64K*8way */ | |
743 | l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff); | |
744 | #endif | |
745 | ||
accb90c8 | 746 | i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices)); |
407c0526 | 747 | i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices)); |
1e354641 | 748 | i2c_register_board_info(3, i2c3_devices, ARRAY_SIZE(i2c3_devices)); |
407c0526 | 749 | |
9b93e244 KM |
750 | sh73a0_add_standard_devices(); |
751 | platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices)); | |
13baf88b BH |
752 | |
753 | sh73a0_pm_init(); | |
9b93e244 KM |
754 | } |
755 | ||
7952717a TK |
756 | static void kzm9g_restart(char mode, const char *cmd) |
757 | { | |
28901c1f | 758 | #define RESCNT2 IOMEM(0xe6188020) |
7952717a TK |
759 | /* Do soft power on reset */ |
760 | writel((1 << 31), RESCNT2); | |
761 | } | |
762 | ||
7296d932 MD |
763 | static const char *kzm9g_boards_compat_dt[] __initdata = { |
764 | "renesas,kzm9g", | |
765 | NULL, | |
766 | }; | |
767 | ||
768 | DT_MACHINE_START(KZM9G_DT, "kzm9g") | |
a62580e5 | 769 | .smp = smp_ops(sh73a0_smp_ops), |
9b93e244 KM |
770 | .map_io = sh73a0_map_io, |
771 | .init_early = sh73a0_add_early_devices, | |
772 | .nr_irqs = NR_IRQS_LEGACY, | |
773 | .init_irq = sh73a0_init_irq, | |
9b93e244 | 774 | .init_machine = kzm_init, |
14dd52f4 | 775 | .init_late = shmobile_init_late, |
6bb27d73 | 776 | .init_time = sh73a0_earlytimer_init, |
7952717a | 777 | .restart = kzm9g_restart, |
7296d932 | 778 | .dt_compat = kzm9g_boards_compat_dt, |
9b93e244 | 779 | MACHINE_END |