aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2010-12-01 06:53:27 -0500
committerFelipe Balbi <balbi@ti.com>2010-12-10 03:21:08 -0500
commit7421107b293cace2fc081731306d447ecd8517ab (patch)
tree47bd68e62b53b3e383abb66b7e87ff387a231d0c /drivers/usb/musb
parent1ea7f352d832d5abe43d5e9198098acb4d611ba3 (diff)
usb: musb: hold context on musb structure
when we start splitting HW glue layer, it's gonna make it easier to re-use that structure. Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb')
-rw-r--r--drivers/usb/musb/musb_core.c112
-rw-r--r--drivers/usb/musb/musb_core.h55
2 files changed, 83 insertions, 84 deletions
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 516c68c6fa50..5abcfe6ab2ee 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2265,8 +2265,6 @@ static int __exit musb_remove(struct platform_device *pdev)
2265 2265
2266#ifdef CONFIG_PM 2266#ifdef CONFIG_PM
2267 2267
2268static struct musb_context_registers musb_context;
2269
2270void musb_save_context(struct musb *musb) 2268void musb_save_context(struct musb *musb)
2271{ 2269{
2272 int i; 2270 int i;
@@ -2274,65 +2272,65 @@ void musb_save_context(struct musb *musb)
2274 void __iomem *epio; 2272 void __iomem *epio;
2275 2273
2276 if (is_host_enabled(musb)) { 2274 if (is_host_enabled(musb)) {
2277 musb_context.frame = musb_readw(musb_base, MUSB_FRAME); 2275 musb->context.frame = musb_readw(musb_base, MUSB_FRAME);
2278 musb_context.testmode = musb_readb(musb_base, MUSB_TESTMODE); 2276 musb->context.testmode = musb_readb(musb_base, MUSB_TESTMODE);
2279 musb_context.busctl = musb_read_ulpi_buscontrol(musb->mregs); 2277 musb->context.busctl = musb_read_ulpi_buscontrol(musb->mregs);
2280 } 2278 }
2281 musb_context.power = musb_readb(musb_base, MUSB_POWER); 2279 musb->context.power = musb_readb(musb_base, MUSB_POWER);
2282 musb_context.intrtxe = musb_readw(musb_base, MUSB_INTRTXE); 2280 musb->context.intrtxe = musb_readw(musb_base, MUSB_INTRTXE);
2283 musb_context.intrrxe = musb_readw(musb_base, MUSB_INTRRXE); 2281 musb->context.intrrxe = musb_readw(musb_base, MUSB_INTRRXE);
2284 musb_context.intrusbe = musb_readb(musb_base, MUSB_INTRUSBE); 2282 musb->context.intrusbe = musb_readb(musb_base, MUSB_INTRUSBE);
2285 musb_context.index = musb_readb(musb_base, MUSB_INDEX); 2283 musb->context.index = musb_readb(musb_base, MUSB_INDEX);
2286 musb_context.devctl = musb_readb(musb_base, MUSB_DEVCTL); 2284 musb->context.devctl = musb_readb(musb_base, MUSB_DEVCTL);
2287 2285
2288 for (i = 0; i < musb->config->num_eps; ++i) { 2286 for (i = 0; i < musb->config->num_eps; ++i) {
2289 epio = musb->endpoints[i].regs; 2287 epio = musb->endpoints[i].regs;
2290 musb_context.index_regs[i].txmaxp = 2288 musb->context.index_regs[i].txmaxp =
2291 musb_readw(epio, MUSB_TXMAXP); 2289 musb_readw(epio, MUSB_TXMAXP);
2292 musb_context.index_regs[i].txcsr = 2290 musb->context.index_regs[i].txcsr =
2293 musb_readw(epio, MUSB_TXCSR); 2291 musb_readw(epio, MUSB_TXCSR);
2294 musb_context.index_regs[i].rxmaxp = 2292 musb->context.index_regs[i].rxmaxp =
2295 musb_readw(epio, MUSB_RXMAXP); 2293 musb_readw(epio, MUSB_RXMAXP);
2296 musb_context.index_regs[i].rxcsr = 2294 musb->context.index_regs[i].rxcsr =
2297 musb_readw(epio, MUSB_RXCSR); 2295 musb_readw(epio, MUSB_RXCSR);
2298 2296
2299 if (musb->dyn_fifo) { 2297 if (musb->dyn_fifo) {
2300 musb_context.index_regs[i].txfifoadd = 2298 musb->context.index_regs[i].txfifoadd =
2301 musb_read_txfifoadd(musb_base); 2299 musb_read_txfifoadd(musb_base);
2302 musb_context.index_regs[i].rxfifoadd = 2300 musb->context.index_regs[i].rxfifoadd =
2303 musb_read_rxfifoadd(musb_base); 2301 musb_read_rxfifoadd(musb_base);
2304 musb_context.index_regs[i].txfifosz = 2302 musb->context.index_regs[i].txfifosz =
2305 musb_read_txfifosz(musb_base); 2303 musb_read_txfifosz(musb_base);
2306 musb_context.index_regs[i].rxfifosz = 2304 musb->context.index_regs[i].rxfifosz =
2307 musb_read_rxfifosz(musb_base); 2305 musb_read_rxfifosz(musb_base);
2308 } 2306 }
2309 if (is_host_enabled(musb)) { 2307 if (is_host_enabled(musb)) {
2310 musb_context.index_regs[i].txtype = 2308 musb->context.index_regs[i].txtype =
2311 musb_readb(epio, MUSB_TXTYPE); 2309 musb_readb(epio, MUSB_TXTYPE);
2312 musb_context.index_regs[i].txinterval = 2310 musb->context.index_regs[i].txinterval =
2313 musb_readb(epio, MUSB_TXINTERVAL); 2311 musb_readb(epio, MUSB_TXINTERVAL);
2314 musb_context.index_regs[i].rxtype = 2312 musb->context.index_regs[i].rxtype =
2315 musb_readb(epio, MUSB_RXTYPE); 2313 musb_readb(epio, MUSB_RXTYPE);
2316 musb_context.index_regs[i].rxinterval = 2314 musb->context.index_regs[i].rxinterval =
2317 musb_readb(epio, MUSB_RXINTERVAL); 2315 musb_readb(epio, MUSB_RXINTERVAL);
2318 2316
2319 musb_context.index_regs[i].txfunaddr = 2317 musb->context.index_regs[i].txfunaddr =
2320 musb_read_txfunaddr(musb_base, i); 2318 musb_read_txfunaddr(musb_base, i);
2321 musb_context.index_regs[i].txhubaddr = 2319 musb->context.index_regs[i].txhubaddr =
2322 musb_read_txhubaddr(musb_base, i); 2320 musb_read_txhubaddr(musb_base, i);
2323 musb_context.index_regs[i].txhubport = 2321 musb->context.index_regs[i].txhubport =
2324 musb_read_txhubport(musb_base, i); 2322 musb_read_txhubport(musb_base, i);
2325 2323
2326 musb_context.index_regs[i].rxfunaddr = 2324 musb->context.index_regs[i].rxfunaddr =
2327 musb_read_rxfunaddr(musb_base, i); 2325 musb_read_rxfunaddr(musb_base, i);
2328 musb_context.index_regs[i].rxhubaddr = 2326 musb->context.index_regs[i].rxhubaddr =
2329 musb_read_rxhubaddr(musb_base, i); 2327 musb_read_rxhubaddr(musb_base, i);
2330 musb_context.index_regs[i].rxhubport = 2328 musb->context.index_regs[i].rxhubport =
2331 musb_read_rxhubport(musb_base, i); 2329 musb_read_rxhubport(musb_base, i);
2332 } 2330 }
2333 } 2331 }
2334 2332
2335 musb_platform_save_context(musb, &musb_context); 2333 musb_platform_save_context(musb, &musb->context);
2336} 2334}
2337 2335
2338void musb_restore_context(struct musb *musb) 2336void musb_restore_context(struct musb *musb)
@@ -2342,67 +2340,67 @@ void musb_restore_context(struct musb *musb)
2342 void __iomem *ep_target_regs; 2340 void __iomem *ep_target_regs;
2343 void __iomem *epio; 2341 void __iomem *epio;
2344 2342
2345 musb_platform_restore_context(musb, &musb_context); 2343 musb_platform_restore_context(musb, &musb->context);
2346 2344
2347 if (is_host_enabled(musb)) { 2345 if (is_host_enabled(musb)) {
2348 musb_writew(musb_base, MUSB_FRAME, musb_context.frame); 2346 musb_writew(musb_base, MUSB_FRAME, musb->context.frame);
2349 musb_writeb(musb_base, MUSB_TESTMODE, musb_context.testmode); 2347 musb_writeb(musb_base, MUSB_TESTMODE, musb->context.testmode);
2350 musb_write_ulpi_buscontrol(musb->mregs, musb_context.busctl); 2348 musb_write_ulpi_buscontrol(musb->mregs, musb->context.busctl);
2351 } 2349 }
2352 musb_writeb(musb_base, MUSB_POWER, musb_context.power); 2350 musb_writeb(musb_base, MUSB_POWER, musb->context.power);
2353 musb_writew(musb_base, MUSB_INTRTXE, musb_context.intrtxe); 2351 musb_writew(musb_base, MUSB_INTRTXE, musb->context.intrtxe);
2354 musb_writew(musb_base, MUSB_INTRRXE, musb_context.intrrxe); 2352 musb_writew(musb_base, MUSB_INTRRXE, musb->context.intrrxe);
2355 musb_writeb(musb_base, MUSB_INTRUSBE, musb_context.intrusbe); 2353 musb_writeb(musb_base, MUSB_INTRUSBE, musb->context.intrusbe);
2356 musb_writeb(musb_base, MUSB_DEVCTL, musb_context.devctl); 2354 musb_writeb(musb_base, MUSB_DEVCTL, musb->context.devctl);
2357 2355
2358 for (i = 0; i < musb->config->num_eps; ++i) { 2356 for (i = 0; i < musb->config->num_eps; ++i) {
2359 epio = musb->endpoints[i].regs; 2357 epio = musb->endpoints[i].regs;
2360 musb_writew(epio, MUSB_TXMAXP, 2358 musb_writew(epio, MUSB_TXMAXP,
2361 musb_context.index_regs[i].txmaxp); 2359 musb->context.index_regs[i].txmaxp);
2362 musb_writew(epio, MUSB_TXCSR, 2360 musb_writew(epio, MUSB_TXCSR,
2363 musb_context.index_regs[i].txcsr); 2361 musb->context.index_regs[i].txcsr);
2364 musb_writew(epio, MUSB_RXMAXP, 2362 musb_writew(epio, MUSB_RXMAXP,
2365 musb_context.index_regs[i].rxmaxp); 2363 musb->context.index_regs[i].rxmaxp);
2366 musb_writew(epio, MUSB_RXCSR, 2364 musb_writew(epio, MUSB_RXCSR,
2367 musb_context.index_regs[i].rxcsr); 2365 musb->context.index_regs[i].rxcsr);
2368 2366
2369 if (musb->dyn_fifo) { 2367 if (musb->dyn_fifo) {
2370 musb_write_txfifosz(musb_base, 2368 musb_write_txfifosz(musb_base,
2371 musb_context.index_regs[i].txfifosz); 2369 musb->context.index_regs[i].txfifosz);
2372 musb_write_rxfifosz(musb_base, 2370 musb_write_rxfifosz(musb_base,
2373 musb_context.index_regs[i].rxfifosz); 2371 musb->context.index_regs[i].rxfifosz);
2374 musb_write_txfifoadd(musb_base, 2372 musb_write_txfifoadd(musb_base,
2375 musb_context.index_regs[i].txfifoadd); 2373 musb->context.index_regs[i].txfifoadd);
2376 musb_write_rxfifoadd(musb_base, 2374 musb_write_rxfifoadd(musb_base,
2377 musb_context.index_regs[i].rxfifoadd); 2375 musb->context.index_regs[i].rxfifoadd);
2378 } 2376 }
2379 2377
2380 if (is_host_enabled(musb)) { 2378 if (is_host_enabled(musb)) {
2381 musb_writeb(epio, MUSB_TXTYPE, 2379 musb_writeb(epio, MUSB_TXTYPE,
2382 musb_context.index_regs[i].txtype); 2380 musb->context.index_regs[i].txtype);
2383 musb_writeb(epio, MUSB_TXINTERVAL, 2381 musb_writeb(epio, MUSB_TXINTERVAL,
2384 musb_context.index_regs[i].txinterval); 2382 musb->context.index_regs[i].txinterval);
2385 musb_writeb(epio, MUSB_RXTYPE, 2383 musb_writeb(epio, MUSB_RXTYPE,
2386 musb_context.index_regs[i].rxtype); 2384 musb->context.index_regs[i].rxtype);
2387 musb_writeb(epio, MUSB_RXINTERVAL, 2385 musb_writeb(epio, MUSB_RXINTERVAL,
2388 2386
2389 musb_context.index_regs[i].rxinterval); 2387 musb->context.index_regs[i].rxinterval);
2390 musb_write_txfunaddr(musb_base, i, 2388 musb_write_txfunaddr(musb_base, i,
2391 musb_context.index_regs[i].txfunaddr); 2389 musb->context.index_regs[i].txfunaddr);
2392 musb_write_txhubaddr(musb_base, i, 2390 musb_write_txhubaddr(musb_base, i,
2393 musb_context.index_regs[i].txhubaddr); 2391 musb->context.index_regs[i].txhubaddr);
2394 musb_write_txhubport(musb_base, i, 2392 musb_write_txhubport(musb_base, i,
2395 musb_context.index_regs[i].txhubport); 2393 musb->context.index_regs[i].txhubport);
2396 2394
2397 ep_target_regs = 2395 ep_target_regs =
2398 musb_read_target_reg_base(i, musb_base); 2396 musb_read_target_reg_base(i, musb_base);
2399 2397
2400 musb_write_rxfunaddr(ep_target_regs, 2398 musb_write_rxfunaddr(ep_target_regs,
2401 musb_context.index_regs[i].rxfunaddr); 2399 musb->context.index_regs[i].rxfunaddr);
2402 musb_write_rxhubaddr(ep_target_regs, 2400 musb_write_rxhubaddr(ep_target_regs,
2403 musb_context.index_regs[i].rxhubaddr); 2401 musb->context.index_regs[i].rxhubaddr);
2404 musb_write_rxhubport(ep_target_regs, 2402 musb_write_rxhubport(ep_target_regs,
2405 musb_context.index_regs[i].rxhubport); 2403 musb->context.index_regs[i].rxhubport);
2406 } 2404 }
2407 } 2405 }
2408} 2406}
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 68fc76f5e316..cb393e4a3722 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -353,6 +353,33 @@ static inline struct usb_request *next_out_request(struct musb_hw_ep *hw_ep)
353#endif 353#endif
354} 354}
355 355
356struct musb_csr_regs {
357 /* FIFO registers */
358 u16 txmaxp, txcsr, rxmaxp, rxcsr;
359 u16 rxfifoadd, txfifoadd;
360 u8 txtype, txinterval, rxtype, rxinterval;
361 u8 rxfifosz, txfifosz;
362 u8 txfunaddr, txhubaddr, txhubport;
363 u8 rxfunaddr, rxhubaddr, rxhubport;
364};
365
366struct musb_context_registers {
367
368#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
369 defined(CONFIG_ARCH_OMAP4)
370 u32 otg_sysconfig, otg_forcestandby;
371#endif
372 u8 power;
373 u16 intrtxe, intrrxe;
374 u8 intrusbe;
375 u16 frame;
376 u8 index, testmode;
377
378 u8 devctl, busctl, misc;
379
380 struct musb_csr_regs index_regs[MUSB_C_NUM_EPS];
381};
382
356/* 383/*
357 * struct musb - Driver instance data. 384 * struct musb - Driver instance data.
358 */ 385 */
@@ -363,6 +390,7 @@ struct musb {
363 struct clk *phy_clock; 390 struct clk *phy_clock;
364 391
365 const struct musb_platform_ops *ops; 392 const struct musb_platform_ops *ops;
393 struct musb_context_registers context;
366 394
367 irqreturn_t (*isr)(int, void *); 395 irqreturn_t (*isr)(int, void *);
368 struct work_struct irq_work; 396 struct work_struct irq_work;
@@ -582,33 +610,6 @@ extern irqreturn_t musb_interrupt(struct musb *);
582extern void musb_hnp_stop(struct musb *musb); 610extern void musb_hnp_stop(struct musb *musb);
583 611
584#ifdef CONFIG_PM 612#ifdef CONFIG_PM
585struct musb_csr_regs {
586 /* FIFO registers */
587 u16 txmaxp, txcsr, rxmaxp, rxcsr;
588 u16 rxfifoadd, txfifoadd;
589 u8 txtype, txinterval, rxtype, rxinterval;
590 u8 rxfifosz, txfifosz;
591 u8 txfunaddr, txhubaddr, txhubport;
592 u8 rxfunaddr, rxhubaddr, rxhubport;
593};
594
595struct musb_context_registers {
596
597#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
598 defined(CONFIG_ARCH_OMAP4)
599 u32 otg_sysconfig, otg_forcestandby;
600#endif
601 u8 power;
602 u16 intrtxe, intrrxe;
603 u8 intrusbe;
604 u16 frame;
605 u8 index, testmode;
606
607 u8 devctl, busctl, misc;
608
609 struct musb_csr_regs index_regs[MUSB_C_NUM_EPS];
610};
611
612#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ 613#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
613 defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_BLACKFIN) 614 defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_BLACKFIN)
614extern void musb_platform_save_context(struct musb *musb, 615extern void musb_platform_save_context(struct musb *musb,