21 #include <linux/kernel.h>
22 #include <linux/module.h>
23 #include <linux/rfkill.h>
26 #include <linux/slab.h>
36 #define PWR_CLK_SET(_RF, _EN) \
37 ((_RF)->pwr_clk_enabled = (!(_EN) ? PWR_ENABLED : PWR_DISABLED))
38 #define PWR_CLK_ENABLED(_RF) ((_RF)->pwr_clk_enabled == PWR_ENABLED)
39 #define PWR_CLK_DISABLED(_RF) ((_RF)->pwr_clk_enabled != PWR_ENABLED)
50 static int rfkill_gpio_set_power(
void *
data,
bool blocked)
55 if (gpio_is_valid(rfkill->
pdata->shutdown_gpio))
57 if (gpio_is_valid(rfkill->
pdata->reset_gpio))
64 if (gpio_is_valid(rfkill->
pdata->reset_gpio))
66 if (gpio_is_valid(rfkill->
pdata->shutdown_gpio))
76 static const struct rfkill_ops rfkill_gpio_ops = {
77 .set_block = rfkill_gpio_set_power,
88 pr_warn(
"%s: No platform data specified\n", __func__);
96 pr_warn(
"%s: invalid platform data\n", __func__);
100 rfkill = kzalloc(
sizeof(*rfkill),
GFP_KERNEL);
107 pr_warn(
"%s: can't set up gpio\n", __func__);
124 goto fail_reset_name;
133 pr_warn(
"%s: can't find pwr_clk.\n", __func__);
134 goto fail_shutdown_name;
141 pr_warn(
"%s: failed to get reset gpio.\n", __func__);
149 pr_warn(
"%s: failed to get shutdown gpio.\n", __func__);
155 &rfkill_gpio_ops, rfkill);
163 platform_set_drvdata(pdev, rfkill);
199 if (gpio_is_valid(rfkill->
pdata->shutdown_gpio))
201 if (gpio_is_valid(rfkill->
pdata->reset_gpio))
215 .probe = rfkill_gpio_probe,
218 .name =
"rfkill_gpio",