forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/usb/gadget/udc/s3c-hsudc.c
....@@ -30,8 +30,6 @@
3030 #include <linux/regulator/consumer.h>
3131 #include <linux/pm_runtime.h>
3232
33
-#include <mach/regs-s3c2443-clock.h>
34
-
3533 #define S3C_HSUDC_REG(x) (x)
3634
3735 /* Non-Indexed Registers */
....@@ -184,53 +182,6 @@
184182 static inline void __orr32(void __iomem *ptr, u32 val)
185183 {
186184 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);
234185 }
235186
236187 /**
....@@ -1188,7 +1139,8 @@
11881139
11891140 pm_runtime_get_sync(hsudc->dev);
11901141
1191
- s3c_hsudc_init_phy();
1142
+ if (hsudc->pd->phy_init)
1143
+ hsudc->pd->phy_init();
11921144 if (hsudc->pd->gpio_init)
11931145 hsudc->pd->gpio_init();
11941146
....@@ -1210,7 +1162,8 @@
12101162
12111163 spin_lock_irqsave(&hsudc->lock, flags);
12121164 hsudc->gadget.speed = USB_SPEED_UNKNOWN;
1213
- s3c_hsudc_uninit_phy();
1165
+ if (hsudc->pd->phy_uninit)
1166
+ hsudc->pd->phy_uninit();
12141167
12151168 pm_runtime_put(hsudc->dev);
12161169
....@@ -1263,7 +1216,6 @@
12631216 static int s3c_hsudc_probe(struct platform_device *pdev)
12641217 {
12651218 struct device *dev = &pdev->dev;
1266
- struct resource *res;
12671219 struct s3c_hsudc *hsudc;
12681220 struct s3c24xx_hsudc_platdata *pd = dev_get_platdata(&pdev->dev);
12691221 int ret, i;
....@@ -1286,13 +1238,12 @@
12861238 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(hsudc->supplies),
12871239 hsudc->supplies);
12881240 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);
12901243 goto err_supplies;
12911244 }
12921245
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);
12961247 if (IS_ERR(hsudc->regs)) {
12971248 ret = PTR_ERR(hsudc->regs);
12981249 goto err_res;
....@@ -1311,10 +1262,8 @@
13111262 s3c_hsudc_setup_ep(hsudc);
13121263
13131264 ret = platform_get_irq(pdev, 0);
1314
- if (ret < 0) {
1315
- dev_err(dev, "unable to obtain IRQ number\n");
1265
+ if (ret < 0)
13161266 goto err_res;
1317
- }
13181267 hsudc->irq = ret;
13191268
13201269 ret = devm_request_irq(&pdev->dev, hsudc->irq, s3c_hsudc_irq, 0,