summaryrefslogtreecommitdiff
path: root/drivers/extcon/extcon-palmas.c
AgeCommit message (Collapse)Author
2017-04-06extcon: palmas: Don't miss GPIO events during suspend/resumeRoger Quadros
The USB cable state can change during suspend/resume so be sure to check and update the extcon state. Signed-off-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-25extcon: palmas: Use dev_dbg macro for the debug messagesRoger Quadros
User is not interested in USB cable events appearing on the console. Use dev_dbg() instead of dev_info() for these events. Signed-off-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2017-01-09extcon: palmas: Check the parent instance to prevent the NULLRoger Quadros
extcon-palmas must be child of palmas and expects parent's drvdata to be valid. Check for non NULL parent drvdata and fail if it is NULL. Not doing so will result in a NULL pointer dereference later in the probe() parent drvdata is NULL (e.g. misplaced extcon-palmas node in device tree). Signed-off-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-09-13extcon: Use the extcon_set_state_sync() instead of deprecated functionsChanwoo Choi
This patch alters the renamed extcon API to set the state of the external connectors instead of deprecated extcon_set_cable_state_(). Because the patch[1] modifies the function name to maintain the function naming pattern. - extcon_set_cable_state_() -> extcon_set_state_sync() - extcon_get_cable_state_() -> extcon_get_state() [1] https://lkml.org/lkml/2016/8/4/729 - extcon: Rename the extcon_set/get_state() to maintain the function naming pattern Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Acked-by: Roger Quadros <rogerq@ti.com>
2016-06-15extcon: palmas: Fix boot up state of VBUS when using GPIO detectionRoger Quadros
If USB cable is connected prior to boot, we don't get any interrupts so we must manually check the VBUS state and report it during probe. If we don't do it then USB controller will never know that peripheral cable was connected till the user unplugs and replugs the cable. Fixes: b7aad8e2685b ("extcon: palmas: Add the support for VBUS detection by using GPIO") Cc: stable@vger.kernel.org Signed-off-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-04-04extcon: palmas: Drop stray IRQF_EARLY_RESUME flagNishanth Menon
Palmas extcon IRQs are nested threaded and wired to the Palmas interrupt controller. So, this flag is not required for nested IRQs anymore, since commit 3c646f2c6aa9 ("genirq: Don't suspend nested_thread irqs over system suspend") was merged. However, the fix in commit ae64e42cc2b3 ("extcon: palmas: Drop IRQF_EARLY_RESUME flag") missed a stray flag causing the following crash on resume on BeagleBoard-X15 platform: [ 53.670141] Unhandled fault: imprecise external abort (0x1406) at 0x00000000 [..] [ 53.670141] [<c04ae734>] (omap_set_gpio_triggering) from [<c04aeb94>] (omap_gpio_unmask_irq+0xc0/0xc4) [ 53.670141] [<c04aeb94>] (omap_gpio_unmask_irq) from [<c01a0b88>] (irq_enable+0x30/0x44) [ 53.670141] [<c01a0b88>] (irq_enable) from [<c019ebd8>] (__enable_irq+0x54/0x78) [ 53.670141] [<c019ebd8>] (__enable_irq) from [<c01a4e60>] (resume_irqs+0xe8/0x100) [ 53.670141] [<c01a4e60>] (resume_irqs) from [<c0514840>] (syscore_resume+0x94/0x298) [ 53.670141] [<c0514840>] (syscore_resume) from [<c01981cc>] (suspend_devices_and_enter+0x790/0x9e4) [ 53.670141] [<c01981cc>] (suspend_devices_and_enter) from [<c0198a60>] (pm_suspend+0x640/0x75c) [ 53.670141] [<c0198a60>] (pm_suspend) from [<c0196bec>] (state_store+0x64/0xb8) [ 53.670141] [<c0196bec>] (state_store) from [<c0307944>] (kernfs_fop_write+0xc0/0x1bc) [ 53.670141] [<c0307944>] (kernfs_fop_write) from [<c028acb0>] (__vfs_write+0x1c/0xd8) [ 53.670141] [<c028acb0>] (__vfs_write) from [<c028bba0>] (vfs_write+0x90/0x16c) [ 53.670141] [<c028bba0>] (vfs_write) from [<c028c8c0>] (SyS_write+0x44/0x9c) [ 53.670141] [<c028c8c0>] (SyS_write) from [<c0107840>] (ret_fast_syscall+0x0/0x1c) [..] Fixes: ae64e42cc2b3 ("extcon: palmas: Drop IRQF_EARLY_RESUME flag") Cc: Grygorii Strashko <grygorii.strashko@ti.com> Cc: MyungJoo Ham <myungjoo.ham@samsung.com> Cc: Chanwoo Choi <cw00.choi@samsung.com> Cc: Tony Lindgren <tony@atomide.com> Cc: Lee Jones <lee.jones@linaro.org> Cc: Roger Quadros <rogerq@ti.com> Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com> Signed-off-by: Nishanth Menon <nm@ti.com> Acked-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-02-29extcon: palmas: Drop IRQF_EARLY_RESUME flagGrygorii Strashko
Palams extcon IRQs are nested threaded and wired to the Palmas inerrupt controller. So, this flag is not required for nested irqs anymore, since commit 3c646f2c6aa9 ("genirq: Don't suspend nested_thread irqs over system suspend") was merged. Cc: MyungJoo Ham <myungjoo.ham@samsung.com> Cc: Chanwoo Choi <cw00.choi@samsung.com> Cc: Tony Lindgren <tony@atomide.com> Cc: Lee Jones <lee.jones@linaro.org> Cc: Roger Quadros <rogerq@ti.com> Cc: Nishanth Menon <nm@ti.com> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2016-02-05extcon: palmas: Add the support for VBUS detection by using GPIOFelipe Balbi
This patch support for VBUS detection by using GPIO pin. Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Acked-by: Lee Jones <lee.jones@linaro.org>
2015-08-13extcon: palmas: Fix build break due to devm_gpiod_get_optional API changeChanwoo Choi
With commit b17d1bf16cc7 ("gpio: make flags mandatory for gpiod_get functions") it becomes necessary to pass the flags argument. And this patch adds the gpio header file to fix the build breakage when build testing with random configuration files. Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2015-08-10extcon: palmas: Support GPIO based USB ID detectionRoger Quadros
Some palmas based chip variants do not have OTG based ID logic. For these variants we rely on GPIO based USB ID detection. These chips do have VBUS comparator for VBUS detection so we continue to use the old way of detecting VBUS. Signed-off-by: Roger Quadros <rogerq@ti.com> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Acked-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-08-10extcon: palmas: Remove the mutually_exclusive arrayChanwoo Choi
This patch removes the mutually_exclusive array of extcon-palmas.c. After used the unique id of each external connector on 2a9de9c0f08d ("extcon: Use the unique id for external connector instead of string"), extcon driver can't directly handle the bit value indicating the external connectors. Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2015-07-29extcon: palmas: Fix NULL pointer errorChanwoo Choi
This patch fixes NULL pointer error by removing the unneeded kfree() call of edev->name because extcon-palmas no longer allocate the memory for edev->name. Fixes: d71aadda19f8 ("extcon: Remove the optional name of extcon device") Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
2015-06-12extcon: Redefine the unique id of supported external connectors without ↵Chanwoo Choi
'enum extcon' type This patch just redefine the unique id of supported external connectors without 'enum extcon' type. Because unique id would be used on devictree file(*.dts) to indicate the specific external connectors like key number of input framework. So, I have the plan to move this definitions to following header file which includes the unique id of supported external connectors. - include/dt-bindings/extcon/extcon.h Fixes: 2a9de9c0f08d ("extcon: Use the unique id for external connector instead of string") Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-05-22extcon: Use the unique id for external connector instead of stringChanwoo Choi
This patch uses the unique id to identify the type of external connector instead of string name. The string name have the many potential issues. So, this patch defines the 'extcon' enumeration which includes all supported external connector on EXTCON subsystem. If new external connector is necessary, the unique id of new connector have to be added in 'extcon' enumeration. There are current supported external connector in 'enum extcon' as following: enum extcon { EXTCON_NONE = 0x0, /* USB external connector */ EXTCON_USB = 0x1, EXTCON_USB_HOST = 0x2, /* Charger external connector */ EXTCON_TA = 0x10, EXTCON_FAST_CHARGER = 0x11, EXTCON_SLOW_CHARGER = 0x12, EXTCON_CHARGE_DOWNSTREAM = 0x13, /* Audio and video external connector */ EXTCON_LINE_IN = 0x20, EXTCON_LINE_OUT = 0x21, EXTCON_MICROPHONE = 0x22, EXTCON_HEADPHONE = 0x23, EXTCON_HDMI = 0x30, EXTCON_MHL = 0x31, EXTCON_DVI = 0x32, EXTCON_VGA = 0x33, EXTCON_SPDIF_IN = 0x34, EXTCON_SPDIF_OUT = 0x35, EXTCON_VIDEO_IN = 0x36, EXTCON_VIDEO_OUT = 0x37, /* Miscellaneous external connector */ EXTCON_DOCK = 0x50, EXTCON_JIG = 0x51, EXTCON_MECHANICAL = 0x52, EXTCON_END, }; For example in extcon-arizona.c: To use unique id removes the potential issue about handling the inconsistent name of external connector with string. - Previously, use the string to register the type of arizona jack connector static const char *arizona_cable[] = { "Mechanical", "Microphone", "Headphone", "Line-out", }; - Newly, use the unique id to register the type of arizona jack connector static const enum extcon arizona_cable[] = { EXTCON_MECHANICAL, EXTCON_MICROPHONE, EXTCON_HEADPHONE, EXTCON_LINE_OUT, EXTCON_NONE, }; And this patch modify the prototype of extcon_{get|set}_cable_state_() which uses the 'enum extcon id' instead of 'cable_index'. Because although one more extcon drivers support USB cable, each extcon driver might has the differnt 'cable_index' for USB cable. All extcon drivers can use the unique id number for same external connector with modified extcon_{get|set}_cable_state_(). - Previously, use 'cable_index' on these functions: extcon_get_cable_state_(struct extcon_dev*, int cable_index) extcon_set_cable_state_(struct extcon_dev*, int cable_index, bool state) -Newly, use 'enum extcon id' on these functions: extcon_get_cable_state_(struct extcon_dev*, enum extcon id) extcon_set_cable_state_(struct extcon_dev*, enum extcon id, bool state) Cc: Arnd Bergmann <arnd@arndb.de> Cc: Felipe Balbi <balbi@ti.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Acked-by: Roger Quadros <rogerq@ti.com> Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Acked-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> [arnd: Report the build break about drivers/usb/phy/phy-tahvo.c after using the unique id for external connector insteadf of string] Reported-by: Arnd Bergmann <arnd@arndb.de> [dan.carpenter: Report the build warning of extcon_{set|get}_cable_state_()] Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
2015-05-19extcon: Remove the optional name of extcon deviceChanwoo Choi
This patch removes the optional name of extcon device. Instead, extcon_dev_register() set the device name as 'extcon[number]' naming pattern. - /sys/class/extcon/[hardcoded device name] -> /sys/class/extcon/extcon[number] Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Acked-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Cc: MyungJoo Ham <myungjoo.ham@samsung.com> Cc: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Cc: Graeme Gregory <gg@slimlogic.co.uk> Cc: Kishon Vijay Abraham I <kishon@ti.com> Cc: Krzysztof Kozlowski <k.kozlowski@samsung.com> Cc: Jaewon Kim <jaewon02.kim@samsung.com>
2014-10-20extcon: drop owner assignment from platform_driversWolfram Sang
A platform_driver does not need to set an owner, it will be populated by the driver core. Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2014-06-16extcon: Set parent device of extcon device using prameter of ↵Chanwoo Choi
devm_extcon_dev_allocate This patch set the parent device of extcon device using first parameter of devm_extco_dev_allocate() to remove duplicate code on all of extcon provider drivers. Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Reported-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Tested-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Cc: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Cc: Mark Brown <broonie@kernel.org> Cc: Graeme Gregory <gg@slimlogic.co.uk> Cc: Kishon Vijay Abraham I <kishon@ti.com> Cc: Krzysztof Kozlowski <k.kozlowski@samsung.com>
2014-06-16extcon: palmas: Make of_device_id array constKrzysztof Kozlowski
Array of struct of_device_id may be be const as expected by of_match_table field. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Cc: Graeme Gregory <gg@slimlogic.co.uk> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2014-04-29extcon: palmas: Use devm_extcon_dev_allocate for extcon_devChanwoo Choi
This patch use devm_extcon_dev_allocate() to simplify the memory control of extcon device. Cc: Graeme Gregory <gg@slimlogic.co.uk> Cc: Kishon Vijay Abraham I <kishon@ti.com> Cc: Felipe Balbi <balbi@ti.com> Cc: Samuel Ortiz <sameo@linux.intel.com> Cc: Lee Jones <lee.jones@linaro.org> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Acked-by: Lee Jones <lee.jones@linaro.org> Acked-by: Felipe Balbi <balbi@ti.com> Tested-by: Felipe Balbi <balbi@ti.com>
2014-04-24extcon: palmas: Use devm_extcon_dev_register()Sangjung Woo
Use the resource-managed extcon device register function (i.e. devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device is attached with this function, that extcon device is automatically unregistered on driver detach. That reduces tiresome managing code. Signed-off-by: Sangjung Woo <sangjung.woo@samsung.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2014-04-22extcon: palmas: explicitly set edev name as node nameKishon Vijay Abraham I
commit ca488 (extcon: of: Remove unnecessary function call by using the name of device_node) started using node name instead of device name to get the extcon device. This breaks dwc3-omap since it's not able to get the extcon device anymore. Fixed it by setting edev name of palmas to be the same as its node name. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Reported-by: Felipe Balbi <balbi@ti.com> Reviewed-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2014-03-19extcon: palmas: Use SIMPLE_DEV_PM_OPS macroJingoo Han
Use SIMPLE_DEV_PM_OPS macro in order to make the code simpler. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2014-01-07extcon: palmas: Handle ID interrupt properly using USB_ID_INT_SRCGeorge Cherian
Always cross check with the ID state and the source of interrupt. Also add a case in which ID Source is ID_GND but LATCH state is set wrongly. This uses the previous Link stat to determine the new state. Signed-off-by: George Cherian <george.cherian@ti.com> Acked-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2014-01-07extcon: palmas: Added a new compatible type *ti,palmas-usb-vid*Kishon Vijay Abraham I
The Palmas device contains only a USB VBUS-ID detector, so added a compatible type *ti,palmas-usb-vid*. Didn't remove the existing compatible types for backward compatibility. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2013-09-27extcon: Simplify extcon_dev_register() prototype by removing unnecessary ↵Chanwoo Choi
parameter This patch remove extcon_dev_register()'s second parameter which means the pointer of parent device to simplify prototype of this function. So, if extcon device has the parent device, it should set the pointer of parent device to edev.dev.parent in extcon device driver instead of in extcon_dev_register(). Cc: Graeme Gregory <gg@slimlogic.co.uk> Cc: Kishon Vijay Abraham I <kishon@ti.com> Cc: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Cc: Mark Brown <broonie@kernel.org> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
2013-09-27extcon: use dev_get_platdata()Jingoo Han
Use the wrapper function for retrieving the platform data instead of accessing dev->platform_data directly. This is a cosmetic change to make the code simpler and enhance the readability. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
2013-08-05extcon: palmas: Option to disable ID/VBUS detection based on platformLaxman Dewangan
Based on system design, platform needs to detect the VBUS or ID or both. Provide option to select this through platform data to disable part of cable detection through palmas-usb. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Acked-by: Graeme Gregory <gg@slimlogic.co.uk> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
2013-08-05extcon: palams: add support for suspend/resumeLaxman Dewangan
Add suspend/resume callbacks and support for wakeup from suspend on USB HOST or USB Device cable insertion or removal. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Acked-by: Graeme Gregory <gg@slimlogic.co.uk> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
2013-08-05extcon: palmas: enable ID_GND and ID_FLOAT detection alwaysLaxman Dewangan
When integrating driver with Tegra platform, it is found that the ID pins get detected only once after booting system and further removal and re-insert does not detect the ID pin. Fixing this issue with enabling interrupt on ID_GND and ID_FLOAT always and clearing the status on LATCH register which actually occurred. Also if interrupt occurs with line status as zero then based on previous status, set the cable state. Add debug prints to display the cable state when any cable insertion/removal happen. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Acked-by: Graeme Gregory <gg@slimlogic.co.uk> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
2013-08-05extcon: palmas: remove assigning "edev.name" to palmasKishon Vijay Abraham I
of_extcon_get_extcon_dev() uses dev_name for getting the reference to the extcon device. If the extcon driver assigns a different name other than dev_name, of_extcon_get_extcon_dev() wouldn't be able to find the reference to the extcon device. Since the client drivers of extcon-palmas would be using of_extcon_get_extcon_dev(), removed assigning edev.name in extcon-palmas. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
2013-06-17extcon: Palmas Extcon DriverGraeme Gregory
This is the driver for the USB comparator built into the palmas chip. It handles the various USB OTG events that can be generated by cable insertion/removal. Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk> Signed-off-by: Moiz Sonasath <m-sonasath@ti.com> Signed-off-by: Ruchika Kharwar <ruchika@ti.com> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: George Cherian <george.cherian@ti.com> [kishon@ti.com: adapted palmas usb driver to use the extcon framework] Signed-off-by: Sebastien Guiriec <s-guiriec@ti.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>