aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/musb_core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/musb/musb_core.c')
-rw-r--r--drivers/usb/musb/musb_core.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 0f8b82918a40..66aaccf04490 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -137,6 +137,9 @@ static int musb_ulpi_read(struct usb_phy *phy, u32 offset)
137 int i = 0; 137 int i = 0;
138 u8 r; 138 u8 r;
139 u8 power; 139 u8 power;
140 int ret;
141
142 pm_runtime_get_sync(phy->io_dev);
140 143
141 /* Make sure the transceiver is not in low power mode */ 144 /* Make sure the transceiver is not in low power mode */
142 power = musb_readb(addr, MUSB_POWER); 145 power = musb_readb(addr, MUSB_POWER);
@@ -154,15 +157,22 @@ static int musb_ulpi_read(struct usb_phy *phy, u32 offset)
154 while (!(musb_readb(addr, MUSB_ULPI_REG_CONTROL) 157 while (!(musb_readb(addr, MUSB_ULPI_REG_CONTROL)
155 & MUSB_ULPI_REG_CMPLT)) { 158 & MUSB_ULPI_REG_CMPLT)) {
156 i++; 159 i++;
157 if (i == 10000) 160 if (i == 10000) {
158 return -ETIMEDOUT; 161 ret = -ETIMEDOUT;
162 goto out;
163 }
159 164
160 } 165 }
161 r = musb_readb(addr, MUSB_ULPI_REG_CONTROL); 166 r = musb_readb(addr, MUSB_ULPI_REG_CONTROL);
162 r &= ~MUSB_ULPI_REG_CMPLT; 167 r &= ~MUSB_ULPI_REG_CMPLT;
163 musb_writeb(addr, MUSB_ULPI_REG_CONTROL, r); 168 musb_writeb(addr, MUSB_ULPI_REG_CONTROL, r);
164 169
165 return musb_readb(addr, MUSB_ULPI_REG_DATA); 170 ret = musb_readb(addr, MUSB_ULPI_REG_DATA);
171
172out:
173 pm_runtime_put(phy->io_dev);
174
175 return ret;
166} 176}
167 177
168static int musb_ulpi_write(struct usb_phy *phy, u32 offset, u32 data) 178static int musb_ulpi_write(struct usb_phy *phy, u32 offset, u32 data)
@@ -171,6 +181,9 @@ static int musb_ulpi_write(struct usb_phy *phy, u32 offset, u32 data)
171 int i = 0; 181 int i = 0;
172 u8 r = 0; 182 u8 r = 0;
173 u8 power; 183 u8 power;
184 int ret = 0;
185
186 pm_runtime_get_sync(phy->io_dev);
174 187
175 /* Make sure the transceiver is not in low power mode */ 188 /* Make sure the transceiver is not in low power mode */
176 power = musb_readb(addr, MUSB_POWER); 189 power = musb_readb(addr, MUSB_POWER);
@@ -184,15 +197,20 @@ static int musb_ulpi_write(struct usb_phy *phy, u32 offset, u32 data)
184 while (!(musb_readb(addr, MUSB_ULPI_REG_CONTROL) 197 while (!(musb_readb(addr, MUSB_ULPI_REG_CONTROL)
185 & MUSB_ULPI_REG_CMPLT)) { 198 & MUSB_ULPI_REG_CMPLT)) {
186 i++; 199 i++;
187 if (i == 10000) 200 if (i == 10000) {
188 return -ETIMEDOUT; 201 ret = -ETIMEDOUT;
202 goto out;
203 }
189 } 204 }
190 205
191 r = musb_readb(addr, MUSB_ULPI_REG_CONTROL); 206 r = musb_readb(addr, MUSB_ULPI_REG_CONTROL);
192 r &= ~MUSB_ULPI_REG_CMPLT; 207 r &= ~MUSB_ULPI_REG_CMPLT;
193 musb_writeb(addr, MUSB_ULPI_REG_CONTROL, r); 208 musb_writeb(addr, MUSB_ULPI_REG_CONTROL, r);
194 209
195 return 0; 210out:
211 pm_runtime_put(phy->io_dev);
212
213 return ret;
196} 214}
197#else 215#else
198#define musb_ulpi_read NULL 216#define musb_ulpi_read NULL
@@ -1904,14 +1922,17 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
1904 1922
1905 if (!musb->isr) { 1923 if (!musb->isr) {
1906 status = -ENODEV; 1924 status = -ENODEV;
1907 goto fail3; 1925 goto fail2;
1908 } 1926 }
1909 1927
1910 if (!musb->xceiv->io_ops) { 1928 if (!musb->xceiv->io_ops) {
1929 musb->xceiv->io_dev = musb->controller;
1911 musb->xceiv->io_priv = musb->mregs; 1930 musb->xceiv->io_priv = musb->mregs;
1912 musb->xceiv->io_ops = &musb_ulpi_access; 1931 musb->xceiv->io_ops = &musb_ulpi_access;
1913 } 1932 }
1914 1933
1934 pm_runtime_get_sync(musb->controller);
1935
1915#ifndef CONFIG_MUSB_PIO_ONLY 1936#ifndef CONFIG_MUSB_PIO_ONLY
1916 if (use_dma && dev->dma_mask) { 1937 if (use_dma && dev->dma_mask) {
1917 struct dma_controller *c; 1938 struct dma_controller *c;
@@ -2023,6 +2044,8 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
2023 goto fail5; 2044 goto fail5;
2024#endif 2045#endif
2025 2046
2047 pm_runtime_put(musb->controller);
2048
2026 dev_info(dev, "USB %s mode controller at %p using %s, IRQ %d\n", 2049 dev_info(dev, "USB %s mode controller at %p using %s, IRQ %d\n",
2027 ({char *s; 2050 ({char *s;
2028 switch (musb->board_mode) { 2051 switch (musb->board_mode) {
@@ -2047,6 +2070,9 @@ fail4:
2047 musb_gadget_cleanup(musb); 2070 musb_gadget_cleanup(musb);
2048 2071
2049fail3: 2072fail3:
2073 pm_runtime_put_sync(musb->controller);
2074
2075fail2:
2050 if (musb->irq_wake) 2076 if (musb->irq_wake)
2051 device_init_wakeup(dev, 0); 2077 device_init_wakeup(dev, 0);
2052 musb_platform_exit(musb); 2078 musb_platform_exit(musb);