aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-shmobile/board-mackerel.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-shmobile/board-mackerel.c')
-rw-r--r--arch/arm/mach-shmobile/board-mackerel.c223
1 files changed, 83 insertions, 140 deletions
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
index 9b42fbd10f8e..865d56d96299 100644
--- a/arch/arm/mach-shmobile/board-mackerel.c
+++ b/arch/arm/mach-shmobile/board-mackerel.c
@@ -43,7 +43,6 @@
43#include <linux/smsc911x.h> 43#include <linux/smsc911x.h>
44#include <linux/sh_intc.h> 44#include <linux/sh_intc.h>
45#include <linux/tca6416_keypad.h> 45#include <linux/tca6416_keypad.h>
46#include <linux/usb/r8a66597.h>
47#include <linux/usb/renesas_usbhs.h> 46#include <linux/usb/renesas_usbhs.h>
48#include <linux/dma-mapping.h> 47#include <linux/dma-mapping.h>
49 48
@@ -145,11 +144,6 @@
145 * 1-2 short | VBUS 5V | Host 144 * 1-2 short | VBUS 5V | Host
146 * open | external VBUS | Function 145 * open | external VBUS | Function
147 * 146 *
148 * *1
149 * CN31 is used as
150 * CONFIG_USB_R8A66597_HCD Host
151 * CONFIG_USB_RENESAS_USBHS Function
152 *
153 * CAUTION 147 * CAUTION
154 * 148 *
155 * renesas_usbhs driver can use external interrupt mode 149 * renesas_usbhs driver can use external interrupt mode
@@ -161,15 +155,6 @@
161 * mackerel can not use external interrupt (IRQ7-PORT167) mode on "USB0", 155 * mackerel can not use external interrupt (IRQ7-PORT167) mode on "USB0",
162 * because Touchscreen is using IRQ7-PORT40. 156 * because Touchscreen is using IRQ7-PORT40.
163 * It is impossible to use IRQ7 demux on this board. 157 * It is impossible to use IRQ7 demux on this board.
164 *
165 * We can use external interrupt mode USB-Function on "USB1".
166 * USB1 can become Host by r8a66597, and become Function by renesas_usbhs.
167 * But don't select both drivers in same time.
168 * These uses same IRQ number for request_irq(), and aren't supporting
169 * IRQF_SHARED / IORESOURCE_IRQ_SHAREABLE.
170 *
171 * Actually these are old/new version of USB driver.
172 * This mean its register will be broken if it supports shared IRQ,
173 */ 158 */
174 159
175/* 160/*
@@ -208,6 +193,16 @@
208 */ 193 */
209 194
210/* 195/*
196 * FSI - AK4642
197 *
198 * it needs amixer settings for playing
199 *
200 * amixer set "Headphone" on
201 * amixer set "HPOUTL Mixer DACH" on
202 * amixer set "HPOUTR Mixer DACH" on
203 */
204
205/*
211 * FIXME !! 206 * FIXME !!
212 * 207 *
213 * gpio_no_direction 208 * gpio_no_direction
@@ -323,8 +318,14 @@ static struct sh_mobile_meram_info mackerel_meram_info = {
323 318
324static struct resource meram_resources[] = { 319static struct resource meram_resources[] = {
325 [0] = { 320 [0] = {
326 .name = "MERAM", 321 .name = "regs",
327 .start = 0xe8000000, 322 .start = 0xe8000000,
323 .end = 0xe807ffff,
324 .flags = IORESOURCE_MEM,
325 },
326 [1] = {
327 .name = "meram",
328 .start = 0xe8080000,
328 .end = 0xe81fffff, 329 .end = 0xe81fffff,
329 .flags = IORESOURCE_MEM, 330 .flags = IORESOURCE_MEM,
330 }, 331 },
@@ -356,29 +357,23 @@ static struct fb_videomode mackerel_lcdc_modes[] = {
356 }, 357 },
357}; 358};
358 359
359static int mackerel_set_brightness(void *board_data, int brightness) 360static int mackerel_set_brightness(int brightness)
360{ 361{
361 gpio_set_value(GPIO_PORT31, brightness); 362 gpio_set_value(GPIO_PORT31, brightness);
362 363
363 return 0; 364 return 0;
364} 365}
365 366
366static int mackerel_get_brightness(void *board_data) 367static int mackerel_get_brightness(void)
367{ 368{
368 return gpio_get_value(GPIO_PORT31); 369 return gpio_get_value(GPIO_PORT31);
369} 370}
370 371
371static struct sh_mobile_meram_cfg lcd_meram_cfg = { 372static const struct sh_mobile_meram_cfg lcd_meram_cfg = {
372 .icb[0] = { 373 .icb[0] = {
373 .marker_icb = 28,
374 .cache_icb = 24,
375 .meram_offset = 0x0,
376 .meram_size = 0x40, 374 .meram_size = 0x40,
377 }, 375 },
378 .icb[1] = { 376 .icb[1] = {
379 .marker_icb = 29,
380 .cache_icb = 25,
381 .meram_offset = 0x40,
382 .meram_size = 0x40, 377 .meram_size = 0x40,
383 }, 378 },
384}; 379};
@@ -389,20 +384,20 @@ static struct sh_mobile_lcdc_info lcdc_info = {
389 .ch[0] = { 384 .ch[0] = {
390 .chan = LCDC_CHAN_MAINLCD, 385 .chan = LCDC_CHAN_MAINLCD,
391 .fourcc = V4L2_PIX_FMT_RGB565, 386 .fourcc = V4L2_PIX_FMT_RGB565,
392 .lcd_cfg = mackerel_lcdc_modes, 387 .lcd_modes = mackerel_lcdc_modes,
393 .num_cfg = ARRAY_SIZE(mackerel_lcdc_modes), 388 .num_modes = ARRAY_SIZE(mackerel_lcdc_modes),
394 .interface_type = RGB24, 389 .interface_type = RGB24,
395 .clock_divider = 3, 390 .clock_divider = 3,
396 .flags = 0, 391 .flags = 0,
397 .lcd_size_cfg.width = 152, 392 .panel_cfg = {
398 .lcd_size_cfg.height = 91, 393 .width = 152,
399 .board_cfg = { 394 .height = 91,
400 .set_brightness = mackerel_set_brightness,
401 .get_brightness = mackerel_get_brightness,
402 }, 395 },
403 .bl_info = { 396 .bl_info = {
404 .name = "sh_mobile_lcdc_bl", 397 .name = "sh_mobile_lcdc_bl",
405 .max_brightness = 1, 398 .max_brightness = 1,
399 .set_brightness = mackerel_set_brightness,
400 .get_brightness = mackerel_get_brightness,
406 }, 401 },
407 .meram_cfg = &lcd_meram_cfg, 402 .meram_cfg = &lcd_meram_cfg,
408 } 403 }
@@ -431,21 +426,44 @@ static struct platform_device lcdc_device = {
431 }, 426 },
432}; 427};
433 428
434static struct sh_mobile_meram_cfg hdmi_meram_cfg = { 429/* HDMI */
430static struct sh_mobile_hdmi_info hdmi_info = {
431 .flags = HDMI_SND_SRC_SPDIF,
432};
433
434static struct resource hdmi_resources[] = {
435 [0] = {
436 .name = "HDMI",
437 .start = 0xe6be0000,
438 .end = 0xe6be00ff,
439 .flags = IORESOURCE_MEM,
440 },
441 [1] = {
442 /* There's also an HDMI interrupt on INTCS @ 0x18e0 */
443 .start = evt2irq(0x17e0),
444 .flags = IORESOURCE_IRQ,
445 },
446};
447
448static struct platform_device hdmi_device = {
449 .name = "sh-mobile-hdmi",
450 .num_resources = ARRAY_SIZE(hdmi_resources),
451 .resource = hdmi_resources,
452 .id = -1,
453 .dev = {
454 .platform_data = &hdmi_info,
455 },
456};
457
458static const struct sh_mobile_meram_cfg hdmi_meram_cfg = {
435 .icb[0] = { 459 .icb[0] = {
436 .marker_icb = 30,
437 .cache_icb = 26,
438 .meram_offset = 0x80,
439 .meram_size = 0x100, 460 .meram_size = 0x100,
440 }, 461 },
441 .icb[1] = { 462 .icb[1] = {
442 .marker_icb = 31,
443 .cache_icb = 27,
444 .meram_offset = 0x180,
445 .meram_size = 0x100, 463 .meram_size = 0x100,
446 }, 464 },
447}; 465};
448/* HDMI */ 466
449static struct sh_mobile_lcdc_info hdmi_lcdc_info = { 467static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
450 .meram_dev = &mackerel_meram_info, 468 .meram_dev = &mackerel_meram_info,
451 .clock_source = LCDC_CLK_EXTERNAL, 469 .clock_source = LCDC_CLK_EXTERNAL,
@@ -456,6 +474,7 @@ static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
456 .clock_divider = 1, 474 .clock_divider = 1,
457 .flags = LCDC_FLAGS_DWPOL, 475 .flags = LCDC_FLAGS_DWPOL,
458 .meram_cfg = &hdmi_meram_cfg, 476 .meram_cfg = &hdmi_meram_cfg,
477 .tx_dev = &hdmi_device,
459 } 478 }
460}; 479};
461 480
@@ -483,36 +502,6 @@ static struct platform_device hdmi_lcdc_device = {
483 }, 502 },
484}; 503};
485 504
486static struct sh_mobile_hdmi_info hdmi_info = {
487 .lcd_chan = &hdmi_lcdc_info.ch[0],
488 .lcd_dev = &hdmi_lcdc_device.dev,
489 .flags = HDMI_SND_SRC_SPDIF,
490};
491
492static struct resource hdmi_resources[] = {
493 [0] = {
494 .name = "HDMI",
495 .start = 0xe6be0000,
496 .end = 0xe6be00ff,
497 .flags = IORESOURCE_MEM,
498 },
499 [1] = {
500 /* There's also an HDMI interrupt on INTCS @ 0x18e0 */
501 .start = evt2irq(0x17e0),
502 .flags = IORESOURCE_IRQ,
503 },
504};
505
506static struct platform_device hdmi_device = {
507 .name = "sh-mobile-hdmi",
508 .num_resources = ARRAY_SIZE(hdmi_resources),
509 .resource = hdmi_resources,
510 .id = -1,
511 .dev = {
512 .platform_data = &hdmi_info,
513 },
514};
515
516static struct platform_device fsi_hdmi_device = { 505static struct platform_device fsi_hdmi_device = {
517 .name = "sh_fsi2_b_hdmi", 506 .name = "sh_fsi2_b_hdmi",
518}; 507};
@@ -676,51 +665,16 @@ static struct platform_device usbhs0_device = {
676 * Use J30 to select between Host and Function. This setting 665 * Use J30 to select between Host and Function. This setting
677 * can however not be detected by software. Hotplug of USBHS1 666 * can however not be detected by software. Hotplug of USBHS1
678 * is provided via IRQ8. 667 * is provided via IRQ8.
668 *
669 * Current USB1 works as "USB Host".
670 * - set J30 "short"
671 *
672 * If you want to use it as "USB gadget",
673 * - J30 "open"
674 * - modify usbhs1_get_id() USBHS_HOST -> USBHS_GADGET
675 * - add .get_vbus = usbhs_get_vbus in usbhs1_private
679 */ 676 */
680#define IRQ8 evt2irq(0x0300) 677#define IRQ8 evt2irq(0x0300)
681
682/* USBHS1 USB Host support via r8a66597_hcd */
683static void usb1_host_port_power(int port, int power)
684{
685 if (!power) /* only power-on is supported for now */
686 return;
687
688 /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */
689 __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008);
690}
691
692static struct r8a66597_platdata usb1_host_data = {
693 .on_chip = 1,
694 .port_power = usb1_host_port_power,
695};
696
697static struct resource usb1_host_resources[] = {
698 [0] = {
699 .name = "USBHS1",
700 .start = 0xe68b0000,
701 .end = 0xe68b00e6 - 1,
702 .flags = IORESOURCE_MEM,
703 },
704 [1] = {
705 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
706 .flags = IORESOURCE_IRQ,
707 },
708};
709
710static struct platform_device usb1_host_device = {
711 .name = "r8a66597_hcd",
712 .id = 1,
713 .dev = {
714 .dma_mask = NULL, /* not use dma */
715 .coherent_dma_mask = 0xffffffff,
716 .platform_data = &usb1_host_data,
717 },
718 .num_resources = ARRAY_SIZE(usb1_host_resources),
719 .resource = usb1_host_resources,
720};
721
722/* USBHS1 USB Function support via renesas_usbhs */
723
724#define USB_PHY_MODE (1 << 4) 678#define USB_PHY_MODE (1 << 4)
725#define USB_PHY_INT_EN ((1 << 3) | (1 << 2)) 679#define USB_PHY_INT_EN ((1 << 3) | (1 << 2))
726#define USB_PHY_ON (1 << 1) 680#define USB_PHY_ON (1 << 1)
@@ -776,7 +730,7 @@ static void usbhs1_hardware_exit(struct platform_device *pdev)
776 730
777static int usbhs1_get_id(struct platform_device *pdev) 731static int usbhs1_get_id(struct platform_device *pdev)
778{ 732{
779 return USBHS_GADGET; 733 return USBHS_HOST;
780} 734}
781 735
782static u32 usbhs1_pipe_cfg[] = { 736static u32 usbhs1_pipe_cfg[] = {
@@ -807,7 +761,6 @@ static struct usbhs_private usbhs1_private = {
807 .hardware_exit = usbhs1_hardware_exit, 761 .hardware_exit = usbhs1_hardware_exit,
808 .get_id = usbhs1_get_id, 762 .get_id = usbhs1_get_id,
809 .phy_reset = usbhs_phy_reset, 763 .phy_reset = usbhs_phy_reset,
810 .get_vbus = usbhs_get_vbus,
811 }, 764 },
812 .driver_param = { 765 .driver_param = {
813 .buswait_bwait = 4, 766 .buswait_bwait = 4,
@@ -901,7 +854,7 @@ static int __fsi_set_round_rate(struct clk *clk, long rate, int enable)
901 return clk_enable(clk); 854 return clk_enable(clk);
902} 855}
903 856
904static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable) 857static int fsi_b_set_rate(struct device *dev, int rate, int enable)
905{ 858{
906 struct clk *fsib_clk; 859 struct clk *fsib_clk;
907 struct clk *fdiv_clk = &sh7372_fsidivb_clk; 860 struct clk *fdiv_clk = &sh7372_fsidivb_clk;
@@ -910,10 +863,6 @@ static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable)
910 int ackmd_bpfmd; 863 int ackmd_bpfmd;
911 int ret; 864 int ret;
912 865
913 /* FSIA is slave mode. nothing to do here */
914 if (is_porta)
915 return 0;
916
917 /* clock start */ 866 /* clock start */
918 switch (rate) { 867 switch (rate) {
919 case 44100: 868 case 44100:
@@ -957,14 +906,16 @@ fsi_set_rate_end:
957} 906}
958 907
959static struct sh_fsi_platform_info fsi_info = { 908static struct sh_fsi_platform_info fsi_info = {
960 .porta_flags = SH_FSI_BRS_INV, 909 .port_a = {
961 910 .flags = SH_FSI_BRS_INV,
962 .portb_flags = SH_FSI_BRS_INV | 911 },
912 .port_b = {
913 .flags = SH_FSI_BRS_INV |
963 SH_FSI_BRM_INV | 914 SH_FSI_BRM_INV |
964 SH_FSI_LRS_INV | 915 SH_FSI_LRS_INV |
965 SH_FSI_FMT_SPDIF, 916 SH_FSI_FMT_SPDIF,
966 917 .set_rate = fsi_b_set_rate,
967 .set_rate = fsi_set_rate, 918 }
968}; 919};
969 920
970static struct resource fsi_resources[] = { 921static struct resource fsi_resources[] = {
@@ -1184,15 +1135,6 @@ static struct resource sh_mmcif_resources[] = {
1184 }, 1135 },
1185}; 1136};
1186 1137
1187static struct sh_mmcif_dma sh_mmcif_dma = {
1188 .chan_priv_rx = {
1189 .slave_id = SHDMA_SLAVE_MMCIF_RX,
1190 },
1191 .chan_priv_tx = {
1192 .slave_id = SHDMA_SLAVE_MMCIF_TX,
1193 },
1194};
1195
1196static struct sh_mmcif_plat_data sh_mmcif_plat = { 1138static struct sh_mmcif_plat_data sh_mmcif_plat = {
1197 .sup_pclk = 0, 1139 .sup_pclk = 0,
1198 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34, 1140 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
@@ -1200,7 +1142,8 @@ static struct sh_mmcif_plat_data sh_mmcif_plat = {
1200 MMC_CAP_8_BIT_DATA | 1142 MMC_CAP_8_BIT_DATA |
1201 MMC_CAP_NEEDS_POLL, 1143 MMC_CAP_NEEDS_POLL,
1202 .get_cd = slot_cn7_get_cd, 1144 .get_cd = slot_cn7_get_cd,
1203 .dma = &sh_mmcif_dma, 1145 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
1146 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
1204}; 1147};
1205 1148
1206static struct platform_device sh_mmcif_device = { 1149static struct platform_device sh_mmcif_device = {
@@ -1311,7 +1254,6 @@ static struct platform_device *mackerel_devices[] __initdata = {
1311 &nor_flash_device, 1254 &nor_flash_device,
1312 &smc911x_device, 1255 &smc911x_device,
1313 &lcdc_device, 1256 &lcdc_device,
1314 &usb1_host_device,
1315 &usbhs1_device, 1257 &usbhs1_device,
1316 &usbhs0_device, 1258 &usbhs0_device,
1317 &leds_device, 1259 &leds_device,
@@ -1326,8 +1268,8 @@ static struct platform_device *mackerel_devices[] __initdata = {
1326 &sh_mmcif_device, 1268 &sh_mmcif_device,
1327 &ceu_device, 1269 &ceu_device,
1328 &mackerel_camera, 1270 &mackerel_camera,
1329 &hdmi_lcdc_device,
1330 &hdmi_device, 1271 &hdmi_device,
1272 &hdmi_lcdc_device,
1331 &meram_device, 1273 &meram_device,
1332}; 1274};
1333 1275
@@ -1402,6 +1344,10 @@ static struct map_desc mackerel_io_desc[] __initdata = {
1402static void __init mackerel_map_io(void) 1344static void __init mackerel_map_io(void)
1403{ 1345{
1404 iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc)); 1346 iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc));
1347 /* DMA memory at 0xff200000 - 0xffdfffff. The default 2MB size isn't
1348 * enough to allocate the frame buffer memory.
1349 */
1350 init_consistent_dma_size(12 << 20);
1405 1351
1406 /* setup early devices and console here as well */ 1352 /* setup early devices and console here as well */
1407 sh7372_add_early_devices(); 1353 sh7372_add_early_devices();
@@ -1473,9 +1419,6 @@ static void __init mackerel_init(void)
1473 gpio_pull_down(GPIO_PORT167CR); /* VBUS0_1 pull down */ 1419 gpio_pull_down(GPIO_PORT167CR); /* VBUS0_1 pull down */
1474 gpio_request(GPIO_FN_IDIN_1_113, NULL); 1420 gpio_request(GPIO_FN_IDIN_1_113, NULL);
1475 1421
1476 /* USB phy tweak to make the r8a66597_hcd host driver work */
1477 __raw_writew(0x8a0a, 0xe6058130); /* USBCR4 */
1478
1479 /* enable FSI2 port A (ak4643) */ 1422 /* enable FSI2 port A (ak4643) */
1480 gpio_request(GPIO_FN_FSIAIBT, NULL); 1423 gpio_request(GPIO_FN_FSIAIBT, NULL);
1481 gpio_request(GPIO_FN_FSIAILR, NULL); 1424 gpio_request(GPIO_FN_FSIAILR, NULL);