[next PATCH] usb: xhci-mtk: remove bus status check

2021-04-16 Thread Chunfeng Yun
PM will take care of the status of child device, so no need
check each port anymore.

Suggested-by: Ikjoon Jang 
Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mtk.c | 43 ++---
 1 file changed, 2 insertions(+), 41 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index d4c455eecb8d..1fdeb315a124 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -654,42 +654,6 @@ static int __maybe_unused xhci_mtk_resume(struct device 
*dev)
return ret;
 }
 
-static int check_rhub_status(struct xhci_hcd *xhci, struct xhci_hub *rhub)
-{
-   u32 suspended_ports;
-   u32 status;
-   int num_ports;
-   int i;
-
-   num_ports = rhub->num_ports;
-   suspended_ports = rhub->bus_state.suspended_ports;
-   for (i = 0; i < num_ports; i++) {
-   if (!(suspended_ports & BIT(i))) {
-   status = readl(rhub->ports[i]->addr);
-   if (status & PORT_CONNECT)
-   return -EBUSY;
-   }
-   }
-
-   return 0;
-}
-
-/*
- * check the bus whether it could suspend or not
- * the bus will suspend if the downstream ports are already suspended,
- * or no devices connected.
- */
-static int check_bus_status(struct xhci_hcd *xhci)
-{
-   int ret;
-
-   ret = check_rhub_status(xhci, >usb3_rhub);
-   if (ret)
-   return ret;
-
-   return check_rhub_status(xhci, >usb2_rhub);
-}
-
 static int __maybe_unused xhci_mtk_runtime_suspend(struct device *dev)
 {
struct xhci_hcd_mtk  *mtk = dev_get_drvdata(dev);
@@ -699,11 +663,8 @@ static int __maybe_unused xhci_mtk_runtime_suspend(struct 
device *dev)
if (xhci->xhc_state)
return -ESHUTDOWN;
 
-   if (device_may_wakeup(dev)) {
-   ret = check_bus_status(xhci);
-   if (!ret)
-   ret = xhci_mtk_suspend(dev);
-   }
+   if (device_may_wakeup(dev))
+   ret = xhci_mtk_suspend(dev);
 
/* -EBUSY: let PM automatically reschedule another autosuspend */
return ret ? -EBUSY : 0;
-- 
2.18.0



Re: [PATCH 4/6] usb: xhci-mtk: add support runtime PM

2021-04-12 Thread Chunfeng Yun
On Mon, 2021-04-12 at 13:14 +0800, Ikjoon Jang wrote:
> On Fri, Apr 9, 2021 at 4:54 PM Chunfeng Yun  wrote:
> >
> > On Fri, 2021-04-09 at 13:45 +0800, Ikjoon Jang wrote:
> > > On Thu, Apr 8, 2021 at 5:35 PM Chunfeng Yun  
> > > wrote:
> > > >
> > > > A dedicated wakeup irq will be used to handle runtime suspend/resume,
> > > > we use dev_pm_set_dedicated_wake_irq API to take care of requesting
> > > > and attaching wakeup irq, then the suspend/resume framework will help
> > > > to enable/disable wakeup irq.
> > > >
> > > > The runtime PM is default off since some platforms may not support it.
> > > > users can enable it via power/control (set "auto") in sysfs.
> > > >
> > > > Signed-off-by: Chunfeng Yun 
> > > > ---
> > > >  drivers/usb/host/xhci-mtk.c | 140 +++-
> > > >  1 file changed, 124 insertions(+), 16 deletions(-)
> > > >
> > > > diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
> > > > index a74764ab914a..30927f4064d4 100644
> > > > --- a/drivers/usb/host/xhci-mtk.c
> > > > +++ b/drivers/usb/host/xhci-mtk.c
[...]
> > > >
> > > > +static int check_rhub_status(struct xhci_hcd *xhci, struct xhci_hub 
> > > > *rhub)
> > > > +{
> > > > +   u32 suspended_ports;
> > > > +   u32 status;
> > > > +   int num_ports;
> > > > +   int i;
> > > > +
> > > > +   num_ports = rhub->num_ports;
> > > > +   suspended_ports = rhub->bus_state.suspended_ports;
> > > > +   for (i = 0; i < num_ports; i++) {
> > > > +   if (!(suspended_ports & BIT(i))) {
> > > > +   status = readl(rhub->ports[i]->addr);
> > > > +   if (status & PORT_CONNECT)
> > >
> > > So this pm_runtime support is activated only when there's no devices
> > > connected at all?
> > No, if the connected devices also support runtime suspend, it will enter
> > suspend mode when no data transfer, then the controller can enter
> > suspend too
> > > I think this will always return -EBUSY with my board having an on-board 
> > > hub
> > > connected to both rhubs.
> > the on-board hub supports runtime suspend by default, so if no devices
> > connected, it will enter suspend
> 
> Sorry, you're correct. I was confused that the condition was
> (suspended && connect)
> My on-board hub connected to rhub is always in a suspended state
> whenever it's called.
> 
> However, I don't think this could return -EBUSY
> rpm_suspend() only be called when all the descendants are in sleep already.
You mean we can drop the bus check? 
If PM already takes care of children count, I think no need check it
anymore.
> Did you see any cases of this function returning -EBUSY or any concerns on 
> here?
No, I didn't see it before.

Thanks

> 
> 
> >
> > >
> > > > +   return -EBUSY;
> > > > +   }
> > > > +   }
> > > > +
> > > > +   return 0;
> > > > +}
> > > > +
> > > > +/*
> > > > + * check the bus whether it could suspend or not
> > > > + * the bus will suspend if the downstream ports are already suspended,
> > > > + * or no devices connected.
> > > > + */
> > > > +static int check_bus_status(struct xhci_hcd *xhci)
> > > > +{
> > > > +   int ret;
> > > > +
> > > > +   ret = check_rhub_status(xhci, >usb3_rhub);
> > > > +   if (ret)
> > > > +   return ret;
> > > > +
> > > > +   return check_rhub_status(xhci, >usb2_rhub);
> > > > +}
> > > > +
> > > > +static int __maybe_unused xhci_mtk_runtime_suspend(struct device *dev)
> > > > +{
> > > > +   struct xhci_hcd_mtk  *mtk = dev_get_drvdata(dev);
> > > > +   struct xhci_hcd *xhci = hcd_to_xhci(mtk->hcd);
> > > > +   int ret = 0;
> > > > +
> > > > +   if (xhci->xhc_state)
> > > > +   return -ESHUTDOWN;
> > > > +
> > > > +   if (device_may_wakeup(dev)) {
> > > > +   ret = check_bus_status(xhci);
> > > > +   if (!ret)
> > > > +   ret = xh

[PATCH v2 2/5] dt-bindings: usb: mtk-xhci: add wakeup interrupt

2021-04-09 Thread Chunfeng Yun
Add an interrupt which is EINT usually to support runtime PM,
meanwhile add "interrupt-names" property, for backward
compatibility, it's optional and used when wakeup interrupt
exists

Reviewed-by: Rob Herring 
Signed-off-by: Chunfeng Yun 
---
v2: add Reviewed-by Rob
---
 .../devicetree/bindings/usb/mediatek,mtk-xhci.yaml  | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml 
b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
index 45bf4ea00c9e..4fe8a301d03f 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
@@ -46,7 +46,18 @@ properties:
   - const: ippc  # optional, only needed for case 1.
 
   interrupts:
-maxItems: 1
+description:
+  use "interrupts-extended" when the interrupts are connected to the
+  separate interrupt controllers
+minItems: 1
+items:
+  - description: xHCI host controller interrupt
+  - description: optional, wakeup interrupt used to support runtime PM
+
+  interrupt-names:
+items:
+  - const: host
+  - const: wakeup
 
   power-domains:
 description: A phandle to USB power domain node to control USB's MTCMOS
-- 
2.18.0



[PATCH v2 3/5] usb: xhci-mtk: add support runtime PM

2021-04-09 Thread Chunfeng Yun
A dedicated wakeup irq will be used to handle runtime suspend/resume,
we use dev_pm_set_dedicated_wake_irq API to take care of requesting
and attaching wakeup irq, then the suspend/resume framework will help
to enable/disable wakeup irq.

The runtime PM is default off since some platforms may not support it.
users can enable it via power/control (set "auto") in sysfs.

Signed-off-by: Chunfeng Yun 
---
v2: no changes, but abandon dependent patch [1], use falling edge type
interrupt

[1]
[1/6] PM: runtime: enable wake irq after runtime_suspend hook called

https://patchwork.kernel.org/project/linux-mediatek/patch/1617874514-12282-1-git-send-email-chunfeng@mediatek.com/
---
 drivers/usb/host/xhci-mtk.c | 140 +++-
 1 file changed, 124 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index a74764ab914a..30927f4064d4 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -358,7 +359,6 @@ static int usb_wakeup_of_property_parse(struct xhci_hcd_mtk 
*mtk,
mtk->uwk_reg_base, mtk->uwk_vers);
 
return PTR_ERR_OR_ZERO(mtk->uwk);
-
 }
 
 static void usb_wakeup_set(struct xhci_hcd_mtk *mtk, bool enable)
@@ -458,6 +458,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
struct resource *res;
struct usb_hcd *hcd;
int ret = -ENODEV;
+   int wakeup_irq;
int irq;
 
if (usb_disabled())
@@ -485,6 +486,21 @@ static int xhci_mtk_probe(struct platform_device *pdev)
if (ret)
return ret;
 
+   irq = platform_get_irq_byname_optional(pdev, "host");
+   if (irq < 0) {
+   if (irq == -EPROBE_DEFER)
+   return irq;
+
+   /* for backward compatibility */
+   irq = platform_get_irq(pdev, 0);
+   if (irq < 0)
+   return irq;
+   }
+
+   wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");
+   if (wakeup_irq == -EPROBE_DEFER)
+   return wakeup_irq;
+
mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable");
/* optional property, ignore the error if it does not exist */
of_property_read_u32(node, "mediatek,u3p-dis-msk",
@@ -496,9 +512,11 @@ static int xhci_mtk_probe(struct platform_device *pdev)
return ret;
}
 
+   pm_runtime_set_active(dev);
+   pm_runtime_use_autosuspend(dev);
+   pm_runtime_set_autosuspend_delay(dev, 4000);
pm_runtime_enable(dev);
pm_runtime_get_sync(dev);
-   device_enable_async_suspend(dev);
 
ret = xhci_mtk_ldos_enable(mtk);
if (ret)
@@ -508,12 +526,6 @@ static int xhci_mtk_probe(struct platform_device *pdev)
if (ret)
goto disable_ldos;
 
-   irq = platform_get_irq(pdev, 0);
-   if (irq < 0) {
-   ret = irq;
-   goto disable_clk;
-   }
-
hcd = usb_create_hcd(driver, dev, dev_name(dev));
if (!hcd) {
ret = -ENOMEM;
@@ -579,8 +591,26 @@ static int xhci_mtk_probe(struct platform_device *pdev)
if (ret)
goto dealloc_usb2_hcd;
 
+   if (wakeup_irq > 0) {
+   ret = dev_pm_set_dedicated_wake_irq(dev, wakeup_irq);
+   if (ret) {
+   dev_err(dev, "set wakeup irq %d failed\n", wakeup_irq);
+   goto dealloc_usb3_hcd;
+   }
+   dev_info(dev, "wakeup irq %d\n", wakeup_irq);
+   }
+
+   device_enable_async_suspend(dev);
+   pm_runtime_mark_last_busy(dev);
+   pm_runtime_put_autosuspend(dev);
+   pm_runtime_forbid(dev);
+
return 0;
 
+dealloc_usb3_hcd:
+   usb_remove_hcd(xhci->shared_hcd);
+   xhci->shared_hcd = NULL;
+
 dealloc_usb2_hcd:
usb_remove_hcd(hcd);
 
@@ -601,25 +631,26 @@ static int xhci_mtk_probe(struct platform_device *pdev)
xhci_mtk_ldos_disable(mtk);
 
 disable_pm:
-   pm_runtime_put_sync(dev);
+   pm_runtime_put_sync_autosuspend(dev);
pm_runtime_disable(dev);
return ret;
 }
 
-static int xhci_mtk_remove(struct platform_device *dev)
+static int xhci_mtk_remove(struct platform_device *pdev)
 {
-   struct xhci_hcd_mtk *mtk = platform_get_drvdata(dev);
+   struct xhci_hcd_mtk *mtk = platform_get_drvdata(pdev);
struct usb_hcd  *hcd = mtk->hcd;
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
struct usb_hcd  *shared_hcd = xhci->shared_hcd;
+   struct device *dev = >dev;
 
-   pm_runtime_put_noidle(>dev);
-   pm_runtime_disable(>dev);
+   pm_runtime_get_sync(dev);
+   xhci->xhc_state |= XHCI_STATE_REMOVING;
+   dev_pm_clear_wake_i

[PATCH v2 4/5] usb: xhci-mtk: use clock bulk to get clocks

2021-04-09 Thread Chunfeng Yun
Use clock bulk helpers to get/enable/disable clocks, meanwhile
make sys_ck optional, then will be easier to handle clocks.

Signed-off-by: Chunfeng Yun 
---
v2: no changes
---
 drivers/usb/host/xhci-mtk.c | 109 +++-
 drivers/usb/host/xhci-mtk.h |  10 ++--
 2 files changed, 24 insertions(+), 95 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 30927f4064d4..d4c455eecb8d 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -7,7 +7,6 @@
  *  Chunfeng Yun 
  */
 
-#include 
 #include 
 #include 
 #include 
@@ -220,89 +219,6 @@ static int xhci_mtk_ssusb_config(struct xhci_hcd_mtk *mtk)
return xhci_mtk_host_enable(mtk);
 }
 
-static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk)
-{
-   struct device *dev = mtk->dev;
-
-   mtk->sys_clk = devm_clk_get(dev, "sys_ck");
-   if (IS_ERR(mtk->sys_clk)) {
-   dev_err(dev, "fail to get sys_ck\n");
-   return PTR_ERR(mtk->sys_clk);
-   }
-
-   mtk->xhci_clk = devm_clk_get_optional(dev, "xhci_ck");
-   if (IS_ERR(mtk->xhci_clk))
-   return PTR_ERR(mtk->xhci_clk);
-
-   mtk->ref_clk = devm_clk_get_optional(dev, "ref_ck");
-   if (IS_ERR(mtk->ref_clk))
-   return PTR_ERR(mtk->ref_clk);
-
-   mtk->mcu_clk = devm_clk_get_optional(dev, "mcu_ck");
-   if (IS_ERR(mtk->mcu_clk))
-   return PTR_ERR(mtk->mcu_clk);
-
-   mtk->dma_clk = devm_clk_get_optional(dev, "dma_ck");
-   return PTR_ERR_OR_ZERO(mtk->dma_clk);
-}
-
-static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk)
-{
-   int ret;
-
-   ret = clk_prepare_enable(mtk->ref_clk);
-   if (ret) {
-   dev_err(mtk->dev, "failed to enable ref_clk\n");
-   goto ref_clk_err;
-   }
-
-   ret = clk_prepare_enable(mtk->sys_clk);
-   if (ret) {
-   dev_err(mtk->dev, "failed to enable sys_clk\n");
-   goto sys_clk_err;
-   }
-
-   ret = clk_prepare_enable(mtk->xhci_clk);
-   if (ret) {
-   dev_err(mtk->dev, "failed to enable xhci_clk\n");
-   goto xhci_clk_err;
-   }
-
-   ret = clk_prepare_enable(mtk->mcu_clk);
-   if (ret) {
-   dev_err(mtk->dev, "failed to enable mcu_clk\n");
-   goto mcu_clk_err;
-   }
-
-   ret = clk_prepare_enable(mtk->dma_clk);
-   if (ret) {
-   dev_err(mtk->dev, "failed to enable dma_clk\n");
-   goto dma_clk_err;
-   }
-
-   return 0;
-
-dma_clk_err:
-   clk_disable_unprepare(mtk->mcu_clk);
-mcu_clk_err:
-   clk_disable_unprepare(mtk->xhci_clk);
-xhci_clk_err:
-   clk_disable_unprepare(mtk->sys_clk);
-sys_clk_err:
-   clk_disable_unprepare(mtk->ref_clk);
-ref_clk_err:
-   return ret;
-}
-
-static void xhci_mtk_clks_disable(struct xhci_hcd_mtk *mtk)
-{
-   clk_disable_unprepare(mtk->dma_clk);
-   clk_disable_unprepare(mtk->mcu_clk);
-   clk_disable_unprepare(mtk->xhci_clk);
-   clk_disable_unprepare(mtk->sys_clk);
-   clk_disable_unprepare(mtk->ref_clk);
-}
-
 /* only clocks can be turn off for ip-sleep wakeup mode */
 static void usb_wakeup_ip_sleep_set(struct xhci_hcd_mtk *mtk, bool enable)
 {
@@ -367,6 +283,19 @@ static void usb_wakeup_set(struct xhci_hcd_mtk *mtk, bool 
enable)
usb_wakeup_ip_sleep_set(mtk, enable);
 }
 
+static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk)
+{
+   struct clk_bulk_data *clks = mtk->clks;
+
+   clks[0].id = "sys_ck";
+   clks[1].id = "xhci_ck";
+   clks[2].id = "ref_ck";
+   clks[3].id = "mcu_ck";
+   clks[4].id = "dma_ck";
+
+   return devm_clk_bulk_get_optional(mtk->dev, BULK_CLKS_NUM, clks);
+}
+
 static int xhci_mtk_ldos_enable(struct xhci_hcd_mtk *mtk)
 {
int ret;
@@ -522,7 +451,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
if (ret)
goto disable_pm;
 
-   ret = xhci_mtk_clks_enable(mtk);
+   ret = clk_bulk_prepare_enable(BULK_CLKS_NUM, mtk->clks);
if (ret)
goto disable_ldos;
 
@@ -625,7 +554,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
usb_put_hcd(hcd);
 
 disable_clk:
-   xhci_mtk_clks_disable(mtk);
+   clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks);
 
 disable_ldos:
xhci_mtk_ldos_disable(mtk);
@@ -655,7 +584,7 @@ static int xhci_mtk_remove(struct platform_device *pdev)
usb_put_hcd(shared_hcd);
usb_put_hcd(hcd);
xhci_mtk_sch_exit(mtk);
-   xhci_mtk_clks_disable(mtk);
+   clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks);
xhci_mtk_ldos_disable(

[PATCH v2 1/5] usb: xhci-mtk: check return value in suspend/resume hooks

2021-04-09 Thread Chunfeng Yun
Return error number if encounter errors during suspend and resume.

Signed-off-by: Chunfeng Yun 
---
v2: no changes
---
 drivers/usb/host/xhci-mtk.c | 37 +++--
 1 file changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index c1bc40289833..a74764ab914a 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -630,18 +630,12 @@ static int xhci_mtk_remove(struct platform_device *dev)
return 0;
 }
 
-/*
- * if ip sleep fails, and all clocks are disabled, access register will hang
- * AHB bus, so stop polling roothubs to avoid regs access on bus suspend.
- * and no need to check whether ip sleep failed or not; this will cause SPM
- * to wake up system immediately after system suspend complete if ip sleep
- * fails, it is what we wanted.
- */
 static int __maybe_unused xhci_mtk_suspend(struct device *dev)
 {
struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev);
struct usb_hcd *hcd = mtk->hcd;
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+   int ret;
 
xhci_dbg(xhci, "%s: stop port polling\n", __func__);
clear_bit(HCD_FLAG_POLL_RH, >flags);
@@ -649,10 +643,21 @@ static int __maybe_unused xhci_mtk_suspend(struct device 
*dev)
clear_bit(HCD_FLAG_POLL_RH, >shared_hcd->flags);
del_timer_sync(>shared_hcd->rh_timer);
 
-   xhci_mtk_host_disable(mtk);
+   ret = xhci_mtk_host_disable(mtk);
+   if (ret)
+   goto restart_poll_rh;
+
xhci_mtk_clks_disable(mtk);
usb_wakeup_set(mtk, true);
return 0;
+
+restart_poll_rh:
+   xhci_dbg(xhci, "%s: restart port polling\n", __func__);
+   set_bit(HCD_FLAG_POLL_RH, >shared_hcd->flags);
+   usb_hcd_poll_rh_status(xhci->shared_hcd);
+   set_bit(HCD_FLAG_POLL_RH, >flags);
+   usb_hcd_poll_rh_status(hcd);
+   return ret;
 }
 
 static int __maybe_unused xhci_mtk_resume(struct device *dev)
@@ -660,10 +665,16 @@ static int __maybe_unused xhci_mtk_resume(struct device 
*dev)
struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev);
struct usb_hcd *hcd = mtk->hcd;
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+   int ret;
 
usb_wakeup_set(mtk, false);
-   xhci_mtk_clks_enable(mtk);
-   xhci_mtk_host_enable(mtk);
+   ret = xhci_mtk_clks_enable(mtk);
+   if (ret)
+   goto enable_wakeup;
+
+   ret = xhci_mtk_host_enable(mtk);
+   if (ret)
+   goto disable_clks;
 
