Commit Graph

20 Commits

Author SHA1 Message Date
Kishon Vijay Abraham I 79e6f2625d phy: core: Let node ptr of PHY point to PHY and not of PHY provider
In case of multi-phy PHY providers, each PHY should be modeled as a sub
node of the PHY provider. Then each PHY will have a different node pointer
(node pointer of sub node) than that of PHY provider. Added this provision
in the PHY core.Also fixed all drivers to use the updated API.

Change-Id: I1c6ad35456cb1b06561c95e2de79559c0e49babb
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
[ygardi@codeaurora.org: merging with qcom-specific changes, and removing
non existing files]
Git-commit: f0ed817638b59aa927f1f7e9564dd8796b18dc4f
Git-repo: https://git.kernel.org/cgit/linux/kernel/git/kishon/linux-phy.git/
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-09-18 14:55:47 +03:00
Yaniv Gardi 3036b13553 Revert "phy: extend APIs of the generic phy framework"
This reverts commit 21bd073ffc.
This patch reverts unnecessary and unused APIs from the generic PHY
framework.

Change-Id: I60022b07bc20a0be0543634c610751c032ea23fd
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-08-07 10:33:01 +03:00
Yaniv Gardi 21bd073ffc phy: extend APIs of the generic phy framework
This change adds a few more APIs to the phy_ops structure:
advertise_quirks - API for setting the phy quirks
suspend - API for the implementation of phy suspend sequence
resume - API for the implementation of phy resume sequence

Change-Id: I44dd77f2603d20acb02ccb0cc0d20ade884f97c2
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-07-28 16:49:56 -07:00
Sergei Shtylyov 194f1b5f3b phy: fix kernel oops in phy_lookup()
The kernel oopses in phy_lookup() due to 'phy->init_data' being NULL if we
register PHYs from a device tree probing driver and then call phy_get() on a
device that has no representation in the device tree (e.g. a PCI device).
Checking the pointer before dereferening it and skipping an interation if
it's NULL prevents this kernel oops.

Change-Id: Ied103e325a1e3fd15bd44c6a254affd26957e12e
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Git-commit: 743bb387a1edbf1ebbba6cf77c1af3e488886c39
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-07-29 02:43:57 +03:00
Kamil Debski 40e680fec5 phy: core: Add devm_of_phy_get to phy-core
Adding devm_of_phy_get will allow to get phys by supplying a
pointer to the struct device_node instead of struct device.

Change-Id: I8e3d0b01a1d6789663e8677e25bed2b77c4fc340
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Git-commit: b5d682f4eb76c98f2ca5658926df43dd05cf2c37
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-07-29 02:40:36 +03:00
Kamil Debski a607acfc4e phy: core: Add an exported of_phy_get function
Previously the of_phy_get function took a struct device * and
was declared static. It was impossible to call it from
another driver and thus it was impossible to get phy defined
for a given node. The old function was renamed to _of_phy_get
and was left for internal use. of_phy_get function was added
and it was exported. The function enables to get a phy for
a given device tree node.

Change-Id: I7d8a71001fd7925f8b45a796498b6a04ae1d5e0f
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Reviewed-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Git-commit: 0b3f3b2c777a2f7d20c9826a190ffd5bbd288f8f
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-07-29 02:38:04 +03:00
Hans de Goede b797edd719 phy-core: Don't propagate -ENOSUPP from phy_pm_runtime_get_sync to caller
The phy-core allows phy_init and phy_power_on to be called multiple times,
but before this patch -ENOSUPP from phy_pm_runtime_get_sync would be
propagated to the caller for the 2nd and later calls.

Change-Id: I7556e5d7cb45e3557acf312e51da7bcc798cc5be
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Git-commit: 767a1b5d6ec4ac5335dde17100880347ed154ce2
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-07-29 02:34:58 +03:00
Hans de Goede 59031a808b phy-core: phy_get: Leave error logging to the caller
In various cases errors may be expected, ie probe-deferral or a call to
phy_get from a driver where the use of a phy is optional.

Rather then adding all sort of complicated checks for this, and/or adding
special functions like devm_phy_get_optional, simply don't log an error,
and let deciding if get_phy returning an error really should result in a
dev_err up to the caller.

Change-Id: I252f82ff21468894c5fb6839e0241b37e1b90ff1
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Git-commit: f40037fd3677ae240978f469cc4155bf3ca7c076
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-07-29 02:32:10 +03:00
Andrew Lunn 61847b6fde drivers: phy: Add support for optional phys
Add devm_phy_optional_get and phy_optional_get, which should be used
when the phy is optional. They does not return an error when the phy
does not exist, rather they returns NULL, which is considered as a valid
phy, but results in NOPs when used with the consumer API.

Change-Id: I70fff892e2a7531a23f935793b503efdedc8034a
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
Git-commit: 788a4d56ff378bff0b8e685d03a962b36903a149
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-07-29 02:29:11 +03:00
Andrew Lunn 59fd9372c5 drivers: phy: Make NULL a valid phy reference
The common clock framework considers NULL a valid clock
reference. This makes handling optional clocks simple, in that if the
optional clock is not available, a NULL reference can be used in the
place of a real clock, simplifying the clock consumer.

Extend this concept to the phy consumer API. A NULL can be passed to
the release calls, the phy_init() and phy_exit() calls, and
phy_power_on() and phy_power_off() and a NOP is performed.

Change-Id: Ib1f2147abc25abec05a23a3976609f487a1ed162
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
Git-commit: 04c2facad8fee66c981a51852806d8923336f362
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-07-29 02:26:41 +03:00
Kishon Vijay Abraham I e4f666bb38 phy: phy-core.c: remove unnecessary initialization of local variables
There were a few places where variables are initialized unncessarily.
Remove those initializations.

