phy: for 4.9
Subsystems (9)
Hi Greg,
Please find the phy pull request for 4.9 merge window below. It adds 4 new phy drivers, adds support for a couple of phys using existing drivers, adds phy_reset() API which can be used by the controller drivers to reset the phy and includes misc fixes and cleanups.
It also includes an immutable extcon branch (ib-extcon-phy-4.9) from Chanwoo, since the Type-C PHY driver is dependent on extcon.
Let me know if I have to change something.
Thanks
Kishon
The following changes since commit 017300da3a4547d85e52c2484fc0bd759e1bbcdb:
phy: sun9i-usb: fix error handling (2016-08-12 14:59:10 +0530)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git tags/phy-for-4.9
for you to fetch changes up to b78ea84a7d45b9e5ad2eee429a2140065a39d755:
phy-twl4030-usb: initialize charging-related stuff via pm_runtime (2016-09-14 10:59:12 +0530)
----------------------------------------------------------------
phy: for 4.9
*) phy driver for USB 3.0 PHY on Northstar
*) phy driver for Rockchip usb2phy
*) phy driver for the Rockchip SoC internal PCIe PHY *) phy driver for USB Type-C PHY on rk3399
*) phy_reset() API
*) support for Allwinner A64 usb phy, usb2 phy in r8a7796 *) Fixes in twl4030-usb, tegra phy, sun4i-usb phy, da8xx-usb phy
and omap-usb2 phy
*) other misc cleanups
----------------------------------------------------------------
Andreas Kemnade (2):
phy-twl4030-usb: better handle musb_mailbox() failure
phy-twl4030-usb: initialize charging-related stuff via pm_runtime
Arnd Bergmann (1):
usb: phy: add USB_SUPPORT dependency
Axel Lin (3):
phy: exynos5-usbdrd: Remove "static" from local variable
phy: bcm-ns2-pcie: Get rid of struct ns2_pci_phy
phy: bcm-ns2-pcie: Set missing .owner field in ns2_pci_phy_ops
Baoyou Xie (2):
phy: tegra: add missing header dependencies
phy: tegra: mark tegra_xusb_lane_lookup_function() static
Chanwoo Choi (12):
extcon: arizona: Remove the usage of extcon_update_state()
extcon: adc-jack: Remove the usage of extcon_set_state()
extcon: gpio: Remove the usage of extcon_set_state()
extcon: Remove the state_store() to prevent the wrong access
extcon: Block the bit masking operation for cable state except for extcon core
extcon: Add the extcon_type to gather each connector into five category
extcon: Add the support for extcon property according to extcon type
extcon: Add the support for the capability of each property
extcon: Rename the extcon_set/get_state() to maintain the function naming pattern
extcon: Add the synchronization extcon APIs to support the notification
extcon: Add new EXTCON_DISP_HMD for Head-mounted Display device
extcon: Add new EXTCON_CHG_WPT for Wireless Power Transfer device
Charles Keepax (1):
extcon: arizona: Remove unneeded semi-colon
Chen-Yu Tsai (1):
phy: sun4i-usb: Use spinlock to guard phyctl register access
Chris Zhong (4):
extcon: Add EXTCON_DISP_DP and the property for USB Type-C
phy: Add USB Type-C PHY driver for rk3399
Documentation: bindings: add dt doc for Rockchip USB Type-C PHY
phy: rockchip-typec: add pm runtime support
David Lechner (1):
phy: da8xx-usb: Fix syscon device name
Frank Wang (3):
Documentation: bindings: add DT documentation for Rockchip USB2PHY
phy: rockchip-inno-usb2: add a new driver for Rockchip usb2phy
phy: rockchip-inno-usb2: add COMMON_CLK dependency
Guenter Roeck (1):
extcon: Introduce EXTCON_PROP_USB_SS property for SuperSpeed mode
Hans de Goede (5):
phy-sun4i-usb: Use bool where appropriate
phy-sun4i-usb: Refactor forced session ending
phy-sun4i-usb: Simplify missing dr_mode handling
phy-sun4i-usb: Add support for phy_set_mode
phy-sun4i-usb: Warn when external vbus is detected
Icenowy Zheng (2):
dt: bindings: add bindings for Allwinner A64 usb phy
phy: sun4i: add support for A64 usb phy
Julia Lawall (1):
phy: qcom-ufs: use of_property_read_bool
Kishon Vijay Abraham I (1):
Merge branch 'ib-extcon-phy-4.9' of git://git.kernel.org/.../chanwoo/extcon into next
Maninder Singh (1):
extcon: Fix compile time warning
Rafał Miłecki (1):
phy: bcm-ns-usb3: new driver for USB 3.0 PHY on Northstar
Randy Li (2):
phy: Add reset callback
phy: rockchip-usb: use rockchip_usb_phy_reset to reset phy during wakeup
Sekhar Nori (2):
phy: omap-usb2: support suspend/resume
dt-bindings: phy: ti: add documentation for ti,dra7x-usb2
Shawn Lin (2):
Documentation: bindings: add dt documentation for Rockchip PCIe PHY
phy: add a driver for the Rockchip SoC internal PCIe PHY
Stephen Boyd (1):
extcon: Move extcon_get_edev_by_phandle() errors to dbg level
Venkat Reddy Talla (1):
extcon: adc-jack: update cable state during boot
Yoshihiro Shimoda (2):
phy: rcar-gen3-usb2: revise the example of device tree doc
phy: rcar-gen3-usb2: Add a compatible string for r8a7796
.../devicetree/bindings/phy/bcm-ns-usb3-phy.txt | 23 + .../bindings/phy/phy-rockchip-inno-usb2.txt | 64 ++ .../devicetree/bindings/phy/phy-rockchip-typec.txt | 101 ++ .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | 6 +- .../devicetree/bindings/phy/rockchip-pcie-phy.txt | 31 + .../devicetree/bindings/phy/rockchip-usb-phy.txt | 3 + .../devicetree/bindings/phy/sun4i-usb-phy.txt | 1 + Documentation/devicetree/bindings/phy/ti-phy.txt | 2 + drivers/extcon/extcon-adc-jack.c | 27 +- drivers/extcon/extcon-arizona.c | 13 +- drivers/extcon/extcon-gpio.c | 2 +- drivers/extcon/extcon.c | 774 ++++++++++++--- drivers/phy/Kconfig | 36 + drivers/phy/Makefile | 4 + drivers/phy/phy-bcm-ns-usb3.c | 274 ++++++ drivers/phy/phy-bcm-ns2-pcie.c | 28 +- drivers/phy/phy-core.c | 15 + drivers/phy/phy-da8xx-usb.c | 2 +- drivers/phy/phy-exynos5-usbdrd.c | 4 +- drivers/phy/phy-omap-usb2.c | 100 +- drivers/phy/phy-qcom-ufs.c | 6 +- drivers/phy/phy-rcar-gen3-usb2.c | 1 + drivers/phy/phy-rockchip-inno-usb2.c | 707 ++++++++++++++ drivers/phy/phy-rockchip-pcie.c | 357 +++++++ drivers/phy/phy-rockchip-typec.c | 1023 ++++++++++++++++++++ drivers/phy/phy-rockchip-usb.c | 20 + drivers/phy/phy-sun4i-usb.c | 154 +-- drivers/phy/phy-twl4030-usb.c | 25 +- drivers/phy/tegra/xusb.c | 4 +- include/linux/extcon.h | 181 +++- include/linux/extcon/extcon-adc-jack.h | 4 +- include/linux/phy/phy.h | 3 + 32 files changed, 3656 insertions(+), 339 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/bcm-ns-usb3-phy.txt create mode 100644 Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.txt create mode 100644 Documentation/devicetree/bindings/phy/phy-rockchip-typec.txt create mode 100644 Documentation/devicetree/bindings/phy/rockchip-pcie-phy.txt create mode 100644 drivers/phy/phy-bcm-ns-usb3.c create mode 100644 drivers/phy/phy-rockchip-inno-usb2.c create mode 100644 drivers/phy/phy-rockchip-pcie.c create mode 100644 drivers/phy/phy-rockchip-typec.c
PATCH 1/51 phy: exynos5-usbdrd: Remove "static" from local variable
From: Axel Lin <[email protected]>
The 'reg' local variable does not need to be static.
--- drivers/phy/phy-exynos5-usbdrd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/phy/phy-exynos5-usbdrd.c +2 -2
@@ -249,7 +249,7 @@ static void exynos5_usbdrd_phy_isol(struct phy_usb_instance *inst,static unsigned int exynos5_usbdrd_pipe3_set_refclk (struct phy_usb_instance *inst) { -static u32 reg; +u32 reg;struct exynos5_usbdrd_phy *phy_drd =to_usbdrd_phy (inst);/* restore any previous reference clock settings */
@@ -295,7 +295,7 @@ exynos5_usbdrd_pipe3_set_refclk(struct phy_usb_instance *inst)static unsigned int exynos5_usbdrd_utmi_set_refclk (struct phy_usb_instance *inst) { -static u32 reg; +u32 reg;struct exynos5_usbdrd_phy *phy_drd =to_usbdrd_phy (inst);/* restore any previous reference clock settings */
Signature · 1 line
1.7.9.5
PATCH 2/51 dt: bindings: add bindings for Allwinner A64 usb phy
In reply to Kishon Vijay Abraham IFrom: Icenowy Zheng <[email protected]>
Update sun4i usb phy dt binding documentation to include support for Allwinner A64 usb phy.
--- .../devicetree/bindings/phy/sun4i-usb-phy.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt +1 -0
@@ -10,6 +10,7 @@ Required properties: * allwinner,sun8i-a23-usb-phy * allwinner,sun8i-a33-usb-phy * allwinner,sun8i-h3-usb-phy + * allwinner,sun50i-a64-usb-phy - reg : a list of offset + length pairs - reg-names : * "phy_ctrl"
Signature · 1 line
1.7.9.5
PATCH 3/51 phy: sun4i: add support for A64 usb phy
In reply to Kishon Vijay Abraham IFrom: Icenowy Zheng <[email protected]>
There's something unknown in the pmu part that shared with H3. It's renamed as PMU_UNK1 from PMU_UNK_H3.
--- drivers/phy/phy-sun4i-usb.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-)
drivers/phy/phy-sun4i-usb.c +29 -6
@@ -50,7 +50,7 @@#define REG_PHYCTL_A33 0x10#define REG_PHY_UNK_H3 0x20 -#define REG_PMU_UNK_H3 0x10 +#define REG_PMU_UNK1 0x10#define PHYCTL_DATA BIT(7)
@@ -98,6 +98,7 @@ enum sun4i_usb_phy_type { sun6i_a31_phy, sun8i_a33_phy, sun8i_h3_phy, + sun50i_a64_phy, }; struct sun4i_usb_phy_cfg {
@@ -106,6 +107,7 @@ struct sun4i_usb_phy_cfg {u32 disc_thresh;u8 phyctl_offset;bool dedicated_clocks; +bool enable_pmu_unk1; };struct sun4i_usb_phy_data {
@@ -183,8 +185,9 @@ static void sun4i_usb_phy_write(struct sun4i_usb_phy *phy, u32 addr, u32 data,mutex_lock (&phy_data->mutex); -if (phy_data->cfg->type == sun8i_a33_phy) { -/* A33 needs us to set phyctl to 0 explicitly */ +if (phy_data->cfg->type == sun8i_a33_phy || + phy_data->cfg->type == sun50i_a64_phy) { +/* A33 or A64 needs us to set phyctl to 0 explicitly */ writel (0 , phyctl); }
@@ -258,14 +261,16 @@ static int sun4i_usb_phy_init(struct phy *_phy)return ret; } +if (data->cfg->enable_pmu_unk1) { + val =readl (phy->pmu +REG_PMU_UNK1 ); +writel (val & ~2 , phy->pmu +REG_PMU_UNK1 ); + } +if (data->cfg->type == sun8i_h3_phy) {if (phy->index ==0 ) { val =readl (data->base +REG_PHY_UNK_H3 );writel (val & ~1 , data->base +REG_PHY_UNK_H3 ); } - - val =readl (phy->pmu +REG_PMU_UNK_H3 ); -writel (val & ~2 , phy->pmu +REG_PMU_UNK_H3 ); }else {/* Enable USB 45 Ohm resistor calibration */ if (phy->index ==0 )
@@ -737,6 +742,7 @@ static const struct sun4i_usb_phy_cfg sun4i_a10_cfg = { .disc_thresh = 3, .phyctl_offset = REG_PHYCTL_A10, .dedicated_clocks = false, + .enable_pmu_unk1 = false, };static const struct sun4i_usb_phy_cfg sun5i_a13_cfg = {
@@ -745,6 +751,7 @@ static const struct sun4i_usb_phy_cfg sun5i_a13_cfg = { .disc_thresh = 2, .phyctl_offset = REG_PHYCTL_A10, .dedicated_clocks = false, + .enable_pmu_unk1 = false, };static const struct sun4i_usb_phy_cfg sun6i_a31_cfg = {
@@ -753,6 +760,7 @@ static const struct sun4i_usb_phy_cfg sun6i_a31_cfg = { .disc_thresh = 3, .phyctl_offset = REG_PHYCTL_A10, .dedicated_clocks = true, + .enable_pmu_unk1 = false, };static const struct sun4i_usb_phy_cfg sun7i_a20_cfg = {
@@ -761,6 +769,7 @@ static const struct sun4i_usb_phy_cfg sun7i_a20_cfg = { .disc_thresh = 2, .phyctl_offset = REG_PHYCTL_A10, .dedicated_clocks = false, + .enable_pmu_unk1 = false, };static const struct sun4i_usb_phy_cfg sun8i_a23_cfg = {
@@ -769,6 +778,7 @@ static const struct sun4i_usb_phy_cfg sun8i_a23_cfg = { .disc_thresh = 3, .phyctl_offset = REG_PHYCTL_A10, .dedicated_clocks = true, + .enable_pmu_unk1 = false, };static const struct sun4i_usb_phy_cfg sun8i_a33_cfg = {
@@ -777,6 +787,7 @@ static const struct sun4i_usb_phy_cfg sun8i_a33_cfg = { .disc_thresh = 3, .phyctl_offset = REG_PHYCTL_A33, .dedicated_clocks = true, + .enable_pmu_unk1 = false, };static const struct sun4i_usb_phy_cfg sun8i_h3_cfg = {
@@ -784,6 +795,16 @@ static const struct sun4i_usb_phy_cfg sun8i_h3_cfg = { .type = sun8i_h3_phy, .disc_thresh = 3, .dedicated_clocks = true, + .enable_pmu_unk1 = true, +}; + +static const struct sun4i_usb_phy_cfg sun50i_a64_cfg = { + .num_phys =2 , + .type = sun50i_a64_phy, + .disc_thresh =3 , + .phyctl_offset =REG_PHYCTL_A33 , + .dedicated_clocks = true, + .enable_pmu_unk1 = true, };static const struct of_device_id sun4i_usb_phy_of_match[] = {
@@ -794,6 +815,8 @@ static const struct of_device_id sun4i_usb_phy_of_match[] = { { .compatible = "allwinner,sun8i-a23-usb-phy", .data = &sun8i_a23_cfg }, { .compatible = "allwinner,sun8i-a33-usb-phy", .data = &sun8i_a33_cfg }, { .compatible = "allwinner,sun8i-h3-usb-phy", .data = &sun8i_h3_cfg }, + { .compatible = "allwinner,sun50i-a64-usb-phy", + .data = &sun50i_a64_cfg}, { }, };MODULE_DEVICE_TABLE (of, sun4i_usb_phy_of_match);
Signature · 1 line
1.7.9.5
PATCH 4/51 phy: bcm-ns-usb3: new driver for USB 3.0 PHY on Northstar
In reply to Kishon Vijay Abraham IFrom: Rafał Miłecki <[email protected]>
Northstar is a family of SoCs used in home routers. They have USB 2.0 and 3.0 controllers with PHYs that need to be properly initialized. This driver provides PHY init support in a generic way and can be bound with XHCI controller driver.
There aren't any public datasheets from Broadcom so we can't have nice defines for all used bits. It means we just follow Broadcom's initialization procedure using their magic values. We were quite lucky actually that Broadcom put some comments in their SDK reference code explaining what given writes are responsible for.
--- .../devicetree/bindings/phy/bcm-ns-usb3-phy.txt | 23 ++ drivers/phy/Kconfig | 9 + drivers/phy/Makefile | 1 + drivers/phy/phy-bcm-ns-usb3.c | 274 ++++++++++++++++++++ 4 files changed, 307 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/bcm-ns-usb3-phy.txt create mode 100644 drivers/phy/phy-bcm-ns-usb3.c
Documentation/devicetree/bindings/phy/bcm-ns-usb3-phy.txt new file +23 -0
@@ -0,0 +1,23 @@ +Driver for Broadcom Northstar USB 3.0 PHY + +Required properties: + +- compatible: one of: "brcm,ns-ax-usb3-phy", "brcm,ns-bx-usb3-phy". +- reg: register mappings for DMP (Device Management Plugin) and ChipCommon B + MMI. +- reg-names: "dmp" and "ccb-mii" + +Initialization of USB 3.0 PHY depends on Northstar version. There are currently +three known series: Ax, Bx and Cx. +Known A0: BCM4707 rev 0 +Known B0: BCM4707 rev 4, BCM53573 rev 2 +Known B1: BCM4707 rev 6 +Known C0: BCM47094 rev 0 + +Example: + usb3-phy { + compatible = "brcm,ns-ax-usb3-phy"; + reg = <0x18105000 0x1000>, <0x18003000 0x1000>; + reg-names = "dmp", "ccb-mii"; + #phy-cells = <0>; + };
drivers/phy/Kconfig +9 -0
@@ -24,6 +24,15 @@ config PHY_BCM_NS_USB2 Enable this to support Broadcom USB 2.0 PHY connected to the USB controller on Northstar family. +config PHY_BCM_NS_USB3 + tristate "Broadcom Northstar USB 3.0 PHY Driver" + depends on ARCH_BCM_IPROC || COMPILE_TEST + depends on HAS_IOMEM && OF + select GENERIC_PHY + help + Enable this to support Broadcom USB 3.0 PHY connected to the USB + controller on Northstar family. + config PHY_BERLIN_USB tristate "Marvell Berlin USB PHY Driver" depends on ARCH_BERLIN && RESET_CONTROLLER && HAS_IOMEM && OF
drivers/phy/Makefile +1 -0
@@ -4,6 +4,7 @@ obj-$(CONFIG_GENERIC_PHY) += phy-core.o obj-$(CONFIG_PHY_BCM_NS_USB2) += phy-bcm-ns-usb2.o +obj-$(CONFIG_PHY_BCM_NS_USB3) += phy-bcm-ns-usb3.o obj-$(CONFIG_PHY_BERLIN_USB) += phy-berlin-usb.o obj-$(CONFIG_PHY_BERLIN_SATA) += phy-berlin-sata.o obj-$(CONFIG_PHY_DA8XX_USB) += phy-da8xx-usb.o
drivers/phy/phy-bcm-ns-usb3.c new file +274 -0
274 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 5/51 phy: qcom-ufs: use of_property_read_bool
In reply to Kishon Vijay Abraham IFrom: Julia Lawall <[email protected]>
Use of_property_read_bool to check for the existence of a property.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression e1,e2,x;
@@
- if (of_get_property(e1,e2,NULL))
- x = true;
- else
- x = false;
+ x = of_property_read_bool(e1,e2);
// </smpl>
--- drivers/phy/phy-qcom-ufs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/phy/phy-qcom-ufs.c +2 -4
@@ -283,10 +283,8 @@ static int __ufs_qcom_phy_init_vreg(struct phy *phy, err =0 ; }snprintf (prop_name,MAX_PROP_NAME ,"%s-always-on" , name); -if (of_get_property (dev->of_node, prop_name,NULL )) - vreg->is_always_on = true; -else - vreg->is_always_on = false; + vreg->is_always_on =of_property_read_bool (dev->of_node, + prop_name); }if (!strcmp (name,"vdda-pll" )) {
Signature · 1 line
1.7.9.5
PATCH 6/51 Documentation: bindings: add DT documentation for Rockchip USB2PHY
In reply to Kishon Vijay Abraham IFrom: Frank Wang <[email protected]>
--- .../bindings/phy/phy-rockchip-inno-usb2.txt | 64 ++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.txt
Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.txt new file +64 -0
@@ -0,0 +1,64 @@ +ROCKCHIP USB2.0 PHY WITH INNO IP BLOCK + +Required properties (phy (parent) node): + - compatible : should be one of the listed compatibles: + * "rockchip,rk3366-usb2phy" + * "rockchip,rk3399-usb2phy" + - reg : the address offset of grf for usb-phy configuration. + - #clock-cells : should be 0. + - clock-output-names : specify the 480m output clock name. + +Optional properties: + - clocks : phandle + phy specifier pair, for the input clock of phy. + - clock-names : input clock name of phy, must be "phyclk". + +Required nodes : a sub-node is required for each port the phy provides. + The sub-node name is used to identify host or otg port, + and shall be the following entries: + * "otg-port" : the name of otg port. + * "host-port" : the name of host port. + +Required properties (port (child) node): + - #phy-cells : must be 0. See ./phy-bindings.txt for details. + - interrupts : specify an interrupt for each entry in interrupt-names. + - interrupt-names : a list which shall be the following entries: + * "otg-id" : for the otg id interrupt. + * "otg-bvalid" : for the otg vbus interrupt. + * "linestate" : for the host/otg linestate interrupt. + +Optional properties: + - phy-supply : phandle to a regulator that provides power to VBUS. + See ./phy-bindings.txt for details. + +Example: + +grf: syscon@ff770000 { + compatible = "rockchip,rk3366-grf", "syscon", "simple-mfd"; + #address-cells = <1>; + #size-cells = <1>; + +... + + u2phy: usb2-phy@700 { + compatible = "rockchip,rk3366-usb2phy"; + reg = <0x700 0x2c>; + #clock-cells = <0>; + clock-output-names = "sclk_otgphy0_480m"; + + u2phy_otg: otg-port { + #phy-cells = <0>; + interrupts = <GIC_SPI 93 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 94 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 95 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "otg-id", "otg-bvalid", "linestate"; + status = "okay"; + }; + + u2phy_host: host-port { + #phy-cells = <0>; + interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "linestate"; + status = "okay"; + }; + }; +};
Signature · 1 line
1.7.9.5
PATCH 7/51 phy: rockchip-inno-usb2: add a new driver for Rockchip usb2phy
In reply to Kishon Vijay Abraham IFrom: Frank Wang <[email protected]>
The newer SoCs (rk3366, rk3399) take a different usb-phy IP block than rk3288 and before, and most of phy-related registers are also different from the past, so a new phy driver is required necessarily.
--- drivers/phy/Kconfig | 7 + drivers/phy/Makefile | 1 + drivers/phy/phy-rockchip-inno-usb2.c | 707 ++++++++++++++++++++++++++++++++++ 3 files changed, 715 insertions(+) create mode 100644 drivers/phy/phy-rockchip-inno-usb2.c
drivers/phy/Kconfig +7 -0
@@ -367,6 +367,13 @@ config PHY_ROCKCHIP_USB help Enable this to support the Rockchip USB 2.0 PHY. +config PHY_ROCKCHIP_INNO_USB2 + tristate "Rockchip INNO USB2PHY Driver" + depends on (ARCH_ROCKCHIP || COMPILE_TEST) && OF + select GENERIC_PHY + help + Support for Rockchip USB2.0 PHY with Innosilicon IP block. + config PHY_ROCKCHIP_EMMC tristate "Rockchip EMMC PHY Driver" depends on ARCH_ROCKCHIP && OF
drivers/phy/Makefile +1 -0
@@ -40,6 +40,7 @@ phy-exynos-usb2-$(CONFIG_PHY_S5PV210_USB2) += phy-s5pv210-usb2.o obj-$(CONFIG_PHY_EXYNOS5_USBDRD) += phy-exynos5-usbdrd.o obj-$(CONFIG_PHY_QCOM_APQ8064_SATA) += phy-qcom-apq8064-sata.o obj-$(CONFIG_PHY_ROCKCHIP_USB) += phy-rockchip-usb.o +obj-$(CONFIG_PHY_ROCKCHIP_INNO_USB2) += phy-rockchip-inno-usb2.o obj-$(CONFIG_PHY_ROCKCHIP_EMMC) += phy-rockchip-emmc.o obj-$(CONFIG_PHY_ROCKCHIP_DP) += phy-rockchip-dp.o obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA) += phy-qcom-ipq806x-sata.o
drivers/phy/phy-rockchip-inno-usb2.c new file +707 -0
707 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 8/51 Documentation: bindings: add dt documentation for Rockchip PCIe PHY
In reply to Kishon Vijay Abraham IFrom: Shawn Lin <[email protected]>
This patch adds a binding that describes the Rockchip PCIe PHY found on Rockchip SoCs PCIe interface.
--- .../devicetree/bindings/phy/rockchip-pcie-phy.txt | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/rockchip-pcie-phy.txt
Documentation/devicetree/bindings/phy/rockchip-pcie-phy.txt new file +31 -0
@@ -0,0 +1,31 @@ +Rockchip PCIE PHY +----------------------- + +Required properties: + - compatible: rockchip,rk3399-pcie-phy + - #phy-cells: must be 0 + - clocks: Must contain an entry in clock-names. + See ../clocks/clock-bindings.txt for details. + - clock-names: Must be "refclk" + - resets: Must contain an entry in reset-names. + See ../reset/reset.txt for details. + - reset-names: Must be "phy" + +Example: + +grf: syscon@ff770000 { + compatible = "rockchip,rk3399-grf", "syscon", "simple-mfd"; + #address-cells = <1>; + #size-cells = <1>; + + ... + + pcie_phy: pcie-phy { + compatible = "rockchip,rk3399-pcie-phy"; + #phy-cells = <0>; + clocks = <&cru SCLK_PCIEPHY_REF>; + clock-names = "refclk"; + resets = <&cru SRST_PCIEPHY>; + reset-names = "phy"; + }; +};
Signature · 1 line
1.7.9.5
PATCH 9/51 phy: add a driver for the Rockchip SoC internal PCIe PHY
In reply to Kishon Vijay Abraham IFrom: Shawn Lin <[email protected]>
This patch to add a generic PHY driver for rockchip PCIe PHY. Access the PHY via registers provided by GRF (general register files) module.
--- drivers/phy/Kconfig | 8 + drivers/phy/Makefile | 1 + drivers/phy/phy-rockchip-pcie.c | 357 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 366 insertions(+) create mode 100644 drivers/phy/phy-rockchip-pcie.c
drivers/phy/Kconfig +8 -0
@@ -388,6 +388,14 @@ config PHY_ROCKCHIP_DP help Enable this to support the Rockchip Display Port PHY. +config PHY_ROCKCHIP_PCIE + tristate "Rockchip PCIe PHY Driver" + depends on (ARCH_ROCKCHIP && OF) || COMPILE_TEST + select GENERIC_PHY + select MFD_SYSCON + help + Enable this to support the Rockchip PCIe PHY. + config PHY_ST_SPEAR1310_MIPHY tristate "ST SPEAR1310-MIPHY driver" select GENERIC_PHY
drivers/phy/Makefile +1 -0
@@ -42,6 +42,7 @@ obj-$(CONFIG_PHY_QCOM_APQ8064_SATA) += phy-qcom-apq8064-sata.o obj-$(CONFIG_PHY_ROCKCHIP_USB) += phy-rockchip-usb.o obj-$(CONFIG_PHY_ROCKCHIP_INNO_USB2) += phy-rockchip-inno-usb2.o obj-$(CONFIG_PHY_ROCKCHIP_EMMC) += phy-rockchip-emmc.o +obj-$(CONFIG_PHY_ROCKCHIP_PCIE) += phy-rockchip-pcie.o obj-$(CONFIG_PHY_ROCKCHIP_DP) += phy-rockchip-dp.o obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA) += phy-qcom-ipq806x-sata.o obj-$(CONFIG_PHY_ST_SPEAR1310_MIPHY) += phy-spear1310-miphy.o
drivers/phy/phy-rockchip-pcie.c new file +357 -0
357 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 10/51 phy: tegra: add missing header dependencies
In reply to Kishon Vijay Abraham IFrom: Baoyou Xie <[email protected]>
We get 5 warnings when building kernel with W=1:drivers/phy/tegra/xusb.c:948:27: warning: no previous prototype for 'tegra_xusb_padctl_get' [-Wmissing-prototypes] drivers/phy/tegra/xusb.c:981:6: warning: no previous prototype for 'tegra_xusb_padctl_put' [-Wmissing-prototypes] drivers/phy/tegra/xusb.c:988:5: warning: no previous prototype for 'tegra_xusb_padctl_usb3_save_context' [-Wmissing-prototypes] drivers/phy/tegra/xusb.c:998:5: warning: no previous prototype for 'tegra_xusb_padctl_hsic_set_idle' [-Wmissing-prototypes] drivers/phy/tegra/xusb.c:1008:5: warning: no previous prototype for 'tegra_xusb_padctl_usb3_set_lfps_detect' [-Wmissing-prototypes]
In fact, these functions are declared in linux/phy/tegra/xusb.h, so this patch adds missing header dependencies.
--- drivers/phy/tegra/xusb.c | 1 + 1 file changed, 1 insertion(+)
drivers/phy/tegra/xusb.c +1 -0
@@ -18,6 +18,7 @@#include <linux/of.h> #include <linux/of_device.h> #include <linux/phy/phy.h> +#include <linux/phy/tegra/xusb.h> #include <linux/platform_device.h> #include <linux/regulator/consumer.h> #include <linux/reset.h>
Signature · 1 line
1.7.9.5
PATCH 11/51 phy: tegra: mark tegra_xusb_lane_lookup_function() static
In reply to Kishon Vijay Abraham IFrom: Baoyou Xie <[email protected]>
We get 1 warning when building kernel with W=1:drivers/phy/tegra/xusb.c:104:5: warning: no previous prototype for 'tegra_xusb_lane_lookup_function' [-Wmissing-prototypes]
In fact, this function is only used in the file in which it is declared and don't need a declaration, but can be made static. So this patch marks it 'static'.
--- drivers/phy/tegra/xusb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/phy/tegra/xusb.c +2 -1
@@ -102,7 +102,8 @@ tegra_xusb_pad_find_phy_node(struct tegra_xusb_pad *pad, unsigned int index)return of_find_node_by_name (np, pad->soc->lanes[index].name); } -int tegra_xusb_lane_lookup_function (struct tegra_xusb_lane *lane, +static int +tegra_xusb_lane_lookup_function (struct tegra_xusb_lane *lane,const char *function) {unsigned int i;
Signature · 1 line
1.7.9.5
PATCH 12/51 phy: bcm-ns2-pcie: Get rid of struct ns2_pci_phy
In reply to Kishon Vijay Abraham IFrom: Axel Lin <[email protected]>
By setting phy_set_drvdata(phy, mdiodev), struct ns2_pci_phy can be removed.
--- drivers/phy/phy-bcm-ns2-pcie.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-)
drivers/phy/phy-bcm-ns2-pcie.c +5 -20
@@ -18,11 +18,6 @@#include <linux/phy.h> #include <linux/phy/phy.h> -struct ns2_pci_phy { -struct mdio_device *mdiodev; -struct phy *phy; -}; -#define BLK_ADDR_REG_OFFSET 0x1f#define PLL_AFE1_100MHZ_BLK 0x2100#define PLL_CLK_AMP_OFFSET 0x03
@@ -30,17 +25,17 @@ struct ns2_pci_phy {static int ns2_pci_phy_init (struct phy *p) { -struct ns2_pci_phy *phy =phy_get_drvdata (p); +struct mdio_device *mdiodev =phy_get_drvdata (p);int rc;/* select the AFE 100MHz block page */ - rc =mdiobus_write (phy->mdiodev->bus, phy->mdiodev->addr, + rc =mdiobus_write (mdiodev->bus, mdiodev->addr,BLK_ADDR_REG_OFFSET ,PLL_AFE1_100MHZ_BLK );if (rc) goto err;/* set the 100 MHz reference clock amplitude to 2.05 v */ - rc =mdiobus_write (phy->mdiodev->bus, phy->mdiodev->addr, + rc =mdiobus_write (mdiodev->bus, mdiodev->addr,PLL_CLK_AMP_OFFSET ,PLL_CLK_AMP_2P05V );if (rc) goto err;
@@ -48,7 +43,7 @@ static int ns2_pci_phy_init(struct phy *p)return 0 ; err: -dev_err (&phy->mdiodev->dev,"Error %d writing to phy\n" , rc); +dev_err (&mdiodev->dev,"Error %d writing to phy\n" , rc);return rc; }
@@ -60,7 +55,6 @@ static int ns2_pci_phy_probe(struct mdio_device *mdiodev) {struct device *dev = &mdiodev->dev;struct phy_provider *provider; -struct ns2_pci_phy *p;struct phy *phy; phy =devm_phy_create (dev, dev->of_node, &ns2_pci_phy_ops);
@@ -69,16 +63,7 @@ static int ns2_pci_phy_probe(struct mdio_device *mdiodev)return PTR_ERR (phy); } - p =devm_kmalloc (dev,sizeof (struct ns2_pci_phy ), -GFP_KERNEL ); -if (!p) -return -ENOMEM ; - - p->mdiodev = mdiodev; -dev_set_drvdata (dev, p); - - p->phy = phy; -phy_set_drvdata (phy, p); +phy_set_drvdata (phy, mdiodev); provider =devm_of_phy_provider_register (&phy->dev, of_phy_simple_xlate);
Signature · 1 line
1.7.9.5
PATCH 13/51 phy: bcm-ns2-pcie: Set missing .owner field in ns2_pci_phy_ops
In reply to Kishon Vijay Abraham IFrom: Axel Lin <[email protected]>
Add missing .owner field in ns2_pci_phy_ops, which is used for refcounting. While at it, also makes ns2_pci_phy_ops const as it's never get modified.
--- drivers/phy/phy-bcm-ns2-pcie.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/phy/phy-bcm-ns2-pcie.c +2 -1
@@ -47,8 +47,9 @@ err:return rc; } -static struct phy_ops ns2_pci_phy_ops = { +static const struct phy_ops ns2_pci_phy_ops = { .init = ns2_pci_phy_init, + .owner =THIS_MODULE , };static int ns2_pci_phy_probe (struct mdio_device *mdiodev)
Signature · 1 line
1.7.9.5
PATCH 14/51 phy: rcar-gen3-usb2: revise the example of device tree doc
In reply to Kishon Vijay Abraham IFrom: Yoshihiro Shimoda <[email protected]>
The clocks property should be set to &cpg, not &mstpX_clks.
--- .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt +2 -2
@@ -30,11 +30,11 @@ Example (R-Car H3): compatible = "renesas,usb2-phy-r8a7795", "renesas,rcar-gen3-usb2-phy"; reg = <0 0xee080200 0 0x700>; interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&mstp7_clks R8A7795_CLK_EHCI0>; + clocks = <&cpg CPG_MOD 703>; }; usb-phy@ee0a0200 { compatible = "renesas,usb2-phy-r8a7795", "renesas,rcar-gen3-usb2-phy"; reg = <0 0xee0a0200 0 0x700>; - clocks = <&mstp7_clks R8A7795_CLK_EHCI0>; + clocks = <&cpg CPG_MOD 702>; };
Signature · 1 line
1.7.9.5
PATCH 15/51 phy: rcar-gen3-usb2: Add a compatible string for r8a7796
In reply to Kishon Vijay Abraham IFrom: Yoshihiro Shimoda <[email protected]>
This driver can support for r8a7796 SoC. So, this patch adds it.
--- .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | 2 ++ drivers/phy/phy-rcar-gen3-usb2.c | 1 + 2 files changed, 3 insertions(+)
Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt +2 -0
@@ -6,6 +6,8 @@ This file provides information on what the device node for the R-Car generation Required properties: - compatible: "renesas,usb2-phy-r8a7795" if the device is a part of an R8A7795 SoC. + "renesas,usb2-phy-r8a7796" if the device is a part of an R8A7796 + SoC. "renesas,rcar-gen3-usb2-phy" for a generic R-Car Gen3 compatible device. When compatible with the generic version, nodes must list the
drivers/phy/phy-rcar-gen3-usb2.c +1 -0
@@ -280,6 +280,7 @@ static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch)static const struct of_device_id rcar_gen3_phy_usb2_match_table[] = { { .compatible ="renesas,usb2-phy-r8a7795" }, + { .compatible ="renesas,usb2-phy-r8a7796" }, { .compatible ="renesas,rcar-gen3-usb2-phy" }, { } };
Signature · 1 line
1.7.9.5
PATCH 16/51 phy: omap-usb2: support suspend/resume
In reply to Kishon Vijay Abraham IFrom: Sekhar Nori <[email protected]>
Relying on PM-ops for shutting down PHY clocks was a bad idea since the users (e.g. USB DWC3) might not have been suspended by then.
Get rid of all PM-ops. It is the sole responsibility of the PHY user to properly turn OFF and de-initialize the PHY as part of its suspend routine.
Enable/disable PHY clock as part of ->init()/->exit() call respectively. With this phy_init() and phy_exit() can be called by PHY user during suspend/resume.
This is similar to what is done for ti-pipe3 driver. See 31c8954efb1b ("phy: ti-pipe3: fix suspend")
The pm_runtime_enable() call in omap_usb2_probe() is still required because without it, phy_create() will not enable runtime PM on the phy device it creates and phy_init() will not call pm_runtime_get_sync().
Without pm_runtime_get_sync(), ocp2scp hwmod will _not_ enable the IP and, thus, we will have abort exceptions.
--- drivers/phy/phy-omap-usb2.c | 100 ++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 54 deletions(-)
drivers/phy/phy-omap-usb2.c +46 -54
@@ -133,11 +133,49 @@ static int omap_usb_power_on(struct phy *x)return omap_usb_phy_power (phy, true); } +static int omap_usb2_disable_clocks (struct omap_usb *phy) +{ +clk_disable (phy->wkupclk); +if (!IS_ERR (phy->optclk)) +clk_disable (phy->optclk); + +return 0 ; +} + +static int omap_usb2_enable_clocks (struct omap_usb *phy) +{ +int ret; + + ret =clk_enable (phy->wkupclk); +if (ret <0 ) { +dev_err (phy->dev,"Failed to enable wkupclk %d\n" , ret); + goto err0; + } + +if (!IS_ERR (phy->optclk)) { + ret =clk_enable (phy->optclk); +if (ret <0 ) { +dev_err (phy->dev,"Failed to enable optclk %d\n" , ret); + goto err1; + } + } + +return 0 ; + +err1: +clk_disable (phy->wkupclk); + +err0: +return ret; +} +static int omap_usb_init (struct phy *x) {struct omap_usb *phy =phy_get_drvdata (x);u32 val; +omap_usb2_enable_clocks (phy); +if (phy->flags &OMAP_USB2_CALIBRATE_FALSE_DISCONNECT ) {/* *
@@ -155,8 +193,16 @@ static int omap_usb_init(struct phy *x)return 0 ; } +static int omap_usb_exit (struct phy *x) +{ +struct omap_usb *phy =phy_get_drvdata (x); + +return omap_usb2_disable_clocks (phy); +} +static const struct phy_ops ops = { .init = omap_usb_init, + .exit = omap_usb_exit, .power_on = omap_usb_power_on, .power_off = omap_usb_power_off, .owner =THIS_MODULE ,
@@ -376,65 +422,11 @@ static int omap_usb2_remove(struct platform_device *pdev)return 0 ; } -#ifdef CONFIG_PM - -static int omap_usb2_runtime_suspend (struct device *dev) -{ -struct platform_device *pdev =to_platform_device (dev); -struct omap_usb *phy =platform_get_drvdata (pdev); - -clk_disable (phy->wkupclk); -if (!IS_ERR (phy->optclk)) -clk_disable (phy->optclk); - -return 0 ; -} - -static int omap_usb2_runtime_resume (struct device *dev) -{ -struct platform_device *pdev =to_platform_device (dev); -struct omap_usb *phy =platform_get_drvdata (pdev); -int ret; - - ret =clk_enable (phy->wkupclk); -if (ret <0 ) { -dev_err (phy->dev,"Failed to enable wkupclk %d\n" , ret); - goto err0; - } - -if (!IS_ERR (phy->optclk)) { - ret =clk_enable (phy->optclk); -if (ret <0 ) { -dev_err (phy->dev,"Failed to enable optclk %d\n" , ret); - goto err1; - } - } - -return 0 ; - -err1: -clk_disable (phy->wkupclk); - -err0: -return ret; -} - -static const struct dev_pm_ops omap_usb2_pm_ops = { -SET_RUNTIME_PM_OPS (omap_usb2_runtime_suspend, omap_usb2_runtime_resume, -NULL ) -}; - -#define DEV_PM_OPS (&omap_usb2_pm_ops) -#else -#define DEV_PM_OPS NULL -#endif -static struct platform_driver omap_usb2_driver = { .probe = omap_usb2_probe, .remove = omap_usb2_remove, .driver = { .name ="omap-usb2" , - .pm =DEV_PM_OPS , .of_match_table = omap_usb2_id_table, }, };
Signature · 1 line
1.7.9.5
PATCH 17/51 dt-bindings: phy: ti: add documentation for ti,dra7x-usb2
In reply to Kishon Vijay Abraham IFrom: Sekhar Nori <[email protected]>
Commit 7e472402ca30 ("phy: omap-usb2: Provide workaround for USB2PHY false disconnect") added a new binding for USB2 PHYs on DRA7x. But it has remained undocumented so far.
Add documentation for the binding.
--- Documentation/devicetree/bindings/phy/ti-phy.txt | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/phy/ti-phy.txt +2 -0
@@ -31,6 +31,8 @@ OMAP USB2 PHY Required properties: - compatible: Should be "ti,omap-usb2" + Should be "ti,dra7x-usb2" for the 1st instance of USB2 PHY on + DRA7x Should be "ti,dra7x-usb2-phy2" for the 2nd instance of USB2 PHY in DRA7x - reg : Address and length of the register set for the device.
Signature · 1 line
1.7.9.5
PATCH 18/51 phy: rockchip-inno-usb2: add COMMON_CLK dependency
In reply to Kishon Vijay Abraham IFrom: Frank Wang <[email protected]>
On kernel builds without COMMON_CLK, the newly added rockchip-inno-usb2 driver fails to build:
drivers/phy/phy-rockchip-inno-usb2.c:124:16: error: field 'clk480m_hw' has incomplete type
struct clk_hw clk480m_hw;
In file included from include/linux/clk.h:16:0
from drivers/phy/phy-rockchip-inno-usb2.c:17:include/linux/kernel.h:831:48: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
... ...
--- drivers/phy/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/phy/Kconfig +1 -0
@@ -370,6 +370,7 @@ config PHY_ROCKCHIP_USB config PHY_ROCKCHIP_INNO_USB2 tristate "Rockchip INNO USB2PHY Driver" depends on (ARCH_ROCKCHIP || COMPILE_TEST) && OF + depends on COMMON_CLK select GENERIC_PHY help Support for Rockchip USB2.0 PHY with Innosilicon IP block.
Signature · 1 line
1.7.9.5
PATCH 19/51 extcon: adc-jack: update cable state during boot
In reply to Kishon Vijay Abraham IFrom: Venkat Reddy Talla <[email protected]>
Update cable state during boot to avoid any missing external cable events occurred before driver initialisation.
--- drivers/extcon/extcon-adc-jack.c | 1 + 1 file changed, 1 insertion(+)
drivers/extcon/extcon-adc-jack.c +1 -0
@@ -158,6 +158,7 @@ static int adc_jack_probe(struct platform_device *pdev)if (data->wakeup_source)device_init_wakeup (&pdev->dev,1 ); +adc_jack_handler (&data->handler.work);return 0 ; }
Signature · 1 line
1.7.9.5
PATCH 20/51 extcon: Move extcon_get_edev_by_phandle() errors to dbg level
In reply to Kishon Vijay Abraham IFrom: Stephen Boyd <[email protected]>
Sometimes drivers may call this API and expect it to fail because the extcon they're looking for is optional. Let's move these prints to debug level so it doesn't look like there's a problem when there isn't one.
--- drivers/extcon/extcon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/extcon/extcon.c +2 -2
@@ -846,13 +846,13 @@ struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)return ERR_PTR (-EINVAL );if (!dev->of_node) { -dev_err (dev,"device does not have a device node entry\n" ); +dev_dbg (dev,"device does not have a device node entry\n" );return ERR_PTR (-EINVAL ); } node =of_parse_phandle (dev->of_node,"extcon" , index);if (!node) { -dev_err (dev,"failed to get phandle in %s node\n" , +dev_dbg (dev,"failed to get phandle in %s node\n" , dev->of_node->full_name);return ERR_PTR (-ENODEV ); }
Signature · 1 line
1.7.9.5
PATCH 21/51 extcon: arizona: Remove unneeded semi-colon
In reply to Kishon Vijay Abraham IFrom: Charles Keepax <[email protected]>
There is no need for a semi-colon at the end of a switch statement so remove it.
--- drivers/extcon/extcon-arizona.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/extcon/extcon-arizona.c +1 -1
@@ -183,7 +183,7 @@ static void arizona_extcon_hp_clamp(struct arizona_extcon_info *info,if (clamp) val =ARIZONA_RMV_SHRT_HP1L ;break ; - }; + }snd_soc_dapm_mutex_lock (arizona->dapm);
Signature · 1 line
1.7.9.5
PATCH 22/51 extcon: arizona: Remove the usage of extcon_update_state()
In reply to Kishon Vijay Abraham IFrom: Chanwoo Choi <[email protected]>
This patch remvoes the usage of extcon_update_state() because the extcon_update_state() use directly the bit masking calculation to change the state of external connector without the unique id of external connector. It makes the code diffcult to read it. So, this patch uses the extcon_set_cable_state_() instead.
--- drivers/extcon/extcon-arizona.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/extcon/extcon-arizona.c +7 -4
@@ -1149,10 +1149,13 @@ static irqreturn_t arizona_jackdet(int irq, void *data) info->micd_ranges[i].key, 0);input_sync (info->input); - ret =extcon_update_state (info->edev,0xffffffff ,0 ); -if (ret !=0 ) -dev_err (arizona->dev,"Removal report failed: %d\n" , - ret); +for (i =0 ; i <ARRAY_SIZE (arizona_cable) -1 ; i++) { + ret =extcon_set_cable_state_ (info->edev, + arizona_cable[i], false); +if (ret !=0 ) +dev_err (arizona->dev, +"Removal report failed: %d\n" , ret); + } regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_DEBOUNCE,
Signature · 1 line
1.7.9.5
PATCH 23/51 extcon: adc-jack: Remove the usage of extcon_set_state()
In reply to Kishon Vijay Abraham IFrom: Chanwoo Choi <[email protected]>
This patch removes the usage of extcon_set_state() because it uses the bit masking to change the state of external connectors. The extcon framework should handle the state by extcon_set/get_cable_state_() with extcon id.
--- drivers/extcon/extcon-adc-jack.c | 26 ++++++++++++++------------ include/linux/extcon/extcon-adc-jack.h | 4 ++-- 2 files changed, 16 insertions(+), 14 deletions(-)
drivers/extcon/extcon-adc-jack.c +14 -12
@@ -3,6 +3,9 @@* * Analog Jack extcon driver with ADC-based detection capability. * +* Copyright (C) 2016 Samsung Electronics +* Chanwoo Choi <[email protected]> +* * Copyright (C) 2012 Samsung Electronics * MyungJoo Ham <[email protected]> *
@@ -58,7 +61,7 @@ static void adc_jack_handler(struct work_struct *work)struct adc_jack_data *data =container_of (to_delayed_work (work), struct adc_jack_data, handler); -u32 state =0 ; +struct adc_jack_cond *def;int ret, adc_val;int i;
@@ -70,17 +73,18 @@ static void adc_jack_handler(struct work_struct *work)/* Get state from adc value with adc_conditions */ for (i =0 ; i < data->num_conditions; i++) { -struct adc_jack_cond *def = &data->adc_conditions[i]; -if (!def->state) -break ; + def = &data->adc_conditions[i];if (def->min_adc <= adc_val && def->max_adc >= adc_val) { - state = def->state; -break ; +extcon_set_cable_state_ (data->edev, def->id, true); +return ; } } -/* if no def has met, it means state = 0 (no cables attached) */ -extcon_set_state (data->edev, state); +/* Set the detached state if adc value is not included in the range */ +for (i =0 ; i < data->num_conditions; i++) { + def = &data->adc_conditions[i]; +extcon_set_cable_state_ (data->edev, def->id, false); + } }static irqreturn_t adc_jack_irq_thread (int irq,void *_data)
@@ -114,16 +118,14 @@ static int adc_jack_probe(struct platform_device *pdev)return -ENOMEM ; } -if (!pdata->adc_conditions || - !pdata->adc_conditions[0 ].state) { +if (!pdata->adc_conditions) {dev_err (&pdev->dev,"error: adc_conditions not defined.\n" );return -EINVAL ; } data->adc_conditions = pdata->adc_conditions;/* Check the length of array and set num_conditions */ -for (i =0 ; data->adc_conditions[i].state; i++) - ; +for (i =0 ; data->adc_conditions[i].id !=EXTCON_NONE ; i++); data->num_conditions = i; data->chan =iio_channel_get (&pdev->dev, pdata->consumer_channel);
include/linux/extcon/extcon-adc-jack.h +2 -2
@@ -20,8 +20,8 @@/** * struct adc_jack_cond - condition to use an extcon state -* @state: the corresponding extcon state (if 0, this struct * denotes the last adc_jack_cond element among the array) +* @id: the unique id of each external connector * @min_adc: min adc value for this condition * @max_adc: max adc value for this condition *
@@ -33,7 +33,7 @@* because when no adc_jack_cond is met, state = 0 is automatically chosen. */ struct adc_jack_cond { -u32 state;/* extcon state value. 0 if invalid */ +unsigned int id;u32 min_adc;u32 max_adc; };
Signature · 1 line
1.7.9.5
PATCH 24/51 extcon: gpio: Remove the usage of extcon_set_state()
In reply to Kishon Vijay Abraham IFrom: Chanwoo Choi <[email protected]>
This patch removes the usage of extcon_set_state() because it uses the bit masking to change the state of external connectors. The extcon framework should handle the state by extcon_set_cable_state_() with extcon id.
--- drivers/extcon/extcon-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/extcon/extcon-gpio.c +1 -1
@@ -49,7 +49,7 @@ static void gpio_extcon_work(struct work_struct *work) state =gpiod_get_value_cansleep (data->id_gpiod);if (data->pdata->gpio_active_low) state = !state; -extcon_set_state (data->edev, state); +extcon_set_cable_state_ (data->edev, data->pdata->extcon_id, state); }static irqreturn_t gpio_irq_handler (int irq,void *dev_id)
Signature · 1 line
1.7.9.5
PATCH 25/51 extcon: Remove the state_store() to prevent the wrong access
In reply to Kishon Vijay Abraham IFrom: Chanwoo Choi <[email protected]>
This patch removes the state_store() which change the state of external connectors with bit masking on user-space. It is wrong access to modify the change the state of external connectors.
--- drivers/extcon/extcon.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-)
drivers/extcon/extcon.c +1 -20
@@ -174,26 +174,7 @@ static ssize_t state_show(struct device *dev, struct device_attribute *attr,return count; } - -static ssize_t state_store (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) -{ -u32 state; -ssize_t ret =0 ; -struct extcon_dev *edev =dev_get_drvdata (dev); - - ret =sscanf (buf,"0x%x" , &state); -if (ret ==0 ) - ret = -EINVAL ; -else - ret =extcon_set_state (edev, state); - -if (ret <0 ) -return ret; - -return count; -} -static DEVICE_ATTR_RW (state); +static DEVICE_ATTR_RO (state);static ssize_t name_show (struct device *dev,struct device_attribute *attr,char *buf)
Signature · 1 line
1.7.9.5
PATCH 26/51 extcon: Block the bit masking operation for cable state except for extcon core
In reply to Kishon Vijay Abraham IFrom: Chanwoo Choi <[email protected]>
This patch restrict the usage of extcon_update_state() in the extcon core because the extcon_update_state() use the bit masking to change the state of external connector. When this function is used in device drivers, it may occur the probelm with the handling mistake of bit masking.
Also, this patch removes the extcon_get/set_state() functions because these functions use the bit masking which is reluctant way. Instead, extcon provides the extcon_set/get_cable_state_() functions.
--- drivers/extcon/extcon.c | 20 +------------------- include/linux/extcon.h | 30 ------------------------------ 2 files changed, 1 insertion(+), 49 deletions(-)
drivers/extcon/extcon.c +1 -19
@@ -224,7 +224,7 @@ static ssize_t cable_state_show(struct device *dev,* Note that the notifier provides which bits are changed in the state * variable with the val parameter (second) to the callback. */ -int extcon_update_state (struct extcon_dev *edev,u32 mask,u32 state) +static int extcon_update_state (struct extcon_dev *edev,u32 mask,u32 state) {char name_buf[120 ];char state_buf[120 ];
@@ -300,24 +300,6 @@ int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state)return 0 ; } -EXPORT_SYMBOL_GPL (extcon_update_state); - -/** -* extcon_set_state() - Set the cable attach states of the extcon device. -* @edev: the extcon device -* @state: new cable attach status for @edev -* -* Note that notifier provides which bits are changed in the state -* variable with the val parameter (second) to the callback. -*/ -int extcon_set_state (struct extcon_dev *edev,u32 state) -{ -if (!edev) -return -EINVAL ; - -return extcon_update_state (edev,0xffffffff , state); -} -EXPORT_SYMBOL_GPL (extcon_set_state);/** * extcon_get_cable_state_() - Get the status of a specific cable.
include/linux/extcon.h +0 -30
@@ -150,20 +150,6 @@ extern struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,extern void devm_extcon_dev_free (struct device *dev,struct extcon_dev *edev);/* -* get/set/update_state access the 32b encoded state value, which represents -* states of all possible cables of the multistate port. For example, if one -* calls extcon_set_state(edev, 0x7), it may mean that all the three cables -* are attached to the port. -*/ -static inline u32 extcon_get_state (struct extcon_dev *edev) -{ -return edev->state; -} - -extern int extcon_set_state (struct extcon_dev *edev,u32 state); -extern int extcon_update_state (struct extcon_dev *edev,u32 mask,u32 state); - -/* * get/set_cable_state access each bit of the 32b encoded state value. * They are used to access the status of each cable based on the cable id. */
@@ -232,22 +218,6 @@ static inline struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,static inline void devm_extcon_dev_free (struct extcon_dev *edev) { } -static inline u32 extcon_get_state (struct extcon_dev *edev) -{ -return 0 ; -} - -static inline int extcon_set_state (struct extcon_dev *edev,u32 state) -{ -return 0 ; -} - -static inline int extcon_update_state (struct extcon_dev *edev,u32 mask, -u32 state) -{ -return 0 ; -} -static inline int extcon_get_cable_state_ (struct extcon_dev *edev,unsigned int id) {
Signature · 1 line
1.7.9.5
PATCH 27/51 extcon: Fix compile time warning
In reply to Kishon Vijay Abraham IFrom: Maninder Singh <[email protected]>
This patch fixes below compilation warning:-drivers/extcon/extcon.c: In function extcon_register_notifier:drivers/extcon/extcon.c:455:6: warning: idx may be used uninitialized in this function [-Wmaybe-uninitialized]
if (idx >= 0) {
--- drivers/extcon/extcon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/extcon/extcon.c +1 -1
@@ -391,7 +391,7 @@ int extcon_register_notifier(struct extcon_dev *edev, unsigned int id, struct notifier_block *nb) {unsigned long flags; -int ret, idx; +int ret, idx = -EINVAL ;if (!nb)return -EINVAL ;
Signature · 1 line
1.7.9.5
PATCH 28/51 extcon: Add the extcon_type to gather each connector into five category
In reply to Kishon Vijay Abraham IFrom: Chanwoo Choi <[email protected]>
This patch adds the new extcon type to group the each connecotr into following five category. This type would be used to handle the connectors as a group unit instead of a connector unit.
- EXTCON_TYPE_USB : USB connector
- EXTCON_TYPE_CHG : Charger connector
- EXTCON_TYPE_JACK : Jack connector
- EXTCON_TYPE_DISP : Display connector
- EXTCON_TYPE_MISC : Miscellaneous connector
Also, each external connector is possible to belong to one more extcon type. In caes of EXTCON_CHG_USB_SDP, it have the EXTCON_TYPE_CHG and EXTCON_TYPE_USB.
--- drivers/extcon/extcon.c | 159 ++++++++++++++++++++++++++++++++++++++--------- include/linux/extcon.h | 9 +++ 2 files changed, 139 insertions(+), 29 deletions(-)
drivers/extcon/extcon.c +130 -29
@@ -38,43 +38,144 @@#define SUPPORTED_CABLE_MAX 32#define CABLE_NAME_MAX 30 -static const char *extcon_name[] = { - [EXTCON_NONE ] ="NONE" , +struct __extcon_info { +unsigned int type; +unsigned int id; +const char *name; + +} extcon_info[] = { + [EXTCON_NONE ] = { + .type =EXTCON_TYPE_MISC , + .id =EXTCON_NONE , + .name ="NONE" , + },/* USB external connector */ - [EXTCON_USB ] ="USB" , - [EXTCON_USB_HOST ] ="USB-HOST" , + [EXTCON_USB ] = { + .type =EXTCON_TYPE_USB , + .id =EXTCON_USB , + .name ="USB" , + }, + [EXTCON_USB_HOST ] = { + .type =EXTCON_TYPE_USB , + .id =EXTCON_USB_HOST , + .name ="USB_HOST" , + },/* Charging external connector */ - [EXTCON_CHG_USB_SDP ] ="SDP" , - [EXTCON_CHG_USB_DCP ] ="DCP" , - [EXTCON_CHG_USB_CDP ] ="CDP" , - [EXTCON_CHG_USB_ACA ] ="ACA" , - [EXTCON_CHG_USB_FAST ] ="FAST-CHARGER" , - [EXTCON_CHG_USB_SLOW ] ="SLOW-CHARGER" , + [EXTCON_CHG_USB_SDP ] = { + .type =EXTCON_TYPE_CHG |EXTCON_TYPE_USB , + .id =EXTCON_CHG_USB_SDP , + .name ="SDP" , + }, + [EXTCON_CHG_USB_DCP ] = { + .type =EXTCON_TYPE_CHG |EXTCON_TYPE_USB , + .id =EXTCON_CHG_USB_DCP , + .name ="DCP" , + }, + [EXTCON_CHG_USB_CDP ] = { + .type =EXTCON_TYPE_CHG |EXTCON_TYPE_USB , + .id =EXTCON_CHG_USB_CDP , + .name ="CDP" , + }, + [EXTCON_CHG_USB_ACA ] = { + .type =EXTCON_TYPE_CHG |EXTCON_TYPE_USB , + .id =EXTCON_CHG_USB_ACA , + .name ="ACA" , + }, + [EXTCON_CHG_USB_FAST ] = { + .type =EXTCON_TYPE_CHG |EXTCON_TYPE_USB , + .id =EXTCON_CHG_USB_FAST , + .name ="FAST-CHARGER" , + }, + [EXTCON_CHG_USB_SLOW ] = { + .type =EXTCON_TYPE_CHG |EXTCON_TYPE_USB , + .id =EXTCON_CHG_USB_SLOW , + .name ="SLOW-CHARGER" , + },/* Jack external connector */ - [EXTCON_JACK_MICROPHONE ] ="MICROPHONE" , - [EXTCON_JACK_HEADPHONE ] ="HEADPHONE" , - [EXTCON_JACK_LINE_IN ] ="LINE-IN" , - [EXTCON_JACK_LINE_OUT ] ="LINE-OUT" , - [EXTCON_JACK_VIDEO_IN ] ="VIDEO-IN" , - [EXTCON_JACK_VIDEO_OUT ] ="VIDEO-OUT" , - [EXTCON_JACK_SPDIF_IN ] ="SPDIF-IN" , - [EXTCON_JACK_SPDIF_OUT ] ="SPDIF-OUT" , + [EXTCON_JACK_MICROPHONE ] = { + .type =EXTCON_TYPE_JACK , + .id =EXTCON_JACK_MICROPHONE , + .name ="MICROPHONE" , + }, + [EXTCON_JACK_HEADPHONE ] = { + .type =EXTCON_TYPE_JACK , + .id =EXTCON_JACK_HEADPHONE , + .name ="HEADPHONE" , + }, + [EXTCON_JACK_LINE_IN ] = { + .type =EXTCON_TYPE_JACK , + .id =EXTCON_JACK_LINE_IN , + .name ="LINE-IN" , + }, + [EXTCON_JACK_LINE_OUT ] = { + .type =EXTCON_TYPE_JACK , + .id =EXTCON_JACK_LINE_OUT , + .name ="LINE-OUT" , + }, + [EXTCON_JACK_VIDEO_IN ] = { + .type =EXTCON_TYPE_JACK , + .id =EXTCON_JACK_VIDEO_IN , + .name ="VIDEO-IN" , + }, + [EXTCON_JACK_VIDEO_OUT ] = { + .type =EXTCON_TYPE_JACK , + .id =EXTCON_JACK_VIDEO_OUT , + .name ="VIDEO-OUT" , + }, + [EXTCON_JACK_SPDIF_IN ] = { + .type =EXTCON_TYPE_JACK , + .id =EXTCON_JACK_SPDIF_IN , + .name ="SPDIF-IN" , + }, + [EXTCON_JACK_SPDIF_OUT ] = { + .type =EXTCON_TYPE_JACK , + .id =EXTCON_JACK_SPDIF_OUT , + .name ="SPDIF-OUT" , + },/* Display external connector */ - [EXTCON_DISP_HDMI ] ="HDMI" , - [EXTCON_DISP_MHL ] ="MHL" , - [EXTCON_DISP_DVI ] ="DVI" , - [EXTCON_DISP_VGA ] ="VGA" , + [EXTCON_DISP_HDMI ] = { + .type =EXTCON_TYPE_DISP , + .id =EXTCON_DISP_HDMI , + .name ="HDMI" , + }, + [EXTCON_DISP_MHL ] = { + .type =EXTCON_TYPE_DISP , + .id =EXTCON_DISP_MHL , + .name ="MHL" , + }, + [EXTCON_DISP_DVI ] = { + .type =EXTCON_TYPE_DISP , + .id =EXTCON_DISP_DVI , + .name ="DVI" , + }, + [EXTCON_DISP_VGA ] = { + .type =EXTCON_TYPE_DISP , + .id =EXTCON_DISP_VGA , + .name ="VGA" , + },/* Miscellaneous external connector */ - [EXTCON_DOCK ] ="DOCK" , - [EXTCON_JIG ] ="JIG" , - [EXTCON_MECHANICAL ] ="MECHANICAL" , - -NULL , + [EXTCON_DOCK ] = { + .type =EXTCON_TYPE_MISC , + .id =EXTCON_DOCK , + .name ="DOCK" , + }, + [EXTCON_JIG ] = { + .type =EXTCON_TYPE_MISC , + .id =EXTCON_JIG , + .name ="JIG" , + }, + [EXTCON_MECHANICAL ] = { + .type =EXTCON_TYPE_MISC , + .id =EXTCON_MECHANICAL , + .name ="MECHANICAL" , + }, + + {/* sentinel */ } };/**
@@ -168,7 +269,7 @@ static ssize_t state_show(struct device *dev, struct device_attribute *attr,for (i =0 ; i < edev->max_supported; i++) { count +=sprintf (buf + count,"%s=%d\n" , - extcon_name[edev->supported_cable[i]], + extcon_info[edev->supported_cable[i]].name, !!(edev->state & (1 << i))); }
@@ -193,7 +294,7 @@ static ssize_t cable_name_show(struct device *dev,int i = cable->cable_index;return sprintf (buf,"%s\n" , - extcon_name[cable->edev->supported_cable[i]]); + extcon_info[cable->edev->supported_cable[i]].name); } static ssize_t cable_state_show(struct device *dev,
include/linux/extcon.h +9 -0
@@ -29,6 +29,15 @@#include <linux/device.h> /* +* Define the type of supported external connectors +*/ +#define EXTCON_TYPE_USB BIT(0)/* USB connector */ +#define EXTCON_TYPE_CHG BIT(1)/* Charger connector */ +#define EXTCON_TYPE_JACK BIT(2)/* Jack connector */ +#define EXTCON_TYPE_DISP BIT(3)/* Display connector */ +#define EXTCON_TYPE_MISC BIT(4)/* Miscellaneous connector */ + +/* * Define the unique id of supported external connectors */ #define EXTCON_NONE 0
Signature · 1 line
1.7.9.5
PATCH 29/51 extcon: Add the support for extcon property according to extcon type
In reply to Kishon Vijay Abraham IFrom: Chanwoo Choi <[email protected]>
This patch support the extcon property for the external connector because each external connector might have the property according to the H/W design and the specific characteristics.
- EXTCON_PROP_USB_[property name]
- EXTCON_PROP_CHG_[property name]
- EXTCON_PROP_JACK_[property name]
- EXTCON_PROP_DISP_[property name]
Add the new extcon APIs to get/set the property value as following:
- int extcon_get_property(struct extcon_dev *edev, unsigned int id, unsigned int prop,
union extcon_property_value *prop_val)
- int extcon_set_property(struct extcon_dev *edev, unsigned int id, unsigned int prop,
union extcon_property_value prop_val)
--- drivers/extcon/extcon.c | 201 ++++++++++++++++++++++++++++++++++++++++++++++- include/linux/extcon.h | 81 +++++++++++++++++++ 2 files changed, 281 insertions(+), 1 deletion(-)
drivers/extcon/extcon.c +200 -1
@@ -196,6 +196,11 @@ struct extcon_cable {struct device_attribute attr_state;struct attribute *attrs[3 ];/* to be fed to attr_g.attrs */ + +union extcon_property_value usb_propval[EXTCON_PROP_USB_CNT ]; +union extcon_property_value chg_propval[EXTCON_PROP_CHG_CNT ]; +union extcon_property_value jack_propval[EXTCON_PROP_JACK_CNT ]; +union extcon_property_value disp_propval[EXTCON_PROP_DISP_CNT ]; };static struct class *extcon_class;
@@ -248,6 +253,27 @@ static int find_cable_index_by_id(struct extcon_dev *edev, const unsigned int idreturn -EINVAL ; } +static int get_extcon_type (unsigned int prop) +{ +switch (prop) { + case EXTCON_PROP_USB_MIN ... EXTCON_PROP_USB_MAX: +return EXTCON_TYPE_USB ; + case EXTCON_PROP_CHG_MIN ... EXTCON_PROP_CHG_MAX: +return EXTCON_TYPE_CHG ; + case EXTCON_PROP_JACK_MIN ... EXTCON_PROP_JACK_MAX: +return EXTCON_TYPE_JACK ; + case EXTCON_PROP_DISP_MIN ... EXTCON_PROP_DISP_MAX: +return EXTCON_TYPE_DISP ; +default : +return -EINVAL ; + } +} + +static bool is_extcon_attached (struct extcon_dev *edev,unsigned int index) +{ +return !!(edev->state &BIT (index)); +} +static bool is_extcon_changed (u32 prev,u32 new,int idx,bool *attached) {if (((prev >> idx) &0x1 ) != ((new >> idx) &0x1 )) {
@@ -258,6 +284,34 @@ static bool is_extcon_changed(u32 prev, u32 new, int idx, bool *attached)return false; } +static bool is_extcon_property_supported (unsigned int id,unsigned int prop) +{ +int type; + +/* Check whether the property is supported or not. */ + type =get_extcon_type (prop); +if (type <0 ) +return false; + +/* Check whether a specific extcon id supports the property or not. */ +return !!(extcon_info[id].type & type); +} + +static void init_property (struct extcon_dev *edev,unsigned int id,int index) +{ +unsigned int type = extcon_info[id].type; +struct extcon_cable *cable = &edev->cables[index]; + +if (EXTCON_TYPE_USB & type) +memset (cable->usb_propval,0 ,sizeof (cable->usb_propval)); +if (EXTCON_TYPE_CHG & type) +memset (cable->chg_propval,0 ,sizeof (cable->chg_propval)); +if (EXTCON_TYPE_JACK & type) +memset (cable->jack_propval,0 ,sizeof (cable->jack_propval)); +if (EXTCON_TYPE_DISP & type) +memset (cable->disp_propval,0 ,sizeof (cable->disp_propval)); +} +static ssize_t state_show (struct device *dev,struct device_attribute *attr,char *buf) {
@@ -421,7 +475,7 @@ int extcon_get_cable_state_(struct extcon_dev *edev, const unsigned int id)if (edev->max_supported && edev->max_supported <= index)return -EINVAL ; -return !!(edev->state & (1 << index)); +return is_extcon_attached (edev, index); }EXPORT_SYMBOL_GPL (extcon_get_cable_state_);
@@ -449,12 +503,157 @@ int extcon_set_cable_state_(struct extcon_dev *edev, unsigned int id,if (edev->max_supported && edev->max_supported <= index)return -EINVAL ; +/* +* Initialize the value of extcon property before setting +* the detached state for an external connector. +*/ +if (!cable_state) +init_property (edev, id, index); + state = cable_state ? (1 << index) :0 ;return extcon_update_state (edev,1 << index, state); }EXPORT_SYMBOL_GPL (extcon_set_cable_state_);/** +* extcon_get_property() - Get the property value of a specific cable. +* @edev: the extcon device that has the cable. +* @id: the unique id of each external connector +* in extcon enumeration. +* @prop: the property id among enum extcon_property. +* @prop_val: the pointer which store the value of property. +* +* When getting the property value of external connector, the external connector +* should be attached. If detached state, function just return 0 without +* property value. Also, the each property should be included in the list of +* supported properties according to the type of external connectors. +* +* Returns 0 if success or error number if fail +*/ +int extcon_get_property (struct extcon_dev *edev,unsigned int id, +unsigned int prop, +union extcon_property_value *prop_val) +{ +struct extcon_cable *cable; +unsigned long flags; +int index, ret =0 ; + + *prop_val = (union extcon_property_value )(0 ); + +if (!edev) +return -EINVAL ; + +/* Check whether the property is supported or not */ +if (!is_extcon_property_supported (id, prop)) +return -EINVAL ; + +/* Find the cable index of external connector by using id */ + index =find_cable_index_by_id (edev, id); +if (index <0 ) +return index; + +spin_lock_irqsave (&edev->lock, flags); + +/* +* Check whether the external connector is attached. +* If external connector is detached, the user can not +* get the property value. +*/ +if (!is_extcon_attached (edev, index)) { +spin_unlock_irqrestore (&edev->lock, flags); +return 0 ; + } + + cable = &edev->cables[index]; + +/* Get the property value according to extcon type */ +switch (prop) { + case EXTCON_PROP_USB_MIN ... EXTCON_PROP_USB_MAX: + *prop_val = cable->usb_propval[prop -EXTCON_PROP_USB_MIN ]; +break ; + case EXTCON_PROP_CHG_MIN ... EXTCON_PROP_CHG_MAX: + *prop_val = cable->chg_propval[prop -EXTCON_PROP_CHG_MIN ]; +break ; + case EXTCON_PROP_JACK_MIN ... EXTCON_PROP_JACK_MAX: + *prop_val = cable->jack_propval[prop -EXTCON_PROP_JACK_MIN ]; +break ; + case EXTCON_PROP_DISP_MIN ... EXTCON_PROP_DISP_MAX: + *prop_val = cable->disp_propval[prop -EXTCON_PROP_DISP_MIN ]; +break ; +default : + ret = -EINVAL ; +break ; + } + +spin_unlock_irqrestore (&edev->lock, flags); + +return ret; +} +EXPORT_SYMBOL_GPL (extcon_get_property); + +/** +* extcon_set_property() - Set the property value of a specific cable. +* @edev: the extcon device that has the cable. +* @id: the unique id of each external connector +* in extcon enumeration. +* @prop: the property id among enum extcon_property. +* @prop_val: the pointer including the new value of property. +* +* The each property should be included in the list of supported properties +* according to the type of external connectors. +* +* Returns 0 if success or error number if fail +*/ +int extcon_set_property (struct extcon_dev *edev,unsigned int id, +unsigned int prop, +union extcon_property_value prop_val) +{ +struct extcon_cable *cable; +unsigned long flags; +int index, ret =0 ; + +if (!edev) +return -EINVAL ; + +/* Check whether the property is supported or not */ +if (!is_extcon_property_supported (id, prop)) +return -EINVAL ; + +/* Find the cable index of external connector by using id */ + index =find_cable_index_by_id (edev, id); +if (index <0 ) +return index; + +spin_lock_irqsave (&edev->lock, flags); + + cable = &edev->cables[index]; + +/* Set the property value according to extcon type */ +switch (prop) { + case EXTCON_PROP_USB_MIN ... EXTCON_PROP_USB_MAX: + cable->usb_propval[prop -EXTCON_PROP_USB_MIN ] = prop_val; +break ; + case EXTCON_PROP_CHG_MIN ... EXTCON_PROP_CHG_MAX: + cable->chg_propval[prop -EXTCON_PROP_CHG_MIN ] = prop_val; +break ; + case EXTCON_PROP_JACK_MIN ... EXTCON_PROP_JACK_MAX: + cable->jack_propval[prop -EXTCON_PROP_JACK_MIN ] = prop_val; +break ; + case EXTCON_PROP_DISP_MIN ... EXTCON_PROP_DISP_MAX: + cable->disp_propval[prop -EXTCON_PROP_DISP_MIN ] = prop_val; +break ; +default : + ret = -EINVAL ; +break ; + } + +spin_unlock_irqrestore (&edev->lock, flags); + +return ret; +} +EXPORT_SYMBOL_GPL (extcon_set_property); + +/** * extcon_get_extcon_dev() - Get the extcon device instance from the name * @extcon_name: The extcon name provided with extcon_dev_register() */
include/linux/extcon.h +81 -0
99 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 30/51 extcon: Add the support for the capability of each property
In reply to Kishon Vijay Abraham IFrom: Chanwoo Choi <[email protected]>
This patch adds the support of the property capability setting. This function decides the supported properties of each external connector on extcon provider driver.
Ths list of new extcon APIs to get/set the capability of property as following:
- int extcon_get_property_capability(struct extcon_dev *edev,
unsigned int id, unsigned int prop); - int extcon_set_property_capability(struct extcon_dev *edev, unsigned int id, unsigned int prop);
--- drivers/extcon/extcon.c | 140 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/extcon.h | 22 ++++++++ 2 files changed, 162 insertions(+)
drivers/extcon/extcon.c +140 -0
@@ -201,6 +201,11 @@ struct extcon_cable {union extcon_property_value chg_propval[EXTCON_PROP_CHG_CNT ];union extcon_property_value jack_propval[EXTCON_PROP_JACK_CNT ];union extcon_property_value disp_propval[EXTCON_PROP_DISP_CNT ]; + +unsigned long usb_bits[BITS_TO_LONGS (EXTCON_PROP_USB_CNT )]; +unsigned long chg_bits[BITS_TO_LONGS (EXTCON_PROP_CHG_CNT )]; +unsigned long jack_bits[BITS_TO_LONGS (EXTCON_PROP_JACK_CNT )]; +unsigned long disp_bits[BITS_TO_LONGS (EXTCON_PROP_DISP_CNT )]; };static struct class *extcon_class;
@@ -297,6 +302,39 @@ static bool is_extcon_property_supported(unsigned int id, unsigned int prop)return !!(extcon_info[id].type & type); } +static int is_extcon_property_capability (struct extcon_dev *edev, +unsigned int id,int index,unsigned int prop) +{ +struct extcon_cable *cable; +int type, ret; + +/* Check whether the property is supported or not. */ + type =get_extcon_type (prop); +if (type <0 ) +return type; + + cable = &edev->cables[index]; + +switch (type) { +case EXTCON_TYPE_USB : + ret =test_bit (prop -EXTCON_PROP_USB_MIN , cable->usb_bits); +break ; +case EXTCON_TYPE_CHG : + ret =test_bit (prop -EXTCON_PROP_CHG_MIN , cable->chg_bits); +break ; +case EXTCON_TYPE_JACK : + ret =test_bit (prop -EXTCON_PROP_JACK_MIN , cable->jack_bits); +break ; +case EXTCON_TYPE_DISP : + ret =test_bit (prop -EXTCON_PROP_DISP_MIN , cable->disp_bits); +break ; +default : + ret = -EINVAL ; + } + +return ret; +} +static void init_property (struct extcon_dev *edev,unsigned int id,int index) {unsigned int type = extcon_info[id].type;
@@ -554,6 +592,12 @@ int extcon_get_property(struct extcon_dev *edev, unsigned int id,spin_lock_irqsave (&edev->lock, flags); +/* Check whether the property is available or not. */ +if (!is_extcon_property_capability (edev, id, index, prop)) { +spin_unlock_irqrestore (&edev->lock, flags); +return -EPERM ; + } +/* * Check whether the external connector is attached. * If external connector is detached, the user can not
@@ -626,6 +670,12 @@ int extcon_set_property(struct extcon_dev *edev, unsigned int id,spin_lock_irqsave (&edev->lock, flags); +/* Check whether the property is available or not. */ +if (!is_extcon_property_capability (edev, id, index, prop)) { +spin_unlock_irqrestore (&edev->lock, flags); +return -EPERM ; + } + cable = &edev->cables[index];/* Set the property value according to extcon type */
@@ -654,6 +704,96 @@ int extcon_set_property(struct extcon_dev *edev, unsigned int id,EXPORT_SYMBOL_GPL (extcon_set_property);/** +* extcon_get_property_capability() - Get the capability of property +* of an external connector. +* @edev: the extcon device that has the cable. +* @id: the unique id of each external connector +* in extcon enumeration. +* @prop: the property id among enum extcon_property. +* +* Returns 1 if the property is available or 0 if not available. +*/ +int extcon_get_property_capability (struct extcon_dev *edev,unsigned int id, +unsigned int prop) +{ +int index; + +if (!edev) +return -EINVAL ; + +/* Check whether the property is supported or not */ +if (!is_extcon_property_supported (id, prop)) +return -EINVAL ; + +/* Find the cable index of external connector by using id */ + index =find_cable_index_by_id (edev, id); +if (index <0 ) +return index; + +return is_extcon_property_capability (edev, id, index, prop); +} +EXPORT_SYMBOL_GPL (extcon_get_property_capability); + +/** +* extcon_set_property_capability() - Set the capability of a property +* of an external connector. +* @edev: the extcon device that has the cable. +* @id: the unique id of each external connector +* in extcon enumeration. +* @prop: the property id among enum extcon_property. +* +* This function set the capability of a property for an external connector +* to mark the bit in capability bitmap which mean the available state of +* a property. +* +* Returns 0 if success or error number if fail +*/ +int extcon_set_property_capability (struct extcon_dev *edev,unsigned int id, +unsigned int prop) +{ +struct extcon_cable *cable; +int index, type, ret =0 ; + +if (!edev) +return -EINVAL ; + +/* Check whether the property is supported or not. */ +if (!is_extcon_property_supported (id, prop)) +return -EINVAL ; + +/* Find the cable index of external connector by using id. */ + index =find_cable_index_by_id (edev, id); +if (index <0 ) +return index; + + type =get_extcon_type (prop); +if (type <0 ) +return type; + + cable = &edev->cables[index]; + +switch (type) { +case EXTCON_TYPE_USB : +__set_bit (prop -EXTCON_PROP_USB_MIN , cable->usb_bits); +break ; +case EXTCON_TYPE_CHG : +__set_bit (prop -EXTCON_PROP_CHG_MIN , cable->chg_bits); +break ; +case EXTCON_TYPE_JACK : +__set_bit (prop -EXTCON_PROP_JACK_MIN , cable->jack_bits); +break ; +case EXTCON_TYPE_DISP : +__set_bit (prop -EXTCON_PROP_DISP_MIN , cable->disp_bits); +break ; +default : + ret = -EINVAL ; + } + +return ret; +} +EXPORT_SYMBOL_GPL (extcon_set_property_capability); + +/** * extcon_get_extcon_dev() - Get the extcon device instance from the name * @extcon_name: The extcon name provided with extcon_dev_register() */
include/linux/extcon.h +22 -0
@@ -235,6 +235,16 @@ extern int extcon_set_property(struct extcon_dev *edev, unsigned int id, union extcon_property_value prop_val);/* +* get/set_property_capability set the capability of the property for each +* external connector. They are used to set the capability of the property +* of each external connector based on the id and property. +*/ +extern int extcon_get_property_capability (struct extcon_dev *edev, +unsigned int id,unsigned int prop); +extern int extcon_set_property_capability (struct extcon_dev *edev, +unsigned int id,unsigned int prop); + +/* * Following APIs are to monitor every action of a notifier. * Registrar gets notified for every external port of a connection device. * Probably this could be used to debug an action of notifier; however,
@@ -320,6 +330,18 @@ static inline int extcon_set_property(struct extcon_dev *edev, unsigned int id,return 0 ; } +static inline int extcon_get_property_capability (struct extcon_dev *edev, +unsigned int id,unsigned int prop) +{ +return 0 ; +} + +static inline int extcon_set_property_capability (struct extcon_dev *edev, +unsigned int id,unsigned int prop) +{ +return 0 ; +} +static inline struct extcon_dev *extcon_get_extcon_dev (const char *extcon_name) {return NULL ;
Signature · 1 line
1.7.9.5
PATCH 31/51 extcon: Rename the extcon_set/get_state() to maintain the function naming pattern
In reply to Kishon Vijay Abraham IFrom: Chanwoo Choi <[email protected]>
This patch just renames the existing extcon_get/set_cable_state_() as following because of maintaining the function naming pattern like as extcon APIs for property.
- extcon_set_cable_state_() -> extcon_set_state()
- extcon_get_cable_state_() -> extcon_get_state()
But, this patch remains the old extcon_set/get_cable_state_() functions to prevent the build break. After altering new APIs, remove the old APIs.
--- drivers/extcon/extcon.c | 28 +++++++++++++--------------- include/linux/extcon.h | 25 ++++++++++++++++++------- 2 files changed, 31 insertions(+), 22 deletions(-)
drivers/extcon/extcon.c +13 -15
@@ -398,8 +398,7 @@ static ssize_t cable_state_show(struct device *dev,int i = cable->cable_index;return sprintf (buf,"%d\n" , -extcon_get_cable_state_ (cable->edev, - cable->edev->supported_cable[i])); +extcon_get_state (cable->edev, cable->edev->supported_cable[i])); }/**
@@ -495,13 +494,14 @@ static int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state) }/** -* extcon_get_cable_state_() - Get the status of a specific cable. +* extcon_get_state() - Get the state of a external connector. * @edev: the extcon device that has the cable. * @id: the unique id of each external connector in extcon enumeration. */ -int extcon_get_cable_state_ (struct extcon_dev *edev,const unsigned int id) +int extcon_get_state (struct extcon_dev *edev,const unsigned int id) { -int index; +int index, state; +unsigned long flags;if (!edev)return -EINVAL ;
@@ -510,22 +510,23 @@ int extcon_get_cable_state_(struct extcon_dev *edev, const unsigned int id)if (index <0 )return index; -if (edev->max_supported && edev->max_supported <= index) -return -EINVAL ; +spin_lock_irqsave (&edev->lock, flags); + state =is_extcon_attached (edev, index); +spin_unlock_irqrestore (&edev->lock, flags); -return is_extcon_attached (edev, index); +return state; } -EXPORT_SYMBOL_GPL (extcon_get_cable_state_); +EXPORT_SYMBOL_GPL (extcon_get_state);/** -* extcon_set_cable_state_() - Set the status of a specific cable. +* extcon_set_state() - Set the state of a external connector. * @edev: the extcon device that has the cable. * @id: the unique id of each external connector * in extcon enumeration. * @state: the new cable status. The default semantics is * true: attached / false: detached. */ -int extcon_set_cable_state_ (struct extcon_dev *edev,unsigned int id, +int extcon_set_state (struct extcon_dev *edev,unsigned int id,bool cable_state) {u32 state;
@@ -538,9 +539,6 @@ int extcon_set_cable_state_(struct extcon_dev *edev, unsigned int id,if (index <0 )return index; -if (edev->max_supported && edev->max_supported <= index) -return -EINVAL ; -/* * Initialize the value of extcon property before setting * the detached state for an external connector.
@@ -551,7 +549,7 @@ int extcon_set_cable_state_(struct extcon_dev *edev, unsigned int id, state = cable_state ? (1 << index) :0 ;return extcon_update_state (edev,1 << index, state); } -EXPORT_SYMBOL_GPL (extcon_set_cable_state_); +EXPORT_SYMBOL_GPL (extcon_set_state);/** * extcon_get_property() - Get the property value of a specific cable.
include/linux/extcon.h +18 -7
@@ -216,11 +216,11 @@ extern struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,extern void devm_extcon_dev_free (struct device *dev,struct extcon_dev *edev);/* -* get/set_cable_state access each bit of the 32b encoded state value. +* get/set_state access each bit of the 32b encoded state value. * They are used to access the status of each cable based on the cable id. */ -extern int extcon_get_cable_state_ (struct extcon_dev *edev,unsigned int id); -extern int extcon_set_cable_state_ (struct extcon_dev *edev,unsigned int id, +extern int extcon_get_state (struct extcon_dev *edev,unsigned int id); +extern int extcon_set_state (struct extcon_dev *edev,unsigned int id,bool cable_state);/*
@@ -305,14 +305,14 @@ static inline struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,static inline void devm_extcon_dev_free (struct extcon_dev *edev) { } -static inline int extcon_get_cable_state_ (struct extcon_dev *edev, -unsigned int id) + +static inline int extcon_get_state (struct extcon_dev *edev,unsigned int id) {return 0 ; } -static inline int extcon_set_cable_state_ (struct extcon_dev *edev, -unsigned int id,bool cable_state) +static inline int extcon_set_state (struct extcon_dev *edev,unsigned int id, +bool cable_state) {return 0 ; }
@@ -402,4 +402,15 @@ static inline int extcon_unregister_interest(struct extcon_specific_cable_nb {return -EINVAL ; } + +static inline int extcon_get_cable_state_ (struct extcon_dev *edev,unsigned int id) +{ +return extcon_get_state (edev, id); +} + +static inline int extcon_set_cable_state_ (struct extcon_dev *edev,unsigned int id, +bool cable_state) +{ +return extcon_set_state (edev, id, cable_state); +}#endif /* __LINUX_EXTCON_H__ */
Signature · 1 line
1.7.9.5
PATCH 32/51 extcon: Add the synchronization extcon APIs to support the notification
In reply to Kishon Vijay Abraham IFrom: Chanwoo Choi <[email protected]>
This patch adds the synchronization extcon APIs to support the notifications for both state and property. When extcon_*_sync() functions is called, the extcon informs the information from extcon provider to extcon client.
The extcon driver may need to change the both state and multiple properties at the same time. After setting the data of a external connector, the extcon send the notification to client driver with the extcon_*_sync().
The list of new extcon APIs as following:
- extcon_sync() : Send the notification for each external connector to synchronize the information between extcon provider driver and extcon client driver.
- extcon_set_state_sync() : Set the state of external connector with noti.
- extcon_set_property_sync() : Set the property of external connector with noti.
For example,
case 1, change the state of external connector and synchronized the data.
extcon_set_state_sync(edev, EXTCON_USB, 1);
case 2, change both the state and property of external connector
and synchronized the data. extcon_set_state(edev, EXTCON_USB, 1); extcon_set_property(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS 1); extcon_sync(edev, EXTCON_USB);
case 3, change the property of external connector and synchronized the data.
extcon_set_property(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS, 0); extcon_sync(edev, EXTCON_USB);
case 4, change the property of external connector and synchronized the data.
extcon_set_property_sync(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS, 0);
--- drivers/extcon/extcon.c | 210 ++++++++++++++++++++++++++++++----------------- include/linux/extcon.h | 30 ++++++- 2 files changed, 164 insertions(+), 76 deletions(-)
drivers/extcon/extcon.c +135 -75
@@ -279,14 +279,11 @@ static bool is_extcon_attached(struct extcon_dev *edev, unsigned int index)return !!(edev->state &BIT (index)); } -static bool is_extcon_changed (u32 prev,u32 new,int idx,bool *attached) +static bool is_extcon_changed (struct extcon_dev *edev,int index, +bool new_state) { -if (((prev >> idx) &0x1 ) != ((new >> idx) &0x1 )) { - *attached = ((new >> idx) &0x1 ) ? true : false; -return true; - } - -return false; +int state = !!(edev->state &BIT (index)); +return (state != new_state); }static bool is_extcon_property_supported (unsigned int id,unsigned int prop)
@@ -402,21 +399,13 @@ static ssize_t cable_state_show(struct device *dev, }/** -* extcon_update_state() - Update the cable attach states of the extcon device -* only for the masked bits. -* @edev: the extcon device -* @mask: the bit mask to designate updated bits. -* @state: new cable attach status for @edev -* -* Changing the state sends uevent with environment variable containing -* the name of extcon device (envp[0]) and the state output (envp[1]). -* Tizen uses this format for extcon device to get events from ports. -* Android uses this format as well. +* extcon_sync() - Synchronize the states for both the attached/detached +* @edev: the extcon device that has the cable. * -* Note that the notifier provides which bits are changed in the state -* variable with the val parameter (second) to the callback. +* This function send a notification to synchronize the all states of a +* specific external connector */ -static int extcon_update_state (struct extcon_dev *edev,u32 mask,u32 state) +int extcon_sync (struct extcon_dev *edev,unsigned int id) {char name_buf[120 ];char state_buf[120 ];
@@ -425,73 +414,58 @@ static int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state)int env_offset =0 ;int length;int index; +int state;unsigned long flags; -bool attached;if (!edev)return -EINVAL ; + index =find_cable_index_by_id (edev, id); +if (index <0 ) +return index; +spin_lock_irqsave (&edev->lock, flags); -if (edev->state != ((edev->state & ~mask) | (state & mask))) { -u32 old_state; + state = !!(edev->state &BIT (index)); +raw_notifier_call_chain (&edev->nh[index], state, edev); -if (check_mutually_exclusive (edev, (edev->state & ~mask) | - (state & mask))) { -spin_unlock_irqrestore (&edev->lock, flags); -return -EPERM ; - } +/* This could be in interrupt handler */ + prop_buf = (char *)get_zeroed_page (GFP_ATOMIC ); +if (!prop_buf) { +/* Unlock early before uevent */ +spin_unlock_irqrestore (&edev->lock, flags); - old_state = edev->state; - edev->state &= ~mask; - edev->state |= state & mask; +dev_err (&edev->dev,"out of memory in extcon_set_state\n" ); +kobject_uevent (&edev->dev.kobj,KOBJ_CHANGE ); -for (index =0 ; index < edev->max_supported; index++) { -if (is_extcon_changed (old_state, edev->state, index, - &attached)) -raw_notifier_call_chain (&edev->nh[index], - attached, edev); - } - -/* This could be in interrupt handler */ - prop_buf = (char *)get_zeroed_page (GFP_ATOMIC ); -if (prop_buf) { - length =name_show (&edev->dev,NULL , prop_buf); -if (length >0 ) { -if (prop_buf[length -1 ] =='\n' ) - prop_buf[length -1 ] =0 ; -snprintf (name_buf,sizeof (name_buf), -"NAME=%s" , prop_buf); - envp[env_offset++] = name_buf; - } - length =state_show (&edev->dev,NULL , prop_buf); -if (length >0 ) { -if (prop_buf[length -1 ] =='\n' ) - prop_buf[length -1 ] =0 ; -snprintf (state_buf,sizeof (state_buf), -"STATE=%s" , prop_buf); - envp[env_offset++] = state_buf; - } - envp[env_offset] =NULL ; -/* Unlock early before uevent */ -spin_unlock_irqrestore (&edev->lock, flags); +return 0 ; + } -kobject_uevent_env (&edev->dev.kobj,KOBJ_CHANGE , envp); -free_page ((unsigned long )prop_buf); - }else { -/* Unlock early before uevent */ -spin_unlock_irqrestore (&edev->lock, flags); + length =name_show (&edev->dev,NULL , prop_buf); +if (length >0 ) { +if (prop_buf[length -1 ] =='\n' ) + prop_buf[length -1 ] =0 ; +snprintf (name_buf,sizeof (name_buf),"NAME=%s" , prop_buf); + envp[env_offset++] = name_buf; + } -dev_err (&edev->dev,"out of memory in extcon_set_state\n" ); -kobject_uevent (&edev->dev.kobj,KOBJ_CHANGE ); - } - }else { -/* No changes */ -spin_unlock_irqrestore (&edev->lock, flags); + length =state_show (&edev->dev,NULL , prop_buf); +if (length >0 ) { +if (prop_buf[length -1 ] =='\n' ) + prop_buf[length -1 ] =0 ; +snprintf (state_buf,sizeof (state_buf),"STATE=%s" , prop_buf); + envp[env_offset++] = state_buf; } + envp[env_offset] =NULL ; + +/* Unlock early before uevent */ +spin_unlock_irqrestore (&edev->lock, flags); +kobject_uevent_env (&edev->dev.kobj,KOBJ_CHANGE , envp); +free_page ((unsigned long )prop_buf);return 0 ; } +EXPORT_SYMBOL_GPL (extcon_sync);/** * extcon_get_state() - Get the state of a external connector.
@@ -520,17 +494,22 @@ EXPORT_SYMBOL_GPL(extcon_get_state);/** * extcon_set_state() - Set the state of a external connector. +* without a notification. * @edev: the extcon device that has the cable. * @id: the unique id of each external connector * in extcon enumeration. * @state: the new cable status. The default semantics is * true: attached / false: detached. +* +* This function only set the state of a external connector without +* a notification. To synchronize the data of a external connector, +* use extcon_set_state_sync() and extcon_sync(). */ int extcon_set_state (struct extcon_dev *edev,unsigned int id,bool cable_state) { -u32 state; -int index; +unsigned long flags; +int index, ret =0 ;if (!edev)return -EINVAL ;
@@ -539,6 +518,18 @@ int extcon_set_state(struct extcon_dev *edev, unsigned int id,if (index <0 )return index; +spin_lock_irqsave (&edev->lock, flags); + +/* Check whether the external connector's state is changed. */ +if (!is_extcon_changed (edev, index, cable_state)) + goto out; + +if (check_mutually_exclusive (edev, + (edev->state & ~BIT (index)) | (cable_state &BIT (index)))) { + ret = -EPERM ; + goto out; + } +/* * Initialize the value of extcon property before setting * the detached state for an external connector.
@@ -546,12 +537,56 @@ int extcon_set_state(struct extcon_dev *edev, unsigned int id,if (!cable_state)init_property (edev, id, index); - state = cable_state ? (1 << index) :0 ; -return extcon_update_state (edev,1 << index, state); +/* Update the state for a external connector. */ +if (cable_state) + edev->state |=BIT (index); +else + edev->state &= ~(BIT (index)); +out: +spin_unlock_irqrestore (&edev->lock, flags); + +return ret; }EXPORT_SYMBOL_GPL (extcon_set_state);/** +* extcon_set_state_sync() - Set the state of a external connector +* with a notification. +* @edev: the extcon device that has the cable. +* @id: the unique id of each external connector +* in extcon enumeration. +* @state: the new cable status. The default semantics is +* true: attached / false: detached. +* +* This function set the state of external connector and synchronize the data +* by usning a notification. +*/ +int extcon_set_state_sync (struct extcon_dev *edev,unsigned int id, +bool cable_state) +{ +int ret, index; +unsigned long flags; + + index =find_cable_index_by_id (edev, id); +if (index <0 ) +return index; + +/* Check whether the external connector's state is changed. */ +spin_lock_irqsave (&edev->lock, flags); + ret =is_extcon_changed (edev, index, cable_state); +spin_unlock_irqrestore (&edev->lock, flags); +if (!ret) +return 0 ; + + ret =extcon_set_state (edev, id, cable_state); +if (ret <0 ) +return ret; + +return extcon_sync (edev, id); +} +EXPORT_SYMBOL_GPL (extcon_set_state_sync); + +/** * extcon_get_property() - Get the property value of a specific cable. * @edev: the extcon device that has the cable. * @id: the unique id of each external connector
@@ -702,6 +737,31 @@ int extcon_set_property(struct extcon_dev *edev, unsigned int id,EXPORT_SYMBOL_GPL (extcon_set_property);/** +* extcon_set_property_sync() - Set the property value of a specific cable +with a notification. +* @prop_val: the pointer including the new value of property. +* +* When setting the property value of external connector, the external connector +* should be attached. The each property should be included in the list of +* supported properties according to the type of external connectors. +* +* Returns 0 if success or error number if fail +*/ +int extcon_set_property_sync (struct extcon_dev *edev,unsigned int id, +unsigned int prop, +union extcon_property_value prop_val) +{ +int ret; + + ret =extcon_set_property (edev, id, prop, prop_val); +if (ret <0 ) +return ret; + +return extcon_sync (edev, id); +} +EXPORT_SYMBOL_GPL (extcon_set_property_sync); + +/** * extcon_get_property_capability() - Get the capability of property * of an external connector. * @edev: the extcon device that has the cable.
include/linux/extcon.h +29 -1
@@ -222,6 +222,13 @@ extern void devm_extcon_dev_free(struct device *dev, struct extcon_dev *edev);extern int extcon_get_state (struct extcon_dev *edev,unsigned int id);extern int extcon_set_state (struct extcon_dev *edev,unsigned int id,bool cable_state); +extern int extcon_set_state_sync (struct extcon_dev *edev,unsigned int id, +bool cable_state); + +/* +* Synchronize the state and property data for a specific external connector. +*/ +extern int extcon_sync (struct extcon_dev *edev,unsigned int id);/* * get/set_property access the property value of each external connector.
@@ -233,6 +240,9 @@ extern int extcon_get_property(struct extcon_dev *edev, unsigned int id,extern int extcon_set_property (struct extcon_dev *edev,unsigned int id,unsigned int prop,union extcon_property_value prop_val); +extern int extcon_set_property_sync (struct extcon_dev *edev,unsigned int id, +unsigned int prop, +union extcon_property_value prop_val);/* * get/set_property_capability set the capability of the property for each
@@ -317,6 +327,17 @@ static inline int extcon_set_state(struct extcon_dev *edev, unsigned int id,return 0 ; } +static inline int extcon_set_state_sync (struct extcon_dev *edev,unsigned int id, +bool cable_state) +{ +return 0 ; +} + +static inline int extcon_sync (struct extcon_dev *edev,unsigned int id) +{ +return 0 ; +} +static inline int extcon_get_property (struct extcon_dev *edev,unsigned int id,unsigned int prop,union extcon_property_value *prop_val)
@@ -330,6 +351,13 @@ static inline int extcon_set_property(struct extcon_dev *edev, unsigned int id,return 0 ; } +static inline int extcon_set_property_sync (struct extcon_dev *edev, +unsigned int id,unsigned int prop, +union extcon_property_value prop_val) +{ +return 0 ; +} +static inline int extcon_get_property_capability (struct extcon_dev *edev,unsigned int id,unsigned int prop) {
@@ -411,6 +439,6 @@ static inline int extcon_get_cable_state_(struct extcon_dev *edev, unsigned intstatic inline int extcon_set_cable_state_ (struct extcon_dev *edev,unsigned int id,bool cable_state) { -return extcon_set_state (edev, id, cable_state); +return extcon_set_state_sync (edev, id, cable_state); }#endif /* __LINUX_EXTCON_H__ */
Signature · 1 line
1.7.9.5
PATCH 33/51 extcon: Add EXTCON_DISP_DP and the property for USB Type-C
In reply to Kishon Vijay Abraham IFrom: Chris Zhong <[email protected]>
Add EXTCON_DISP_DP for the Display external connector. For Type-C connector the DisplayPort can work as an Alternate Mode(VESA DisplayPort Alt Mode on USB Type-C Standard). The Type-C support both normal and flipped orientation, so add a property to extcon.
--- drivers/extcon/extcon.c | 5 +++++ include/linux/extcon.h | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-)
drivers/extcon/extcon.c +5 -0
@@ -157,6 +157,11 @@ struct __extcon_info { .id = EXTCON_DISP_VGA, .name = "VGA", }, + [EXTCON_DISP_DP] = { + .type = EXTCON_TYPE_DISP | EXTCON_TYPE_USB, + .id = EXTCON_DISP_DP, + .name = "DP", + },/* Miscellaneous external connector */ [EXTCON_DOCK] = {
include/linux/extcon.h +7 -1
@@ -69,6 +69,7 @@#define EXTCON_DISP_MHL 41/* Mobile High-Definition Link */ #define EXTCON_DISP_DVI 42/* Digital Visual Interface */ #define EXTCON_DISP_VGA 43/* Video Graphics Array */ +#define EXTCON_DISP_DP 44/* Display Port */ /* Miscellaneous external connector */ #define EXTCON_DOCK 60
@@ -102,11 +103,16 @@* @type: integer (intval) * @value: 0 (low) or 1 (high) * @default: 0 (low) +* - EXTCON_PROP_USB_TYPEC_POLARITY +* @type: integer (intval) +* @value: 0 (normal) or 1 (flip) +* @default: 0 (normal) */ #define EXTCON_PROP_USB_VBUS 0 +#define EXTCON_PROP_USB_TYPEC_POLARITY 1#define EXTCON_PROP_USB_MIN 0 -#define EXTCON_PROP_USB_MAX 0 +#define EXTCON_PROP_USB_MAX 1#define EXTCON_PROP_USB_CNT (EXTCON_PROP_USB_MAX - EXTCON_PROP_USB_MIN + 1)/* Properties of EXTCON_TYPE_CHG. */
Signature · 1 line
1.7.9.5
PATCH 34/51 extcon: Add new EXTCON_DISP_HMD for Head-mounted Display device
In reply to Kishon Vijay Abraham IFrom: Chanwoo Choi <[email protected]>
This patch adds the new EXTCON_DISP_HMD id for Head-mounted Display[1] device. The HMD device is usually for USB connector type So, the HMD connector has the two extcon types of both EXTCON_TYPE_DISP and EXTCON_TYPE_USB.
[1] https://en.wikipedia.org/wiki/Head-mounted_display
--- drivers/extcon/extcon.c | 5 +++++ include/linux/extcon.h | 1 + 2 files changed, 6 insertions(+)
drivers/extcon/extcon.c +5 -0
@@ -162,6 +162,11 @@ struct __extcon_info { .id = EXTCON_DISP_DP, .name = "DP", }, + [EXTCON_DISP_HMD] = { + .type = EXTCON_TYPE_DISP | EXTCON_TYPE_USB, + .id = EXTCON_DISP_HMD, + .name = "HMD", + },/* Miscellaneous external connector */ [EXTCON_DOCK] = {
include/linux/extcon.h +1 -0
@@ -70,6 +70,7 @@#define EXTCON_DISP_DVI 42/* Digital Visual Interface */ #define EXTCON_DISP_VGA 43/* Video Graphics Array */ #define EXTCON_DISP_DP 44/* Display Port */ +#define EXTCON_DISP_HMD 45/* Head-Mounted Display */ /* Miscellaneous external connector */ #define EXTCON_DOCK 60
Signature · 1 line
1.7.9.5
PATCH 35/51 extcon: Add new EXTCON_CHG_WPT for Wireless Power Transfer device
In reply to Kishon Vijay Abraham IFrom: Chanwoo Choi <[email protected]>
This patchs add the new EXTCON_CHG_WPT for Wireless Power Transfer[1]. The Wireless Power Transfer is the transmission of electronical energy from a power source. The EXTCON_CHG_WPT has the EXTCON_TYPE_CHG.
[1] https://en.wikipedia.org/wiki/Wireless_power_transfer
--- drivers/extcon/extcon.c | 5 +++++ include/linux/extcon.h | 1 + 2 files changed, 6 insertions(+)
drivers/extcon/extcon.c +5 -0
@@ -93,6 +93,11 @@ struct __extcon_info { .id = EXTCON_CHG_USB_SLOW, .name = "SLOW-CHARGER", }, + [EXTCON_CHG_WPT] = { + .type = EXTCON_TYPE_CHG, + .id = EXTCON_CHG_WPT, + .name = "WPT", + },/* Jack external connector */ [EXTCON_JACK_MICROPHONE] = {
include/linux/extcon.h +1 -0
@@ -53,6 +53,7 @@#define EXTCON_CHG_USB_ACA 8/* Accessory Charger Adapter */ #define EXTCON_CHG_USB_FAST 9#define EXTCON_CHG_USB_SLOW 10 +#define EXTCON_CHG_WPT 11/* Wireless Power Transfer */ /* Jack external connector */ #define EXTCON_JACK_MICROPHONE 20
Signature · 1 line
1.7.9.5
PATCH 36/51 extcon: Introduce EXTCON_PROP_USB_SS property for SuperSpeed mode
In reply to Kishon Vijay Abraham IFrom: Guenter Roeck <[email protected]>
EXTCON_PROP_USB_SS (SuperSpeed)[1] is necessary to distinguish between USB/USB2 and USB3 connections on USB Type-C cables.
[1] https://en.wikipedia.org/wiki/USB#Overview
--- include/linux/extcon.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
include/linux/extcon.h +7 -1
@@ -109,12 +109,18 @@* @type: integer (intval) * @value: 0 (normal) or 1 (flip) * @default: 0 (normal) +* - EXTCON_PROP_USB_SS (SuperSpeed) +* @type: integer (intval) +* @value: 0 (USB/USB2) or 1 (USB3) +* @default: 0 (USB/USB2) +* */ #define EXTCON_PROP_USB_VBUS 0#define EXTCON_PROP_USB_TYPEC_POLARITY 1 +#define EXTCON_PROP_USB_SS 2#define EXTCON_PROP_USB_MIN 0 -#define EXTCON_PROP_USB_MAX 1 +#define EXTCON_PROP_USB_MAX 2#define EXTCON_PROP_USB_CNT (EXTCON_PROP_USB_MAX - EXTCON_PROP_USB_MIN + 1)/* Properties of EXTCON_TYPE_CHG. */
Signature · 1 line
1.7.9.5
PATCH 37/51 phy: da8xx-usb: Fix syscon device name
In reply to Kishon Vijay Abraham IFrom: David Lechner <[email protected]>
The syscon device in board config/device tree has been renamed.
--- drivers/phy/phy-da8xx-usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/phy-da8xx-usb.c +1 -1
@@ -154,7 +154,7 @@ static int da8xx_usb_phy_probe(struct platform_device *pdev) d_phy->regmap =syscon_regmap_lookup_by_compatible ("ti,da830-cfgchip" ); else - d_phy->regmap = syscon_regmap_lookup_by_pdevname("syscon.0"); + d_phy->regmap = syscon_regmap_lookup_by_pdevname("syscon");if (IS_ERR (d_phy->regmap)) {dev_err (dev,"Failed to get syscon\n" );return PTR_ERR (d_phy->regmap);
Signature · 1 line
1.7.9.5
PATCH 38/51 phy: Add USB Type-C PHY driver for rk3399
In reply to Kishon Vijay Abraham IFrom: Chris Zhong <[email protected]>
Add a PHY provider driver for the rk3399 SoC Type-c PHY. The USB Type-C PHY is designed to support the USB3 and DP applications. The USB3 operates in SuperSpeed mode and the DP can operate at RBR, HBR and HBR2 data rates. This driver create 2 PHY devices separately for USB3 and DisplyPort, and registers them under the child node.
--- drivers/phy/Kconfig | 9 + drivers/phy/Makefile | 1 + drivers/phy/phy-rockchip-typec.c | 1013 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 1023 insertions(+) create mode 100644 drivers/phy/phy-rockchip-typec.c
drivers/phy/Kconfig +9 -0
@@ -397,6 +397,15 @@ config PHY_ROCKCHIP_PCIE help Enable this to support the Rockchip PCIe PHY. +config PHY_ROCKCHIP_TYPEC + tristate "Rockchip TYPEC PHY Driver" + depends on OF && (ARCH_ROCKCHIP || COMPILE_TEST) + select EXTCON + select GENERIC_PHY + select RESET_CONTROLLER + help + Enable this to support the Rockchip USB TYPEC PHY. + config PHY_ST_SPEAR1310_MIPHY tristate "ST SPEAR1310-MIPHY driver" select GENERIC_PHY
drivers/phy/Makefile +1 -0
@@ -44,6 +44,7 @@ obj-$(CONFIG_PHY_ROCKCHIP_INNO_USB2) += phy-rockchip-inno-usb2.o obj-$(CONFIG_PHY_ROCKCHIP_EMMC) += phy-rockchip-emmc.o obj-$(CONFIG_PHY_ROCKCHIP_PCIE) += phy-rockchip-pcie.o obj-$(CONFIG_PHY_ROCKCHIP_DP) += phy-rockchip-dp.o +obj-$(CONFIG_PHY_ROCKCHIP_TYPEC) += phy-rockchip-typec.o obj-$(CONFIG_PHY_QCOM_IPQ806X_SATA) += phy-qcom-ipq806x-sata.o obj-$(CONFIG_PHY_ST_SPEAR1310_MIPHY) += phy-spear1310-miphy.o obj-$(CONFIG_PHY_ST_SPEAR1340_MIPHY) += phy-spear1340-miphy.o
drivers/phy/phy-rockchip-typec.c new file +1013 -0
1,013 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 39/51 Documentation: bindings: add dt doc for Rockchip USB Type-C PHY
In reply to Kishon Vijay Abraham IFrom: Chris Zhong <[email protected]>
This patch adds a binding that describes the Rockchip USB Type-C PHY for rk3399
--- .../devicetree/bindings/phy/phy-rockchip-typec.txt | 101 ++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/phy-rockchip-typec.txt
Documentation/devicetree/bindings/phy/phy-rockchip-typec.txt new file +101 -0
@@ -0,0 +1,101 @@ +* ROCKCHIP type-c PHY +--------------------- + +Required properties: + - compatible : must be "rockchip,rk3399-typec-phy" + - reg: Address and length of the usb phy control register set + - rockchip,grf : phandle to the syscon managing the "general + register files" + - clocks : phandle + clock specifier for the phy clocks + - clock-names : string, clock name, must be "tcpdcore", "tcpdphy-ref"; + - assigned-clocks: main clock, should be <&cru SCLK_UPHY0_TCPDCORE> or + <&cru SCLK_UPHY1_TCPDCORE>; + - assigned-clock-rates : the phy core clk frequency, shall be: 50000000 + - resets : a list of phandle + reset specifier pairs + - reset-names : string reset name, must be: + "uphy", "uphy-pipe", "uphy-tcphy" + - extcon : extcon specifier for the Power Delivery + +Note, there are 2 type-c phys for RK3399, and they are almost identical, except +these registers(description below), every register node contains 3 sections: +offset, enable bit, write mask bit. + - rockchip,typec-conn-dir : the register of type-c connector direction, + for type-c phy0, it must be <0xe580 0 16>; + for type-c phy1, it must be <0xe58c 0 16>; + - rockchip,usb3tousb2-en : the register of type-c force usb3 to usb2 enable + control. + for type-c phy0, it must be <0xe580 3 19>; + for type-c phy1, it must be <0xe58c 3 19>; + - rockchip,external-psm : the register of type-c phy external psm clock + selection. + for type-c phy0, it must be <0xe588 14 30>; + for type-c phy1, it must be <0xe594 14 30>; + - rockchip,pipe-status : the register of type-c phy pipe status. + for type-c phy0, it must be <0xe5c0 0 0>; + for type-c phy1, it must be <0xe5c0 16 16>; + +Required nodes : a sub-node is required for each port the phy provides. + The sub-node name is used to identify dp or usb3 port, + and shall be the following entries: + * "dp-port" : the name of DP port. + * "usb3-port" : the name of USB3 port. + +Required properties (port (child) node): +- #phy-cells : must be 0, See ./phy-bindings.txt for details. + +Example: + tcphy0: phy@ff7c0000 { + compatible = "rockchip,rk3399-typec-phy"; + reg = <0x0 0xff7c0000 0x0 0x40000>; + rockchip,grf = <&grf>; + extcon = <&fusb0>; + clocks = <&cru SCLK_UPHY0_TCPDCORE>, + <&cru SCLK_UPHY0_TCPDPHY_REF>; + clock-names = "tcpdcore", "tcpdphy-ref"; + assigned-clocks = <&cru SCLK_UPHY0_TCPDCORE>; + assigned-clock-rates = <50000000>; + resets = <&cru SRST_UPHY0>, + <&cru SRST_UPHY0_PIPE_L00>, + <&cru SRST_P_UPHY0_TCPHY>; + reset-names = "uphy", "uphy-pipe", "uphy-tcphy"; + rockchip,typec-conn-dir = <0xe580 0 16>; + rockchip,usb3tousb2-en = <0xe580 3 19>; + rockchip,external-psm = <0xe588 14 30>; + rockchip,pipe-status = <0xe5c0 0 0>; + + tcphy0_dp: dp-port { + #phy-cells = <0>; + }; + + tcphy0_usb3: usb3-port { + #phy-cells = <0>; + }; + }; + + tcphy1: phy@ff800000 { + compatible = "rockchip,rk3399-typec-phy"; + reg = <0x0 0xff800000 0x0 0x40000>; + rockchip,grf = <&grf>; + extcon = <&fusb1>; + clocks = <&cru SCLK_UPHY1_TCPDCORE>, + <&cru SCLK_UPHY1_TCPDPHY_REF>; + clock-names = "tcpdcore", "tcpdphy-ref"; + assigned-clocks = <&cru SCLK_UPHY1_TCPDCORE>; + assigned-clock-rates = <50000000>; + resets = <&cru SRST_UPHY1>, + <&cru SRST_UPHY1_PIPE_L00>, + <&cru SRST_P_UPHY1_TCPHY>; + reset-names = "uphy", "uphy-pipe", "uphy-tcphy"; + rockchip,typec-conn-dir = <0xe58c 0 16>; + rockchip,usb3tousb2-en = <0xe58c 3 19>; + rockchip,external-psm = <0xe594 14 30>; + rockchip,pipe-status = <0xe5c0 16 16>; + + tcphy1_dp: dp-port { + #phy-cells = <0>; + }; + + tcphy1_usb3: usb3-port { + #phy-cells = <0>; + }; + };
Signature · 1 line
1.7.9.5
PATCH 40/51 usb: phy: add USB_SUPPORT dependency
In reply to Kishon Vijay Abraham IFrom: Arnd Bergmann <[email protected]>
The driver now calls of_usb_get_dr_mode_by_phy, which is part of the USB core layer, and it fails to build when that is not provided:
drivers/phy/phy-sun4i-usb.o: In function `sun4i_usb_phy_probe':
phy-sun4i-usb.c:(.text.sun4i_usb_phy_probe+0x140): undefined reference to `of_usb_get_dr_mode_by_phy'
We already have a couple of other PHY drivers with a dependency on USB_SUPPORT, so that seems to be the easiest fix here.
An alternative would be to adjust the #ifdef in include/linux/usb/of.h to also check for CONFIG_USB_SUPPORT.
--- drivers/phy/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
drivers/phy/Kconfig +2 -0
@@ -267,7 +267,9 @@ config PHY_SUN4I_USB depends on RESET_CONTROLLER depends on EXTCON depends on POWER_SUPPLY + depends on USB_SUPPORT select GENERIC_PHY + select USB_COMMON help Enable this to support the transceiver that is part of Allwinner sunxi SoCs.
Signature · 1 line
1.7.9.5
PATCH 41/51 phy: rockchip-typec: add pm runtime support
In reply to Kishon Vijay Abraham IFrom: Chris Zhong <[email protected]>
Adds pm_runtime support for rockchip Type-C, so that power domain is enabled only when there is a transaction going on to help save power.
--- drivers/phy/phy-rockchip-typec.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/phy/phy-rockchip-typec.c +10 -0
@@ -960,6 +960,8 @@ static int rockchip_typec_phy_probe(struct platform_device *pdev)return PTR_ERR (tcphy->extcon); } +pm_runtime_enable (dev); +for_each_available_child_of_node (np, child_np) {struct phy *phy;
@@ -990,6 +992,13 @@ static int rockchip_typec_phy_probe(struct platform_device *pdev)return 0 ; } +static int rockchip_typec_phy_remove (struct platform_device *pdev) +{ +pm_runtime_disable (&pdev->dev); + +return 0 ; +} +static const struct of_device_id rockchip_typec_phy_dt_ids[] = { { .compatible ="rockchip,rk3399-typec-phy" }, {}
@@ -999,6 +1008,7 @@ MODULE_DEVICE_TABLE(of, rockchip_typec_phy_dt_ids);static struct platform_driver rockchip_typec_phy_driver = { .probe = rockchip_typec_phy_probe, + .remove = rockchip_typec_phy_remove, .driver = { .name ="rockchip-typec-phy" , .of_match_table = rockchip_typec_phy_dt_ids,
Signature · 1 line
1.7.9.5
PATCH 42/51 phy-sun4i-usb: Use bool where appropriate
In reply to Kishon Vijay Abraham IFrom: Hans de Goede <[email protected]>
We're using bool as true/false type in most places in phy-sun4i-usb.c for consistency fixup the remaining uses of ints which are ever only 0 or 1 to be bools too.
--- drivers/phy/phy-sun4i-usb.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/phy/phy-sun4i-usb.c +4 -3
@@ -445,7 +445,8 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work)struct sun4i_usb_phy_data *data = container_of(work, struct sun4i_usb_phy_data, detect.work);struct phy *phy0 = data->phys[0 ].phy; -int id_det, vbus_det, id_notify =0 , vbus_notify =0 ; +bool id_notify = false, vbus_notify = false; +int id_det, vbus_det;if (phy0 ==NULL )return ;
@@ -474,13 +475,13 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work) }sun4i_usb_phy0_set_id_detect (phy0, id_det); data->id_det = id_det; - id_notify =1 ; + id_notify = true; }if (vbus_det != data->vbus_det) {sun4i_usb_phy0_set_vbus_detect (phy0, vbus_det); data->vbus_det = vbus_det; - vbus_notify =1 ; + vbus_notify = true; }mutex_unlock (&phy0->mutex);
Signature · 1 line
1.7.9.5
PATCH 43/51 phy-sun4i-usb: Refactor forced session ending
In reply to Kishon Vijay Abraham IFrom: Hans de Goede <[email protected]>
The phy-sun4i-usb code supports forced ending a session on systems which lack Vbus detection, to allow switching between host and peripheral mode on such systems.
Role switching via the musb driver "mode" sysfs attribute requires force ending the session too. This commit refactors the code to allow other parts of the phy-sun4i-usb code to request a forced session end.
--- drivers/phy/phy-sun4i-usb.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/phy/phy-sun4i-usb.c +13 -14
@@ -133,6 +133,7 @@ struct sun4i_usb_phy_data {struct power_supply *vbus_power_supply;struct notifier_block vbus_power_nb;bool vbus_power_nb_registered; +bool force_session_end;int id_det_irq;int vbus_det_irq;int id_det;
@@ -445,7 +446,7 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work)struct sun4i_usb_phy_data *data = container_of(work, struct sun4i_usb_phy_data, detect.work);struct phy *phy0 = data->phys[0 ].phy; -bool id_notify = false, vbus_notify = false; +bool force_session_end, id_notify = false, vbus_notify = false;int id_det, vbus_det;if (phy0 ==NULL )
@@ -461,14 +462,17 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work)return ; } + force_session_end = data->force_session_end; + data->force_session_end = false; +if (id_det != data->id_det) { -/* -* When a host cable (id == 0) gets plugged in on systems -* without vbus detection report vbus low for long enough for -* the musb-ip to end the current device session. -*/ +/* id-change, force session end if we've no vbus detection */ if (data->dr_mode ==USB_DR_MODE_OTG && - !sun4i_usb_phy0_have_vbus_det (data) && id_det ==0 ) { + !sun4i_usb_phy0_have_vbus_det (data)) + force_session_end = true; + +/* When entering host mode (id = 0) force end the session now */ +if (force_session_end && id_det ==0 ) {sun4i_usb_phy0_set_vbus_detect (phy0,0 );msleep (200 );sun4i_usb_phy0_set_vbus_detect (phy0,1 );
@@ -489,13 +493,8 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work)if (id_notify) {extcon_set_cable_state_ (data->extcon,EXTCON_USB_HOST , !id_det); -/* -* When a host cable gets unplugged (id == 1) on systems -* without vbus detection report vbus low for long enough to -* the musb-ip to end the current host session. -*/ -if (data->dr_mode ==USB_DR_MODE_OTG && - !sun4i_usb_phy0_have_vbus_det (data) && id_det ==1 ) { +/* When leaving host mode force end the session here */ +if (force_session_end && id_det ==1 ) {mutex_lock (&phy0->mutex);sun4i_usb_phy0_set_vbus_detect (phy0,0 );msleep (1000 );
Signature · 1 line
1.7.9.5
PATCH 44/51 phy-sun4i-usb: Simplify missing dr_mode handling
In reply to Kishon Vijay Abraham IFrom: Hans de Goede <[email protected]>
If we cannot get dr_mode or no id gpio is specified simply assume peripheral mode, as this is always safe.
--- drivers/phy/phy-sun4i-usb.c | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-)
drivers/phy/phy-sun4i-usb.c +14 -28
@@ -124,7 +124,6 @@ struct sun4i_usb_phy_data {bool regulator_on;int index; } phys[MAX_PHYS ]; -int first_phy;/* phy0 / otg related variables */ struct extcon_dev *extcon;bool phy0_init;
@@ -326,7 +325,10 @@ static int sun4i_usb_phy0_get_id_det(struct sun4i_usb_phy_data *data) {switch (data->dr_mode) {case USB_DR_MODE_OTG : -return gpiod_get_value_cansleep (data->id_det_gpio); +if (data->id_det_gpio) +return gpiod_get_value_cansleep (data->id_det_gpio); +else +return 1 ;/* Fallback to peripheral mode */ case USB_DR_MODE_HOST :return 0 ;case USB_DR_MODE_PERIPHERAL :
@@ -539,8 +541,7 @@ static struct phy *sun4i_usb_phy_xlate(struct device *dev, {struct sun4i_usb_phy_data *data =dev_get_drvdata (dev); -if (args->args[0 ] < data->first_phy || - args->args[0 ] >= data->cfg->num_phys) +if (args->args[0 ] >= data->cfg->num_phys)return ERR_PTR (-ENODEV );return data->phys[args->args[0 ]].phy;
@@ -615,33 +616,18 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev) } data->dr_mode =of_usb_get_dr_mode_by_phy (np,0 ); -switch (data->dr_mode) { -case USB_DR_MODE_OTG : -/* otg without id_det makes no sense, and is not supported */ -if (!data->id_det_gpio) { -dev_err (dev,"usb0_id_det missing or invalid\n" ); -return -ENODEV ; - } -/* fall through */ -case USB_DR_MODE_HOST : -case USB_DR_MODE_PERIPHERAL : - data->extcon =devm_extcon_dev_allocate (dev, - sun4i_usb_phy0_cable); -if (IS_ERR (data->extcon)) -return PTR_ERR (data->extcon); - ret =devm_extcon_dev_register (dev, data->extcon); -if (ret) { -dev_err (dev,"failed to register extcon: %d\n" , ret); -return ret; - } -break ; -default : -dev_info (dev,"dr_mode unknown, not registering usb phy0\n" ); - data->first_phy =1 ; + data->extcon =devm_extcon_dev_allocate (dev, sun4i_usb_phy0_cable); +if (IS_ERR (data->extcon)) +return PTR_ERR (data->extcon); + + ret =devm_extcon_dev_register (dev, data->extcon); +if (ret) { +dev_err (dev,"failed to register extcon: %d\n" , ret); +return ret; } -for (i = data->first_phy; i < data->cfg->num_phys; i++) { +for (i =0 ; i < data->cfg->num_phys; i++) {struct sun4i_usb_phy *phy = data->phys + i;char name[16 ];
Signature · 1 line
1.7.9.5
PATCH 45/51 phy-sun4i-usb: Add support for phy_set_mode
In reply to Kishon Vijay Abraham IFrom: Hans de Goede <[email protected]>
Together with some musb sunxi glue changes this allows run-time dr_mode switching support via the "mode" musb sysfs attribute.
--- drivers/phy/phy-sun4i-usb.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
drivers/phy/phy-sun4i-usb.c +30 -0
@@ -427,6 +427,35 @@ static int sun4i_usb_phy_power_off(struct phy *_phy)return 0 ; } +static int sun4i_usb_phy_set_mode (struct phy *_phy,enum phy_mode mode) +{ +struct sun4i_usb_phy *phy =phy_get_drvdata (_phy); +struct sun4i_usb_phy_data *data =to_sun4i_usb_phy_data (phy); + +if (phy->index !=0 ) +return -EINVAL ; + +switch (mode) { +case PHY_MODE_USB_HOST : + data->dr_mode =USB_DR_MODE_HOST ; +break ; +case PHY_MODE_USB_DEVICE : + data->dr_mode =USB_DR_MODE_PERIPHERAL ; +break ; +case PHY_MODE_USB_OTG : + data->dr_mode =USB_DR_MODE_OTG ; +break ; +default : +return -EINVAL ; + } + +dev_info (&_phy->dev,"Changing dr_mode to %d\n" , (int )data->dr_mode); + data->force_session_end = true; +queue_delayed_work (system_wq, &data->detect,0 ); + +return 0 ; +} +void sun4i_usb_phy_set_squelch_detect (struct phy *_phy,bool enabled) {struct sun4i_usb_phy *phy =phy_get_drvdata (_phy);
@@ -440,6 +469,7 @@ static const struct phy_ops sun4i_usb_phy_ops = { .exit = sun4i_usb_phy_exit, .power_on = sun4i_usb_phy_power_on, .power_off = sun4i_usb_phy_power_off, + .set_mode = sun4i_usb_phy_set_mode, .owner = THIS_MODULE, };
Signature · 1 line
1.7.9.5
PATCH 46/51 phy-sun4i-usb: Warn when external vbus is detected
In reply to Kishon Vijay Abraham IFrom: Hans de Goede <[email protected]>
Warn when external vbus is detected when we're trying to enable our own vbus.
--- drivers/phy/phy-sun4i-usb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/phy/phy-sun4i-usb.c +3 -1
@@ -390,8 +390,10 @@ static int sun4i_usb_phy_power_on(struct phy *_phy)/* For phy0 only turn on Vbus if we don't have an ext. Vbus */ if (phy->index ==0 &&sun4i_usb_phy0_have_vbus_det (data) && - data->vbus_det) + data->vbus_det) { +dev_warn (&_phy->dev,"External vbus detected, not enabling our own vbus\n" );return 0 ; + } ret =regulator_enable (phy->vbus);if (ret)
Signature · 1 line
1.7.9.5
PATCH 47/51 phy: Add reset callback
In reply to Kishon Vijay Abraham IFrom: Randy Li <[email protected]>
The only use for this is for solving a hardware design problem in usb of Rockchip RK3288.
--- drivers/phy/phy-core.c | 15 +++++++++++++++ include/linux/phy/phy.h | 3 +++ 2 files changed, 18 insertions(+)
drivers/phy/phy-core.c +15 -0
@@ -357,6 +357,21 @@ int phy_set_mode(struct phy *phy, enum phy_mode mode) }EXPORT_SYMBOL_GPL (phy_set_mode); +int phy_reset (struct phy *phy) +{ +int ret; + +if (!phy || !phy->ops->reset) +return 0 ; + +mutex_lock (&phy->mutex); + ret = phy->ops->reset (phy); +mutex_unlock (&phy->mutex); + +return ret; +} +EXPORT_SYMBOL_GPL (phy_reset); +/** * _of_phy_get() - lookup and obtain a reference to a phy by phandle * @np: device_node for which to get the phy
include/linux/phy/phy.h +3 -0
@@ -36,6 +36,7 @@ enum phy_mode {* @power_on: powering on the phy * @power_off: powering off the phy * @set_mode: set the mode of the phy +* @reset: resetting the phy * @owner: the module owner containing the ops */ struct phy_ops {
@@ -44,6 +45,7 @@ struct phy_ops {int (*power_on)(struct phy *phy);int (*power_off)(struct phy *phy);int (*set_mode)(struct phy *phy,enum phy_mode mode); +int (*reset)(struct phy *phy);struct module *owner; };
@@ -136,6 +138,7 @@ int phy_exit(struct phy *phy);int phy_power_on (struct phy *phy);int phy_power_off (struct phy *phy);int phy_set_mode (struct phy *phy,enum phy_mode mode); +int phy_reset (struct phy *phy);static inline int phy_get_bus_width (struct phy *phy) {return phy->attrs.bus_width;
Signature · 1 line
1.7.9.5
PATCH 48/51 phy: rockchip-usb: use rockchip_usb_phy_reset to reset phy during wakeup
In reply to Kishon Vijay Abraham IFrom: Randy Li <[email protected]>
It is a hardware bug in RK3288, the only way to solve it is to reset the phy.
--- .../devicetree/bindings/phy/rockchip-usb-phy.txt | 3 +++ drivers/phy/phy-rockchip-usb.c | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+)
Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt +3 -0
@@ -27,6 +27,9 @@ Optional Properties: - clocks : phandle + clock specifier for the phy clocks - clock-names: string, clock name, must be "phyclk" - #clock-cells: for users of the phy-pll, should be 0 +- reset-names: Only allow the following entries: + - phy-reset +- resets: Must contain an entry for each entry in reset-names. Example:
drivers/phy/phy-rockchip-usb.c +20 -0
@@ -29,6 +29,7 @@#include <linux/reset.h> #include <linux/regmap.h> #include <linux/mfd/syscon.h> +#include <linux/delay.h> static int enable_usb_uart;
@@ -64,6 +65,7 @@ struct rockchip_usb_phy {struct clk_hw clk480m_hw;struct phy *phy;bool uart_enabled; +struct reset_control *reset; }; static int rockchip_usb_phy_power(struct rockchip_usb_phy *phy,
@@ -144,9 +146,23 @@ static int rockchip_usb_phy_power_on(struct phy *_phy)return clk_prepare_enable (phy->clk480m); } +static int rockchip_usb_phy_reset (struct phy *_phy) +{ +struct rockchip_usb_phy *phy =phy_get_drvdata (_phy); + +if (phy->reset) { +reset_control_assert (phy->reset); +udelay (10 ); +reset_control_deassert (phy->reset); + } + +return 0 ; +} +static const struct phy_ops ops = { .power_on = rockchip_usb_phy_power_on, .power_off = rockchip_usb_phy_power_off, + .reset = rockchip_usb_phy_reset, .owner =THIS_MODULE , };
@@ -185,6 +201,10 @@ static int rockchip_usb_phy_init(struct rockchip_usb_phy_base *base,return -EINVAL ; } + rk_phy->reset =of_reset_control_get (child,"phy-reset" ); +if (IS_ERR (rk_phy->reset)) + rk_phy->reset =NULL ; + rk_phy->reg_offset = reg_offset; rk_phy->clk =of_clk_get_by_name (child,"phyclk" );
Signature · 1 line
1.7.9.5
PATCH 49/51 phy: sun4i-usb: Use spinlock to guard phyctl register access
In reply to Kishon Vijay Abraham IFrom: Chen-Yu Tsai <[email protected]>
The musb driver calls into this phy driver to disable/enable squelch detection. This function was introduced in 24fe86a617c5 ("phy: sun4i-usb:
Add a sunxi specific function for setting squelch-detect"). This function in turn calls sun4i_usb_phy_write, which uses a mutex to guard the common access register. Unfortunately musb does this in atomic context, which results in the following warning with lock debugging enabled:
BUG: sleeping function called from invalid context at kernel/locking/mutex.c:97 in_atomic(): 1, irqs_disabled(): 128, pid: 96, name: kworker/0:2 CPU: 0 PID: 96 Comm: kworker/0:2 Not tainted 4.8.0-rc4-00181-gd502f8ad1c3e #13 Hardware name: Allwinner sun8i Family Workqueue: events musb_deassert_reset [<c010bc01>] (unwind_backtrace) from [<c0109237>] (show_stack+0xb/0xc) [<c0109237>] (show_stack) from [<c02a669b>] (dump_stack+0x67/0x74) [<c02a669b>] (dump_stack) from [<c05d68c9>] (mutex_lock+0x15/0x2c) [<c05d68c9>] (mutex_lock) from [<c02c3589>] (sun4i_usb_phy_write+0x39/0xec) [<c02c3589>] (sun4i_usb_phy_write) from [<c03e6327>] (musb_port_reset+0xfb/0x184) [<c03e6327>] (musb_port_reset) from [<c03e4917>] (musb_deassert_reset+0x1f/0x2c) [<c03e4917>] (musb_deassert_reset) from [<c012ecb5>] (process_one_work+0x129/0x2b8) [<c012ecb5>] (process_one_work) from [<c012f5e3>] (worker_thread+0xf3/0x424) [<c012f5e3>] (worker_thread) from [<c0132dbd>] (kthread+0xa1/0xb8) [<c0132dbd>] (kthread) from [<c0105f31>] (ret_from_fork+0x11/0x20)
Since the register access is mmio, we can use a spinlock to guard this specific access, rather than the mutex that guards the entire phy.
--- drivers/phy/phy-sun4i-usb.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/phy/phy-sun4i-usb.c +7 -4
@@ -40,6 +40,7 @@#include <linux/power_supply.h> #include <linux/regulator/consumer.h> #include <linux/reset.h> +#include <linux/spinlock.h> #include <linux/usb/of.h> #include <linux/workqueue.h>
@@ -114,7 +115,7 @@ struct sun4i_usb_phy_data {void __iomem *base;const struct sun4i_usb_phy_cfg *cfg;enum usb_dr_mode dr_mode; -struct mutex mutex; +spinlock_t reg_lock;/* guard access to phyctl reg */ struct sun4i_usb_phy {struct phy *phy;void __iomem *pmu;
@@ -181,9 +182,10 @@ static void sun4i_usb_phy_write(struct sun4i_usb_phy *phy, u32 addr, u32 data,struct sun4i_usb_phy_data *phy_data =to_sun4i_usb_phy_data (phy);u32 temp, usbc_bit =BIT (phy->index *2 );void __iomem *phyctl = phy_data->base + phy_data->cfg->phyctl_offset; +unsigned long flags;int i; -mutex_lock (&phy_data->mutex); +spin_lock_irqsave (&phy_data->reg_lock, flags);if (phy_data->cfg->type == sun8i_a33_phy || phy_data->cfg->type == sun50i_a64_phy) {
@@ -221,7 +223,8 @@ static void sun4i_usb_phy_write(struct sun4i_usb_phy *phy, u32 addr, u32 data, data >>=1 ; } -mutex_unlock (&phy_data->mutex); + +spin_unlock_irqrestore (&phy_data->reg_lock, flags); }static void sun4i_usb_phy_passby (struct sun4i_usb_phy *phy,int enable)
@@ -615,7 +618,7 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)if (!data)return -ENOMEM ; -mutex_init (&data->mutex); +spin_lock_init (&data->reg_lock);INIT_DELAYED_WORK (&data->detect, sun4i_usb_phy0_id_vbus_det_scan);dev_set_drvdata (dev, data); data->cfg =of_device_get_match_data (dev);
Signature · 1 line
1.7.9.5
PATCH 50/51 phy-twl4030-usb: better handle musb_mailbox() failure
In reply to Kishon Vijay Abraham IFrom: Andreas Kemnade <[email protected]>
setting twl->linkstat = MUSB_UNKNOWN upon error in musb_mailbox as introduced in
commit 12b7db2bf8b8 ("usb: musb: Return error value from musb_mailbox") causes twl4030_usb_irq() to not detect a state change form cable connected to cable disconnected after such an error so that pm_runtime_put_autosuspend() will not be called and the usage counter gets unbalanced. Such errors happen e.g. if the omap2430 module is not (yet) loaded during plug/unplug events.
This patch introduces a flag instead that indicates whether there is information for the musb_mailbox pending and calls musb_mailbox() if that flag is set.
--- drivers/phy/phy-twl4030-usb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/phy/phy-twl4030-usb.c +7 -2
@@ -172,6 +172,7 @@ struct twl4030_usb {int irq;enum musb_vbus_id_status linkstat;bool vbus_supplied; +bool musb_mailbox_pending;struct delayed_work id_workaround_work; };
@@ -569,9 +570,12 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl)pm_runtime_mark_last_busy (twl->dev);pm_runtime_put_autosuspend (twl->dev); } + twl->musb_mailbox_pending = true; + } +if (twl->musb_mailbox_pending) { err =musb_mailbox (status); -if (err) - twl->linkstat =MUSB_UNKNOWN ; +if (!err) + twl->musb_mailbox_pending = false; }/* don't schedule during sleep - irq works right then */
@@ -676,6 +680,7 @@ static int twl4030_usb_probe(struct platform_device *pdev) twl->irq =platform_get_irq (pdev,0 ); twl->vbus_supplied = false; twl->linkstat =MUSB_UNKNOWN ; + twl->musb_mailbox_pending = false; twl->phy.dev = twl->dev; twl->phy.label ="twl4030" ;
Signature · 1 line
1.7.9.5
PATCH 51/51 phy-twl4030-usb: initialize charging-related stuff via pm_runtime
In reply to Kishon Vijay Abraham IFrom: Andreas Kemnade <[email protected]>
twl4030_phy_power_on() initializes some bits which are required for charging. As they are not set in twl4030_usb_runtime_resume() a call to pm_runtime_get_sync() is not sufficient to enable charging.
This patch moves the initialization to twl4030_usb_runtime_resume() so everything needed for charging is initialized upon pm_runtime_get_sync().
That also gives improved possibilities to debug problems in that area because the relevant parts can be checked separately. Charging can be enabled without having the musb subsystem active.
As a side effect this hides some bugs in musb which causes unbalanced calls to phy_power_off()/phy_power_on() so that phy->power_count becomes -1.
The result is that e.g. the GTA04 phone (dm3730 + twl4030) works finally as a usb gadget again and charging is working.
--- drivers/phy/phy-twl4030-usb.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/phy/phy-twl4030-usb.c +11 -5
@@ -440,6 +440,17 @@ static int __maybe_unused twl4030_usb_runtime_resume(struct device *dev) (PHY_CLK_CTRL_CLOCKGATING_EN | PHY_CLK_CTRL_CLK32K_EN)); +twl4030_i2c_access (twl,1 ); +twl4030_usb_set_mode (twl, twl->usb_mode); +if (twl->usb_mode ==T2_USB_MODE_ULPI ) +twl4030_i2c_access (twl,0 ); +/* +* According to the TPS65950 TRM, there has to be at least 50ms +* delay between setting POWER_CTRL_OTG_ENAB and enabling charging +* so wait here so that a fully enabled phy can be expected after +* resume +*/ +msleep (50 );return 0 ; }
@@ -460,11 +471,6 @@ static int twl4030_phy_power_on(struct phy *phy)dev_dbg (twl->dev,"%s\n" , __func__);pm_runtime_get_sync (twl->dev); -twl4030_i2c_access (twl,1 ); -twl4030_usb_set_mode (twl, twl->usb_mode); -if (twl->usb_mode ==T2_USB_MODE_ULPI ) -twl4030_i2c_access (twl,0 ); - twl->linkstat =MUSB_UNKNOWN ;schedule_delayed_work (&twl->id_workaround_work,HZ );return 0 ;
Signature · 1 line
1.7.9.5
Quoted 19 lines · Kishon Vijay Abraham I
Hi Greg,
Please find the phy pull request for 4.9 merge window below. It adds 4 new phy drivers, adds support for a couple of phys using existing drivers, adds
phy_reset()API which can be used by the controller drivers to reset the phy and includes misc fixes and cleanups.It also includes an immutable extcon branch (ib-extcon-phy-4.9) from Chanwoo, since the Type-C PHY driver is dependent on extcon.
Let me know if I have to change something.
Thanks
KishonThe following changes since commit
017300da3a4547d85e52c2484fc0bd759e1bbcdb:phy: sun9i-usb: fix error handling (2016-08-12 14:59:10 +0530)
Quoted 7 lines
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.gittags/phy-for-4.9for you to fetch changes up to
b78ea84a7d45b9e5ad2eee429a2140065a39d755:phy-twl4030-usb: initialize charging-related stuff via
pm_runtime(2016-09-14 10:59:12 +0530)
commit c7914e8dfa4032d24ef7af4c86b9c841ec6b74e6 is odd, it is touching EXTCON_PROP_DISP_MAX without saying why in the changelog, what happened there? How do I resolve this?
There are merge issues when I pull this into my usb-next branch in a number of extcon files:
drivers/extcon/extcon-adc-jack.c drivers/extcon/extcon-arizona.c drivers/extcon/extcon-gpio.c include/linux/extcon.h
Now I can guess at the merge resolutions, but I doubt you want me to :)
Can you give me a hint as to what to do here?
thanks,
greg k-h
+Chanwoo
Hi Greg,
Quoted 24 lines · Greg KH
Quoted 23 lines · Kishon Vijay Abraham I
Hi Greg,
Please find the phy pull request for 4.9 merge window below. It adds 4 new phy drivers, adds support for a couple of phys using existing drivers, adds
phy_reset()API which can be used by the controller drivers to reset the phy and includes misc fixes and cleanups.It also includes an immutable extcon branch (ib-extcon-phy-4.9) from Chanwoo, since the Type-C PHY driver is dependent on extcon.
Let me know if I have to change something.
Thanks
KishonThe following changes since commit
017300da3a4547d85e52c2484fc0bd759e1bbcdb:phy: sun9i-usb: fix error handling (2016-08-12 14:59:10 +0530)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.gittags/phy-for-4.9
Quoted 7 lines
Quoted 3 lines
for you to fetch changes up to
b78ea84a7d45b9e5ad2eee429a2140065a39d755:phy-twl4030-usb: initialize charging-related stuff via
pm_runtime(2016-09-14 10:59:12 +0530)commit
c7914e8dfa4032d24ef7af4c86b9c841ec6b74e6is odd, it is touchingEXTCON_PROP_DISP_MAXwithout saying why in the changelog, what happened there? How do I resolve this?
This came from the extcon tree. Chanwoo?
Quoted 11 lines
There are merge issues when I pull this into my usb-next branch in a number of extcon files:
drivers/extcon/extcon-adc-jack.cdrivers/extcon/extcon-arizona.cdrivers/extcon/extcon-gpio.cinclude/linux/extcon.hNow I can guess at the merge resolutions, but I doubt you want me to :)
Can you give me a hint as to what to do here?
I guess there was a change in the immutable branch ib-extcon-phy-4.9 after it was merged to PHY tree.
The resolution for extcon-adc-jack.c, extcon-arizona.c, extcon-gpio.c should be based on the following patch (it replaces extcon_set_cable_state_ with extcon_set_state_sync)
The resolution for extcon.h should be based on
https://git.kernel.org/cgit/linux/kernel/git/gregkh/usb.git/commit/?h=usb-next&id=c7914e8dfa4032d24ef7af4c86b9c841ec6b74e6
Alternatively, I've resolved the conflicts and pushed the linux-phy tree.git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git
tags/phy-for-4.9-resolved
Thanks
Kishon
Quoted 57 lines · Kishon Vijay Abraham I
+Chanwoo
Hi Greg,
Quoted 24 lines · Greg KH
Quoted 23 lines · Kishon Vijay Abraham I
Hi Greg,
Please find the phy pull request for 4.9 merge window below. It adds 4 new phy drivers, adds support for a couple of phys using existing drivers, adds
phy_reset()API which can be used by the controller drivers to reset the phy and includes misc fixes and cleanups.It also includes an immutable extcon branch (ib-extcon-phy-4.9) from Chanwoo, since the Type-C PHY driver is dependent on extcon.
Let me know if I have to change something.
Thanks
KishonThe following changes since commit
017300da3a4547d85e52c2484fc0bd759e1bbcdb:phy: sun9i-usb: fix error handling (2016-08-12 14:59:10 +0530)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.gittags/phy-for-4.9Quoted 7 lines
Quoted 3 lines
for you to fetch changes up to
b78ea84a7d45b9e5ad2eee429a2140065a39d755:phy-twl4030-usb: initialize charging-related stuff via
pm_runtime(2016-09-14 10:59:12 +0530)commit
c7914e8dfa4032d24ef7af4c86b9c841ec6b74e6is odd, it is touchingEXTCON_PROP_DISP_MAXwithout saying why in the changelog, what happened there? How do I resolve this?This came from the extcon tree. Chanwoo?
Quoted 11 lines
There are merge issues when I pull this into my usb-next branch in a number of extcon files:
drivers/extcon/extcon-adc-jack.cdrivers/extcon/extcon-arizona.cdrivers/extcon/extcon-gpio.cinclude/linux/extcon.hNow I can guess at the merge resolutions, but I doubt you want me to :)
Can you give me a hint as to what to do here?
I guess there was a change in the immutable branch ib-extcon-phy-4.9 after it was merged to PHY tree.
The resolution for
extcon-adc-jack.c,extcon-arizona.c,extcon-gpio.cshould be based on the following patch (it replacesextcon_set_cable_state_withextcon_set_state_sync)
Quoted 8 lines
The resolution for
extcon.hshould be based on
https://git.kernel.org/cgit/linux/kernel/git/gregkh/usb.git/commit/?h=usb-next&id=c7914e8dfa4032d24ef7af4c86b9c841ec6b74e6Alternatively, I've resolved the conflicts and pushed the linux-phy tree.
git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git
tags/phy-for-4.9-resolved
Can you do a new pull request for this, so I know I get it correctly?
thanks,
greg k-h
Quoted 60 lines · Greg KH
Quoted 59 lines · Kishon Vijay Abraham I
+Chanwoo
Hi Greg,
Quoted 24 lines · Greg KH
Quoted 23 lines · Kishon Vijay Abraham I
Hi Greg,
Please find the phy pull request for 4.9 merge window below. It adds 4 new phy drivers, adds support for a couple of phys using existing drivers, adds
phy_reset()API which can be used by the controller drivers to reset the phy and includes misc fixes and cleanups.It also includes an immutable extcon branch (ib-extcon-phy-4.9) from Chanwoo, since the Type-C PHY driver is dependent on extcon.
Let me know if I have to change something.
Thanks
KishonThe following changes since commit
017300da3a4547d85e52c2484fc0bd759e1bbcdb:phy: sun9i-usb: fix error handling (2016-08-12 14:59:10 +0530)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.gittags/phy-for-4.9Quoted 7 lines
Quoted 3 lines
for you to fetch changes up to
b78ea84a7d45b9e5ad2eee429a2140065a39d755:phy-twl4030-usb: initialize charging-related stuff via
pm_runtime(2016-09-14 10:59:12 +0530)commit
c7914e8dfa4032d24ef7af4c86b9c841ec6b74e6is odd, it is touchingEXTCON_PROP_DISP_MAXwithout saying why in the changelog, what happened there? How do I resolve this?This came from the extcon tree. Chanwoo?
Quoted 11 lines
There are merge issues when I pull this into my usb-next branch in a number of extcon files:
drivers/extcon/extcon-adc-jack.cdrivers/extcon/extcon-arizona.cdrivers/extcon/extcon-gpio.cinclude/linux/extcon.hNow I can guess at the merge resolutions, but I doubt you want me to :)
Can you give me a hint as to what to do here?
I guess there was a change in the immutable branch ib-extcon-phy-4.9 after it was merged to PHY tree.
The resolution for
extcon-adc-jack.c,extcon-arizona.c,extcon-gpio.cshould be based on the following patch (it replacesextcon_set_cable_state_withextcon_set_state_sync)
Quoted 8 lines
Quoted 6 lines
The resolution for
extcon.hshould be based on
https://git.kernel.org/cgit/linux/kernel/git/gregkh/usb.git/commit/?h=usb-next&id=c7914e8dfa4032d24ef7af4c86b9c841ec6b74e6Alternatively, I've resolved the conflicts and pushed the linux-phy tree.
git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git
tags/phy-for-4.9-resolvedCan you do a new pull request for this, so I know I get it correctly?
sure.. here it goes..
The following changes since commit 81522637485dd6ec9de4279c9714d58f884b6091:
Merge tag 'usb-for-v4.9' ofgit://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next (2016-09-14 20:37:50 +0200)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git
tags/phy-for-4.9-updated
for you to fetch changes up to e3de5885ddc79341c80caccf820a28a2c5aba146:
Merge branch 'next' into resolution (2016-09-15 15:46:11 +0530)
----------------------------------------------------------------
phy: for 4.9 (with extcon merge resolution)
updated tag for 4.9 based on usb-next along with extcon merge resolution
phy updates includes:
*) phy driver for USB 3.0 PHY on Northstar
*) phy driver for Rockchip usb2phy
*) phy driver for the Rockchip SoC internal PCIe PHY *) phy driver for USB Type-C PHY on rk3399
*) phy_reset() API
*) support for Allwinner A64 usb phy, usb2 phy in r8a7796 *) Fixes in twl4030-usb, tegra phy, sun4i-usb phy, da8xx-usb phy
and omap-usb2 phy
*) other misc cleanups
----------------------------------------------------------------
Andreas Kemnade (2):
phy-twl4030-usb: better handle musb_mailbox() failure
phy-twl4030-usb: initialize charging-related stuff via pm_runtime
Arnd Bergmann (1):
usb: phy: add USB_SUPPORT dependency
Axel Lin (3):
phy: exynos5-usbdrd: Remove "static" from local variable
phy: bcm-ns2-pcie: Get rid of struct ns2_pci_phy
phy: bcm-ns2-pcie: Set missing .owner field in ns2_pci_phy_ops
Baoyou Xie (2):
phy: tegra: add missing header dependencies
phy: tegra: mark tegra_xusb_lane_lookup_function() static
Chanwoo Choi (12):
extcon: arizona: Remove the usage of extcon_update_state()
extcon: adc-jack: Remove the usage of extcon_set_state()
extcon: gpio: Remove the usage of extcon_set_state()
extcon: Remove the state_store() to prevent the wrong access
extcon: Block the bit masking operation for cable state except for extcon
core
extcon: Add the extcon_type to gather each connector into five category
extcon: Add the support for extcon property according to extcon type
extcon: Add the support for the capability of each property
extcon: Rename the extcon_set/get_state() to maintain the function naming
pattern
extcon: Add the synchronization extcon APIs to support the notification
extcon: Add new EXTCON_DISP_HMD for Head-mounted Display device
extcon: Add new EXTCON_CHG_WPT for Wireless Power Transfer device
Charles Keepax (1):
extcon: arizona: Remove unneeded semi-colon
Chen-Yu Tsai (1):
phy: sun4i-usb: Use spinlock to guard phyctl register access
Chris Zhong (4):
extcon: Add EXTCON_DISP_DP and the property for USB Type-C
phy: Add USB Type-C PHY driver for rk3399
Documentation: bindings: add dt doc for Rockchip USB Type-C PHY
phy: rockchip-typec: add pm runtime support
David Lechner (1):
phy: da8xx-usb: Fix syscon device name
Frank Wang (3):
Documentation: bindings: add DT documentation for Rockchip USB2PHY
phy: rockchip-inno-usb2: add a new driver for Rockchip usb2phy
phy: rockchip-inno-usb2: add COMMON_CLK dependency
Guenter Roeck (1):
extcon: Introduce EXTCON_PROP_USB_SS property for SuperSpeed mode
Hans de Goede (5):
phy-sun4i-usb: Use bool where appropriate
phy-sun4i-usb: Refactor forced session ending
phy-sun4i-usb: Simplify missing dr_mode handling
phy-sun4i-usb: Add support for phy_set_mode
phy-sun4i-usb: Warn when external vbus is detected
Icenowy Zheng (2):
dt: bindings: add bindings for Allwinner A64 usb phy
phy: sun4i: add support for A64 usb phy
Julia Lawall (1):
phy: qcom-ufs: use of_property_read_bool
Kishon Vijay Abraham I (2):
Merge branch 'ib-extcon-phy-4.9' ofgit://git.kernel.org/.../chanwoo/extcon into next
Merge branch 'next' into resolution
Maninder Singh (1):
extcon: Fix compile time warning
Rafał Miłecki (1):
phy: bcm-ns-usb3: new driver for USB 3.0 PHY on Northstar
Randy Li (2):
phy: Add reset callback
phy: rockchip-usb: use rockchip_usb_phy_reset to reset phy during wakeup
Sekhar Nori (2):
phy: omap-usb2: support suspend/resume
dt-bindings: phy: ti: add documentation for ti,dra7x-usb2
Shawn Lin (2):
Documentation: bindings: add dt documentation for Rockchip PCIe PHY
phy: add a driver for the Rockchip SoC internal PCIe PHY
Stephen Boyd (1):
extcon: Move extcon_get_edev_by_phandle() errors to dbg level
Venkat Reddy Talla (1):
extcon: adc-jack: update cable state during boot
Yoshihiro Shimoda (2):
phy: rcar-gen3-usb2: revise the example of device tree doc
phy: rcar-gen3-usb2: Add a compatible string for r8a7796
.../devicetree/bindings/phy/bcm-ns-usb3-phy.txt | 23 + .../bindings/phy/phy-rockchip-inno-usb2.txt | 64 ++ .../devicetree/bindings/phy/phy-rockchip-typec.txt | 101 ++ .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | 6 +- .../devicetree/bindings/phy/rockchip-pcie-phy.txt | 31 + .../devicetree/bindings/phy/rockchip-usb-phy.txt | 3 + .../devicetree/bindings/phy/sun4i-usb-phy.txt | 1 + Documentation/devicetree/bindings/phy/ti-phy.txt | 2 + drivers/extcon/extcon-gpio.c | 1 + drivers/phy/Kconfig | 36 + drivers/phy/Makefile | 4 + drivers/phy/phy-bcm-ns-usb3.c | 274 ++++++ drivers/phy/phy-bcm-ns2-pcie.c | 28 +- drivers/phy/phy-core.c | 15 + drivers/phy/phy-da8xx-usb.c | 2 +- drivers/phy/phy-exynos5-usbdrd.c | 4 +- drivers/phy/phy-omap-usb2.c | 100 +- drivers/phy/phy-qcom-ufs.c | 6 +- drivers/phy/phy-rcar-gen3-usb2.c | 1 + drivers/phy/phy-rockchip-inno-usb2.c | 707 ++++++++++++++ drivers/phy/phy-rockchip-pcie.c | 357 +++++++ drivers/phy/phy-rockchip-typec.c | 1023 ++++++++++++++++++++ drivers/phy/phy-rockchip-usb.c | 20 + drivers/phy/phy-sun4i-usb.c | 154 +-- drivers/phy/phy-twl4030-usb.c | 25 +- drivers/phy/tegra/xusb.c | 4 +- include/linux/extcon.h | 57 ++ include/linux/phy/phy.h | 3 + 28 files changed, 2905 insertions(+), 147 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/bcm-ns-usb3-phy.txt create mode 100644 Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.txt create mode 100644 Documentation/devicetree/bindings/phy/phy-rockchip-typec.txt create mode 100644 Documentation/devicetree/bindings/phy/rockchip-pcie-phy.txt create mode 100644 drivers/phy/phy-bcm-ns-usb3.c create mode 100644 drivers/phy/phy-rockchip-inno-usb2.c create mode 100644 drivers/phy/phy-rockchip-pcie.c create mode 100644 drivers/phy/phy-rockchip-typec.c
Hi Greg,
Quoted 80 lines · Kishon Vijay Abraham I
Quoted 60 lines · Greg KH
Quoted 59 lines · Kishon Vijay Abraham I
+Chanwoo
Hi Greg,
Quoted 24 lines · Greg KH
Quoted 23 lines · Kishon Vijay Abraham I
Hi Greg,
Please find the phy pull request for 4.9 merge window below. It adds 4 new phy drivers, adds support for a couple of phys using existing drivers, adds
phy_reset()API which can be used by the controller drivers to reset the phy and includes misc fixes and cleanups.It also includes an immutable extcon branch (ib-extcon-phy-4.9) from Chanwoo, since the Type-C PHY driver is dependent on extcon.
Let me know if I have to change something.
Thanks
KishonThe following changes since commit
017300da3a4547d85e52c2484fc0bd759e1bbcdb:phy: sun9i-usb: fix error handling (2016-08-12 14:59:10 +0530)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.gittags/phy-for-4.9Quoted 7 lines
Quoted 3 lines
for you to fetch changes up to
b78ea84a7d45b9e5ad2eee429a2140065a39d755:phy-twl4030-usb: initialize charging-related stuff via
pm_runtime(2016-09-14 10:59:12 +0530)commit
c7914e8dfa4032d24ef7af4c86b9c841ec6b74e6is odd, it is touchingEXTCON_PROP_DISP_MAXwithout saying why in the changelog, what happened there? How do I resolve this?This came from the extcon tree. Chanwoo?
Quoted 11 lines
There are merge issues when I pull this into my usb-next branch in a number of extcon files:
drivers/extcon/extcon-adc-jack.cdrivers/extcon/extcon-arizona.cdrivers/extcon/extcon-gpio.cinclude/linux/extcon.hNow I can guess at the merge resolutions, but I doubt you want me to :)
Can you give me a hint as to what to do here?
I guess there was a change in the immutable branch ib-extcon-phy-4.9 after it was merged to PHY tree.
The resolution for
extcon-adc-jack.c,extcon-arizona.c,extcon-gpio.cshould be based on the following patch (it replacesextcon_set_cable_state_withextcon_set_state_sync)Quoted 8 lines
Quoted 6 lines
The resolution for
extcon.hshould be based on
https://git.kernel.org/cgit/linux/kernel/git/gregkh/usb.git/commit/?h=usb-next&id=c7914e8dfa4032d24ef7af4c86b9c841ec6b74e6Alternatively, I've resolved the conflicts and pushed the linux-phy tree.
git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git
tags/phy-for-4.9-resolvedCan you do a new pull request for this, so I know I get it correctly?
sure.. here it goes..
The following changes since commit
81522637485dd6ec9de4279c9714d58f884b6091:Merge tag 'usb-for-v4.9' of
git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usbinto usb-next (2016-09-14 20:37:50 +0200)
Quoted 5 lines
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git
tags/phy-for-4.9-updated
please ignore this. I got an error with this. Will fix that and resend a fresh pull request.
Thanks
Kishon