diff options
| -rw-r--r-- | drivers/extcon/Kconfig | 4 | ||||
| -rw-r--r-- | drivers/extcon/Makefile | 2 | ||||
| -rw-r--r-- | drivers/extcon/extcon-class.c | 42 | ||||
| -rw-r--r-- | drivers/extcon/extcon-gpio.c | 4 | ||||
| -rw-r--r-- | drivers/extcon/extcon-palmas.c | 5 | ||||
| -rw-r--r-- | drivers/extcon/of_extcon.c | 64 | ||||
| -rw-r--r-- | drivers/usb/dwc3/dwc3-omap.c | 3 | ||||
| -rw-r--r-- | include/linux/extcon.h | 12 | ||||
| -rw-r--r-- | include/linux/extcon/of_extcon.h | 31 |
9 files changed, 57 insertions, 110 deletions
diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig index bdb5a00f1dfa..be56e8ac95e6 100644 --- a/drivers/extcon/Kconfig +++ b/drivers/extcon/Kconfig | |||
| @@ -14,10 +14,6 @@ if EXTCON | |||
| 14 | 14 | ||
| 15 | comment "Extcon Device Drivers" | 15 | comment "Extcon Device Drivers" |
| 16 | 16 | ||
| 17 | config OF_EXTCON | ||
| 18 | def_tristate y | ||
| 19 | depends on OF | ||
| 20 | |||
| 21 | config EXTCON_GPIO | 17 | config EXTCON_GPIO |
| 22 | tristate "GPIO extcon support" | 18 | tristate "GPIO extcon support" |
| 23 | depends on GPIOLIB | 19 | depends on GPIOLIB |
diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile index 43eccc0e3448..bf7861ec0906 100644 --- a/drivers/extcon/Makefile +++ b/drivers/extcon/Makefile | |||
| @@ -2,8 +2,6 @@ | |||
| 2 | # Makefile for external connector class (extcon) devices | 2 | # Makefile for external connector class (extcon) devices |
| 3 | # | 3 | # |
| 4 | 4 | ||
| 5 | obj-$(CONFIG_OF_EXTCON) += of_extcon.o | ||
| 6 | |||
| 7 | obj-$(CONFIG_EXTCON) += extcon-class.o | 5 | obj-$(CONFIG_EXTCON) += extcon-class.o |
| 8 | obj-$(CONFIG_EXTCON_GPIO) += extcon-gpio.o | 6 | obj-$(CONFIG_EXTCON_GPIO) += extcon-gpio.o |
| 9 | obj-$(CONFIG_EXTCON_ADC_JACK) += extcon-adc-jack.o | 7 | obj-$(CONFIG_EXTCON_ADC_JACK) += extcon-adc-jack.o |
diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c index 76322330cbd7..7ab21aa6eaa1 100644 --- a/drivers/extcon/extcon-class.c +++ b/drivers/extcon/extcon-class.c | |||
| @@ -31,6 +31,7 @@ | |||
| 31 | #include <linux/extcon.h> | 31 | #include <linux/extcon.h> |
| 32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
| 33 | #include <linux/sysfs.h> | 33 | #include <linux/sysfs.h> |
| 34 | #include <linux/of.h> | ||
| 34 | 35 | ||
| 35 | /* | 36 | /* |
| 36 | * extcon_cable_name suggests the standard cable names for commonly used | 37 | * extcon_cable_name suggests the standard cable names for commonly used |
| @@ -818,6 +819,47 @@ void extcon_dev_unregister(struct extcon_dev *edev) | |||
| 818 | } | 819 | } |
| 819 | EXPORT_SYMBOL_GPL(extcon_dev_unregister); | 820 | EXPORT_SYMBOL_GPL(extcon_dev_unregister); |
| 820 | 821 | ||
| 822 | #ifdef CONFIG_OF | ||
| 823 | /* | ||
| 824 | * extcon_get_edev_by_phandle - Get the extcon device from devicetree | ||
| 825 | * @dev - instance to the given device | ||
| 826 | * @index - index into list of extcon_dev | ||
| 827 | * | ||
| 828 | * return the instance of extcon device | ||
| 829 | */ | ||
| 830 | struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) | ||
| 831 | { | ||
| 832 | struct device_node *node; | ||
| 833 | struct extcon_dev *edev; | ||
| 834 | |||
| 835 | if (!dev->of_node) { | ||
| 836 | dev_err(dev, "device does not have a device node entry\n"); | ||
| 837 | return ERR_PTR(-EINVAL); | ||
| 838 | } | ||
| 839 | |||
| 840 | node = of_parse_phandle(dev->of_node, "extcon", index); | ||
| 841 | if (!node) { | ||
| 842 | dev_err(dev, "failed to get phandle in %s node\n", | ||
| 843 | dev->of_node->full_name); | ||
| 844 | return ERR_PTR(-ENODEV); | ||
| 845 | } | ||
| 846 | |||
| 847 | edev = extcon_get_extcon_dev(node->name); | ||
| 848 | if (!edev) { | ||
| 849 | dev_err(dev, "unable to get extcon device : %s\n", node->name); | ||
| 850 | return ERR_PTR(-ENODEV); | ||
| 851 | } | ||
| 852 | |||
| 853 | return edev; | ||
| 854 | } | ||
| 855 | #else | ||
| 856 | struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) | ||
| 857 | { | ||
| 858 | return ERR_PTR(-ENOSYS); | ||
| 859 | } | ||
| 860 | #endif /* CONFIG_OF */ | ||
| 861 | EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle); | ||
| 862 | |||
| 821 | static int __init extcon_class_init(void) | 863 | static int __init extcon_class_init(void) |
| 822 | { | 864 | { |
| 823 | return create_extcon_class(); | 865 | return create_extcon_class(); |
diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index a63a6b21c9ad..13d522255d81 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c | |||
| @@ -176,9 +176,7 @@ static int gpio_extcon_resume(struct device *dev) | |||
| 176 | } | 176 | } |
| 177 | #endif | 177 | #endif |
| 178 | 178 | ||
| 179 | static const struct dev_pm_ops gpio_extcon_pm_ops = { | 179 | static SIMPLE_DEV_PM_OPS(gpio_extcon_pm_ops, NULL, gpio_extcon_resume); |
| 180 | SET_SYSTEM_SLEEP_PM_OPS(NULL, gpio_extcon_resume) | ||
| 181 | }; | ||
| 182 | 180 | ||
| 183 | static struct platform_driver gpio_extcon_driver = { | 181 | static struct platform_driver gpio_extcon_driver = { |
| 184 | .probe = gpio_extcon_probe, | 182 | .probe = gpio_extcon_probe, |
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c index 2aea4bcdd7f3..ddff2b72f0a8 100644 --- a/drivers/extcon/extcon-palmas.c +++ b/drivers/extcon/extcon-palmas.c | |||
| @@ -271,10 +271,7 @@ static int palmas_usb_resume(struct device *dev) | |||
| 271 | }; | 271 | }; |
| 272 | #endif | 272 | #endif |
| 273 | 273 | ||
| 274 | static const struct dev_pm_ops palmas_pm_ops = { | 274 | static SIMPLE_DEV_PM_OPS(palmas_pm_ops, palmas_usb_suspend, palmas_usb_resume); |
| 275 | SET_SYSTEM_SLEEP_PM_OPS(palmas_usb_suspend, | ||
| 276 | palmas_usb_resume) | ||
| 277 | }; | ||
| 278 | 275 | ||
| 279 | static struct of_device_id of_palmas_match_tbl[] = { | 276 | static struct of_device_id of_palmas_match_tbl[] = { |
| 280 | { .compatible = "ti,palmas-usb", }, | 277 | { .compatible = "ti,palmas-usb", }, |
diff --git a/drivers/extcon/of_extcon.c b/drivers/extcon/of_extcon.c deleted file mode 100644 index 72173ecbb311..000000000000 --- a/drivers/extcon/of_extcon.c +++ /dev/null | |||
| @@ -1,64 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * OF helpers for External connector (extcon) framework | ||
| 3 | * | ||
| 4 | * Copyright (C) 2013 Texas Instruments, Inc. | ||
| 5 | * Kishon Vijay Abraham I <kishon@ti.com> | ||
| 6 | * | ||
| 7 | * Copyright (C) 2013 Samsung Electronics | ||
| 8 | * Chanwoo Choi <cw00.choi@samsung.com> | ||
| 9 | * | ||
| 10 | * This program is free software; you can redistribute it and/or modify | ||
| 11 | * it under the terms of the GNU General Public License as published by | ||
| 12 | * the Free Software Foundation; either version 2 of the License, or | ||
| 13 | * (at your option) any later version. | ||
| 14 | */ | ||
| 15 | |||
| 16 | #include <linux/module.h> | ||
| 17 | #include <linux/slab.h> | ||
| 18 | #include <linux/err.h> | ||
| 19 | #include <linux/extcon.h> | ||
| 20 | #include <linux/of.h> | ||
| 21 | #include <linux/of_platform.h> | ||
| 22 | #include <linux/extcon/of_extcon.h> | ||
| 23 | |||
| 24 | /* | ||
| 25 | * of_extcon_get_extcon_dev - Get the name of extcon device from devicetree | ||
| 26 | * @dev - instance to the given device | ||
| 27 | * @index - index into list of extcon_dev | ||
| 28 | * | ||
| 29 | * return the instance of extcon device | ||
| 30 | */ | ||
| 31 | struct extcon_dev *of_extcon_get_extcon_dev(struct device *dev, int index) | ||
| 32 | { | ||
| 33 | struct device_node *node; | ||
| 34 | struct extcon_dev *edev; | ||
| 35 | struct platform_device *extcon_parent_dev; | ||
| 36 | |||
| 37 | if (!dev->of_node) { | ||
| 38 | dev_dbg(dev, "device does not have a device node entry\n"); | ||
| 39 | return ERR_PTR(-EINVAL); | ||
| 40 | } | ||
| 41 | |||
| 42 | node = of_parse_phandle(dev->of_node, "extcon", index); | ||
| 43 | if (!node) { | ||
| 44 | dev_dbg(dev, "failed to get phandle in %s node\n", | ||
| 45 | dev->of_node->full_name); | ||
| 46 | return ERR_PTR(-ENODEV); | ||
| 47 | } | ||
| 48 | |||
| 49 | extcon_parent_dev = of_find_device_by_node(node); | ||
| 50 | if (!extcon_parent_dev) { | ||
| 51 | dev_dbg(dev, "unable to find device by node\n"); | ||
| 52 | return ERR_PTR(-EPROBE_DEFER); | ||
| 53 | } | ||
| 54 | |||
| 55 | edev = extcon_get_extcon_dev(dev_name(&extcon_parent_dev->dev)); | ||
| 56 | if (!edev) { | ||
| 57 | dev_dbg(dev, "unable to get extcon device : %s\n", | ||
| 58 | dev_name(&extcon_parent_dev->dev)); | ||
| 59 | return ERR_PTR(-ENODEV); | ||
| 60 | } | ||
| 61 | |||
| 62 | return edev; | ||
| 63 | } | ||
| 64 | EXPORT_SYMBOL_GPL(of_extcon_get_extcon_dev); | ||
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index b269dbd47fc4..b1d7ee6e40b7 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c | |||
| @@ -29,7 +29,6 @@ | |||
| 29 | #include <linux/of.h> | 29 | #include <linux/of.h> |
| 30 | #include <linux/of_platform.h> | 30 | #include <linux/of_platform.h> |
| 31 | #include <linux/extcon.h> | 31 | #include <linux/extcon.h> |
| 32 | #include <linux/extcon/of_extcon.h> | ||
| 33 | #include <linux/regulator/consumer.h> | 32 | #include <linux/regulator/consumer.h> |
| 34 | 33 | ||
| 35 | #include <linux/usb/otg.h> | 34 | #include <linux/usb/otg.h> |
| @@ -522,7 +521,7 @@ static int dwc3_omap_probe(struct platform_device *pdev) | |||
| 522 | dwc3_omap_enable_irqs(omap); | 521 | dwc3_omap_enable_irqs(omap); |
| 523 | 522 | ||
| 524 | if (of_property_read_bool(node, "extcon")) { | 523 | if (of_property_read_bool(node, "extcon")) { |
| 525 | edev = of_extcon_get_extcon_dev(dev, 0); | 524 | edev = extcon_get_edev_by_phandle(dev, 0); |
| 526 | if (IS_ERR(edev)) { | 525 | if (IS_ERR(edev)) { |
| 527 | dev_vdbg(dev, "couldn't get extcon device\n"); | 526 | dev_vdbg(dev, "couldn't get extcon device\n"); |
| 528 | ret = -EPROBE_DEFER; | 527 | ret = -EPROBE_DEFER; |
diff --git a/include/linux/extcon.h b/include/linux/extcon.h index 21c59af1150b..f488145bb2d4 100644 --- a/include/linux/extcon.h +++ b/include/linux/extcon.h | |||
| @@ -240,6 +240,12 @@ extern int extcon_register_notifier(struct extcon_dev *edev, | |||
| 240 | struct notifier_block *nb); | 240 | struct notifier_block *nb); |
| 241 | extern int extcon_unregister_notifier(struct extcon_dev *edev, | 241 | extern int extcon_unregister_notifier(struct extcon_dev *edev, |
| 242 | struct notifier_block *nb); | 242 | struct notifier_block *nb); |
| 243 | |||
| 244 | /* | ||
| 245 | * Following API get the extcon device from devicetree. | ||
| 246 | * This function use phandle of devicetree to get extcon device directly. | ||
| 247 | */ | ||
| 248 | extern struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index); | ||
| 243 | #else /* CONFIG_EXTCON */ | 249 | #else /* CONFIG_EXTCON */ |
| 244 | static inline int extcon_dev_register(struct extcon_dev *edev) | 250 | static inline int extcon_dev_register(struct extcon_dev *edev) |
| 245 | { | 251 | { |
| @@ -324,5 +330,11 @@ static inline int extcon_unregister_interest(struct extcon_specific_cable_nb | |||
| 324 | { | 330 | { |
| 325 | return 0; | 331 | return 0; |
| 326 | } | 332 | } |
| 333 | |||
| 334 | static inline struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, | ||
| 335 | int index) | ||
| 336 | { | ||
| 337 | return ERR_PTR(-ENODEV); | ||
| 338 | } | ||
| 327 | #endif /* CONFIG_EXTCON */ | 339 | #endif /* CONFIG_EXTCON */ |
| 328 | #endif /* __LINUX_EXTCON_H__ */ | 340 | #endif /* __LINUX_EXTCON_H__ */ |
diff --git a/include/linux/extcon/of_extcon.h b/include/linux/extcon/of_extcon.h deleted file mode 100644 index 0ebfeff1b55d..000000000000 --- a/include/linux/extcon/of_extcon.h +++ /dev/null | |||
| @@ -1,31 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * OF helpers for External connector (extcon) framework | ||
| 3 | * | ||
| 4 | * Copyright (C) 2013 Texas Instruments, Inc. | ||
| 5 | * Kishon Vijay Abraham I <kishon@ti.com> | ||
| 6 | * | ||
| 7 | * Copyright (C) 2013 Samsung Electronics | ||
| 8 | * Chanwoo Choi <cw00.choi@samsung.com> | ||
| 9 | * | ||
| 10 | * This program is free software; you can redistribute it and/or modify | ||
| 11 | * it under the terms of the GNU General Public License as published by | ||
| 12 | * the Free Software Foundation; either version 2 of the License, or | ||
| 13 | * (at your option) any later version. | ||
| 14 | */ | ||
| 15 | |||
| 16 | #ifndef __LINUX_OF_EXTCON_H | ||
| 17 | #define __LINUX_OF_EXTCON_H | ||
| 18 | |||
| 19 | #include <linux/err.h> | ||
| 20 | |||
| 21 | #if IS_ENABLED(CONFIG_OF_EXTCON) | ||
| 22 | extern struct extcon_dev | ||
| 23 | *of_extcon_get_extcon_dev(struct device *dev, int index); | ||
| 24 | #else | ||
| 25 | static inline struct extcon_dev | ||
| 26 | *of_extcon_get_extcon_dev(struct device *dev, int index) | ||
| 27 | { | ||
| 28 | return ERR_PTR(-ENOSYS); | ||
| 29 | } | ||
| 30 | #endif /* CONFIG_OF_EXTCON */ | ||
| 31 | #endif /* __LINUX_OF_EXTCON_H */ | ||
