Browse files

Add wifi driver - just a straight copy from .29 for now.

NEEDS TO BE MERGED WITH board-zoom2-wifi.c

We don't compile in board-zoom2-wifi.c for now since some of it's
gpio asignments conflict with Encore charger and touchscreen
  • Loading branch information...
1 parent 27419ca commit e2a71aa21d9dba6ba0d5a40d6123394aa09bfa19 @verygreen committed Mar 12, 2011
View
8 arch/arm/mach-omap2/Kconfig
@@ -74,6 +74,7 @@ config MACH_ENCORE
bool "Barnes & Noble Encore (Nook Color)"
depends on ARCH_OMAP3
select OMAP_PACKAGE_CBP
+ select WLAN_POWER_EVT1
config MACH_OVERO
bool "Gumstix Overo board"
@@ -111,6 +112,13 @@ config TIWLAN_MMC_CONTROLLER
connected to. TI WLAN has SDIO host controller that will control
this MMC port.
+config WLAN_POWER_EVT1
+ bool "WLAN power support"
+ depends on MACH_ENCORE && TIWLAN_SDIO
+ default "y"
+ help
+ Has to be set for B&N Encore board.
+
config MACH_OMAP3517EVM
bool "OMAP3517/ AM3517 EVM board"
depends on ARCH_OMAP3
View
5 arch/arm/mach-omap2/Makefile
@@ -202,9 +202,12 @@ obj-$(CONFIG_MACH_OMAP4_PANDA) += board-omap4panda.o \
ifeq ($(CONFIG_ARCH_OMAP4),y)
obj-$(CONFIG_TIWLAN_SDIO) += board-4430sdp-wifi.o
endif
-ifeq ($(CONFIG_ARCH_OMAP3),y)
+ifeq ($(CONFIG_MACH_OMAP_ZOOM2),y)
obj-$(CONFIG_TIWLAN_SDIO) += board-zoom2-wifi.o
endif
+ifeq ($(CONFIG_MACH_ENCORE),y)
+obj-$(CONFIG_TIWLAN_SDIO) += board-boxer-wifi.o
+endif
obj-$(CONFIG_MACH_OMAP3517EVM) += board-am3517evm.o
View
164 arch/arm/mach-omap2/board-boxer-wifi.c
@@ -0,0 +1,164 @@
+/* linux/arch/arm/mach-omap2/board-boxer-wifi.c
+*/
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+#include <linux/mmc/host.h>
+#include <linux/mmc/sdio_ids.h>
+#include <linux/err.h>
+
+#include <asm/gpio.h>
+#include <asm/io.h>
+#include <linux/wifi_tiwlan.h>
+
+#ifdef CONFIG_WLAN_POWER_EVT1
+#include <linux/i2c/twl.h>
+
+#define PM_RECEIVER TWL4030_MODULE_PM_RECEIVER
+#define ENABLE_VAUX2_DEDICATED 0x05
+#define ENABLE_VAUX2_DEV_GRP 0x20
+#define ENABLE_VAUX3_DEDICATED 0x03
+#define ENABLE_VAUX3_DEV_GRP 0x20
+
+#include <plat/board-encore.h>
+
+#define t2_out(c, r, v) twl_i2c_write_u8(c, r, v)
+#endif
+
+static int boxer_wifi_cd = 0; /* WIFI virtual 'card detect' status */
+static void (*wifi_status_cb)(int card_present, void *dev_id);
+static void *wifi_status_cb_devid;
+
+static int wifi_v18io_power_enable_init(void)
+{
+ int return_value = 0;
+#ifdef CONFIG_WLAN_POWER_EVT1
+ printk("Enabling VAUX for wifi \n");
+ return_value = t2_out(PM_RECEIVER,ENABLE_VAUX2_DEDICATED,TWL4030_VAUX2_DEDICATED);
+ return_value |= t2_out(PM_RECEIVER,ENABLE_VAUX2_DEV_GRP,TWL4030_VAUX2_DEV_GRP);
+ if(0 != return_value)
+ printk("Enabling VAUX for wifi incomplete error: %d\n",return_value);
+#endif
+ return return_value;
+}
+
+int omap_wifi_status_register(void (*callback)(int card_present,
+ void *dev_id), void *dev_id)
+{
+ if (wifi_status_cb)
+ return -EAGAIN;
+ wifi_status_cb = callback;
+ wifi_status_cb_devid = dev_id;
+ return 0;
+}
+
+int omap_wifi_status(int irq)
+{
+ return boxer_wifi_cd;
+}
+
+int boxer_wifi_set_carddetect(int val)
+{
+ printk("%s: %d\n", __func__, val);
+ boxer_wifi_cd = val;
+ if (wifi_status_cb) {
+ wifi_status_cb(val, wifi_status_cb_devid);
+ } else
+ printk(KERN_WARNING "%s: Nobody to notify\n", __func__);
+ return 0;
+}
+#ifndef CONFIG_WIFI_CONTROL_FUNC
+EXPORT_SYMBOL(boxer_wifi_set_carddetect);
+#endif
+
+static int boxer_wifi_power_state;
+
+int boxer_wifi_power(int on)
+{
+ printk("%s: %d\n", __func__, on);
+ gpio_set_value(BOXER_WIFI_PMENA_GPIO, on);
+ boxer_wifi_power_state = on;
+ return 0;
+}
+#ifndef CONFIG_WIFI_CONTROL_FUNC
+EXPORT_SYMBOL(boxer_wifi_power);
+#endif
+
+static int boxer_wifi_reset_state;
+int boxer_wifi_reset(int on)
+{
+ printk("%s: %d\n", __func__, on);
+ boxer_wifi_reset_state = on;
+ return 0;
+}
+#ifndef CONFIG_WIFI_CONTROL_FUNC
+EXPORT_SYMBOL(boxer_wifi_reset);
+#endif
+
+struct wifi_platform_data boxer_wifi_control = {
+ .set_power = boxer_wifi_power,
+ .set_reset = boxer_wifi_reset,
+ .set_carddetect = boxer_wifi_set_carddetect,
+};
+
+#ifdef CONFIG_WIFI_CONTROL_FUNC
+static struct resource boxer_wifi_resources[] = {
+ [0] = {
+ .name = "device_wifi_irq",
+ .start = OMAP_GPIO_IRQ(BOXER_WIFI_IRQ_GPIO),
+ .end = OMAP_GPIO_IRQ(BOXER_WIFI_IRQ_GPIO),
+ .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
+ },
+};
+
+static struct platform_device boxer_wifi_device = {
+ .name = "device_wifi",
+ .id = 1,
+ .num_resources = ARRAY_SIZE(boxer_wifi_resources),
+ .resource = boxer_wifi_resources,
+ .dev = {
+ .platform_data = &boxer_wifi_control,
+ },
+};
+#endif
+
+static int __init boxer_wifi_init(void)
+{
+ int ret;
+
+ printk("%s: start\n", __func__);
+ ret = gpio_request(BOXER_WIFI_IRQ_GPIO, "wifi_irq");
+ if (ret < 0) {
+ printk(KERN_ERR "%s: can't reserve GPIO: %d\n", __func__,
+ BOXER_WIFI_IRQ_GPIO);
+ goto out;
+ }
+ ret = gpio_request(BOXER_WIFI_PMENA_GPIO, "wifi_pmena");
+ if (ret < 0) {
+ printk(KERN_ERR "%s: can't reserve GPIO: %d\n", __func__,
+ BOXER_WIFI_PMENA_GPIO);
+ gpio_free(BOXER_WIFI_IRQ_GPIO);
+ goto out;
+ }
+ ret = gpio_request(BOXER_WIFI_EN_POW, "wifi_en_pow");
+ if (ret < 0) {
+ printk(KERN_ERR "%s: can't reserve GPIO: %d\n", __func__,
+ BOXER_WIFI_EN_POW);
+ gpio_free(BOXER_WIFI_EN_POW);
+ goto out;
+ }
+ wifi_v18io_power_enable_init();
+ gpio_direction_input(BOXER_WIFI_IRQ_GPIO);
+ gpio_direction_output(BOXER_WIFI_PMENA_GPIO, 0);
+ gpio_direction_output(BOXER_WIFI_EN_POW, 1);
+
+#ifdef CONFIG_WIFI_CONTROL_FUNC
+ ret = platform_device_register(&boxer_wifi_device);
+#endif
+out:
+ return ret;
+}
+
+device_initcall(boxer_wifi_init);
View
4 arch/arm/plat-omap/include/plat/board-encore.h
@@ -55,6 +55,10 @@ extern unsigned get_last_off_on_transaction_id(struct device *dev);
#define MAX8903_GPIO_CHG_ILM 61
#endif
+#define BOXER_WIFI_PMENA_GPIO 22
+#define BOXER_WIFI_IRQ_GPIO 15
+#define BOXER_WIFI_EN_POW 16
+
#define BOARD_ENCORE_REV_EVT1A 0x1
#define BOARD_ENCORE_REV_EVT1B 0x2
#define BOARD_ENCORE_REV_EVT2 0x3

0 comments on commit e2a71aa

Please sign in to comment.