[PATCH v2 1/4] usb: phy: phy-omap-control: Add API to power and wakeup
on/off USB PHY for AM335X Add APIs to -power on/off USB PHY for AM335X -enable/disable PHY wakeup. This API will be called from phy-am-usb driver. Signed-off-by: George Cherian --- drivers/usb/phy/phy-omap-control.c | 67 include/linux/usb/omap_control_usb.h | 24 + 2 files changed, 91 insertions(+) diff --git a/drivers/usb/phy/phy-omap-control.c b/drivers/usb/phy/phy-omap-control.c index 1419ced..4f2502c 100644 --- a/drivers/usb/phy/phy-omap-control.c +++ b/drivers/usb/phy/phy-omap-control.c @@ -46,6 +46,73 @@ struct device *omap_get_control_dev(void) EXPORT_SYMBOL_GPL(omap_get_control_dev); /** + * omap_control_am335x_phy_wkup - PHY wakeup on/off using control + * module + * @dev: the control module device + * @on: 0 to off and 1 to on PHY wakeup feature + * @id: phy id 0 or 1 for phy instance 0 and 1 repectively + * + * AM PHY driver should call this API to enable or disable PHY wakeup. + */ +void omap_control_am335x_phy_wkup(struct device *dev, bool on, u8 id) +{ + u32 val; + u32 *phy_wkup_reg; + struct omap_control_usb *control_usb = dev_get_drvdata(dev); + + if (control_usb->type != OMAP_CTRL_DEV_TYPE3 || id < 0 || id > 1) + return; + + phy_wkup_reg = control_usb->dev_conf + AM335X_USB_WKUP_OFFSET; + val = readl(phy_wkup_reg); + + if (on) + val |= id ? AM335X_USB1_WKUP_CTRL_ENABLE : + AM335X_USB0_WKUP_CTRL_ENABLE; +else + val &= id ? ~AM335X_USB1_WKUP_CTRL_ENABLE : + ~AM335X_USB0_WKUP_CTRL_ENABLE; + + + writel(val, phy_wkup_reg); +} +EXPORT_SYMBOL_GPL(omap_control_am335x_phy_wkup); + +/** + * omap_control_am335x_phy_power - power on/off the serializer using control + * module + * @dev: the control module device + * @on: 0 to off and 1 to on based on powering on or off the PHY + * @id: phy id 0 or 1 for phy instance 0 and 1 repectively + * + * AM PHY driver should call this API to power on or off the PHY. + */ +void omap_control_am335x_phy_power(struct device *dev, bool on, u8 id) +{ + u32 val; + u32 *phy_pwr_reg; + struct omap_control_usb *control_usb = dev_get_drvdata(dev); + + if (control_usb->type != OMAP_CTRL_DEV_TYPE3 || id < 0 || id > 1) + return; + + phy_pwr_reg = GET_PHY_POWER_REG(control_usb->dev_conf, id); + val = readl(phy_pwr_reg); + + if (on) { + val &= ~(AM335X_USBPHY_CM_PWRDN | AM335X_USBPHY_OTG_PWRDN); + val |= AM335X_USBPHY_OTGVDET_EN | + AM335X_USBPHY_OTGSESSEND_EN; + } else + val |= AM335X_USBPHY_CM_PWRDN | AM335X_USBPHY_OTG_PWRDN; + + + writel(val, phy_pwr_reg); +} +EXPORT_SYMBOL_GPL(omap_control_am335x_phy_power); + + +/** * omap_control_usb3_phy_power - power on/off the serializer using control * module * @dev: the control module device diff --git a/include/linux/usb/omap_control_usb.h b/include/linux/usb/omap_control_usb.h index 27b5b8c..a92b417 100644 --- a/include/linux/usb/omap_control_usb.h +++ b/include/linux/usb/omap_control_usb.h @@ -45,6 +45,7 @@ enum omap_control_usb_mode { /* To differentiate ctrl module IP having either mailbox or USB3 PHY power */ #defineOMAP_CTRL_DEV_TYPE1 0x1 #defineOMAP_CTRL_DEV_TYPE2 0x2 +#defineOMAP_CTRL_DEV_TYPE3 0x3 #defineOMAP_CTRL_DEV_PHY_PDBIT(0) @@ -63,10 +64,23 @@ enum omap_control_usb_mode { #defineOMAP_CTRL_USB3_PHY_TX_RX_POWERON0x3 #defineOMAP_CTRL_USB3_PHY_TX_RX_POWEROFF 0x0 +#define GET_PHY_POWER_REG(base, id)((u32 *)base + (id * 2)) +#define AM335X_USBPHY_CM_PWRDN (1 << 0) +#define AM335X_USBPHY_OTG_PWRDN(1 << 1) +#define AM335X_USBPHY_OTGVDET_EN (1 << 19) +#define AM335X_USBPHY_OTGSESSEND_EN(1 << 20) +#define AM335X_USB_WKUP_OFFSET 0xA +#define AM335X_USB0_WKUP_CTRL_ENABLE (1 << 0) +#define AM335X_USB1_WKUP_CTRL_ENABLE (1 << 8) + + + #if IS_ENABLED(CONFIG_OMAP_CONTROL_USB) extern struct device *omap_get_control_dev(void); extern void omap_control_usb_phy_power(struct device *dev, int on); extern void omap_control_usb3_phy_power(struct device *dev, bool on); +extern void omap_control_am335x_phy_power(struct device *dev, bool on, u8 id); +extern void omap_control_am335x_phy_wkup(struct device *dev, bool on, u8 id); extern void omap_control_usb_set_mode(struct device *dev, enum omap_control_usb_mode mode); #else @@ -87,6 +101,16 @@ static inline void omap_control_usb_set_mode(struct device *dev, enum omap_control_usb_mode mode) { } + +static inline void omap_control_am335x_phy_power(struct device *dev, +bool on, u8 id) +{ +} + +static inline void omap_control_am335x_phy_wkup(struct device *dev, +bool on, u8 id) +{ +} #endif
Re: [PATCH v2 1/4] usb: phy: phy-omap-control: Add API to power and wakeup
Hi, On Friday 19 July 2013 06:04 PM, George Cherian wrote: > on/off USB PHY for AM335X > > Add APIs to > -power on/off USB PHY for AM335X > -enable/disable PHY wakeup. > > This API will be called from phy-am-usb driver. > > Signed-off-by: George Cherian > --- > drivers/usb/phy/phy-omap-control.c | 67 > > include/linux/usb/omap_control_usb.h | 24 + > 2 files changed, 91 insertions(+) > > diff --git a/drivers/usb/phy/phy-omap-control.c > b/drivers/usb/phy/phy-omap-control.c > index 1419ced..4f2502c 100644 > --- a/drivers/usb/phy/phy-omap-control.c > +++ b/drivers/usb/phy/phy-omap-control.c > @@ -46,6 +46,73 @@ struct device *omap_get_control_dev(void) > EXPORT_SYMBOL_GPL(omap_get_control_dev); > > /** > + * omap_control_am335x_phy_wkup - PHY wakeup on/off using control > + * module > + * @dev: the control module device > + * @on: 0 to off and 1 to on PHY wakeup feature %s/off/disable %s/on/enable > + * @id: phy id 0 or 1 for phy instance 0 and 1 repectively > + * > + * AM PHY driver should call this API to enable or disable PHY wakeup. > + */ > +void omap_control_am335x_phy_wkup(struct device *dev, bool on, u8 id) > +{ > + u32 val; > + u32 *phy_wkup_reg; > + struct omap_control_usb *control_usb = dev_get_drvdata(dev); > + > + if (control_usb->type != OMAP_CTRL_DEV_TYPE3 || id < 0 || id > 1) > + return; > + > + phy_wkup_reg = control_usb->dev_conf + AM335X_USB_WKUP_OFFSET; > + val = readl(phy_wkup_reg); > + > + if (on) > + val |= id ? AM335X_USB1_WKUP_CTRL_ENABLE : > + AM335X_USB0_WKUP_CTRL_ENABLE; > + else > + val &= id ? ~AM335X_USB1_WKUP_CTRL_ENABLE : > + ~AM335X_USB0_WKUP_CTRL_ENABLE; > + > + You really need two blank spaces here? > + writel(val, phy_wkup_reg); > +} > +EXPORT_SYMBOL_GPL(omap_control_am335x_phy_wkup); > + > +/** > + * omap_control_am335x_phy_power - power on/off the serializer using control > + * module > + * @dev: the control module device > + * @on: 0 to off and 1 to on based on powering on or off the PHY > + * @id: phy id 0 or 1 for phy instance 0 and 1 repectively > + * > + * AM PHY driver should call this API to power on or off the PHY. > + */ > +void omap_control_am335x_phy_power(struct device *dev, bool on, u8 id) > +{ > + u32 val; > + u32 *phy_pwr_reg; > + struct omap_control_usb *control_usb = dev_get_drvdata(dev); > + > + if (control_usb->type != OMAP_CTRL_DEV_TYPE3 || id < 0 || id > 1) > + return; > + > + phy_pwr_reg = GET_PHY_POWER_REG(control_usb->dev_conf, id); > + val = readl(phy_pwr_reg); > + > + if (on) { > + val &= ~(AM335X_USBPHY_CM_PWRDN | AM335X_USBPHY_OTG_PWRDN); > + val |= AM335X_USBPHY_OTGVDET_EN | > + AM335X_USBPHY_OTGSESSEND_EN; > + } else > + val |= AM335X_USBPHY_CM_PWRDN | AM335X_USBPHY_OTG_PWRDN; > + > + ditto. > + writel(val, phy_pwr_reg); > +} > +EXPORT_SYMBOL_GPL(omap_control_am335x_phy_power); > + > + ditto. > +/** > * omap_control_usb3_phy_power - power on/off the serializer using control > * module > * @dev: the control module device > diff --git a/include/linux/usb/omap_control_usb.h > b/include/linux/usb/omap_control_usb.h > index 27b5b8c..a92b417 100644 > --- a/include/linux/usb/omap_control_usb.h > +++ b/include/linux/usb/omap_control_usb.h > @@ -45,6 +45,7 @@ enum omap_control_usb_mode { > /* To differentiate ctrl module IP having either mailbox or USB3 PHY power */ > #define OMAP_CTRL_DEV_TYPE1 0x1 > #define OMAP_CTRL_DEV_TYPE2 0x2 > +#define OMAP_CTRL_DEV_TYPE3 0x3 > > #define OMAP_CTRL_DEV_PHY_PDBIT(0) > > @@ -63,10 +64,23 @@ enum omap_control_usb_mode { > #define OMAP_CTRL_USB3_PHY_TX_RX_POWERON0x3 > #define OMAP_CTRL_USB3_PHY_TX_RX_POWEROFF 0x0 > > +#define GET_PHY_POWER_REG(base, id) ((u32 *)base + (id * 2)) how about #define GET_PHY_POWER_REG(base, id) ((u32 *)(base) + ((id) * 2)) > +#define AM335X_USBPHY_CM_PWRDN (1 << 0) > +#define AM335X_USBPHY_OTG_PWRDN (1 << 1) > +#define AM335X_USBPHY_OTGVDET_EN (1 << 19) > +#define AM335X_USBPHY_OTGSESSEND_EN (1 << 20) > +#define AM335X_USB_WKUP_OFFSET 0xA > +#define AM335X_USB0_WKUP_CTRL_ENABLE (1 << 0) > +#define AM335X_USB1_WKUP_CTRL_ENABLE (1 << 8) > + > + > + too many blank lines... Thanks Kishon -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/4] usb: phy: phy-omap-control: Add API to power and wakeup
* George Cherian | 2013-07-19 18:04:34 [+0530]: >diff --git a/drivers/usb/phy/phy-omap-control.c >b/drivers/usb/phy/phy-omap-control.c >index 1419ced..4f2502c 100644 >--- a/drivers/usb/phy/phy-omap-control.c >+++ b/drivers/usb/phy/phy-omap-control.c >@@ -46,6 +46,73 @@ struct device *omap_get_control_dev(void) > EXPORT_SYMBOL_GPL(omap_get_control_dev); > > /** >+ * omap_control_am335x_phy_wkup - PHY wakeup on/off using control >+ *module >+ * @dev: the control module device >+ * @on: 0 to off and 1 to on PHY wakeup feature >+ * @id: phy id 0 or 1 for phy instance 0 and 1 repectively >+ * >+ * AM PHY driver should call this API to enable or disable PHY wakeup. >+ */ >+void omap_control_am335x_phy_wkup(struct device *dev, bool on, u8 id) >+{ >+ u32 val; >+ u32 *phy_wkup_reg; >+ struct omap_control_usb *control_usb = dev_get_drvdata(dev); >+ >+ if (control_usb->type != OMAP_CTRL_DEV_TYPE3 || id < 0 || id > 1) >+ return; >+ >+ phy_wkup_reg = control_usb->dev_conf + AM335X_USB_WKUP_OFFSET; >+ val = readl(phy_wkup_reg); Where do you get the memory from? In the DT patches I've made I export one memory space of 8 bytes for each phy. This memory space applies directly to the on/off register. I didn't export the register for wakeup so far since I had no idea how this will be used. So how do you get your re-mapped memory here? >+ >+ if (on) >+ val |= id ? AM335X_USB1_WKUP_CTRL_ENABLE : >+ AM335X_USB0_WKUP_CTRL_ENABLE; >+ else >+ val &= id ? ~AM335X_USB1_WKUP_CTRL_ENABLE : >+ ~AM335X_USB0_WKUP_CTRL_ENABLE; >+ >+ >+ writel(val, phy_wkup_reg); >+} >+EXPORT_SYMBOL_GPL(omap_control_am335x_phy_wkup); Sebastian -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/4] usb: phy: phy-omap-control: Add API to power and wakeup
On 7/29/2013 7:55 PM, Sebastian Andrzej Siewior wrote: * George Cherian | 2013-07-19 18:04:34 [+0530]: diff --git a/drivers/usb/phy/phy-omap-control.c b/drivers/usb/phy/phy-omap-control.c index 1419ced..4f2502c 100644 --- a/drivers/usb/phy/phy-omap-control.c +++ b/drivers/usb/phy/phy-omap-control.c @@ -46,6 +46,73 @@ struct device *omap_get_control_dev(void) EXPORT_SYMBOL_GPL(omap_get_control_dev); /** + * omap_control_am335x_phy_wkup - PHY wakeup on/off using control + * module + * @dev: the control module device + * @on: 0 to off and 1 to on PHY wakeup feature + * @id: phy id 0 or 1 for phy instance 0 and 1 repectively + * + * AM PHY driver should call this API to enable or disable PHY wakeup. + */ +void omap_control_am335x_phy_wkup(struct device *dev, bool on, u8 id) +{ + u32 val; + u32 *phy_wkup_reg; + struct omap_control_usb *control_usb = dev_get_drvdata(dev); + + if (control_usb->type != OMAP_CTRL_DEV_TYPE3 || id < 0 || id > 1) + return; + + phy_wkup_reg = control_usb->dev_conf + AM335X_USB_WKUP_OFFSET; + val = readl(phy_wkup_reg); Where do you get the memory from? In the DT patches I've made I export one memory space of 8 bytes for each phy. This memory space applies directly to the on/off register. Control module have 2 separate registers for phy on/off per instance (offset 0x620 and 0x628), where as wkup_ctrl is a shared control module register (offset 0x648). Currently the control module driver maps memory from 0x620 till beyond 0x648 and uses the same mapping for writing to wkup_reg. I didn't export the register for wakeup so far since I had no idea how this will be used. So how do you get your re-mapped memory here? Mapping it per instance is not possible since its the same register (if we use devm_* calls). -- -George -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/4] usb: phy: phy-omap-control: Add API to power and wakeup
On 07/30/2013 06:53 AM, George Cherian wrote: > Control module have 2 separate registers for phy on/off per instance > (offset 0x620 and 0x628), where as > wkup_ctrl is a shared control module register (offset 0x648). Currently > the control module driver maps > memory from 0x620 till beyond 0x648 and uses the same mapping for > writing to wkup_reg. This I know about. My question is where do you remap this memory. You have to put the memory address somewhere. Sebastian -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html