net: rfkill: add wifi and bt driver

Signed-off-by: Alex Zhao <zzc@rock-chips.com>
Change-Id: I1d399641587124d2291b5b49e5538e7e490a843a
This commit is contained in:
Alex Zhao
2021-11-06 14:46:09 +08:00
committed by Tao Huang
parent c0d53bb51b
commit 4bfa8f90b5
5 changed files with 49 additions and 36 deletions
+1
View File
@@ -68,6 +68,7 @@ struct rfkill_rk_platform_data {
};
int rfkill_get_bt_power_state(int *power, bool *toggle);
void rfkill_rk_sleep_bt(bool sleep);
#endif /* __RFKILL_GPIO_H */
+9
View File
@@ -32,3 +32,12 @@ config RFKILL_GPIO
help
If you say yes here you get support of a generic gpio RFKILL
driver.
config RFKILL_RK
tristate "Rockchip RFKILL driver"
depends on RFKILL
depends on MMC
depends on ARCH_ROCKCHIP
default n
help
Rockchip rfkill driver for rk29/rk3X
+2
View File
@@ -7,3 +7,5 @@ rfkill-y += core.o
rfkill-$(CONFIG_RFKILL_INPUT) += input.o
obj-$(CONFIG_RFKILL) += rfkill.o
obj-$(CONFIG_RFKILL_GPIO) += rfkill-gpio.o
rfkill-rk-y += rfkill-wlan.o rfkill-bt.o
obj-$(CONFIG_RFKILL_RK) += rfkill-rk.o
+19 -20
View File
@@ -231,7 +231,6 @@ void rfkill_rk_sleep_bt(bool sleep)
{
struct rfkill_rk_data *rfkill = g_rfkill;
struct rfkill_rk_gpio *wake;
bool ret;
DBG("Enter %s\n", __func__);
@@ -246,7 +245,7 @@ void rfkill_rk_sleep_bt(bool sleep)
return;
}
ret = cancel_delayed_work_sync(&rfkill->bt_sleep_delay_work);
cancel_delayed_work_sync(&rfkill->bt_sleep_delay_work);
rfkill_rk_sleep_bt_internal(rfkill, sleep);
@@ -387,7 +386,6 @@ static int rfkill_rk_pm_prepare(struct device *dev)
struct rfkill_rk_data *rfkill = g_rfkill;
struct rfkill_rk_gpio *rts;
struct rfkill_rk_irq *wake_host_irq;
struct pinctrl *pinctrl = rfkill->pdata->pinctrl;
DBG("Enter %s\n", __func__);
@@ -398,9 +396,9 @@ static int rfkill_rk_pm_prepare(struct device *dev)
wake_host_irq = &rfkill->pdata->wake_host_irq;
//To prevent uart to receive bt data when suspended
if (pinctrl && gpio_is_valid(rts->io)) {
if (rfkill->pdata->pinctrl && gpio_is_valid(rts->io)) {
DBG("Disable UART_RTS\n");
pinctrl_select_state(pinctrl, rts->gpio_state);
pinctrl_select_state(rfkill->pdata->pinctrl, rts->gpio_state);
gpio_direction_output(rts->io, !rts->enable);
}
@@ -415,7 +413,9 @@ static int rfkill_rk_pm_prepare(struct device *dev)
}
#ifdef CONFIG_RFKILL_RESET
rfkill_set_states(rfkill->rfkill_dev, BT_BLOCKED, false);
rfkill_init_sw_state(rfkill->rfkill_dev, BT_BLOCKED);
rfkill_set_sw_state(rfkill->rfkill_dev, BT_BLOCKED);
rfkill_set_hw_state(rfkill->rfkill_dev, false);
rfkill_rk_set_power(rfkill, BT_BLOCKED);
#endif
@@ -427,7 +427,6 @@ static void rfkill_rk_pm_complete(struct device *dev)
struct rfkill_rk_data *rfkill = g_rfkill;
struct rfkill_rk_irq *wake_host_irq;
struct rfkill_rk_gpio *rts;
struct pinctrl *pinctrl = rfkill->pdata->pinctrl;
DBG("Enter %s\n", __func__);
@@ -442,10 +441,10 @@ static void rfkill_rk_pm_complete(struct device *dev)
disable_irq(wake_host_irq->irq);
}
if (pinctrl && gpio_is_valid(rts->io)) {
if (rfkill->pdata->pinctrl && gpio_is_valid(rts->io)) {
DBG("Enable UART_RTS\n");
gpio_direction_output(rts->io, rts->enable);
pinctrl_select_state(pinctrl, rts->default_state);
pinctrl_select_state(rfkill->pdata->pinctrl, rts->default_state);
}
}
@@ -586,16 +585,14 @@ static int bluetooth_platdata_parse_dt(struct device *dev,
}
#endif //CONFIG_OF
static const struct file_operations bluesleep_lpm = {
.owner = THIS_MODULE,
.read = bluesleep_read_proc_lpm,
.write = bluesleep_write_proc_lpm,
static const struct proc_ops bluesleep_lpm = {
.proc_read = bluesleep_read_proc_lpm,
.proc_write = bluesleep_write_proc_lpm,
};
static const struct file_operations bluesleep_btwrite = {
.owner = THIS_MODULE,
.read = bluesleep_read_proc_btwrite,
.write = bluesleep_write_proc_btwrite,
static const struct proc_ops bluesleep_btwrite = {
.proc_read = bluesleep_read_proc_btwrite,
.proc_write = bluesleep_write_proc_btwrite,
};
static int rfkill_rk_probe(struct platform_device *pdev)
@@ -649,7 +646,7 @@ static int rfkill_rk_probe(struct platform_device *pdev)
}
/* read/write proc entries */
ent = proc_create("lpm", 0, sleep_dir, &bluesleep_lpm);
ent = proc_create("lpm", 0444, sleep_dir, &bluesleep_lpm);
if (!ent) {
LOG("Unable to create /proc/%s/lpm entry", PROC_DIR);
ret = -ENOMEM;
@@ -657,7 +654,7 @@ static int rfkill_rk_probe(struct platform_device *pdev)
}
/* read/write proc entries */
ent = proc_create("btwrite", 0, sleep_dir, &bluesleep_btwrite);
ent = proc_create("btwrite", 0444, sleep_dir, &bluesleep_btwrite);
if (!ent) {
LOG("Unable to create /proc/%s/btwrite entry", PROC_DIR);
ret = -ENOMEM;
@@ -699,7 +696,9 @@ static int rfkill_rk_probe(struct platform_device *pdev)
if (!rfkill->rfkill_dev)
goto fail_alloc;
rfkill_set_states(rfkill->rfkill_dev, BT_BLOCKED, false);
rfkill_init_sw_state(rfkill->rfkill_dev, BT_BLOCKED);
rfkill_set_sw_state(rfkill->rfkill_dev, BT_BLOCKED);
rfkill_set_hw_state(rfkill->rfkill_dev, false);
ret = rfkill_register(rfkill->rfkill_dev);
if (ret < 0)
goto fail_rfkill;
+18 -16
View File
@@ -234,9 +234,6 @@ int rockchip_wifi_power(int on)
LOG("%s: %d\n", __func__, on);
if (!on && primary_sdio_host)
mmc_pwrseq_power_off(primary_sdio_host);
if (!mrfkill) {
LOG("%s: rfkill-wlan driver has not Successful initialized\n",
__func__);
@@ -271,12 +268,17 @@ int rockchip_wifi_power(int on)
regulator_set_voltage(ldo, 3000000, 3000000);
LOG("%s: %s enabled\n", __func__, ldostr);
ret = regulator_enable(ldo);
if (ret)
LOG("ldo enable failed\n");
wifi_power_state = 1;
LOG("wifi turn on power.\n");
} else {
LOG("%s: %s disabled\n", __func__, ldostr);
while (regulator_is_enabled(ldo) > 0)
while (regulator_is_enabled(ldo) > 0) {
ret = regulator_disable(ldo);
if (ret)
LOG("ldo disable failed\n");
}
wifi_power_state = 0;
LOG("wifi shut off power.\n");
}
@@ -337,10 +339,9 @@ EXPORT_SYMBOL(rockchip_wifi_power);
* Wifi Sdio Detect Func
*
*************************************************************************/
extern int mmc_host_rescan(struct mmc_host *host, int val, int irq_type);
int rockchip_wifi_set_carddetect(int val)
{
return mmc_host_rescan(NULL, val, 1);
return 0;
}
EXPORT_SYMBOL(rockchip_wifi_set_carddetect);
@@ -557,7 +558,8 @@ static int wlan_platdata_parse_dt(struct device *dev,
__func__);
strcpy(wifi_chip_type_string, "rkwifi");
} else {
strcpy(wifi_chip_type_string, strings);
if (strings && strlen(strings) < 64)
strcpy(wifi_chip_type_string, strings);
}
LOG("%s: wifi_chip_type = %s\n", __func__, wifi_chip_type_string);
@@ -855,11 +857,6 @@ static int rfkill_wlan_probe(struct platform_device *pdev)
if (ret)
goto fail_alloc;
ret = rfkill_rk_setup_gpio(&pdata->power_n, wlan_name,
"wlan_poweren");
if (ret)
goto fail_alloc;
ret = rfkill_rk_setup_gpio(&pdata->reset_n, wlan_name,
"wlan_reset");
if (ret)
@@ -873,11 +870,7 @@ static int rfkill_wlan_probe(struct platform_device *pdev)
#ifdef CONFIG_SDIO_KEEPALIVE
if (gpio_is_valid(pdata->power_n.io) &&
primary_sdio_host && primary_sdio_host->support_chip_alive)
gpio_direction_output(pdata->power_n.io, pdata->power_n.enable);
#else
if (gpio_is_valid(pdata->power_n.io))
gpio_direction_output(pdata->power_n.io, !pdata->power_n.enable);
#endif
@@ -930,6 +923,14 @@ static int rfkill_wlan_remove(struct platform_device *pdev)
return 0;
}
static void rfkill_wlan_shutdown(struct platform_device *pdev)
{
LOG("Enter %s\n", __func__);
rockchip_wifi_power(0);
rfkill_set_wifi_bt_power(0);
}
static int rfkill_wlan_suspend(struct platform_device *pdev, pm_message_t state)
{
LOG("Enter %s\n", __func__);
@@ -953,6 +954,7 @@ MODULE_DEVICE_TABLE(of, wlan_platdata_of_match);
static struct platform_driver rfkill_wlan_driver = {
.probe = rfkill_wlan_probe,
.remove = rfkill_wlan_remove,
.shutdown = rfkill_wlan_shutdown,
.suspend = rfkill_wlan_suspend,
.resume = rfkill_wlan_resume,
.driver = {