xhci_dbg(xhci, "%s: restart port polling\n", __func__);
set_bit(HCD_FLAG_POLL_RH, >shared_hcd->flags);
@@ -671,6 +682,12 @@ static int __maybe_unused xhci_mtk_resume(struct device 
*dev)
set_bit(HCD_FLAG_POLL_RH, >flags);
usb_hcd_poll_rh_status(hcd);
return 0;
+
+disable_clks:
+   xhci_mtk_clks_disable(mtk);
+enable_wakeup:
+   usb_wakeup_set(mtk, true);
+   return ret;
 }
 
 static const struct dev_pm_ops xhci_mtk_pm_ops = {
-- 
2.18.0



[PATCH v2 5/5] usb: xhci-mtk: remove unused members

2021-04-09 Thread Chunfeng Yun
Now some members about phys and wakeup are not used anymore,
remove them.

Signed-off-by: Chunfeng Yun 
---
v2: no changes
---
 drivers/usb/host/xhci-mtk.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
index 11996edc1967..7940593a3445 100644
--- a/drivers/usb/host/xhci-mtk.h
+++ b/drivers/usb/host/xhci-mtk.h
@@ -145,9 +145,6 @@ struct xhci_hcd_mtk {
struct regulator *vusb33;
struct regulator *vbus;
struct clk_bulk_data clks[BULK_CLKS_NUM];
-   struct regmap *pericfg;
-   struct phy **phys;
-   int num_phys;
bool lpm_support;
/* usb remote wakeup */
bool uwk_en;
-- 
2.18.0



Re: [PATCH 1/6] PM: runtime: enable wake irq after runtime_suspend hook called

2021-04-09 Thread Chunfeng Yun
On Fri, 2021-04-09 at 13:14 +0200, Rafael J. Wysocki wrote:
> On Fri, Apr 9, 2021 at 10:36 AM Chunfeng Yun  
> wrote:
> >
> > On Fri, 2021-04-09 at 08:39 +0300, Tony Lindgren wrote:
> > > * Chunfeng Yun  [210409 01:54]:
> > > > On Thu, 2021-04-08 at 19:41 +0200, Rafael J. Wysocki wrote:
> > > > > On Thu, Apr 8, 2021 at 11:35 AM Chunfeng Yun 
> > > > >  wrote:
> > > > > >
> > > > > > When the dedicated wake irq is level trigger, enable it before
> > > > > > calling runtime_suspend, will trigger an interrupt.
> > > > > >
> > > > > > e.g.
> > > > > > for a low level trigger type, it's low level at running time (0),
> > > > > > and becomes high level when enters suspend (runtime_suspend (1) is
> > > > > > called), a wakeup signal at (2) make it become low level, wake irq
> > > > > > will be triggered.
> > > > > >
> > > > > > --
> > > > > >|   ^ ^|
> > > > > >    | | --
> > > > > >  |<---(0)--->|<--(1)--|   (3)   (2)(4)
> > > > > >
> > > > > > if we enable the wake irq before calling runtime_suspend during (0),
> > > > > > an interrupt will arise, it causes resume immediately;
> > > > >
> > > > > But that's necessary to avoid missing a wakeup interrupt, isn't it?
> > > > That's also what I worry about.
> > >
> > > Yeah sounds like this patch will lead into missed wakeirqs.
> > If miss level trigger wakeirqs, that means HW doesn't latch it? is it HW
> > limitation?
> 
> If it's level-triggered, it won't be missed, but then it is just
> pointless to suspend the device when wakeup is being signaled in the
> first place.
Got it
> 
> I'm not sure if I understand the underlying problem correctly.  Is it
> about addressing spurious wakeups?
In fact, it's default value is the same as the wakeup signal, maybe the
above case, using level trigger, should be avoided, it is not clear and
causes confusion, as Ikjoon and Tony suggested, using falling edge type
is better.

Thanks a lot





[PATCH v2] usb: core: reduce power-on-good delay time of root hub

2021-04-09 Thread Chunfeng Yun
Return the exactly delay time given by root hub descriptor,
this helps to reduce resume time etc.

Due to the root hub descriptor is usually provided by the host
controller driver, if there is compatibility for a root hub,
we can fix it easily without affect other root hub

Acked-by: Alan Stern 
Signed-off-by: Chunfeng Yun 
---
v2: remove RFC tag, and add acked-by Alan
---
 drivers/usb/core/hub.h | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 73f4482d833a..22ea1f4f2d66 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -148,8 +148,10 @@ static inline unsigned hub_power_on_good_delay(struct 
usb_hub *hub)
 {
unsigned delay = hub->descriptor->bPwrOn2PwrGood * 2;
 
-   /* Wait at least 100 msec for power to become stable */
-   return max(delay, 100U);
+   if (!hub->hdev->parent) /* root hub */
+   return delay;
+   else /* Wait at least 100 msec for power to become stable */
+   return max(delay, 100U);
 }
 
 static inline int hub_port_debounce_be_connected(struct usb_hub *hub,
-- 
2.18.0



Re: [PATCH 4/6] usb: xhci-mtk: add support runtime PM

2021-04-09 Thread Chunfeng Yun
On Fri, 2021-04-09 at 13:45 +0800, Ikjoon Jang wrote:
> On Thu, Apr 8, 2021 at 5:35 PM Chunfeng Yun  wrote:
> >
> > A dedicated wakeup irq will be used to handle runtime suspend/resume,
> > we use dev_pm_set_dedicated_wake_irq API to take care of requesting
> > and attaching wakeup irq, then the suspend/resume framework will help
> > to enable/disable wakeup irq.
> >
> > The runtime PM is default off since some platforms may not support it.
> > users can enable it via power/control (set "auto") in sysfs.
> >
> > Signed-off-by: Chunfeng Yun 
> > ---
> >  drivers/usb/host/xhci-mtk.c | 140 +++-
> >  1 file changed, 124 insertions(+), 16 deletions(-)
> >
> > diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
> > index a74764ab914a..30927f4064d4 100644
> > --- a/drivers/usb/host/xhci-mtk.c
> > +++ b/drivers/usb/host/xhci-mtk.c
> > @@ -16,6 +16,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >
> > @@ -358,7 +359,6 @@ static int usb_wakeup_of_property_parse(struct 
> > xhci_hcd_mtk *mtk,
> > mtk->uwk_reg_base, mtk->uwk_vers);
> >
> > return PTR_ERR_OR_ZERO(mtk->uwk);
> > -
> >  }
> >
> >  static void usb_wakeup_set(struct xhci_hcd_mtk *mtk, bool enable)
> > @@ -458,6 +458,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
> > struct resource *res;
> > struct usb_hcd *hcd;
> > int ret = -ENODEV;
> > +   int wakeup_irq;
> > int irq;
> >
> > if (usb_disabled())
> > @@ -485,6 +486,21 @@ static int xhci_mtk_probe(struct platform_device *pdev)
> > if (ret)
> > return ret;
> >
> > +   irq = platform_get_irq_byname_optional(pdev, "host");
> > +   if (irq < 0) {
> > +   if (irq == -EPROBE_DEFER)
> > +   return irq;
> > +
> > +   /* for backward compatibility */
> > +   irq = platform_get_irq(pdev, 0);
> > +   if (irq < 0)
> > +   return irq;
> > +   }
> > +
> > +   wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");
> > +   if (wakeup_irq == -EPROBE_DEFER)
> > +   return wakeup_irq;
> > +
> > mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable");
> > /* optional property, ignore the error if it does not exist */
> > of_property_read_u32(node, "mediatek,u3p-dis-msk",
> > @@ -496,9 +512,11 @@ static int xhci_mtk_probe(struct platform_device *pdev)
> > return ret;
> > }
> >
> > +   pm_runtime_set_active(dev);
> > +   pm_runtime_use_autosuspend(dev);
> > +   pm_runtime_set_autosuspend_delay(dev, 4000);
> > pm_runtime_enable(dev);
> > pm_runtime_get_sync(dev);
> > -   device_enable_async_suspend(dev);
> >
> > ret = xhci_mtk_ldos_enable(mtk);
> > if (ret)
> > @@ -508,12 +526,6 @@ static int xhci_mtk_probe(struct platform_device *pdev)
> > if (ret)
> > goto disable_ldos;
> >
> > -   irq = platform_get_irq(pdev, 0);
> > -   if (irq < 0) {
> > -   ret = irq;
> > -   goto disable_clk;
> > -   }
> > -
> > hcd = usb_create_hcd(driver, dev, dev_name(dev));
> > if (!hcd) {
> > ret = -ENOMEM;
> > @@ -579,8 +591,26 @@ static int xhci_mtk_probe(struct platform_device *pdev)
> > if (ret)
> > goto dealloc_usb2_hcd;
> >
> > +   if (wakeup_irq > 0) {
> > +   ret = dev_pm_set_dedicated_wake_irq(dev, wakeup_irq);
> > +   if (ret) {
> > +   dev_err(dev, "set wakeup irq %d failed\n", 
> > wakeup_irq);
> > +   goto dealloc_usb3_hcd;
> > +   }
> > +   dev_info(dev, "wakeup irq %d\n", wakeup_irq);
> > +   }
> > +
> > +   device_enable_async_suspend(dev);
> > +   pm_runtime_mark_last_busy(dev);
> > +   pm_runtime_put_autosuspend(dev);
> > +   pm_runtime_forbid(dev);
> > +
> > return 0;
> >
> > +dealloc_usb3_hcd:
> > +   usb_remove_hcd(xhci->shared_hcd);
> > +   xhci->shared_hcd = NULL;
&

Re: [PATCH 1/6] PM: runtime: enable wake irq after runtime_suspend hook called

2021-04-09 Thread Chunfeng Yun
On Fri, 2021-04-09 at 13:32 +0800, Ikjoon Jang wrote:
> Hi Chunfeng,
> 
> On Thu, Apr 8, 2021 at 5:35 PM Chunfeng Yun  wrote:
> >
> > When the dedicated wake irq is level trigger, enable it before
> > calling runtime_suspend, will trigger an interrupt.
> >
> > e.g.
> > for a low level trigger type, it's low level at running time (0),
> > and becomes high level when enters suspend (runtime_suspend (1) is
> > called), a wakeup signal at (2) make it become low level, wake irq
> > will be triggered.
> >
> > --
> >|   ^ ^|
> >    | | --
> >  |<---(0)--->|<--(1)--|   (3)   (2)(4)
> >
> 
> Can't we just use a falling edge type for this irq line?
I'll try it, but the original code still doesn't process above mentioned
case.

> 
> > if we enable the wake irq before calling runtime_suspend during (0),
> > an interrupt will arise, it causes resume immediately;
> > enable wake irq after calling runtime_suspend, e.g. at (3) or (4),
> > will works.
> >
> > This patch seems no side effect on edge trigger wake irq.
> >
> > Signed-off-by: Chunfeng Yun 
> > ---
> >  drivers/base/power/runtime.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
> > index a46a7e30881b..796739a015a5 100644
> > --- a/drivers/base/power/runtime.c
> > +++ b/drivers/base/power/runtime.c
> > @@ -619,12 +619,12 @@ static int rpm_suspend(struct device *dev, int 
> > rpmflags)
> > __update_runtime_status(dev, RPM_SUSPENDING);
> >
> > callback = RPM_GET_CALLBACK(dev, runtime_suspend);
> > -
> > -   dev_pm_enable_wake_irq_check(dev, true);
> > retval = rpm_callback(callback, dev);
> > if (retval)
> > goto fail;
> >
> > +   dev_pm_enable_wake_irq_check(dev, true);
> > +
> >   no_callback:
> > __update_runtime_status(dev, RPM_SUSPENDED);
> > pm_runtime_deactivate_timer(dev);
> > @@ -659,7 +659,6 @@ static int rpm_suspend(struct device *dev, int rpmflags)
> > return retval;
> >
> >   fail:
> > -   dev_pm_disable_wake_irq_check(dev);
> > __update_runtime_status(dev, RPM_ACTIVE);
> > dev->power.deferred_resume = false;
> > wake_up_all(>power.wait_queue);
> > --
> > 2.18.0
> >



Re: [PATCH 1/6] PM: runtime: enable wake irq after runtime_suspend hook called

2021-04-09 Thread Chunfeng Yun
On Fri, 2021-04-09 at 08:39 +0300, Tony Lindgren wrote:
> * Chunfeng Yun  [210409 01:54]:
> > On Thu, 2021-04-08 at 19:41 +0200, Rafael J. Wysocki wrote:
> > > On Thu, Apr 8, 2021 at 11:35 AM Chunfeng Yun  
> > > wrote:
> > > >
> > > > When the dedicated wake irq is level trigger, enable it before
> > > > calling runtime_suspend, will trigger an interrupt.
> > > >
> > > > e.g.
> > > > for a low level trigger type, it's low level at running time (0),
> > > > and becomes high level when enters suspend (runtime_suspend (1) is
> > > > called), a wakeup signal at (2) make it become low level, wake irq
> > > > will be triggered.
> > > >
> > > > --
> > > >|   ^ ^|
> > > >    | | --
> > > >  |<---(0)--->|<--(1)--|   (3)   (2)(4)
> > > >
> > > > if we enable the wake irq before calling runtime_suspend during (0),
> > > > an interrupt will arise, it causes resume immediately;
> > > 
> > > But that's necessary to avoid missing a wakeup interrupt, isn't it?
> > That's also what I worry about.
> 
> Yeah sounds like this patch will lead into missed wakeirqs.
If miss level trigger wakeirqs, that means HW doesn't latch it? is it HW
limitation?
> 
> Regards,
> 
> Tony



[PATCH] phy: qcom-qmp: remove redundant error of clock bulk

2021-04-08 Thread Chunfeng Yun
There is error log in clk_bulk_prepare/enable()

Signed-off-by: Chunfeng Yun 
---
 drivers/phy/qualcomm/phy-qcom-qmp.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c 
b/drivers/phy/qualcomm/phy-qcom-qmp.c
index 9cdebe7..f14b8be 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp.c
@@ -3598,10 +3598,8 @@ static int qcom_qmp_phy_com_init(struct qmp_phy *qphy)
}
 
ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks);
-   if (ret) {
-   dev_err(qmp->dev, "failed to enable clks, err=%d\n", ret);
+   if (ret)
goto err_rst;
-   }
 
if (cfg->has_phy_dp_com_ctrl) {
qphy_setbits(dp_com, QPHY_V3_DP_COM_POWER_DOWN_CTRL,
@@ -4035,10 +4033,8 @@ static int __maybe_unused 
qcom_qmp_phy_runtime_resume(struct device *dev)
}
 
ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks);
-   if (ret) {
-   dev_err(qmp->dev, "failed to enable clks, err=%d\n", ret);
+   if (ret)
return ret;
-   }
 
ret = clk_prepare_enable(qphy->pipe_clk);
if (ret) {
-- 
1.8.1.1.dirty



[PATCH] irqchip: gic-pm: remove redundant error log of clock bulk

2021-04-08 Thread Chunfeng Yun
There is error log in clk_bulk_prepare/enable()

Signed-off-by: Chunfeng Yun 
---
 drivers/irqchip/irq-gic-pm.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-gic-pm.c b/drivers/irqchip/irq-gic-pm.c
index 1337cec..b60e185 100644
--- a/drivers/irqchip/irq-gic-pm.c
+++ b/drivers/irqchip/irq-gic-pm.c
@@ -30,10 +30,8 @@ static int gic_runtime_resume(struct device *dev)
int ret;
 
ret = clk_bulk_prepare_enable(data->num_clocks, chip_pm->clks);
-   if (ret) {
-   dev_err(dev, "clk_enable failed: %d\n", ret);
+   if (ret)
return ret;
-   }
 
/*
 * On the very first resume, the pointer to chip_pm->chip_data
-- 
1.8.1.1.dirty



[RFC PATCH] usb: core: reduce power-on-good delay time of root hub

2021-04-08 Thread Chunfeng Yun
Return the exactly delay time given by root hub descriptor,
this helps to reduce resume time etc.

Due to the root hub descriptor is usually provided by the host
controller driver, if there is compatibility for a root hub,
we can fix it easily without affect other root hub

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/core/hub.h | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 73f4482d833a..22ea1f4f2d66 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -148,8 +148,10 @@ static inline unsigned hub_power_on_good_delay(struct 
usb_hub *hub)
 {
unsigned delay = hub->descriptor->bPwrOn2PwrGood * 2;
 
-   /* Wait at least 100 msec for power to become stable */
-   return max(delay, 100U);
+   if (!hub->hdev->parent) /* root hub */
+   return delay;
+   else /* Wait at least 100 msec for power to become stable */
+   return max(delay, 100U);
 }
 
 static inline int hub_port_debounce_be_connected(struct usb_hub *hub,
-- 
2.18.0



Re: [PATCH 1/6] PM: runtime: enable wake irq after runtime_suspend hook called

2021-04-08 Thread Chunfeng Yun
On Thu, 2021-04-08 at 19:41 +0200, Rafael J. Wysocki wrote:
> On Thu, Apr 8, 2021 at 11:35 AM Chunfeng Yun  
> wrote:
> >
> > When the dedicated wake irq is level trigger, enable it before
> > calling runtime_suspend, will trigger an interrupt.
> >
> > e.g.
> > for a low level trigger type, it's low level at running time (0),
> > and becomes high level when enters suspend (runtime_suspend (1) is
> > called), a wakeup signal at (2) make it become low level, wake irq
> > will be triggered.
> >
> > --
> >|   ^ ^|
> >    | | --
> >  |<---(0)--->|<--(1)--|   (3)   (2)(4)
> >
> > if we enable the wake irq before calling runtime_suspend during (0),
> > an interrupt will arise, it causes resume immediately;
> 
> But that's necessary to avoid missing a wakeup interrupt, isn't it?
That's also what I worry about.
It may happen if the trigger level only keeps a very short time, and the
interrupt controller can't process it timely, but I don't think it
follow the level trigger mechanism, the HW should latch it until the ISR
is called. right?

> 
> > enable wake irq after calling runtime_suspend, e.g. at (3) or (4),
> > will works.
> >
> > This patch seems no side effect on edge trigger wake irq.
> >
> > Signed-off-by: Chunfeng Yun 
> > ---
> >  drivers/base/power/runtime.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
> > index a46a7e30881b..796739a015a5 100644
> > --- a/drivers/base/power/runtime.c
> > +++ b/drivers/base/power/runtime.c
> > @@ -619,12 +619,12 @@ static int rpm_suspend(struct device *dev, int 
> > rpmflags)
> > __update_runtime_status(dev, RPM_SUSPENDING);
> >
> > callback = RPM_GET_CALLBACK(dev, runtime_suspend);
> > -
> > -   dev_pm_enable_wake_irq_check(dev, true);
> > retval = rpm_callback(callback, dev);
> > if (retval)
> > goto fail;
> >
> > +   dev_pm_enable_wake_irq_check(dev, true);
> > +
> >   no_callback:
> > __update_runtime_status(dev, RPM_SUSPENDED);
> > pm_runtime_deactivate_timer(dev);
> > @@ -659,7 +659,6 @@ static int rpm_suspend(struct device *dev, int rpmflags)
> > return retval;
> >
> >   fail:
> > -   dev_pm_disable_wake_irq_check(dev);
> > __update_runtime_status(dev, RPM_ACTIVE);
> > dev->power.deferred_resume = false;
> > wake_up_all(>power.wait_queue);
> > --
> > 2.18.0
> >



Re: [PATCH v2 -next] phy: phy-mtk-hdmi: Remove redundant dev_err call in mtk_hdmi_phy_probe()

2021-04-08 Thread Chunfeng Yun
On Thu, 2021-04-08 at 07:55 -0400, He Ying wrote:
> There is a error message within devm_ioremap_resource
> already, so remove the dev_err call to avoid redundant
> error message.
> 
> Reported-by: Hulk Robot 
> Signed-off-by: He Ying 
> ---
> v2:
> - Use 'return PTR_ERR()' instead of 'ret = PTR_ERR();return ret;'.
> 
>  drivers/phy/mediatek/phy-mtk-hdmi.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/phy/mediatek/phy-mtk-hdmi.c 
> b/drivers/phy/mediatek/phy-mtk-hdmi.c
> index 8313bd517e4c..8ad8f717ef43 100644
> --- a/drivers/phy/mediatek/phy-mtk-hdmi.c
> +++ b/drivers/phy/mediatek/phy-mtk-hdmi.c
> @@ -119,9 +119,7 @@ static int mtk_hdmi_phy_probe(struct platform_device 
> *pdev)
>   mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>   hdmi_phy->regs = devm_ioremap_resource(dev, mem);
>   if (IS_ERR(hdmi_phy->regs)) {
> - ret = PTR_ERR(hdmi_phy->regs);
> - dev_err(dev, "Failed to get memory resource: %d\n", ret);
> -         return ret;
> + return PTR_ERR(hdmi_phy->regs);
>   }
Reviewed-by: Chunfeng Yun 

Thanks a lot
>  
>   ref_clk = devm_clk_get(dev, "pll_ref");



Re: [PATCH 4/6] usb: xhci-mtk: add support runtime PM

2021-04-08 Thread Chunfeng Yun
Hi Ikjoon,

On Thu, 2021-04-08 at 17:35 +0800, Chunfeng Yun wrote:
> A dedicated wakeup irq will be used to handle runtime suspend/resume,
> we use dev_pm_set_dedicated_wake_irq API to take care of requesting
> and attaching wakeup irq, then the suspend/resume framework will help
> to enable/disable wakeup irq.
> 
> The runtime PM is default off since some platforms may not support it.
> users can enable it via power/control (set "auto") in sysfs.
> 
> Signed-off-by: Chunfeng Yun 
> ---
>  drivers/usb/host/xhci-mtk.c | 140 +++-
>  1 file changed, 124 insertions(+), 16 deletions(-)

Please help to test the series on mt8192 chromebook, thanks a lot



[PATCH 5/6] usb: xhci-mtk: use clock bulk to get clocks

2021-04-08 Thread Chunfeng Yun
Use clock bulk helpers to get/enable/disable clocks, meanwhile
make sys_ck optional, then will be easier to handle clocks.

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mtk.c | 109 +++-
 drivers/usb/host/xhci-mtk.h |  10 ++--
 2 files changed, 24 insertions(+), 95 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 30927f4064d4..d4c455eecb8d 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -7,7 +7,6 @@
  *  Chunfeng Yun 
  */
 
-#include 
 #include 
 #include 
 #include 
@@ -220,89 +219,6 @@ static int xhci_mtk_ssusb_config(struct xhci_hcd_mtk *mtk)
return xhci_mtk_host_enable(mtk);
 }
 
-static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk)
-{
-   struct device *dev = mtk->dev;
-
-   mtk->sys_clk = devm_clk_get(dev, "sys_ck");
-   if (IS_ERR(mtk->sys_clk)) {
-   dev_err(dev, "fail to get sys_ck\n");
-   return PTR_ERR(mtk->sys_clk);
-   }
-
-   mtk->xhci_clk = devm_clk_get_optional(dev, "xhci_ck");
-   if (IS_ERR(mtk->xhci_clk))
-   return PTR_ERR(mtk->xhci_clk);
-
-   mtk->ref_clk = devm_clk_get_optional(dev, "ref_ck");
-   if (IS_ERR(mtk->ref_clk))
-   return PTR_ERR(mtk->ref_clk);
-
-   mtk->mcu_clk = devm_clk_get_optional(dev, "mcu_ck");
-   if (IS_ERR(mtk->mcu_clk))
-   return PTR_ERR(mtk->mcu_clk);
-
-   mtk->dma_clk = devm_clk_get_optional(dev, "dma_ck");
-   return PTR_ERR_OR_ZERO(mtk->dma_clk);
-}
-
-static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk)
-{
-   int ret;
-
-   ret = clk_prepare_enable(mtk->ref_clk);
-   if (ret) {
-   dev_err(mtk->dev, "failed to enable ref_clk\n");
-   goto ref_clk_err;
-   }
-
-   ret = clk_prepare_enable(mtk->sys_clk);
-   if (ret) {
-   dev_err(mtk->dev, "failed to enable sys_clk\n");
-   goto sys_clk_err;
-   }
-
-   ret = clk_prepare_enable(mtk->xhci_clk);
-   if (ret) {
-   dev_err(mtk->dev, "failed to enable xhci_clk\n");
-   goto xhci_clk_err;
-   }
-
-   ret = clk_prepare_enable(mtk->mcu_clk);
-   if (ret) {
-   dev_err(mtk->dev, "failed to enable mcu_clk\n");
-   goto mcu_clk_err;
-   }
-
-   ret = clk_prepare_enable(mtk->dma_clk);
-   if (ret) {
-   dev_err(mtk->dev, "failed to enable dma_clk\n");
-   goto dma_clk_err;
-   }
-
-   return 0;
-
-dma_clk_err:
-   clk_disable_unprepare(mtk->mcu_clk);
-mcu_clk_err:
-   clk_disable_unprepare(mtk->xhci_clk);
-xhci_clk_err:
-   clk_disable_unprepare(mtk->sys_clk);
-sys_clk_err:
-   clk_disable_unprepare(mtk->ref_clk);
-ref_clk_err:
-   return ret;
-}
-
-static void xhci_mtk_clks_disable(struct xhci_hcd_mtk *mtk)
-{
-   clk_disable_unprepare(mtk->dma_clk);
-   clk_disable_unprepare(mtk->mcu_clk);
-   clk_disable_unprepare(mtk->xhci_clk);
-   clk_disable_unprepare(mtk->sys_clk);
-   clk_disable_unprepare(mtk->ref_clk);
-}
-
 /* only clocks can be turn off for ip-sleep wakeup mode */
 static void usb_wakeup_ip_sleep_set(struct xhci_hcd_mtk *mtk, bool enable)
 {
@@ -367,6 +283,19 @@ static void usb_wakeup_set(struct xhci_hcd_mtk *mtk, bool 
enable)
usb_wakeup_ip_sleep_set(mtk, enable);
 }
 
+static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk)
+{
+   struct clk_bulk_data *clks = mtk->clks;
+
+   clks[0].id = "sys_ck";
+   clks[1].id = "xhci_ck";
+   clks[2].id = "ref_ck";
+   clks[3].id = "mcu_ck";
+   clks[4].id = "dma_ck";
+
+   return devm_clk_bulk_get_optional(mtk->dev, BULK_CLKS_NUM, clks);
+}
+
 static int xhci_mtk_ldos_enable(struct xhci_hcd_mtk *mtk)
 {
int ret;
@@ -522,7 +451,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
if (ret)
goto disable_pm;
 
-   ret = xhci_mtk_clks_enable(mtk);
+   ret = clk_bulk_prepare_enable(BULK_CLKS_NUM, mtk->clks);
if (ret)
goto disable_ldos;
 
@@ -625,7 +554,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
usb_put_hcd(hcd);
 
 disable_clk:
-   xhci_mtk_clks_disable(mtk);
+   clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks);
 
 disable_ldos:
xhci_mtk_ldos_disable(mtk);
@@ -655,7 +584,7 @@ static int xhci_mtk_remove(struct platform_device *pdev)
usb_put_hcd(shared_hcd);
usb_put_hcd(hcd);
xhci_mtk_sch_exit(mtk);
-   xhci_mtk_clks_disable(mtk);
+   clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks);
xhci_mtk_ldos_disable(mtk);
 
pm_runtime_di

[PATCH 6/6] usb: xhci-mtk: remove unused members

2021-04-08 Thread Chunfeng Yun
Now some members about phys and wakeup are not used anymore,
remove them.

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mtk.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
index 11996edc1967..7940593a3445 100644
--- a/drivers/usb/host/xhci-mtk.h
+++ b/drivers/usb/host/xhci-mtk.h
@@ -145,9 +145,6 @@ struct xhci_hcd_mtk {
struct regulator *vusb33;
struct regulator *vbus;
struct clk_bulk_data clks[BULK_CLKS_NUM];
-   struct regmap *pericfg;
-   struct phy **phys;
-   int num_phys;
bool lpm_support;
/* usb remote wakeup */
bool uwk_en;
-- 
2.18.0



[PATCH 4/6] usb: xhci-mtk: add support runtime PM

2021-04-08 Thread Chunfeng Yun
A dedicated wakeup irq will be used to handle runtime suspend/resume,
we use dev_pm_set_dedicated_wake_irq API to take care of requesting
and attaching wakeup irq, then the suspend/resume framework will help
to enable/disable wakeup irq.

The runtime PM is default off since some platforms may not support it.
users can enable it via power/control (set "auto") in sysfs.

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mtk.c | 140 +++-
 1 file changed, 124 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index a74764ab914a..30927f4064d4 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -358,7 +359,6 @@ static int usb_wakeup_of_property_parse(struct xhci_hcd_mtk 
*mtk,
mtk->uwk_reg_base, mtk->uwk_vers);
 
return PTR_ERR_OR_ZERO(mtk->uwk);
-
 }
 
 static void usb_wakeup_set(struct xhci_hcd_mtk *mtk, bool enable)
@@ -458,6 +458,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
struct resource *res;
struct usb_hcd *hcd;
int ret = -ENODEV;
+   int wakeup_irq;
int irq;
 
if (usb_disabled())
@@ -485,6 +486,21 @@ static int xhci_mtk_probe(struct platform_device *pdev)
if (ret)
return ret;
 
