mbox series

[v7,0/3] usb: cdns3: add runtime pm support

Message ID 20200825021120.4926-1-peter.chen@nxp.com
Headers show
Series usb: cdns3: add runtime pm support | expand

Message

Peter Chen Aug. 25, 2020, 2:11 a.m. UTC
Hi Felipe,

In this series, it adds cdns3 runtime PM support, and verified at
NXP i.MX8QM and i.MX8QXP platforms.

Changes for v7:
- Fix one coding style issue [Patch 2/3]
- Fix one sparese isse Reported-by: kernel test robot <lkp@intel.com> [Patch 3/3]

Changes for v6:
- Add Pawel's reviewed-by
- Remove xhci-plat patches, which was sent by xhci patch series [1]
- Rebased on the newest usb/next

Changes for v5:
- Address Greg's comments for more obvious PHY power controller APIs [Patch 1/2]
- One build warning from kernel test robot

Changes for v4:
- Address Jun Li's comments for cdns3 core changes [Patch 2]
- Some small fixes for cdns3-imx for CLK_125_REQ bit
- Rebase the latest usb-next

Changes for v3:
Add Jun Li’s reviewed-by [Patch 1 and Patch 6]
Add Mathias’s acked-by [Patch 4-6]
Some wakeup logic improvement [Patch 2]
Add dedicated wakeup interrupt for core, and improve the commit log [Patch]
Fix build error found by kbuild test robot [Patch 3]
Using xhci_plat_priv quirk for skip PHY initialization [patch 7, patch 9]
Some other typo and tiny improvements

Changes for v2:
- Add the 1st patch. Without it, the build on the usb-next will fail.
- Change the subject for cover letter a little to reflect all contents.

[1] https://www.spinics.net/lists/linux-usb/msg199399.html

Peter Chen (3):
  usb: cdns3: introduce set_phy_power_on{off} APIs
  usb: cdns3: add runtime PM support
  usb: cdns3: imx: add glue layer runtime pm implementation

 drivers/usb/cdns3/cdns3-imx.c | 203 ++++++++++++++++++++++++++++++++--
 drivers/usb/cdns3/core.c      | 195 ++++++++++++++++++++++++++------
 drivers/usb/cdns3/core.h      |  16 +++
 drivers/usb/cdns3/drd.c       |   3 +
 drivers/usb/cdns3/gadget.c    |   4 +
 drivers/usb/cdns3/host.c      |   7 ++
 6 files changed, 385 insertions(+), 43 deletions(-)

Comments

