]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - sitara-epos/sitara-epos-kernel.git/blob - arch/arm/mach-omap2/board-am335xevm.c
am335x: add musb support
[sitara-epos/sitara-epos-kernel.git] / arch / arm / mach-omap2 / board-am335xevm.c
1 /*
2  * Code for AM335X EVM.
3  *
4  * Copyright (C) 2011 Texas Instruments, Inc. - http://www.ti.com/
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation version 2.
9  *
10  * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11  * kind, whether express or implied; without even the implied warranty
12  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  */
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/i2c.h>
18 #include <linux/module.h>
19 #include <linux/i2c/at24.h>
20 #include <linux/gpio.h>
21 #include <linux/clk.h>
22 #include <linux/err.h>
24 /* LCD controller is similar to DA850 */
25 #include <video/da8xx-fb.h>
27 #include <mach/hardware.h>
28 #include <mach/board-am335xevm.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
34 #include <plat/irqs.h>
35 #include <plat/board.h>
36 #include <plat/common.h>
37 #include <plat/lcdc.h>
38 #include <plat/usb.h>
40 static const struct display_panel disp_panel = {
41         WVGA,
42         32,
43         32,
44         COLOR_ACTIVE,
45 };
47 static struct lcd_ctrl_config lcd_cfg = {
48         &disp_panel,
49         .ac_bias                = 255,
50         .ac_bias_intrpt         = 0,
51         .dma_burst_sz           = 16,
52         .bpp                    = 32,
53         .fdd                    = 0x80,
54         .tft_alt_mode           = 0,
55         .stn_565_mode           = 0,
56         .mono_8bit_mode         = 0,
57         .invert_line_clock      = 1,
58         .invert_frm_clock       = 1,
59         .sync_edge              = 0,
60         .sync_ctrl              = 1,
61         .raster_order           = 0,
62 };
64 struct da8xx_lcdc_platform_data TFC_S9700RTWV35TR_01B_pdata = {
65         .manu_name              = "ThreeFive",
66         .controller_data        = &lcd_cfg,
67         .type                   = "TFC_S9700RTWV35TR_01B",
68 };
70 #include "common.h"
72 /* TSc controller */
73 #include <linux/input/ti_tscadc.h>
75 static struct resource tsc_resources[]  = {
76         [0] = {
77                 .start  = AM33XX_TSC_BASE,
78                 .end    = AM33XX_TSC_BASE + SZ_8K - 1,
79                 .flags  = IORESOURCE_MEM,
80         },
81         [1] = {
82                 .start  = AM33XX_IRQ_ADC_GEN,
83                 .end    = AM33XX_IRQ_ADC_GEN,
84                 .flags  = IORESOURCE_IRQ,
85         },
86 };
88 static struct tsc_data am335x_touchscreen_data  = {
89         .wires  = 4,
90         .x_plate_resistance = 200,
91 };
93 static struct platform_device tsc_device = {
94         .name   = "tsc",
95         .id     = -1,
96         .dev    = {
97                         .platform_data  = &am335x_touchscreen_data,
98         },
99         .num_resources  = ARRAY_SIZE(tsc_resources),
100         .resource       = tsc_resources,
101 };
103 #include "mux.h"
105 #ifdef CONFIG_OMAP_MUX
106 static struct omap_board_mux board_mux[] __initdata = {
107         AM33XX_MUX(I2C0_SDA, OMAP_MUX_MODE0 | AM33XX_SLEWCTRL_SLOW |
108                         AM33XX_INPUT_EN | AM33XX_PIN_OUTPUT),
109         AM33XX_MUX(I2C0_SCL, OMAP_MUX_MODE0 | AM33XX_SLEWCTRL_SLOW |
110                         AM33XX_INPUT_EN | AM33XX_PIN_OUTPUT),
111         { .reg_offset = OMAP_MUX_TERMINATOR },
112 };
113 #else
114 #define board_mux       NULL
115 #endif
117 /* module pin mux structure */
118 struct pinmux_config {
119         const char *string_name; /* signal name format */
120         int val; /* Options for the mux register value */
121 };
123 struct evm_dev_cfg {
124         void (*device_init)(int evm_id, int profile);
126 /*
127 * If the device is required on both baseboard & daughter board (ex i2c),
128 * specify DEV_ON_BASEBOARD
129 */
130 #define DEV_ON_BASEBOARD        0
131 #define DEV_ON_DGHTR_BRD        1
132         u32 device_on;
134         u32 profile;    /* Profiles (0-7) in which the module is present */
135 };
137 /* AM335X - CPLD Register Offsets */
138 #define CPLD_DEVICE_HDR 0x00 /* CPLD Header */
139 #define CPLD_DEVICE_ID  0x04 /* CPLD identification */
140 #define CPLD_DEVICE_REV 0x0C /* Revision of the CPLD code */
141 #define CPLD_CFG_REG    0x10 /* Configuration Register */
143 static struct i2c_client *cpld_client;
144 static u32 am335x_evm_id;
145 static struct omap_board_config_kernel am335x_evm_config[] __initdata = {
146 };
148 /*
149 * EVM Config held in On-Board eeprom device.
151 * Header Format
153 *  Name                 Size    Contents
154 *                       (Bytes)
155 *-------------------------------------------------------------
156 *  Header               4       0xAA, 0x55, 0x33, 0xEE
158 *  Board Name           8       Name for board in ASCII.
159 *                               example "A33515BB" = "AM335X
160                                 Low Cost EVM board"
162 *  Version              4       Hardware version code for board in
163 *                               in ASCII. "1.0A" = rev.01.0A
165 *  Serial Number        12      Serial number of the board. This is a 12
166 *                               character string which is WWYY4P16nnnn, where
167 *                               WW = 2 digit week of the year of production
168 *                               YY = 2 digit year of production
169 *                               nnnn = incrementing board number
171 *  Configuration option 32      Codes(TBD) to show the configuration
172 *                               setup on this board.
174 *  Available            32720   Available space for other non-volatile
175 *                               data.
176 */
177 struct am335x_evm_eeprom_config {
178         u32     header;
179         u8      name[8];
180         u32     version;
181         u8      serial[12];
182         u8      opt[32];
183 };
185 static struct am335x_evm_eeprom_config config;
186 static bool daughter_brd_detected;
188 #define GP_EVM_REV_IS_1_0               0x1
189 #define GP_EVM_REV_IS_1_1A              0x2
190 #define GP_EVM_REV_IS_UNKNOWN           0xFF
191 static unsigned int gp_evm_revision = GP_EVM_REV_IS_UNKNOWN;
193 #define AM335X_EEPROM_HEADER            0xEE3355AA
195 /* current profile if exists else PROFILE_0 on error */
196 static u32 am335x_get_profile_selection(void)
198         int val = 0;
200         if (!cpld_client)
201                 /* error checking is not done in func's calling this routine.
202                 so return profile 0 on error */
203                 return 0;
205         val = i2c_smbus_read_word_data(cpld_client, CPLD_CFG_REG);
206         if (val < 0)
207                 return 0;       /* default to Profile 0 on Error */
208         else
209                 return val & 0x7;
212 /* Module pin mux for LCDC */
213 static struct pinmux_config lcdc_pin_mux[] = {
214         {"lcd_data0.lcd_data0",         OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
215                                                        | AM33XX_PULL_DISA},
216         {"lcd_data1.lcd_data1",         OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
217                                                        | AM33XX_PULL_DISA},
218         {"lcd_data2.lcd_data2",         OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
219                                                        | AM33XX_PULL_DISA},
220         {"lcd_data3.lcd_data3",         OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
221                                                        | AM33XX_PULL_DISA},
222         {"lcd_data4.lcd_data4",         OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
223                                                        | AM33XX_PULL_DISA},
224         {"lcd_data5.lcd_data5",         OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
225                                                        | AM33XX_PULL_DISA},
226         {"lcd_data6.lcd_data6",         OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
227                                                        | AM33XX_PULL_DISA},
228         {"lcd_data7.lcd_data7",         OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
229                                                        | AM33XX_PULL_DISA},
230         {"lcd_data8.lcd_data8",         OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
231                                                        | AM33XX_PULL_DISA},
232         {"lcd_data9.lcd_data9",         OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
233                                                        | AM33XX_PULL_DISA},
234         {"lcd_data10.lcd_data10",       OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
235                                                        | AM33XX_PULL_DISA},
236         {"lcd_data11.lcd_data11",       OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
237                                                        | AM33XX_PULL_DISA},
238         {"lcd_data12.lcd_data12",       OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
239                                                        | AM33XX_PULL_DISA},
240         {"lcd_data13.lcd_data13",       OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
241                                                        | AM33XX_PULL_DISA},
242         {"lcd_data14.lcd_data14",       OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
243                                                        | AM33XX_PULL_DISA},
244         {"lcd_data15.lcd_data15",       OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
245                                                        | AM33XX_PULL_DISA},
246         {"gpmc_ad8.lcd_data16",         OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
247         {"gpmc_ad9.lcd_data17",         OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
248         {"gpmc_ad10.lcd_data18",        OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
249         {"gpmc_ad11.lcd_data19",        OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
250         {"gpmc_ad12.lcd_data20",        OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
251         {"gpmc_ad13.lcd_data21",        OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
252         {"gpmc_ad14.lcd_data22",        OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
253         {"gpmc_ad15.lcd_data23",        OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
254         {"lcd_vsync.lcd_vsync",         OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
255         {"lcd_hsync.lcd_hsync",         OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
256         {"lcd_pclk.lcd_pclk",           OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
257         {"lcd_ac_bias_en.lcd_ac_bias_en", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
258         {NULL, 0},
259 };
261 static struct pinmux_config tsc_pin_mux[] = {
262         {"ain0.ain0",           OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
263         {"ain1.ain1",           OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
264         {"ain2.ain2",           OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
265         {"ain3.ain3",           OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
266         {"vrefp.vrefp",         OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
267         {"vrefn.vrefn",         OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
268         {NULL, 0},
269 };
272 /* Module pin mux for rgmii1 */
273 static struct pinmux_config rgmii1_pin_mux[] = {
274         {"mii1_txen.rgmii1_tctl", OMAP_MUX_MODE2 | AM33XX_PIN_OUTPUT},
275         {"mii1_rxdv.rgmii1_rctl", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLDOWN},
276         {"mii1_txd3.rgmii1_td3", OMAP_MUX_MODE2 | AM33XX_PIN_OUTPUT},
277         {"mii1_txd2.rgmii1_td2", OMAP_MUX_MODE2 | AM33XX_PIN_OUTPUT},
278         {"mii1_txd1.rgmii1_td1", OMAP_MUX_MODE2 | AM33XX_PIN_OUTPUT},
279         {"mii1_txd0.rgmii1_td0", OMAP_MUX_MODE2 | AM33XX_PIN_OUTPUT},
280         {"mii1_txclk.rgmii1_tclk", OMAP_MUX_MODE2 | AM33XX_PIN_OUTPUT},
281         {"mii1_rxclk.rgmii1_rclk", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLDOWN},
282         {"mii1_rxd3.rgmii1_rd3", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLDOWN},
283         {"mii1_rxd2.rgmii1_rd2", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLDOWN},
284         {"mii1_rxd1.rgmii1_rd1", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLDOWN},
285         {"mii1_rxd0.rgmii1_rd0", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLDOWN},
286         {"mdio_data.mdio_data", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
287         {"mdio_clk.mdio_clk", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT_PULLUP},
288         {NULL, 0},
289 };
291 /* Module pin mux for rgmii2 */
292 static struct pinmux_config rgmii2_pin_mux[] = {
293         {"gpmc_a0.rgmii2_tctl", OMAP_MUX_MODE2 | AM33XX_PIN_OUTPUT},
294         {"gpmc_a1.rgmii2_rctl", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLDOWN},
295         {"gpmc_a2.rgmii2_td3", OMAP_MUX_MODE2 | AM33XX_PIN_OUTPUT},
296         {"gpmc_a3.rgmii2_td2", OMAP_MUX_MODE2 | AM33XX_PIN_OUTPUT},
297         {"gpmc_a4.rgmii2_td1", OMAP_MUX_MODE2 | AM33XX_PIN_OUTPUT},
298         {"gpmc_a5.rgmii2_td0", OMAP_MUX_MODE2 | AM33XX_PIN_OUTPUT},
299         {"gpmc_a6.rgmii2_tclk", OMAP_MUX_MODE2 | AM33XX_PIN_OUTPUT},
300         {"gpmc_a7.rgmii2_rclk", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLDOWN},
301         {"gpmc_a8.rgmii2_rd3", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLDOWN},
302         {"gpmc_a9.rgmii2_rd2", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLDOWN},
303         {"gpmc_a10.rgmii2_rd1", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLDOWN},
304         {"gpmc_a11.rgmii2_rd0", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLDOWN},
305         {"mdio_data.mdio_data", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
306         {"mdio_clk.mdio_clk", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT_PULLUP},
307         {NULL, 0},
308 };
310 /* Module pin mux for mii1 */
311 static struct pinmux_config mii1_pin_mux[] = {
312         {"mii1_rxerr.mii1_rxerr", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},
313         {"mii1_txen.mii1_txen", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
314         {"mii1_rxdv.mii1_rxdv", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},
315         {"mii1_txd3.mii1_txd3", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
316         {"mii1_txd2.mii1_txd2", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
317         {"mii1_txd1.mii1_txd1", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
318         {"mii1_txd0.mii1_txd0", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
319         {"mii1_txclk.mii1_txclk", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},
320         {"mii1_rxclk.mii1_rxclk", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},
321         {"mii1_rxd3.mii1_rxd3", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},
322         {"mii1_rxd2.mii1_rxd2", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},
323         {"mii1_rxd1.mii1_rxd1", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},
324         {"mii1_rxd0.mii1_rxd0", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},
325         {"mdio_data.mdio_data", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
326         {"mdio_clk.mdio_clk", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT_PULLUP},
327         {NULL, 0},
328 };
330 /*
331 * @pin_mux - single module pin-mux structure which defines pin-mux
332 *                       details for all its pins.
333 */
334 static void setup_pin_mux(struct pinmux_config *pin_mux)
336         int i;
338         for (i = 0; pin_mux->string_name != NULL; pin_mux++)
339                 omap_mux_init_signal(pin_mux->string_name, pin_mux->val);
343 /*
344 * @evm_id - evm id which needs to be configured
345 * @dev_cfg - single evm structure which includes
346 *                               all module inits, pin-mux defines
347 * @profile - if present, else PROFILE_NONE
348 * @dghtr_brd_flg - Whether Daughter board is present or not
349 */
350 static void _configure_device(int evm_id, struct evm_dev_cfg *dev_cfg,
351         int profile)
353         int i;
355         /*
356         * Only General Purpose & Industrial Auto Motro Control
357         * EVM has profiles. So check if this evm has profile.
358         * If not, ignore the profile comparison
359         */
361         /*
362         * If the device is on baseboard, directly configure it. Else (device on
363         * Daughter board), check if the daughter card is detected.
364         */
365         if (profile == PROFILE_NONE) {
366                 for (i = 0; dev_cfg->device_init != NULL; dev_cfg++) {
367                         if (dev_cfg->device_on == DEV_ON_BASEBOARD)
368                                 dev_cfg->device_init(evm_id, profile);
369                         else if (daughter_brd_detected == true)
370                                 dev_cfg->device_init(evm_id, profile);
371                 }
372         } else {
373                 for (i = 0; dev_cfg->device_init != NULL; dev_cfg++) {
374                         if (dev_cfg->profile & profile) {
375                                 if (dev_cfg->device_on == DEV_ON_BASEBOARD)
376                                         dev_cfg->device_init(evm_id, profile);
377                                 else if (daughter_brd_detected == true)
378                                         dev_cfg->device_init(evm_id, profile);
379                         }
380                 }
381         }
384 /* Convert GPIO signal to GPIO pin number */
385 #define GPIO_TO_PIN(bank, gpio) (32 * (bank) + (gpio))
387 #define AM335X_LCD_BL_PIN       GPIO_TO_PIN(0, 7)
389 /* pinmux for usb0 drvvbus */
390 static struct pinmux_config usb0_pin_mux[] = {
391         {"usb0_drvvbus.usb0_drvvbus",    OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
392         {NULL, 0},
393 };
395 /* pinmux for usb1 drvvbus */
396 static struct pinmux_config usb1_pin_mux[] = {
397         {"usb1_drvvbus.usb1_drvvbus",    OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
398         {NULL, 0},
399 };
401 /* Module pin mux for eCAP0 */
402 static struct pinmux_config ecap0_pin_mux[] = {
403         {"ecap0_in_pwm0_out.gpio0_7", AM33XX_PIN_OUTPUT},
404         {NULL, 0},
405 };
407 static int backlight_enable;
409 static void enable_ecap0(int evm_id, int profile)
411         backlight_enable = true;
414 static int __init ecap0_init(void)
416         int status = 0;
418         if (backlight_enable) {
419                 setup_pin_mux(ecap0_pin_mux);
421                 status = gpio_request(AM335X_LCD_BL_PIN, "lcd bl\n");
422                 if (status < 0)
423                         pr_warn("Failed to request gpio for LCD backlight\n");
425                 gpio_direction_output(AM335X_LCD_BL_PIN, 1);
426         }
427         return status;
429 late_initcall(ecap0_init);
431 static int __init conf_disp_pll(int rate)
433         struct clk *disp_pll;
434         int ret = -EINVAL;
436         disp_pll = clk_get(NULL, "dpll_disp_ck");
437         if (IS_ERR(disp_pll)) {
438                 pr_err("Cannot clk_get disp_pll\n");
439                 goto out;
440         }
442         ret = clk_set_rate(disp_pll, rate);
443         clk_put(disp_pll);
444 out:
445         return ret;
448 static void lcdc_init(int evm_id, int profile)
451         setup_pin_mux(lcdc_pin_mux);
453         if (conf_disp_pll(300000000)) {
454                 pr_info("Failed configure display PLL, not attempting to"
455                                 "register LCDC\n");
456                 return;
457         }
459         if (am33xx_register_lcdc(&TFC_S9700RTWV35TR_01B_pdata))
460                 pr_info("Failed to register LCDC device\n");
461         return;
464 static void tsc_init(int evm_id, int profile)
466         int err;
468         if (gp_evm_revision == GP_EVM_REV_IS_1_1A) {
469                 am335x_touchscreen_data.analog_input = 1;
470                 pr_info("TSC connected to beta GP EVM\n");
471         } else {
472                 am335x_touchscreen_data.analog_input = 0;
473                 pr_info("TSC connected to alpha GP EVM\n");
474         }
475         setup_pin_mux(tsc_pin_mux);
476         err = platform_device_register(&tsc_device);
477         if (err)
478                 pr_err("failed to register touchscreen device\n");
481 static void rgmii1_init(int evm_id, int profile)
483         setup_pin_mux(rgmii1_pin_mux);
484         return;
487 static void rgmii2_init(int evm_id, int profile)
489         setup_pin_mux(rgmii2_pin_mux);
490         return;
493 static void mii1_init(int evm_id, int profile)
495         setup_pin_mux(mii1_pin_mux);
496         return;
499 static void usb0_init(int evm_id, int profile)
501         setup_pin_mux(usb0_pin_mux);
502         return;
505 static void usb1_init(int evm_id, int profile)
507         setup_pin_mux(usb1_pin_mux);
508         return;
511 /* Low-Cost EVM */
512 static struct evm_dev_cfg low_cost_evm_dev_cfg[] = {
513         {rgmii1_init,   DEV_ON_BASEBOARD, PROFILE_NONE},
514         {usb0_init,     DEV_ON_BASEBOARD, PROFILE_NONE},
515         {usb1_init,     DEV_ON_BASEBOARD, PROFILE_NONE},
516         {NULL, 0, 0},
517 };
519 /* General Purpose EVM */
520 static struct evm_dev_cfg gen_purp_evm_dev_cfg[] = {
521         {enable_ecap0,  DEV_ON_DGHTR_BRD, (PROFILE_0 | PROFILE_1 |
522                                                 PROFILE_2 | PROFILE_7) },
523         {lcdc_init,     DEV_ON_DGHTR_BRD, (PROFILE_0 | PROFILE_1 |
524                                                 PROFILE_2 | PROFILE_7) },
525         {tsc_init,      DEV_ON_DGHTR_BRD, (PROFILE_0 | PROFILE_1 |
526                                                 PROFILE_2 | PROFILE_7) },
527         {rgmii1_init,   DEV_ON_BASEBOARD, PROFILE_ALL},
528         {rgmii2_init,   DEV_ON_DGHTR_BRD, (PROFILE_1 | PROFILE_2 |
529                                                 PROFILE_4 | PROFILE_6) },
530         {usb0_init,     DEV_ON_BASEBOARD, PROFILE_ALL},
531         {usb1_init,     DEV_ON_BASEBOARD, PROFILE_ALL},
532         {NULL, 0, 0},
533 };
535 /* Industrial Auto Motor Control EVM */
536 static struct evm_dev_cfg ind_auto_mtrl_evm_dev_cfg[] = {
537         {mii1_init,     DEV_ON_DGHTR_BRD, PROFILE_ALL},
538         {usb0_init,     DEV_ON_BASEBOARD, PROFILE_ALL},
539         {usb1_init,     DEV_ON_BASEBOARD, PROFILE_ALL},
540         {NULL, 0, 0},
541 };
543 /* IP-Phone EVM */
544 static struct evm_dev_cfg ip_phn_evm_dev_cfg[] = {
545         {enable_ecap0,  DEV_ON_DGHTR_BRD, PROFILE_NONE},
546         {lcdc_init,     DEV_ON_DGHTR_BRD, PROFILE_NONE},
547         {tsc_init,      DEV_ON_DGHTR_BRD, PROFILE_NONE},
548         {rgmii1_init,   DEV_ON_BASEBOARD, PROFILE_NONE},
549         {rgmii2_init,   DEV_ON_DGHTR_BRD, PROFILE_NONE},
550         {usb0_init,     DEV_ON_BASEBOARD, PROFILE_NONE},
551         {usb1_init,     DEV_ON_BASEBOARD, PROFILE_NONE},
552         {NULL, 0, 0},
553 };
555 static void setup_low_cost_evm(void)
557         pr_info("The board is a AM335x Low Cost EVM.\n");
559         _configure_device(LOW_COST_EVM, low_cost_evm_dev_cfg, PROFILE_NONE);
562 static void setup_general_purpose_evm(void)
564         u32 prof_sel = am335x_get_profile_selection();
565         pr_info("The board is general purpose EVM in profile %d\n", prof_sel);
567         if (!strncmp("1.1A", config.version, 4)) {
568                 gp_evm_revision = GP_EVM_REV_IS_1_1A;
569         } else if (!strncmp("1.0", config.version, 3)) {
570                 gp_evm_revision = GP_EVM_REV_IS_1_0;
571         } else {
572                 pr_err("Found invalid GP EVM revision, falling back to Rev1.1A");
573                 gp_evm_revision = GP_EVM_REV_IS_1_1A;
574         }
576         if (gp_evm_revision == GP_EVM_REV_IS_1_0)
577                 gigabit_enable = 0;
578         else if (gp_evm_revision == GP_EVM_REV_IS_1_1A)
579                 gigabit_enable = 1;
581         _configure_device(GEN_PURP_EVM, gen_purp_evm_dev_cfg, (1L << prof_sel));
584 static void setup_ind_auto_motor_ctrl_evm(void)
586         u32 prof_sel = am335x_get_profile_selection();
588         pr_info("The board is an industrial automation EVM in profile %d\n",
589                 prof_sel);
591         /* Only Profile 0 is supported */
592         if ((1L << prof_sel) != PROFILE_0) {
593                 pr_err("AM335X: Only Profile 0 is supported\n");
594                 pr_err("Assuming profile 0 & continuing\n");
595                 prof_sel = PROFILE_0;
596         }
598         _configure_device(IND_AUT_MTR_EVM, ind_auto_mtrl_evm_dev_cfg,
599                 PROFILE_0);
603 static void setup_ip_phone_evm(void)
605         pr_info("The board is an IP phone EVM\n");
607         _configure_device(IP_PHN_EVM, ip_phn_evm_dev_cfg, PROFILE_NONE);
610 static void am335x_setup_daughter_board(struct memory_accessor *m, void *c)
612         u8 tmp;
613         int ret;
615         /*
616          * try reading a byte from the EEPROM to see if it is
617          * present. We could read a lot more, but that would
618          * just slow the boot process and we have all the information
619          * we need from the EEPROM on the base board anyway.
620          */
621         ret = m->read(m, &tmp, 0, sizeof(u8));
622         if (ret == sizeof(u8)) {
623                 pr_info("Detected a daughter card on AM335x EVM..");
624                 daughter_brd_detected = true;
625         } else {
626                 pr_info("No daughter card found\n");
627                 daughter_brd_detected = false;
628         }
631 static void am335x_evm_setup(struct memory_accessor *mem_acc, void *context)
633         int ret;
634         char tmp[10];
636         /* get board specific data */
637         ret = mem_acc->read(mem_acc, (char *)&config, 0, sizeof(config));
638         if (ret != sizeof(config)) {
639                 pr_warning("AM335X EVM config read fail, read %d bytes\n", ret);
640                 return;
641         }
643         if (config.header != AM335X_EEPROM_HEADER) {
644                 pr_warning("AM335X: wrong header 0x%x, expected 0x%x\n",
645                         config.header, AM335X_EEPROM_HEADER);
646                 goto out;
647         }
649         if (strncmp("A335", config.name, 4)) {
650                 pr_err("Board %s doesn't look like an AM335x board\n",
651                         config.name);
652                 goto out;
653         }
655         snprintf(tmp, sizeof(config.name), "%s", config.name);
656         pr_info("Board name: %s\n", tmp);
657         /* only 6 characters of options string used for now */
658         snprintf(tmp, 7, "%s", config.opt);
659         pr_info("SKU: %s\n", tmp);
661         if (!strncmp("SKU#00", config.opt, 6))
662                 setup_low_cost_evm();
663         else if (!strncmp("SKU#01", config.opt, 6))
664                 setup_general_purpose_evm();
665         else if (!strncmp("SKU#02", config.opt, 6))
666                 setup_ind_auto_motor_ctrl_evm();
667         else if (!strncmp("SKU#03", config.opt, 6))
668                 setup_ip_phone_evm();
669         else
670                 goto out;
672         /* Initialize cpsw after board detection is completed as board
673          * information is required for configuring phy address and hence
674          * should be call only after board detection
675          */
676         am33xx_cpsw_init();
678         return;
679 out:
680         /*
681          * for bring-up assume a full configuration, this should
682          * eventually be changed to assume a minimal configuration
683          */
684         pr_err("Could not detect any board, falling back to: "
685                 "General purpose EVM in profile 0 with daughter card connected\n");
686         daughter_brd_detected = true;
687         setup_general_purpose_evm();
689         /* Initialize cpsw after board detection is completed as board
690          * information is required for configuring phy address and hence
691          * should be call only after board detection
692          */
693         am33xx_cpsw_init();
697 static struct at24_platform_data am335x_daughter_board_eeprom_info = {
698         .byte_len       = (256*1024) / 8,
699         .page_size      = 64,
700         .flags          = AT24_FLAG_ADDR16,
701         .setup          = am335x_setup_daughter_board,
702         .context        = (void *)NULL,
703 };
705 static struct at24_platform_data am335x_baseboard_eeprom_info = {
706         .byte_len       = (256*1024) / 8,
707         .page_size      = 64,
708         .flags          = AT24_FLAG_ADDR16,
709         .setup          = am335x_evm_setup,
710         .context        = (void *)NULL,
711 };
713 /*
714 * Daughter board Detection.
715 * Every board has a ID memory (EEPROM) on board. We probe these devices at
716 * machine init, starting from daughter board and ending with baseboard.
717 * Assumptions :
718 *       1. probe for i2c devices are called in the order they are included in
719 *          the below struct. Daughter boards eeprom are probed 1st. Baseboard
720 *          eeprom probe is called last.
721 */
722 static struct i2c_board_info __initdata am335x_i2c_boardinfo[] = {
723         {
724                 /* Daughter Board EEPROM */
725                 I2C_BOARD_INFO("24c256", DAUG_BOARD_I2C_ADDR),
726                 .platform_data  = &am335x_daughter_board_eeprom_info,
727         },
728         {
729                 /* Baseboard board EEPROM */
730                 I2C_BOARD_INFO("24c256", BASEBOARD_I2C_ADDR),
731                 .platform_data  = &am335x_baseboard_eeprom_info,
732         },
733         {
734                 I2C_BOARD_INFO("cpld_reg", 0x35),
735         },
736         {
737                 I2C_BOARD_INFO("tlc59108", 0x40),
738         },
740 };
742 static struct omap_musb_board_data musb_board_data = {
743         .interface_type = MUSB_INTERFACE_ULPI,
744         .mode           = MUSB_OTG,
745         .power          = 500,
746         .instances      = 1,
747 };
749 static int cpld_reg_probe(struct i2c_client *client,
750             const struct i2c_device_id *id)
752         cpld_client = client;
753         return 0;
756 static int __devexit cpld_reg_remove(struct i2c_client *client)
758         cpld_client = NULL;
759         return 0;
762 static const struct i2c_device_id cpld_reg_id[] = {
763         { "cpld_reg", 0 },
764         { }
765 };
767 static struct i2c_driver cpld_reg_driver = {
768         .driver = {
769                 .name   = "cpld_reg",
770         },
771         .probe          = cpld_reg_probe,
772         .remove         = cpld_reg_remove,
773         .id_table       = cpld_reg_id,
774 };
776 static void evm_init_cpld(void)
778         i2c_add_driver(&cpld_reg_driver);
781 static void __init am335x_evm_i2c_init(void)
783         /* Initially assume Low Cost EVM Config */
784         am335x_evm_id = LOW_COST_EVM;
786         evm_init_cpld();
788         omap_register_i2c_bus(1, 100, am335x_i2c_boardinfo,
789                                 ARRAY_SIZE(am335x_i2c_boardinfo));
792 static void __init am335x_evm_init(void)
794         am33xx_mux_init(board_mux);
795         omap_serial_init();
796         am335x_evm_i2c_init();
797         omap_sdrc_init(NULL, NULL);
798         usb_musb_init(&musb_board_data);
799         omap_board_config = am335x_evm_config;
800         omap_board_config_size = ARRAY_SIZE(am335x_evm_config);
803 static void __init am335x_evm_map_io(void)
805         omap2_set_globals_am33xx();
806         omapam33xx_map_common_io();
809 MACHINE_START(AM335XEVM, "am335xevm")
810         /* Maintainer: Texas Instruments */
811         .atag_offset    = 0x100,
812         .map_io         = am335x_evm_map_io,
813         .init_early     = am33xx_init_early,
814         .init_irq       = ti81xx_init_irq,
815         .handle_irq     = omap3_intc_handle_irq,
816         .timer          = &omap3_am33xx_timer,
817         .init_machine   = am335x_evm_init,
818 MACHINE_END