omap3-pandora-kernel2: update
[openpandora.oe.git] / recipes / linux / omap3-pandora-kernel / 0001-SDIO-patches-to-put-some-card-into-into-platform-dev.patch
1 From 5800973aa82858036239b232e16d63796ba0de95 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 1/4] 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 88bc884..6585a15
55 --- a/arch/arm/mach-omap2/board-omap3pandora.c
56 +++ b/arch/arm/mach-omap2/board-omap3pandora.c
57 @@ -36,6 +36,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 @@ -59,6 +61,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 @@ -489,6 +495,49 @@ 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 @@ -496,6 +545,7 @@ static struct platform_device *omap3pandora_devices[] __initdata = {
128         &omap3pandora_bl,
129         &omap3pandora_dss_device,
130         &pandora_leds_pwm,
131 +    &pandora_wifi,
132  };
133  
134  static void __init omap3pandora_init(void)
135 diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c
136 old mode 100644
137 new mode 100755
138 index 66d08fc..80d344e
139 --- a/arch/arm/mach-omap2/hsmmc.c
140 +++ b/arch/arm/mach-omap2/hsmmc.c
141 @@ -380,13 +380,48 @@ static int hsmmc3_set_power(struct device *dev, int slot, int power_on,
142         return 0;
143  }
144  
145 +/*
146 + * Hack: Hardcoded WL1251 embedded data for Pandora
147 + * - passed up via a dirty hack to the MMC platform data.
148 + */
149 +
150 +#include <linux/mmc/host.h>
151 +#include <linux/mmc/card.h>
152 +#include <linux/mmc/sdio_func.h>
153 +#include <linux/mmc/sdio_ids.h>
154 +
155 +static struct sdio_embedded_func wifi_func = {
156 +       .f_class        = SDIO_CLASS_WLAN,
157 +       .f_maxblksize   = 512,
158 +};
159 +
160 +static struct embedded_sdio_data pandora_wifi_emb_data = {
161 +       .cis    = {
162 +               .vendor         = 0x104c,
163 +               .device         = 0x9066,
164 +               .blksize        = 512,
165 +               .max_dtr        = 20000000,
166 +       },
167 +       .cccr   = {
168 +               .multi_block    = 0,
169 +               .low_speed      = 0,
170 +               .wide_bus       = 1,
171 +               .high_power     = 0,
172 +               .high_speed     = 0,
173 +       },
174 +       .funcs  = &wifi_func,
175 +       .num_funcs = 1,
176 +};
177 +
178 +
179  static struct omap_mmc_platform_data mmc3_data = {
180         .nr_slots                       = 1,
181         .dma_mask                       = 0xffffffff,
182 +       .embedded_sdio              = &pandora_wifi_emb_data,
183         .slots[0] = {
184                 .wire4                  = 1,
185                 .set_power              = hsmmc3_set_power,
186 -               .ocr_mask               = MMC_VDD_165_195 | MMC_VDD_20_21,
187 +               .ocr_mask               = MMC_VDD_28_29,
188                 .name                   = "third slot",
189         },
190  };
191 diff --git a/arch/arm/plat-omap/include/mach/mmc.h b/arch/arm/plat-omap/include/mach/mmc.h
192 old mode 100644
193 new mode 100755
194 index 2f20789..1a10c07
195 --- a/arch/arm/plat-omap/include/mach/mmc.h
196 +++ b/arch/arm/plat-omap/include/mach/mmc.h
197 @@ -33,6 +33,16 @@
198  
199  #define OMAP_MMC_MAX_SLOTS     2
200  
201 +#include <linux/mmc/card.h>
202 +#include <linux/mmc/sdio_func.h>
203 +
204 +struct embedded_sdio_data {
205 +        struct sdio_cis cis;
206 +        struct sdio_cccr cccr;
207 +        struct sdio_embedded_func *funcs;
208 +        int num_funcs;
209 +};
210 +
211  struct omap_mmc_platform_data {
212  
213         /* number of slots per controller */
214 @@ -56,6 +66,8 @@ struct omap_mmc_platform_data {
215  
216         u64 dma_mask;
217  
218 +       struct embedded_sdio_data *embedded_sdio;
219 +
220         struct omap_mmc_slot_data {
221  
222                 /*
223 diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
224 old mode 100644
225 new mode 100755
226 index c80c063..bc5c73b
227 --- a/drivers/mmc/host/omap_hsmmc.c
228 +++ b/drivers/mmc/host/omap_hsmmc.c
229 @@ -156,9 +156,9 @@ struct mmc_omap_host {
230  
231  
232  /*
233 - * Hack: hardcoded WL1251 embedded data
234 + * Hack: hardcoded WL1251 embedded data - Should be passed in platform data,
235   */
236 -#include <linux/mmc/card.h>
237 +/*#include <linux/mmc/card.h>
238  #include <linux/mmc/sdio_func.h>
239  #include <linux/mmc/sdio_ids.h>
240  
241 @@ -166,7 +166,6 @@ static struct sdio_cis wifi_cis = {
242         .vendor         = 0x104c,
243         .device         = 0x9066,
244         .blksize        = 512,
245 -       /*.max_dtr      = 24000000,  Max of chip - no worky on Trout */
246         .max_dtr        = 20000000,
247  };
248  
249 @@ -181,7 +180,8 @@ static struct sdio_cccr wifi_cccr = {
250  static struct sdio_embedded_func wifi_func = {
251         .f_class        = SDIO_CLASS_WLAN,
252         .f_maxblksize   = 512,
253 -};
254 +};*/
255 +
256  
257  /*
258   * A hack to have fake detect events on MMC3
259 @@ -189,11 +189,11 @@ static struct sdio_embedded_func wifi_func = {
260   */
261  static struct mmc_omap_host *mmc3_host;
262  
263 -void omap_mmc_fake_detect_mmc3(int is_in)
264 +int omap_mmc_fake_detect_mmc3(int is_in)
265  {
266         if (mmc3_host) {
267 -               mmc_set_embedded_sdio_data(mmc3_host->mmc, &wifi_cis,
268 -                                       &wifi_cccr, &wifi_func, 1);
269 +//             mmc_set_embedded_sdio_data(mmc3_host->mmc, &wifi_cis,
270 +//                                     &wifi_cccr, &wifi_func, 1);
271  
272                 printk(KERN_INFO "Sending %s event for MMC3...\n",
273                         is_in ? "insert" : "remove");
274 @@ -202,6 +202,7 @@ void omap_mmc_fake_detect_mmc3(int is_in)
275         } else
276                 printk(KERN_ERR "Can't scan MMC3, host not registered "
277                                 "with driver.\n");
278 +       return 0;
279  }
280  
281  EXPORT_SYMBOL(omap_mmc_fake_detect_mmc3);
282 @@ -957,6 +958,15 @@ static int __init omap_mmc_probe(struct platform_device *pdev)
283  
284         sema_init(&host->sem, 1);
285  
286 +#ifdef CONFIG_MMC_EMBEDDED_SDIO
287 +       if (pdata->embedded_sdio)
288 +               mmc_set_embedded_sdio_data(mmc,
289 +                                          &pdata->embedded_sdio->cis,
290 +                                          &pdata->embedded_sdio->cccr,
291 +                                          pdata->embedded_sdio->funcs,
292 +                                          pdata->embedded_sdio->num_funcs);
293 +#endif
294 +
295         host->iclk = clk_get(&pdev->dev, "mmchs_ick");
296         if (IS_ERR(host->iclk)) {
297                 ret = PTR_ERR(host->iclk);
298 diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
299 old mode 100644
300 new mode 100755
301 index 6016dcb..0a47c82
302 --- a/include/linux/mmc/host.h
303 +++ b/include/linux/mmc/host.h
304 @@ -160,12 +160,12 @@ struct mmc_host {
305         struct dentry           *debugfs_root;
306  
307  #ifdef CONFIG_MMC_EMBEDDED_SDIO
308 -       struct {
309 -               struct sdio_cis                 *cis;
310 -               struct sdio_cccr                *cccr;
311 -               struct sdio_embedded_func       *funcs;
312 -               int                             num_funcs;
313 -       } embedded_sdio_data;
314 +       struct {
315 +               struct sdio_cis                 *cis;
316 +               struct sdio_cccr                *cccr;
317 +               struct sdio_embedded_func       *funcs;
318 +               int                             num_funcs;
319 +       } embedded_sdio_data;
320  #endif
321  
322         unsigned long           private[0] ____cacheline_aligned;
323 diff --git a/include/linux/wifi_tiwlan.h b/include/linux/wifi_tiwlan.h
324 new file mode 100755
325 index 0000000..f4e0e3c
326 --- /dev/null
327 +++ b/include/linux/wifi_tiwlan.h
328 @@ -0,0 +1,32 @@
329 +/* include/linux/wifi_tiwlan.h\r
330 + *\r
331 + * Copyright (C) 2008 Google, Inc.\r
332 + *\r
333 + * This software is licensed under the terms of the GNU General Public\r
334 + * License version 2, as published by the Free Software Foundation, and\r
335 + * may be copied, distributed, and modified under those terms.\r
336 + *\r
337 + * This program is distributed in the hope that it will be useful,\r
338 + * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
339 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
340 + * GNU General Public License for more details.\r
341 + *\r
342 + */\r
343 +#ifndef _LINUX_WIFI_TIWLAN_H_\r
344 +#define _LINUX_WIFI_TIWLAN_H_\r
345 +\r
346 +#define WMPA_NUMBER_OF_SECTIONS        3\r
347 +#define WMPA_NUMBER_OF_BUFFERS 160\r
348 +#define WMPA_SECTION_HEADER    24\r
349 +#define WMPA_SECTION_SIZE_0    (WMPA_NUMBER_OF_BUFFERS * 64)\r
350 +#define WMPA_SECTION_SIZE_1    (WMPA_NUMBER_OF_BUFFERS * 256)\r
351 +#define WMPA_SECTION_SIZE_2    (WMPA_NUMBER_OF_BUFFERS * 2048)\r
352 +\r
353 +struct wifi_platform_data {\r
354 +        int (*set_power)(int val);\r
355 +        int (*set_reset)(int val);\r
356 +        int (*set_carddetect)(int val);\r
357 +               void *(*mem_prealloc)(int section, unsigned long size);\r
358 +};\r
359 +\r
360 +#endif\r
361 -- 
362 1.6.3.1
363