6e8a33e9a0b34c695de96060e3cf6333aa5e4045
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-3.0 / beagle / 0002-UNFINISHED-OMAP3-beagle-add-support-for-expansionboa.patch
1 From 04557e8b744e8e6f8ab8b7c4fc715cecd585f2ab 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 |  246 +++++++++++++++++++++++++++++++
9  1 files changed, 246 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..e542df0 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 @@ -479,6 +655,15 @@ static struct omap_board_mux board_mux[] __initdata = {
221  };
222  #endif
223  
224 +static int __init expansionboard_setup(char *str)
225 +{
226 +       if (!str)
227 +               return -EINVAL;
228 +       strncpy(expansionboard_name, str, 16);
229 +       printk(KERN_INFO "Beagle expansionboard: %s\n", expansionboard_name);
230 +       return 0;
231 +}
233  static void __init beagle_opp_init(void)
234  {
235         int r = 0;
236 @@ -542,6 +727,65 @@ static void __init omap3_beagle_init(void)
237         /* REVISIT leave DVI powered down until it's needed ... */
238         gpio_request_one(170, GPIOF_OUT_INIT_HIGH, "DVI_nPD");
239  
240 +       if(!strcmp(expansionboard_name, "zippy")) 
241 +       {
242 +               printk(KERN_INFO "Beagle expansionboard: initializing enc28j60\n");
243 +               omap3beagle_enc28j60_init();
244 +               printk(KERN_INFO "Beagle expansionboard: assigning GPIO 141 and 162 to MMC1\n");
245 +               mmc[1].gpio_wp = 141;
246 +               mmc[1].gpio_cd = 162;
247 +       }
248 +       
249 +       if(!strcmp(expansionboard_name, "zippy2")) 
250 +       {
251 +               printk(KERN_INFO "Beagle expansionboard: initializing ks_8851\n");
252 +               omap3beagle_ks8851_init();
253 +               printk(KERN_INFO "Beagle expansionboard: assigning GPIO 141 and 162 to MMC1\n");
254 +               mmc[1].gpio_wp = 141;
255 +               mmc[1].gpio_cd = 162;
256 +       }
258 +       if(!strcmp(expansionboard_name, "trainer"))
259 +       {
260 +               printk(KERN_INFO "Beagle expansionboard: exporting GPIOs 130-141,162 to userspace\n");
261 +               gpio_request(130, "sysfs");
262 +               gpio_export(130, 1);
263 +               gpio_request(131, "sysfs");
264 +               gpio_export(131, 1);
265 +               gpio_request(132, "sysfs");
266 +               gpio_export(132, 1);
267 +               gpio_request(133, "sysfs");
268 +               gpio_export(133, 1);
269 +               gpio_request(134, "sysfs");
270 +               gpio_export(134, 1);
271 +               gpio_request(135, "sysfs");
272 +               gpio_export(135, 1);
273 +               gpio_request(136, "sysfs");
274 +               gpio_export(136, 1);
275 +               gpio_request(137, "sysfs");
276 +               gpio_export(137, 1);
277 +               gpio_request(138, "sysfs");
278 +               gpio_export(138, 1);
279 +               gpio_request(139, "sysfs");
280 +               gpio_export(139, 1);
281 +               gpio_request(140, "sysfs");
282 +               gpio_export(140, 1);
283 +               gpio_request(141, "sysfs");
284 +               gpio_export(141, 1);
285 +               gpio_request(162, "sysfs");
286 +               gpio_export(162, 1);
287 +       }
289 +       if(!strcmp(expansionboard_name, "bbtoys-wifi"))
290 +       {
291 +               if (wl12xx_set_platform_data(&omap_beagle_wlan_data))
292 +                       pr_err("error setting wl12xx data\n");
293 +               printk(KERN_INFO "Beagle expansionboard: registering wl12xx bt platform device\n");
294 +               platform_device_register(&wl12xx_device);
295 +               printk(KERN_INFO "Beagle expansionboard: registering wl12xx wifi platform device\n");
296 +               platform_device_register(&omap_vwlan_device);
297 +       }
299         usb_musb_init(NULL);
300         usbhs_init(&usbhs_bdata);
301         omap_nand_flash_init(NAND_BUSWIDTH_16, omap3beagle_nand_partitions,
302 @@ -558,6 +802,8 @@ static void __init omap3_beagle_init(void)
303         beagle_opp_init();
304  }
305  
306 +early_param("buddy", expansionboard_setup);
308  MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
309         /* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */
310         .boot_params    = 0x80000100,
311 -- 
312 1.6.6.1