Merge branch 'rfkill-gpio-cleanups' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next
This commit is contained in:
Коммит
68b422db3d
|
@ -23,9 +23,7 @@
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
|
||||||
static struct rfkill_gpio_platform_data wifi_rfkill_platform_data = {
|
static struct rfkill_gpio_platform_data wifi_rfkill_platform_data = {
|
||||||
.name = "wifi_rfkill",
|
.name = "wifi_rfkill",
|
||||||
.reset_gpio = 25, /* PD1 */
|
|
||||||
.shutdown_gpio = 85, /* PK5 */
|
|
||||||
.type = RFKILL_TYPE_WLAN,
|
.type = RFKILL_TYPE_WLAN,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -27,21 +27,11 @@
|
||||||
* struct rfkill_gpio_platform_data - platform data for rfkill gpio device.
|
* struct rfkill_gpio_platform_data - platform data for rfkill gpio device.
|
||||||
* for unused gpio's, the expected value is -1.
|
* for unused gpio's, the expected value is -1.
|
||||||
* @name: name for the gpio rf kill instance
|
* @name: name for the gpio rf kill instance
|
||||||
* @reset_gpio: GPIO which is used for reseting rfkill switch
|
|
||||||
* @shutdown_gpio: GPIO which is used for shutdown of rfkill switch
|
|
||||||
* @power_clk_name: [optional] name of clk to turn off while blocked
|
|
||||||
* @gpio_runtime_close: clean up platform specific gpio configuration
|
|
||||||
* @gpio_runtime_setup: set up platform specific gpio configuration
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct rfkill_gpio_platform_data {
|
struct rfkill_gpio_platform_data {
|
||||||
char *name;
|
char *name;
|
||||||
int reset_gpio;
|
|
||||||
int shutdown_gpio;
|
|
||||||
const char *power_clk_name;
|
|
||||||
enum rfkill_type type;
|
enum rfkill_type type;
|
||||||
void (*gpio_runtime_close)(struct platform_device *);
|
|
||||||
int (*gpio_runtime_setup)(struct platform_device *);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __RFKILL_GPIO_H */
|
#endif /* __RFKILL_GPIO_H */
|
||||||
|
|
|
@ -36,8 +36,6 @@ struct rfkill_gpio_data {
|
||||||
struct gpio_desc *shutdown_gpio;
|
struct gpio_desc *shutdown_gpio;
|
||||||
|
|
||||||
struct rfkill *rfkill_dev;
|
struct rfkill *rfkill_dev;
|
||||||
char *reset_name;
|
|
||||||
char *shutdown_name;
|
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
|
|
||||||
bool clk_enabled;
|
bool clk_enabled;
|
||||||
|
@ -87,10 +85,8 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct rfkill_gpio_platform_data *pdata = pdev->dev.platform_data;
|
struct rfkill_gpio_platform_data *pdata = pdev->dev.platform_data;
|
||||||
struct rfkill_gpio_data *rfkill;
|
struct rfkill_gpio_data *rfkill;
|
||||||
const char *clk_name = NULL;
|
|
||||||
struct gpio_desc *gpio;
|
struct gpio_desc *gpio;
|
||||||
int ret;
|
int ret;
|
||||||
int len;
|
|
||||||
|
|
||||||
rfkill = devm_kzalloc(&pdev->dev, sizeof(*rfkill), GFP_KERNEL);
|
rfkill = devm_kzalloc(&pdev->dev, sizeof(*rfkill), GFP_KERNEL);
|
||||||
if (!rfkill)
|
if (!rfkill)
|
||||||
|
@ -101,28 +97,15 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
} else if (pdata) {
|
} else if (pdata) {
|
||||||
clk_name = pdata->power_clk_name;
|
|
||||||
rfkill->name = pdata->name;
|
rfkill->name = pdata->name;
|
||||||
rfkill->type = pdata->type;
|
rfkill->type = pdata->type;
|
||||||
} else {
|
} else {
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = strlen(rfkill->name);
|
rfkill->clk = devm_clk_get(&pdev->dev, NULL);
|
||||||
rfkill->reset_name = devm_kzalloc(&pdev->dev, len + 7, GFP_KERNEL);
|
|
||||||
if (!rfkill->reset_name)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
rfkill->shutdown_name = devm_kzalloc(&pdev->dev, len + 10, GFP_KERNEL);
|
gpio = devm_gpiod_get_index(&pdev->dev, "reset", 0);
|
||||||
if (!rfkill->shutdown_name)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
snprintf(rfkill->reset_name, len + 6 , "%s_reset", rfkill->name);
|
|
||||||
snprintf(rfkill->shutdown_name, len + 9, "%s_shutdown", rfkill->name);
|
|
||||||
|
|
||||||
rfkill->clk = devm_clk_get(&pdev->dev, clk_name);
|
|
||||||
|
|
||||||
gpio = devm_gpiod_get_index(&pdev->dev, rfkill->reset_name, 0);
|
|
||||||
if (!IS_ERR(gpio)) {
|
if (!IS_ERR(gpio)) {
|
||||||
ret = gpiod_direction_output(gpio, 0);
|
ret = gpiod_direction_output(gpio, 0);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -130,7 +113,7 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
|
||||||
rfkill->reset_gpio = gpio;
|
rfkill->reset_gpio = gpio;
|
||||||
}
|
}
|
||||||
|
|
||||||
gpio = devm_gpiod_get_index(&pdev->dev, rfkill->shutdown_name, 1);
|
gpio = devm_gpiod_get_index(&pdev->dev, "shutdown", 1);
|
||||||
if (!IS_ERR(gpio)) {
|
if (!IS_ERR(gpio)) {
|
||||||
ret = gpiod_direction_output(gpio, 0);
|
ret = gpiod_direction_output(gpio, 0);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -146,14 +129,6 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pdata && pdata->gpio_runtime_setup) {
|
|
||||||
ret = pdata->gpio_runtime_setup(pdev);
|
|
||||||
if (ret) {
|
|
||||||
dev_err(&pdev->dev, "can't set up gpio\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rfkill->rfkill_dev = rfkill_alloc(rfkill->name, &pdev->dev,
|
rfkill->rfkill_dev = rfkill_alloc(rfkill->name, &pdev->dev,
|
||||||
rfkill->type, &rfkill_gpio_ops,
|
rfkill->type, &rfkill_gpio_ops,
|
||||||
rfkill);
|
rfkill);
|
||||||
|
@ -174,20 +149,23 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
|
||||||
static int rfkill_gpio_remove(struct platform_device *pdev)
|
static int rfkill_gpio_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct rfkill_gpio_data *rfkill = platform_get_drvdata(pdev);
|
struct rfkill_gpio_data *rfkill = platform_get_drvdata(pdev);
|
||||||
struct rfkill_gpio_platform_data *pdata = pdev->dev.platform_data;
|
|
||||||
|
|
||||||
if (pdata && pdata->gpio_runtime_close)
|
|
||||||
pdata->gpio_runtime_close(pdev);
|
|
||||||
rfkill_unregister(rfkill->rfkill_dev);
|
rfkill_unregister(rfkill->rfkill_dev);
|
||||||
rfkill_destroy(rfkill->rfkill_dev);
|
rfkill_destroy(rfkill->rfkill_dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_ACPI
|
||||||
static const struct acpi_device_id rfkill_acpi_match[] = {
|
static const struct acpi_device_id rfkill_acpi_match[] = {
|
||||||
|
{ "BCM2E1A", RFKILL_TYPE_BLUETOOTH },
|
||||||
|
{ "BCM2E39", RFKILL_TYPE_BLUETOOTH },
|
||||||
|
{ "BCM2E3D", RFKILL_TYPE_BLUETOOTH },
|
||||||
{ "BCM4752", RFKILL_TYPE_GPS },
|
{ "BCM4752", RFKILL_TYPE_GPS },
|
||||||
|
{ "LNV4752", RFKILL_TYPE_GPS },
|
||||||
{ },
|
{ },
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
static struct platform_driver rfkill_gpio_driver = {
|
static struct platform_driver rfkill_gpio_driver = {
|
||||||
.probe = rfkill_gpio_probe,
|
.probe = rfkill_gpio_probe,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче