add bt rfkill support for the raho board platform
authorlbt <lbt@rock-chips.com>
Fri, 3 Sep 2010 13:01:46 +0000 (21:01 +0800)
committerlbt <lbt@rock-chips.com>
Fri, 3 Sep 2010 13:01:46 +0000 (21:01 +0800)
arch/arm/configs/rk2818_raho_defconfig
arch/arm/mach-rk2818/Makefile
arch/arm/mach-rk2818/board-raho-rfkill.c [new file with mode: 0755]
arch/arm/mach-rk2818/board-raho.c

index f06b14f001f5e36533e6482df8c204c86d6c8d40..9cddd7853af5469a938c49e0514e85f7ab7e0607 100755 (executable)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.32.9
-# Sat Aug 21 10:51:54 2010
+# Fri Sep  3 20:53:52 2010
 #
 CONFIG_ARM=y
 CONFIG_SYS_SUPPORTS_APM_EMULATION=y
@@ -206,6 +206,7 @@ CONFIG_MACH_RAHO=y
 CONFIG_RK28_GPIO_IRQ=16
 CONFIG_RK28_ADC=y
 CONFIG_RK28_USB_WAKE=y
+CONFIG_WIFI_CONTROL_FUNC=y
 
 #
 # Processor Type
@@ -436,7 +437,7 @@ CONFIG_BT_HCIUART_H4=y
 # CONFIG_BT_HCIUART_LL is not set
 # CONFIG_BT_HCIVHCI is not set
 # CONFIG_BT_MRVL is not set
-CONFIG_BT_HCIBCM4325=y
+# CONFIG_BT_HCIBCM4325 is not set
 # CONFIG_AF_RXRPC is not set
 CONFIG_WIRELESS=y
 # CONFIG_CFG80211 is not set
@@ -712,6 +713,7 @@ CONFIG_INPUT_TOUCHSCREEN=y
 # CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI is not set
 CONFIG_TOUCHSCREEN_XPT2046_320X480_SPI=y
 # CONFIG_TOUCHSCREEN_XPT2046_320X480_CBN_SPI is not set
+# CONFIG_TOUCHSCREEN_IT7250 is not set
 # CONFIG_TOUCHSCREEN_AD7879_I2C is not set
 # CONFIG_TOUCHSCREEN_AD7879_SPI is not set
 # CONFIG_TOUCHSCREEN_AD7879 is not set
@@ -947,6 +949,9 @@ CONFIG_MEDIA_SUPPORT=y
 #
 # Multimedia drivers
 #
+CONFIG_SMS_SIANO_MDTV=y
+# CONFIG_SMS_USB_DRV is not set
+# CONFIG_SMS_SDIO_DRV is not set
 # CONFIG_DAB is not set
 
 #
@@ -1300,6 +1305,20 @@ CONFIG_RK2818_DSP=y
 #
 CONFIG_RK2818_POWER=y
 
+#
+# CMMB
+#
+CONFIG_CMMB=y
+
+#
+# Siano module components
+#
+# CONFIG_SMS_DVB3_SUBSYS is not set
+# CONFIG_SMS_DVB5_S2API_SUBSYS is not set
+CONFIG_SMS_HOSTLIB_SUBSYS=y
+# CONFIG_SMS_NET_SUBSYS is not set
+CONFIG_SMS_SPI_ROCKCHIP=y
+
 #
 # File systems
 #
index 9b050ac315307753edff009a6fe824556499c6c7..4c0a3fb7fe54fe660fe1b8c512132076ca4420c5 100644 (file)
@@ -8,5 +8,5 @@ obj-$(CONFIG_PM) += pm.o
 obj-$(CONFIG_RK28_ADC) += adc.o
 obj-$(CONFIG_MACH_RK2818MID) += board-midsdk.o
 obj-$(CONFIG_MACH_RK2818PHONE) += board-phonesdk.o
-obj-$(CONFIG_MACH_RAHO) += board-raho.o
+obj-$(CONFIG_MACH_RAHO) += board-raho.o board-raho-rfkill.o
 obj-$(CONFIG_MACH_RK2818INFO) += board-infosdk.o board-infosdk-rfkill.o 