+   irq = platform_get_irq_byname_optional(pdev, "host");
+   if (irq < 0) {
+   if (irq == -EPROBE_DEFER)
+   return irq;
+
+   /* for backward compatibility */
+   irq = platform_get_irq(pdev, 0);
+   if (irq < 0)
+   return irq;
+   }
+
+   wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");
+   if (wakeup_irq == -EPROBE_DEFER)
+   return wakeup_irq;
+
mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable");
/* optional property, ignore the error if it does not exist */
of_property_read_u32(node, "mediatek,u3p-dis-msk",
@@ -496,9 +512,11 @@ static int xhci_mtk_probe(struct platform_device *pdev)
return ret;
}
 
+   pm_runtime_set_active(dev);
+   pm_runtime_use_autosuspend(dev);
+   pm_runtime_set_autosuspend_delay(dev, 4000);
pm_runtime_enable(dev);
pm_runtime_get_sync(dev);
-   device_enable_async_suspend(dev);
 
ret = xhci_mtk_ldos_enable(mtk);
if (ret)
@@ -508,12 +526,6 @@ static int xhci_mtk_probe(struct platform_device *pdev)
if (ret)
goto disable_ldos;
 
-   irq = platform_get_irq(pdev, 0);
-   if (irq < 0) {
-   ret = irq;
-   goto disable_clk;
-   }
-
hcd = usb_create_hcd(driver, dev, dev_name(dev));
if (!hcd) {
ret = -ENOMEM;
@@ -579,8 +591,26 @@ static int xhci_mtk_probe(struct platform_device *pdev)
if (ret)
goto dealloc_usb2_hcd;
 
+   if (wakeup_irq > 0) {
+   ret = dev_pm_set_dedicated_wake_irq(dev, wakeup_irq);
+   if (ret) {
+   dev_err(dev, "set wakeup irq %d failed\n", wakeup_irq);
+   goto dealloc_usb3_hcd;
+   }
+   dev_info(dev, "wakeup irq %d\n", wakeup_irq);
+   }
+
+   device_enable_async_suspend(dev);
+   pm_runtime_mark_last_busy(dev);
+   pm_runtime_put_autosuspend(dev);
+   pm_runtime_forbid(dev);
+
return 0;
 
+dealloc_usb3_hcd:
+   usb_remove_hcd(xhci->shared_hcd);
+   xhci->shared_hcd = NULL;
+
 dealloc_usb2_hcd:
usb_remove_hcd(hcd);
 
@@ -601,25 +631,26 @@ static int xhci_mtk_probe(struct platform_device *pdev)
xhci_mtk_ldos_disable(mtk);
 
 disable_pm:
-   pm_runtime_put_sync(dev);
+   pm_runtime_put_sync_autosuspend(dev);
pm_runtime_disable(dev);
return ret;
 }
 
-static int xhci_mtk_remove(struct platform_device *dev)
+static int xhci_mtk_remove(struct platform_device *pdev)
 {
-   struct xhci_hcd_mtk *mtk = platform_get_drvdata(dev);
+   struct xhci_hcd_mtk *mtk = platform_get_drvdata(pdev);
struct usb_hcd  *hcd = mtk->hcd;
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
struct usb_hcd  *shared_hcd = xhci->shared_hcd;
+   struct device *dev = >dev;
 
-   pm_runtime_put_noidle(>dev);
-   pm_runtime_disable(>dev);
+   pm_runtime_get_sync(dev);
+   xhci->xhc_state |= XHCI_STATE_REMOVING;
+   dev_pm_clear_wake_irq(dev);
+   device_init_wakeup(dev, false);
 
usb_remove_hcd(shared_hcd);
xhci->shared_hcd = NULL;
-   device_init_wakeup(>dev, false);
-
usb_remove_hcd(hcd);
usb_put_hcd(shared_hcd);
usb_put_hcd(hcd);
@@ -627,6 +658,10 @@ s

[PATCH 3/6] dt-bindings: usb: mtk-xhci: add wakeup interrupt

2021-04-08 Thread Chunfeng Yun
Add an interrupt which is EINT usually to support runtime PM,
meanwhile add "interrupt-names" property, for backward
compatibility, it's optional and used when wakeup interrupt
exists

Signed-off-by: Chunfeng Yun 
---
 .../devicetree/bindings/usb/mediatek,mtk-xhci.yaml  | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml 
b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
index 45bf4ea00c9e..4fe8a301d03f 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
@@ -46,7 +46,18 @@ properties:
   - const: ippc  # optional, only needed for case 1.
 
   interrupts:
-maxItems: 1
+description:
+  use "interrupts-extended" when the interrupts are connected to the
+  separate interrupt controllers
+minItems: 1
+items:
+  - description: xHCI host controller interrupt
+  - description: optional, wakeup interrupt used to support runtime PM
+
+  interrupt-names:
+items:
+  - const: host
+  - const: wakeup
 
   power-domains:
 description: A phandle to USB power domain node to control USB's MTCMOS
-- 
2.18.0



[PATCH 2/6] usb: xhci-mtk: check return value in suspend/resume hooks

2021-04-08 Thread Chunfeng Yun
Return error number if encounter errors during suspend and resume.

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mtk.c | 37 +++--
 1 file changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index c1bc40289833..a74764ab914a 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -630,18 +630,12 @@ static int xhci_mtk_remove(struct platform_device *dev)
return 0;
 }
 
-/*
- * if ip sleep fails, and all clocks are disabled, access register will hang
- * AHB bus, so stop polling roothubs to avoid regs access on bus suspend.
- * and no need to check whether ip sleep failed or not; this will cause SPM
- * to wake up system immediately after system suspend complete if ip sleep
- * fails, it is what we wanted.
- */
 static int __maybe_unused xhci_mtk_suspend(struct device *dev)
 {
struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev);
struct usb_hcd *hcd = mtk->hcd;
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+   int ret;
 
xhci_dbg(xhci, "%s: stop port polling\n", __func__);
clear_bit(HCD_FLAG_POLL_RH, >flags);
@@ -649,10 +643,21 @@ static int __maybe_unused xhci_mtk_suspend(struct device 
*dev)
clear_bit(HCD_FLAG_POLL_RH, >shared_hcd->flags);
del_timer_sync(>shared_hcd->rh_timer);
 
-   xhci_mtk_host_disable(mtk);
+   ret = xhci_mtk_host_disable(mtk);
+   if (ret)
+   goto restart_poll_rh;
+
xhci_mtk_clks_disable(mtk);
usb_wakeup_set(mtk, true);
return 0;
+
+restart_poll_rh:
+   xhci_dbg(xhci, "%s: restart port polling\n", __func__);
+   set_bit(HCD_FLAG_POLL_RH, >shared_hcd->flags);
+   usb_hcd_poll_rh_status(xhci->shared_hcd);
+   set_bit(HCD_FLAG_POLL_RH, >flags);
+   usb_hcd_poll_rh_status(hcd);
+   return ret;
 }
 
 static int __maybe_unused xhci_mtk_resume(struct device *dev)
@@ -660,10 +665,16 @@ static int __maybe_unused xhci_mtk_resume(struct device 
*dev)
struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev);
struct usb_hcd *hcd = mtk->hcd;
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+   int ret;
 
usb_wakeup_set(mtk, false);
-   xhci_mtk_clks_enable(mtk);
-   xhci_mtk_host_enable(mtk);
+   ret = xhci_mtk_clks_enable(mtk);
+   if (ret)
+   goto enable_wakeup;
+
+   ret = xhci_mtk_host_enable(mtk);
+   if (ret)
+   goto disable_clks;
 
