From: lbt Date: Wed, 15 Sep 2010 09:33:41 +0000 (+0800) Subject: bsp:modify wifi and bt gpio control for the infoit50 board X-Git-Tag: firefly_0821_release~11139 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e954d000f44d57519fcbdd821b58776f1cdb9b56;p=firefly-linux-kernel-4.4.55.git bsp:modify wifi and bt gpio control for the infoit50 board --- diff --git a/arch/arm/mach-rk2818/Makefile b/arch/arm/mach-rk2818/Makefile index f8bd0633f68a..6668289b73db 100644 --- a/arch/arm/mach-rk2818/Makefile +++ b/arch/arm/mach-rk2818/Makefile @@ -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 index 000000000000..e622ccf15e08 --- /dev/null +++ b/arch/arm/mach-rk2818/board-infoit50-rfkill.c @@ -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 +#include +#include +#include +#include + +#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"); + diff --git a/arch/arm/mach-rk2818/board-infoit50.c b/arch/arm/mach-rk2818/board-infoit50.c index 8f7ccf0c11a5..7402275ca883 100755 --- a/arch/arm/mach-rk2818/board-infoit50.c +++ b/arch/arm/mach-rk2818/board-infoit50.c @@ -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,