diff --git a/arch/arm/mach-rk2818/board-raho-rfkill.c b/arch/arm/mach-rk2818/board-raho-rfkill.c
new file mode 100755 (executable)
index 0000000..2b0001c
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2010 ROCKCHIP, Inc.
+ * Author: roger_chen <cz@rock-chips.com>
+ *
+ * This program is the bluetooth device bcm4329's driver,
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/rfkill.h>
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+//#include <asm/gpio.h>
+//#include <asm/arch/gpio.h>
+//#include <asm/arch/iomux.h>
+//#include <asm/arch/gpio.h>
+#include <linux/interrupt.h>
+#include <linux/wakelock.h>
+#include <mach/spi_fpga.h>
+#include <linux/fs.h>
+#include <asm/uaccess.h>
+#include <mach/gpio.h>
+
+#if 1
+#define DBG(x...)   printk(KERN_INFO x)
+#else
+#define DBG(x...)
+#endif
+
+#define RAHO_BT_GPIO_POWER_N   FPGA_PIO1_06
+#define RAHO_BT_GPIO_RESET_N   FPGA_PIO1_07
+
+static struct rfkill *bt_rfk;
+static const char bt_name[] = "bcm4329";
+extern int raho_bt_power_state;
+extern int raho_wifi_power_state;
+  
+static int bcm4329_set_block(void *data, bool blocked)
+{
+       DBG("%s---blocked :%d\n", __FUNCTION__, blocked);
+
+       if (false == blocked) {          
+               gpio_set_value(RAHO_BT_GPIO_POWER_N, GPIO_HIGH);  /* bt power on */
+               gpio_set_value(RAHO_BT_GPIO_RESET_N, GPIO_HIGH);  /* bt reset deactive*/
+               mdelay(20);
+               pr_info("bt turn on power\n");
+       }
+       else {
+               if (!raho_wifi_power_state) {
+                       gpio_set_value(RAHO_BT_GPIO_POWER_N, GPIO_LOW);  /* bt power off */
+                       mdelay(20);     
+                       pr_info("bt shut off power\n");
+               }else {
+                       pr_info("bt shouldn't shut off power, wifi is using it!\n");
+               }
+
+               gpio_set_value(RAHO_BT_GPIO_RESET_N, GPIO_LOW);  /* bt reset active*/
+               mdelay(20);
+       }
+
+       raho_bt_power_state = !blocked;
+       return 0;
+}
+
+
+static const struct rfkill_ops bcm4329_rfk_ops = {
+       .set_block = bcm4329_set_block,
+};
+
+static int __init bcm4329_rfkill_probe(struct platform_device *pdev)
+{
+       int rc = 0;
+       bool default_state = true;
+       
+       DBG("Enter::%s,line=%d\n",__FUNCTION__,__LINE__);
+       
+       /* default to bluetooth off */
+       bcm4329_set_block(NULL, default_state); /* blocked -> bt off */
+        
+       bt_rfk = rfkill_alloc(bt_name, 
+                    NULL, 
+                    RFKILL_TYPE_BLUETOOTH, 
+                    &bcm4329_rfk_ops, 
+                    NULL);
+
+       if (!bt_rfk)
+       {
+               printk("fail to rfkill_allocate************\n");
+               return -ENOMEM;
+       }
+       
+       rfkill_set_states(bt_rfk, default_state, false);
+
+       rc = rfkill_register(bt_rfk);
+       if (rc)
+               rfkill_destroy(bt_rfk);
+
+       printk("rc=0x%x\n", rc);
+    
+       return rc;
+}
+
+
+static int __devexit bcm4329_rfkill_remove(struct platform_device *pdev)
+{
+       if (bt_rfk)
+               rfkill_unregister(bt_rfk);
+       bt_rfk = NULL;
+
+       platform_set_drvdata(pdev, NULL);
+       DBG("Enter::%s,line=%d\n",__FUNCTION__,__LINE__);
+       return 0;
+}
+
+static struct platform_driver bcm4329_rfkill_driver = {
+       .probe = bcm4329_rfkill_probe,
+       .remove = __devexit_p(bcm4329_rfkill_remove),
+       .driver = {
+               .name = "raho_rfkill", 
+               .owner = THIS_MODULE,
+       },
+};
+
+/*
+ * Module initialization
+ */
+static int __init bcm4329_mod_init(void)
+{
+       int ret;
+       DBG("Enter::%s,line=%d\n",__FUNCTION__,__LINE__);
+       ret = platform_driver_register(&bcm4329_rfkill_driver);
+       printk("ret=0x%x\n", ret);
+       return ret;
+}
+
+static void __exit bcm4329_mod_exit(void)
+{
+       platform_driver_unregister(&bcm4329_rfkill_driver);
+}
+
+module_init(bcm4329_mod_init);
+module_exit(bcm4329_mod_exit);
+MODULE_DESCRIPTION("bcm4329 Bluetooth driver");
+MODULE_AUTHOR("roger_chen cz@rock-chips.com");
+MODULE_LICENSE("GPL");
+
index 718ec875aea30dadcfc3461f0afa166233d42464..146c15c7d5c07a7054f9d23c4710aecc34679c20 100644 (file)
@@ -199,6 +199,9 @@ struct rk2818_sdmmc_platform_data default_sdmmc0_data = {
        .use_dma = 0,
 #endif
 };
