]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/arm/mach-omap2/board-am3517evm.c
omap: complete removal of machine_desc.io_pg_offst and .phys_io
[karo-tx-linux.git] / arch / arm / mach-omap2 / board-am3517evm.c
1 /*
2  * linux/arch/arm/mach-omap2/board-am3517evm.c
3  *
4  * Copyright (C) 2009 Texas Instruments Incorporated
5  * Author: Ranjith Lohithakshan <ranjithl@ti.com>
6  *
7  * Based on mach-omap2/board-omap3evm.c
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU General Public License as  published by the
11  * Free Software Foundation version 2.
12  *
13  * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
14  * whether express or implied; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  */
18
19 #include <linux/kernel.h>
20 #include <linux/init.h>
21 #include <linux/platform_device.h>
22 #include <linux/gpio.h>
23 #include <linux/i2c/pca953x.h>
24 #include <linux/can/platform/ti_hecc.h>
25 #include <linux/davinci_emac.h>
26
27 #include <mach/hardware.h>
28 #include <mach/am35xx.h>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
32
33 #include <plat/board.h>
34 #include <plat/common.h>
35 #include <plat/usb.h>
36 #include <plat/display.h>
37
38 #include "mux.h"
39 #include "control.h"
40
41 #define AM35XX_EVM_PHY_MASK             (0xF)
42 #define AM35XX_EVM_MDIO_FREQUENCY       (1000000)
43
44 static struct emac_platform_data am3517_evm_emac_pdata = {
45         .phy_mask       = AM35XX_EVM_PHY_MASK,
46         .mdio_max_freq  = AM35XX_EVM_MDIO_FREQUENCY,
47         .rmii_en        = 1,
48 };
49
50 static struct resource am3517_emac_resources[] = {
51         {
52                 .start  = AM35XX_IPSS_EMAC_BASE,
53                 .end    = AM35XX_IPSS_EMAC_BASE + 0x3FFFF,
54                 .flags  = IORESOURCE_MEM,
55         },
56         {
57                 .start  = INT_35XX_EMAC_C0_RXTHRESH_IRQ,
58                 .end    = INT_35XX_EMAC_C0_RXTHRESH_IRQ,
59                 .flags  = IORESOURCE_IRQ,
60         },
61         {
62                 .start  = INT_35XX_EMAC_C0_RX_PULSE_IRQ,
63                 .end    = INT_35XX_EMAC_C0_RX_PULSE_IRQ,
64                 .flags  = IORESOURCE_IRQ,
65         },
66         {
67                 .start  = INT_35XX_EMAC_C0_TX_PULSE_IRQ,
68                 .end    = INT_35XX_EMAC_C0_TX_PULSE_IRQ,
69                 .flags  = IORESOURCE_IRQ,
70         },
71         {
72                 .start  = INT_35XX_EMAC_C0_MISC_PULSE_IRQ,
73                 .end    = INT_35XX_EMAC_C0_MISC_PULSE_IRQ,
74                 .flags  = IORESOURCE_IRQ,
75         },
76 };
77
78 static struct platform_device am3517_emac_device = {
79         .name           = "davinci_emac",
80         .id             = -1,
81         .num_resources  = ARRAY_SIZE(am3517_emac_resources),
82         .resource       = am3517_emac_resources,
83 };
84
85 static void am3517_enable_ethernet_int(void)
86 {
87         u32 regval;
88
89         regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
90         regval = (regval | AM35XX_CPGMAC_C0_RX_PULSE_CLR |
91                 AM35XX_CPGMAC_C0_TX_PULSE_CLR |
92                 AM35XX_CPGMAC_C0_MISC_PULSE_CLR |
93                 AM35XX_CPGMAC_C0_RX_THRESH_CLR);
94         omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR);
95         regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
96 }
97
98 static void am3517_disable_ethernet_int(void)
99 {
100         u32 regval;
101
102         regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
103         regval = (regval | AM35XX_CPGMAC_C0_RX_PULSE_CLR |
104                 AM35XX_CPGMAC_C0_TX_PULSE_CLR);
105         omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR);
106         regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
107 }
108
109 static void am3517_evm_ethernet_init(struct emac_platform_data *pdata)
110 {
111         unsigned int regval;
112
113         pdata->ctrl_reg_offset          = AM35XX_EMAC_CNTRL_OFFSET;
114         pdata->ctrl_mod_reg_offset      = AM35XX_EMAC_CNTRL_MOD_OFFSET;
115         pdata->ctrl_ram_offset          = AM35XX_EMAC_CNTRL_RAM_OFFSET;
116         pdata->mdio_reg_offset          = AM35XX_EMAC_MDIO_OFFSET;
117         pdata->ctrl_ram_size            = AM35XX_EMAC_CNTRL_RAM_SIZE;
118         pdata->version                  = EMAC_VERSION_2;
119         pdata->hw_ram_addr              = AM35XX_EMAC_HW_RAM_ADDR;
120         pdata->interrupt_enable         = am3517_enable_ethernet_int;
121         pdata->interrupt_disable        = am3517_disable_ethernet_int;
122         am3517_emac_device.dev.platform_data    = pdata;
123         platform_device_register(&am3517_emac_device);
124
125         regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
126         regval = regval & (~(AM35XX_CPGMACSS_SW_RST));
127         omap_ctrl_writel(regval, AM35XX_CONTROL_IP_SW_RESET);
128         regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
129
130         return ;
131 }
132
133
134
135 #define LCD_PANEL_PWR           176
136 #define LCD_PANEL_BKLIGHT_PWR   182
137 #define LCD_PANEL_PWM           181
138
139 static struct i2c_board_info __initdata am3517evm_i2c1_boardinfo[] = {
140         {
141                 I2C_BOARD_INFO("s35390a", 0x30),
142         },
143 };
144
145 /*
146  * RTC - S35390A
147  */
148 #define GPIO_RTCS35390A_IRQ     55
149
150 static void __init am3517_evm_rtc_init(void)
151 {
152         int r;
153
154         omap_mux_init_gpio(GPIO_RTCS35390A_IRQ, OMAP_PIN_INPUT_PULLUP);
155         r = gpio_request(GPIO_RTCS35390A_IRQ, "rtcs35390a-irq");
156         if (r < 0) {
157                 printk(KERN_WARNING "failed to request GPIO#%d\n",
158                                 GPIO_RTCS35390A_IRQ);
159                 return;
160         }
161         r = gpio_direction_input(GPIO_RTCS35390A_IRQ);
162         if (r < 0) {
163                 printk(KERN_WARNING "GPIO#%d cannot be configured as input\n",
164                                 GPIO_RTCS35390A_IRQ);
165                 gpio_free(GPIO_RTCS35390A_IRQ);
166                 return;
167         }
168         am3517evm_i2c1_boardinfo[0].irq = gpio_to_irq(GPIO_RTCS35390A_IRQ);
169 }
170
171 /*
172  * I2C GPIO Expander - TCA6416
173  */
174
175 /* Mounted on Base-Board */
176 static struct pca953x_platform_data am3517evm_gpio_expander_info_0 = {
177         .gpio_base      = OMAP_MAX_GPIO_LINES,
178 };
179 static struct i2c_board_info __initdata am3517evm_i2c2_boardinfo[] = {
180         {
181                 I2C_BOARD_INFO("tca6416", 0x21),
182                 .platform_data = &am3517evm_gpio_expander_info_0,
183         },
184 };
185
186 /* Mounted on UI Card */
187 static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_1 = {
188         .gpio_base      = OMAP_MAX_GPIO_LINES + 16,
189 };
190 static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_2 = {
191         .gpio_base      = OMAP_MAX_GPIO_LINES + 32,
192 };
193 static struct i2c_board_info __initdata am3517evm_i2c3_boardinfo[] = {
194         {
195                 I2C_BOARD_INFO("tca6416", 0x20),
196                 .platform_data = &am3517evm_ui_gpio_expander_info_1,
197         },
198         {
199                 I2C_BOARD_INFO("tca6416", 0x21),
200                 .platform_data = &am3517evm_ui_gpio_expander_info_2,
201         },
202 };
203
204 static int __init am3517_evm_i2c_init(void)
205 {
206         omap_register_i2c_bus(1, 400, NULL, 0);
207         omap_register_i2c_bus(2, 400, am3517evm_i2c2_boardinfo,
208                         ARRAY_SIZE(am3517evm_i2c2_boardinfo));
209         omap_register_i2c_bus(3, 400, am3517evm_i2c3_boardinfo,
210                         ARRAY_SIZE(am3517evm_i2c3_boardinfo));
211
212         return 0;
213 }
214
215 static int lcd_enabled;
216 static int dvi_enabled;
217
218 #if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \
219                 defined(CONFIG_PANEL_SHARP_LQ043T1DG01_MODULE)
220 static void __init am3517_evm_display_init(void)
221 {
222         int r;
223
224         omap_mux_init_gpio(LCD_PANEL_PWR, OMAP_PIN_INPUT_PULLUP);
225         omap_mux_init_gpio(LCD_PANEL_BKLIGHT_PWR, OMAP_PIN_INPUT_PULLDOWN);
226         omap_mux_init_gpio(LCD_PANEL_PWM, OMAP_PIN_INPUT_PULLDOWN);
227         /*
228          * Enable GPIO 182 = LCD Backlight Power
229          */
230         r = gpio_request(LCD_PANEL_BKLIGHT_PWR, "lcd_backlight_pwr");
231         if (r) {
232                 printk(KERN_ERR "failed to get lcd_backlight_pwr\n");
233                 return;
234         }
235         gpio_direction_output(LCD_PANEL_BKLIGHT_PWR, 1);
236         /*
237          * Enable GPIO 181 = LCD Panel PWM
238          */
239         r = gpio_request(LCD_PANEL_PWM, "lcd_pwm");
240         if (r) {
241                 printk(KERN_ERR "failed to get lcd_pwm\n");
242                 goto err_1;
243         }
244         gpio_direction_output(LCD_PANEL_PWM, 1);
245         /*
246          * Enable GPIO 176 = LCD Panel Power enable pin
247          */
248         r = gpio_request(LCD_PANEL_PWR, "lcd_panel_pwr");
249         if (r) {
250                 printk(KERN_ERR "failed to get lcd_panel_pwr\n");
251                 goto err_2;
252         }
253         gpio_direction_output(LCD_PANEL_PWR, 1);
254
255         printk(KERN_INFO "Display initialized successfully\n");
256         return;
257
258 err_2:
259         gpio_free(LCD_PANEL_PWM);
260 err_1:
261         gpio_free(LCD_PANEL_BKLIGHT_PWR);
262 }
263 #else
264 static void __init am3517_evm_display_init(void) {}
265 #endif
266
267 static int am3517_evm_panel_enable_lcd(struct omap_dss_device *dssdev)
268 {
269         if (dvi_enabled) {
270                 printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
271                 return -EINVAL;
272         }
273         gpio_set_value(LCD_PANEL_PWR, 1);
274         lcd_enabled = 1;
275
276         return 0;
277 }
278
279 static void am3517_evm_panel_disable_lcd(struct omap_dss_device *dssdev)
280 {
281         gpio_set_value(LCD_PANEL_PWR, 0);
282         lcd_enabled = 0;
283 }
284
285 static struct omap_dss_device am3517_evm_lcd_device = {
286         .type                   = OMAP_DISPLAY_TYPE_DPI,
287         .name                   = "lcd",
288         .driver_name            = "sharp_lq_panel",
289         .phy.dpi.data_lines     = 16,
290         .platform_enable        = am3517_evm_panel_enable_lcd,
291         .platform_disable       = am3517_evm_panel_disable_lcd,
292 };
293
294 static int am3517_evm_panel_enable_tv(struct omap_dss_device *dssdev)
295 {
296         return 0;
297 }
298
299 static void am3517_evm_panel_disable_tv(struct omap_dss_device *dssdev)
300 {
301 }
302
303 static struct omap_dss_device am3517_evm_tv_device = {
304         .type                   = OMAP_DISPLAY_TYPE_VENC,
305         .name                   = "tv",
306         .driver_name            = "venc",
307         .phy.venc.type          = OMAP_DSS_VENC_TYPE_SVIDEO,
308         .platform_enable        = am3517_evm_panel_enable_tv,
309         .platform_disable       = am3517_evm_panel_disable_tv,
310 };
311
312 static int am3517_evm_panel_enable_dvi(struct omap_dss_device *dssdev)
313 {
314         if (lcd_enabled) {
315                 printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
316                 return -EINVAL;
317         }
318         dvi_enabled = 1;
319
320         return 0;
321 }
322
323 static void am3517_evm_panel_disable_dvi(struct omap_dss_device *dssdev)
324 {
325         dvi_enabled = 0;
326 }
327
328 static struct omap_dss_device am3517_evm_dvi_device = {
329         .type                   = OMAP_DISPLAY_TYPE_DPI,
330         .name                   = "dvi",
331         .driver_name            = "generic_panel",
332         .phy.dpi.data_lines     = 24,
333         .platform_enable        = am3517_evm_panel_enable_dvi,
334         .platform_disable       = am3517_evm_panel_disable_dvi,
335 };
336
337 static struct omap_dss_device *am3517_evm_dss_devices[] = {
338         &am3517_evm_lcd_device,
339         &am3517_evm_tv_device,
340         &am3517_evm_dvi_device,
341 };
342
343 static struct omap_dss_board_info am3517_evm_dss_data = {
344         .num_devices    = ARRAY_SIZE(am3517_evm_dss_devices),
345         .devices        = am3517_evm_dss_devices,
346         .default_device = &am3517_evm_lcd_device,
347 };
348
349 static struct platform_device am3517_evm_dss_device = {
350         .name           = "omapdss",
351         .id             = -1,
352         .dev            = {
353                 .platform_data  = &am3517_evm_dss_data,
354         },
355 };
356
357 /*
358  * Board initialization
359  */
360 static struct omap_board_config_kernel am3517_evm_config[] __initdata = {
361 };
362
363 static struct platform_device *am3517_evm_devices[] __initdata = {
364         &am3517_evm_dss_device,
365 };
366
367 static void __init am3517_evm_init_irq(void)
368 {
369         omap_board_config = am3517_evm_config;
370         omap_board_config_size = ARRAY_SIZE(am3517_evm_config);
371
372         omap2_init_common_hw(NULL, NULL);
373         omap_init_irq();
374         omap_gpio_init();
375 }
376
377 static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
378         .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
379 #if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \
380                 defined(CONFIG_PANEL_SHARP_LQ043T1DG01_MODULE)
381         .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
382 #else
383         .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
384 #endif
385         .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
386
387         .phy_reset  = true,
388         .reset_gpio_port[0]  = 57,
389         .reset_gpio_port[1]  = -EINVAL,
390         .reset_gpio_port[2]  = -EINVAL
391 };
392
393 #ifdef CONFIG_OMAP_MUX
394 static struct omap_board_mux board_mux[] __initdata = {
395         { .reg_offset = OMAP_MUX_TERMINATOR },
396 };
397 #else
398 #define board_mux       NULL
399 #endif
400
401
402 static struct resource am3517_hecc_resources[] = {
403         {
404                 .start  = AM35XX_IPSS_HECC_BASE,
405                 .end    = AM35XX_IPSS_HECC_BASE + 0x3FFF,
406                 .flags  = IORESOURCE_MEM,
407         },
408         {
409                 .start  = INT_35XX_HECC0_IRQ,
410                 .end    = INT_35XX_HECC0_IRQ,
411                 .flags  = IORESOURCE_IRQ,
412         },
413 };
414
415 static struct platform_device am3517_hecc_device = {
416         .name           = "ti_hecc",
417         .id             = -1,
418         .num_resources  = ARRAY_SIZE(am3517_hecc_resources),
419         .resource       = am3517_hecc_resources,
420 };
421
422 static struct ti_hecc_platform_data am3517_evm_hecc_pdata = {
423         .scc_hecc_offset        = AM35XX_HECC_SCC_HECC_OFFSET,
424         .scc_ram_offset         = AM35XX_HECC_SCC_RAM_OFFSET,
425         .hecc_ram_offset        = AM35XX_HECC_RAM_OFFSET,
426         .mbx_offset             = AM35XX_HECC_MBOX_OFFSET,
427         .int_line               = AM35XX_HECC_INT_LINE,
428         .version                = AM35XX_HECC_VERSION,
429 };
430
431 static void am3517_evm_hecc_init(struct ti_hecc_platform_data *pdata)
432 {
433         am3517_hecc_device.dev.platform_data = pdata;
434         platform_device_register(&am3517_hecc_device);
435 }
436
437 static void __init am3517_evm_init(void)
438 {
439         omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
440
441         am3517_evm_i2c_init();
442         platform_add_devices(am3517_evm_devices,
443                                 ARRAY_SIZE(am3517_evm_devices));
444
445         omap_serial_init();
446
447         /* Configure GPIO for EHCI port */
448         omap_mux_init_gpio(57, OMAP_PIN_OUTPUT);
449         usb_ehci_init(&ehci_pdata);
450         am3517_evm_hecc_init(&am3517_evm_hecc_pdata);
451         /* DSS */
452         am3517_evm_display_init();
453
454         /* RTC - S35390A */
455         am3517_evm_rtc_init();
456
457         i2c_register_board_info(1, am3517evm_i2c1_boardinfo,
458                                 ARRAY_SIZE(am3517evm_i2c1_boardinfo));
459         /*Ethernet*/
460         am3517_evm_ethernet_init(&am3517_evm_emac_pdata);
461 }
462
463 MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM")
464         .phys_io        = 0x48000000,
465         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
466         .boot_params    = 0x80000100,
467         .map_io         = omap3_map_io,
468         .reserve        = omap_reserve,
469         .init_irq       = am3517_evm_init_irq,
470         .init_machine   = am3517_evm_init,
471         .timer          = &omap_timer,
472 MACHINE_END