Lines Matching +full:rfkill +full:- +full:gpio

1 // SPDX-License-Identifier: GPL-2.0-or-later
11 #include <linux/rfkill.h>
17 #include <linux/gpio/consumer.h>
25 struct rfkill *rfkill_dev;
33 struct rfkill_gpio_data *rfkill = data; in rfkill_gpio_set_power() local
35 if (!blocked && !IS_ERR(rfkill->clk) && !rfkill->clk_enabled) in rfkill_gpio_set_power()
36 clk_enable(rfkill->clk); in rfkill_gpio_set_power()
38 gpiod_set_value_cansleep(rfkill->shutdown_gpio, !blocked); in rfkill_gpio_set_power()
39 gpiod_set_value_cansleep(rfkill->reset_gpio, !blocked); in rfkill_gpio_set_power()
41 if (blocked && !IS_ERR(rfkill->clk) && rfkill->clk_enabled) in rfkill_gpio_set_power()
42 clk_disable(rfkill->clk); in rfkill_gpio_set_power()
44 rfkill->clk_enabled = !blocked; in rfkill_gpio_set_power()
57 { "reset-gpios", &reset_gpios, 1 },
58 { "shutdown-gpios", &shutdown_gpios, 1 },
63 struct rfkill_gpio_data *rfkill) in rfkill_gpio_acpi_probe() argument
67 id = acpi_match_device(dev->driver->acpi_match_table, dev); in rfkill_gpio_acpi_probe()
69 return -ENODEV; in rfkill_gpio_acpi_probe()
71 rfkill->type = (unsigned)id->driver_data; in rfkill_gpio_acpi_probe()
76 /* List of DMI matches for devices on which rfkill-gpio should not load,
81 /* Lenovo Yoga Tab 3 Pro YT3-X90, bogus "BCM4752" device in DSDT */
84 DMI_MATCH(DMI_PRODUCT_VERSION, "Blade3-10A-001"),
92 struct rfkill_gpio_data *rfkill; in rfkill_gpio_probe() local
93 struct gpio_desc *gpio; in rfkill_gpio_probe() local
100 return -ENODEV; in rfkill_gpio_probe()
102 rfkill = devm_kzalloc(&pdev->dev, sizeof(*rfkill), GFP_KERNEL); in rfkill_gpio_probe()
103 if (!rfkill) in rfkill_gpio_probe()
104 return -ENOMEM; in rfkill_gpio_probe()
106 if (dev_of_node(&pdev->dev)) { in rfkill_gpio_probe()
108 type_property = "radio-type"; in rfkill_gpio_probe()
113 device_property_read_string(&pdev->dev, name_property, &rfkill->name); in rfkill_gpio_probe()
114 device_property_read_string(&pdev->dev, type_property, &type_name); in rfkill_gpio_probe()
116 if (!rfkill->name) in rfkill_gpio_probe()
117 rfkill->name = dev_name(&pdev->dev); in rfkill_gpio_probe()
119 rfkill->type = rfkill_find_type(type_name); in rfkill_gpio_probe()
121 if (ACPI_HANDLE(&pdev->dev)) { in rfkill_gpio_probe()
122 ret = rfkill_gpio_acpi_probe(&pdev->dev, rfkill); in rfkill_gpio_probe()
127 rfkill->clk = devm_clk_get(&pdev->dev, NULL); in rfkill_gpio_probe()
129 gpio = devm_gpiod_get_optional(&pdev->dev, "reset", GPIOD_ASIS); in rfkill_gpio_probe()
130 if (IS_ERR(gpio)) in rfkill_gpio_probe()
131 return PTR_ERR(gpio); in rfkill_gpio_probe()
133 rfkill->reset_gpio = gpio; in rfkill_gpio_probe()
135 gpio = devm_gpiod_get_optional(&pdev->dev, "shutdown", GPIOD_ASIS); in rfkill_gpio_probe()
136 if (IS_ERR(gpio)) in rfkill_gpio_probe()
137 return PTR_ERR(gpio); in rfkill_gpio_probe()
139 rfkill->shutdown_gpio = gpio; in rfkill_gpio_probe()
141 /* Make sure at-least one GPIO is defined for this instance */ in rfkill_gpio_probe()
142 if (!rfkill->reset_gpio && !rfkill->shutdown_gpio) { in rfkill_gpio_probe()
143 dev_err(&pdev->dev, "invalid platform data\n"); in rfkill_gpio_probe()
144 return -EINVAL; in rfkill_gpio_probe()
147 ret = gpiod_direction_output(rfkill->reset_gpio, true); in rfkill_gpio_probe()
151 ret = gpiod_direction_output(rfkill->shutdown_gpio, true); in rfkill_gpio_probe()
155 rfkill->rfkill_dev = rfkill_alloc(rfkill->name, &pdev->dev, in rfkill_gpio_probe()
156 rfkill->type, &rfkill_gpio_ops, in rfkill_gpio_probe()
157 rfkill); in rfkill_gpio_probe()
158 if (!rfkill->rfkill_dev) in rfkill_gpio_probe()
159 return -ENOMEM; in rfkill_gpio_probe()
161 ret = rfkill_register(rfkill->rfkill_dev); in rfkill_gpio_probe()
165 platform_set_drvdata(pdev, rfkill); in rfkill_gpio_probe()
167 dev_info(&pdev->dev, "%s device registered.\n", rfkill->name); in rfkill_gpio_probe()
172 rfkill_destroy(rfkill->rfkill_dev); in rfkill_gpio_probe()
179 struct rfkill_gpio_data *rfkill = platform_get_drvdata(pdev); in rfkill_gpio_remove() local
181 rfkill_unregister(rfkill->rfkill_dev); in rfkill_gpio_remove()
182 rfkill_destroy(rfkill->rfkill_dev); in rfkill_gpio_remove()
195 { .compatible = "rfkill-gpio", },
212 MODULE_DESCRIPTION("gpio rfkill");