Re: [PATCHv3] phy: cpcap-usb: Add CPCAP PMIC USB support
* Kishon Vijay Abraham I[170507 23:23]: > Hi Tony, > > On Monday 10 April 2017 09:49 AM, Tony Lindgren wrote: > > 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. > > 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). 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. > 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). OK > 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. > > +Example: > > +cpcap_usb2_phy: phy { > > + compatible = "motorola,mapphone-cpcap-usb-phy"; ... > > +}; > > 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 linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv3] phy: cpcap-usb: Add CPCAP PMIC USB support
Hi Tony, On Monday 10 April 2017 09:49 AM, Tony Lindgren wrote: > 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. 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. > > Cc: devicet...@vger.kernel.org > Cc: Marcel Partap> Cc: Michael Scott > Acked-by: Rob Herring > Tested-by: Sebastian Reichel > Signed-off-by: Tony Lindgren > --- > > 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 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 > > diff --git a/Documentation/devicetree/bindings/phy/phy-cpcap-usb.txt > b/Documentation/devicetree/bindings/phy/phy-cpcap-usb.txt > new file mode 100644 > --- /dev/null > +++ b/Documentation/devicetree/bindings/phy/phy-cpcap-usb.txt > @@ -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 = <_gpio_mux_sel1 _gpio_mux_sel2>; > + pinctrl-1 = <_ulpi_pins>; > + pinctrl-2 = <_utmi_pins>; > + pinctrl-3 = <_pins>; > + pinctrl-names = "default", "ulpi", "utmi", "uart"; > + #phy-cells = <0>; > + interrupts-extended = < > + 15 0 14 0 28 0 19 0 > + 18 0 17 0 16 0 49 0 > + 48 1 > + >; > + interrupt-names = > + "id_ground", "id_float", "se0conn", "vbusvld", > + "sessvld", "sessend", "se1", "dm", "dp"; > + mode-gpios = < 28 GPIO_ACTIVE_HIGH > +0 GPIO_ACTIVE_HIGH>; > + io-channels = <_adc 2>, <_adc 7>; > + io-channel-names = "vbus", "id"; > + vusb-supply = <>; > +}; I would have preferred this to be a separate patch but since Rob has Acked it, it is fine. Thanks Kishon -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCHv3] 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. Cc: devicet...@vger.kernel.org Cc: Marcel PartapCc: Michael Scott Acked-by: Rob Herring Tested-by: Sebastian Reichel Signed-off-by: Tony Lindgren --- 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 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 diff --git a/Documentation/devicetree/bindings/phy/phy-cpcap-usb.txt b/Documentation/devicetree/bindings/phy/phy-cpcap-usb.txt new file mode 100644 --- /dev/null +++ b/Documentation/devicetree/bindings/phy/phy-cpcap-usb.txt @@ -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 = <_gpio_mux_sel1 _gpio_mux_sel2>; + pinctrl-1 = <_ulpi_pins>; + pinctrl-2 = <_utmi_pins>; + pinctrl-3 = <_pins>; + pinctrl-names = "default", "ulpi", "utmi", "uart"; + #phy-cells = <0>; + interrupts-extended = < +15 0 14 0 28 0 19 0 +18 0 17 0 16 0 49 0 +48 1 + >; + interrupt-names = + "id_ground", "id_float", "se0conn", "vbusvld", + "sessvld", "sessend", "se1", "dm", "dp"; + mode-gpios = < 28 GPIO_ACTIVE_HIGH + 0 GPIO_ACTIVE_HIGH>; + io-channels = <_adc 2>, <_adc 7>; + io-channel-names = "vbus", "id"; + vusb-supply = <>; +}; diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -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 diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -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 diff --git a/drivers/phy/phy-cpcap-usb.c b/drivers/phy/phy-cpcap-usb.c new file mode 100644 --- /dev/null +++ b/drivers/phy/phy-cpcap-usb.c @@ -0,0 +1,734 @@ +/* + * Motorola CPCAP PMIC USB PHY driver + * Copyright (C) 2017 Tony Lindgren + * + * Some parts based on earlier Motorola Linux kernel tree code in + * board-mapphone-usb.c and cpcap-usb-det.c: + * Copyright (C) 2007 - 2011 Motorola, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under