phy: cpcap-usb: Add CPCAP PMIC USB support
Subsystems (2)
PATCH v3 1/1 phy: cpcap-usb: Add CPCAP PMIC USB support
Some Motorola phones like droid 4 use a custom CPCAP PMIC that has a multiplexing USB PHY.
This USB PHY can operate at least in four modes using pin multiplexing and two control GPIOS:
- Pass through companion PHY for the SoC USB PHY
- ULPI PHY for the SoC
- Pass through USB for the modem
- UART debug console for the SoC
This patch adds support for droid 4 USB PHY and debug UART modes, support for other modes can be added later on as needed.
Both peripheral and host mode are working for the USB. The host mode depends on the cpcap-charger driver for VBUS.
VBUS and ID pin detection are done using cpcap-adc IIO ADC driver.
---
Changes since v2:
- Added extcon support as requested by Kishon
- Added Rob's ack
- Folded in Kconfig randconfig build fix to add depends on IIO
Changes since v1:
- Use iio_read_channel_processed() instead of iio_read_channel_scaled() as changed in the v2 of the ADC driver
- Kept Tested-by from Sebastian Reichel <[email protected]> as the change from v1 is trivial
--- .../devicetree/bindings/phy/phy-cpcap-usb.txt | 40 ++ drivers/phy/Kconfig | 8 + drivers/phy/Makefile | 1 + drivers/phy/phy-cpcap-usb.c | 734 +++++++++++++++++++++ 4 files changed, 783 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/phy-cpcap-usb.txt create mode 100644 drivers/phy/phy-cpcap-usb.c
Documentation/devicetree/bindings/phy/phy-cpcap-usb.txt new file +40 -0
@@ -0,0 +1,40 @@ +Motorola CPCAP PMIC USB PHY binding + +Required properties: +compatible: Shall be either "motorola,cpcap-usb-phy" or + "motorola,mapphone-cpcap-usb-phy" +#phy-cells: Shall be 0 +interrupts: CPCAP PMIC interrupts used by the USB PHY +interrupt-names: Interrupt names +io-channels: IIO ADC channels used by the USB PHY +io-channel-names: IIO ADC channel names +vusb-supply: Regulator for the PHY + +Optional properties: +pinctrl: Optional alternate pin modes for the PHY +pinctrl-names: Names for optional pin modes +mode-gpios: Optional GPIOs for configuring alternate modes + +Example: +cpcap_usb2_phy: phy { + compatible = "motorola,mapphone-cpcap-usb-phy"; + pinctrl-0 = <&usb_gpio_mux_sel1 &usb_gpio_mux_sel2>; + pinctrl-1 = <&usb_ulpi_pins>; + pinctrl-2 = <&usb_utmi_pins>; + pinctrl-3 = <&uart3_pins>; + pinctrl-names = "default", "ulpi", "utmi", "uart"; + #phy-cells = <0>; + interrupts-extended = < + &cpcap 15 0 &cpcap 14 0 &cpcap 28 0 &cpcap 19 0 + &cpcap 18 0 &cpcap 17 0 &cpcap 16 0 &cpcap 49 0 + &cpcap 48 1 + >; + interrupt-names = + "id_ground", "id_float", "se0conn", "vbusvld", + "sessvld", "sessend", "se1", "dm", "dp"; + mode-gpios = <&gpio2 28 GPIO_ACTIVE_HIGH + &gpio1 0 GPIO_ACTIVE_HIGH>; + io-channels = <&cpcap_adc 2>, <&cpcap_adc 7>; + io-channel-names = "vbus", "id"; + vusb-supply = <&vusb>; +};
drivers/phy/Kconfig +8 -0
@@ -47,6 +47,14 @@ config PHY_BERLIN_SATA help Enable this to support the SATA PHY on Marvell Berlin SoCs. +config PHY_CPCAP_USB + tristate "CPCAP USB PHY driver" + depends on USB_SUPPORT && IIO + select GENERIC_PHY + select USB_PHY + help + Enable this for CPCAP USB to work. + config ARMADA375_USBCLUSTER_PHY def_bool y depends on MACH_ARMADA_375 || COMPILE_TEST
drivers/phy/Makefile +1 -0
@@ -7,6 +7,7 @@ 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_CPCAP_USB) += phy-cpcap-usb.o obj-$(CONFIG_PHY_DA8XX_USB) += phy-da8xx-usb.o obj-$(CONFIG_PHY_DM816X_USB) += phy-dm816x-usb.o obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY) += phy-armada375-usb2.o
drivers/phy/phy-cpcap-usb.c new file +734 -0
734 lines not on this page · raw message
Signature · 5 lines
2.12.2 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Tony,
Quoted 11 lines · Tony Lindgren
Some Motorola phones like droid 4 use a custom CPCAP PMIC that has a multiplexing USB PHY.
This USB PHY can operate at least in four modes using pin multiplexing and two control GPIOS:
- Pass through companion PHY for the SoC USB PHY
- ULPI PHY for the SoC
- Pass through USB for the modem
- UART debug console for the SoC
Quoted 8 lines
This patch adds support for droid 4 USB PHY and debug UART modes, support for other modes can be added later on as needed.
Both peripheral and host mode are working for the USB. The host mode depends on the cpcap-charger driver for VBUS.
VBUS and ID pin detection are done using cpcap-adc IIO ADC driver.
I thought of using EXTCON differently from what was used below. Actually I thought EXTCON shuld be used in cpcap-adc driver for notifying VBUS or ID events to phy-cpcap driver which performs the various setting based on VBUS or ID. (See drivers/usb/dwc3/dwc3-omap.c which receives VBUS/ID notifications fo sample). That would have simply replaced the iio* calls with EXTCON calls in phy-cpcap-usb driver (in addition to adding extcon API's in cpcap-adc driver).
Usage of EXTCON like below is not of much use here since MUSB doesn't really wait for notification of ID or VBUS events (This is unlike dwc3-omap. since we invoke musb_mailbox functin directly).
If adding EXTCON in cpcap-adc isn't simple then we should stick to your patch version 2 since extcon support in this version is not useful IMO.
Quoted 67 lines
Cc Marcel Partap <[email protected]>Cc Michael Scott <[email protected]>Acked-by Rob Herring <[email protected]>Tested-by Sebastian Reichel <[email protected]>Signed-off-by Tony Lindgren <[email protected]>---
Changes since v2:
- Added extcon support as requested by Kishon- Added Rob's ack
- Folded in
Kconfigrandconfig build fix to add depends on IIOChanges since v1:
- Useiio_read_channel_processed()instead ofiio_read_channel_scaled()as changed in the v2 of the ADC driver- Kept Tested-by from Sebastian Reichel <[email protected]> as the change from v1 is trivial
--- .../devicetree/bindings/phy/phy-cpcap-usb.txt | 40 ++ drivers/phy/Kconfig | 8 + drivers/phy/Makefile | 1 + drivers/phy/phy-cpcap-usb.c | 734 +++++++++++++++++++++ 4 files changed, 783 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/phy-cpcap-usb.txt create mode 100644 drivers/phy/phy-cpcap-usb.cDocumentation/devicetree/bindings/phy/phy-cpcap-usb.txt new file +30
-0@@ -0,0 +1,40 @@ +Motorola CPCAP PMIC USB PHY binding + +Required properties: +compatible: Shall be either "motorola,cpcap-usb-phy" or + "motorola,mapphone-cpcap-usb-phy" +#phy-cells: Shall be 0 +interrupts: CPCAP PMIC interrupts used by the USB PHY +interrupt-names: Interrupt names +io-channels: IIO ADC channels used by the USB PHY +io-channel-names: IIO ADC channel names +vusb-supply: Regulator for the PHY + +Optional properties: +pinctrl: Optional alternate pin modes for the PHY +pinctrl-names: Names for optional pin modes +mode-gpios: Optional GPIOs for configuring alternate modes + +Example: +cpcap_usb2_phy: phy { + compatible = "motorola,mapphone-cpcap-usb-phy"; + pinctrl-0 = <&usb_gpio_mux_sel1 &usb_gpio_mux_sel2>; + pinctrl-1 = <&usb_ulpi_pins>; + pinctrl-2 = <&usb_utmi_pins>; + pinctrl-3 = <&uart3_pins>; + pinctrl-names = "default", "ulpi", "utmi", "uart"; + #phy-cells = <0>; + interrupts-extended = < + &cpcap 15 0 &cpcap 14 0 &cpcap 28 0 &cpcap 19 0 + &cpcap 18 0 &cpcap 17 0 &cpcap 16 0 &cpcap 49 0 + &cpcap 48 1
Documentation/devicetree/bindings/phy/phy-cpcap-usb.txt line 40
Quoted 10 lines
Documentation/devicetree/bindings/phy/phy-cpcap-usb.txt new file +10
-0+ >; + interrupt-names = + "id_ground", "id_float", "se0conn", "vbusvld", + "sessvld", "sessend", "se1", "dm", "dp"; + mode-gpios = <&gpio2 28 GPIO_ACTIVE_HIGH + &gpio1 0 GPIO_ACTIVE_HIGH>; + io-channels = <&cpcap_adc 2>, <&cpcap_adc 7>; + io-channel-names = "vbus", "id"; + vusb-supply = <&vusb>; +};
I would have preferred this to be a separate patch but since Rob has Acked it, it is fine.
Thanks
Kishon
Quoted 23 lines · Kishon Vijay Abraham I
Hi Tony,
Quoted 11 lines · Tony Lindgren
Some Motorola phones like droid 4 use a custom CPCAP PMIC that has a multiplexing USB PHY.
This USB PHY can operate at least in four modes using pin multiplexing and two control GPIOS:
- Pass through companion PHY for the SoC USB PHY
- ULPI PHY for the SoC
- Pass through USB for the modem
- UART debug console for the SoCQuoted 8 lines
This patch adds support for droid 4 USB PHY and debug UART modes, support for other modes can be added later on as needed.
Both peripheral and host mode are working for the USB. The host mode depends on the cpcap-charger driver for VBUS.
VBUS and ID pin detection are done using cpcap-adc IIO ADC driver.
Quoted 6 lines
I thought of using EXTCON differently from what was used below. Actually I thought EXTCON shuld be used in cpcap-adc driver for notifying VBUS or ID events to phy-cpcap driver which performs the various setting based on VBUS or ID. (See
drivers/usb/dwc3/dwc3-omap.cwhich receives VBUS/ID notifications fo sample). That would have simply replaced the iio* calls with EXTCON calls in phy-cpcap-usb driver (in addition to adding extcon API's in cpcap-adc driver).
OK sorry yeah I misunderstood what you wanted then. I actually started running into issues with extcon as it assumes that the extcon provider can't be removed if there are consumers. So yeah let's scrap this usage as it adds a bogus dependency between the charger driver and PHY driver.
Quoted 3 lines
Usage of EXTCON like below is not of much use here since MUSB doesn't really wait for notification of ID or VBUS events (This is unlike dwc3-omap. since we invoke
musb_mailboxfunctin directly).
OK
Quoted 2 lines
If adding EXTCON in cpcap-adc isn't simple then we should stick to your patch version 2 since extcon support in this version is not useful IMO.
OK. I'll check and will post v3. My gut feeling is that IIO is better for VBUS and ID as we want the values too.
For example ID pin can have multiple values, and it seems that many PHYs can detect 102/200/440K pull-up on the ID pin for "carkit" mode etc. I'm not yet sure if there are multiple ID pull-up values to be considered in this case, but there is at least one pull-up value for detecting "factory mode" where the device is supposed to be powered on USB only even if there is no battery.
Also the VBUS in this case is the direct voltage from the battery as far as I can tell so the voltage value should be considered.
Quoted 3 lines
Quoted 3 lines
Documentation/devicetree/bindings/phy/phy-cpcap-usb.txt new file +3
-0+Example: +cpcap_usb2_phy: phy { + compatible = "motorola,mapphone-cpcap-usb-phy";
...
Quoted 4 lines
Quoted 1 line
+};
I would have preferred this to be a separate patch but since Rob has Acked it, it is fine.
OK
Regards,
Tony
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html