Merge tag 'renesas-soc-r8a7790-for-v3.10' of git://git.kernel.org/pub/scm/linux/kerne...
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / mach-mmp / gplugd.c
1 /*
2 * linux/arch/arm/mach-mmp/gplugd.c
3 *
4 * Support for the Marvell PXA168-based GuruPlug Display (gplugD) Platform.
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 version 2 as
8 * publishhed by the Free Software Foundation.
9 */
10
11 #include <linux/init.h>
12 #include <linux/platform_device.h>
13 #include <linux/gpio.h>
14
15 #include <asm/mach/arch.h>
16 #include <asm/mach-types.h>
17
18 #include <mach/irqs.h>
19 #include <mach/pxa168.h>
20 #include <mach/mfp-pxa168.h>
21
22 #include "common.h"
23
24 static unsigned long gplugd_pin_config[] __initdata = {
25 /* UART3 */
26 GPIO8_UART3_TXD,
27 GPIO9_UART3_RXD,
28 GPIO1O_UART3_CTS,
29 GPIO11_UART3_RTS,
30
31 /* USB OTG PEN */
32 GPIO18_GPIO,
33
34 /* MMC2 */
35 GPIO28_MMC2_CMD,
36 GPIO29_MMC2_CLK,
37 GPIO30_MMC2_DAT0,
38 GPIO31_MMC2_DAT1,
39 GPIO32_MMC2_DAT2,
40 GPIO33_MMC2_DAT3,
41
42 /* LCD & HDMI clock selection GPIO: 0: 74.176MHz, 1: 74.25 MHz */
43 GPIO35_GPIO,
44 GPIO36_GPIO, /* CEC Interrupt */
45
46 /* MMC1 */
47 GPIO43_MMC1_CLK,
48 GPIO49_MMC1_CMD,
49 GPIO41_MMC1_DAT0,
50 GPIO40_MMC1_DAT1,
51 GPIO52_MMC1_DAT2,
52 GPIO51_MMC1_DAT3,
53 GPIO53_MMC1_CD,
54
55 /* LCD */
56 GPIO56_LCD_FCLK_RD,
57 GPIO57_LCD_LCLK_A0,
58 GPIO58_LCD_PCLK_WR,
59 GPIO59_LCD_DENA_BIAS,
60 GPIO60_LCD_DD0,
61 GPIO61_LCD_DD1,
62 GPIO62_LCD_DD2,
63 GPIO63_LCD_DD3,
64 GPIO64_LCD_DD4,
65 GPIO65_LCD_DD5,
66 GPIO66_LCD_DD6,
67 GPIO67_LCD_DD7,
68 GPIO68_LCD_DD8,
69 GPIO69_LCD_DD9,
70 GPIO70_LCD_DD10,
71 GPIO71_LCD_DD11,
72 GPIO72_LCD_DD12,
73 GPIO73_LCD_DD13,
74 GPIO74_LCD_DD14,
75 GPIO75_LCD_DD15,
76 GPIO76_LCD_DD16,
77 GPIO77_LCD_DD17,
78 GPIO78_LCD_DD18,
79 GPIO79_LCD_DD19,
80 GPIO80_LCD_DD20,
81 GPIO81_LCD_DD21,
82 GPIO82_LCD_DD22,
83 GPIO83_LCD_DD23,
84
85 /* GPIO */
86 GPIO84_GPIO,
87 GPIO85_GPIO,
88
89 /* Fast-Ethernet*/
90 GPIO86_TX_CLK,
91 GPIO87_TX_EN,
92 GPIO88_TX_DQ3,
93 GPIO89_TX_DQ2,
94 GPIO90_TX_DQ1,
95 GPIO91_TX_DQ0,
96 GPIO92_MII_CRS,
97 GPIO93_MII_COL,
98 GPIO94_RX_CLK,
99 GPIO95_RX_ER,
100 GPIO96_RX_DQ3,
101 GPIO97_RX_DQ2,
102 GPIO98_RX_DQ1,
103 GPIO99_RX_DQ0,
104 GPIO100_MII_MDC,
105 GPIO101_MII_MDIO,
106 GPIO103_RX_DV,
107 GPIO104_GPIO, /* Reset PHY */
108
109 /* RTC interrupt */
110 GPIO102_GPIO,
111
112 /* I2C */
113 GPIO105_CI2C_SDA,
114 GPIO106_CI2C_SCL,
115
116 /* SPI NOR Flash on SSP2 */
117 GPIO107_SSP2_RXD,
118 GPIO108_SSP2_TXD,
119 GPIO110_GPIO, /* SPI_CSn */
120 GPIO111_SSP2_CLK,
121
122 /* Select JTAG */
123 GPIO109_GPIO,
124
125 /* I2S */
126 GPIO114_I2S_FRM,
127 GPIO115_I2S_BCLK,
128 GPIO116_I2S_TXD
129 };
130
131 static struct i2c_board_info gplugd_i2c_board_info[] = {
132 {
133 .type = "isl1208",
134 .addr = 0x6F,
135 }
136 };
137
138 /* Bring PHY out of reset by setting GPIO 104 */
139 static int gplugd_eth_init(void)
140 {
141 if (unlikely(gpio_request(104, "ETH_RESET_N"))) {
142 printk(KERN_ERR "Can't get hold of GPIO 104 to bring Ethernet "
143 "PHY out of reset\n");
144 return -EIO;
145 }
146
147 gpio_direction_output(104, 1);
148 gpio_free(104);
149 return 0;
150 }
151
152 struct pxa168_eth_platform_data gplugd_eth_platform_data = {
153 .port_number = 0,
154 .phy_addr = 0,
155 .speed = 0, /* Autonagotiation */
156 .init = gplugd_eth_init,
157 };
158
159 static void __init select_disp_freq(void)
160 {
161 /* set GPIO 35 & clear GPIO 85 to set LCD External Clock to 74.25 MHz */
162 if (unlikely(gpio_request(35, "DISP_FREQ_SEL"))) {
163 printk(KERN_ERR "Can't get hold of GPIO 35 to select display "
164 "frequency\n");
165 } else {
166 gpio_direction_output(35, 1);
167 gpio_free(35);
168 }
169
170 if (unlikely(gpio_request(85, "DISP_FREQ_SEL_2"))) {
171 printk(KERN_ERR "Can't get hold of GPIO 85 to select display "
172 "frequency\n");
173 } else {
174 gpio_direction_output(85, 0);
175 gpio_free(85);
176 }
177 }
178
179 static void __init gplugd_init(void)
180 {
181 mfp_config(ARRAY_AND_SIZE(gplugd_pin_config));
182
183 select_disp_freq();
184
185 /* on-chip devices */
186 pxa168_add_uart(3);
187 pxa168_add_ssp(1);
188 pxa168_add_twsi(0, NULL, ARRAY_AND_SIZE(gplugd_i2c_board_info));
189 platform_device_register(&pxa168_device_gpio);
190
191 pxa168_add_eth(&gplugd_eth_platform_data);
192 }
193
194 MACHINE_START(GPLUGD, "PXA168-based GuruPlug Display (gplugD) Platform")
195 .map_io = mmp_map_io,
196 .nr_irqs = MMP_NR_IRQS,
197 .init_irq = pxa168_init_irq,
198 .init_time = pxa168_timer_init,
199 .init_machine = gplugd_init,
200 .restart = pxa168_restart,
201 MACHINE_END