Re: [PATCHv2] phy: cpcap-usb: Add CPCAP PMIC USB support
Hi, * Kishon Vijay Abraham I[170330 04:51]: > On Monday 27 March 2017 08:35 PM, Tony Lindgren wrote: > > Seems this can be also done when implementing PM runtime handling. > > If you want some of these changes done for the initial patch, > > please let me know. > > I think it's better we get extcon stuff in the initial patch so that we don't > have to maintain some piece of code for legacy dt. Others can be added later. Sure, I'll take a look at that hopefully this week at some point. Regards, Tony
Re: [PATCHv2] phy: cpcap-usb: Add CPCAP PMIC USB support
Hi, * Kishon Vijay Abraham I [170330 04:51]: > On Monday 27 March 2017 08:35 PM, Tony Lindgren wrote: > > Seems this can be also done when implementing PM runtime handling. > > If you want some of these changes done for the initial patch, > > please let me know. > > I think it's better we get extcon stuff in the initial patch so that we don't > have to maintain some piece of code for legacy dt. Others can be added later. Sure, I'll take a look at that hopefully this week at some point. Regards, Tony
Re: [PATCHv2] phy: cpcap-usb: Add CPCAP PMIC USB support
Hi Tony, On Monday 27 March 2017 08:35 PM, Tony Lindgren wrote: > * Kishon Vijay Abraham I[170326 23:27]: >> On Thursday 23 March 2017 05:16 AM, Tony Lindgren wrote: >>> +static const struct phy_ops ops = { >>> + .owner = THIS_MODULE, >>> +}; >> >> Given that this phy doesn't have any phy_ops, Is there a reason for >> registering >> this phy with the phy framework? Is it because this driver uses the >> phy_core's >> pm_runtime feature? > > Well there's also an ULPI PHY on CPCAP, but it's not used in the > motorola-mapphone configuration. I think some other configurations > use it though, so probably best to keep it. > > And yeah, for PM runtime, I was thinking that we can have the > UART mode be the idle state. > >>> +static void cpcap_usb_detect(struct work_struct *work) >>> +{ >>> + struct cpcap_phy_ddata *ddata; >>> + struct cpcap_usb_ints_state s; >>> + bool vbus = false; >>> + int error; >>> + >>> + ddata = container_of(work, struct cpcap_phy_ddata, detect_work.work); >>> + >>> + error = cpcap_phy_get_ints_state(ddata, ); >>> + if (error) >>> + return; >>> + >>> + /* See also cpcap-charger.c phy_companion for VBUS handling */ >> >> I think this companion should have ideally used extcon framework. Then we >> could >> have used extcon_get_state() here. > > OK I'll take a look at that. I'd like to do that as a follow-up > patches if that's OK with you. > > FYI in case you're wondering, there are ADCs on the PMIC available > via IIO, and the charger is also using IIO framework for VBUS and > battery voltage. And the VBUS is set up as reverse mode in the > charger registers and the charging needs to be disabled for VBUS. > > I guess Ideally the VBUS would be just a regulator from Linux point > of view that also allows negative current :) > >>> + ddata->vusb = devm_regulator_get(>dev, "vusb"); >>> + if (IS_ERR(ddata->vusb)) >>> + return PTR_ERR(ddata->vusb); >>> + >>> + error = regulator_enable(ddata->vusb); >>> + if (error) >>> + return error; >> >> Maybe we should create power_on ops and do regulator enable there? > > This regulator is also needed for the UART mode, so it would have > to be disabled conditionally based on maybe a module parameter. > But yeah thanks for the pointer I did not even realize you have > power_on ops :) > > Seems this can be also done when implementing PM runtime handling. > If you want some of these changes done for the initial patch, > please let me know. I think it's better we get extcon stuff in the initial patch so that we don't have to maintain some piece of code for legacy dt. Others can be added later. Thanks Kishon
Re: [PATCHv2] phy: cpcap-usb: Add CPCAP PMIC USB support
Hi Tony, On Monday 27 March 2017 08:35 PM, Tony Lindgren wrote: > * Kishon Vijay Abraham I [170326 23:27]: >> On Thursday 23 March 2017 05:16 AM, Tony Lindgren wrote: >>> +static const struct phy_ops ops = { >>> + .owner = THIS_MODULE, >>> +}; >> >> Given that this phy doesn't have any phy_ops, Is there a reason for >> registering >> this phy with the phy framework? Is it because this driver uses the >> phy_core's >> pm_runtime feature? > > Well there's also an ULPI PHY on CPCAP, but it's not used in the > motorola-mapphone configuration. I think some other configurations > use it though, so probably best to keep it. > > And yeah, for PM runtime, I was thinking that we can have the > UART mode be the idle state. > >>> +static void cpcap_usb_detect(struct work_struct *work) >>> +{ >>> + struct cpcap_phy_ddata *ddata; >>> + struct cpcap_usb_ints_state s; >>> + bool vbus = false; >>> + int error; >>> + >>> + ddata = container_of(work, struct cpcap_phy_ddata, detect_work.work); >>> + >>> + error = cpcap_phy_get_ints_state(ddata, ); >>> + if (error) >>> + return; >>> + >>> + /* See also cpcap-charger.c phy_companion for VBUS handling */ >> >> I think this companion should have ideally used extcon framework. Then we >> could >> have used extcon_get_state() here. > > OK I'll take a look at that. I'd like to do that as a follow-up > patches if that's OK with you. > > FYI in case you're wondering, there are ADCs on the PMIC available > via IIO, and the charger is also using IIO framework for VBUS and > battery voltage. And the VBUS is set up as reverse mode in the > charger registers and the charging needs to be disabled for VBUS. > > I guess Ideally the VBUS would be just a regulator from Linux point > of view that also allows negative current :) > >>> + ddata->vusb = devm_regulator_get(>dev, "vusb"); >>> + if (IS_ERR(ddata->vusb)) >>> + return PTR_ERR(ddata->vusb); >>> + >>> + error = regulator_enable(ddata->vusb); >>> + if (error) >>> + return error; >> >> Maybe we should create power_on ops and do regulator enable there? > > This regulator is also needed for the UART mode, so it would have > to be disabled conditionally based on maybe a module parameter. > But yeah thanks for the pointer I did not even realize you have > power_on ops :) > > Seems this can be also done when implementing PM runtime handling. > If you want some of these changes done for the initial patch, > please let me know. I think it's better we get extcon stuff in the initial patch so that we don't have to maintain some piece of code for legacy dt. Others can be added later. Thanks Kishon
Re: [PATCHv2] phy: cpcap-usb: Add CPCAP PMIC USB support
On Wed, Mar 22, 2017 at 04:46:02PM -0700, 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. > > Cc: devicet...@vger.kernel.org > Cc: Marcel Partap> Cc: Michael Scott > Tested-by: Sebastian Reichel > Signed-off-by: Tony Lindgren > --- > > Changes since v1: > > - Use iio_read_channel_processed() instead of iio_read_channel_scaled() > as changed in the v2 of the ADC driver > > - Keep Tested-by from Sebastian Reichel as the change > from v1 is trivial > > --- > .../devicetree/bindings/phy/phy-cpcap-usb.txt | 40 ++ Acked-by: Rob Herring > drivers/phy/Kconfig| 8 + > drivers/phy/Makefile | 1 + > drivers/phy/phy-cpcap-usb.c| 695 > + > 4 files changed, 744 insertions(+) > create mode 100644 Documentation/devicetree/bindings/phy/phy-cpcap-usb.txt > create mode 100644 drivers/phy/phy-cpcap-usb.c
Re: [PATCHv2] phy: cpcap-usb: Add CPCAP PMIC USB support
On Wed, Mar 22, 2017 at 04:46:02PM -0700, 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. > > Cc: devicet...@vger.kernel.org > Cc: Marcel Partap > Cc: Michael Scott > Tested-by: Sebastian Reichel > Signed-off-by: Tony Lindgren > --- > > Changes since v1: > > - Use iio_read_channel_processed() instead of iio_read_channel_scaled() > as changed in the v2 of the ADC driver > > - Keep Tested-by from Sebastian Reichel as the change > from v1 is trivial > > --- > .../devicetree/bindings/phy/phy-cpcap-usb.txt | 40 ++ Acked-by: Rob Herring > drivers/phy/Kconfig| 8 + > drivers/phy/Makefile | 1 + > drivers/phy/phy-cpcap-usb.c| 695 > + > 4 files changed, 744 insertions(+) > create mode 100644 Documentation/devicetree/bindings/phy/phy-cpcap-usb.txt > create mode 100644 drivers/phy/phy-cpcap-usb.c
Re: [PATCHv2] phy: cpcap-usb: Add CPCAP PMIC USB support
* Kishon Vijay Abraham I[170326 23:27]: > On Thursday 23 March 2017 05:16 AM, Tony Lindgren wrote: > > +static const struct phy_ops ops = { > > + .owner = THIS_MODULE, > > +}; > > Given that this phy doesn't have any phy_ops, Is there a reason for > registering > this phy with the phy framework? Is it because this driver uses the phy_core's > pm_runtime feature? Well there's also an ULPI PHY on CPCAP, but it's not used in the motorola-mapphone configuration. I think some other configurations use it though, so probably best to keep it. And yeah, for PM runtime, I was thinking that we can have the UART mode be the idle state. > > +static void cpcap_usb_detect(struct work_struct *work) > > +{ > > + struct cpcap_phy_ddata *ddata; > > + struct cpcap_usb_ints_state s; > > + bool vbus = false; > > + int error; > > + > > + ddata = container_of(work, struct cpcap_phy_ddata, detect_work.work); > > + > > + error = cpcap_phy_get_ints_state(ddata, ); > > + if (error) > > + return; > > + > > + /* See also cpcap-charger.c phy_companion for VBUS handling */ > > I think this companion should have ideally used extcon framework. Then we > could > have used extcon_get_state() here. OK I'll take a look at that. I'd like to do that as a follow-up patches if that's OK with you. FYI in case you're wondering, there are ADCs on the PMIC available via IIO, and the charger is also using IIO framework for VBUS and battery voltage. And the VBUS is set up as reverse mode in the charger registers and the charging needs to be disabled for VBUS. I guess Ideally the VBUS would be just a regulator from Linux point of view that also allows negative current :) > > + ddata->vusb = devm_regulator_get(>dev, "vusb"); > > + if (IS_ERR(ddata->vusb)) > > + return PTR_ERR(ddata->vusb); > > + > > + error = regulator_enable(ddata->vusb); > > + if (error) > > + return error; > > Maybe we should create power_on ops and do regulator enable there? This regulator is also needed for the UART mode, so it would have to be disabled conditionally based on maybe a module parameter. But yeah thanks for the pointer I did not even realize you have power_on ops :) Seems this can be also done when implementing PM runtime handling. If you want some of these changes done for the initial patch, please let me know. Regards, Tony
Re: [PATCHv2] phy: cpcap-usb: Add CPCAP PMIC USB support
* Kishon Vijay Abraham I [170326 23:27]: > On Thursday 23 March 2017 05:16 AM, Tony Lindgren wrote: > > +static const struct phy_ops ops = { > > + .owner = THIS_MODULE, > > +}; > > Given that this phy doesn't have any phy_ops, Is there a reason for > registering > this phy with the phy framework? Is it because this driver uses the phy_core's > pm_runtime feature? Well there's also an ULPI PHY on CPCAP, but it's not used in the motorola-mapphone configuration. I think some other configurations use it though, so probably best to keep it. And yeah, for PM runtime, I was thinking that we can have the UART mode be the idle state. > > +static void cpcap_usb_detect(struct work_struct *work) > > +{ > > + struct cpcap_phy_ddata *ddata; > > + struct cpcap_usb_ints_state s; > > + bool vbus = false; > > + int error; > > + > > + ddata = container_of(work, struct cpcap_phy_ddata, detect_work.work); > > + > > + error = cpcap_phy_get_ints_state(ddata, ); > > + if (error) > > + return; > > + > > + /* See also cpcap-charger.c phy_companion for VBUS handling */ > > I think this companion should have ideally used extcon framework. Then we > could > have used extcon_get_state() here. OK I'll take a look at that. I'd like to do that as a follow-up patches if that's OK with you. FYI in case you're wondering, there are ADCs on the PMIC available via IIO, and the charger is also using IIO framework for VBUS and battery voltage. And the VBUS is set up as reverse mode in the charger registers and the charging needs to be disabled for VBUS. I guess Ideally the VBUS would be just a regulator from Linux point of view that also allows negative current :) > > + ddata->vusb = devm_regulator_get(>dev, "vusb"); > > + if (IS_ERR(ddata->vusb)) > > + return PTR_ERR(ddata->vusb); > > + > > + error = regulator_enable(ddata->vusb); > > + if (error) > > + return error; > > Maybe we should create power_on ops and do regulator enable there? This regulator is also needed for the UART mode, so it would have to be disabled conditionally based on maybe a module parameter. But yeah thanks for the pointer I did not even realize you have power_on ops :) Seems this can be also done when implementing PM runtime handling. If you want some of these changes done for the initial patch, please let me know. Regards, Tony
Re: [PATCHv2] phy: cpcap-usb: Add CPCAP PMIC USB support
Hi Tony, On Thursday 23 March 2017 05:16 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. > > Cc: devicet...@vger.kernel.org > Cc: Marcel Partap> Cc: Michael Scott > Tested-by: Sebastian Reichel > Signed-off-by: Tony Lindgren > --- > > Changes since v1: > > - Use iio_read_channel_processed() instead of iio_read_channel_scaled() > as changed in the v2 of the ADC driver > > - Keep 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| 695 > + > 4 files changed, 744 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 > + 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,695 @@ > +/* > + * 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. > + *
Re: [PATCHv2] phy: cpcap-usb: Add CPCAP PMIC USB support
Hi Tony, On Thursday 23 March 2017 05:16 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. > > Cc: devicet...@vger.kernel.org > Cc: Marcel Partap > Cc: Michael Scott > Tested-by: Sebastian Reichel > Signed-off-by: Tony Lindgren > --- > > Changes since v1: > > - Use iio_read_channel_processed() instead of iio_read_channel_scaled() > as changed in the v2 of the ADC driver > > - Keep 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| 695 > + > 4 files changed, 744 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 > + 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,695 @@ > +/* > + * 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 the terms of the GNU
Re: [PATCHv2] phy: cpcap-usb: Add CPCAP PMIC USB support
* kbuild test robot[170325 13:45]: > Hi Tony, > > [auto build test ERROR on phy/next] > [also build test ERROR on v4.11-rc3 next-20170324] > [if your patch is applied to the wrong git tree, please drop us a note to > help improve the system] > > url: > https://github.com/0day-ci/linux/commits/Tony-Lindgren/phy-cpcap-usb-Add-CPCAP-PMIC-USB-support/20170324-061112 > base: https://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git > next > config: x86_64-randconfig-a0-03260238 (attached as .config) > compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7 > reproduce: > # save the attached .config to linux build tree > make ARCH=x86_64 > > All errors (new ones prefixed by >>): > >drivers/built-in.o: In function `cpcap_usb_detect': > >> phy-cpcap-usb.c:(.text+0x18ad): undefined reference to > >> `iio_read_channel_processed' >drivers/built-in.o: In function `cpcap_usb_phy_probe': > >> phy-cpcap-usb.c:(.text+0x1c5e): undefined reference to > >> `devm_iio_channel_get' > >> phy-cpcap-usb.c:(.text+0x1c92): undefined reference to > >> `iio_get_channel_type' OK thanks for the report, we need IIO for VBUS level, here's a patch to fix it. Regards, Tony 8< --- >From tony Mon Sep 17 00:00:00 2001 From: Tony Lindgren Date: Sat, 25 Mar 2017 15:04:37 -0700 Subject: [PATCH] phy: cpcap-usb: Fix build by adding a dependency to CONFIG_IIO We need the ADC output provided by IIO to detect VBUS level. Otherwise we can get: drivers/built-in.o: In function `cpcap_usb_detect': phy-cpcap-usb.c:(.text+0x18ad): undefined reference to `iio_read_channel_processed' drivers/built-in.o: In function `cpcap_usb_phy_probe': phy-cpcap-usb.c:(.text+0x1c5e): undefined reference to `devm_iio_channel_get' phy-cpcap-usb.c:(.text+0x1c92): undefined reference to`iio_get_channel_type' Reported-by: kbuild test robot Signed-off-by: Tony Lindgren --- drivers/phy/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -49,7 +49,7 @@ config PHY_BERLIN_SATA config PHY_CPCAP_USB tristate "CPCAP USB PHY driver" - depends on USB_SUPPORT + depends on USB_SUPPORT && IIO select GENERIC_PHY select USB_PHY help -- 2.12.1
Re: [PATCHv2] phy: cpcap-usb: Add CPCAP PMIC USB support
* kbuild test robot [170325 13:45]: > Hi Tony, > > [auto build test ERROR on phy/next] > [also build test ERROR on v4.11-rc3 next-20170324] > [if your patch is applied to the wrong git tree, please drop us a note to > help improve the system] > > url: > https://github.com/0day-ci/linux/commits/Tony-Lindgren/phy-cpcap-usb-Add-CPCAP-PMIC-USB-support/20170324-061112 > base: https://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git > next > config: x86_64-randconfig-a0-03260238 (attached as .config) > compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7 > reproduce: > # save the attached .config to linux build tree > make ARCH=x86_64 > > All errors (new ones prefixed by >>): > >drivers/built-in.o: In function `cpcap_usb_detect': > >> phy-cpcap-usb.c:(.text+0x18ad): undefined reference to > >> `iio_read_channel_processed' >drivers/built-in.o: In function `cpcap_usb_phy_probe': > >> phy-cpcap-usb.c:(.text+0x1c5e): undefined reference to > >> `devm_iio_channel_get' > >> phy-cpcap-usb.c:(.text+0x1c92): undefined reference to > >> `iio_get_channel_type' OK thanks for the report, we need IIO for VBUS level, here's a patch to fix it. Regards, Tony 8< --- >From tony Mon Sep 17 00:00:00 2001 From: Tony Lindgren Date: Sat, 25 Mar 2017 15:04:37 -0700 Subject: [PATCH] phy: cpcap-usb: Fix build by adding a dependency to CONFIG_IIO We need the ADC output provided by IIO to detect VBUS level. Otherwise we can get: drivers/built-in.o: In function `cpcap_usb_detect': phy-cpcap-usb.c:(.text+0x18ad): undefined reference to `iio_read_channel_processed' drivers/built-in.o: In function `cpcap_usb_phy_probe': phy-cpcap-usb.c:(.text+0x1c5e): undefined reference to `devm_iio_channel_get' phy-cpcap-usb.c:(.text+0x1c92): undefined reference to`iio_get_channel_type' Reported-by: kbuild test robot Signed-off-by: Tony Lindgren --- drivers/phy/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -49,7 +49,7 @@ config PHY_BERLIN_SATA config PHY_CPCAP_USB tristate "CPCAP USB PHY driver" - depends on USB_SUPPORT + depends on USB_SUPPORT && IIO select GENERIC_PHY select USB_PHY help -- 2.12.1
Re: [PATCHv2] phy: cpcap-usb: Add CPCAP PMIC USB support
Hi Tony, [auto build test ERROR on phy/next] [also build test ERROR on v4.11-rc3 next-20170324] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Tony-Lindgren/phy-cpcap-usb-Add-CPCAP-PMIC-USB-support/20170324-061112 base: https://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git next config: x86_64-randconfig-a0-03260238 (attached as .config) compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): drivers/built-in.o: In function `cpcap_usb_detect': >> phy-cpcap-usb.c:(.text+0x18ad): undefined reference to >> `iio_read_channel_processed' drivers/built-in.o: In function `cpcap_usb_phy_probe': >> phy-cpcap-usb.c:(.text+0x1c5e): undefined reference to `devm_iio_channel_get' >> phy-cpcap-usb.c:(.text+0x1c92): undefined reference to `iio_get_channel_type' --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [PATCHv2] phy: cpcap-usb: Add CPCAP PMIC USB support
Hi Tony, [auto build test ERROR on phy/next] [also build test ERROR on v4.11-rc3 next-20170324] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Tony-Lindgren/phy-cpcap-usb-Add-CPCAP-PMIC-USB-support/20170324-061112 base: https://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git next config: x86_64-randconfig-a0-03260238 (attached as .config) compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): drivers/built-in.o: In function `cpcap_usb_detect': >> phy-cpcap-usb.c:(.text+0x18ad): undefined reference to >> `iio_read_channel_processed' drivers/built-in.o: In function `cpcap_usb_phy_probe': >> phy-cpcap-usb.c:(.text+0x1c5e): undefined reference to `devm_iio_channel_get' >> phy-cpcap-usb.c:(.text+0x1c92): undefined reference to `iio_get_channel_type' --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
[PATCHv2] 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 Tested-by: Sebastian Reichel Signed-off-by: Tony Lindgren --- Changes since v1: - Use iio_read_channel_processed() instead of iio_read_channel_scaled() as changed in the v2 of the ADC driver - Keep 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| 695 + 4 files changed, 744 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 + 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,695 @@ +/* + * 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 the terms of the GNU General Public License as + * published by the Free Software Foundation version 2. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether
[PATCHv2] 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 Partap Cc: Michael Scott Tested-by: Sebastian Reichel Signed-off-by: Tony Lindgren --- Changes since v1: - Use iio_read_channel_processed() instead of iio_read_channel_scaled() as changed in the v2 of the ADC driver - Keep 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| 695 + 4 files changed, 744 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 + 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,695 @@ +/* + * 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 the terms of the GNU General Public License as + * published by the Free Software Foundation version 2. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR