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
diff --git a/recipes/linux/omap3-pandora-kernel/0001-SDIO-patches-to-put-some-card-into-into-platform-dev.patch b/recipes/linux/omap3-pandora-kernel/0001-SDIO-patches-to-put-some-card-into-into-platform-dev.patch
new file mode 100755 (executable)
index 0000000..af2c689
--- /dev/null
@@ -0,0 +1,362 @@
+From 6531593a263a254edcf1effbf132ead1aa5e4654 Mon Sep 17 00:00:00 2001
+From: David-John Willis <John.Willis@Distant-earth.com>
+Date: Mon, 22 Jun 2009 20:49:31 +0100
+Subject: [PATCH] SDIO patches to put some card into into platform devices (hack) to match WL1251 driver.
+
+---
+ arch/arm/include/asm/mach/mmc.h          |   10 ++++++
+ arch/arm/mach-omap2/board-omap3pandora.c |   50 ++++++++++++++++++++++++++++++
+ arch/arm/mach-omap2/hsmmc.c              |   37 +++++++++++++++++++++-
+ arch/arm/plat-omap/include/mach/mmc.h    |   12 +++++++
+ drivers/mmc/host/omap_hsmmc.c            |   24 ++++++++++----
+ include/linux/mmc/host.h                 |   12 +++---
+ include/linux/wifi_tiwlan.h              |   32 +++++++++++++++++++
+ 7 files changed, 163 insertions(+), 14 deletions(-)
+ mode change 100644 => 100755 arch/arm/include/asm/mach/mmc.h
+ mode change 100644 => 100755 arch/arm/mach-omap2/board-omap3pandora.c
+ mode change 100644 => 100755 arch/arm/mach-omap2/hsmmc.c
+ mode change 100644 => 100755 arch/arm/plat-omap/include/mach/mmc.h
+ mode change 100644 => 100755 drivers/mmc/host/omap_hsmmc.c
+ mode change 100644 => 100755 include/linux/mmc/host.h
+ create mode 100755 include/linux/wifi_tiwlan.h
+
+diff --git a/arch/arm/include/asm/mach/mmc.h b/arch/arm/include/asm/mach/mmc.h
+old mode 100644
+new mode 100755
+index 4da332b..4df7955
+--- a/arch/arm/include/asm/mach/mmc.h
++++ b/arch/arm/include/asm/mach/mmc.h
+@@ -5,11 +5,21 @@
+ #define ASMARM_MACH_MMC_H
+ #include <linux/mmc/host.h>
++#include <linux/mmc/card.h>
++#include <linux/mmc/sdio_func.h>
++
++struct embedded_sdio_data {
++        struct sdio_cis cis;
++        struct sdio_cccr cccr;
++        struct sdio_embedded_func *funcs;
++        int num_funcs;
++};
+ struct mmc_platform_data {
+       unsigned int ocr_mask;                  /* available voltages */
+       u32 (*translate_vdd)(struct device *, unsigned int);
+       unsigned int (*status)(struct device *);
++      struct embedded_sdio_data *embedded_sdio;
+ };
+ #endif
+diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
+old mode 100644
+new mode 100755
+index 6e4b207..031ad2d
+--- a/arch/arm/mach-omap2/board-omap3pandora.c
++++ b/arch/arm/mach-omap2/board-omap3pandora.c
+@@ -35,6 +35,8 @@
+ #include <linux/mtd/nand.h>
+ #include <linux/mtd/partitions.h>
++#include <linux/wifi_tiwlan.h>
++
+ #include <asm/mach-types.h>
+ #include <asm/mach/arch.h>
+ #include <asm/mach/flash.h>
+@@ -58,6 +60,10 @@
+ #define GPMC_CS0_BASE  0x60
+ #define GPMC_CS_SIZE   0x30
++#define PANDORA_WIFI_GPIO 23
++
++extern int omap_mmc_fake_detect_mmc3(int is_in);
++
+ static struct mtd_partition omap3pandora_nand_partitions[] = {
+       {
+               .name           = "xloader",
+@@ -446,12 +452,56 @@ static struct platform_device bt_device = {
+       },
+ };
++static int pandora_wifi_power_state;
++
++int pandora_wifi_power(int on)
++{
++      printk("%s: %d\n", __func__, on);
++
++      if (on) {
++              gpio_set_value(PANDORA_WIFI_GPIO, 1);
++      mdelay(50);
++      } else {
++          gpio_set_value(PANDORA_WIFI_GPIO, 0);
++      mdelay(50);
++      }
++      pandora_wifi_power_state = on;
++      return 0;
++}
++
++static int pandora_wifi_reset_state;
++
++int pandora_wifi_reset(int on)
++{
++      printk("%s: %d\n", __func__, on);
++      pandora_wifi_reset_state = on;
++      return 0;
++}
++
++struct wifi_platform_data pandora_wifi_control = {
++      .set_power              = pandora_wifi_power,
++      .set_reset              = pandora_wifi_reset,
++      .set_carddetect         = omap_mmc_fake_detect_mmc3,
++      .mem_prealloc           = NULL,
++};
++
++static struct platform_device pandora_wifi = {
++       .name           = "msm_wifi", /* Hack to work with hardcode in driver */
++       .id             = 1,
++       .num_resources  = 0,
++       .resource       = NULL,
++       .dev            = {
++       .platform_data = &pandora_wifi_control,
++       },
++};
++
+ static struct platform_device *omap3pandora_devices[] __initdata = {
+       &omap3pandora_lcd_device,
+       &omap3pandora_leds_gpio,
+       &bt_device,
+       &omap3pandora_bl,
+       &omap3pandora_dss_device,
++    &pandora_wifi,
+ };
+ static void __init omap3pandora_init(void)
+diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c
+old mode 100644
+new mode 100755
+index 66d08fc..80d344e
+--- a/arch/arm/mach-omap2/hsmmc.c
++++ b/arch/arm/mach-omap2/hsmmc.c
+@@ -380,13 +380,48 @@ static int hsmmc3_set_power(struct device *dev, int slot, int power_on,
+       return 0;
+ }
++/*
++ * Hack: Hardcoded WL1251 embedded data for Pandora
++ * - passed up via a dirty hack to the MMC platform data.
++ */
++
++#include <linux/mmc/host.h>
++#include <linux/mmc/card.h>
++#include <linux/mmc/sdio_func.h>
++#include <linux/mmc/sdio_ids.h>
++
++static struct sdio_embedded_func wifi_func = {
++      .f_class        = SDIO_CLASS_WLAN,
++      .f_maxblksize   = 512,
++};
++
++static struct embedded_sdio_data pandora_wifi_emb_data = {
++      .cis    = {
++              .vendor         = 0x104c,
++              .device         = 0x9066,
++              .blksize        = 512,
++              .max_dtr        = 20000000,
++      },
++      .cccr   = {
++              .multi_block    = 0,
++              .low_speed      = 0,
++              .wide_bus       = 1,
++              .high_power     = 0,
++              .high_speed     = 0,
++      },
++      .funcs  = &wifi_func,
++      .num_funcs = 1,
++};
++
++
+ static struct omap_mmc_platform_data mmc3_data = {
+       .nr_slots                       = 1,
+       .dma_mask                       = 0xffffffff,
++      .embedded_sdio              = &pandora_wifi_emb_data,
+       .slots[0] = {
+               .wire4                  = 1,
+               .set_power              = hsmmc3_set_power,
+-              .ocr_mask               = MMC_VDD_165_195 | MMC_VDD_20_21,
++              .ocr_mask               = MMC_VDD_28_29,
+               .name                   = "third slot",
+       },
+ };
+diff --git a/arch/arm/plat-omap/include/mach/mmc.h b/arch/arm/plat-omap/include/mach/mmc.h
+old mode 100644
+new mode 100755
+index 2f20789..1a10c07
+--- a/arch/arm/plat-omap/include/mach/mmc.h
++++ b/arch/arm/plat-omap/include/mach/mmc.h
+@@ -33,6 +33,16 @@
+ #define OMAP_MMC_MAX_SLOTS    2
++#include <linux/mmc/card.h>
++#include <linux/mmc/sdio_func.h>
++
++struct embedded_sdio_data {
++        struct sdio_cis cis;
++        struct sdio_cccr cccr;
++        struct sdio_embedded_func *funcs;
++        int num_funcs;
++};
++
+ struct omap_mmc_platform_data {
+       /* number of slots per controller */
+@@ -56,6 +66,8 @@ struct omap_mmc_platform_data {
+       u64 dma_mask;
++      struct embedded_sdio_data *embedded_sdio;
++
+       struct omap_mmc_slot_data {
+               /*
+diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
+old mode 100644
+new mode 100755
+index c80c063..bc5c73b
+--- a/drivers/mmc/host/omap_hsmmc.c
++++ b/drivers/mmc/host/omap_hsmmc.c
+@@ -156,9 +156,9 @@ struct mmc_omap_host {
+ /*
+- * Hack: hardcoded WL1251 embedded data
++ * Hack: hardcoded WL1251 embedded data - Should be passed in platform data,
+  */
+-#include <linux/mmc/card.h>
++/*#include <linux/mmc/card.h>
+ #include <linux/mmc/sdio_func.h>
+ #include <linux/mmc/sdio_ids.h>
+@@ -166,7 +166,6 @@ static struct sdio_cis wifi_cis = {
+       .vendor         = 0x104c,
+       .device         = 0x9066,
+       .blksize        = 512,
+-      /*.max_dtr      = 24000000,  Max of chip - no worky on Trout */
+       .max_dtr        = 20000000,
+ };
+@@ -181,7 +180,8 @@ static struct sdio_cccr wifi_cccr = {
+ static struct sdio_embedded_func wifi_func = {
+       .f_class        = SDIO_CLASS_WLAN,
+       .f_maxblksize   = 512,
+-};
++};*/
++
+ /*
+  * A hack to have fake detect events on MMC3
+@@ -189,11 +189,11 @@ static struct sdio_embedded_func wifi_func = {
+  */
+ static struct mmc_omap_host *mmc3_host;
+-void omap_mmc_fake_detect_mmc3(int is_in)
++int omap_mmc_fake_detect_mmc3(int is_in)
+ {
+       if (mmc3_host) {
+-              mmc_set_embedded_sdio_data(mmc3_host->mmc, &wifi_cis,
+-                                      &wifi_cccr, &wifi_func, 1);
++//            mmc_set_embedded_sdio_data(mmc3_host->mmc, &wifi_cis,
++//                                    &wifi_cccr, &wifi_func, 1);
+               printk(KERN_INFO "Sending %s event for MMC3...\n",
+                       is_in ? "insert" : "remove");
+@@ -202,6 +202,7 @@ void omap_mmc_fake_detect_mmc3(int is_in)
+       } else
+               printk(KERN_ERR "Can't scan MMC3, host not registered "
+                               "with driver.\n");
++      return 0;
+ }
+ EXPORT_SYMBOL(omap_mmc_fake_detect_mmc3);
+@@ -957,6 +958,15 @@ static int __init omap_mmc_probe(struct platform_device *pdev)
+       sema_init(&host->sem, 1);
++#ifdef CONFIG_MMC_EMBEDDED_SDIO
++      if (pdata->embedded_sdio)
++              mmc_set_embedded_sdio_data(mmc,
++                                         &pdata->embedded_sdio->cis,
++                                         &pdata->embedded_sdio->cccr,
++                                         pdata->embedded_sdio->funcs,
++                                         pdata->embedded_sdio->num_funcs);
++#endif
++
+       host->iclk = clk_get(&pdev->dev, "mmchs_ick");
+       if (IS_ERR(host->iclk)) {
+               ret = PTR_ERR(host->iclk);
+diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
+old mode 100644
+new mode 100755
+index 6016dcb..0a47c82
+--- a/include/linux/mmc/host.h
++++ b/include/linux/mmc/host.h
+@@ -160,12 +160,12 @@ struct mmc_host {
+       struct dentry           *debugfs_root;
+ #ifdef CONFIG_MMC_EMBEDDED_SDIO
+-      struct {
+-              struct sdio_cis                 *cis;
+-              struct sdio_cccr                *cccr;
+-              struct sdio_embedded_func       *funcs;
+-              int                             num_funcs;
+-      } embedded_sdio_data;
++       struct {
++               struct sdio_cis                 *cis;
++               struct sdio_cccr                *cccr;
++               struct sdio_embedded_func       *funcs;
++               int                             num_funcs;
++       } embedded_sdio_data;
+ #endif
+       unsigned long           private[0] ____cacheline_aligned;
+diff --git a/include/linux/wifi_tiwlan.h b/include/linux/wifi_tiwlan.h
+new file mode 100755
+index 0000000..f4e0e3c
+--- /dev/null
++++ b/include/linux/wifi_tiwlan.h
+@@ -0,0 +1,32 @@
++/* include/linux/wifi_tiwlan.h\r
++ *\r
++ * Copyright (C) 2008 Google, Inc.\r
++ *\r
++ * This software is licensed under the terms of the GNU General Public\r
++ * License version 2, as published by the Free Software Foundation, and\r
++ * may be copied, distributed, and modified under those terms.\r
++ *\r
++ * This program is distributed in the hope that it will be useful,\r
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
++ * GNU General Public License for more details.\r
++ *\r
++ */\r
++#ifndef _LINUX_WIFI_TIWLAN_H_\r
++#define _LINUX_WIFI_TIWLAN_H_\r
++\r
++#define WMPA_NUMBER_OF_SECTIONS       3\r
++#define WMPA_NUMBER_OF_BUFFERS        160\r
++#define WMPA_SECTION_HEADER   24\r
++#define WMPA_SECTION_SIZE_0   (WMPA_NUMBER_OF_BUFFERS * 64)\r
++#define WMPA_SECTION_SIZE_1   (WMPA_NUMBER_OF_BUFFERS * 256)\r
++#define WMPA_SECTION_SIZE_2   (WMPA_NUMBER_OF_BUFFERS * 2048)\r
++\r
++struct wifi_platform_data {\r
++        int (*set_power)(int val);\r
++        int (*set_reset)(int val);\r
++        int (*set_carddetect)(int val);\r
++              void *(*mem_prealloc)(int section, unsigned long size);\r
++};\r
++\r
++#endif\r
+-- 
+1.6.3.1
+