linux 3.0: add support for RTC on zippy/zippy2 boards
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-3.0 / beagle / 0002-UNFINISHED-OMAP3-beagle-add-support-for-expansionboa.patch
1 From e5e3655c165de9507d2020d5eae4c5589c7a3dad Mon Sep 17 00:00:00 2001
2 From: Koen Kooi <koen@dominion.thruhere.net>
3 Date: Thu, 21 Jul 2011 14:29:42 +0200
4 Subject: [PATCH 2/3] UNFINISHED: OMAP3: beagle: add support for expansionboards
6 Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
7 ---
8  arch/arm/mach-omap2/board-omap3beagle.c |  266 +++++++++++++++++++++++++++++++
9  1 files changed, 266 insertions(+), 0 deletions(-)
11 diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
12 index 32f5f89..f26a9a8 100644
13 --- a/arch/arm/mach-omap2/board-omap3beagle.c
14 +++ b/arch/arm/mach-omap2/board-omap3beagle.c
15 @@ -21,6 +21,7 @@
16  #include <linux/io.h>
17  #include <linux/leds.h>
18  #include <linux/gpio.h>
19 +#include <linux/irq.h>
20  #include <linux/input.h>
21  #include <linux/gpio_keys.h>
22  #include <linux/opp.h>
23 @@ -156,6 +157,167 @@ static void __init omap3_beagle_init_rev(void)
24         }
25  }
26  
27 +char expansionboard_name[16];
28 +
29 +#if defined(CONFIG_WL12XX) || defined(CONFIG_WL12XX_MODULE)
30 +#include <linux/regulator/fixed.h>
31 +#include <linux/wl12xx.h>
32 +
33 +#define OMAP_BEAGLE_WLAN_EN_GPIO    (139)
34 +#define OMAP_BEAGLE_BT_EN_GPIO      (138)
35 +#define OMAP_BEAGLE_WLAN_IRQ_GPIO   (137)
36 +#define OMAP_BEAGLE_FM_EN_BT_WU     (136)
37 +
38 +struct wl12xx_platform_data omap_beagle_wlan_data __initdata = {
39 +       .irq = OMAP_GPIO_IRQ(OMAP_BEAGLE_WLAN_IRQ_GPIO),
40 +       .board_ref_clock = 2, /* 38.4 MHz */
41 +};
42 +
43 +static int gpios[] = {OMAP_BEAGLE_BT_EN_GPIO, OMAP_BEAGLE_FM_EN_BT_WU, -1};
44 +static struct platform_device wl12xx_device = {
45 +               .name           = "kim",
46 +               .id                     = -1,
47 +               .dev.platform_data = &gpios,
48 +};
49 +
50 +static struct omap2_hsmmc_info mmcbbt[] = {
51 +       {
52 +               .mmc            = 1,
53 +               .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
54 +               .gpio_wp        = 29,
55 +       },
56 +       {
57 +               .name           = "wl1271",
58 +               .mmc            = 2,
59 +               .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD,
60 +               .gpio_wp        = -EINVAL,
61 +               .gpio_cd        = -EINVAL,
62 +               .ocr_mask       = MMC_VDD_165_195,
63 +               .nonremovable   = true,
64 +       },
65 +       {}      /* Terminator */
66 + };
67 +
68 +static struct regulator_consumer_supply beagle_vmmc2_supply = 
69 +       REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1");
70 +
71 +static struct regulator_init_data beagle_vmmc2 = {
72 +       .constraints = {
73 +               .min_uV                 = 1850000,
74 +               .max_uV                 = 1850000,
75 +               .apply_uV               = true,
76 +               .valid_modes_mask       = REGULATOR_MODE_NORMAL
77 +                                       | REGULATOR_MODE_STANDBY,
78 +               .valid_ops_mask         = REGULATOR_CHANGE_MODE
79 +                                       | REGULATOR_CHANGE_STATUS,
80 +       },
81 +       .num_consumer_supplies = 1,
82 +       .consumer_supplies = &beagle_vmmc2_supply,
83 +};
84 +
85 +static struct fixed_voltage_config beagle_vwlan = {
86 +       .supply_name = "vwl1271",
87 +       .microvolts = 1800000,  /* 1.8V */
88 +       .gpio = OMAP_BEAGLE_WLAN_EN_GPIO,
89 +       .startup_delay = 70000, /* 70ms */
90 +       .enable_high = 1,
91 +       .enabled_at_boot = 0,
92 +       .init_data = &beagle_vmmc2,
93 +};
94 +
95 +static struct platform_device omap_vwlan_device = {
96 +       .name           = "reg-fixed-voltage",
97 +       .id             = 1,
98 +       .dev = {
99 +               .platform_data = &beagle_vwlan,
100 +       },
101 +};
102 +#endif
104 +#if defined(CONFIG_ENC28J60) || defined(CONFIG_ENC28J60_MODULE)
106 +#include <plat/mcspi.h>
107 +#include <linux/spi/spi.h>
109 +#define OMAP3BEAGLE_GPIO_ENC28J60_IRQ 157
111 +static struct omap2_mcspi_device_config enc28j60_spi_chip_info = {
112 +       .turbo_mode     = 0,
113 +       .single_channel = 1,    /* 0: slave, 1: master */
114 +};
116 +static struct spi_board_info omap3beagle_zippy_spi_board_info[] __initdata = {
117 +       {
118 +               .modalias               = "enc28j60",
119 +               .bus_num                = 4,
120 +               .chip_select            = 0,
121 +               .max_speed_hz           = 20000000,
122 +               .controller_data        = &enc28j60_spi_chip_info,
123 +       },
124 +};
126 +static void __init omap3beagle_enc28j60_init(void)
127 +{
128 +       if ((gpio_request(OMAP3BEAGLE_GPIO_ENC28J60_IRQ, "ENC28J60_IRQ") == 0) &&
129 +           (gpio_direction_input(OMAP3BEAGLE_GPIO_ENC28J60_IRQ) == 0)) {
130 +               gpio_export(OMAP3BEAGLE_GPIO_ENC28J60_IRQ, 0);
131 +               omap3beagle_zippy_spi_board_info[0].irq = OMAP_GPIO_IRQ(OMAP3BEAGLE_GPIO_ENC28J60_IRQ);
132 +               irq_set_irq_type(omap3beagle_zippy_spi_board_info[0].irq, IRQ_TYPE_EDGE_FALLING);
133 +       } else {
134 +               printk(KERN_ERR "could not obtain gpio for ENC28J60_IRQ\n");
135 +               return;
136 +       }
138 +       spi_register_board_info(omap3beagle_zippy_spi_board_info,
139 +                       ARRAY_SIZE(omap3beagle_zippy_spi_board_info));
140 +}
142 +#else
143 +static inline void __init omap3beagle_enc28j60_init(void) { return; }
144 +#endif
146 +#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
148 +#include <plat/mcspi.h>
149 +#include <linux/spi/spi.h>
151 +#define OMAP3BEAGLE_GPIO_KS8851_IRQ 157
153 +static struct omap2_mcspi_device_config ks8851_spi_chip_info = {
154 +       .turbo_mode     = 0,
155 +       .single_channel = 1,    /* 0: slave, 1: master */
156 +};
158 +static struct spi_board_info omap3beagle_zippy2_spi_board_info[] __initdata = {
159 +       {
160 +               .modalias               = "ks8851",
161 +               .bus_num                = 4,
162 +               .chip_select            = 0,
163 +               .max_speed_hz           = 36000000,
164 +               .controller_data        = &ks8851_spi_chip_info,
165 +       },
166 +};
168 +static void __init omap3beagle_ks8851_init(void)
169 +{
170 +       if ((gpio_request(OMAP3BEAGLE_GPIO_KS8851_IRQ, "KS8851_IRQ") == 0) &&
171 +           (gpio_direction_input(OMAP3BEAGLE_GPIO_KS8851_IRQ) == 0)) {
172 +               gpio_export(OMAP3BEAGLE_GPIO_KS8851_IRQ, 0);
173 +               omap3beagle_zippy2_spi_board_info[0].irq        = OMAP_GPIO_IRQ(OMAP3BEAGLE_GPIO_KS8851_IRQ);
174 +               irq_set_irq_type(omap3beagle_zippy2_spi_board_info[0].irq, IRQ_TYPE_EDGE_FALLING);
175 +       } else {
176 +               printk(KERN_ERR "could not obtain gpio for KS8851_IRQ\n");
177 +               return;
178 +       }
179 +       
180 +       spi_register_board_info(omap3beagle_zippy2_spi_board_info,
181 +                                                       ARRAY_SIZE(omap3beagle_zippy2_spi_board_info));
182 +}
184 +#else
185 +static inline void __init omap3beagle_ks8851_init(void) { return; }
186 +#endif
188  static struct mtd_partition omap3beagle_nand_partitions[] = {
189         /* All the partition sizes are listed in terms of NAND block size */
190         {
191 @@ -254,6 +416,12 @@ static struct omap2_hsmmc_info mmc[] = {
192                 .caps           = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
193                 .gpio_wp        = -EINVAL,
194         },
195 +       {
196 +               .mmc            = 2,
197 +               .caps       = MMC_CAP_4_BIT_DATA,
198 +               .transceiver    = true,
199 +               .ocr_mask       = 0x00100000,   /* 3.3V */
200 +       },
201         {}      /* Terminator */
202  };
203  
204 @@ -277,7 +445,15 @@ static int beagle_twl_gpio_setup(struct device *dev,
205         mmc[0].gpio_wp = beagle_config.mmc1_gpio_wp;
206         /* gpio + 0 is "mmc0_cd" (input/IRQ) */
207         mmc[0].gpio_cd = gpio + 0;
208 +#if defined(CONFIG_WL12XX) || defined(CONFIG_WL12XX_MODULE)
209 +       if(!strcmp(expansionboard_name, "bbtoys-wifi")) { 
210 +               omap2_hsmmc_init(mmcbbt);
211 +       } else {
212 +               omap2_hsmmc_init(mmc);
213 +       }
214 +#else
215         omap2_hsmmc_init(mmc);
216 +#endif
217  
218         /*
219          * TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, XM active
220 @@ -375,6 +551,19 @@ static struct i2c_board_info __initdata beagle_i2c_eeprom[] = {
221         },
222  };
223  
224 +#if defined(CONFIG_RTC_DRV_DS1307) || \
225 +       defined(CONFIG_RTC_DRV_DS1307_MODULE)
227 +static struct i2c_board_info __initdata beagle_i2c2_zippy[] = {
228 +       {
229 +               I2C_BOARD_INFO("eeprom", 0x50),
230 +               I2C_BOARD_INFO("ds1307", 0x68),
231 +       },
232 +};
233 +#else
234 +static struct i2c_board_info __initdata beagle_i2c2_zippy[] = {};
235 +#endif
237  static int __init omap3_beagle_i2c_init(void)
238  {
239         omap3_pmic_get_config(&beagle_twldata,
240 @@ -479,6 +668,15 @@ static struct omap_board_mux board_mux[] __initdata = {
241  };
242  #endif
243  
244 +static int __init expansionboard_setup(char *str)
245 +{
246 +       if (!str)
247 +               return -EINVAL;
248 +       strncpy(expansionboard_name, str, 16);
249 +       printk(KERN_INFO "Beagle expansionboard: %s\n", expansionboard_name);
250 +       return 0;
251 +}
253  static void __init beagle_opp_init(void)
254  {
255         int r = 0;
256 @@ -542,6 +740,72 @@ static void __init omap3_beagle_init(void)
257         /* REVISIT leave DVI powered down until it's needed ... */
258         gpio_request_one(170, GPIOF_OUT_INIT_HIGH, "DVI_nPD");
259  
260 +       if(!strcmp(expansionboard_name, "zippy")) 
261 +       {
262 +               printk(KERN_INFO "Beagle expansionboard: initializing enc28j60\n");
263 +               omap3beagle_enc28j60_init();
264 +               printk(KERN_INFO "Beagle expansionboard: assigning GPIO 141 and 162 to MMC1\n");
265 +               mmc[1].gpio_wp = 141;
266 +               mmc[1].gpio_cd = 162;
267 +               printk(KERN_INFO "Beagle expansionboard: registering I2C2 for zippy board\n");
268 +               omap_register_i2c_bus(2, 400,  beagle_i2c2_zippy,
269 +                                                       ARRAY_SIZE(beagle_i2c2_zippy));
271 +       }
272 +       
273 +       if(!strcmp(expansionboard_name, "zippy2")) 
274 +       {
275 +               printk(KERN_INFO "Beagle expansionboard: initializing ks_8851\n");
276 +               omap3beagle_ks8851_init();
277 +               printk(KERN_INFO "Beagle expansionboard: assigning GPIO 141 and 162 to MMC1\n");
278 +               mmc[1].gpio_wp = 141;
279 +               mmc[1].gpio_cd = 162;
280 +               printk(KERN_INFO "Beagle expansionboard: registering I2C2 for zippy2 board\n");
281 +               omap_register_i2c_bus(2, 400,  beagle_i2c2_zippy,
282 +                                                       ARRAY_SIZE(beagle_i2c2_zippy));         
283 +       }
285 +       if(!strcmp(expansionboard_name, "trainer"))
286 +       {
287 +               printk(KERN_INFO "Beagle expansionboard: exporting GPIOs 130-141,162 to userspace\n");
288 +               gpio_request(130, "sysfs");
289 +               gpio_export(130, 1);
290 +               gpio_request(131, "sysfs");
291 +               gpio_export(131, 1);
292 +               gpio_request(132, "sysfs");
293 +               gpio_export(132, 1);
294 +               gpio_request(133, "sysfs");
295 +               gpio_export(133, 1);
296 +               gpio_request(134, "sysfs");
297 +               gpio_export(134, 1);
298 +               gpio_request(135, "sysfs");
299 +               gpio_export(135, 1);
300 +               gpio_request(136, "sysfs");
301 +               gpio_export(136, 1);
302 +               gpio_request(137, "sysfs");
303 +               gpio_export(137, 1);
304 +               gpio_request(138, "sysfs");
305 +               gpio_export(138, 1);
306 +               gpio_request(139, "sysfs");
307 +               gpio_export(139, 1);
308 +               gpio_request(140, "sysfs");
309 +               gpio_export(140, 1);
310 +               gpio_request(141, "sysfs");
311 +               gpio_export(141, 1);
312 +               gpio_request(162, "sysfs");
313 +               gpio_export(162, 1);
314 +       }
316 +       if(!strcmp(expansionboard_name, "bbtoys-wifi"))
317 +       {
318 +               if (wl12xx_set_platform_data(&omap_beagle_wlan_data))
319 +                       pr_err("error setting wl12xx data\n");
320 +               printk(KERN_INFO "Beagle expansionboard: registering wl12xx bt platform device\n");
321 +               platform_device_register(&wl12xx_device);
322 +               printk(KERN_INFO "Beagle expansionboard: registering wl12xx wifi platform device\n");
323 +               platform_device_register(&omap_vwlan_device);
324 +       }
326         usb_musb_init(NULL);
327         usbhs_init(&usbhs_bdata);
328         omap_nand_flash_init(NAND_BUSWIDTH_16, omap3beagle_nand_partitions,
329 @@ -558,6 +822,8 @@ static void __init omap3_beagle_init(void)
330         beagle_opp_init();
331  }
332  
333 +early_param("buddy", expansionboard_setup);
335  MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
336         /* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */
337         .boot_params    = 0x80000100,
338 -- 
339 1.6.6.1