xhci_dbg(xhci, "%s: restart port polling\n", __func__);
set_bit(HCD_FLAG_POLL_RH, >shared_hcd->flags);
@@ -671,6 +682,12 @@ static int __maybe_unused xhci_mtk_resume(struct device 
*dev)
set_bit(HCD_FLAG_POLL_RH, >flags);
usb_hcd_poll_rh_status(hcd);
return 0;
+
+disable_clks:
+   xhci_mtk_clks_disable(mtk);
+enable_wakeup:
+   usb_wakeup_set(mtk, true);
+   return ret;
 }
 
 static const struct dev_pm_ops xhci_mtk_pm_ops = {
-- 
2.18.0



[PATCH 1/6] PM: runtime: enable wake irq after runtime_suspend hook called

2021-04-08 Thread Chunfeng Yun
When the dedicated wake irq is level trigger, enable it before
calling runtime_suspend, will trigger an interrupt.

e.g.
for a low level trigger type, it's low level at running time (0),
and becomes high level when enters suspend (runtime_suspend (1) is
called), a wakeup signal at (2) make it become low level, wake irq
will be triggered.

--
   |   ^ ^|
   | | --
 |<---(0)--->|<--(1)--|   (3)   (2)(4)

if we enable the wake irq before calling runtime_suspend during (0),
an interrupt will arise, it causes resume immediately;
enable wake irq after calling runtime_suspend, e.g. at (3) or (4),
will works.

This patch seems no side effect on edge trigger wake irq.

Signed-off-by: Chunfeng Yun 
---
 drivers/base/power/runtime.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index a46a7e30881b..796739a015a5 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -619,12 +619,12 @@ static int rpm_suspend(struct device *dev, int rpmflags)
__update_runtime_status(dev, RPM_SUSPENDING);
 
callback = RPM_GET_CALLBACK(dev, runtime_suspend);
-
-   dev_pm_enable_wake_irq_check(dev, true);
retval = rpm_callback(callback, dev);
if (retval)
goto fail;
 
+   dev_pm_enable_wake_irq_check(dev, true);
+
  no_callback:
__update_runtime_status(dev, RPM_SUSPENDED);
pm_runtime_deactivate_timer(dev);
@@ -659,7 +659,6 @@ static int rpm_suspend(struct device *dev, int rpmflags)
return retval;
 
  fail:
-   dev_pm_disable_wake_irq_check(dev);
__update_runtime_status(dev, RPM_ACTIVE);
dev->power.deferred_resume = false;
wake_up_all(>power.wait_queue);
-- 
2.18.0



Re: [PATCH 05/16] media: cadence: csi2rx: Add external DPHY support

2021-04-08 Thread Chunfeng Yun
On Wed, 2021-04-07 at 00:24 +0530, Pratyush Yadav wrote:
> On 31/03/21 05:24PM, Chunfeng Yun wrote:
> > On Tue, 2021-03-30 at 23:03 +0530, Pratyush Yadav wrote:
> > > Some platforms like TI's J721E can have the CSI2RX paired with an
> > > external DPHY. Add support to enable and configure the DPHY using the
> > > generic PHY framework.
> > > 
> > > Get the pixel rate and bpp from the subdev and pass them on to the DPHY
> > > along with the number of lanes. All other settings are left to their
> > > default values.
> > > 
> > > Signed-off-by: Pratyush Yadav 
> > > ---
> > >  drivers/media/platform/cadence/cdns-csi2rx.c | 147 +--
> > >  1 file changed, 137 insertions(+), 10 deletions(-)
> > > 
> > > diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c 
> > > b/drivers/media/platform/cadence/cdns-csi2rx.c
> > > index c68a3eac62cd..31bd80e3f780 100644
> > > --- a/drivers/media/platform/cadence/cdns-csi2rx.c
> > > +++ b/drivers/media/platform/cadence/cdns-csi2rx.c
> > > @@ -30,6 +30,12 @@
> > >  #define CSI2RX_STATIC_CFG_DLANE_MAP(llane, plane)((plane) << (16 
> > > + (llane) * 4))
> > >  #define CSI2RX_STATIC_CFG_LANES_MASK GENMASK(11, 8)
> > >  
> > > +#define CSI2RX_DPHY_LANE_CTRL_REG0x40
> > > +#define CSI2RX_DPHY_CL_RST   BIT(16)
> > > +#define CSI2RX_DPHY_DL_RST(i)BIT((i) + 12)
> > > +#define CSI2RX_DPHY_CL_ENBIT(4)
> > > +#define CSI2RX_DPHY_DL_EN(i) BIT(i)
> > > +
> > >  #define CSI2RX_STREAM_BASE(n)(((n) + 1) * 0x100)
> > >  
> > >  #define CSI2RX_STREAM_CTRL_REG(n)(CSI2RX_STREAM_BASE(n) 
> > > + 0x000)
> > > @@ -54,6 +60,11 @@ enum csi2rx_pads {
> > >   CSI2RX_PAD_MAX,
> > >  };
> > >  
> > > +struct csi2rx_fmt {
> > > + u32 code;
> > > + u8  bpp;
> > > +};
> > > +
> > >  struct csi2rx_priv {
> > >   struct device   *dev;
> > >   unsigned intcount;
> > > @@ -85,6 +96,52 @@ struct csi2rx_priv {
> > >   int source_pad;
> > >  };
> > >  
> > > +static const struct csi2rx_fmt formats[] = {
> > > + {
> > > + .code   = MEDIA_BUS_FMT_YUYV8_2X8,
> > > + .bpp= 16,
> > > + },
> > > + {
> > > + .code   = MEDIA_BUS_FMT_UYVY8_2X8,
> > > + .bpp= 16,
> > > + },
> > > + {
> > > + .code   = MEDIA_BUS_FMT_YVYU8_2X8,
> > > + .bpp= 16,
> > > + },
> > > + {
> > > + .code   = MEDIA_BUS_FMT_VYUY8_2X8,
> > > + .bpp= 16,
> > > + },
> > > +};
> > > +
> > > +static u8 csi2rx_get_bpp(u32 code)
> > > +{
> > > + int i;
> > > +
> > > + for (i = 0; i < ARRAY_SIZE(formats); i++) {
> > > + if (formats[i].code == code)
> > > + return formats[i].bpp;
> > > + }
> > > +
> > > + return 0;
> > > +}
> > > +
> > > +static s64 csi2rx_get_pixel_rate(struct csi2rx_priv *csi2rx)
> > > +{
> > > + struct v4l2_ctrl *ctrl;
> > > +
> > > + ctrl = v4l2_ctrl_find(csi2rx->source_subdev->ctrl_handler,
> > > +   V4L2_CID_PIXEL_RATE);
> > > + if (!ctrl) {
> > > + dev_err(csi2rx->dev, "no pixel rate control in subdev: %s\n",
> > > + csi2rx->source_subdev->name);
> > > + return -EINVAL;
> > > + }
> > > +
> > > + return v4l2_ctrl_g_ctrl_int64(ctrl);
> > > +}
> > > +
> > >  static inline
> > >  struct csi2rx_priv *v4l2_subdev_to_csi2rx(struct v4l2_subdev *subdev)
> > >  {
> > > @@ -101,6 +158,55 @@ static void csi2rx_reset(struct csi2rx_priv *csi2rx)
> > >   writel(0, csi2rx->base + CSI2RX_SOFT_RESET_REG);
> > >  }
> > >  
> > > +static int csi2rx_configure_external_dphy(struct csi2rx_priv *csi2rx)
> > > +{
> > > + union phy_configure_opts opts = { };
> > > + struct phy_configure_opts_mipi_dphy *cfg = _dphy;
> > > + struct v4l2_subdev_format sd_fmt;
> > > + s64 pixel_rate;
> > > + int ret;
> > > + u8

Re: [PATCH 1/2] usb: xhci-mtk: remove unnecessary assignments in periodic TT scheduler

2021-04-05 Thread Chunfeng Yun
On Mon, 2021-04-05 at 09:04 +0200, Greg Kroah-Hartman wrote:
> On Wed, Mar 31, 2021 at 04:30:55PM +0800, Chunfeng Yun wrote:
> > cc Yaqii Wu 
> > 
> > I'll test it , thanks
> 
> Did you test this series and find any problems?  If not, I'll go queue
> these up...
Yes, found an issue on the start-split transaction, but not found the
root cause yet :(

> 
> thanks,
> 
> greg k-h



Re: [PATCH 05/16] media: cadence: csi2rx: Add external DPHY support

2021-03-31 Thread Chunfeng Yun
On Tue, 2021-03-30 at 23:03 +0530, Pratyush Yadav wrote:
> Some platforms like TI's J721E can have the CSI2RX paired with an
> external DPHY. Add support to enable and configure the DPHY using the
> generic PHY framework.
> 
> Get the pixel rate and bpp from the subdev and pass them on to the DPHY
> along with the number of lanes. All other settings are left to their
> default values.
> 
> Signed-off-by: Pratyush Yadav 
> ---
>  drivers/media/platform/cadence/cdns-csi2rx.c | 147 +--
>  1 file changed, 137 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c 
> b/drivers/media/platform/cadence/cdns-csi2rx.c
> index c68a3eac62cd..31bd80e3f780 100644
> --- a/drivers/media/platform/cadence/cdns-csi2rx.c
> +++ b/drivers/media/platform/cadence/cdns-csi2rx.c
> @@ -30,6 +30,12 @@
>  #define CSI2RX_STATIC_CFG_DLANE_MAP(llane, plane)((plane) << (16 + 
> (llane) * 4))
>  #define CSI2RX_STATIC_CFG_LANES_MASK GENMASK(11, 8)
>  
> +#define CSI2RX_DPHY_LANE_CTRL_REG0x40
> +#define CSI2RX_DPHY_CL_RST   BIT(16)
> +#define CSI2RX_DPHY_DL_RST(i)BIT((i) + 12)
> +#define CSI2RX_DPHY_CL_ENBIT(4)
> +#define CSI2RX_DPHY_DL_EN(i) BIT(i)
> +
>  #define CSI2RX_STREAM_BASE(n)(((n) + 1) * 0x100)
>  
>  #define CSI2RX_STREAM_CTRL_REG(n)(CSI2RX_STREAM_BASE(n) + 0x000)
> @@ -54,6 +60,11 @@ enum csi2rx_pads {
>   CSI2RX_PAD_MAX,
>  };
>  
> +struct csi2rx_fmt {
> + u32 code;
> + u8  bpp;
> +};
> +
>  struct csi2rx_priv {
>   struct device   *dev;
>   unsigned intcount;
> @@ -85,6 +96,52 @@ struct csi2rx_priv {
>   int source_pad;
>  };
>  
> +static const struct csi2rx_fmt formats[] = {
> + {
> + .code   = MEDIA_BUS_FMT_YUYV8_2X8,
> + .bpp= 16,
> + },
> + {
> + .code   = MEDIA_BUS_FMT_UYVY8_2X8,
> + .bpp= 16,
> + },
> + {
> + .code   = MEDIA_BUS_FMT_YVYU8_2X8,
> + .bpp= 16,
> + },
> + {
> + .code   = MEDIA_BUS_FMT_VYUY8_2X8,
> + .bpp= 16,
> + },
> +};
> +
> +static u8 csi2rx_get_bpp(u32 code)
> +{
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(formats); i++) {
> + if (formats[i].code == code)
> + return formats[i].bpp;
> + }
> +
> + return 0;
> +}
> +
> +static s64 csi2rx_get_pixel_rate(struct csi2rx_priv *csi2rx)
> +{
> + struct v4l2_ctrl *ctrl;
> +
> + ctrl = v4l2_ctrl_find(csi2rx->source_subdev->ctrl_handler,
> +   V4L2_CID_PIXEL_RATE);
> + if (!ctrl) {
> + dev_err(csi2rx->dev, "no pixel rate control in subdev: %s\n",
> + csi2rx->source_subdev->name);
> + return -EINVAL;
> + }
> +
> + return v4l2_ctrl_g_ctrl_int64(ctrl);
> +}
> +
>  static inline
>  struct csi2rx_priv *v4l2_subdev_to_csi2rx(struct v4l2_subdev *subdev)
>  {
> @@ -101,6 +158,55 @@ static void csi2rx_reset(struct csi2rx_priv *csi2rx)
>   writel(0, csi2rx->base + CSI2RX_SOFT_RESET_REG);
>  }
>  
> +static int csi2rx_configure_external_dphy(struct csi2rx_priv *csi2rx)
> +{
> + union phy_configure_opts opts = { };
> + struct phy_configure_opts_mipi_dphy *cfg = _dphy;
> + struct v4l2_subdev_format sd_fmt;
> + s64 pixel_rate;
> + int ret;
> + u8 bpp;
> +
> + sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
> + sd_fmt.pad = 0;
> +
> + ret = v4l2_subdev_call(csi2rx->source_subdev, pad, get_fmt, NULL,
> +_fmt);
> + if (ret)
> + return ret;
> +
> + bpp = csi2rx_get_bpp(sd_fmt.format.code);
> + if (!bpp)
> + return -EINVAL;
> +
> + pixel_rate = csi2rx_get_pixel_rate(csi2rx);
> + if (pixel_rate < 0)
> + return pixel_rate;
> +
> + ret = phy_mipi_dphy_get_default_config(pixel_rate, bpp,
> +csi2rx->num_lanes, cfg);
> + if (ret)
> + return ret;
> +
> + ret = phy_set_mode_ext(csi2rx->dphy, PHY_MODE_MIPI_DPHY,
> +PHY_MIPI_DPHY_SUBMODE_RX);
> + if (ret)
> + return ret;
> +
> + ret = phy_power_on(csi2rx->dphy);
> + if (ret)
> + return ret;
Seems phy_power_on, then phy_set_mode_ext?

> +
> + ret = phy_configure(csi2rx->dphy, );
> + if (ret) {
> + /* Can't do anything if it fails. Ignore the return value. */
> + phy_power_off(csi2rx->dphy);
> + return ret;
> + }
> +
> + return 0;
> +}
> +
>  static int csi2rx_start(struct csi2rx_priv *csi2rx)
>  {
>   unsigned int i;
> @@ -139,6 +245,17 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
>   if (ret)
>   goto 

[PATCH v4 3/4] usb: xhci-mtk: fix broken streams issue on 0.96 xHCI

2021-03-31 Thread Chunfeng Yun
The MediaTek 0.96 xHCI controller on some platforms does not
support bulk stream even HCCPARAMS says supporting, due to MaxPSASize
is set a default value 1 by mistake, here use XHCI_BROKEN_STREAMS
quirk to fix it.

Fixes: 94a631d91ad3 ("usb: xhci-mtk: check hcc_params after adding primary hcd")
Cc: stable 
Signed-off-by: Chunfeng Yun 
---
v4: cc stable suggested by Frank
v2~3: no changes
---
 drivers/usb/host/xhci-mtk.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index c1bc40289833..4e3d53cc24f4 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -411,6 +411,13 @@ static void xhci_mtk_quirks(struct device *dev, struct 
xhci_hcd *xhci)
xhci->quirks |= XHCI_SPURIOUS_SUCCESS;
if (mtk->lpm_support)
xhci->quirks |= XHCI_LPM_SUPPORT;
+
+   /*
+* MTK xHCI 0.96: PSA is 1 by default even if doesn't support stream,
+* and it's 3 when support it.
+*/
+   if (xhci->hci_version < 0x100 && HCC_MAX_PSA(xhci->hcc_params) == 4)
+   xhci->quirks |= XHCI_BROKEN_STREAMS;
 }
 
 /* called during probe() after chip reset completes */
@@ -572,7 +579,8 @@ static int xhci_mtk_probe(struct platform_device *pdev)
if (ret)
goto put_usb3_hcd;
 
-   if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
+   if (HCC_MAX_PSA(xhci->hcc_params) >= 4 &&
+   !(xhci->quirks & XHCI_BROKEN_STREAMS))
xhci->shared_hcd->can_do_streams = 1;
 
ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
-- 
2.18.0



[PATCH v4 4/4] usb: xhci-mtk: support quirk to disable usb2 lpm

2021-03-31 Thread Chunfeng Yun
The xHCI driver support usb2 HW LPM by default, here add support
XHCI_HW_LPM_DISABLE quirk, then we can disable usb2 lpm when
need it.

Signed-off-by: Chunfeng Yun 
---
v2~4: no changes
---
 drivers/usb/host/xhci-mtk.c | 3 +++
 drivers/usb/host/xhci-mtk.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 4e3d53cc24f4..744639d23fa8 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -411,6 +411,8 @@ static void xhci_mtk_quirks(struct device *dev, struct 
xhci_hcd *xhci)
xhci->quirks |= XHCI_SPURIOUS_SUCCESS;
if (mtk->lpm_support)
xhci->quirks |= XHCI_LPM_SUPPORT;
+   if (mtk->u2_lpm_disable)
+   xhci->quirks |= XHCI_HW_LPM_DISABLE;
 
/*
 * MTK xHCI 0.96: PSA is 1 by default even if doesn't support stream,
@@ -493,6 +495,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
return ret;
 
mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable");
+   mtk->u2_lpm_disable = of_property_read_bool(node, "usb2-lpm-disable");
/* optional property, ignore the error if it does not exist */
of_property_read_u32(node, "mediatek,u3p-dis-msk",
 >u3p_dis_msk);
diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
index 621ec1a85009..4ccd08e20a15 100644
--- a/drivers/usb/host/xhci-mtk.h
+++ b/drivers/usb/host/xhci-mtk.h
@@ -149,6 +149,7 @@ struct xhci_hcd_mtk {
struct phy **phys;
int num_phys;
bool lpm_support;
+   bool u2_lpm_disable;
/* usb remote wakeup */
bool uwk_en;
struct regmap *uwk;
-- 
2.18.0



[PATCH v4 1/4] dt-bindings: usb: mtk-xhci: support property usb2-lpm-disable

2021-03-31 Thread Chunfeng Yun
Add support common property usb2-lpm-disable

Acked-by: Rob Herring 
Signed-off-by: Chunfeng Yun 
---
v4: add acked-by Rob
v3: remove redefinition of type and description suggested by Rob
v2: no changes
---
 Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml 
b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
index 45bf4ea00c9e..291749f49f35 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
@@ -104,6 +104,8 @@ properties:
 description: supports USB3.0 LPM
 type: boolean
 
+  usb2-lpm-disable: true
+
   imod-interval-ns:
 description:
   Interrupt moderation interval value, it is 8 times as much as that
-- 
2.18.0



[PATCH v4 2/4] dt-bindings: usb: mtk-xhci: remove redefinitions of usb3-lpm-capable

2021-03-31 Thread Chunfeng Yun
The property usb3-lpm-capable is defined in usb-xhci.yaml which is
already referenced in this file, so no need 'description' and 'type'
anymore.

Acked-by: Rob Herring 
Signed-off-by: Chunfeng Yun 
---
v4: add acked-by Rob
v3: new patch
---
 Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml 
b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
index 291749f49f35..69c3e7d0f9dd 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
@@ -100,9 +100,7 @@ properties:
   vbus-supply:
 description: Regulator of USB VBUS5v
 
-  usb3-lpm-capable:
-description: supports USB3.0 LPM
-type: boolean
+  usb3-lpm-capable: true
 
   usb2-lpm-disable: true
 
-- 
2.18.0



Re: [PATCH 2/2] usb: xhci-mtk: relax periodic TT bandwidth checking

2021-03-31 Thread Chunfeng Yun
On Tue, 2021-03-30 at 16:06 +0800, Ikjoon Jang wrote:
> Software bandwidth checking logics used by xhci-mtk puts
> a quite heavy constraints to TT periodic endpoint allocations.
> 
> This patch provides a relaxed bandwidth calculation by
> - Allowing multiple periodic transactions in a same microframe
>   for a device with multiple interrupt endpoints.
> - Using best case budget instead of maximum number of
>   complete-split when calculating byte budgets on lower speed bus
> 
> Without this patch, a typical full speed audio headset with
> 3 periodic endpoints (audio isoc-in/out, input int-in) cannot be
> configured with xhci-mtk.
> 
> Signed-off-by: Ikjoon Jang 
> ---
cc Yaqii Wu 

I'll test it, thanks

> 
>  drivers/usb/host/xhci-mtk-sch.c | 68 ++---
>  drivers/usb/host/xhci-mtk.h |  2 -
>  2 files changed, 20 insertions(+), 50 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
> index 0cb41007ec65..76827e48049a 100644
> --- a/drivers/usb/host/xhci-mtk-sch.c
> +++ b/drivers/usb/host/xhci-mtk-sch.c
> @@ -388,13 +388,17 @@ static void setup_sch_info(struct xhci_ep_ctx *ep_ctx,
>   } else { /* INT_IN_EP or ISOC_IN_EP */
>   bwb_table[0] = 0; /* start split */
>   bwb_table[1] = 0; /* idle */
> +
> + sch_ep->num_budget_microframes += 2;
> + if (sch_ep->num_budget_microframes > sch_ep->esit)
> + sch_ep->num_budget_microframes = sch_ep->esit;
>   /*
>* due to cs_count will be updated according to cs
>* position, assign all remainder budget array
>* elements as @bw_cost_per_microframe, but only first
>* @num_budget_microframes elements will be used later
>*/
> - for (i = 2; i < TT_MICROFRAMES_MAX; i++)
> + for (i = 2; i < sch_ep->num_budget_microframes; i++)
>   bwb_table[i] =  sch_ep->bw_cost_per_microframe;
>   }
>   }
> @@ -449,20 +453,17 @@ static void update_bus_bw(struct mu3h_sch_bw_info 
> *sch_bw,
>  static int check_fs_bus_bw(struct mu3h_sch_ep_info *sch_ep, int offset)
>  {
>   struct mu3h_sch_tt *tt = sch_ep->sch_tt;
> - u32 num_esit, tmp;
> - int base;
>   int i, j;
> + const int nr_lower_uframes =
> + DIV_ROUND_UP(sch_ep->maxpkt, FS_PAYLOAD_MAX);
>  
> - num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit;
> - for (i = 0; i < num_esit; i++) {
> - base = offset + i * sch_ep->esit;
> -
> + for (i = offset; i < XHCI_MTK_MAX_ESIT; i += sch_ep->esit) {
>   /*
>* Compared with hs bus, no matter what ep type,
>* the hub will always delay one uframe to send data
>*/
> - for (j = 0; j < sch_ep->cs_count; j++) {
> - tmp = tt->fs_bus_bw[base + j] + 
> sch_ep->bw_cost_per_microframe;
> + for (j = 0; j < nr_lower_uframes; j++) {
> + u32 tmp = tt->fs_bus_bw[i + j + 1] + 
> sch_ep->bw_cost_per_microframe;
>   if (tmp > FS_PAYLOAD_MAX)
>   return -ESCH_BW_OVERFLOW;
>   }
> @@ -473,11 +474,9 @@ static int check_fs_bus_bw(struct mu3h_sch_ep_info 
> *sch_ep, int offset)
>  
>  static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, u32 offset)
>  {
> - struct mu3h_sch_tt *tt = sch_ep->sch_tt;
>   u32 extra_cs_count;
>   u32 start_ss, last_ss;
>   u32 start_cs, last_cs;
> - int i;
>  
>   if (!sch_ep->sch_tt)
>   return 0;
> @@ -494,10 +493,6 @@ static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, 
> u32 offset)
>   if (!(start_ss == 7 || last_ss < 6))
>   return -ESCH_SS_Y6;
>  
> - for (i = 0; i < sch_ep->cs_count; i++)
> - if (test_bit(offset + i, tt->ss_bit_map))
> - return -ESCH_SS_OVERLAP;
> -
>   } else {
>   u32 cs_count = DIV_ROUND_UP(sch_ep->maxpkt, FS_PAYLOAD_MAX);
>  
> @@ -524,19 +519,7 @@ static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, 
> u32 offset)
>   if (cs_count > 7)
>   cs_count = 7; /* HW limit */
>  
> - if (test_bit(offset, tt->ss_bit_map))
> - return -ESCH_SS_OVERLAP;
> -
>   sch_ep->cs_count = cs_count;
> - /* one for ss, the other for idle */
> - sch_ep->num_budget_microframes = cs_count + 2;
> -
> - /*
> -  * if interval=1, maxp >752, num_budge_micoframe is larger
> -  * than sch_ep->esit, will overstep boundary
> -  */
> - if (sch_ep->num_budget_microframes > sch_ep->esit)
> - sch_ep->num_budget_microframes = 

Re: [PATCH 1/2] usb: xhci-mtk: remove unnecessary assignments in periodic TT scheduler

2021-03-31 Thread Chunfeng Yun
cc Yaqii Wu 

I'll test it , thanks

On Tue, 2021-03-30 at 16:06 +0800, Ikjoon Jang wrote:
> Remove unnecessary variables in check_sch_bw().
> No functional changes, just for better readability.
> 
> Signed-off-by: Ikjoon Jang 
> ---
> 
>  drivers/usb/host/xhci-mtk-sch.c | 52 +
>  1 file changed, 21 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
> index a59d1f6d4744..0cb41007ec65 100644
> --- a/drivers/usb/host/xhci-mtk-sch.c
> +++ b/drivers/usb/host/xhci-mtk-sch.c
> @@ -479,6 +479,9 @@ static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, 
> u32 offset)
>   u32 start_cs, last_cs;
>   int i;
>  
> + if (!sch_ep->sch_tt)
> + return 0;
> +
>   start_ss = offset % 8;
>  
>   if (sch_ep->ep_type == ISOC_OUT_EP) {
> @@ -606,54 +609,41 @@ static u32 get_esit_boundary(struct mu3h_sch_ep_info 
> *sch_ep)
>  static int check_sch_bw(struct mu3h_sch_bw_info *sch_bw,
>   struct mu3h_sch_ep_info *sch_ep)
>  {
> - u32 offset;
> - u32 min_bw;
> - u32 min_index;
> - u32 worst_bw;
> - u32 bw_boundary;
> - u32 esit_boundary;
> - u32 min_num_budget;
> - u32 min_cs_count;
> - int ret = 0;
> + int i, found = -1;
> + const u32 esit_boundary = get_esit_boundary(sch_ep);
> + const u32 bw_boundary = get_bw_boundary(sch_ep->speed);
> + u32 min_bw = ~0;
>  
>   /*
>* Search through all possible schedule microframes.
>* and find a microframe where its worst bandwidth is minimum.
>*/
> - min_bw = ~0;
> - min_index = 0;
> - min_cs_count = sch_ep->cs_count;
> - min_num_budget = sch_ep->num_budget_microframes;
> - esit_boundary = get_esit_boundary(sch_ep);
> - for (offset = 0; offset < sch_ep->esit; offset++) {
> - if (sch_ep->sch_tt) {
> - ret = check_sch_tt(sch_ep, offset);
> - if (ret)
> - continue;
> - }
> + for (i = 0; i < sch_ep->esit; i++) {
> + u32 worst_bw;
>  
> - if ((offset + sch_ep->num_budget_microframes) > esit_boundary)
> + if ((i + sch_ep->num_budget_microframes) > esit_boundary)
>   break;
>  
> - worst_bw = get_max_bw(sch_bw, sch_ep, offset);
> + if (check_sch_tt(sch_ep, i))
> + continue;
> +
> + worst_bw = get_max_bw(sch_bw, sch_ep, i);
> + if (worst_bw > bw_boundary)
> + continue;
> +
>   if (min_bw > worst_bw) {
>   min_bw = worst_bw;
> - min_index = offset;
> - min_cs_count = sch_ep->cs_count;
> - min_num_budget = sch_ep->num_budget_microframes;
> + found = i;
>   }
>   if (min_bw == 0)
>   break;
>   }
>  
> - bw_boundary = get_bw_boundary(sch_ep->speed);
>   /* check bandwidth */
> - if (min_bw > bw_boundary)
> - return ret ? ret : -ESCH_BW_OVERFLOW;
> + if (found < 0)
> + return -ESCH_BW_OVERFLOW;
>  
> - sch_ep->offset = min_index;
> - sch_ep->cs_count = min_cs_count;
> - sch_ep->num_budget_microframes = min_num_budget;
> + sch_ep->offset = found;
>  
>   return load_ep_bw(sch_bw, sch_ep, true);
>  }



[PATCH next 2/2] usb: xhci-mtk: fix oops when unbind driver

2021-03-31 Thread Chunfeng Yun
The oops happens when unbind driver through sysfs as following,
because xhci_mtk_drop_ep() try to drop the endpoint of root hub
which is not added by xhci_add_endpoint() and the virtual device
is not allocated, in fact also needn't drop it, so should skip it.

Call trace:
 xhci_mtk_drop_ep+0x1b8/0x298
 usb_hcd_alloc_bandwidth+0x1d8/0x380
 usb_disable_device_endpoints+0x8c/0xe0
 usb_disable_device+0x128/0x168
 usb_disconnect+0xbc/0x2c8
 usb_remove_hcd+0xd8/0x210
 xhci_mtk_remove+0x98/0x108
 platform_remove+0x28/0x60
 device_release_driver_internal+0x110/0x1e8
 device_driver_detach+0x18/0x28
 unbind_store+0xd4/0x108
 drv_attr_store+0x24/0x38

Fixes: 14295a150050 ("usb: xhci-mtk: support to build xhci-mtk-hcd.ko")
Reported-by: Eddie Hung 
Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mtk-sch.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
index 7ac76ae28998..8b90da5a6ed1 100644
--- a/drivers/usb/host/xhci-mtk-sch.c
+++ b/drivers/usb/host/xhci-mtk-sch.c
@@ -872,6 +872,8 @@ int xhci_mtk_drop_ep(struct usb_hcd *hcd, struct usb_device 
*udev,
if (ret)
return ret;
 
-   drop_ep_quirk(hcd, udev, ep);
+   if (ep->hcpriv)
+   drop_ep_quirk(hcd, udev, ep);
+
return 0;
 }
-- 
2.18.0



[PATCH next 1/2] usb: xhci-mtk: fix wrong remainder of bandwidth budget

2021-03-31 Thread Chunfeng Yun
The remainder of the last bandwidth bugdget is wrong,
it's the value alloacted in last bugdget, not unused.

Reported-by: Yaqii Wu 
Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mtk-sch.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
index a59d1f6d4744..7ac76ae28998 100644
--- a/drivers/usb/host/xhci-mtk-sch.c
+++ b/drivers/usb/host/xhci-mtk-sch.c
@@ -341,7 +341,6 @@ static void setup_sch_info(struct xhci_ep_ctx *ep_ctx,
}
 
if (ep_type == ISOC_IN_EP || ep_type == ISOC_OUT_EP) {
-   u32 remainder;
 
if (sch_ep->esit == 1)
sch_ep->pkts = esit_pkts;
@@ -357,14 +356,12 @@ static void setup_sch_info(struct xhci_ep_ctx *ep_ctx,
sch_ep->repeat = !!(sch_ep->num_budget_microframes > 1);
sch_ep->bw_cost_per_microframe = maxpkt * sch_ep->pkts;
 
-   remainder = sch_ep->bw_cost_per_microframe;
-   remainder *= sch_ep->num_budget_microframes;
-   remainder -= (maxpkt * esit_pkts);
for (i = 0; i < sch_ep->num_budget_microframes - 1; i++)
bwb_table[i] = sch_ep->bw_cost_per_microframe;
 
/* last one <= bw_cost_per_microframe */
-   bwb_table[i] = remainder;
+   bwb_table[i] = maxpkt * esit_pkts
+  - i * sch_ep->bw_cost_per_microframe;
}
} else if (is_fs_or_ls(sch_ep->speed)) {
sch_ep->pkts = 1; /* at most one packet for each microframe */
-- 
2.18.0



[PATCH v3 1/4] dt-bindings: usb: mtk-xhci: support property usb2-lpm-disable

2021-03-29 Thread Chunfeng Yun
Add support common property usb2-lpm-disable

Signed-off-by: Chunfeng Yun 
---
v3: remove redefinition of type and description suggested by Rob
v2: no changes
---
 Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml 
b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
index 45bf4ea00c9e..291749f49f35 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
@@ -104,6 +104,8 @@ properties:
 description: supports USB3.0 LPM
 type: boolean
 
+  usb2-lpm-disable: true
+
   imod-interval-ns:
 description:
   Interrupt moderation interval value, it is 8 times as much as that
-- 
2.18.0



[PATCH v3 4/4] usb: xhci-mtk: support quirk to disable usb2 lpm

2021-03-29 Thread Chunfeng Yun
The xHCI driver support usb2 HW LPM by default, here add support
XHCI_HW_LPM_DISABLE quirk, then we can disable usb2 lpm when
need it.

Signed-off-by: Chunfeng Yun 
---
v2~3: no changes
---
 drivers/usb/host/xhci-mtk.c | 3 +++
 drivers/usb/host/xhci-mtk.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 4e3d53cc24f4..744639d23fa8 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -411,6 +411,8 @@ static void xhci_mtk_quirks(struct device *dev, struct 
xhci_hcd *xhci)
xhci->quirks |= XHCI_SPURIOUS_SUCCESS;
if (mtk->lpm_support)
xhci->quirks |= XHCI_LPM_SUPPORT;
+   if (mtk->u2_lpm_disable)
+   xhci->quirks |= XHCI_HW_LPM_DISABLE;
 
/*
 * MTK xHCI 0.96: PSA is 1 by default even if doesn't support stream,
@@ -493,6 +495,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
return ret;
 
mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable");
+   mtk->u2_lpm_disable = of_property_read_bool(node, "usb2-lpm-disable");
/* optional property, ignore the error if it does not exist */
of_property_read_u32(node, "mediatek,u3p-dis-msk",
 >u3p_dis_msk);
diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
index 621ec1a85009..4ccd08e20a15 100644
--- a/drivers/usb/host/xhci-mtk.h
+++ b/drivers/usb/host/xhci-mtk.h
@@ -149,6 +149,7 @@ struct xhci_hcd_mtk {
struct phy **phys;
int num_phys;
bool lpm_support;
+   bool u2_lpm_disable;
/* usb remote wakeup */
bool uwk_en;
struct regmap *uwk;
-- 
2.18.0



[PATCH v3 3/4] usb: xhci-mtk: fix broken streams issue on 0.96 xHCI

2021-03-29 Thread Chunfeng Yun
The MediaTek 0.96 xHCI controller on some platforms does not
support bulk stream even HCCPARAMS says supporting, due to MaxPSASize
is set a default value 1 by mistake, here use XHCI_BROKEN_STREAMS
quirk to fix it.

Fixes: 94a631d91ad3 ("usb: xhci-mtk: check hcc_params after adding primary hcd")
Signed-off-by: Chunfeng Yun 
---
v2~3: no changes
---
 drivers/usb/host/xhci-mtk.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index c1bc40289833..4e3d53cc24f4 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -411,6 +411,13 @@ static void xhci_mtk_quirks(struct device *dev, struct 
xhci_hcd *xhci)
xhci->quirks |= XHCI_SPURIOUS_SUCCESS;
if (mtk->lpm_support)
xhci->quirks |= XHCI_LPM_SUPPORT;
+
+   /*
+* MTK xHCI 0.96: PSA is 1 by default even if doesn't support stream,
+* and it's 3 when support it.
+*/
+   if (xhci->hci_version < 0x100 && HCC_MAX_PSA(xhci->hcc_params) == 4)
+   xhci->quirks |= XHCI_BROKEN_STREAMS;
 }
 
 /* called during probe() after chip reset completes */
@@ -572,7 +579,8 @@ static int xhci_mtk_probe(struct platform_device *pdev)
if (ret)
goto put_usb3_hcd;
 
-   if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
+   if (HCC_MAX_PSA(xhci->hcc_params) >= 4 &&
+   !(xhci->quirks & XHCI_BROKEN_STREAMS))
xhci->shared_hcd->can_do_streams = 1;
 
ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
-- 
2.18.0



[PATCH v3 2/4] dt-bindings: usb: mtk-xhci: remove redefinitions of usb3-lpm-capable

2021-03-29 Thread Chunfeng Yun
The property usb3-lpm-capable is defined in usb-xhci.yaml which is
already referenced in this file, so no need 'description' and 'type'
anymore.

Signed-off-by: Chunfeng Yun 
---
v3: new patch
---
 Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml 
b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
index 291749f49f35..69c3e7d0f9dd 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
@@ -100,9 +100,7 @@ properties:
   vbus-supply:
 description: Regulator of USB VBUS5v
 
-  usb3-lpm-capable:
-description: supports USB3.0 LPM
-type: boolean
+  usb3-lpm-capable: true
 
   usb2-lpm-disable: true
 
-- 
2.18.0



Re: [PATCH v2 01/13] dt-bindings: usb: mtk-xhci: support property usb2-lpm-disable

2021-03-28 Thread Chunfeng Yun
On Sat, 2021-03-27 at 11:24 -0600, Rob Herring wrote:
> On Tue, Mar 23, 2021 at 03:02:43PM +0800, Chunfeng Yun wrote:
> > Add support common property usb2-lpm-disable
> > 
> > Signed-off-by: Chunfeng Yun 
> > ---
> > v2: no changes
> > ---
> >  Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml | 4 
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml 
> > b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
> > index 14f40efb3b22..2246d29a5e4e 100644
> > --- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
> > +++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
> > @@ -103,6 +103,10 @@ properties:
> >  description: supports USB3.0 LPM
> >  type: boolean
> >  
> > +  usb2-lpm-disable:
> > +description: disable USB2 HW LPM
> > +type: boolean
> 
> Already has a type. Don't redefine here. Just 'usb2-lpm-disable: true' 
> and make sure usb-xhci.yaml is referenced.
Ok, thanks
> 
> > +
> >imod-interval-ns:
> >  description:
> >Interrupt moderation interval value, it is 8 times as much as that
> > -- 
> > 2.18.0
> > 



[PATCH RESEND v5 11/12] arm: dts: mt7623: harmonize node names and compatibles

2021-03-25 Thread Chunfeng Yun
This is used to fix dtbs_check warning

Signed-off-by: Chunfeng Yun 
---
v2~v5: no changes
---
 arch/arm/boot/dts/mt7623.dtsi  | 26 ++
 arch/arm/boot/dts/mt7623n.dtsi |  4 ++--
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/arch/arm/boot/dts/mt7623.dtsi b/arch/arm/boot/dts/mt7623.dtsi
index aea6809500d7..3c11f7cfcc40 100644
--- a/arch/arm/boot/dts/mt7623.dtsi
+++ b/arch/arm/boot/dts/mt7623.dtsi
@@ -787,8 +787,9 @@
};
};
 
-   pcie0_phy: pcie-phy@1a149000 {
-   compatible = "mediatek,generic-tphy-v1";
+   pcie0_phy: t-phy@1a149000 {
+   compatible = "mediatek,mt7623-tphy",
+"mediatek,generic-tphy-v1";
reg = <0 0x1a149000 0 0x0700>;
#address-cells = <2>;
#size-cells = <2>;
@@ -804,8 +805,9 @@
};
};
 
-   pcie1_phy: pcie-phy@1a14a000 {
-   compatible = "mediatek,generic-tphy-v1";
+   pcie1_phy: t-phy@1a14a000 {
+   compatible = "mediatek,mt7623-tphy",
+"mediatek,generic-tphy-v1";
reg = <0 0x1a14a000 0 0x0700>;
#address-cells = <2>;
#size-cells = <2>;
@@ -823,7 +825,7 @@
 
usb1: usb@1a1c {
compatible = "mediatek,mt7623-xhci",
-"mediatek,mt8173-xhci";
+"mediatek,mtk-xhci";
reg = <0 0x1a1c 0 0x1000>,
  <0 0x1a1c4700 0 0x0100>;
reg-names = "mac", "ippc";
@@ -836,9 +838,9 @@
status = "disabled";
};
 
-   u3phy1: usb-phy@1a1c4000 {
-   compatible = "mediatek,mt7623-u3phy",
-"mediatek,mt2701-u3phy";
+   u3phy1: t-phy@1a1c4000 {
+   compatible = "mediatek,mt7623-tphy",
+"mediatek,generic-tphy-v1";
reg = <0 0x1a1c4000 0 0x0700>;
#address-cells = <2>;
#size-cells = <2>;
@@ -864,7 +866,7 @@
 
usb2: usb@1a24 {
compatible = "mediatek,mt7623-xhci",
-"mediatek,mt8173-xhci";
+"mediatek,mtk-xhci";
reg = <0 0x1a24 0 0x1000>,
  <0 0x1a244700 0 0x0100>;
reg-names = "mac", "ippc";
@@ -877,9 +879,9 @@
status = "disabled";
};
 
-   u3phy2: usb-phy@1a244000 {
-   compatible = "mediatek,mt7623-u3phy",
-"mediatek,mt2701-u3phy";
+   u3phy2: t-phy@1a244000 {
+   compatible = "mediatek,mt7623-tphy",
+"mediatek,generic-tphy-v1";
reg = <0 0x1a244000 0 0x0700>;
#address-cells = <2>;
#size-cells = <2>;
diff --git a/arch/arm/boot/dts/mt7623n.dtsi b/arch/arm/boot/dts/mt7623n.dtsi
index 1880ac9e32cf..bcb0846e29fd 100644
--- a/arch/arm/boot/dts/mt7623n.dtsi
+++ b/arch/arm/boot/dts/mt7623n.dtsi
@@ -246,7 +246,7 @@
status = "disabled";
};
 
-   mipi_tx0: mipi-dphy@1001 {
+   mipi_tx0: dsi-phy@1001 {
compatible = "mediatek,mt7623-mipi-tx",
 "mediatek,mt2701-mipi-tx";
reg = <0 0x1001 0 0x90>;
@@ -265,7 +265,7 @@
status = "disabled";
};
 
-   hdmi_phy: phy@10209100 {
+   hdmi_phy: hdmi-phy@10209100 {
compatible = "mediatek,mt7623-hdmi-phy",
 "mediatek,mt2701-hdmi-phy";
reg = <0 0x10209100 0 0x24>;
-- 
2.18.0



[PATCH RESEND v5 02/12] dt-bindings: phy: mediatek: hdmi-phy: modify compatible items

2021-03-25 Thread Chunfeng Yun
mt7623-hdmi-tx is compatible to mt2701-hdmi-tx, and the compatible
"mediatek,mt7623-hdmi-tx" is not supported in driver, in fact uses
"mediatek,mt2701-hdmi-tx" instead on MT7623, so changes the
compatible items to make dependence clear.

Cc: Chun-Kuang Hu 
Cc: Philipp Zabel 
Acked-by: Chun-Kuang Hu 
Reviewed-by: Rob Herring 
Signed-off-by: Chunfeng Yun 
---
v5: no changes
v4: add acked-by CK and Reviewed-by Rob
v3: modify commit message
v2: no changes
---
 .../devicetree/bindings/phy/mediatek,hdmi-phy.yaml| 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/phy/mediatek,hdmi-phy.yaml 
b/Documentation/devicetree/bindings/phy/mediatek,hdmi-phy.yaml
index 4752517a1446..0d94950b84ca 100644
--- a/Documentation/devicetree/bindings/phy/mediatek,hdmi-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/mediatek,hdmi-phy.yaml
@@ -21,10 +21,13 @@ properties:
 pattern: "^hdmi-phy@[0-9a-f]+$"
 
   compatible:
-enum:
-  - mediatek,mt2701-hdmi-phy
-  - mediatek,mt7623-hdmi-phy
-  - mediatek,mt8173-hdmi-phy
+oneOf:
+  - items:
+  - enum:
+  - mediatek,mt7623-hdmi-phy
+  - const: mediatek,mt2701-hdmi-phy
+  - const: mediatek,mt2701-hdmi-phy
+  - const: mediatek,mt8173-hdmi-phy
 
   reg:
 maxItems: 1
-- 
2.18.0



[PATCH RESEND v5 08/12] arm64: dts: mediatek: mt7622: harmonize node names and compatibles

2021-03-25 Thread Chunfeng Yun
This is used to fix dtbs_check warning

Signed-off-by: Chunfeng Yun 
---
v2~v5: no changes
---
 arch/arm64/boot/dts/mediatek/mt7622.dtsi | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt7622.dtsi 
b/arch/arm64/boot/dts/mediatek/mt7622.dtsi
index 7c6d871538a6..890a942ec608 100644
--- a/arch/arm64/boot/dts/mediatek/mt7622.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt7622.dtsi
@@ -742,8 +742,8 @@
status = "disabled";
};
 
-   u3phy: usb-phy@1a0c4000 {
-   compatible = "mediatek,mt7622-u3phy",
+   u3phy: t-phy@1a0c4000 {
+   compatible = "mediatek,mt7622-tphy",
 "mediatek,generic-tphy-v1";
reg = <0 0x1a0c4000 0 0x700>;
#address-cells = <2>;
@@ -877,8 +877,9 @@
status = "disabled";
};
 
-   sata_phy: sata-phy@1a243000 {
-   compatible = "mediatek,generic-tphy-v1";
+   sata_phy: t-phy@1a243000 {
+   compatible = "mediatek,mt7622-tphy",
+"mediatek,generic-tphy-v1";
#address-cells = <2>;
#size-cells = <2>;
ranges;
-- 
2.18.0



[PATCH RESEND v5 06/12] arm64: dts: mediatek: mt2712: harmonize node names

2021-03-25 Thread Chunfeng Yun
This is used to fix dtbs_check warning.

Signed-off-by: Chunfeng Yun 
---
v2~v5: no changes
---
 arch/arm64/boot/dts/mediatek/mt2712e.dtsi | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi 
b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi
index db17d0a4ed57..a9cca9c146fd 100644
--- a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi
@@ -805,7 +805,7 @@
ranges;
status = "disabled";
 
-   usb_host0: xhci@1127 {
+   usb_host0: usb@1127 {
compatible = "mediatek,mt2712-xhci",
 "mediatek,mtk-xhci";
reg = <0 0x1127 0 0x1000>;
@@ -818,7 +818,7 @@
};
};
 
-   u3phy0: usb-phy@1129 {
+   u3phy0: t-phy@1129 {
compatible = "mediatek,mt2712-tphy",
 "mediatek,generic-tphy-v2";
#address-cells = <1>;
@@ -869,7 +869,7 @@
ranges;
status = "disabled";
 
-   usb_host1: xhci@112c {
+   usb_host1: usb@112c {
compatible = "mediatek,mt2712-xhci",
 "mediatek,mtk-xhci";
reg = <0 0x112c 0 0x1000>;
@@ -882,7 +882,7 @@
};
};
 
-   u3phy1: usb-phy@112e {
+   u3phy1: t-phy@112e {
compatible = "mediatek,mt2712-tphy",
 "mediatek,generic-tphy-v2";
#address-cells = <1>;
-- 
2.18.0



[PATCH RESEND v5 01/12] dt-bindings: phy: mediatek: dsi-phy: modify compatible dependence

2021-03-25 Thread Chunfeng Yun
mt7623-mipi-tx is compatible to mt2701-mipi-tx, and use
"mediatek,mt2701-mipi-tx" instead on MT7623, so modify
the compatible items to make dependence clear.

Cc: Chun-Kuang Hu 
Cc: Philipp Zabel 
Acked-by: Chun-Kuang Hu 
Reviewed-by: Rob Herring 
Signed-off-by: Chunfeng Yun 
---
v5: no changes
v4: add acked-by CK, and reviewed-by Rob
v3: modify commit message suggested by CK
v2: separate two patches suggested by CK
---
 .../devicetree/bindings/phy/mediatek,dsi-phy.yaml   | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/phy/mediatek,dsi-phy.yaml 
b/Documentation/devicetree/bindings/phy/mediatek,dsi-phy.yaml
index 71d4acea1f66..6e4d795f9b02 100644
--- a/Documentation/devicetree/bindings/phy/mediatek,dsi-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/mediatek,dsi-phy.yaml
@@ -19,11 +19,14 @@ properties:
 pattern: "^dsi-phy@[0-9a-f]+$"
 
   compatible:
-enum:
-  - mediatek,mt2701-mipi-tx
-  - mediatek,mt7623-mipi-tx
-  - mediatek,mt8173-mipi-tx
-  - mediatek,mt8183-mipi-tx
+oneOf:
+  - items:
+  - enum:
+  - mediatek,mt7623-mipi-tx
+  - const: mediatek,mt2701-mipi-tx
+  - const: mediatek,mt2701-mipi-tx
+  - const: mediatek,mt8173-mipi-tx
+  - const: mediatek,mt8183-mipi-tx
 
   reg:
 maxItems: 1
-- 
2.18.0



[PATCH RESEND v5 03/12] dt-bindings: phy: mediatek: tphy: change patternProperties

2021-03-25 Thread Chunfeng Yun
The phy may be named as pcie-phy when the T-PHY only supports
PCIe mode, it's also the similar case for SATA, named as
sata-phy.

Reviewed-by: Rob Herring 
Signed-off-by: Chunfeng Yun 
---
v5: no changes
v4: add reviewed-by Rob
v2~v3: no changes
---
 Documentation/devicetree/bindings/phy/mediatek,tphy.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/phy/mediatek,tphy.yaml 
b/Documentation/devicetree/bindings/phy/mediatek,tphy.yaml
index 602e6ff45785..4f1733fd9a55 100644
--- a/Documentation/devicetree/bindings/phy/mediatek,tphy.yaml
+++ b/Documentation/devicetree/bindings/phy/mediatek,tphy.yaml
@@ -117,7 +117,7 @@ properties:
 
 # Required child node:
 patternProperties:
-  "^usb-phy@[0-9a-f]+$":
+  "^(usb|pcie|sata)-phy@[0-9a-f]+$":
 type: object
 description:
   A sub-node is required for each port the controller provides.
-- 
2.18.0



[PATCH RESEND v5 05/12] arm64: dts: mediatek: mt8173: fix dtbs_check warning

2021-03-25 Thread Chunfeng Yun
Harmonize nodes names, compatibles and remove unused property.

Signed-off-by: Chunfeng Yun 
---
v2~v5: no changes
---
 arch/arm64/boot/dts/mediatek/mt8173-evb.dts |  4 +---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi| 13 +++--
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173-evb.dts 
b/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
index 6dffada2e66b..0ce81c4fe81e 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
@@ -516,10 +516,8 @@
extcon = <_usb>;
dr_mode = "otg";
wakeup-source;
-   pinctrl-names = "default", "id_float", "id_ground";
+   pinctrl-names = "default";
pinctrl-0 = <_id_pins_float>;
-   pinctrl-1 = <_id_pins_float>;
-   pinctrl-2 = <_id_pins_ground>;
status = "okay";
 };
 
diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index ecb37a7e6870..003a5653c505 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -631,7 +631,7 @@
#mbox-cells = <2>;
};
 
-   mipi_tx0: mipi-dphy@10215000 {
+   mipi_tx0: dsi-phy@10215000 {
compatible = "mediatek,mt8173-mipi-tx";
reg = <0 0x10215000 0 0x1000>;
clocks = <>;
@@ -641,7 +641,7 @@
status = "disabled";
};
 
-   mipi_tx1: mipi-dphy@10216000 {
+   mipi_tx1: dsi-phy@10216000 {
compatible = "mediatek,mt8173-mipi-tx";
reg = <0 0x10216000 0 0x1000>;
clocks = <>;
@@ -926,7 +926,7 @@
};
 
ssusb: usb@11271000 {
-   compatible = "mediatek,mt8173-mtu3";
+   compatible = "mediatek,mt8173-mtu3", "mediatek,mtu3";
reg = <0 0x11271000 0 0x3000>,
  <0 0x11280700 0 0x0100>;
reg-names = "mac", "ippc";
@@ -943,8 +943,9 @@
ranges;
status = "disabled";
 
-   usb_host: xhci@1127 {
-   compatible = "mediatek,mt8173-xhci";
+   usb_host: usb@1127 {
+   compatible = "mediatek,mt8173-xhci",
+"mediatek,mtk-xhci";
reg = <0 0x1127 0 0x1000>;
reg-names = "mac";
interrupts = ;
@@ -955,7 +956,7 @@
};
};
 
-   u3phy: usb-phy@1129 {
+   u3phy: t-phy@1129 {
compatible = "mediatek,mt8173-u3phy";
reg = <0 0x1129 0 0x800>;
#address-cells = <2>;
-- 
2.18.0



[PATCH RESEND v5 07/12] arm64: dts: mediatek: mt8516: harmonize node names and compatibles

2021-03-25 Thread Chunfeng Yun
This is used to fix dtbs_check warning:
  harmonize node names and compatibles;
  add property "usb-role-switch" for connector dependence.

Signed-off-by: Chunfeng Yun 
---
v2~v5: no changes
---
 arch/arm64/boot/dts/mediatek/mt8516.dtsi | 9 +
 arch/arm64/boot/dts/mediatek/pumpkin-common.dtsi | 1 +
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8516.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8516.dtsi
index b80e95574bef..bbe5a1419eff 100644
--- a/arch/arm64/boot/dts/mediatek/mt8516.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8516.dtsi
@@ -480,7 +480,7 @@
};
 
usb0: usb@1110 {
-   compatible = "mediatek,mtk-musb";
+   compatible = "mediatek,mt8516-musb", 
"mediatek,mtk-musb";
reg = <0 0x1110 0 0x1000>;
interrupts = ;
interrupt-names = "mc";
@@ -493,7 +493,7 @@
};
 
usb1: usb@1119 {
-   compatible = "mediatek,mtk-musb";
+   compatible = "mediatek,mt8516-musb", 
"mediatek,mtk-musb";
reg = <0 0x1119 0 0x1000>;
interrupts = ;
interrupt-names = "mc";
@@ -506,8 +506,9 @@
status = "disabled";
};
 
-   usb_phy: usb@ {
-   compatible = "mediatek,generic-tphy-v1";
+   usb_phy: t-phy@ {
+   compatible = "mediatek,mt8516-tphy",
+"mediatek,generic-tphy-v1";
reg = <0 0x 0 0x800>;
#address-cells = <2>;
#size-cells = <2>;
diff --git a/arch/arm64/boot/dts/mediatek/pumpkin-common.dtsi 
b/arch/arm64/boot/dts/mediatek/pumpkin-common.dtsi
index 63fd70086bb8..7d738f01cf8d 100644
--- a/arch/arm64/boot/dts/mediatek/pumpkin-common.dtsi
+++ b/arch/arm64/boot/dts/mediatek/pumpkin-common.dtsi
@@ -188,6 +188,7 @@
  {
status = "okay";
dr_mode = "peripheral";
+   usb-role-switch;
 
usb_con: connector {
compatible = "usb-c-connector";
-- 
2.18.0



[PATCH RESEND v5 09/12] arm64: dts: mediatek: mt8183: fix dtbs_check warning

2021-03-25 Thread Chunfeng Yun
Harmonize node names, compatibles and properties.

Signed-off-by: Chunfeng Yun 
---
v4~v5: no changes
v3: remove property clock-names suggested by CK
v2: no changes
---
 arch/arm64/boot/dts/mediatek/mt8183.dtsi | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8183.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
index 80519a145f13..8882d35ac6ab 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
@@ -880,7 +880,7 @@
ranges;
status = "disabled";
 
-   usb_host: xhci@1120 {
+   usb_host: usb@1120 {
compatible = "mediatek,mt8183-xhci",
 "mediatek,mtk-xhci";
reg = <0 0x1120 0 0x1000>;
@@ -923,11 +923,10 @@
status = "disabled";
};
 
-   mipi_tx0: mipi-dphy@11e5 {
+   mipi_tx0: dsi-phy@11e5 {
compatible = "mediatek,mt8183-mipi-tx";
reg = <0 0x11e5 0 0x1000>;
clocks = < CLK_APMIXED_MIPID0_26M>;
-   clock-names = "ref_clk";
#clock-cells = <0>;
#phy-cells = <0>;
clock-output-names = "mipi_tx0_pll";
@@ -946,11 +945,10 @@
};
};
 
-   u3phy: usb-phy@11f4 {
+   u3phy: t-phy@11f4 {
compatible = "mediatek,mt8183-tphy",
 "mediatek,generic-tphy-v2";
#address-cells = <1>;
-   #phy-cells = <1>;
#size-cells = <1>;
ranges = <0 0 0x11f4 0x1000>;
status = "okay";
-- 
2.18.0



[PATCH RESEND v5 04/12] arm64: dts: mt8173: fix property typo of 'phys' in dsi node

2021-03-25 Thread Chunfeng Yun
Use 'phys' instead of 'phy'.

Fixes: 81ad4dbaf7af ("arm64: dts: mt8173: Add display subsystem related nodes")
Cc: stable 
Reviewed-by: Chun-Kuang Hu 
Signed-off-by: Chunfeng Yun 
---
v5: merged into this series, add Reviewed-by CK
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 7fa870e4386a..ecb37a7e6870 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -1235,7 +1235,7 @@
 < CLK_MM_DSI1_DIGITAL>,
 <_tx1>;
clock-names = "engine", "digital", "hs";
-   phy = <_tx1>;
+   phys = <_tx1>;
phy-names = "dphy";
status = "disabled";
};
-- 
2.18.0



[PATCH RESEND v5 12/12] arm: dts: mt2701: harmonize node names and compatibles

2021-03-25 Thread Chunfeng Yun
This is used to fix dtbs_check warning

Signed-off-by: Chunfeng Yun 
---
v2~v5: no changes
---
 arch/arm/boot/dts/mt2701.dtsi | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi
index fade14284017..4776f85d6d5b 100644
--- a/arch/arm/boot/dts/mt2701.dtsi
+++ b/arch/arm/boot/dts/mt2701.dtsi
@@ -607,7 +607,7 @@
};
 
usb0: usb@1a1c {
-   compatible = "mediatek,mt8173-xhci";
+   compatible = "mediatek,mt2701-xhci", "mediatek,mtk-xhci";
reg = <0 0x1a1c 0 0x1000>,
  <0 0x1a1c4700 0 0x0100>;
reg-names = "mac", "ippc";
@@ -620,8 +620,9 @@
status = "disabled";
};
 
-   u3phy0: usb-phy@1a1c4000 {
-   compatible = "mediatek,mt2701-u3phy";
+   u3phy0: t-phy@1a1c4000 {
+   compatible = "mediatek,mt2701-tphy",
+"mediatek,generic-tphy-v1";
reg = <0 0x1a1c4000 0 0x0700>;
#address-cells = <2>;
#size-cells = <2>;
@@ -646,7 +647,7 @@
};
 
usb1: usb@1a24 {
-   compatible = "mediatek,mt8173-xhci";
+   compatible = "mediatek,mt2701-xhci", "mediatek,mtk-xhci";
reg = <0 0x1a24 0 0x1000>,
  <0 0x1a244700 0 0x0100>;
reg-names = "mac", "ippc";
@@ -659,8 +660,9 @@
status = "disabled";
};
 
-   u3phy1: usb-phy@1a244000 {
-   compatible = "mediatek,mt2701-u3phy";
+   u3phy1: t-phy@1a244000 {
+   compatible = "mediatek,mt2701-tphy",
+"mediatek,generic-tphy-v1";
reg = <0 0x1a244000 0 0x0700>;
#address-cells = <2>;
#size-cells = <2>;
@@ -700,8 +702,9 @@
status = "disabled";
};
 
-   u2phy0: usb-phy@1121 {
-   compatible = "mediatek,generic-tphy-v1";
+   u2phy0: t-phy@1121 {
+   compatible = "mediatek,mt2701-tphy",
+"mediatek,generic-tphy-v1";
reg = <0 0x1121 0 0x0800>;
#address-cells = <2>;
#size-cells = <2>;
-- 
2.18.0



[PATCH RESEND v5 10/12] arm: dts: mt7629: harmonize node names and compatibles

2021-03-25 Thread Chunfeng Yun
This is used to fix dtbs_check warning

Signed-off-by: Chunfeng Yun 
---
v2~v5: no changes
---
 arch/arm/boot/dts/mt7629.dtsi | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/arm/boot/dts/mt7629.dtsi b/arch/arm/boot/dts/mt7629.dtsi
index 5cbb3d244c75..874043f0490d 100644
--- a/arch/arm/boot/dts/mt7629.dtsi
+++ b/arch/arm/boot/dts/mt7629.dtsi
@@ -329,8 +329,9 @@
status = "disabled";
};
 
-   u3phy0: usb-phy@1a0c4000 {
-   compatible = "mediatek,generic-tphy-v2";
+   u3phy0: t-phy@1a0c4000 {
+   compatible = "mediatek,mt7629-tphy",
+"mediatek,generic-tphy-v2";
#address-cells = <1>;
#size-cells = <1>;
ranges = <0 0x1a0c4000 0xe00>;
@@ -413,14 +414,15 @@
};
};
 
-   pciephy1: pcie-phy@1a14a000 {
-   compatible = "mediatek,generic-tphy-v2";
+   pciephy1: t-phy@1a14a000 {
+   compatible = "mediatek,mt7629-tphy",
+"mediatek,generic-tphy-v2";
#address-cells = <1>;
#size-cells = <1>;
ranges = <0 0x1a14a000 0x1000>;
status = "disabled";
 
-   pcieport1: port1phy@0 {
+   pcieport1: pcie-phy@0 {
reg = <0 0x1000>;
clocks = <>;
clock-names = "ref";
-- 
2.18.0



[PATCH v2 06/13] usb: xhci-mtk: support ip-sleep wakeup for MT8183

2021-03-23 Thread Chunfeng Yun
Add support ip-sleep wakeup for MT8183, it's similar to MT8173,
and it's also a specific one, but not following IPM rule.
Due to the index 2 already used by many DTS, it's better to keep
it unchanged for backward compatibility, treat specific ones without
following IPM rule as revision 1.x, meanwhile reserve 3~10 for
later revision that follows the IPM rule.

Signed-off-by: Chunfeng Yun 
---
v2:
   1. fix typo suggested by Sergei
   2. fix build warning - Woverflow
   3. modify revision format
---
 drivers/usb/host/xhci-mtk.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 09f2ddbfe8b9..ef2c74281ab4 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -57,12 +57,19 @@
 #define CTRL_U2_FORCE_PLL_STB  BIT(28)
 
 /* usb remote wakeup registers in syscon */
+
 /* mt8173 etc */
 #define PERI_WK_CTRL1  0x4
 #define WC1_IS_C(x)(((x) & 0xf) << 26)  /* cycle debounce */
 #define WC1_IS_EN  BIT(25)
 #define WC1_IS_P   BIT(6)  /* polarity for ip sleep */
 
+/* mt8183 */
+#define PERI_WK_CTRL0  0x0
+#define WC0_IS_C(x)((u32)(((x) & 0xf) << 28))  /* cycle debounce */
+#define WC0_IS_P   BIT(12) /* polarity */
+#define WC0_IS_EN  BIT(6)
+
 /* mt2712 etc */
 #define PERI_SSUSB_SPM_CTRL0x0
 #define SSC_IP_SLEEP_ENBIT(4)
@@ -71,6 +78,7 @@
 enum ssusb_uwk_vers {
SSUSB_UWK_V1 = 1,
SSUSB_UWK_V2,
+   SSUSB_UWK_V1_1 = 101,   /* specific revision 1.01 */
 };
 
 static int xhci_mtk_host_enable(struct xhci_hcd_mtk *mtk)
@@ -300,6 +308,11 @@ static void usb_wakeup_ip_sleep_set(struct xhci_hcd_mtk 
*mtk, bool enable)
msk = WC1_IS_EN | WC1_IS_C(0xf) | WC1_IS_P;
val = enable ? (WC1_IS_EN | WC1_IS_C(0x8)) : 0;
break;
+   case SSUSB_UWK_V1_1:
+   reg = mtk->uwk_reg_base + PERI_WK_CTRL0;
+   msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P;
+   val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 0;
+   break;
case SSUSB_UWK_V2:
reg = mtk->uwk_reg_base + PERI_SSUSB_SPM_CTRL;
msk = SSC_IP_SLEEP_EN | SSC_SPM_INT_EN;
-- 
2.18.0



[PATCH v2 08/13] usb: xhci-mtk: drop CONFIG_OF

2021-03-23 Thread Chunfeng Yun
The driver can match only the devices created by the OF core
via the DT table, so the table should be always used.

Signed-off-by: Chunfeng Yun 
---
v2: no changes
---
 drivers/usb/host/xhci-mtk.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 24342112cd1d..832c5b8bb8a8 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -689,14 +689,12 @@ static const struct dev_pm_ops xhci_mtk_pm_ops = {
 };
 #define DEV_PM_OPS IS_ENABLED(CONFIG_PM) ? _mtk_pm_ops : NULL
 
-#ifdef CONFIG_OF
 static const struct of_device_id mtk_xhci_of_match[] = {
{ .compatible = "mediatek,mt8173-xhci"},
{ .compatible = "mediatek,mtk-xhci"},
{ },
 };
 MODULE_DEVICE_TABLE(of, mtk_xhci_of_match);
-#endif
 
 static struct platform_driver mtk_xhci_driver = {
.probe  = xhci_mtk_probe,
@@ -704,7 +702,7 @@ static struct platform_driver mtk_xhci_driver = {
.driver = {
.name = "xhci-mtk",
.pm = DEV_PM_OPS,
-   .of_match_table = of_match_ptr(mtk_xhci_of_match),
+   .of_match_table = mtk_xhci_of_match,
},
 };
 MODULE_ALIAS("platform:xhci-mtk");
-- 
2.18.0



[PATCH v2 10/13] usb: mtu3: support ip-sleep wakeup for MT8183

2021-03-23 Thread Chunfeng Yun
Add support ip-sleep wakeup for MT8183, it's similar to MT8173,
and it's also a specific one, but not following IPM rule.
Due to the index 2 already used by many DTS, it's better to keep
it unchanged for backward compatibility, treat specific ones without
following IPM rule as revision 1.x, meanwhile reserve 3~10 for later
revision that follows the IPM rule.

Signed-off-by: Chunfeng Yun 
---
v2:
   1. fix typo suggested by Sergei
   2. fix build warning - Woverflow
   3. modify revision format
---
 drivers/usb/mtu3/mtu3_host.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c
index c871b94f3e6f..398ce0014606 100644
--- a/drivers/usb/mtu3/mtu3_host.c
+++ b/drivers/usb/mtu3/mtu3_host.c
@@ -24,6 +24,12 @@
 #define WC1_IS_EN  BIT(25)
 #define WC1_IS_P   BIT(6)  /* polarity for ip sleep */
 
+/* mt8183 */
+#define PERI_WK_CTRL0  0x0
+#define WC0_IS_C(x)((u32)(((x) & 0xf) << 28))  /* cycle debounce */
+#define WC0_IS_P   BIT(12) /* polarity */
+#define WC0_IS_EN  BIT(6)
+
 /* mt2712 etc */
 #define PERI_SSUSB_SPM_CTRL0x0
 #define SSC_IP_SLEEP_ENBIT(4)
@@ -32,6 +38,7 @@
 enum ssusb_uwk_vers {
SSUSB_UWK_V1 = 1,
SSUSB_UWK_V2,
+   SSUSB_UWK_V1_1 = 101,   /* specific revision 1.01 */
 };
 
 /*
@@ -48,6 +55,11 @@ static void ssusb_wakeup_ip_sleep_set(struct ssusb_mtk 
*ssusb, bool enable)
msk = WC1_IS_EN | WC1_IS_C(0xf) | WC1_IS_P;
val = enable ? (WC1_IS_EN | WC1_IS_C(0x8)) : 0;
break;
+   case SSUSB_UWK_V1_1:
+   reg = ssusb->uwk_reg_base + PERI_WK_CTRL0;
+   msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P;
+   val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 0;
+   break;
case SSUSB_UWK_V2:
reg = ssusb->uwk_reg_base + PERI_SSUSB_SPM_CTRL;
msk = SSC_IP_SLEEP_EN | SSC_SPM_INT_EN;
-- 
2.18.0



[PATCH v2 09/13] usb: xhci-mtk: remove MODULE_ALIAS

2021-03-23 Thread Chunfeng Yun
Since the driver only supports the devices created by the OF
core, seems no need MODULE_ALIAS() anymore.

Signed-off-by: Chunfeng Yun 
---
v2: no changes
---
 drivers/usb/host/xhci-mtk.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 832c5b8bb8a8..744639d23fa8 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -705,7 +705,6 @@ static struct platform_driver mtk_xhci_driver = {
.of_match_table = mtk_xhci_of_match,
},
 };
-MODULE_ALIAS("platform:xhci-mtk");
 
 static int __init xhci_mtk_init(void)
 {
-- 
2.18.0



[PATCH v2 11/13] usb: mtu3: add support ip-sleep wakeup for MT8192

2021-03-23 Thread Chunfeng Yun
Add add support ip-sleep wakeup for MT8192, it's a specific
revision, not following IPM rule.

Signed-off-by: Chunfeng Yun 
---
v2:
   1. fix typo suggested by Sergei
   2. modify revision format
---
 drivers/usb/mtu3/mtu3_host.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c
index 398ce0014606..e3c923e6529f 100644
--- a/drivers/usb/mtu3/mtu3_host.c
+++ b/drivers/usb/mtu3/mtu3_host.c
@@ -30,6 +30,10 @@
 #define WC0_IS_P   BIT(12) /* polarity */
 #define WC0_IS_EN  BIT(6)
 
+/* mt8192 */
+#define WC0_SSUSB0_CDENBIT(6)
+#define WC0_IS_SPM_EN  BIT(1)
+
 /* mt2712 etc */
 #define PERI_SSUSB_SPM_CTRL0x0
 #define SSC_IP_SLEEP_ENBIT(4)
@@ -39,6 +43,7 @@ enum ssusb_uwk_vers {
SSUSB_UWK_V1 = 1,
SSUSB_UWK_V2,
SSUSB_UWK_V1_1 = 101,   /* specific revision 1.01 */
+   SSUSB_UWK_V1_2, /* specific revision 1.02 */
 };
 
 /*
@@ -60,6 +65,11 @@ static void ssusb_wakeup_ip_sleep_set(struct ssusb_mtk 
*ssusb, bool enable)
msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P;
val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 0;
break;
+   case SSUSB_UWK_V1_2:
+   reg = ssusb->uwk_reg_base + PERI_WK_CTRL0;
+   msk = WC0_SSUSB0_CDEN | WC0_IS_SPM_EN;
+   val = enable ? msk : 0;
+   break;
case SSUSB_UWK_V2:
reg = ssusb->uwk_reg_base + PERI_SSUSB_SPM_CTRL;
msk = SSC_IP_SLEEP_EN | SSC_SPM_INT_EN;
-- 
2.18.0



[PATCH v2 13/13] arm64: dts: mt8183: update wakeup register offset

2021-03-23 Thread Chunfeng Yun
Use wakeup control register offset exactly, and update revision
number

Signed-off-by: Chunfeng Yun 
---
v2: modify revision format
---
 arch/arm64/boot/dts/mediatek/mt8183.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8183.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
index 80519a145f13..9ea84d636556 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
@@ -874,7 +874,7 @@
clocks = < CLK_INFRA_UNIPRO_SCK>,
 < CLK_INFRA_USB>;
clock-names = "sys_ck", "ref_ck";
-   mediatek,syscon-wakeup = < 0x400 0>;
+   mediatek,syscon-wakeup = < 0x420 101>;
#address-cells = <2>;
#size-cells = <2>;
ranges;
-- 
2.18.0



[PATCH v2 12/13] usb: mtu3: drop CONFIG_OF

2021-03-23 Thread Chunfeng Yun
The driver can match only the devices created by the OF core
via the DT table, so the table should be always used.

Signed-off-by: Chunfeng Yun 
---
v2: no changes
---
 drivers/usb/mtu3/mtu3_plat.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
index d44d5417438d..7786a95a874e 100644
--- a/drivers/usb/mtu3/mtu3_plat.c
+++ b/drivers/usb/mtu3/mtu3_plat.c
@@ -502,25 +502,20 @@ static const struct dev_pm_ops mtu3_pm_ops = {
 
 #define DEV_PM_OPS (IS_ENABLED(CONFIG_PM) ? _pm_ops : NULL)
 
-#ifdef CONFIG_OF
-
 static const struct of_device_id mtu3_of_match[] = {
{.compatible = "mediatek,mt8173-mtu3",},
{.compatible = "mediatek,mtu3",},
{},
 };
-
 MODULE_DEVICE_TABLE(of, mtu3_of_match);
 
-#endif
-
 static struct platform_driver mtu3_driver = {
.probe = mtu3_probe,
.remove = mtu3_remove,
.driver = {
.name = MTU3_DRIVER_NAME,
.pm = DEV_PM_OPS,
-   .of_match_table = of_match_ptr(mtu3_of_match),
+   .of_match_table = mtu3_of_match,
},
 };
 module_platform_driver(mtu3_driver);
-- 
2.18.0



[PATCH v2 07/13] usb: xhci-mtk: add support ip-sleep wakeup for mT8192

2021-03-23 Thread Chunfeng Yun
Add support ip-sleep wakeup for mT8192, it's a specific revision,
and not following IPM rule.

Signed-off-by: Chunfeng Yun 
---
v2:
   1. fix typo suggested by Sergei
   2. modify revision format
---
 drivers/usb/host/xhci-mtk.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index ef2c74281ab4..24342112cd1d 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -70,6 +70,10 @@
 #define WC0_IS_P   BIT(12) /* polarity */
 #define WC0_IS_EN  BIT(6)
 
+/* mt8192 */
+#define WC0_SSUSB0_CDENBIT(6)
+#define WC0_IS_SPM_EN  BIT(1)
+
 /* mt2712 etc */
 #define PERI_SSUSB_SPM_CTRL0x0
 #define SSC_IP_SLEEP_ENBIT(4)
@@ -79,6 +83,7 @@ enum ssusb_uwk_vers {
SSUSB_UWK_V1 = 1,
SSUSB_UWK_V2,
SSUSB_UWK_V1_1 = 101,   /* specific revision 1.01 */
+   SSUSB_UWK_V1_2, /* specific revision 1.2 */
 };
 
 static int xhci_mtk_host_enable(struct xhci_hcd_mtk *mtk)
@@ -313,6 +318,11 @@ static void usb_wakeup_ip_sleep_set(struct xhci_hcd_mtk 
*mtk, bool enable)
msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P;
val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 0;
break;
+   case SSUSB_UWK_V1_2:
+   reg = mtk->uwk_reg_base + PERI_WK_CTRL0;
+   msk = WC0_SSUSB0_CDEN | WC0_IS_SPM_EN;
+   val = enable ? msk : 0;
+   break;
case SSUSB_UWK_V2:
reg = mtk->uwk_reg_base + PERI_SSUSB_SPM_CTRL;
msk = SSC_IP_SLEEP_EN | SSC_SPM_INT_EN;
-- 
2.18.0



[PATCH v2 04/13] usb: xhci-mtk: fix broken streams issue on 0.96 xHCI

2021-03-23 Thread Chunfeng Yun
The MediaTek 0.96 xHCI controller on some platforms does not
support bulk stream even HCCPARAMS says supporting, due to MaxPSASize
is set a default value 1 by mistake, here use XHCI_BROKEN_STREAMS
quirk to fix it.

Fixes: 94a631d91ad3 ("usb: xhci-mtk: check hcc_params after adding primary hcd")
Signed-off-by: Chunfeng Yun 
---
v2: no changes
---
 drivers/usb/host/xhci-mtk.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 57bcfdfa0465..1b9f10048fe0 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -388,6 +388,13 @@ static void xhci_mtk_quirks(struct device *dev, struct 
xhci_hcd *xhci)
xhci->quirks |= XHCI_SPURIOUS_SUCCESS;
if (mtk->lpm_support)
xhci->quirks |= XHCI_LPM_SUPPORT;
+
+   /*
+* MTK xHCI 0.96: PSA is 1 by default even if doesn't support stream,
+* and it's 3 when support it.
+*/
+   if (xhci->hci_version < 0x100 && HCC_MAX_PSA(xhci->hcc_params) == 4)
+   xhci->quirks |= XHCI_BROKEN_STREAMS;
 }
 
 /* called during probe() after chip reset completes */
@@ -549,7 +556,8 @@ static int xhci_mtk_probe(struct platform_device *pdev)
if (ret)
goto put_usb3_hcd;
 
-   if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
+   if (HCC_MAX_PSA(xhci->hcc_params) >= 4 &&
+   !(xhci->quirks & XHCI_BROKEN_STREAMS))
xhci->shared_hcd->can_do_streams = 1;
 
ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
-- 
2.18.0



[PATCH v2 05/13] usb: xhci-mtk: support quirk to disable usb2 lpm

2021-03-23 Thread Chunfeng Yun
The xHCI driver support usb2 HW LPM by default, here add support
XHCI_HW_LPM_DISABLE quirk, then we can disable usb2 lpm when
need it.

Signed-off-by: Chunfeng Yun 
---
v2: no changes
---
 drivers/usb/host/xhci-mtk.c | 3 +++
 drivers/usb/host/xhci-mtk.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 1b9f10048fe0..09f2ddbfe8b9 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -388,6 +388,8 @@ static void xhci_mtk_quirks(struct device *dev, struct 
xhci_hcd *xhci)
xhci->quirks |= XHCI_SPURIOUS_SUCCESS;
if (mtk->lpm_support)
xhci->quirks |= XHCI_LPM_SUPPORT;
+   if (mtk->u2_lpm_disable)
+   xhci->quirks |= XHCI_HW_LPM_DISABLE;
 
/*
 * MTK xHCI 0.96: PSA is 1 by default even if doesn't support stream,
@@ -470,6 +472,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
return ret;
 
mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable");
+   mtk->u2_lpm_disable = of_property_read_bool(node, "usb2-lpm-disable");
/* optional property, ignore the error if it does not exist */
of_property_read_u32(node, "mediatek,u3p-dis-msk",
 >u3p_dis_msk);
diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
index 621ec1a85009..4ccd08e20a15 100644
--- a/drivers/usb/host/xhci-mtk.h
+++ b/drivers/usb/host/xhci-mtk.h
@@ -149,6 +149,7 @@ struct xhci_hcd_mtk {
struct phy **phys;
int num_phys;
bool lpm_support;
+   bool u2_lpm_disable;
/* usb remote wakeup */
bool uwk_en;
struct regmap *uwk;
-- 
2.18.0



[PATCH v2 01/13] dt-bindings: usb: mtk-xhci: support property usb2-lpm-disable

2021-03-23 Thread Chunfeng Yun
Add support common property usb2-lpm-disable

Signed-off-by: Chunfeng Yun 
---
v2: no changes
---
 Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml | 4 
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml 
b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
index 14f40efb3b22..2246d29a5e4e 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
@@ -103,6 +103,10 @@ properties:
 description: supports USB3.0 LPM
 type: boolean
 
+  usb2-lpm-disable:
+description: disable USB2 HW LPM
+type: boolean
+
   imod-interval-ns:
 description:
   Interrupt moderation interval value, it is 8 times as much as that
-- 
2.18.0



[PATCH v2 03/13] dt-bindings: usb: mtu3: support wakeup for mt8183 and mt8192

2021-03-23 Thread Chunfeng Yun
These two HW of wakeup don't follow MediaTek internal IPM rule,
and both use a specific way, like as early revision of mt8173.

Due to the index 2 already used by many DTS, it's better to keep
it unchanged for backward compatibility, treat specific ones without
following IPM rule as revision 1.x, meanwhile reserve 3~99 for
later revision that following the IPM rule.

Signed-off-by: Chunfeng Yun 
---
v2: modify revision format
---
 .../devicetree/bindings/usb/mediatek,mtu3.yaml | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml 
b/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
index f5c04b9d2de9..8e37403520ff 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
@@ -24,6 +24,7 @@ properties:
   - mediatek,mt2712-mtu3
   - mediatek,mt8173-mtu3
   - mediatek,mt8183-mtu3
+  - mediatek,mt8192-mtu3
   - const: mediatek,mtu3
 
   reg:
@@ -152,10 +153,13 @@ properties:
 - description:
 The second cell represents the register base address of the glue
 layer in syscon
-- description:
+- description: |
 The third cell represents the hardware version of the glue layer,
-1 is used by mt8173 etc, 2 is used by mt2712 etc
-  enum: [1, 2]
+1 - used by mt8173 etc, revision 1 without following IPM rule;
+2 - used by mt2712 etc, revision 2 with following IPM rule;
+101 - used by mt8183, specific 1.01;
+102 - used by mt8192, specific 1.02;
+  enum: [1, 2, 101, 102]
 
   mediatek,u3p-dis-msk:
 $ref: /schemas/types.yaml#/definitions/uint32
-- 
2.18.0



[PATCH v2 02/13] dt-bindings: usb: mtk-xhci: add support wakeup for mt8183 and mt8192

2021-03-23 Thread Chunfeng Yun
These two HW of wakeup don't follow MediaTek internal IPM rule,
both use a specific way, like as early revision of mt8173.

Due to the index 2 already used by many DTS, it's better to keep
it unchanged for backward compatibility, treat specific ones without
following IPM rule as revision 1.x, meanwhile reserve 3~99 for
later revisions with following the IPM rule.

Signed-off-by: Chunfeng Yun 
---
v2: modify revision format
---
 .../devicetree/bindings/usb/mediatek,mtk-xhci.yaml | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml 
b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
index 2246d29a5e4e..2bdf8997d836 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
@@ -30,6 +30,7 @@ properties:
   - mediatek,mt7629-xhci
   - mediatek,mt8173-xhci
   - mediatek,mt8183-xhci
+  - mediatek,mt8192-xhci
   - const: mediatek,mtk-xhci
 
   reg:
@@ -131,10 +132,13 @@ properties:
 - description:
 The second cell represents the register base address of the glue
 layer in syscon
-- description:
+- description: |
 The third cell represents the hardware version of the glue layer,
-1 is used by mt8173 etc, 2 is used by mt2712 etc
-  enum: [1, 2]
+1 - used by mt8173 etc, revision 1 without following IPM rule;
+2 - used by mt2712 etc, revision 2 following IPM rule;
+101 - used by mt8183, specific 1.01;
+102 - used by mt8192, specific 1.02;
+  enum: [1, 2, 101, 102]
 
   mediatek,u3p-dis-msk:
 $ref: /schemas/types.yaml#/definitions/uint32
-- 
2.18.0



Re: [PATCH v2 8/8] arm64: dts: Add Mediatek SoC MT8195 and evaluation board dts and Makefile

2021-03-22 Thread Chunfeng Yun
  #address-cells = <1>;
> + #size-cells = <1>;
> + ranges = <0 0 0x11e4 0xe00>;
> + status = "disabled";
> +
> + u2port0: usb-phy@0 {
> + reg = <0x0 0x700>;
> + clocks = <>;
> + clock-names = "ref";
> + #phy-cells = <1>;
> + };
> +
> + u3port0: usb-phy@700 {
> + reg = <0x700 0x700>;
> + clocks = <>;
> + clock-names = "ref";
> + #phy-cells = <1>;
> + };
> + };
> +
> + ufsphy: phy@11fa {
> + compatible = "mediatek,mt8195-ufsphy", 
> "mediatek,mt8183-ufsphy";
> + reg = <0 0x11fa 0 0xc000>;
> + clocks = <>, <>;
> + clock-names = "unipro", "mp";
> + #phy-cells = <0>;
> + status = "disabled";
> + };
> + };
> +};
phy part:

Reviewed-by: Chunfeng Yun 

Thank you




Re: [PATCH 10/13] usb: mtu3: support ip-sleep wakeup for MT8183

2021-03-22 Thread Chunfeng Yun
On Mon, 2021-03-22 at 11:57 +0300, Sergei Shtylyov wrote:
> Same comments as to the patch #6.
Ok, will check others, thanks a lot

> 
> MBR, Sergei



Re: [PATCH 07/13] usb: xhci-mtk: add support ip-sleep wakeup for mT8192

2021-03-22 Thread Chunfeng Yun
On Mon, 2021-03-22 at 11:58 +0300, Sergei Shtylyov wrote:
> On 22.03.2021 6:13, Chunfeng Yun wrote:
> 
> > Add support ip-sleep wakeup for mT8192, it's a specific revision,
>   ^ for
> 
> > and not follow IPM rule.
> 
> Following?
> 
> > Signed-off-by: Chunfeng Yun 
> > ---
> >   drivers/usb/host/xhci-mtk.c | 10 ++
> >   1 file changed, 10 insertions(+)
> > 
> > diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
> > index 8ba1f914cb75..1bfa28c9b5a2 100644
> > --- a/drivers/usb/host/xhci-mtk.c
> > +++ b/drivers/usb/host/xhci-mtk.c
> > @@ -70,6 +70,10 @@
> >   #define WC0_IS_P  BIT(12) /* polarity */
> >   #define WC0_IS_EN BIT(6)
> >   
> > +/* mt8192 */
> > +#define WC0_SSUSB0_CDENBIT(6)
> > +#define WC0_IS_SPM_EN  BIT(1)
> > +
> >   /* mt2712 etc */
> >   #define PERI_SSUSB_SPM_CTRL   0x0
> >   #define SSC_IP_SLEEP_EN   BIT(4)
> > @@ -79,6 +83,7 @@ enum ssusb_uwk_vers {
> > SSUSB_UWK_V1 = 1,
> > SSUSB_UWK_V2,
> > SSUSB_UWK_V11 = 11, /* specific revision 1.1 */
> > +   SSUSB_UWK_V12,  /* specific revision 1.2 */
> 
> SSUSB_UWK_V1_2, maybe?
Ok, will do it, thanks a lot

> 
> [...]
> 
> MBR, Sergei



Re: [PATCH 06/13] usb: xhci-mtk: support ip-sleep wakeup for MT8183

2021-03-22 Thread Chunfeng Yun
On Mon, 2021-03-22 at 11:54 +0300, Sergei Shtylyov wrote:
> Hello!
> 
> On 22.03.2021 6:13, Chunfeng Yun wrote:
> 
> > Add support ip-sleep wakeup for MT8183, it's similar to MT8173,
>   ^ for
> 
> > and it's also a specific one, but not follow IPM rule.
> 
> Following?
Ack
> 
> > Due to the index 2 already used by many DTS, it's better to keep
> > it unchanged for backward compatible, treat specific ones without
> 
> Compatibility.
Ack
> 
> > following IPM rule as revision 1.x, meanwhile reserve 3~10 for
> > later revision that follows the IPM rule.
> > 
> > Signed-off-by: Chunfeng Yun 
> > ---
> >   drivers/usb/host/xhci-mtk.c | 13 +
> >   1 file changed, 13 insertions(+)
> > 
> > diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
> > index 09f2ddbfe8b9..8ba1f914cb75 100644
> > --- a/drivers/usb/host/xhci-mtk.c
> > +++ b/drivers/usb/host/xhci-mtk.c
> > @@ -57,12 +57,19 @@
> >   #define CTRL_U2_FORCE_PLL_STB BIT(28)
> >   
> >   /* usb remote wakeup registers in syscon */
> > +
> >   /* mt8173 etc */
> >   #define PERI_WK_CTRL1 0x4
> >   #define WC1_IS_C(x)   (((x) & 0xf) << 26)  /* cycle debounce */
> >   #define WC1_IS_EN BIT(25)
> >   #define WC1_IS_P  BIT(6)  /* polarity for ip sleep */
> >   
> > +/* mt8183 */
> > +#define PERI_WK_CTRL0  0x0
> > +#define WC0_IS_C(x)(((x) & 0xf) << 28)  /* cycle debounce */
> > +#define WC0_IS_P   BIT(12) /* polarity */
> > +#define WC0_IS_EN  BIT(6)
> > +
> >   /* mt2712 etc */
> >   #define PERI_SSUSB_SPM_CTRL   0x0
> >   #define SSC_IP_SLEEP_EN   BIT(4)
> > @@ -71,6 +78,7 @@
> >   enum ssusb_uwk_vers {
> > SSUSB_UWK_V1 = 1,
> > SSUSB_UWK_V2,
> > +   SSUSB_UWK_V11 = 11, /* specific revision 1.1 */
> 
> SSUSB_UWK_V1_1, maybe?
Good point, will modify it.

Thanks a lot

> 
> [...]
> 
> MBR, Sergei



[PATCH 12/13] usb: mtu3: drop CONFIG_OF

2021-03-21 Thread Chunfeng Yun
The driver can match only the devices created by the OF core
via the DT table, so the table should be always used.

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/mtu3/mtu3_plat.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
index d44d5417438d..7786a95a874e 100644
--- a/drivers/usb/mtu3/mtu3_plat.c
+++ b/drivers/usb/mtu3/mtu3_plat.c
@@ -502,25 +502,20 @@ static const struct dev_pm_ops mtu3_pm_ops = {
 
 #define DEV_PM_OPS (IS_ENABLED(CONFIG_PM) ? _pm_ops : NULL)
 
-#ifdef CONFIG_OF
-
 static const struct of_device_id mtu3_of_match[] = {
{.compatible = "mediatek,mt8173-mtu3",},
{.compatible = "mediatek,mtu3",},
{},
 };
-
 MODULE_DEVICE_TABLE(of, mtu3_of_match);
 
-#endif
-
 static struct platform_driver mtu3_driver = {
.probe = mtu3_probe,
.remove = mtu3_remove,
.driver = {
.name = MTU3_DRIVER_NAME,
.pm = DEV_PM_OPS,
-   .of_match_table = of_match_ptr(mtu3_of_match),
+   .of_match_table = mtu3_of_match,
},
 };
 module_platform_driver(mtu3_driver);
-- 
2.18.0



[PATCH 11/13] usb: mtu3: add support ip-sleep wakeup for MT8192

2021-03-21 Thread Chunfeng Yun
Add add support ip-sleep wakeup for MT8192, it's a specific
revision, not follow IP rule.

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/mtu3/mtu3_host.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c
index e35b17e5f58e..601656f436a1 100644
--- a/drivers/usb/mtu3/mtu3_host.c
+++ b/drivers/usb/mtu3/mtu3_host.c
@@ -30,6 +30,10 @@
 #define WC0_IS_P   BIT(12) /* polarity */
 #define WC0_IS_EN  BIT(6)
 
+/* mt8192 */
+#define WC0_SSUSB0_CDENBIT(6)
+#define WC0_IS_SPM_EN  BIT(1)
+
 /* mt2712 etc */
 #define PERI_SSUSB_SPM_CTRL0x0
 #define SSC_IP_SLEEP_ENBIT(4)
@@ -39,6 +43,7 @@ enum ssusb_uwk_vers {
SSUSB_UWK_V1 = 1,
SSUSB_UWK_V2,
SSUSB_UWK_V11 = 11, /* specific revision 1.1 */
+   SSUSB_UWK_V12,  /* specific revision 1.2 */
 };
 
 /*
@@ -60,6 +65,11 @@ static void ssusb_wakeup_ip_sleep_set(struct ssusb_mtk 
*ssusb, bool enable)
msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P;
val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 0;
break;
+   case SSUSB_UWK_V12:
+   reg = ssusb->uwk_reg_base + PERI_WK_CTRL0;
+   msk = WC0_SSUSB0_CDEN | WC0_IS_SPM_EN;
+   val = enable ? msk : 0;
+   break;
case SSUSB_UWK_V2:
reg = ssusb->uwk_reg_base + PERI_SSUSB_SPM_CTRL;
msk = SSC_IP_SLEEP_EN | SSC_SPM_INT_EN;
-- 
2.18.0



[PATCH 13/13] arm64: dts: mt8183: update wakeup register offset

2021-03-21 Thread Chunfeng Yun
Use wakeup control register offset exactly, and update revision
number

Signed-off-by: Chunfeng Yun 
---
 arch/arm64/boot/dts/mediatek/mt8183.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8183.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
index 80519a145f13..9d18a938150c 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
@@ -874,7 +874,7 @@
clocks = < CLK_INFRA_UNIPRO_SCK>,
 < CLK_INFRA_USB>;
clock-names = "sys_ck", "ref_ck";
-   mediatek,syscon-wakeup = < 0x400 0>;
+   mediatek,syscon-wakeup = < 0x420 11>;
#address-cells = <2>;
#size-cells = <2>;
ranges;
-- 
2.18.0



[PATCH 06/13] usb: xhci-mtk: support ip-sleep wakeup for MT8183

2021-03-21 Thread Chunfeng Yun
Add support ip-sleep wakeup for MT8183, it's similar to MT8173,
and it's also a specific one, but not follow IPM rule.
Due to the index 2 already used by many DTS, it's better to keep
it unchanged for backward compatible, treat specific ones without
following IPM rule as revision 1.x, meanwhile reserve 3~10 for
later revision that follows the IPM rule.

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mtk.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 09f2ddbfe8b9..8ba1f914cb75 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -57,12 +57,19 @@
 #define CTRL_U2_FORCE_PLL_STB  BIT(28)
 
 /* usb remote wakeup registers in syscon */
+
 /* mt8173 etc */
 #define PERI_WK_CTRL1  0x4
 #define WC1_IS_C(x)(((x) & 0xf) << 26)  /* cycle debounce */
 #define WC1_IS_EN  BIT(25)
 #define WC1_IS_P   BIT(6)  /* polarity for ip sleep */
 
+/* mt8183 */
+#define PERI_WK_CTRL0  0x0
+#define WC0_IS_C(x)(((x) & 0xf) << 28)  /* cycle debounce */
+#define WC0_IS_P   BIT(12) /* polarity */
+#define WC0_IS_EN  BIT(6)
+
 /* mt2712 etc */
 #define PERI_SSUSB_SPM_CTRL0x0
 #define SSC_IP_SLEEP_ENBIT(4)
@@ -71,6 +78,7 @@
 enum ssusb_uwk_vers {
SSUSB_UWK_V1 = 1,
SSUSB_UWK_V2,
+   SSUSB_UWK_V11 = 11, /* specific revision 1.1 */
 };
 
 static int xhci_mtk_host_enable(struct xhci_hcd_mtk *mtk)
@@ -300,6 +308,11 @@ static void usb_wakeup_ip_sleep_set(struct xhci_hcd_mtk 
*mtk, bool enable)
msk = WC1_IS_EN | WC1_IS_C(0xf) | WC1_IS_P;
val = enable ? (WC1_IS_EN | WC1_IS_C(0x8)) : 0;
break;
+   case SSUSB_UWK_V11:
+   reg = mtk->uwk_reg_base + PERI_WK_CTRL0;
+   msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P;
+   val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 0;
+   break;
case SSUSB_UWK_V2:
reg = mtk->uwk_reg_base + PERI_SSUSB_SPM_CTRL;
msk = SSC_IP_SLEEP_EN | SSC_SPM_INT_EN;
-- 
2.18.0



[PATCH 09/13] usb: xhci-mtk: remove MODULE_ALIAS

2021-03-21 Thread Chunfeng Yun
Since the driver only supports the devices created by the OF
core, seems no need MODULE_ALIAS() anymore.

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mtk.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 7b49064ae5d4..888666c9d7bc 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -705,7 +705,6 @@ static struct platform_driver mtk_xhci_driver = {
.of_match_table = mtk_xhci_of_match,
},
 };
-MODULE_ALIAS("platform:xhci-mtk");
 
 static int __init xhci_mtk_init(void)
 {
-- 
2.18.0



[PATCH 02/13] dt-bindings: usb: mtk-xhci: add support wakeup for mt8183 and mt8192

2021-03-21 Thread Chunfeng Yun
These two HW of wakeup don't follow MediaTek internal IPM rule,
both use a specific way, like as early revision of mt8173.

Due to the index 2 already used by many DTS, it's better to keep
it unchanged for backward compatible, treat specific ones without
following IPM rule as revision 1.x, meanwhile reserve 3~10 for
later revisions with following the IPM rule.

Signed-off-by: Chunfeng Yun 
---
 .../devicetree/bindings/usb/mediatek,mtk-xhci.yaml | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml 
b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
index 2246d29a5e4e..f5dff7fb5755 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
@@ -30,6 +30,7 @@ properties:
   - mediatek,mt7629-xhci
   - mediatek,mt8173-xhci
   - mediatek,mt8183-xhci
+  - mediatek,mt8192-xhci
   - const: mediatek,mtk-xhci
 
   reg:
@@ -131,10 +132,13 @@ properties:
 - description:
 The second cell represents the register base address of the glue
 layer in syscon
-- description:
+- description: |
 The third cell represents the hardware version of the glue layer,
-1 is used by mt8173 etc, 2 is used by mt2712 etc
-  enum: [1, 2]
+1 - used by mt8173 etc, revision 1 without following IPM rule;
+2 - used by mt2712 etc, revision 2 following IPM rule;
+11 - used by mt8183, specific 1.1;
+12 - used by mt8192, specific 1.2;
+  enum: [1, 2, 11, 12]
 
   mediatek,u3p-dis-msk:
 $ref: /schemas/types.yaml#/definitions/uint32
-- 
2.18.0



[PATCH 08/13] usb: xhci-mtk: drop CONFIG_OF

2021-03-21 Thread Chunfeng Yun
The driver can match only the devices created by the OF core
via the DT table, so the table should be always used.

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mtk.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 1bfa28c9b5a2..7b49064ae5d4 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -689,14 +689,12 @@ static const struct dev_pm_ops xhci_mtk_pm_ops = {
 };
 #define DEV_PM_OPS IS_ENABLED(CONFIG_PM) ? _mtk_pm_ops : NULL
 
-#ifdef CONFIG_OF
 static const struct of_device_id mtk_xhci_of_match[] = {
{ .compatible = "mediatek,mt8173-xhci"},
{ .compatible = "mediatek,mtk-xhci"},
{ },
 };
 MODULE_DEVICE_TABLE(of, mtk_xhci_of_match);
-#endif
 
 static struct platform_driver mtk_xhci_driver = {
.probe  = xhci_mtk_probe,
@@ -704,7 +702,7 @@ static struct platform_driver mtk_xhci_driver = {
.driver = {
.name = "xhci-mtk",
.pm = DEV_PM_OPS,
-   .of_match_table = of_match_ptr(mtk_xhci_of_match),
+   .of_match_table = mtk_xhci_of_match,
},
 };
 MODULE_ALIAS("platform:xhci-mtk");
-- 
2.18.0



[PATCH 10/13] usb: mtu3: support ip-sleep wakeup for MT8183

2021-03-21 Thread Chunfeng Yun
Add support ip-sleep wakeup for MT8183, it's similar to MT8173,
and it's also a specific one, but not follow IPM rule.
Due to the index 2 already used by many DTS, it's better to keep
it unchanged for backward compatible, treat specific ones without
following IPM rule as revision 1.x, meanwhile reserve 3~10 for later
revision that follows the IPM rule.

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/mtu3/mtu3_host.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c
index c871b94f3e6f..e35b17e5f58e 100644
--- a/drivers/usb/mtu3/mtu3_host.c
+++ b/drivers/usb/mtu3/mtu3_host.c
@@ -24,6 +24,12 @@
 #define WC1_IS_EN  BIT(25)
 #define WC1_IS_P   BIT(6)  /* polarity for ip sleep */
 
+/* mt8183 */
+#define PERI_WK_CTRL0  0x0
+#define WC0_IS_C(x)(((x) & 0xf) << 28)  /* cycle debounce */
+#define WC0_IS_P   BIT(12) /* polarity */
+#define WC0_IS_EN  BIT(6)
+
 /* mt2712 etc */
 #define PERI_SSUSB_SPM_CTRL0x0
 #define SSC_IP_SLEEP_ENBIT(4)
@@ -32,6 +38,7 @@
 enum ssusb_uwk_vers {
SSUSB_UWK_V1 = 1,
SSUSB_UWK_V2,
+   SSUSB_UWK_V11 = 11, /* specific revision 1.1 */
 };
 
 /*
@@ -48,6 +55,11 @@ static void ssusb_wakeup_ip_sleep_set(struct ssusb_mtk 
*ssusb, bool enable)
msk = WC1_IS_EN | WC1_IS_C(0xf) | WC1_IS_P;
val = enable ? (WC1_IS_EN | WC1_IS_C(0x8)) : 0;
break;
+   case SSUSB_UWK_V11:
+   reg = ssusb->uwk_reg_base + PERI_WK_CTRL0;
+   msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P;
+   val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 0;
+   break;
case SSUSB_UWK_V2:
reg = ssusb->uwk_reg_base + PERI_SSUSB_SPM_CTRL;
msk = SSC_IP_SLEEP_EN | SSC_SPM_INT_EN;
-- 
2.18.0



[PATCH 05/13] usb: xhci-mtk: support quirk to disable usb2 lpm

2021-03-21 Thread Chunfeng Yun
The xHCI driver support usb2 HW LPM by default, here add support
XHCI_HW_LPM_DISABLE quirk, then we can disable usb2 lpm when
need it.

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mtk.c | 3 +++
 drivers/usb/host/xhci-mtk.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 1b9f10048fe0..09f2ddbfe8b9 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -388,6 +388,8 @@ static void xhci_mtk_quirks(struct device *dev, struct 
xhci_hcd *xhci)
xhci->quirks |= XHCI_SPURIOUS_SUCCESS;
if (mtk->lpm_support)
xhci->quirks |= XHCI_LPM_SUPPORT;
+   if (mtk->u2_lpm_disable)
+   xhci->quirks |= XHCI_HW_LPM_DISABLE;
 
/*
 * MTK xHCI 0.96: PSA is 1 by default even if doesn't support stream,
@@ -470,6 +472,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
return ret;
 
mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable");
+   mtk->u2_lpm_disable = of_property_read_bool(node, "usb2-lpm-disable");
/* optional property, ignore the error if it does not exist */
of_property_read_u32(node, "mediatek,u3p-dis-msk",
 >u3p_dis_msk);
diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
index 621ec1a85009..4ccd08e20a15 100644
--- a/drivers/usb/host/xhci-mtk.h
+++ b/drivers/usb/host/xhci-mtk.h
@@ -149,6 +149,7 @@ struct xhci_hcd_mtk {
struct phy **phys;
int num_phys;
bool lpm_support;
+   bool u2_lpm_disable;
/* usb remote wakeup */
bool uwk_en;
struct regmap *uwk;
-- 
2.18.0



[PATCH 07/13] usb: xhci-mtk: add support ip-sleep wakeup for mT8192

2021-03-21 Thread Chunfeng Yun
Add support ip-sleep wakeup for mT8192, it's a specific revision,
and not follow IPM rule.

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mtk.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 8ba1f914cb75..1bfa28c9b5a2 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -70,6 +70,10 @@
 #define WC0_IS_P   BIT(12) /* polarity */
 #define WC0_IS_EN  BIT(6)
 
+/* mt8192 */
+#define WC0_SSUSB0_CDENBIT(6)
+#define WC0_IS_SPM_EN  BIT(1)
+
 /* mt2712 etc */
 #define PERI_SSUSB_SPM_CTRL0x0
 #define SSC_IP_SLEEP_ENBIT(4)
@@ -79,6 +83,7 @@ enum ssusb_uwk_vers {
SSUSB_UWK_V1 = 1,
SSUSB_UWK_V2,
SSUSB_UWK_V11 = 11, /* specific revision 1.1 */
+   SSUSB_UWK_V12,  /* specific revision 1.2 */
 };
 
 static int xhci_mtk_host_enable(struct xhci_hcd_mtk *mtk)
@@ -313,6 +318,11 @@ static void usb_wakeup_ip_sleep_set(struct xhci_hcd_mtk 
*mtk, bool enable)
msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P;
val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 0;
break;
+   case SSUSB_UWK_V12:
+   reg = mtk->uwk_reg_base + PERI_WK_CTRL0;
+   msk = WC0_SSUSB0_CDEN | WC0_IS_SPM_EN;
+   val = enable ? msk : 0;
+   break;
case SSUSB_UWK_V2:
reg = mtk->uwk_reg_base + PERI_SSUSB_SPM_CTRL;
msk = SSC_IP_SLEEP_EN | SSC_SPM_INT_EN;
-- 
2.18.0



[PATCH 04/13] usb: xhci-mtk: fix broken streams issue on 0.96 xHCI

2021-03-21 Thread Chunfeng Yun
The MediaTek 0.96 xHCI controller on some platforms does not
support bulk stream even HCCPARAMS says supporting, due to MaxPSASize
is set a default value 1 by mistake, here use XHCI_BROKEN_STREAMS
quirk to fix it.

Fixes: 94a631d91ad3 ("usb: xhci-mtk: check hcc_params after adding primary hcd")
Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci-mtk.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 57bcfdfa0465..1b9f10048fe0 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -388,6 +388,13 @@ static void xhci_mtk_quirks(struct device *dev, struct 
xhci_hcd *xhci)
xhci->quirks |= XHCI_SPURIOUS_SUCCESS;
if (mtk->lpm_support)
xhci->quirks |= XHCI_LPM_SUPPORT;
+
+   /*
+* MTK xHCI 0.96: PSA is 1 by default even if doesn't support stream,
+* and it's 3 when support it.
+*/
+   if (xhci->hci_version < 0x100 && HCC_MAX_PSA(xhci->hcc_params) == 4)
+   xhci->quirks |= XHCI_BROKEN_STREAMS;
 }
 
 /* called during probe() after chip reset completes */
@@ -549,7 +556,8 @@ static int xhci_mtk_probe(struct platform_device *pdev)
if (ret)
goto put_usb3_hcd;
 
-   if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
+   if (HCC_MAX_PSA(xhci->hcc_params) >= 4 &&
+   !(xhci->quirks & XHCI_BROKEN_STREAMS))
xhci->shared_hcd->can_do_streams = 1;
 
ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
-- 
2.18.0



[PATCH 03/13] dt-bindings: usb: mtu3: support wakeup for mt8183 and mt8192

2021-03-21 Thread Chunfeng Yun
These two HW of wakeup don't follow MediaTek internal IPM rule,
and both use a specific way, like as early revision of mt8173.

Due to the index 2 already used by many DTS, it's better to keep
it unchanged for backward compatible, treat specific ones without
following IPM rule as revision 1.x, meanwhile reserve 3~10 for
later revision that following the IPM rule.

Signed-off-by: Chunfeng Yun 
---
 .../devicetree/bindings/usb/mediatek,mtu3.yaml | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml 
b/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
index f5c04b9d2de9..918f9d6447c6 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtu3.yaml
@@ -24,6 +24,7 @@ properties:
   - mediatek,mt2712-mtu3
   - mediatek,mt8173-mtu3
   - mediatek,mt8183-mtu3
+  - mediatek,mt8192-mtu3
   - const: mediatek,mtu3
 
   reg:
@@ -152,10 +153,13 @@ properties:
 - description:
 The second cell represents the register base address of the glue
 layer in syscon
-- description:
+- description: |
 The third cell represents the hardware version of the glue layer,
-1 is used by mt8173 etc, 2 is used by mt2712 etc
-  enum: [1, 2]
+1 - used by mt8173 etc, revision 1 without following IPM rule;
+2 - used by mt2712 etc, revision 2 with following IPM rule;
+11 - used by mt8183, specific 1.1;
+12 - used by mt8192, specific 1.2;
+  enum: [1, 2, 11, 12]
 
   mediatek,u3p-dis-msk:
 $ref: /schemas/types.yaml#/definitions/uint32
-- 
2.18.0



[PATCH 01/13] dt-bindings: usb: mtk-xhci: support property usb2-lpm-disable

2021-03-21 Thread Chunfeng Yun
Add support common property usb2-lpm-disable

Signed-off-by: Chunfeng Yun 
---
 Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml | 4 
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml 
b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
index 14f40efb3b22..2246d29a5e4e 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.yaml
@@ -103,6 +103,10 @@ properties:
 description: supports USB3.0 LPM
 type: boolean
 
+  usb2-lpm-disable:
+description: disable USB2 HW LPM
+type: boolean
+
   imod-interval-ns:
 description:
   Interrupt moderation interval value, it is 8 times as much as that
-- 
2.18.0



[PATCH] arm64: dts: mt8173: fix wrong power-domain phandle of pmic

2021-03-18 Thread Chunfeng Yun
Due to power domain controller is added, the power domain's
phanle is also changed from 'scpsys' to 'spm', but forget to
modify pmic node's

Fixes: 8b6562644df9 ("arm64: dts: mediatek: Add mt8173 power domain controller")
Signed-off-by: Chunfeng Yun 
---
 arch/arm64/boot/dts/mediatek/mt8173-evb.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173-evb.dts 
b/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
index 6dffada2e66b..28aa634c9780 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
@@ -294,7 +294,7 @@
 
  {
/* Only MT8173 E1 needs USB power domain */
-   power-domains = < MT8173_POWER_DOMAIN_USB>;
+   power-domains = < MT8173_POWER_DOMAIN_USB>;
 
pmic: mt6397 {
compatible = "mediatek,mt6397";
-- 
2.18.0



Re: [PATCH 10/10] arm64: dts: Add Mediatek SoC MT8195 and evaluation board dts and Makefile

2021-03-17 Thread Chunfeng Yun
On Tue, 2021-03-16 at 19:14 +0800, Seiya Wang wrote:
> Add basic chip support for Mediatek MT8195
> 
> Signed-off-by: Seiya Wang 
> ---
>  arch/arm64/boot/dts/mediatek/Makefile   |   1 +
>  arch/arm64/boot/dts/mediatek/mt8195-evb.dts |  29 ++
>  arch/arm64/boot/dts/mediatek/mt8195.dtsi| 477 
> 
>  3 files changed, 507 insertions(+)
>  create mode 100644 arch/arm64/boot/dts/mediatek/mt8195-evb.dts
>  create mode 100644 arch/arm64/boot/dts/mediatek/mt8195.dtsi
> 
> diff --git a/arch/arm64/boot/dts/mediatek/Makefile 
> b/arch/arm64/boot/dts/mediatek/Makefile
> index deba27ab7657..aee4b9715d2f 100644
> --- a/arch/arm64/boot/dts/mediatek/Makefile
> +++ b/arch/arm64/boot/dts/mediatek/Makefile
> @@ -16,4 +16,5 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += mt8183-evb.dtb
>  dtb-$(CONFIG_ARCH_MEDIATEK) += mt8183-kukui-krane-sku0.dtb
>  dtb-$(CONFIG_ARCH_MEDIATEK) += mt8183-kukui-krane-sku176.dtb
>  dtb-$(CONFIG_ARCH_MEDIATEK) += mt8192-evb.dtb
> +dtb-$(CONFIG_ARCH_MEDIATEK) += mt8195-evb.dtb
>  dtb-$(CONFIG_ARCH_MEDIATEK) += mt8516-pumpkin.dtb
> diff --git a/arch/arm64/boot/dts/mediatek/mt8195-evb.dts 
> b/arch/arm64/boot/dts/mediatek/mt8195-evb.dts
> new file mode 100644
> index ..82bb10e9a531
> --- /dev/null
> +++ b/arch/arm64/boot/dts/mediatek/mt8195-evb.dts
> @@ -0,0 +1,29 @@
> +// SPDX-License-Identifier: (GPL-2.0 OR MIT)
> +/*
> + * Copyright (C) 2021 MediaTek Inc.
> + * Author: Seiya Wang 
> + */
> +/dts-v1/;
> +#include "mt8195.dtsi"
> +
> +/ {
> + model = "MediaTek MT8195 evaluation board";
> + compatible = "mediatek,mt8195-evb", "mediatek,mt8195";
> +
> + aliases {
> + serial0 = 
> + };
> +
> + chosen {
> + stdout-path = "serial0:921600n8";
> + };
> +
> + memory@4000 {
> + device_type = "memory";
> + reg = <0 0x4000 0 0x8000>;
> + };
> +};
> +
> + {
> + status = "okay";
> +};
> diff --git a/arch/arm64/boot/dts/mediatek/mt8195.dtsi 
> b/arch/arm64/boot/dts/mediatek/mt8195.dtsi
> new file mode 100644
> index ..356583fe4f03
> --- /dev/null
> +++ b/arch/arm64/boot/dts/mediatek/mt8195.dtsi
> @@ -0,0 +1,477 @@
> +// SPDX-License-Identifier: (GPL-2.0 OR MIT)
> +/*
> + * Copyright (c) 2021 MediaTek Inc.
> + * Author: Seiya Wang 
> + */
> +
> +/dts-v1/;
> +
> +#include 
> +#include 
> +
> +/ {
> + compatible = "mediatek,mt8195";
> + interrupt-parent = <>;
> + #address-cells = <2>;
> + #size-cells = <2>;
> +
> + clocks {
> + clk26m: oscillator0 {
> + compatible = "fixed-clock";
> + #clock-cells = <0>;
> + clock-frequency = <2600>;
> + clock-output-names = "clk26m";
> + };
> +
> + clk32k: oscillator1 {
> + compatible = "fixed-clock";
> + #clock-cells = <0>;
> + clock-frequency = <32768>;
> + clock-output-names = "clk32k";
> + };
> + };
[...]
> +
> + nor_flash: nor@1132c000 {
> + compatible = "mediatek,mt8195-nor", 
> "mediatek,mt8173-nor";
> + reg = <0 0x1132c000 0 0x1000>;
> + interrupts = ;
> + clocks = <>, <>;
> + clock-names = "spi", "sf";
> + #address-cells = <1>;
> + #size-cells = <0>;
> + status = "disabled";
> + };
> +
> + u3phy2: usb-phy2@11c4 {
use t-phy instead of usb-phy2

It's better to run dtbs_check for this patch

> + compatible = "mediatek,mt8195-tphy", 
> "mediatek,generic-tphy-v2";
> + clocks = <>;
> + clock-names = "u3phya_ref";
No need clocks for v2
> + #address-cells = <1>;
> + #size-cells = <1>;
> + ranges = <0 0 0x11c4 0x700>;
> + status = "disabled";
> +
> + u2port2: usb2-phy2@0 {
use usb-phy instead of usb2-phy2

> + reg = <0x0 0x700>;
> + clocks = <>;
> + clock-names = "ref";
> + #phy-cells = <1>;
> + status = "disabled";
I think no need disable it
it's parent node is already disabled. if enable parent node,
we also want to enable all children at the same time.

> + };
> + };
> +
> + u3phy3: usb-phy3@11c5 {
t-phy@...
> + compatible = "mediatek,mt8195-tphy", 
> "mediatek,generic-tphy-v2";
> + clocks = <>;
> + clock-names = "u3phya_ref";
No need clocks
> + #address-cells = <1>;
> + #size-cells = <1>;
> + ranges = <0 0 0x11c5 0x700>;
> +

Re: [PATCH v5 02/13] dt-bindings: phy: mediatek: dsi-phy: modify compatible dependence

2021-03-17 Thread Chunfeng Yun
Hi Vinod,

  Could you please help to apply patches [02/13] [03/13] [04/13] of the
series?

   Thanks a lot

On Tue, 2021-03-16 at 17:22 +0800, Chunfeng Yun wrote:
> mt7623-mipi-tx is compatible to mt2701-mipi-tx, and use
> "mediatek,mt2701-mipi-tx" instead on MT7623, so modify
> the compatible items to make dependence clear.
> 
> Cc: Chun-Kuang Hu 
> Cc: Philipp Zabel 
> Acked-by: Chun-Kuang Hu 
> Reviewed-by: Rob Herring 
> Signed-off-by: Chunfeng Yun 
> ---
> v5: no changes
> v4: add acked-by CK, and reviewed-by Rob
> v3: modify commit message suggested by CK
> v2: separate two patches suggested by CK
> ---
>  .../devicetree/bindings/phy/mediatek,dsi-phy.yaml   | 13 -
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/phy/mediatek,dsi-phy.yaml 
> b/Documentation/devicetree/bindings/phy/mediatek,dsi-phy.yaml
> index 71d4acea1f66..6e4d795f9b02 100644
> --- a/Documentation/devicetree/bindings/phy/mediatek,dsi-phy.yaml
> +++ b/Documentation/devicetree/bindings/phy/mediatek,dsi-phy.yaml
> @@ -19,11 +19,14 @@ properties:
>  pattern: "^dsi-phy@[0-9a-f]+$"
>  
>compatible:
> -enum:
> -  - mediatek,mt2701-mipi-tx
> -  - mediatek,mt7623-mipi-tx
> -  - mediatek,mt8173-mipi-tx
> -  - mediatek,mt8183-mipi-tx
> +oneOf:
> +  - items:
> +  - enum:
> +  - mediatek,mt7623-mipi-tx
> +  - const: mediatek,mt2701-mipi-tx
> +  - const: mediatek,mt2701-mipi-tx
> +  - const: mediatek,mt8173-mipi-tx
> +  - const: mediatek,mt8183-mipi-tx
>  
>reg:
>  maxItems: 1



Re: [PATCH 08/10] dt-bindings: phy: Add compatible for Mediatek MT8195

2021-03-17 Thread Chunfeng Yun
Hi Vinod,

On Wed, 2021-03-17 at 12:10 +0530, Vinod Koul wrote:
> On 16-03-21, 19:14, Seiya Wang wrote:
> > This commit adds dt-binding documentation of UFS M-Phy for Mediatek MT8195 
> > SoC
> > Platform.
> 
> Applied, thanks

Usually, we expect the dt-binding patch is acked or reviewed by Rob
before it's applied?

Thanks a lot

> 



Re: [PATCH 08/10] dt-bindings: phy: Add compatible for Mediatek MT8195

2021-03-17 Thread Chunfeng Yun
On Tue, 2021-03-16 at 19:14 +0800, Seiya Wang wrote:
> This commit adds dt-binding documentation of UFS M-Phy for Mediatek MT8195 SoC
> Platform.
> 
> Signed-off-by: Seiya Wang 
> ---
>  Documentation/devicetree/bindings/phy/mediatek,ufs-phy.yaml | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/Documentation/devicetree/bindings/phy/mediatek,ufs-phy.yaml 
> b/Documentation/devicetree/bindings/phy/mediatek,ufs-phy.yaml
> index 3a9be82e7f13..5235b1a0d188 100644
> --- a/Documentation/devicetree/bindings/phy/mediatek,ufs-phy.yaml
> +++ b/Documentation/devicetree/bindings/phy/mediatek,ufs-phy.yaml
> @@ -22,6 +22,7 @@ properties:
>  pattern: "^ufs-phy@[0-9a-f]+$"
>  
>compatible:
> +enum: mediatek,mt8195-ufsphy
>  const: mediatek,mt8183-ufsphy
>  
There is warning when I make dt_binding_check, if mt8195 is compatible
with mt8183, will add it as following:

oneOf:
  - items:
  - enum:
  - mediatek,mt8195-ufsphy
  - const: mediatek,mt8183-ufsphy
  - const: mediatek,mt8183-ufsphy

Due to Vinod already apply this patch, I'll send out a fix patch later

Thanks

>reg:



[PATCH v5 11/13] arm: dts: mt7629: harmonize node names and compatibles

2021-03-16 Thread Chunfeng Yun
This is used to fix dtbs_check warning

Signed-off-by: Chunfeng Yun 
---
v2~v5: no changes
---
 arch/arm/boot/dts/mt7629.dtsi | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/arm/boot/dts/mt7629.dtsi b/arch/arm/boot/dts/mt7629.dtsi
index 5cbb3d244c75..874043f0490d 100644
--- a/arch/arm/boot/dts/mt7629.dtsi
+++ b/arch/arm/boot/dts/mt7629.dtsi
@@ -329,8 +329,9 @@
status = "disabled";
};
 
-   u3phy0: usb-phy@1a0c4000 {
-   compatible = "mediatek,generic-tphy-v2";
+   u3phy0: t-phy@1a0c4000 {
+   compatible = "mediatek,mt7629-tphy",
+"mediatek,generic-tphy-v2";
#address-cells = <1>;
#size-cells = <1>;
ranges = <0 0x1a0c4000 0xe00>;
@@ -413,14 +414,15 @@
};
};
 
-   pciephy1: pcie-phy@1a14a000 {
-   compatible = "mediatek,generic-tphy-v2";
+   pciephy1: t-phy@1a14a000 {
+   compatible = "mediatek,mt7629-tphy",
+"mediatek,generic-tphy-v2";
#address-cells = <1>;
#size-cells = <1>;
ranges = <0 0x1a14a000 0x1000>;
status = "disabled";
 
-   pcieport1: port1phy@0 {
+   pcieport1: pcie-phy@0 {
reg = <0 0x1000>;
clocks = <>;
clock-names = "ref";
-- 
2.18.0



[PATCH v5 08/13] arm64: dts: mediatek: mt8516: harmonize node names and compatibles

2021-03-16 Thread Chunfeng Yun
This is used to fix dtbs_check warning:
  harmonize node names and compatibles;
  add property "usb-role-switch" for connector dependence.

Signed-off-by: Chunfeng Yun 
---
v2~v5: no changes
---
 arch/arm64/boot/dts/mediatek/mt8516.dtsi | 9 +
 arch/arm64/boot/dts/mediatek/pumpkin-common.dtsi | 1 +
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8516.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8516.dtsi
index b80e95574bef..bbe5a1419eff 100644
--- a/arch/arm64/boot/dts/mediatek/mt8516.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8516.dtsi
@@ -480,7 +480,7 @@
};
 
usb0: usb@1110 {
-   compatible = "mediatek,mtk-musb";
+   compatible = "mediatek,mt8516-musb", 
"mediatek,mtk-musb";
reg = <0 0x1110 0 0x1000>;
interrupts = ;
interrupt-names = "mc";
@@ -493,7 +493,7 @@
};
 
usb1: usb@1119 {
-   compatible = "mediatek,mtk-musb";
+   compatible = "mediatek,mt8516-musb", 
"mediatek,mtk-musb";
reg = <0 0x1119 0 0x1000>;
interrupts = ;
interrupt-names = "mc";
@@ -506,8 +506,9 @@
status = "disabled";
};
 
-   usb_phy: usb@ {
-   compatible = "mediatek,generic-tphy-v1";
+   usb_phy: t-phy@ {
+   compatible = "mediatek,mt8516-tphy",
+"mediatek,generic-tphy-v1";
reg = <0 0x 0 0x800>;
#address-cells = <2>;
#size-cells = <2>;
diff --git a/arch/arm64/boot/dts/mediatek/pumpkin-common.dtsi 
b/arch/arm64/boot/dts/mediatek/pumpkin-common.dtsi
index 63fd70086bb8..7d738f01cf8d 100644
--- a/arch/arm64/boot/dts/mediatek/pumpkin-common.dtsi
+++ b/arch/arm64/boot/dts/mediatek/pumpkin-common.dtsi
@@ -188,6 +188,7 @@
  {
status = "okay";
dr_mode = "peripheral";
+   usb-role-switch;
 
usb_con: connector {
compatible = "usb-c-connector";
-- 
2.18.0



[PATCH v5 09/13] arm64: dts: mediatek: mt7622: harmonize node names and compatibles

2021-03-16 Thread Chunfeng Yun
This is used to fix dtbs_check warning

Signed-off-by: Chunfeng Yun 
---
v2~v5: no changes
---
 arch/arm64/boot/dts/mediatek/mt7622.dtsi | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt7622.dtsi 
b/arch/arm64/boot/dts/mediatek/mt7622.dtsi
index 7c6d871538a6..890a942ec608 100644
--- a/arch/arm64/boot/dts/mediatek/mt7622.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt7622.dtsi
@@ -742,8 +742,8 @@
status = "disabled";
};
 
-   u3phy: usb-phy@1a0c4000 {
-   compatible = "mediatek,mt7622-u3phy",
+   u3phy: t-phy@1a0c4000 {
+   compatible = "mediatek,mt7622-tphy",
 "mediatek,generic-tphy-v1";
reg = <0 0x1a0c4000 0 0x700>;
#address-cells = <2>;
@@ -877,8 +877,9 @@
status = "disabled";
};
 
-   sata_phy: sata-phy@1a243000 {
-   compatible = "mediatek,generic-tphy-v1";
+   sata_phy: t-phy@1a243000 {
+   compatible = "mediatek,mt7622-tphy",
+"mediatek,generic-tphy-v1";
#address-cells = <2>;
#size-cells = <2>;
ranges;
-- 
2.18.0



[PATCH v5 13/13] arm: dts: mt2701: harmonize node names and compatibles

2021-03-16 Thread Chunfeng Yun
This is used to fix dtbs_check warning

Signed-off-by: Chunfeng Yun 
---
v2~v5: no changes
---
 arch/arm/boot/dts/mt2701.dtsi | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi
index fade14284017..4776f85d6d5b 100644
--- a/arch/arm/boot/dts/mt2701.dtsi
+++ b/arch/arm/boot/dts/mt2701.dtsi
@@ -607,7 +607,7 @@
};
 
usb0: usb@1a1c {
-   compatible = "mediatek,mt8173-xhci";
+   compatible = "mediatek,mt2701-xhci", "mediatek,mtk-xhci";
reg = <0 0x1a1c 0 0x1000>,
  <0 0x1a1c4700 0 0x0100>;
reg-names = "mac", "ippc";
@@ -620,8 +620,9 @@
status = "disabled";
};
 
-   u3phy0: usb-phy@1a1c4000 {
-   compatible = "mediatek,mt2701-u3phy";
+   u3phy0: t-phy@1a1c4000 {
+   compatible = "mediatek,mt2701-tphy",
+"mediatek,generic-tphy-v1";
reg = <0 0x1a1c4000 0 0x0700>;
#address-cells = <2>;
#size-cells = <2>;
@@ -646,7 +647,7 @@
};
 
usb1: usb@1a24 {
-   compatible = "mediatek,mt8173-xhci";
+   compatible = "mediatek,mt2701-xhci", "mediatek,mtk-xhci";
reg = <0 0x1a24 0 0x1000>,
  <0 0x1a244700 0 0x0100>;
reg-names = "mac", "ippc";
@@ -659,8 +660,9 @@
status = "disabled";
};
 
-   u3phy1: usb-phy@1a244000 {
-   compatible = "mediatek,mt2701-u3phy";
+   u3phy1: t-phy@1a244000 {
+   compatible = "mediatek,mt2701-tphy",
+"mediatek,generic-tphy-v1";
reg = <0 0x1a244000 0 0x0700>;
#address-cells = <2>;
#size-cells = <2>;
@@ -700,8 +702,9 @@
status = "disabled";
};
 
-   u2phy0: usb-phy@1121 {
-   compatible = "mediatek,generic-tphy-v1";
+   u2phy0: t-phy@1121 {
+   compatible = "mediatek,mt2701-tphy",
+"mediatek,generic-tphy-v1";
reg = <0 0x1121 0 0x0800>;
#address-cells = <2>;
#size-cells = <2>;
-- 
2.18.0



[PATCH v5 03/13] dt-bindings: phy: mediatek: hdmi-phy: modify compatible items

2021-03-16 Thread Chunfeng Yun
mt7623-hdmi-tx is compatible to mt2701-hdmi-tx, and the compatible
"mediatek,mt7623-hdmi-tx" is not supported in driver, in fact uses
"mediatek,mt2701-hdmi-tx" instead on MT7623, so changes the
compatible items to make dependence clear.

Cc: Chun-Kuang Hu 
Cc: Philipp Zabel 
Acked-by: Chun-Kuang Hu 
Reviewed-by: Rob Herring 
Signed-off-by: Chunfeng Yun 
---
v5: no changes
v4: add acked-by CK and Reviewed-by Rob
v3: modify commit message
v2: no changes
---
 .../devicetree/bindings/phy/mediatek,hdmi-phy.yaml| 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/phy/mediatek,hdmi-phy.yaml 
b/Documentation/devicetree/bindings/phy/mediatek,hdmi-phy.yaml
index 4752517a1446..0d94950b84ca 100644
--- a/Documentation/devicetree/bindings/phy/mediatek,hdmi-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/mediatek,hdmi-phy.yaml
@@ -21,10 +21,13 @@ properties:
 pattern: "^hdmi-phy@[0-9a-f]+$"
 
   compatible:
-enum:
-  - mediatek,mt2701-hdmi-phy
-  - mediatek,mt7623-hdmi-phy
-  - mediatek,mt8173-hdmi-phy
+oneOf:
+  - items:
+  - enum:
+  - mediatek,mt7623-hdmi-phy
+  - const: mediatek,mt2701-hdmi-phy
+  - const: mediatek,mt2701-hdmi-phy
+  - const: mediatek,mt8173-hdmi-phy
 
   reg:
 maxItems: 1
-- 
2.18.0



[PATCH v5 05/13] arm64: dts: mt8173: fix property typo of 'phys' in dsi node

2021-03-16 Thread Chunfeng Yun
Use 'phys' instead of 'phy'.

Fixes: 81ad4dbaf7af ("arm64: dts: mt8173: Add display subsystem related nodes")
Cc: stable 
Reviewed-by: Chun-Kuang Hu 
Signed-off-by: Chunfeng Yun 
---
v5: merged into this series, add Reviewed-by CK
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 7fa870e4386a..ecb37a7e6870 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -1235,7 +1235,7 @@
 < CLK_MM_DSI1_DIGITAL>,
 <_tx1>;
clock-names = "engine", "digital", "hs";
-   phy = <_tx1>;
+   phys = <_tx1>;
phy-names = "dphy";
status = "disabled";
};
-- 
2.18.0



[PATCH v5 12/13] arm: dts: mt7623: harmonize node names and compatibles

2021-03-16 Thread Chunfeng Yun
This is used to fix dtbs_check warning

Signed-off-by: Chunfeng Yun 
---
v2~v5: no changes
---
 arch/arm/boot/dts/mt7623.dtsi  | 26 ++
 arch/arm/boot/dts/mt7623n.dtsi |  4 ++--
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/arch/arm/boot/dts/mt7623.dtsi b/arch/arm/boot/dts/mt7623.dtsi
index aea6809500d7..3c11f7cfcc40 100644
--- a/arch/arm/boot/dts/mt7623.dtsi
+++ b/arch/arm/boot/dts/mt7623.dtsi
@@ -787,8 +787,9 @@
};
};
 
-   pcie0_phy: pcie-phy@1a149000 {
-   compatible = "mediatek,generic-tphy-v1";
+   pcie0_phy: t-phy@1a149000 {
+   compatible = "mediatek,mt7623-tphy",
+"mediatek,generic-tphy-v1";
reg = <0 0x1a149000 0 0x0700>;
#address-cells = <2>;
#size-cells = <2>;
@@ -804,8 +805,9 @@
};
};
 
-   pcie1_phy: pcie-phy@1a14a000 {
-   compatible = "mediatek,generic-tphy-v1";
+   pcie1_phy: t-phy@1a14a000 {
+   compatible = "mediatek,mt7623-tphy",
+"mediatek,generic-tphy-v1";
reg = <0 0x1a14a000 0 0x0700>;
#address-cells = <2>;
#size-cells = <2>;
@@ -823,7 +825,7 @@
 
usb1: usb@1a1c {
compatible = "mediatek,mt7623-xhci",
-"mediatek,mt8173-xhci";
+"mediatek,mtk-xhci";
reg = <0 0x1a1c 0 0x1000>,
  <0 0x1a1c4700 0 0x0100>;
reg-names = "mac", "ippc";
@@ -836,9 +838,9 @@
status = "disabled";
};
 
-   u3phy1: usb-phy@1a1c4000 {
-   compatible = "mediatek,mt7623-u3phy",
-"mediatek,mt2701-u3phy";
+   u3phy1: t-phy@1a1c4000 {
+   compatible = "mediatek,mt7623-tphy",
+"mediatek,generic-tphy-v1";
reg = <0 0x1a1c4000 0 0x0700>;
#address-cells = <2>;
#size-cells = <2>;
@@ -864,7 +866,7 @@
 
usb2: usb@1a24 {
compatible = "mediatek,mt7623-xhci",
-"mediatek,mt8173-xhci";
+"mediatek,mtk-xhci";
reg = <0 0x1a24 0 0x1000>,
  <0 0x1a244700 0 0x0100>;
reg-names = "mac", "ippc";
@@ -877,9 +879,9 @@
status = "disabled";
};
 
-   u3phy2: usb-phy@1a244000 {
-   compatible = "mediatek,mt7623-u3phy",
-"mediatek,mt2701-u3phy";
+   u3phy2: t-phy@1a244000 {
+   compatible = "mediatek,mt7623-tphy",
+"mediatek,generic-tphy-v1";
reg = <0 0x1a244000 0 0x0700>;
#address-cells = <2>;
#size-cells = <2>;
diff --git a/arch/arm/boot/dts/mt7623n.dtsi b/arch/arm/boot/dts/mt7623n.dtsi
index 1880ac9e32cf..bcb0846e29fd 100644
--- a/arch/arm/boot/dts/mt7623n.dtsi
+++ b/arch/arm/boot/dts/mt7623n.dtsi
@@ -246,7 +246,7 @@
status = "disabled";
};
 
-   mipi_tx0: mipi-dphy@1001 {
+   mipi_tx0: dsi-phy@1001 {
compatible = "mediatek,mt7623-mipi-tx",
 "mediatek,mt2701-mipi-tx";
reg = <0 0x1001 0 0x90>;
@@ -265,7 +265,7 @@
status = "disabled";
};
 
-   hdmi_phy: phy@10209100 {
+   hdmi_phy: hdmi-phy@10209100 {
compatible = "mediatek,mt7623-hdmi-phy",
 "mediatek,mt2701-hdmi-phy";
reg = <0 0x10209100 0 0x24>;
-- 
2.18.0



[PATCH v5 01/13] dt-bindings: usb: fix yamllint check warning

2021-03-16 Thread Chunfeng Yun
Fix warning: "missing starting space in comment"

Fixes: 23bf6fc7046c ("dt-bindings: usb: convert usb-device.txt to YAML schema")
Signed-off-by: Chunfeng Yun 
---
v5: add Fixes tag suggested by Greg
v2~v4: no changes
---
 Documentation/devicetree/bindings/usb/usb-device.yaml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-device.yaml 
b/Documentation/devicetree/bindings/usb/usb-device.yaml
index d4c99809ee9a..b77960a7a37b 100644
--- a/Documentation/devicetree/bindings/usb/usb-device.yaml
+++ b/Documentation/devicetree/bindings/usb/usb-device.yaml
@@ -82,9 +82,9 @@ required:
 additionalProperties: true
 
 examples:
-  #hub connected to port 1
-  #device connected to port 2
-  #device connected to port 3
+  # hub connected to port 1
+  # device connected to port 2
+  # device connected to port 3
   #interface 0 of configuration 1
   #interface 0 of configuration 2
   - |
-- 
2.18.0



[PATCH v5 10/13] arm64: dts: mediatek: mt8183: fix dtbs_check warning

2021-03-16 Thread Chunfeng Yun
Harmonize node names, compatibles and properties.

Signed-off-by: Chunfeng Yun 
---
v4~v5: no changes
v3: remove property clock-names suggested by CK
v2: no changes
---
 arch/arm64/boot/dts/mediatek/mt8183.dtsi | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8183.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
index 80519a145f13..8882d35ac6ab 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
@@ -880,7 +880,7 @@
ranges;
status = "disabled";
 
-   usb_host: xhci@1120 {
+   usb_host: usb@1120 {
compatible = "mediatek,mt8183-xhci",
 "mediatek,mtk-xhci";
reg = <0 0x1120 0 0x1000>;
@@ -923,11 +923,10 @@
status = "disabled";
};
 
-   mipi_tx0: mipi-dphy@11e5 {
+   mipi_tx0: dsi-phy@11e5 {
compatible = "mediatek,mt8183-mipi-tx";
reg = <0 0x11e5 0 0x1000>;
clocks = < CLK_APMIXED_MIPID0_26M>;
-   clock-names = "ref_clk";
#clock-cells = <0>;
#phy-cells = <0>;
clock-output-names = "mipi_tx0_pll";
@@ -946,11 +945,10 @@
};
};
 
-   u3phy: usb-phy@11f4 {
+   u3phy: t-phy@11f4 {
compatible = "mediatek,mt8183-tphy",
 "mediatek,generic-tphy-v2";
#address-cells = <1>;
-   #phy-cells = <1>;
#size-cells = <1>;
ranges = <0 0 0x11f4 0x1000>;
status = "okay";
-- 
2.18.0



[PATCH v5 04/13] dt-bindings: phy: mediatek: tphy: change patternProperties

2021-03-16 Thread Chunfeng Yun
The phy may be named as pcie-phy when the T-PHY only supports
PCIe mode, it's also the similar case for SATA, named as
sata-phy.

Reviewed-by: Rob Herring 
Signed-off-by: Chunfeng Yun 
---
v5: no changes
v4: add reviewed-by Rob
v2~v3: no changes
---
 Documentation/devicetree/bindings/phy/mediatek,tphy.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/phy/mediatek,tphy.yaml 
b/Documentation/devicetree/bindings/phy/mediatek,tphy.yaml
index 602e6ff45785..4f1733fd9a55 100644
--- a/Documentation/devicetree/bindings/phy/mediatek,tphy.yaml
+++ b/Documentation/devicetree/bindings/phy/mediatek,tphy.yaml
@@ -117,7 +117,7 @@ properties:
 
 # Required child node:
 patternProperties:
-  "^usb-phy@[0-9a-f]+$":
+  "^(usb|pcie|sata)-phy@[0-9a-f]+$":
 type: object
 description:
   A sub-node is required for each port the controller provides.
-- 
2.18.0



[PATCH v5 06/13] arm64: dts: mediatek: mt8173: fix dtbs_check warning

2021-03-16 Thread Chunfeng Yun
Harmonize nodes names, compatibles and remove unused property.

Signed-off-by: Chunfeng Yun 
---
v2~v5: no changes
---
 arch/arm64/boot/dts/mediatek/mt8173-evb.dts |  4 +---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi| 13 +++--
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173-evb.dts 
b/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
index 6dffada2e66b..0ce81c4fe81e 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
@@ -516,10 +516,8 @@
extcon = <_usb>;
dr_mode = "otg";
wakeup-source;
-   pinctrl-names = "default", "id_float", "id_ground";
+   pinctrl-names = "default";
pinctrl-0 = <_id_pins_float>;
-   pinctrl-1 = <_id_pins_float>;
-   pinctrl-2 = <_id_pins_ground>;
status = "okay";
 };
 
diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index ecb37a7e6870..003a5653c505 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -631,7 +631,7 @@
#mbox-cells = <2>;
};
 
-   mipi_tx0: mipi-dphy@10215000 {
+   mipi_tx0: dsi-phy@10215000 {
compatible = "mediatek,mt8173-mipi-tx";
reg = <0 0x10215000 0 0x1000>;
clocks = <>;
@@ -641,7 +641,7 @@
status = "disabled";
};
 
-   mipi_tx1: mipi-dphy@10216000 {
+   mipi_tx1: dsi-phy@10216000 {
compatible = "mediatek,mt8173-mipi-tx";
reg = <0 0x10216000 0 0x1000>;
clocks = <>;
@@ -926,7 +926,7 @@
};
 
ssusb: usb@11271000 {
-   compatible = "mediatek,mt8173-mtu3";
+   compatible = "mediatek,mt8173-mtu3", "mediatek,mtu3";
reg = <0 0x11271000 0 0x3000>,
  <0 0x11280700 0 0x0100>;
reg-names = "mac", "ippc";
@@ -943,8 +943,9 @@
ranges;
status = "disabled";
 
-   usb_host: xhci@1127 {
-   compatible = "mediatek,mt8173-xhci";
+   usb_host: usb@1127 {
+   compatible = "mediatek,mt8173-xhci",
+"mediatek,mtk-xhci";
reg = <0 0x1127 0 0x1000>;
reg-names = "mac";
interrupts = ;
@@ -955,7 +956,7 @@
};
};
 
-   u3phy: usb-phy@1129 {
+   u3phy: t-phy@1129 {
compatible = "mediatek,mt8173-u3phy";
reg = <0 0x1129 0 0x800>;
#address-cells = <2>;
-- 
2.18.0



[PATCH v5 02/13] dt-bindings: phy: mediatek: dsi-phy: modify compatible dependence

2021-03-16 Thread Chunfeng Yun
mt7623-mipi-tx is compatible to mt2701-mipi-tx, and use
"mediatek,mt2701-mipi-tx" instead on MT7623, so modify
the compatible items to make dependence clear.

Cc: Chun-Kuang Hu 
Cc: Philipp Zabel 
Acked-by: Chun-Kuang Hu 
Reviewed-by: Rob Herring 
Signed-off-by: Chunfeng Yun 
---
v5: no changes
v4: add acked-by CK, and reviewed-by Rob
v3: modify commit message suggested by CK
v2: separate two patches suggested by CK
---
 .../devicetree/bindings/phy/mediatek,dsi-phy.yaml   | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/phy/mediatek,dsi-phy.yaml 
b/Documentation/devicetree/bindings/phy/mediatek,dsi-phy.yaml
index 71d4acea1f66..6e4d795f9b02 100644
--- a/Documentation/devicetree/bindings/phy/mediatek,dsi-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/mediatek,dsi-phy.yaml
@@ -19,11 +19,14 @@ properties:
 pattern: "^dsi-phy@[0-9a-f]+$"
 
   compatible:
-enum:
-  - mediatek,mt2701-mipi-tx
-  - mediatek,mt7623-mipi-tx
-  - mediatek,mt8173-mipi-tx
-  - mediatek,mt8183-mipi-tx
+oneOf:
+  - items:
+  - enum:
+  - mediatek,mt7623-mipi-tx
+  - const: mediatek,mt2701-mipi-tx
+  - const: mediatek,mt2701-mipi-tx
+  - const: mediatek,mt8173-mipi-tx
+  - const: mediatek,mt8183-mipi-tx
 
   reg:
 maxItems: 1
-- 
2.18.0



[PATCH v5 07/13] arm64: dts: mediatek: mt2712: harmonize node names

2021-03-16 Thread Chunfeng Yun
This is used to fix dtbs_check warning.

Signed-off-by: Chunfeng Yun 
---
v2~v5: no changes
---
 arch/arm64/boot/dts/mediatek/mt2712e.dtsi | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi 
b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi
index db17d0a4ed57..a9cca9c146fd 100644
--- a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi
@@ -805,7 +805,7 @@
ranges;
status = "disabled";
 
-   usb_host0: xhci@1127 {
+   usb_host0: usb@1127 {
compatible = "mediatek,mt2712-xhci",
 "mediatek,mtk-xhci";
reg = <0 0x1127 0 0x1000>;
@@ -818,7 +818,7 @@
};
};
 
-   u3phy0: usb-phy@1129 {
+   u3phy0: t-phy@1129 {
compatible = "mediatek,mt2712-tphy",
 "mediatek,generic-tphy-v2";
#address-cells = <1>;
@@ -869,7 +869,7 @@
ranges;
status = "disabled";
 
-   usb_host1: xhci@112c {
+   usb_host1: usb@112c {
compatible = "mediatek,mt2712-xhci",
 "mediatek,mtk-xhci";
reg = <0 0x112c 0 0x1000>;
@@ -882,7 +882,7 @@
};
};
 
-   u3phy1: usb-phy@112e {
+   u3phy1: t-phy@112e {
compatible = "mediatek,mt2712-tphy",
 "mediatek,generic-tphy-v2";
#address-cells = <1>;
-- 
2.18.0



  1   2   3   4   5   6   7   8   9   10   >