Change-Id: I0c4abb0f17cb630eb45e5d662d5c55ca1ac19087
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Git-commit: d18c960430ca341e5c12a023c805ff8fd10032a6
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-07-29 02:23:20 +03:00
Kishon Vijay Abraham I 8da911ef21 phy: phy-core: increment refcounting variables only on 'success'
Increment 'init_count' only if the 'init' callback succeeded and decrement
'init_count' only if the 'exit' callback succeded. Increment 'power_count'
only if 'power_on' callback succeded and if it failed disable the clocks using
phy_pm_runtime_put_sync(). Also decrement 'power_count' only if 'power_off'
callback succeded and if it failed do not disable the clocks.

Change-Id: I8190df3b3febb2b5a7b093df3fd949ede26d7ea4
Reported-by: George Cherian <george.cherian@ti.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Git-commit: 637d378cea0b463c466a61a6564cdd541d689af5
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-07-29 02:19:09 +03:00
Felipe Balbi f5eee3a86b phy: core: properly handle failure of pm_runtime_get functions
In case pm_runtime_get*() fails, it still
increments pm usage counter, so we *must*
make sure to pm_runtime_put() even in those
cases.

This patch fixes that mistake the same way
usbcore treats those possible failures.

Change-Id: Id3f8b7bfb6bc10fcd2acd4458dba8dd669aa9a4a
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Git-commit: cedb7f89d1e1f631b7e5d920fe1ea7f742d07f79
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-07-29 02:15:15 +03:00
Dan Carpenter a9d37457e5 drivers: phy: tweaks to phy_create()
If this was called with a NULL "dev" then it lead to a NULL dereference
when we called dev_WARN().  I have changed it to WARN_ON() so that we
get a stack dump and can fix the caller.

The rest of this patch is just cleanup like returning directly instead
of having do-nothing gotos.  Using descriptive labels instead of
GW-BASIC style "err0" and "err1".  I also flipped the order of
put_device() and ida_remove() so they are a mirror reflection of the
order they were allocated.

Change-Id: Ie54a9c4523a8d6afd66fda66b99b1f29fdf61110
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Git-commit: 52797d293287f5a98bd686616527b102b077ac39
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-07-28 12:38:41 -07:00
Sachin Kamat f26d84efb3 drivers: phy: Fix memory leak
'phy' was not being freed upon error in one of the cases.
Adjust the 'goto's to fix this.

Change-Id: I2537e5b32629de93c567ef2ee936bceb0ad56b96
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Git-commit: c1b1731d2002b93857810aa5da856b43f46bb470
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-07-28 12:38:33 -07:00
Yaniv Gardi 11235d6b69 Revert "phy: extend APIs of the generic phy framework"
This reverts commit 63566d8d49.

This change reverts changes in the generic PHY framework.
Many changes were uploaded into the generic PHY framework in the
upstream code.
In order to avoid conflicts, we need to revert this patch, then
cherry-pick the changes of generic PHY framework from the
upstream.

Change-Id: Idbbe331255f8199f0869bcb76d7ad00767fb83e1
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-07-28 22:36:31 +03:00
Yaniv Gardi ec8f560715 Revert "phy: fix wrong return value of phy framework APIs"
This reverts commit 15a373cea8.

This change reverts changes in the generic PHY framework.
Many changes were uploaded into the generic PHY framework in the
upstream code.
In order to avoid conflicts, we need to revert this patch, then
cherry-pick the changes of generic PHY framework from the upstream.

Change-Id: I04cc1771c67d4f47be875b3ccf6f01348efd0905
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-07-28 22:31:18 +03:00
Yaniv Gardi 15a373cea8 phy: fix wrong return value of phy framework APIs
Currently, a few APIs (init, exit, power_on, power_off,
suspend, resume) in the phy framework, return a wrong
value (-ENOTSUPP).
This change fixes the return value to be 0, to indicate
there is no actual error.

Change-Id: Ieff05a11738b9d3ec21f171e763c52638de88c8b
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-07-14 17:56:35 +03:00
Yaniv Gardi 63566d8d49 phy: extend APIs of the generic phy framework
This change adds a few more APIs to the phy_ops structure:
advertise_quirks - an API for setting the phy quirks
suspend - an API for the implementation of
          phy suspend sequence
resume - an API for implementation of phy resume sequence

Change-Id: Idc76e7aef7fa1029f4d9d8baedae869346992da8
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
2014-07-08 03:08:31 -07:00
Kishon Vijay Abraham I 06111d5283 drivers: phy: add generic PHY framework
The PHY framework provides a set of APIs for the PHY drivers to
create/destroy a PHY and APIs for the PHY users to obtain a reference to the
PHY with or without using phandle. For dt-boot, the PHY drivers should
also register *PHY provider* with the framework.

PHY drivers should create the PHY by passing id and ops like init, exit,
power_on and power_off. This framework is also pm runtime enabled.

The documentation for the generic PHY framework is added in
Documentation/phy.txt and the documentation for dt binding can be found at
Documentation/devicetree/bindings/phy/phy-bindings.txt

Change-Id: I02be3faa7082e3c93c14ca3ac57059569c905eed
Cc: Tomasz Figa <t.figa@samsung.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Acked-by: Felipe Balbi <balbi@ti.com>
Tested-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Git-commit: ff764963479a1b18721ab96e531404c50fefe8b1
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
2013-12-10 08:17:57 +05:30