Update tree with local changes. Disable WiLink4 drivers in the image and enable the...
[openpandora.oe.git] / recipes / linux / omap3-pandora-kernel / 0001-SDIO-patches-to-put-some-card-into-into-platform-dev.patch
1 From 6531593a263a254edcf1effbf132ead1aa5e4654 Mon Sep 17 00:00:00 2001
2 From: David-John Willis <John.Willis@Distant-earth.com>
3 Date: Mon, 22 Jun 2009 20:49:31 +0100
4 Subject: [PATCH] SDIO patches to put some card into into platform devices (hack) to match WL1251 driver.
5
6 ---
7  arch/arm/include/asm/mach/mmc.h          |   10 ++++++
8  arch/arm/mach-omap2/board-omap3pandora.c |   50 ++++++++++++++++++++++++++++++
9  arch/arm/mach-omap2/hsmmc.c              |   37 +++++++++++++++++++++-
10  arch/arm/plat-omap/include/mach/mmc.h    |   12 +++++++
11  drivers/mmc/host/omap_hsmmc.c            |   24 ++++++++++----
12  include/linux/mmc/host.h                 |   12 +++---
13  include/linux/wifi_tiwlan.h              |   32 +++++++++++++++++++
14  7 files changed, 163 insertions(+), 14 deletions(-)
15  mode change 100644 => 100755 arch/arm/include/asm/mach/mmc.h
16  mode change 100644 => 100755 arch/arm/mach-omap2/board-omap3pandora.c
17  mode change 100644 => 100755 arch/arm/mach-omap2/hsmmc.c
18  mode change 100644 => 100755 arch/arm/plat-omap/include/mach/mmc.h
19  mode change 100644 => 100755 drivers/mmc/host/omap_hsmmc.c
20  mode change 100644 => 100755 include/linux/mmc/host.h
21  create mode 100755 include/linux/wifi_tiwlan.h
22
23 diff --git a/arch/arm/include/asm/mach/mmc.h b/arch/arm/include/asm/mach/mmc.h
24 old mode 100644
25 new mode 100755
26 index 4da332b..4df7955
27 --- a/arch/arm/include/asm/mach/mmc.h
28 +++ b/arch/arm/include/asm/mach/mmc.h
29 @@ -5,11 +5,21 @@
30  #define ASMARM_MACH_MMC_H
31  
32  #include <linux/mmc/host.h>
33 +#include <linux/mmc/card.h>
34 +#include <linux/mmc/sdio_func.h>
35 +
36 +struct embedded_sdio_data {
37 +        struct sdio_cis cis;
38 +        struct sdio_cccr cccr;
39 +        struct sdio_embedded_func *funcs;
40 +        int num_funcs;
41 +};
42  
43  struct mmc_platform_data {
44         unsigned int ocr_mask;                  /* available voltages */
45         u32 (*translate_vdd)(struct device *, unsigned int);
46         unsigned int (*status)(struct device *);
47 +       struct embedded_sdio_data *embedded_sdio;
48  };
49  
50  #endif
51 diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
52 old mode 100644
53 new mode 100755
54 index 6e4b207..031ad2d
55 --- a/arch/arm/mach-omap2/board-omap3pandora.c
56 +++ b/arch/arm/mach-omap2/board-omap3pandora.c
57 @@ -35,6 +35,8 @@
58  #include <linux/mtd/nand.h>
59  #include <linux/mtd/partitions.h>
60  
61 +#include <linux/wifi_tiwlan.h>
62 +
63  #include <asm/mach-types.h>
64  #include <asm/mach/arch.h>
65  #include <asm/mach/flash.h>
66 @@ -58,6 +60,10 @@
67  #define GPMC_CS0_BASE  0x60
68  #define GPMC_CS_SIZE   0x30
69  
70 +#define PANDORA_WIFI_GPIO 23
71 +
72 +extern int omap_mmc_fake_detect_mmc3(int is_in);
73 +
74  static struct mtd_partition omap3pandora_nand_partitions[] = {
75         {
76                 .name           = "xloader",
77 @@ -446,12 +452,56 @@ static struct platform_device bt_device = {
78         },
79  };
80  
81 +static int pandora_wifi_power_state;
82 +
83 +int pandora_wifi_power(int on)
84 +{
85 +       printk("%s: %d\n", __func__, on);
86 +
87 +       if (on) {
88 +               gpio_set_value(PANDORA_WIFI_GPIO, 1);
89 +       mdelay(50);
90 +       } else {
91 +           gpio_set_value(PANDORA_WIFI_GPIO, 0);
92 +       mdelay(50);
93 +       }
94 +       pandora_wifi_power_state = on;
95 +       return 0;
96 +}
97 +
98 +static int pandora_wifi_reset_state;
99 +
100 +int pandora_wifi_reset(int on)
101 +{
102 +       printk("%s: %d\n", __func__, on);
103 +       pandora_wifi_reset_state = on;
104 +       return 0;
105 +}
106 +
107 +struct wifi_platform_data pandora_wifi_control = {
108 +       .set_power              = pandora_wifi_power,
109 +       .set_reset              = pandora_wifi_reset,
110 +       .set_carddetect         = omap_mmc_fake_detect_mmc3,
111 +       .mem_prealloc           = NULL,
112 +};
113 +
114 +static struct platform_device pandora_wifi = {
115 +       .name           = "msm_wifi", /* Hack to work with hardcode in driver */
116 +       .id             = 1,
117 +       .num_resources  = 0,
118 +       .resource       = NULL,
119 +       .dev            = {
120 +       .platform_data = &pandora_wifi_control,
121 +       },
122 +};
123 +
124  static struct platform_device *omap3pandora_devices[] __initdata = {
125         &omap3pandora_lcd_device,
126         &omap3pandora_leds_gpio,
127         &bt_device,
128         &omap3pandora_bl,
129         &omap3pandora_dss_device,
130 +    &pandora_wifi,
131  };
132  
133  static void __init omap3pandora_init(void)
134 diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c
135 old mode 100644
136 new mode 100755
137 index 66d08fc..80d344e
138 --- a/arch/arm/mach-omap2/hsmmc.c
139 +++ b/arch/arm/mach-omap2/hsmmc.c
140 @@ -380,13 +380,48 @@ static int hsmmc3_set_power(struct device *dev, int slot, int power_on,
141         return 0;
142  }
143  
144 +/*
145 + * Hack: Hardcoded WL1251 embedded data for Pandora
146 + * - passed up via a dirty hack to the MMC platform data.
147 + */
148 +
149 +#include <linux/mmc/host.h>
150 +#include <linux/mmc/card.h>
151 +#include <linux/mmc/sdio_func.h>
152 +#include <linux/mmc/sdio_ids.h>
153 +
154 +static struct sdio_embedded_func wifi_func = {
155 +       .f_class        = SDIO_CLASS_WLAN,
156 +       .f_maxblksize   = 512,
157 +};
158 +
159 +static struct embedded_sdio_data pandora_wifi_emb_data = {
160 +       .cis    = {
161 +               .vendor         = 0x104c,
162 +               .device         = 0x9066,
163 +               .blksize        = 512,
164 +               .max_dtr        = 20000000,
165 +       },
166 +       .cccr   = {
167 +               .multi_block    = 0,
168 +               .low_speed      = 0,
169 +               .wide_bus       = 1,
170 +               .high_power     = 0,
171 +               .high_speed     = 0,
172 +       },
173 +       .funcs  = &wifi_func,
174 +       .num_funcs = 1,
175 +};
176 +
177 +
178  static struct omap_mmc_platform_data mmc3_data = {
179         .nr_slots                       = 1,
180         .dma_mask                       = 0xffffffff,
181 +       .embedded_sdio              = &pandora_wifi_emb_data,
182         .slots[0] = {
183                 .wire4                  = 1,
184                 .set_power              = hsmmc3_set_power,
185 -               .ocr_mask               = MMC_VDD_165_195 | MMC_VDD_20_21,
186 +               .ocr_mask               = MMC_VDD_28_29,
187                 .name                   = "third slot",
188         },
189  };
190 diff --git a/arch/arm/plat-omap/include/mach/mmc.h b/arch/arm/plat-omap/include/mach/mmc.h
191 old mode 100644
192 new mode 100755
193 index 2f20789..1a10c07
194 --- a/arch/arm/plat-omap/include/mach/mmc.h
195 +++ b/arch/arm/plat-omap/include/mach/mmc.h
196 @@ -33,6 +33,16 @@
197  
198  #define OMAP_MMC_MAX_SLOTS     2
199  
200 +#include <linux/mmc/card.h>
201 +#include <linux/mmc/sdio_func.h>
202 +
203 +struct embedded_sdio_data {
204 +        struct sdio_cis cis;
205 +        struct sdio_cccr cccr;
206 +        struct sdio_embedded_func *funcs;
207 +        int num_funcs;
208 +};
209 +
210  struct omap_mmc_platform_data {
211  
212         /* number of slots per controller */
213 @@ -56,6 +66,8 @@ struct omap_mmc_platform_data {
214  
215         u64 dma_mask;
216  
217 +       struct embedded_sdio_data *embedded_sdio;
218 +
219         struct omap_mmc_slot_data {
220  
221                 /*
222 diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
223 old mode 100644
224 new mode 100755
225 index c80c063..bc5c73b
226 --- a/drivers/mmc/host/omap_hsmmc.c
227 +++ b/drivers/mmc/host/omap_hsmmc.c
228 @@ -156,9 +156,9 @@ struct mmc_omap_host {
229  
230  
231  /*
232 - * Hack: hardcoded WL1251 embedded data
233 + * Hack: hardcoded WL1251 embedded data - Should be passed in platform data,
234   */
235 -#include <linux/mmc/card.h>
236 +/*#include <linux/mmc/card.h>
237  #include <linux/mmc/sdio_func.h>
238  #include <linux/mmc/sdio_ids.h>
239  
240 @@ -166,7 +166,6 @@ static struct sdio_cis wifi_cis = {
241         .vendor         = 0x104c,
242         .device         = 0x9066,
243         .blksize        = 512,
244 -       /*.max_dtr      = 24000000,  Max of chip - no worky on Trout */
245         .max_dtr        = 20000000,
246  };
247  
248 @@ -181,7 +180,8 @@ static struct sdio_cccr wifi_cccr = {
249  static struct sdio_embedded_func wifi_func = {
250         .f_class        = SDIO_CLASS_WLAN,
251         .f_maxblksize   = 512,
252 -};
253 +};*/
254 +
255  
256  /*
257   * A hack to have fake detect events on MMC3
258 @@ -189,11 +189,11 @@ static struct sdio_embedded_func wifi_func = {
259   */
260  static struct mmc_omap_host *mmc3_host;
261  
262 -void omap_mmc_fake_detect_mmc3(int is_in)
263 +int omap_mmc_fake_detect_mmc3(int is_in)
264  {
265         if (mmc3_host) {
266 -               mmc_set_embedded_sdio_data(mmc3_host->mmc, &wifi_cis,
267 -                                       &wifi_cccr, &wifi_func, 1);
268 +//             mmc_set_embedded_sdio_data(mmc3_host->mmc, &wifi_cis,
269 +//                                     &wifi_cccr, &wifi_func, 1);
270  
271                 printk(KERN_INFO "Sending %s event for MMC3...\n",
272                         is_in ? "insert" : "remove");
273 @@ -202,6 +202,7 @@ void omap_mmc_fake_detect_mmc3(int is_in)
274         } else
275                 printk(KERN_ERR "Can't scan MMC3, host not registered "
276                                 "with driver.\n");
277 +       return 0;
278  }
279  
280  EXPORT_SYMBOL(omap_mmc_fake_detect_mmc3);
281 @@ -957,6 +958,15 @@ static int __init omap_mmc_probe(struct platform_device *pdev)
282  
283         sema_init(&host->sem, 1);
284  
285 +#ifdef CONFIG_MMC_EMBEDDED_SDIO
286 +       if (pdata->embedded_sdio)
287 +               mmc_set_embedded_sdio_data(mmc,
288 +                                          &pdata->embedded_sdio->cis,
289 +                                          &pdata->embedded_sdio->cccr,
290 +                                          pdata->embedded_sdio->funcs,
291 +                                          pdata->embedded_sdio->num_funcs);
292 +#endif
293 +
294         host->iclk = clk_get(&pdev->dev, "mmchs_ick");
295         if (IS_ERR(host->iclk)) {
296                 ret = PTR_ERR(host->iclk);
297 diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
298 old mode 100644
299 new mode 100755
300 index 6016dcb..0a47c82
301 --- a/include/linux/mmc/host.h
302 +++ b/include/linux/mmc/host.h
303 @@ -160,12 +160,12 @@ struct mmc_host {
304         struct dentry           *debugfs_root;
305  
306  #ifdef CONFIG_MMC_EMBEDDED_SDIO
307 -       struct {
308 -               struct sdio_cis                 *cis;
309 -               struct sdio_cccr                *cccr;
310 -               struct sdio_embedded_func       *funcs;
311 -               int                             num_funcs;
312 -       } embedded_sdio_data;
313 +       struct {
314 +               struct sdio_cis                 *cis;
315 +               struct sdio_cccr                *cccr;
316 +               struct sdio_embedded_func       *funcs;
317 +               int                             num_funcs;
318 +       } embedded_sdio_data;
319  #endif
320  
321         unsigned long           private[0] ____cacheline_aligned;
322 diff --git a/include/linux/wifi_tiwlan.h b/include/linux/wifi_tiwlan.h
323 new file mode 100755
324 index 0000000..f4e0e3c
325 --- /dev/null
326 +++ b/include/linux/wifi_tiwlan.h
327 @@ -0,0 +1,32 @@
328 +/* include/linux/wifi_tiwlan.h\r
329 + *\r
330 + * Copyright (C) 2008 Google, Inc.\r
331 + *\r
332 + * This software is licensed under the terms of the GNU General Public\r
333 + * License version 2, as published by the Free Software Foundation, and\r
334 + * may be copied, distributed, and modified under those terms.\r
335 + *\r
336 + * This program is distributed in the hope that it will be useful,\r
337 + * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
338 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
339 + * GNU General Public License for more details.\r
340 + *\r
341 + */\r
342 +#ifndef _LINUX_WIFI_TIWLAN_H_\r
343 +#define _LINUX_WIFI_TIWLAN_H_\r
344 +\r
345 +#define WMPA_NUMBER_OF_SECTIONS        3\r
346 +#define WMPA_NUMBER_OF_BUFFERS 160\r
347 +#define WMPA_SECTION_HEADER    24\r
348 +#define WMPA_SECTION_SIZE_0    (WMPA_NUMBER_OF_BUFFERS * 64)\r
349 +#define WMPA_SECTION_SIZE_1    (WMPA_NUMBER_OF_BUFFERS * 256)\r
350 +#define WMPA_SECTION_SIZE_2    (WMPA_NUMBER_OF_BUFFERS * 2048)\r
351 +\r
352 +struct wifi_platform_data {\r
353 +        int (*set_power)(int val);\r
354 +        int (*set_reset)(int val);\r
355 +        int (*set_carddetect)(int val);\r
356 +               void *(*mem_prealloc)(int section, unsigned long size);\r
357 +};\r
358 +\r
359 +#endif\r
360 -- 
361 1.6.3.1
362