aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/phy/phy-generic.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-01-15usb: phy-generic: Delete unused platform dataLinus Walleij1-27/+12
The last user of the phy generic platform data was deleted in commit 1e041b6f313aaa966612a7e415cfc09c90d6b829 ("usb: dwc3: exynos: Remove dead code"). So get rid of the platform data, which rids us of another consumer of the legacy GPIO API at the same time. Make sure we only inlcude <linux/gpio/consumer.h> which is all we use. Alter the usb_phy_gen_create_phy() function prototype to not pass any platform data as this is just hardcoded to NULL at all locations calling it in the kernel. Move the devm_gpiod_get* calls out of the if (of_node) parenthesis, as these calls are generic and do not depend on device tree, they are used by any hardware description. Cc: Marek Szyprowski <m.szyprowski@samsung.com> Cc: Felipe Balbi <balbi@kernel.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Felipe Balbi <balbi@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-13usb: phy-generic: Use gpiod_set_value_cansleepMike Looijmans1-3/+3
The nop_reset and shutdown methods are called in a context that can sleep, so use gpiod_set_value_cansleep instead of gpiod_set_value. If you've connected the reset line to a GPIO expander, you'd get a kernel "slowpath" warning with gpiod_set_value. Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-11-07USB: phy: Remove redundant license textGreg Kroah-Hartman1-14/+0
Now that the SPDX tag is in all USB files, that identifies the license in a specific and legally-defined manner. So the extra GPL text wording can be removed as it is no longer needed at all. This is done on a quest to remove the 700+ different ways that files in the kernel describe the GPL license text. And there's unneeded stuff like the address (sometimes incorrect) for the FSF which is never needed. No copyright headers or other non-license-description text was removed. Cc: Thierry Reding <thierry.reding@gmail.com> Cc: Jonathan Hunter <jonathanh@nvidia.com> Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-04USB: add SPDX identifiers to all remaining files in drivers/usb/Greg Kroah-Hartman1-0/+1
It's good to have SPDX identifiers in all files to make it easier to audit the kernel tree for correct licenses. Update the drivers/usb/ and include/linux/usb* files with the correct SPDX license identifier based on the license text in the file itself. The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. This work is based on a script and data from Thomas Gleixner, Philippe Ombredanne, and Kate Stewart. Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Kate Stewart <kstewart@linuxfoundation.org> Cc: Philippe Ombredanne <pombredanne@nexb.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com> Acked-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-19usb: phy: phy-generic: propagate clk_get error if clock is requiredLucas Stach1-1/+4
If the clock handle is given in the DT, it means the clock is required for proper operation of the PHY. In that case a failure to obtain the clock must be propagated to stop the driver from probing. This fixes working with clocks, which request probe deferral. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2016-11-18usb: phy: phy-generic: add the implementation of .set_suspendPeter Chen1-0/+9
Add clock operation at .set_suspend if the PHY has suspend requirement, it can be benefit of power saving for phy and the whole system (parent clock may also be disabled). Signed-off-by: Peter Chen <peter.chen@nxp.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2016-09-14Merge tag 'usb-for-v4.9' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-nextGreg Kroah-Hartman1-5/+4
Felipe writes: usb: patches for v4.9 merge window This time around we have 92 non-merge commits. Most of the changes are in drivers/usb/gadget (40.3%) with drivers/usb/gadget/function being the most active directory (27.2%). As for UDC drivers, only dwc3 (26.5%) and dwc2 (12.7%) have really been active. The most important changes for dwc3 are better support for scatterlist and, again, throughput improvements. While on dwc2 got some minor stability fixes related to soft reset and FIFO usage. Felipe Tonello has done some good work fixing up our f_midi gadget and Tal Shorer has implemented a nice API change for our ULPI bus. Apart from these, we have our usual set of non-critical fixes, spelling fixes, build warning fixes, etc.
2016-09-05usb: phy: phy-generic: Check clk_prepare_enable() errorFabio Estevam1-2/+6
clk_prepare_enable() may fail, so we should better check its return value and propagate it in the case of failure. Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2016-08-25usb: phy: generic: remove the vbus dependencyRobert Jarzmik1-5/+2
As the last known user, ie. pxa27x_udc relying on calls to usb_gadget_xxx() was amended to use the phy notifier, remove a bit the USB stack adherence. Actually the driver still uses the gadget API for structures definition, but the implementation of USB gadget specific function usb_gadget_*() is not necessary anymore. Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2016-08-25usb: phy: generic: cope with initial stateRobert Jarzmik1-0/+2
In the gpio based case, the status of the phy is known at start by reading the VBus gpio. Actually, this is a fix, as this initial state, when not set up, prevents a gadget to answer to the enumeration phase, as there is no notification in this case (the VBus is already high when kernel boots) so no interrupt is triggered, and the flow is : - gadget initializes - gadget gets its phy-generic with a xxx_get_phy_xxx() call type - gadget does a "set_peripheral()" call type => here if the otg->state is correctly filled, the proper vbus handling will be called, and the gadget will be aware it should answer enumeration and go forth Without this fix, the USB cable must be removed and replugged for any gadget relying on phy-generic and its gpio vbus handling to work. The problem was seen on a pxa27x architecture based board on a devicetree build. Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2016-03-04usb: phy: generic: Handle late registration of gadgetMaarten ter Huurne1-3/+8
It is possible for the VBUS detect GPIO interrupt to occur before nop_set_peripheral() is called, in which case otg->gadget is NULL. Signed-off-by: Maarten ter Huurne <maarten@treewalker.org> Signed-off-by: Felipe Balbi <balbi@kernel.org>
2015-09-14usb: phy: phy-generic: Fix reset behaviour on legacy bootRoger Quadros1-1/+2
The gpio-desc migration done in v4.0 caused a regression with legacy boots due to reversed reset logic. e.g. omap3-beagle USB host breaks on legacy boot. Request the reset GPIO with GPIOF_ACTIVE_LOW flag so that it matches the driver logic and pin behaviour. Fixes: e9f2cefb0cdc ("usb: phy: generic: migrate to gpio_desc") Cc: <stable@vger.kernel.org> # 4.0+ Tested-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-07-29usb: pass flags parameter to gpiod_get functionsUwe Kleine-König1-2/+4
Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions) which appeared in v3.17-rc1, the gpiod_get* functions take an additional parameter that allows to specify direction and initial value for output. Currently this parameter is made optional with the help of a cpp trick. To allow dropping this hack convert callers to explictly pass a value for flags. Acked-by: Felipe Balbi <balbi@ti.com> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-03-11usb: phy: phy-generic: No need to call gpiod_direction_output() twiceFabio Estevam1-7/+5
Commit 9eb0797722895f4309b4 ("usb: phy: generic: fix the gpios to be optional") calls gpiod_direction_output() in the probe function, so there is no need to call it again, as we can simply call gpiod_set_value() directly. Also, in usb_gen_phy_shutdown() we can simply put the GPIO directly in its active level state and this allows us to simplify the nop_reset function to treat only the reset case. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-30usb: phy: phy-generic: Fix USB PHY gpio resetFabio Estevam1-4/+5
Since commit e9f2cefb0cdc2ae ("usb: phy: generic: migrate to gpio_desc") a kernel hang is observed on imx51-babbage board: [ 1.392824] ci_hdrc ci_hdrc.1: doesn't support gadget [ 1.397975] ci_hdrc ci_hdrc.1: EHCI Host Controller [ 1.403205] ci_hdrc ci_hdrc.1: new USB bus registered, assigned bus number 1 [ 1.422335] ci_hdrc ci_hdrc.1: USB 2.0 started, EHCI 1.00 [ 1.432962] hub 1-0:1.0: USB hub found [ 1.437119] hub 1-0:1.0: 1 port detected This hang happens because the reset GPIO stays at logic level 0. The USB PHY reset gpio is defined in the dts file as: reset-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>; , which means it is active low, so what the gpio reset pin needs to do in this case is the following: - Go to logic level 0 to reset the USB PHY - Stay at 0 for a bit - Go back to logic level 1 When switching to gpiod API we need to following according to Documentation/gpio/consumer.txt: "The first thing a driver must do with a GPIO is setting its direction. If no direction-setting flags have been given to gpiod_get*(), this is done by invoking one of the gpiod_direction_*() functions: int gpiod_direction_input(struct gpio_desc *desc) int gpiod_direction_output(struct gpio_desc *desc, int value)" Since no direction-setting flags have been given to devm_gpiod_get_optional() in our case, we need to use gpiod_direction_output to comply with the gpiod API. With this change the USB PHY reset performs a proper reset, the kernel boots fine and USB host is functional. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-30usb: phy: generic: fix the vbus interrupt requestRobert Jarzmik1-1/+2
Declare the interrupt as "one shot" so that it is masked until the end of the threaded handler. This prevents the irq core from spitting out an error : "Threaded irq requested with handler=NULL and !ONESHOT for irq 63" This was introduced by commit "usb: phy: generic: add vbus support". Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-30usb: phy: generic: fix the gpios to be optionalRobert Jarzmik1-5/+7
All the gpios, ie. reset-gpios and vbus-detect-gpio, should be optional and not prevent the driver from working. Fix the regression in the behavior introduced by commit "usb: phy: generic: migrate to gpio_desc". Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Tested-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-19usb: phy: make GPIOs optional for the generic phyPaul Zimmerman1-2/+2
The use of GPIOs should be optional for the generic phy, otherwise the Altera SOCFPGA platform at least is broken. Fixes breakage caused by a combination of e9f2cefb0cd "usb: phy: generic: migrate to gpio_desc" and 135b3c4304d "usb: dwc2: platform: add generic PHY framework support". Reviewed-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Paul Zimmerman <paulz@synopsys.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12usb: phy: generic: add vbus supportRobert Jarzmik1-1/+90
Add support for vbus detection and power supply. This code is more or less stolen from phy-gpio-vbus-usb.c, and aims at providing a detection mechanism for VBus (ie. usb cable plug) based on a GPIO line, and a power supply activation which draws current from the VBus. [ balbi@ti.com : fix build break ] Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12usb: phy: generic: migrate to gpio_descRobert Jarzmik1-42/+19
Change internal gpio handling from integer gpios into gpio descriptors. This change only addresses the internal API and device-tree/ACPI, while the legacy platform data remains integer space based. This change is only build compile tested, and very prone to error. I leave this comment for now in the commit message so that this patch gets some testing as I'm pretty sure it's buggy. Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-12-14Merge tag 'driver-core-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-coreLinus Torvalds1-1/+0
Pull driver core update from Greg KH: "Here's the set of driver core patches for 3.19-rc1. They are dominated by the removal of the .owner field in platform drivers. They touch a lot of files, but they are "simple" changes, just removing a line in a structure. Other than that, a few minor driver core and debugfs changes. There are some ath9k patches coming in through this tree that have been acked by the wireless maintainers as they relied on the debugfs changes. Everything has been in linux-next for a while" * tag 'driver-core-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (324 commits) Revert "ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries" fs: debugfs: add forward declaration for struct device type firmware class: Deletion of an unnecessary check before the function call "vunmap" firmware loader: fix hung task warning dump devcoredump: provide a one-way disable function device: Add dev_<level>_once variants ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries ath: use seq_file api for ath9k debugfs files debugfs: add helper function to create device related seq_file drivers/base: cacheinfo: remove noisy error boot message Revert "core: platform: add warning if driver has no owner" drivers: base: support cpu cache information interface to userspace via sysfs drivers: base: add cpu_device_create to support per-cpu devices topology: replace custom attribute macros with standard DEVICE_ATTR* cpumask: factor out show_cpumap into separate helper function driver core: Fix unbalanced device reference in drivers_probe driver core: fix race with userland in device_add() sysfs/kernfs: make read requests on pre-alloc files use the buffer. sysfs/kernfs: allow attributes to request write buffer be pre-allocated. fs: sysfs: return EGBIG on write if offset is larger than file size ...
2014-11-05usb: phy: remove file names from heading commentsSergei Shtylyov1-2/+0
File names in the heading comments fell out of favor long ago, and these weren't even changed when the drivers were moved from drivers/usb/otg/, so remove them at last... Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-11-03usb: rename phy to usb_phy in OTGAntoine Tenart1-1/+1
This patch prepares the introduction of the generic PHY support in the USB OTG common functions. The USB PHY member of the OTG structure is renamed to 'usb_phy' and modifications are done in all drivers accessing it. Renaming this pointer will allow to keep the compatibility for USB PHY drivers. Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-11-03usb: move the OTG state from the USB PHY to the OTG structureAntoine Tenart1-2/+2
Before using the PHY framework instead of the USB PHY one, we need to move the OTG state into another place, since it won't be available when USB PHY isn't used. This patch moves the OTG state into the OTG structure, and makes all the needed modifications in the drivers using the OTG state. [ balbi@ti.com : fix build regressions with phy-tahvo.c, musb_dsps.c, phy-isp1301-omap, and chipidea's debug.c ] Acked-by: Kishon Vijay Abraham I <kishon@ti.com> Acked-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-10-20usb: phy: drop owner assignment from platform_driversWolfram Sang1-1/+0
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-04-21usb: phy: generic: allow multiples calls to usb_phy_generic_register()Felipe Balbi1-14/+5
it's now very easy to return a platform_device pointer and have the caller pass it as argument when calling usb_phy_generic_unregister(). Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-04-21usb: phy: rename <linux/usb/usb_phy_gen_xceiv.h> to <linux/usb/usb_phy_generic.h>Felipe Balbi1-1/+1
now that all functions match the driver name, the only missing piece is to rename the header file itself. Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-04-21usb: phy: rename usb_nop_xceiv to usb_phy_genericFelipe Balbi1-25/+25
no functional changes, just renaming the function in order to make it slightly clearer what it should be used for, also matching the driver name. Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-04-21usb: gadget: only GPL drivers in the gadget and phy frameworkFelipe Balbi1-2/+2
We only support GPL drivers in the USB Gadget Framework, it sounds correct to make all exported symbols GPL too. Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-12-19Merge tag 'v3.13-rc4' into nextFelipe Balbi1-34/+34
Linux 3.13-rc4 * tag 'v3.13-rc4': (1001 commits) Linux 3.13-rc4 null_blk: mem garbage on NUMA systems during init radeon_pm: fix oops in hwmon_attributes_visible() and radeon_hwmon_show_temp_thresh() Revert "selinux: consider filesystem subtype in policies" igb: Fix for issue where values could be too high for udelay function. i40e: fix null dereference ARM: fix asm/memory.h build error dm array: fix a reference counting bug in shadow_ablock dm space map: disallow decrementing a reference count below zero mm: memcg: do not allow task about to OOM kill to bypass the limit mm: memcg: fix race condition between memcg teardown and swapin thp: move preallocated PTE page table on move_huge_pmd() mfd/rtc: s5m: fix register updating by adding regmap for RTC rtc: s5m: enable IRQ wake during suspend rtc: s5m: limit endless loop waiting for register update rtc: s5m: fix unsuccesful IRQ request during probe drivers/rtc/rtc-s5m.c: fix info->rtc assignment include/linux/kernel.h: make might_fault() a nop for !MMU drivers/rtc/rtc-at91rm9200.c: correct alarm over day/month wrap procfs: also fix proc_reg_get_unmapped_area() for !MMU case ... Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-12-12usb: phy: initialize the notifier when add a new phyNeil Zhang1-1/+0
We need to initialize the notifer before use it. So lets initialize it when add a new phy device to reduce the code redundancy. Signed-off-by: Neil Zhang <zhangwm@marvell.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-11-25usb: phy: phy-generic: fix return value check in usb_nop_xceiv_register()Wei Yongjun1-1/+2
In case of error, the function platform_device_register_simple() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR(). Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-11-25usb: phy: generic: fix a compiler warningHeikki Krogerus1-1/+1
Just because it annoys me. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-11-25usb: phy-generic: fix nop xceiv probeAaro Koskinen1-0/+2
Commit bd27fa44e13830d2baa278d5702e766380659cb3 (usb: phy: generic: Don't use regulator framework for RESET line) introduced regression: All users of usb_nop_xceiv_register() will fail because there is no platform data and the default reset GPIO is 0 which is a valid GPIO. Fix that. Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi> Acked-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-11-25usb: phy: generic: fix how we find out about our resourcesFelipe Balbi1-31/+30
instead of having each user of generic phy find out about its own resources and pass it to the core layer, have th core layer itself figure that out. It's as simple as moving a piece of code around. This fixes a big regression caused during the merge window where am335x-based platforms wouldn't be able to probe their PHY driver. Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-11-25usb: phy: remove dead codeMichal Nazarewicz1-2/+0
Commit [4d175f34: usb: phy: nop: Defer clock prepare until PHY init] removed a goto reaching behind a “return ret” at the end of the function thus removing the only possible way that statement could be reached, and so rendering it a dead code. This commit cleans it up by removing said dead code. Signed-off-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-10-04usb: phy: generic: Don't use regulator framework for RESET lineRoger Quadros1-28/+56
Modelling the RESET line as a regulator supply wasn't a good idea as it kind of abuses the regulator framework and also makes adaptation code more complex. Instead, manage the RESET gpio line directly in the driver. Update the device tree binding information. This also makes us easy to migrate to a dedicated GPIO RESET controller whenever it becomes available. Signed-off-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-10-01usb: phy: nop: Defer clock prepare until PHY initMark Brown1-21/+3
Since we only enable the PHY clock on init and the PHY init and shutdown does not occur in atomitc context there is no need to prepare the clock before it is enabled. Move the clk_prepare() operations to go along with the enables, allowing the clock to be fully idle when not in use. Signed-off-by: Mark Brown <broonie@linaro.org> Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-08-09usb: phy: phy-generic: export init functionsSebastian Andrzej Siewior1-58/+74
This patch exports the mostly generic functions so they can be used from other phy driver instead of duplicating the code. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-08-09Merge branch 'nop-phy-rename' into nextFelipe Balbi1-0/+293
Signed-off-by: Felipe Balbi <balbi@ti.com> Conflicts: drivers/usb/phy/phy-generic.c
2013-08-09usb: phy: rename nop_usb_xceiv => usb_phy_gen_xceivSebastian Andrzej Siewior1-0/+292
The "nop" driver isn't a do-nothing-stub but supports a couple functions like clock on/off or is able to use a voltage regulator. This patch simply renames the driver to "generic" since it is easy possible to extend it by a simple function istead of writing a complete driver. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>