usb: ehci: add freescale imx28 special write register method
Subsystems (4)
PATCH 1/3 usb: ehci: add freescale imx28 special write register method
According to Freescale imx28 Errata, "ENGR119653 USB: ARM to USB register error issue", All USB register write operations must use the ARM SWP instruction. So, we implement a special ehci_write for imx28.
Discussion for it at below:
http://marc.info/?l=linux-usb&m=137996395529294&w=2
--- drivers/usb/host/ehci.h | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)
drivers/usb/host/ehci.h +13 -0
@@ -203,6 +203,7 @@ struct ehci_hcd { /* one per controller */ unsigned has_synopsys_hc_bug:1; /* Synopsys HC */ unsigned frame_index_bug:1; /* MosChip (AKA NetMos) */ unsigned need_oc_pp_cycle:1; /* MPC834X port power */ + unsigned imx28_write_fix:1; /* For Freescale i.MX28 *//* required for usb32 quirk */ #define OHCI_CTRL_HCFS (3 << 6)
@@ -680,6 +681,13 @@ static inline unsigned int ehci_readl(const struct ehci_hcd *ehci,#endif } +#ifdef CONFIG_SOC_IMX28 +static inline void imx28_ehci_writel (u32 val32,volatile u32 *addr) +{ + __asm__ ("swp %0, %0, [%1]" : :"r" (val32),"r" (addr)); +} +#endif +static inline void ehci_writel (const struct ehci_hcd *ehci,const unsigned int val,__u32 __iomem *regs) {
@@ -687,6 +695,11 @@ static inline void ehci_writel(const struct ehci_hcd *ehci,ehci_big_endian_mmio (ehci) ?writel_be (val, regs) :writel (val, regs); +#elif defined(CONFIG_SOC_IMX28 ) +if (ehci->imx28_write_fix) +imx28_ehci_writel (val, regs); +else +writel (val, regs);#else writel (val, regs);#endif
Signature · 1 line
1.7.1
PATCH 2/3 usb: chipidea: add freescale imx28 special write register method
According to Freescale imx28 Errata, "ENGR119653 USB: ARM to USB register error issue", All USB register write operations must use the ARM SWP instruction. So, we implement special hw_write and hw_test_and_clear for imx28.
Discussion for it at below:
http://marc.info/?l=linux-usb&m=137996395529294&w=2
--- drivers/usb/chipidea/ci.h | 23 +++++++++++++++++++++++ drivers/usb/chipidea/core.c | 2 ++ drivers/usb/chipidea/host.c | 1 + include/linux/usb/chipidea.h | 1 + 4 files changed, 27 insertions(+), 0 deletions(-)
drivers/usb/chipidea/ci.h +23 -0
@@ -176,6 +176,8 @@ struct ci_hdrc {bool supports_runtime_pm;bool in_lpm;bool wakeup_int; +/* imx28 needs swp instruction for writing */ +bool imx28_write_fix; };static inline struct ci_role_driver *ci_role (struct ci_hdrc *ci)
@@ -256,6 +258,13 @@ static inline u32 hw_read(struct ci_hdrc *ci, enum ci_hw_regs reg, u32 mask)return ioread32 (ci->hw_bank.regmap[reg]) & mask; } +#ifdef CONFIG_SOC_IMX28 +static inline void imx28_ci_writel (u32 val32,volatile u32 *addr) +{ + __asm__ ("swp %0, %0, [%1]" : :"r" (val32),"r" (addr)); +} +#endif +/** * hw_write: writes to a hw register * @reg: register index
@@ -269,7 +278,14 @@ static inline void hw_write(struct ci_hdrc *ci, enum ci_hw_regs reg, data = (ioread32 (ci->hw_bank.regmap[reg]) & ~mask) | (data & mask); +#ifdef CONFIG_SOC_IMX28 +if (ci->imx28_write_fix) +imx28_ci_writel (data, ci->hw_bank.regmap[reg]); +else +iowrite32 (data, ci->hw_bank.regmap[reg]); +#else iowrite32 (data, ci->hw_bank.regmap[reg]); +#endif }/**
@@ -284,7 +300,14 @@ static inline u32 hw_test_and_clear(struct ci_hdrc *ci, enum ci_hw_regs reg, {u32 val =ioread32 (ci->hw_bank.regmap[reg]) & mask; +#ifdef CONFIG_SOC_IMX28 +if (ci->imx28_write_fix) +imx28_ci_writel (val, ci->hw_bank.regmap[reg]); +else +iowrite32 (val, ci->hw_bank.regmap[reg]); +#else iowrite32 (val, ci->hw_bank.regmap[reg]); +#endif return val; }
drivers/usb/chipidea/core.c +2 -0
@@ -565,6 +565,8 @@ static int ci_hdrc_probe(struct platform_device *pdev) ci->dev = dev; ci->platdata = dev->platform_data; + ci->imx28_write_fix = !!(ci->platdata->flags & +CI_HDRC_IMX28_WRITE_FIX ); ret =hw_device_init (ci, base);if (ret <0 ) {
drivers/usb/chipidea/host.c +1 -0
@@ -235,6 +235,7 @@ static int host_start(struct ci_hdrc *ci) ehci->caps = ci->hw_bank.cap; ehci->has_hostpc = ci->hw_bank.lpm; ehci->has_tdi_phy_lpm = ci->hw_bank.lpm; + ehci->imx28_write_fix = ci->imx28_write_fix;if (ci->platdata->reg_vbus) { ret =regulator_enable (ci->platdata->reg_vbus);
include/linux/usb/chipidea.h +1 -0
@@ -26,6 +26,7 @@ struct ci_hdrc_platform_data {*/ #define CI_HDRC_DUAL_ROLE_NOT_OTG BIT(4)#define CI_HDRC_IMX_EHCI_QUIRK BIT(5) +#define CI_HDRC_IMX28_WRITE_FIX BIT(6)enum usb_dr_mode dr_mode;#define CI_HDRC_CONTROLLER_RESET_EVENT 0#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1
Signature · 1 line
1.7.1
PATCH 3/3 usb: chipidea: imx: set CI_HDRC_IMX28_WRITE_FIX for imx28
In reply to Peter ChenDue to imx28 needs ARM swp instruction for writing, we set CI_HDRC_IMX28_WRITE_FIX for imx28.
--- drivers/usb/chipidea/ci_hdrc_imx.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/usb/chipidea/ci_hdrc_imx.c +4 -0
@@ -128,6 +128,9 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) data->supports_runtime_pm = true; } +if (of_device_is_compatible (np,"fsl,imx28-usb" )) + pdata.flags |=CI_HDRC_IMX28_WRITE_FIX ; +if (!pdev->dev.dma_mask) pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;if (!pdev->dev.coherent_dma_mask)
@@ -309,6 +312,7 @@ static const struct dev_pm_ops ci_hdrc_imx_pm_ops = { };static const struct of_device_id ci_hdrc_imx_dt_ids[] = { { .compatible ="fsl,imx27-usb" , }, + { .compatible ="fsl,imx28-usb" , }, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, ci_hdrc_imx_dt_ids);
Signature · 1 line
1.7.1
Fabio Estevam
reviewerPATCH 1/3 usb: ehci: add freescale imx28 special write register method
In reply to Peter ChenHi Peter,
Quoted 40 lines · Peter Chen
According to Freescale imx28 Errata, "ENGR119653 USB: ARM to USB register error issue", All USB register write operations must use the ARM SWP instruction. So, we implement a special
ehci_writefor imx28.Discussion for it at below:
http://marc.info/?l=linux-usb&m=137996395529294&w=2Signed-off-by Peter Chen <[email protected]>--- drivers/usb/host/ehci.h | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)drivers/usb/host/ehci.h +8
-0@@ -203,6 +203,7 @@ struct ehci_hcd { /* one per controller */ unsigned has_synopsys_hc_bug:1; /* Synopsys HC */ unsigned frame_index_bug:1; /* MosChip (AKA NetMos) */ unsigned need_oc_pp_cycle:1; /* MPC834X port power */ + unsigned imx28_write_fix:1; /* For Freescale i.MX28 *//* required for usb32 quirk */ #define OHCI_CTRL_HCFS (3 << 6)@@ -680,6 +681,13 @@ static inline unsigned int ehci_readl(const struct ehci_hcd *ehci,#endif } +#ifdef CONFIG_SOC_IMX28 +static inline void imx28_ehci_writel (u32 val32,volatile u32 *addr) +{ + __asm__ ("swp %0, %0, [%1]" : :"r" (val32),"r" (addr)); +} +#endif +static inline void ehci_writel (const struct ehci_hcd *ehci,const unsigned int val,__u32 __iomem *regs) {
drivers/usb/host/ehci.h static inline void ehci_writel(const struct ehci_hcd *ehci, · line 702
Quoted 8 lines
drivers/usb/host/ehci.h +5
-0@@ -687,6 +695,11 @@ static inline void ehci_writel(const struct ehci_hcd *ehci,ehci_big_endian_mmio (ehci) ?writel_be (val, regs) :writel (val, regs); +#elif defined(CONFIG_SOC_IMX28 ) +if (ehci->imx28_write_fix) +imx28_ehci_writel (val, regs); +else +writel (val, regs);
Have you tested this on mx23?
What if we have a kernel built for both mx23 and mx28?
Regards,
Fabio Estevam
Alan Stern
maintainerPATCH 1/3 usb: ehci: add freescale imx28 special write register method
In reply to Peter ChenQuoted 9 lines · Peter Chen
According to Freescale imx28 Errata, "ENGR119653 USB: ARM to USB register error issue", All USB register write operations must use the ARM SWP instruction. So, we implement a special
ehci_writefor imx28.Discussion for it at below:
http://marc.info/?l=linux-usb&m=137996395529294&w=2Signed-off-by Peter Chen <[email protected]>
PATCH 1/3 usb: ehci: add freescale imx28 special write register method
In reply to Fabio EstevamQuoted 54 lines · Fabio Estevam
Hi Peter,
Quoted 40 lines · Peter Chen
According to Freescale imx28 Errata, "ENGR119653 USB: ARM to USB register error issue", All USB register write operations must use the ARM SWP instruction. So, we implement a special
ehci_writefor imx28.Discussion for it at below:
http://marc.info/?l=linux-usb&m=137996395529294&w=2Signed-off-by Peter Chen <[email protected]>--- drivers/usb/host/ehci.h | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)drivers/usb/host/ehci.h +8
-0@@ -203,6 +203,7 @@ struct ehci_hcd { /* one per controller */ unsigned has_synopsys_hc_bug:1; /* Synopsys HC */ unsigned frame_index_bug:1; /* MosChip (AKA NetMos) */ unsigned need_oc_pp_cycle:1; /* MPC834X port power */ + unsigned imx28_write_fix:1; /* For Freescale i.MX28 *//* required for usb32 quirk */ #define OHCI_CTRL_HCFS (3 << 6)@@ -680,6 +681,13 @@ static inline unsigned int ehci_readl(const struct ehci_hcd *ehci,#endif } +#ifdef CONFIG_SOC_IMX28 +static inline void imx28_ehci_writel (u32 val32,volatile u32 *addr) +{ + __asm__ ("swp %0, %0, [%1]" : :"r" (val32),"r" (addr)); +} +#endif +static inline void ehci_writel (const struct ehci_hcd *ehci,const unsigned int val,__u32 __iomem *regs) {drivers/usb/host/ehci.h static inline void ehci_writel(const struct ehci_hcd *ehci, · line 702
Quoted 8 lines
drivers/usb/host/ehci.h +5
-0@@ -687,6 +695,11 @@ static inline void ehci_writel(const struct ehci_hcd *ehci,ehci_big_endian_mmio (ehci) ?writel_be (val, regs) :writel (val, regs); +#elif defined(CONFIG_SOC_IMX28 ) +if (ehci->imx28_write_fix) +imx28_ehci_writel (val, regs); +else +writel (val, regs);Have you tested this on mx23?
Quoted 2 lines
What if we have a kernel built for both mx23 and mx28?
The condition ehci->imx28_write_fix will only be set for imx28 platform, you can refer patch 2/3 and patch 3/3.
Signature · 2 lines
Best Regards, Peter Chen