diff options
Diffstat (limited to 'arch/arm/mach-davinci/board-omapl138-hawk.c')
-rw-r--r-- | arch/arm/mach-davinci/board-omapl138-hawk.c | 284 |
1 files changed, 284 insertions, 0 deletions
diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c b/arch/arm/mach-davinci/board-omapl138-hawk.c index 0b8dbdb79fe0..67c38d0ecd10 100644 --- a/arch/arm/mach-davinci/board-omapl138-hawk.c +++ b/arch/arm/mach-davinci/board-omapl138-hawk.c | |||
@@ -19,6 +19,279 @@ | |||
19 | 19 | ||
20 | #include <mach/cp_intc.h> | 20 | #include <mach/cp_intc.h> |
21 | #include <mach/da8xx.h> | 21 | #include <mach/da8xx.h> |
22 | #include <mach/mux.h> | ||
23 | |||
24 | #define HAWKBOARD_PHY_ID "0:07" | ||
25 | #define DA850_HAWK_MMCSD_CD_PIN GPIO_TO_PIN(3, 12) | ||
26 | #define DA850_HAWK_MMCSD_WP_PIN GPIO_TO_PIN(3, 13) | ||
27 | |||
28 | #define DA850_USB1_VBUS_PIN GPIO_TO_PIN(2, 4) | ||
29 | #define DA850_USB1_OC_PIN GPIO_TO_PIN(6, 13) | ||
30 | |||
31 | static short omapl138_hawk_mii_pins[] __initdata = { | ||
32 | DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3, | ||
33 | DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER, | ||
34 | DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3, | ||
35 | DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK, | ||
36 | DA850_MDIO_D, | ||
37 | -1 | ||
38 | }; | ||
39 | |||
40 | static __init void omapl138_hawk_config_emac(void) | ||
41 | { | ||
42 | void __iomem *cfgchip3 = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG); | ||
43 | int ret; | ||
44 | u32 val; | ||
45 | struct davinci_soc_info *soc_info = &davinci_soc_info; | ||
46 | |||
47 | val = __raw_readl(cfgchip3); | ||
48 | val &= ~BIT(8); | ||
49 | ret = davinci_cfg_reg_list(omapl138_hawk_mii_pins); | ||
50 | if (ret) { | ||
51 | pr_warning("%s: cpgmac/mii mux setup failed: %d\n", | ||
52 | __func__, ret); | ||
53 | return; | ||
54 | } | ||
55 | |||
56 | /* configure the CFGCHIP3 register for MII */ | ||
57 | __raw_writel(val, cfgchip3); | ||
58 | pr_info("EMAC: MII PHY configured\n"); | ||
59 | |||
60 | soc_info->emac_pdata->phy_id = HAWKBOARD_PHY_ID; | ||
61 | |||
62 | ret = da8xx_register_emac(); | ||
63 | if (ret) | ||
64 | pr_warning("%s: emac registration failed: %d\n", | ||
65 | __func__, ret); | ||
66 | } | ||
67 | |||
68 | /* | ||
69 | * The following EDMA channels/slots are not being used by drivers (for | ||
70 | * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM/Hawkboard, | ||
71 | * hence they are being reserved for codecs on the DSP side. | ||
72 | */ | ||
73 | static const s16 da850_dma0_rsv_chans[][2] = { | ||
74 | /* (offset, number) */ | ||
75 | { 8, 6}, | ||
76 | {24, 4}, | ||
77 | {30, 2}, | ||
78 | {-1, -1} | ||
79 | }; | ||
80 | |||
81 | static const s16 da850_dma0_rsv_slots[][2] = { | ||
82 | /* (offset, number) */ | ||
83 | { 8, 6}, | ||
84 | {24, 4}, | ||
85 | {30, 50}, | ||
86 | {-1, -1} | ||
87 | }; | ||
88 | |||
89 | static const s16 da850_dma1_rsv_chans[][2] = { | ||
90 | /* (offset, number) */ | ||
91 | { 0, 28}, | ||
92 | {30, 2}, | ||
93 | {-1, -1} | ||
94 | }; | ||
95 | |||
96 | static const s16 da850_dma1_rsv_slots[][2] = { | ||
97 | /* (offset, number) */ | ||
98 | { 0, 28}, | ||
99 | {30, 90}, | ||
100 | {-1, -1} | ||
101 | }; | ||
102 | |||
103 | static struct edma_rsv_info da850_edma_cc0_rsv = { | ||
104 | .rsv_chans = da850_dma0_rsv_chans, | ||
105 | .rsv_slots = da850_dma0_rsv_slots, | ||
106 | }; | ||
107 | |||
108 | static struct edma_rsv_info da850_edma_cc1_rsv = { | ||
109 | .rsv_chans = da850_dma1_rsv_chans, | ||
110 | .rsv_slots = da850_dma1_rsv_slots, | ||
111 | }; | ||
112 | |||
113 | static struct edma_rsv_info *da850_edma_rsv[2] = { | ||
114 | &da850_edma_cc0_rsv, | ||
115 | &da850_edma_cc1_rsv, | ||
116 | }; | ||
117 | |||
118 | static const short hawk_mmcsd0_pins[] = { | ||
119 | DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2, | ||
120 | DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD, | ||
121 | DA850_GPIO3_12, DA850_GPIO3_13, | ||
122 | -1 | ||
123 | }; | ||
124 | |||
125 | static int da850_hawk_mmc_get_ro(int index) | ||
126 | { | ||
127 | return gpio_get_value(DA850_HAWK_MMCSD_WP_PIN); | ||
128 | } | ||
129 | |||
130 | static int da850_hawk_mmc_get_cd(int index) | ||
131 | { | ||
132 | return !gpio_get_value(DA850_HAWK_MMCSD_CD_PIN); | ||
133 | } | ||
134 | |||
135 | static struct davinci_mmc_config da850_mmc_config = { | ||
136 | .get_ro = da850_hawk_mmc_get_ro, | ||
137 | .get_cd = da850_hawk_mmc_get_cd, | ||
138 | .wires = 4, | ||
139 | .max_freq = 50000000, | ||
140 | .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED, | ||
141 | .version = MMC_CTLR_VERSION_2, | ||
142 | }; | ||
143 | |||
144 | static __init void omapl138_hawk_mmc_init(void) | ||
145 | { | ||
146 | int ret; | ||
147 | |||
148 | ret = davinci_cfg_reg_list(hawk_mmcsd0_pins); | ||
149 | if (ret) { | ||
150 | pr_warning("%s: MMC/SD0 mux setup failed: %d\n", | ||
151 | __func__, ret); | ||
152 | return; | ||
153 | } | ||
154 | |||
155 | ret = gpio_request_one(DA850_HAWK_MMCSD_CD_PIN, | ||
156 | GPIOF_DIR_IN, "MMC CD"); | ||
157 | if (ret < 0) { | ||
158 | pr_warning("%s: can not open GPIO %d\n", | ||
159 | __func__, DA850_HAWK_MMCSD_CD_PIN); | ||
160 | return; | ||
161 | } | ||
162 | |||
163 | ret = gpio_request_one(DA850_HAWK_MMCSD_WP_PIN, | ||
164 | GPIOF_DIR_IN, "MMC WP"); | ||
165 | if (ret < 0) { | ||
166 | pr_warning("%s: can not open GPIO %d\n", | ||
167 | __func__, DA850_HAWK_MMCSD_WP_PIN); | ||
168 | goto mmc_setup_wp_fail; | ||
169 | } | ||
170 | |||
171 | ret = da8xx_register_mmcsd0(&da850_mmc_config); | ||
172 | if (ret) { | ||
173 | pr_warning("%s: MMC/SD0 registration failed: %d\n", | ||
174 | __func__, ret); | ||
175 | goto mmc_setup_mmcsd_fail; | ||
176 | } | ||
177 | |||
178 | return; | ||
179 | |||
180 | mmc_setup_mmcsd_fail: | ||
181 | gpio_free(DA850_HAWK_MMCSD_WP_PIN); | ||
182 | mmc_setup_wp_fail: | ||
183 | gpio_free(DA850_HAWK_MMCSD_CD_PIN); | ||
184 | } | ||
185 | |||
186 | static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id); | ||
187 | static da8xx_ocic_handler_t hawk_usb_ocic_handler; | ||
188 | |||
189 | static const short da850_hawk_usb11_pins[] = { | ||
190 | DA850_GPIO2_4, DA850_GPIO6_13, | ||
191 | -1 | ||
192 | }; | ||
193 | |||
194 | static int hawk_usb_set_power(unsigned port, int on) | ||
195 | { | ||
196 | gpio_set_value(DA850_USB1_VBUS_PIN, on); | ||
197 | return 0; | ||
198 | } | ||
199 | |||
200 | static int hawk_usb_get_power(unsigned port) | ||
201 | { | ||
202 | return gpio_get_value(DA850_USB1_VBUS_PIN); | ||
203 | } | ||
204 | |||
205 | static int hawk_usb_get_oci(unsigned port) | ||
206 | { | ||
207 | return !gpio_get_value(DA850_USB1_OC_PIN); | ||
208 | } | ||
209 | |||
210 | static int hawk_usb_ocic_notify(da8xx_ocic_handler_t handler) | ||
211 | { | ||
212 | int irq = gpio_to_irq(DA850_USB1_OC_PIN); | ||
213 | int error = 0; | ||
214 | |||
215 | if (handler != NULL) { | ||
216 | hawk_usb_ocic_handler = handler; | ||
217 | |||
218 | error = request_irq(irq, omapl138_hawk_usb_ocic_irq, | ||
219 | IRQF_DISABLED | IRQF_TRIGGER_RISING | | ||
220 | IRQF_TRIGGER_FALLING, | ||
221 | "OHCI over-current indicator", NULL); | ||
222 | if (error) | ||
223 | pr_err("%s: could not request IRQ to watch " | ||
224 | "over-current indicator changes\n", __func__); | ||
225 | } else { | ||
226 | free_irq(irq, NULL); | ||
227 | } | ||
228 | return error; | ||
229 | } | ||
230 | |||
231 | static struct da8xx_ohci_root_hub omapl138_hawk_usb11_pdata = { | ||
232 | .set_power = hawk_usb_set_power, | ||
233 | .get_power = hawk_usb_get_power, | ||
234 | .get_oci = hawk_usb_get_oci, | ||
235 | .ocic_notify = hawk_usb_ocic_notify, | ||
236 | /* TPS2087 switch @ 5V */ | ||
237 | .potpgt = (3 + 1) / 2, /* 3 ms max */ | ||
238 | }; | ||
239 | |||
240 | static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id) | ||
241 | { | ||
242 | hawk_usb_ocic_handler(&omapl138_hawk_usb11_pdata, 1); | ||
243 | return IRQ_HANDLED; | ||
244 | } | ||
245 | |||
246 | static __init void omapl138_hawk_usb_init(void) | ||
247 | { | ||
248 | int ret; | ||
249 | u32 cfgchip2; | ||
250 | |||
251 | ret = davinci_cfg_reg_list(da850_hawk_usb11_pins); | ||
252 | if (ret) { | ||
253 | pr_warning("%s: USB 1.1 PinMux setup failed: %d\n", | ||
254 | __func__, ret); | ||
255 | return; | ||
256 | } | ||
257 | |||
258 | /* Setup the Ref. clock frequency for the HAWK at 24 MHz. */ | ||
259 | |||
260 | cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)); | ||
261 | cfgchip2 &= ~CFGCHIP2_REFFREQ; | ||
262 | cfgchip2 |= CFGCHIP2_REFFREQ_24MHZ; | ||
263 | __raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)); | ||
264 | |||
265 | ret = gpio_request_one(DA850_USB1_VBUS_PIN, | ||
266 | GPIOF_DIR_OUT, "USB1 VBUS"); | ||
267 | if (ret < 0) { | ||
268 | pr_err("%s: failed to request GPIO for USB 1.1 port " | ||
269 | "power control: %d\n", __func__, ret); | ||
270 | return; | ||
271 | } | ||
272 | |||
273 | ret = gpio_request_one(DA850_USB1_OC_PIN, | ||
274 | GPIOF_DIR_IN, "USB1 OC"); | ||
275 | if (ret < 0) { | ||
276 | pr_err("%s: failed to request GPIO for USB 1.1 port " | ||
277 | "over-current indicator: %d\n", __func__, ret); | ||
278 | goto usb11_setup_oc_fail; | ||
279 | } | ||
280 | |||
281 | ret = da8xx_register_usb11(&omapl138_hawk_usb11_pdata); | ||
282 | if (ret) { | ||
283 | pr_warning("%s: USB 1.1 registration failed: %d\n", | ||
284 | __func__, ret); | ||
285 | goto usb11_setup_fail; | ||
286 | } | ||
287 | |||
288 | return; | ||
289 | |||
290 | usb11_setup_fail: | ||
291 | gpio_free(DA850_USB1_OC_PIN); | ||
292 | usb11_setup_oc_fail: | ||
293 | gpio_free(DA850_USB1_VBUS_PIN); | ||
294 | } | ||
22 | 295 | ||
23 | static struct davinci_uart_config omapl138_hawk_uart_config __initdata = { | 296 | static struct davinci_uart_config omapl138_hawk_uart_config __initdata = { |
24 | .enabled_uarts = 0x7, | 297 | .enabled_uarts = 0x7, |
@@ -30,6 +303,17 @@ static __init void omapl138_hawk_init(void) | |||
30 | 303 | ||
31 | davinci_serial_init(&omapl138_hawk_uart_config); | 304 | davinci_serial_init(&omapl138_hawk_uart_config); |
32 | 305 | ||
306 | omapl138_hawk_config_emac(); | ||
307 | |||
308 | ret = da850_register_edma(da850_edma_rsv); | ||
309 | if (ret) | ||
310 | pr_warning("%s: EDMA registration failed: %d\n", | ||
311 | __func__, ret); | ||
312 | |||
313 | omapl138_hawk_mmc_init(); | ||
314 | |||
315 | omapl138_hawk_usb_init(); | ||
316 | |||
33 | ret = da8xx_register_watchdog(); | 317 | ret = da8xx_register_watchdog(); |
34 | if (ret) | 318 | if (ret) |
35 | pr_warning("omapl138_hawk_init: " | 319 | pr_warning("omapl138_hawk_init: " |