]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - sitara-epos/sitara-epos-kernel.git/blob - arch/arm/mach-omap2/board-omap3encore.c
am335x-evm: beta evm bringup changes for wlan and bt
[sitara-epos/sitara-epos-kernel.git] / arch / arm / mach-omap2 / board-omap3encore.c
1 /*
2  * Support for Barns&Noble Nook Color
3  *
4  * Loosely based on mach-omap2/board-zoom.c
5  * Copyright (C) 2008-2010 Texas Instruments Inc.
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  *
11  * June 2011 Oleg Drokin <green@linuxhacker.ru> - Port to mainline
12  *
13  */
15 #include <linux/gpio.h>
16 #include <linux/gpio_keys.h>
17 #include <linux/i2c/twl.h>
18 #include <linux/regulator/machine.h>
20 #include <asm/mach-types.h>
21 #include <asm/mach/arch.h>
23 #include <plat/usb.h>
24 #include <plat/mux.h>
25 #include <plat/mmc.h>
27 #include "common.h"
28 #include "mux.h"
29 #include "hsmmc.h"
30 #include "sdram-hynix-h8mbx00u0mer-0em.h"
32 /* Encore-specific device-info and i2c addresses. */
33 /* Battery, bus 1 */
34 #define MAX17042_I2C_SLAVE_ADDRESS      0x36
35 #define MAX17042_GPIO_FOR_IRQ           100
37 /*addition of MAXIM8903/TI GPIO mapping WRT schematics */
38 #define MAX8903_UOK_GPIO_FOR_IRQ        115
39 #define MAX8903_DOK_GPIO_FOR_IRQ        114
40 #define MAX8903_GPIO_CHG_EN             110
41 #define MAX8903_GPIO_CHG_STATUS         111
42 #define MAX8903_GPIO_CHG_FLT            101
43 #define MAX8903_GPIO_CHG_IUSB           102
44 #define MAX8903_GPIO_CHG_USUS           104
45 #define MAX8903_GPIO_CHG_ILM            61
47 /* TI WLAN */
48 #define ENCORE_WIFI_PMENA_GPIO          22
49 #define ENCORE_WIFI_IRQ_GPIO            15
50 #define ENCORE_WIFI_EN_POW              16
52 /* Accelerometer i2c bus 1*/
53 #define KXTF9_I2C_SLAVE_ADDRESS         0x0F
54 #define KXTF9_GPIO_FOR_PWR              34
55 #define KXTF9_GPIO_FOR_IRQ              113
57 /* Touch screen i2c bus 2*/
58 #define CYTTSP_I2C_SLAVEADDRESS         34
59 #define ENCORE_CYTTSP_GPIO              99
60 #define ENCORE_CYTTSP_RESET_GPIO        46
62 /* Audio codec, i2c bus 2 */
63 #define AUDIO_CODEC_POWER_ENABLE_GPIO   103
64 #define AUDIO_CODEC_RESET_GPIO          37
65 #define AUDIO_CODEC_IRQ_GPIO            59
66 #define AIC3100_I2CSLAVEADDRESS         0x18
69 /* Different HW revisions */
70 #define BOARD_ENCORE_REV_EVT1A          0x1
71 #define BOARD_ENCORE_REV_EVT1B          0x2
72 #define BOARD_ENCORE_REV_EVT2           0x3
73 #define BOARD_ENCORE_REV_DVT            0x4
74 #define BOARD_ENCORE_REV_PVT            0x5
75 #define BOARD_ENCORE_REV_UNKNOWN        0x6
77 static inline int is_encore_board_evt2(void)
78 {
79         return system_rev >= BOARD_ENCORE_REV_EVT2;
80 }
82 static inline int is_encore_board_evt1b(void)
83 {
84         return system_rev == BOARD_ENCORE_REV_EVT1B;
85 }
87 static int encore_twl4030_keymap[] = {
88         KEY(1, 0, KEY_VOLUMEUP),
89         KEY(2, 0, KEY_VOLUMEDOWN),
90 };
92 static struct matrix_keymap_data encore_twl4030_keymap_data = {
93         .keymap                 = encore_twl4030_keymap,
94         .keymap_size            = ARRAY_SIZE(encore_twl4030_keymap),
95 };
97 static struct twl4030_keypad_data encore_kp_twl4030_data = {
98         .rows                   = 8,
99         .cols                   = 8,
100         .keymap_data            = &encore_twl4030_keymap_data,
101         .rep                    = 1,
102 };
104 /* HOME key code for HW > EVT2A */
105 static struct gpio_keys_button encore_gpio_buttons[] = {
106         {
107                 .code                   = KEY_POWER,
108                 .gpio                   = 14,
109                 .desc                   = "POWER",
110                 .active_low             = 0,
111                 .wakeup                 = 1,
112         },
113         {
114                 .code                   = KEY_HOME,
115                 .gpio                   = 48,
116                 .desc                   = "HOME",
117                 .active_low             = 1,
118                 .wakeup                 = 1,
119         },
120 };
122 static struct gpio_keys_platform_data encore_gpio_key_info = {
123         .buttons        = encore_gpio_buttons,
124         .nbuttons       = ARRAY_SIZE(encore_gpio_buttons),
125 };
127 static struct platform_device encore_keys_gpio = {
128         .name   = "gpio-keys",
129         .id     = -1,
130         .dev    = {
131                 .platform_data  = &encore_gpio_key_info,
132         },
133 };
135 static struct platform_device *encore_devices[] __initdata = {
136         &encore_keys_gpio,
137 };
139 static struct twl4030_usb_data encore_usb_data = {
140         .usb_mode       = T2_USB_MODE_ULPI,
141 };
143 static struct regulator_consumer_supply encore_vmmc1_supply[] = {
144         REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
145 };
147 static struct regulator_consumer_supply encore_vdda_dac_supply[] = {
148         REGULATOR_SUPPLY("vdda_dac", "omapdss_venc"),
149 };
151 /* VMMC1 for OMAP VDD_MMC1 (i/o) and MMC1 card */
152 static struct regulator_init_data encore_vmmc1 = {
153         .constraints = {
154                 .min_uV                 = 1850000,
155                 .max_uV                 = 3150000,
156                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
157                                         | REGULATOR_MODE_STANDBY,
158                 .valid_ops_mask         = REGULATOR_CHANGE_VOLTAGE
159                                         | REGULATOR_CHANGE_MODE
160                                         | REGULATOR_CHANGE_STATUS,
161         },
162         .num_consumer_supplies  = ARRAY_SIZE(encore_vmmc1_supply),
163         .consumer_supplies      = encore_vmmc1_supply,
164 };
166 static struct regulator_init_data encore_vdac = {
167         .constraints = {
168                 .min_uV                 = 1800000,
169                 .max_uV                 = 1800000,
170                 .valid_modes_mask       = REGULATOR_MODE_NORMAL
171                                         | REGULATOR_MODE_STANDBY,
172                 .valid_ops_mask         = REGULATOR_CHANGE_MODE
173                                         | REGULATOR_CHANGE_STATUS,
174         },
175         .num_consumer_supplies  = ARRAY_SIZE(encore_vdda_dac_supply),
176         .consumer_supplies      = encore_vdda_dac_supply,
177 };
179 /*
180  * The order is reverted in this table so that internal eMMC is presented
181  * as first mmc card for compatibility with existing installations and
182  * for common sense reasons
183  */
184 static struct omap2_hsmmc_info mmc[] __initdata = {
185         {
186                 .name           = "internal",
187                 .mmc            = 2,
188                 .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
189                 .gpio_cd        = -EINVAL,
190                 .gpio_wp        = -EINVAL,
191                 .nonremovable   = true,
192                 .power_saving   = true,
193                 .ocr_mask       = MMC_VDD_165_195, /* 1.85V */
194         },
195         {
196                 .name           = "external",
197                 .mmc            = 1,
198                 .caps           = MMC_CAP_4_BIT_DATA,
199                 .gpio_cd        = -EINVAL,
200                 .gpio_wp        = -EINVAL,
201                 .power_saving   = true,
202         },
203         {
204                 .name           = "internal",
205                 .mmc            = 3,
206                 .caps           = MMC_CAP_4_BIT_DATA,
207                 .gpio_cd        = -EINVAL,
208                 .gpio_wp        = -EINVAL,
209                 .nonremovable   = true,
210                 .power_saving   = true,
211         },
212         {}      /* Terminator */
213 };
215 static int encore_hsmmc_card_detect(struct device *dev, int slot)
217         struct omap_mmc_platform_data *mmc = dev->platform_data;
219         /* Encore board EVT2 and later has pin high when card is present */
220         return gpio_get_value_cansleep(mmc->slots[0].switch_pin);
223 static int encore_twl4030_hsmmc_late_init(struct device *dev)
225         int ret = 0;
226         struct platform_device *pdev = container_of(dev,
227                                                 struct platform_device, dev);
228         struct omap_mmc_platform_data *pdata = dev->platform_data;
230         if (is_encore_board_evt2()) {
231                 /* Setting MMC1 (external) Card detect */
232                 if (pdev->id == 0)
233                         pdata->slots[0].card_detect = encore_hsmmc_card_detect;
234         }
236         return ret;
239 static __init void encore_hsmmc_set_late_init(struct device *dev)
241         struct omap_mmc_platform_data *pdata;
243         /* dev can be null if CONFIG_MMC_OMAP_HS is not set */
244         if (!dev)
245                 return;
247         pdata = dev->platform_data;
248         pdata->init = encore_twl4030_hsmmc_late_init;
251 static int __ref encore_twl_gpio_setup(struct device *dev,
252                 unsigned gpio, unsigned ngpio)
254         struct omap2_hsmmc_info *c;
255         /*
256          * gpio + 0 is "mmc0_cd" (input/IRQ),
257          * gpio + 1 is "mmc1_cd" (input/IRQ)
258          */
259         mmc[1].gpio_cd = gpio + 0;
260         mmc[0].gpio_cd = gpio + 1;
261         omap2_hsmmc_init(mmc);
262         for (c = mmc; c->mmc; c++)
263                 encore_hsmmc_set_late_init(c->dev);
265         return 0;
268 static struct twl4030_gpio_platform_data encore_gpio_data = {
269         .gpio_base      = OMAP_MAX_GPIO_LINES,
270         .irq_base       = TWL4030_GPIO_IRQ_BASE,
271         .irq_end        = TWL4030_GPIO_IRQ_END,
272         .setup          = encore_twl_gpio_setup,
273 };
275 static struct twl4030_madc_platform_data encore_madc_data = {
276         .irq_line       = 1,
277 };
279 static struct twl4030_platform_data __refdata encore_twldata = {
280         .irq_base       = TWL4030_IRQ_BASE,
281         .irq_end        = TWL4030_IRQ_END,
283         .madc           = &encore_madc_data,
284         .usb            = &encore_usb_data,
285         .gpio           = &encore_gpio_data,
286         .keypad         = &encore_kp_twl4030_data,
287         .vmmc1          = &encore_vmmc1,
288         .vdac           = &encore_vdac,
289 };
291 static struct i2c_board_info __initdata encore_i2c_bus1_info[] = {
292         {
293                 I2C_BOARD_INFO("tps65921", 0x48),
294                 .flags = I2C_CLIENT_WAKE,
295                 .irq = INT_34XX_SYS_NIRQ,
296                 .platform_data = &encore_twldata,
297         },
298 };
300 static struct i2c_board_info __initdata encore_i2c_bus2_info[] = {
301 };
303 #ifdef CONFIG_OMAP_MUX
304 static struct omap_board_mux board_mux[] __initdata = {
305         { .reg_offset = OMAP_MUX_TERMINATOR },
306 };
307 #endif
309 static struct omap_board_config_kernel encore_config[] __initdata = {
310 };
312 static void __init omap_i2c_init(void)
314         omap_register_i2c_bus(1, 100, encore_i2c_bus1_info,
315                         ARRAY_SIZE(encore_i2c_bus1_info));
316         omap_register_i2c_bus(2, 400, encore_i2c_bus2_info,
317                         ARRAY_SIZE(encore_i2c_bus2_info));
320 static void __init omap_encore_init(void)
322         omap3_mux_init(board_mux, OMAP_PACKAGE_CBP);
323         omap_i2c_init();
324         omap_serial_init();
325         omap_sdrc_init(h8mbx00u0mer0em_sdrc_params,
326                                   h8mbx00u0mer0em_sdrc_params);
327         usb_musb_init(NULL);
329         omap_board_config = encore_config;
330         omap_board_config_size = ARRAY_SIZE(encore_config);
332         platform_add_devices(encore_devices, ARRAY_SIZE(encore_devices));
335 MACHINE_START(ENCORE, "encore")
336         .atag_offset    = 0x100,
337         .reserve        = omap_reserve,
338         .map_io         = omap3_map_io,
339         .init_early     = omap3630_init_early,
340         .init_irq       = omap3_init_irq,
341         .handle_irq     = omap3_intc_handle_irq,
342         .init_machine   = omap_encore_init,
343         .timer          = &omap3_timer,
344 MACHINE_END