| .. | .. |
|---|
| 30 | 30 | #include <linux/regulator/consumer.h> |
|---|
| 31 | 31 | #include <linux/pm_runtime.h> |
|---|
| 32 | 32 | |
|---|
| 33 | | -#include <mach/regs-s3c2443-clock.h> |
|---|
| 34 | | - |
|---|
| 35 | 33 | #define S3C_HSUDC_REG(x) (x) |
|---|
| 36 | 34 | |
|---|
| 37 | 35 | /* Non-Indexed Registers */ |
|---|
| .. | .. |
|---|
| 184 | 182 | static inline void __orr32(void __iomem *ptr, u32 val) |
|---|
| 185 | 183 | { |
|---|
| 186 | 184 | writel(readl(ptr) | val, ptr); |
|---|
| 187 | | -} |
|---|
| 188 | | - |
|---|
| 189 | | -static void s3c_hsudc_init_phy(void) |
|---|
| 190 | | -{ |
|---|
| 191 | | - u32 cfg; |
|---|
| 192 | | - |
|---|
| 193 | | - cfg = readl(S3C2443_PWRCFG) | S3C2443_PWRCFG_USBPHY; |
|---|
| 194 | | - writel(cfg, S3C2443_PWRCFG); |
|---|
| 195 | | - |
|---|
| 196 | | - cfg = readl(S3C2443_URSTCON); |
|---|
| 197 | | - cfg |= (S3C2443_URSTCON_FUNCRST | S3C2443_URSTCON_PHYRST); |
|---|
| 198 | | - writel(cfg, S3C2443_URSTCON); |
|---|
| 199 | | - mdelay(1); |
|---|
| 200 | | - |
|---|
| 201 | | - cfg = readl(S3C2443_URSTCON); |
|---|
| 202 | | - cfg &= ~(S3C2443_URSTCON_FUNCRST | S3C2443_URSTCON_PHYRST); |
|---|
| 203 | | - writel(cfg, S3C2443_URSTCON); |
|---|
| 204 | | - |
|---|
| 205 | | - cfg = readl(S3C2443_PHYCTRL); |
|---|
| 206 | | - cfg &= ~(S3C2443_PHYCTRL_CLKSEL | S3C2443_PHYCTRL_DSPORT); |
|---|
| 207 | | - cfg |= (S3C2443_PHYCTRL_EXTCLK | S3C2443_PHYCTRL_PLLSEL); |
|---|
| 208 | | - writel(cfg, S3C2443_PHYCTRL); |
|---|
| 209 | | - |
|---|
| 210 | | - cfg = readl(S3C2443_PHYPWR); |
|---|
| 211 | | - cfg &= ~(S3C2443_PHYPWR_FSUSPEND | S3C2443_PHYPWR_PLL_PWRDN | |
|---|
| 212 | | - S3C2443_PHYPWR_XO_ON | S3C2443_PHYPWR_PLL_REFCLK | |
|---|
| 213 | | - S3C2443_PHYPWR_ANALOG_PD); |
|---|
| 214 | | - cfg |= S3C2443_PHYPWR_COMMON_ON; |
|---|
| 215 | | - writel(cfg, S3C2443_PHYPWR); |
|---|
| 216 | | - |
|---|
| 217 | | - cfg = readl(S3C2443_UCLKCON); |
|---|
| 218 | | - cfg |= (S3C2443_UCLKCON_DETECT_VBUS | S3C2443_UCLKCON_FUNC_CLKEN | |
|---|
| 219 | | - S3C2443_UCLKCON_TCLKEN); |
|---|
| 220 | | - writel(cfg, S3C2443_UCLKCON); |
|---|
| 221 | | -} |
|---|
| 222 | | - |
|---|
| 223 | | -static void s3c_hsudc_uninit_phy(void) |
|---|
| 224 | | -{ |
|---|
| 225 | | - u32 cfg; |
|---|
| 226 | | - |
|---|
| 227 | | - cfg = readl(S3C2443_PWRCFG) & ~S3C2443_PWRCFG_USBPHY; |
|---|
| 228 | | - writel(cfg, S3C2443_PWRCFG); |
|---|
| 229 | | - |
|---|
| 230 | | - writel(S3C2443_PHYPWR_FSUSPEND, S3C2443_PHYPWR); |
|---|
| 231 | | - |
|---|
| 232 | | - cfg = readl(S3C2443_UCLKCON) & ~S3C2443_UCLKCON_FUNC_CLKEN; |
|---|
| 233 | | - writel(cfg, S3C2443_UCLKCON); |
|---|
| 234 | 185 | } |
|---|
| 235 | 186 | |
|---|
| 236 | 187 | /** |
|---|
| .. | .. |
|---|
| 1188 | 1139 | |
|---|
| 1189 | 1140 | pm_runtime_get_sync(hsudc->dev); |
|---|
| 1190 | 1141 | |
|---|
| 1191 | | - s3c_hsudc_init_phy(); |
|---|
| 1142 | + if (hsudc->pd->phy_init) |
|---|
| 1143 | + hsudc->pd->phy_init(); |
|---|
| 1192 | 1144 | if (hsudc->pd->gpio_init) |
|---|
| 1193 | 1145 | hsudc->pd->gpio_init(); |
|---|
| 1194 | 1146 | |
|---|
| .. | .. |
|---|
| 1210 | 1162 | |
|---|
| 1211 | 1163 | spin_lock_irqsave(&hsudc->lock, flags); |
|---|
| 1212 | 1164 | hsudc->gadget.speed = USB_SPEED_UNKNOWN; |
|---|
| 1213 | | - s3c_hsudc_uninit_phy(); |
|---|
| 1165 | + if (hsudc->pd->phy_uninit) |
|---|
| 1166 | + hsudc->pd->phy_uninit(); |
|---|
| 1214 | 1167 | |
|---|
| 1215 | 1168 | pm_runtime_put(hsudc->dev); |
|---|
| 1216 | 1169 | |
|---|
| .. | .. |
|---|
| 1263 | 1216 | static int s3c_hsudc_probe(struct platform_device *pdev) |
|---|
| 1264 | 1217 | { |
|---|
| 1265 | 1218 | struct device *dev = &pdev->dev; |
|---|
| 1266 | | - struct resource *res; |
|---|
| 1267 | 1219 | struct s3c_hsudc *hsudc; |
|---|
| 1268 | 1220 | struct s3c24xx_hsudc_platdata *pd = dev_get_platdata(&pdev->dev); |
|---|
| 1269 | 1221 | int ret, i; |
|---|
| .. | .. |
|---|
| 1286 | 1238 | ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(hsudc->supplies), |
|---|
| 1287 | 1239 | hsudc->supplies); |
|---|
| 1288 | 1240 | if (ret != 0) { |
|---|
| 1289 | | - dev_err(dev, "failed to request supplies: %d\n", ret); |
|---|
| 1241 | + if (ret != -EPROBE_DEFER) |
|---|
| 1242 | + dev_err(dev, "failed to request supplies: %d\n", ret); |
|---|
| 1290 | 1243 | goto err_supplies; |
|---|
| 1291 | 1244 | } |
|---|
| 1292 | 1245 | |
|---|
| 1293 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 1294 | | - |
|---|
| 1295 | | - hsudc->regs = devm_ioremap_resource(&pdev->dev, res); |
|---|
| 1246 | + hsudc->regs = devm_platform_ioremap_resource(pdev, 0); |
|---|
| 1296 | 1247 | if (IS_ERR(hsudc->regs)) { |
|---|
| 1297 | 1248 | ret = PTR_ERR(hsudc->regs); |
|---|
| 1298 | 1249 | goto err_res; |
|---|
| .. | .. |
|---|
| 1311 | 1262 | s3c_hsudc_setup_ep(hsudc); |
|---|
| 1312 | 1263 | |
|---|
| 1313 | 1264 | ret = platform_get_irq(pdev, 0); |
|---|
| 1314 | | - if (ret < 0) { |
|---|
| 1315 | | - dev_err(dev, "unable to obtain IRQ number\n"); |
|---|
| 1265 | + if (ret < 0) |
|---|
| 1316 | 1266 | goto err_res; |
|---|
| 1317 | | - } |
|---|
| 1318 | 1267 | hsudc->irq = ret; |
|---|
| 1319 | 1268 | |
|---|
| 1320 | 1269 | ret = devm_request_irq(&pdev->dev, hsudc->irq, s3c_hsudc_irq, 0, |
|---|