Peter Chen Sept. 2, 2020, 9:49 a.m. UTC | #1
B
> >
> > > Add imx glue layer runtime pm implementation, and the runtime
> > > pm is default off.
> > >
> > > Reviewed-by: Pawel Laszczak <pawell@cadence.com>
> > > Signed-off-by: Peter Chen <peter.chen@nxp.com>
> > > ---
> > >  drivers/usb/cdns3/cdns3-imx.c | 203 ++++++++++++++++++++++++++++++++--
> > >  1 file changed, 192 insertions(+), 11 deletions(-)
> > >
> > > diff --git a/drivers/usb/cdns3/cdns3-imx.c b/drivers/usb/cdns3/cdns3-imx.c
> > > index aba988e71958..a413df26e948 100644
> > > --- a/drivers/usb/cdns3/cdns3-imx.c
> > > +++ b/drivers/usb/cdns3/cdns3-imx.c
> > > @@ -15,6 +15,8 @@
> > >  #include <linux/io.h>
> > >  #include <linux/of_platform.h>
> > >  #include <linux/iopoll.h>
> > > +#include <linux/pm_runtime.h>
> > > +#include "core.h"
> > >
> > >  #define USB3_CORE_CTRL1    0x00
> > >  #define USB3_CORE_CTRL2    0x04
> > > @@ -32,7 +34,7 @@
> > >  /* Register bits definition */
> > >
> > >  /* USB3_CORE_CTRL1 */
> > > -#define SW_RESET_MASK      (0x3f << 26)
> > > +#define SW_RESET_MASK      GENMASK(31, 26)
> >
> > why is this part of adding imx runtime pm?
>
> Sorry, will delete this improvement
> >
> > > @@ -44,17 +46,17 @@
> > >  #define OC_DISABLE BIT(9)
> > >  #define MDCTRL_CLK_SEL     BIT(7)
> > >  #define MODE_STRAP_MASK    (0x7)
> > > -#define DEV_MODE   (1 << 2)
> > > -#define HOST_MODE  (1 << 1)
> > > -#define OTG_MODE   (1 << 0)
> > > +#define DEV_MODE   BIT(2)
> > > +#define HOST_MODE  BIT(1)
> > > +#define OTG_MODE   BIT(0)
> >
> > and these?
>
> Sorry, will delete this improvement
>
> >
> > >
> > >  /* USB3_INT_REG */
> > >  #define CLK_125_REQ        BIT(29)
> > >  #define LPM_CLK_REQ        BIT(28)
> > >  #define DEVU3_WAEKUP_EN    BIT(14)
> > >  #define OTG_WAKEUP_EN      BIT(12)
> > > -#define DEV_INT_EN (3 << 8) /* DEV INT b9:8 */
> > > -#define HOST_INT1_EN (1 << 0) /* HOST INT b7:0 */
> > > +#define DEV_INT_EN GENMASK(9, 8) /* DEV INT b9:8 */
> > > +#define HOST_INT1_EN       BIT(0) /* HOST INT b7:0 */
> >
> Sorry, will delete this improvement
>
> >
> > > @@ -62,15 +64,34 @@
> > >  #define HOST_POWER_ON_READY        BIT(12)
> > >
> > >  /* USB3_SSPHY_STATUS */
> > > -#define CLK_VALID_MASK             (0x3f << 26)
> > > -#define CLK_VALID_COMPARE_BITS     (0xf << 28)
> > > -#define PHY_REFCLK_REQ             (1 << 0)
> > > +#define CLK_VALID_MASK             GENMASK(31, 26)
> > > +#define CLK_VALID_COMPARE_BITS     GENMASK(31, 28)
> > > +#define PHY_REFCLK_REQ             BIT(0)
> >
>
> Sorry, will delete this improvement
>
> >
> > > +/* OTG registers definition */
> > > +#define OTGSTS             0x4
> > > +/* OTGSTS */
> > > +#define OTG_NRDY   BIT(11)
> > > +
> > > +/* xHCI registers definition  */
> > > +#define XECP_PM_PMCSR              0x8018
> > > +#define XECP_AUX_CTRL_REG1 0x8120
> > > +
> > > +/* Register bits definition */
> > > +/* XECP_AUX_CTRL_REG1 */
> > > +#define CFG_RXDET_P3_EN            BIT(15)
> > > +
> > > +/* XECP_PM_PMCSR */
> > > +#define PS_MASK                    GENMASK(1, 0)
> > > +#define PS_D0                      0
> > > +#define PS_D1                      1
> >
> > I think only these are part of $subject
>
> Yes, you are right.
>
> >
> > >  struct cdns_imx {
> > >     struct device *dev;
> > >     void __iomem *noncore;
> > >     struct clk_bulk_data *clks;
> > >     int num_clks;
> > > +   struct platform_device *cdns3_pdev;
> > >  };
> > >
> > >  static inline u32 cdns_imx_readl(struct cdns_imx *data, u32 offset)
> > > @@ -126,6 +147,20 @@ static int cdns_imx_noncore_init(struct cdns_imx *data)
> > >     return ret;
> > >  }
> > >
> > > +static int cdns_imx_platform_suspend(struct device *dev,
> > > +   bool suspend, bool wakeup);
> > > +static struct cdns3_platform_data cdns_imx_pdata = {
> >
> > make it const?
>
> Will change

After thinking more, the platform data may be different for
different glue layer platforms. I will keep this unchanging.

Peter