Commit c2c9caa94748657ac8b47428ef4e95ccb646cea7

Authored by Peter Chen
Committed by Felipe Balbi
1 parent f0ea8834df

usb: gadget: fsl_mxc_udc: replace MX35_IO_ADDRESS to ioremap

As mach/hardware.h is deleted, we can't visit platform code at driver.
It has no phy driver to combine with this controller, so it has to use
ioremap to map phy address as a workaround.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>

Showing 3 changed files with 29 additions and 10 deletions Side-by-side Diff

drivers/usb/gadget/fsl_mxc_udc.c
... ... @@ -23,7 +23,8 @@
23 23 static struct clk *mxc_ipg_clk;
24 24  
25 25 /* workaround ENGcm09152 for i.MX35 */
26   -#define USBPHYCTRL_OTGBASE_OFFSET 0x608
  26 +#define MX35_USBPHYCTRL_OFFSET 0x600
  27 +#define USBPHYCTRL_OTGBASE_OFFSET 0x8
27 28 #define USBPHYCTRL_EVDO (1 << 23)
28 29  
29 30 int fsl_udc_clk_init(struct platform_device *pdev)
30 31  
31 32  
32 33  
33 34  
34 35  
... ... @@ -77,25 +78,40 @@
77 78 return ret;
78 79 }
79 80  
80   -void fsl_udc_clk_finalize(struct platform_device *pdev)
  81 +int fsl_udc_clk_finalize(struct platform_device *pdev)
81 82 {
82 83 struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
83   - unsigned int v;
  84 + int ret = 0;
84 85  
85 86 /* workaround ENGcm09152 for i.MX35 */
86 87 if (pdata->workaround & FLS_USB2_WORKAROUND_ENGCM09152) {
87   - v = readl(MX35_IO_ADDRESS(MX35_USB_BASE_ADDR +
88   - USBPHYCTRL_OTGBASE_OFFSET));
  88 + unsigned int v;
  89 + struct resource *res = platform_get_resource
  90 + (pdev, IORESOURCE_MEM, 0);
  91 + void __iomem *phy_regs = ioremap(res->start +
  92 + MX35_USBPHYCTRL_OFFSET, 512);
  93 + if (!phy_regs) {
  94 + dev_err(&pdev->dev, "ioremap for phy address fails\n");
  95 + ret = -EINVAL;
  96 + goto ioremap_err;
  97 + }
  98 +
  99 + v = readl(phy_regs + USBPHYCTRL_OTGBASE_OFFSET);
89 100 writel(v | USBPHYCTRL_EVDO,
90   - MX35_IO_ADDRESS(MX35_USB_BASE_ADDR +
91   - USBPHYCTRL_OTGBASE_OFFSET));
  101 + phy_regs + USBPHYCTRL_OTGBASE_OFFSET);
  102 +
  103 + iounmap(phy_regs);
92 104 }
93 105  
  106 +
  107 +ioremap_err:
94 108 /* ULPI transceivers don't need usbpll */
95 109 if (pdata->phy_mode == FSL_USB2_PHY_ULPI) {
96 110 clk_disable_unprepare(mxc_per_clk);
97 111 mxc_per_clk = NULL;
98 112 }
  113 +
  114 + return ret;
99 115 }
100 116  
101 117 void fsl_udc_clk_release(void)
drivers/usb/gadget/fsl_udc_core.c
... ... @@ -2543,7 +2543,9 @@
2543 2543 dr_controller_setup(udc_controller);
2544 2544 }
2545 2545  
2546   - fsl_udc_clk_finalize(pdev);
  2546 + ret = fsl_udc_clk_finalize(pdev);
  2547 + if (ret)
  2548 + goto err_free_irq;
2547 2549  
2548 2550 /* Setup gadget structure */
2549 2551 udc_controller->gadget.ops = &fsl_gadget_ops;
drivers/usb/gadget/fsl_usb2_udc.h
... ... @@ -592,15 +592,16 @@
592 592 struct platform_device;
593 593 #ifdef CONFIG_ARCH_MXC
594 594 int fsl_udc_clk_init(struct platform_device *pdev);
595   -void fsl_udc_clk_finalize(struct platform_device *pdev);
  595 +int fsl_udc_clk_finalize(struct platform_device *pdev);
596 596 void fsl_udc_clk_release(void);
597 597 #else
598 598 static inline int fsl_udc_clk_init(struct platform_device *pdev)
599 599 {
600 600 return 0;
601 601 }
602   -static inline void fsl_udc_clk_finalize(struct platform_device *pdev)
  602 +static inline int fsl_udc_clk_finalize(struct platform_device *pdev)
603 603 {
  604 + return 0;
604 605 }
605 606 static inline void fsl_udc_clk_release(void)
606 607 {