bsp:modify wifi and bt gpio control for the infoit50 board
authorlbt <lbt@rock-chips.com>
Wed, 15 Sep 2010 09:33:41 +0000 (17:33 +0800)
committerlbt <lbt@rock-chips.com>
Wed, 15 Sep 2010 09:33:41 +0000 (17:33 +0800)
arch/arm/mach-rk2818/Makefile
arch/arm/mach-rk2818/board-infoit50-rfkill.c [new file with mode: 0755]
arch/arm/mach-rk2818/board-infoit50.c

index f8bd0633f68a22460bccc93a883e90caa06750ad..6668289b73dbf50738e23bf284bbebea1cb72d33 100644 (file)
@@ -10,4 +10,4 @@ obj-$(CONFIG_MACH_RK2818MID) += board-midsdk.o
 obj-$(CONFIG_MACH_RK2818PHONE) += board-phonesdk.o
 obj-$(CONFIG_MACH_RAHO) += board-raho.o board-raho-rfkill.o
 obj-$(CONFIG_MACH_RK2818INFO) += board-infosdk.o board-infosdk-rfkill.o 
-obj-$(CONFIG_MACH_RK2818INFO_IT50) += board-infoit50.o board-infosdk-rfkill.o 
+obj-$(CONFIG_MACH_RK2818INFO_IT50) += board-infoit50.o board-infoit50-rfkill.o 
diff --git a/arch/arm/mach-rk2818/board-infoit50-rfkill.c b/arch/arm/mach-rk2818/board-infoit50-rfkill.c
new file mode 100755 (executable)
index 0000000..e622ccf
--- /dev/null
@@ -0,0 +1,140 @@
+/* linux/arch/arm/mach-rk2818/board-infoit50-rfkill.c
+ *
+ * Copyright (C) 2010 ROCKCHIP, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/rfkill.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <mach/gpio.h>
+
+#define INFOIT50_BT_GPIO_POWER_N   TCA6424_P01
+#define INFOIT50_BT_GPIO_RESET_N   TCA6424_P14
+
+static struct rfkill *bt_rfk;
+static const char bt_name[] = "bcm4329";
+
+static int bcm4329_set_block(void *data, bool blocked)
+{
+       pr_info("%s---blocked :%d\n", __func__, blocked);
+
+       if (false == blocked) {
+               gpio_direction_output(INFOIT50_BT_GPIO_POWER_N, GPIO_HIGH);  /* bt power on */
+               gpio_direction_output(INFOIT50_BT_GPIO_RESET_N, GPIO_HIGH);  /* bt reset deactive */
+               mdelay(20);
+               pr_info("bt turn on power\n");
+       }else{   
+               gpio_direction_output(INFOIT50_BT_GPIO_POWER_N, GPIO_LOW);  /* bt power off */
+               gpio_direction_output(INFOIT50_BT_GPIO_RESET_N, GPIO_LOW); /* bt reset active */
+               mdelay(20);     
+               pr_info("bt shut off power\n");
+       }
+
+       return 0;
+}
+
+
+static const struct rfkill_ops bcm4329_rfk_ops = {
+       .set_block = bcm4329_set_block,
+};
+
+static int bcm4329_rfkill_probe(struct platform_device *pdev)
+{
+       int rc = 0;
+       bool default_state = true;
+       
+       pr_info("Enter::%s,line=%d\n",__FUNCTION__,__LINE__);
+       
+       rc = gpio_request(INFOIT50_BT_GPIO_POWER_N, "bt_shutdown");
+       if (rc)
+               return rc;      
+       rc = gpio_request(INFOIT50_BT_GPIO_RESET_N, "bt_reset");
+       if (rc){
+               gpio_free(INFOIT50_BT_GPIO_POWER_N);    
+               return rc;
+       }
+       
+       /* 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 bcm4329_rfkill_remove(struct platform_device *pdev)
+{
+       if (bt_rfk)
+               rfkill_unregister(bt_rfk);
+       rfkill_destroy(bt_rfk);
+       bt_rfk = NULL;
+       gpio_free(INFOIT50_BT_GPIO_POWER_N);
+       gpio_free(INFOIT50_BT_GPIO_RESET_N);
+
+       platform_set_drvdata(pdev, NULL);
+       pr_info("Enter::%s,line=%d\n",__FUNCTION__,__LINE__);
+       return 0;
+}
+
+static struct platform_driver bcm4329_rfkill_driver = {
+       .probe = bcm4329_rfkill_probe,
+       .remove = bcm4329_rfkill_remove,
+       .driver = {
+               .name = "infoit50_rfkill", 
+               .owner = THIS_MODULE,
+       },
+};
+
+/*
+ * Module initialization
+ */
+static int __init bcm4329_mod_init(void)
+{
+       int ret;
+       pr_info("Enter::%s,line=%d\n",__func__,__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 8f7ccf0c11a5b7c0547609cc93a61dd8da122dca..7402275ca88347f025a0cfd315886b8d46cd5d62 100755 (executable)
@@ -232,7 +232,7 @@ static int info_wifi_status_register(void (*callback)(int card_present, void *de
        return 0;
 }
 
-#define INFO_WIFI_GPIO_POWER_N  TCA6424_P01
+#define INFO_WIFI_GPIO_POWER_N  TCA6424_P00
 #define INFO_WIFI_GPIO_RESET_N  TCA6424_P00 
 
 int info_wifi_power_state = 0;
@@ -244,16 +244,11 @@ static int info_wifi_power(int on)
        if (on){
                gpio_set_value(INFO_WIFI_GPIO_POWER_N, on);
                mdelay(100);
-               pr_info("wifi turn on power\n");
+               pr_info("wifi turn on power and reset deactive\n");
        }else{
-               if (!info_bt_power_state){
-                       gpio_set_value(INFO_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"); 
-               }
+               gpio_set_value(INFO_WIFI_GPIO_POWER_N, on);     
+               mdelay(100);
+               pr_info("wifi shut off power and reset active\n");
 
        }
 
@@ -264,9 +259,7 @@ static int info_wifi_power(int on)
 static int info_wifi_reset_state;
 static int info_wifi_reset(int on)
 {
-       pr_info("%s: %d\n", __func__, on);
-       gpio_set_value(INFO_WIFI_GPIO_RESET_N, on);
-       mdelay(100);
+       pr_info("%s: do nothing\n", __func__);
        info_wifi_reset_state = on;
        return 0;
 }
@@ -298,7 +291,7 @@ static struct platform_device info_wifi_device = {
 
 /* bluetooth rfkill device */
 static struct platform_device info_rfkill = {
-       .name = "info_rfkill",
+       .name = "infoit50_rfkill",
        .id = -1,
 };
  
@@ -354,12 +347,12 @@ struct pca9554_platform_data rk2818_pca9554_data={
 #if defined (CONFIG_IOEXTEND_TCA6424)
 struct rk2818_gpio_expander_info  extgpio_tca6424_settinginfo[] = {
        {
-               .gpio_num                       = TCA6424_P00,  //wifi reset
+               .gpio_num                       = TCA6424_P00,  //wifi power and reset together
                .pin_type                       = GPIO_OUT,
                .pin_value                      = GPIO_LOW,
        },
        {
-               .gpio_num                       = TCA6424_P01,  //wifi reg on
+               .gpio_num                       = TCA6424_P01,  //bt reg on
                .pin_type                       = GPIO_OUT,
                .pin_value                      = GPIO_LOW,
        },
@@ -395,6 +388,11 @@ struct rk2818_gpio_expander_info  extgpio_tca6424_settinginfo[] = {
                .pin_type           = GPIO_OUT,
                .pin_value                      =GPIO_HIGH,
        },
+       {
+               .gpio_num               = TCA6424_P14,
+               .pin_type               = GPIO_OUT,
+               .pin_value              = GPIO_LOW,
+       },
        {
                .gpio_num               = TCA6424_P17,// 3G reset
                .pin_type           = GPIO_OUT,