+
+static int raho_wifi_status(struct device *dev);
+static int raho_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
 struct rk2818_sdmmc_platform_data default_sdmmc1_data = {
        .host_ocr_avail = (MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
                                           MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
@@ -213,6 +216,96 @@ struct rk2818_sdmmc_platform_data default_sdmmc1_data = {
 #else
        .use_dma = 0,
 #endif
+       .status = raho_wifi_status,
+        .register_status_notify = raho_wifi_status_register,
+};
+
+static int raho_wifi_cd;   /* wifi virtual 'card detect' status */
+static void (*wifi_status_cb)(int card_present, void *dev_id);
+static void *wifi_status_cb_devid;
+
+static int raho_wifi_status(struct device *dev)
+{
+        return raho_wifi_cd;
+}
+
+static int raho_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;
+}
+
+#define RAHO_WIFI_GPIO_POWER_N  FPGA_PIO1_06
+#define RAHO_WIFI_GPIO_RESET_N  FPGA_PIO1_03
+
+int raho_wifi_power_state = 0;
+int raho_bt_power_state = 0;
+
+static int raho_wifi_power(int on)
+{
+        pr_info("%s: %d\n", __func__, on);
+        if (on){
+                gpio_set_value(RAHO_WIFI_GPIO_POWER_N, on);
+                mdelay(100);
+                pr_info("wifi turn on power\n");
+        }else{
+                if (!raho_bt_power_state){
+                        gpio_set_value(RAHO_WIFI_GPIO_POWER_N, on);
+                        mdelay(100);
+                        pr_info("wifi shut off power\n");
+                }else
+                {
+                        pr_info("wifi shouldn't shut off power, bt is using it!\n");
+                }
+
+        }
+
+        raho_wifi_power_state = on;
+        return 0;
+}
+
+static int raho_wifi_reset_state;
+static int raho_wifi_reset(int on)
+{
+        pr_info("%s: %d\n", __func__, on);
+        gpio_set_value(RAHO_WIFI_GPIO_RESET_N, on);
+        mdelay(100);
+        raho_wifi_reset_state = on;
+        return 0;
+}
+
+static int raho_wifi_set_carddetect(int val)
+{
+        pr_info("%s:%d\n", __func__, val);
+        raho_wifi_cd = val;
+        if (wifi_status_cb){
+                wifi_status_cb(val, wifi_status_cb_devid);
+        }else {
+                pr_warning("%s, nobody to notify\n", __func__);
+        }
+        return 0;
+}
+
+static struct wifi_platform_data raho_wifi_control = {
+        .set_power = raho_wifi_power,
+        .set_reset = raho_wifi_reset,
+        .set_carddetect = raho_wifi_set_carddetect,
+};
+static struct platform_device raho_wifi_device = {
+        .name = "bcm4329_wlan",
+        .id = 1,
+        .dev = {
+                .platform_data = &raho_wifi_control,
+         },
+};
+
+/* bluetooth rfkill device */
+static struct platform_device raho_rfkill = {
+        .name = "raho_rfkill",
+        .id = -1,
 };
 
 /*****************************************************************************************
@@ -1599,7 +1692,7 @@ struct rk2818_nand_platform_data rk2818_nand_data = {
 
 static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_BT
-    &rk2818_device_rfkill,
+        &raho_rfkill,
 #endif
        &rk2818_device_uart0,
        &rk2818_device_uart1,
@@ -1615,6 +1708,7 @@ static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_SDMMC1_RK2818
        &rk2818_device_sdmmc1,
 #endif
+       &raho_wifi_device,
        &rk2818_device_spim,
        &rk2818_device_i2s,
 #if defined(CONFIG_ANDROID_PMEM)