diff options
author | Paul Mundt <lethal@linux-sh.org> | 2009-08-23 05:02:59 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2009-08-23 05:02:59 -0400 |
commit | 0858d9c0c591ce9baa1baf72eaf6f67823f3bc25 (patch) | |
tree | 1ea697a8e34ff1784572db22bcb5c9da7bbfb40c /drivers | |
parent | 9d7302299ee96ca954fe4ab8ca640333b6e19ad0 (diff) | |
parent | 963e04cafbf001ec431025a46ec246ae6d89daba (diff) |
Merge branch 'sh/hwblk' into sh/pm-runtime
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/serial/sh-sci.c | 5 | ||||
-rw-r--r-- | drivers/usb/gadget/Kconfig | 10 | ||||
-rw-r--r-- | drivers/usb/gadget/m66592-udc.c | 284 | ||||
-rw-r--r-- | drivers/usb/gadget/m66592-udc.h | 90 | ||||
-rw-r--r-- | drivers/usb/host/Kconfig | 7 | ||||
-rw-r--r-- | drivers/usb/host/r8a66597-hcd.c | 210 | ||||
-rw-r--r-- | drivers/usb/host/r8a66597.h | 440 | ||||
-rw-r--r-- | drivers/video/Kconfig | 2 | ||||
-rw-r--r-- | drivers/video/sh_mobile_lcdcfb.c | 21 |
9 files changed, 367 insertions, 702 deletions
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c index 8e2feb563347..4cbb87ad070a 100644 --- a/drivers/serial/sh-sci.c +++ b/drivers/serial/sh-sci.c | |||
@@ -662,10 +662,11 @@ static irqreturn_t sci_rx_interrupt(int irq, void *port) | |||
662 | static irqreturn_t sci_tx_interrupt(int irq, void *ptr) | 662 | static irqreturn_t sci_tx_interrupt(int irq, void *ptr) |
663 | { | 663 | { |
664 | struct uart_port *port = ptr; | 664 | struct uart_port *port = ptr; |
665 | unsigned long flags; | ||
665 | 666 | ||
666 | spin_lock_irq(&port->lock); | 667 | spin_lock_irqsave(&port->lock, flags); |
667 | sci_transmit_chars(port); | 668 | sci_transmit_chars(port); |
668 | spin_unlock_irq(&port->lock); | 669 | spin_unlock_irqrestore(&port->lock, flags); |
669 | 670 | ||
670 | return IRQ_HANDLED; | 671 | return IRQ_HANDLED; |
671 | } | 672 | } |
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 7f8e83a954ac..b7f10bc25c2c 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig | |||
@@ -360,16 +360,6 @@ config USB_M66592 | |||
360 | default USB_GADGET | 360 | default USB_GADGET |
361 | select USB_GADGET_SELECTED | 361 | select USB_GADGET_SELECTED |
362 | 362 | ||
363 | config SUPERH_BUILT_IN_M66592 | ||
364 | boolean "Enable SuperH built-in USB like the M66592" | ||
365 | depends on USB_GADGET_M66592 && CPU_SUBTYPE_SH7722 | ||
366 | help | ||
367 | SH7722 has USB like the M66592. | ||
368 | |||
369 | The transfer rate is very slow when use "Ethernet Gadget". | ||
370 | However, this problem is improved if change a value of | ||
371 | NET_IP_ALIGN to 4. | ||
372 | |||
373 | # | 363 | # |
374 | # Controllers available only in discrete form (and all PCI controllers) | 364 | # Controllers available only in discrete form (and all PCI controllers) |
375 | # | 365 | # |
diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c index 43dcf9e1af6b..a61c70caff12 100644 --- a/drivers/usb/gadget/m66592-udc.c +++ b/drivers/usb/gadget/m66592-udc.c | |||
@@ -31,38 +31,12 @@ | |||
31 | 31 | ||
32 | #include "m66592-udc.h" | 32 | #include "m66592-udc.h" |
33 | 33 | ||
34 | |||
35 | MODULE_DESCRIPTION("M66592 USB gadget driver"); | 34 | MODULE_DESCRIPTION("M66592 USB gadget driver"); |
36 | MODULE_LICENSE("GPL"); | 35 | MODULE_LICENSE("GPL"); |
37 | MODULE_AUTHOR("Yoshihiro Shimoda"); | 36 | MODULE_AUTHOR("Yoshihiro Shimoda"); |
38 | MODULE_ALIAS("platform:m66592_udc"); | 37 | MODULE_ALIAS("platform:m66592_udc"); |
39 | 38 | ||
40 | #define DRIVER_VERSION "18 Oct 2007" | 39 | #define DRIVER_VERSION "21 July 2009" |
41 | |||
42 | /* module parameters */ | ||
43 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) | ||
44 | static unsigned short endian = M66592_LITTLE; | ||
45 | module_param(endian, ushort, 0644); | ||
46 | MODULE_PARM_DESC(endian, "data endian: big=0, little=0 (default=0)"); | ||
47 | #else | ||
48 | static unsigned short clock = M66592_XTAL24; | ||
49 | module_param(clock, ushort, 0644); | ||
50 | MODULE_PARM_DESC(clock, "input clock: 48MHz=32768, 24MHz=16384, 12MHz=0 " | ||
51 | "(default=16384)"); | ||
52 | |||
53 | static unsigned short vif = M66592_LDRV; | ||
54 | module_param(vif, ushort, 0644); | ||
55 | MODULE_PARM_DESC(vif, "input VIF: 3.3V=32768, 1.5V=0 (default=32768)"); | ||
56 | |||
57 | static unsigned short endian; | ||
58 | module_param(endian, ushort, 0644); | ||
59 | MODULE_PARM_DESC(endian, "data endian: big=256, little=0 (default=0)"); | ||
60 | |||
61 | static unsigned short irq_sense = M66592_INTL; | ||
62 | module_param(irq_sense, ushort, 0644); | ||
63 | MODULE_PARM_DESC(irq_sense, "IRQ sense: low level=2, falling edge=0 " | ||
64 | "(default=2)"); | ||
65 | #endif | ||
66 | 40 | ||
67 | static const char udc_name[] = "m66592_udc"; | 41 | static const char udc_name[] = "m66592_udc"; |
68 | static const char *m66592_ep_name[] = { | 42 | static const char *m66592_ep_name[] = { |
@@ -244,6 +218,7 @@ static inline int get_buffer_size(struct m66592 *m66592, u16 pipenum) | |||
244 | static inline void pipe_change(struct m66592 *m66592, u16 pipenum) | 218 | static inline void pipe_change(struct m66592 *m66592, u16 pipenum) |
245 | { | 219 | { |
246 | struct m66592_ep *ep = m66592->pipenum2ep[pipenum]; | 220 | struct m66592_ep *ep = m66592->pipenum2ep[pipenum]; |
221 | unsigned short mbw; | ||
247 | 222 | ||
248 | if (ep->use_dma) | 223 | if (ep->use_dma) |
249 | return; | 224 | return; |
@@ -252,7 +227,12 @@ static inline void pipe_change(struct m66592 *m66592, u16 pipenum) | |||
252 | 227 | ||
253 | ndelay(450); | 228 | ndelay(450); |
254 | 229 | ||
255 | m66592_bset(m66592, M66592_MBW, ep->fifosel); | 230 | if (m66592->pdata->on_chip) |
231 | mbw = M66592_MBW_32; | ||
232 | else | ||
233 | mbw = M66592_MBW_16; | ||
234 | |||
235 | m66592_bset(m66592, mbw, ep->fifosel); | ||
256 | } | 236 | } |
257 | 237 | ||
258 | static int pipe_buffer_setting(struct m66592 *m66592, | 238 | static int pipe_buffer_setting(struct m66592 *m66592, |
@@ -276,24 +256,27 @@ static int pipe_buffer_setting(struct m66592 *m66592, | |||
276 | buf_bsize = 0; | 256 | buf_bsize = 0; |
277 | break; | 257 | break; |
278 | case M66592_BULK: | 258 | case M66592_BULK: |
279 | bufnum = m66592->bi_bufnum + | 259 | /* isochronous pipes may be used as bulk pipes */ |
280 | (info->pipe - M66592_BASE_PIPENUM_BULK) * 16; | 260 | if (info->pipe > M66592_BASE_PIPENUM_BULK) |
281 | m66592->bi_bufnum += 16; | 261 | bufnum = info->pipe - M66592_BASE_PIPENUM_BULK; |
262 | else | ||
263 | bufnum = info->pipe - M66592_BASE_PIPENUM_ISOC; | ||
264 | |||
265 | bufnum = M66592_BASE_BUFNUM + (bufnum * 16); | ||
282 | buf_bsize = 7; | 266 | buf_bsize = 7; |
283 | pipecfg |= M66592_DBLB; | 267 | pipecfg |= M66592_DBLB; |
284 | if (!info->dir_in) | 268 | if (!info->dir_in) |
285 | pipecfg |= M66592_SHTNAK; | 269 | pipecfg |= M66592_SHTNAK; |
286 | break; | 270 | break; |
287 | case M66592_ISO: | 271 | case M66592_ISO: |
288 | bufnum = m66592->bi_bufnum + | 272 | bufnum = M66592_BASE_BUFNUM + |
289 | (info->pipe - M66592_BASE_PIPENUM_ISOC) * 16; | 273 | (info->pipe - M66592_BASE_PIPENUM_ISOC) * 16; |
290 | m66592->bi_bufnum += 16; | ||
291 | buf_bsize = 7; | 274 | buf_bsize = 7; |
292 | break; | 275 | break; |
293 | } | 276 | } |
294 | if (m66592->bi_bufnum > M66592_MAX_BUFNUM) { | 277 | |
295 | pr_err("m66592 pipe memory is insufficient(%d)\n", | 278 | if (buf_bsize && ((bufnum + 16) >= M66592_MAX_BUFNUM)) { |
296 | m66592->bi_bufnum); | 279 | pr_err("m66592 pipe memory is insufficient\n"); |
297 | return -ENOMEM; | 280 | return -ENOMEM; |
298 | } | 281 | } |
299 | 282 | ||
@@ -313,17 +296,6 @@ static void pipe_buffer_release(struct m66592 *m66592, | |||
313 | if (info->pipe == 0) | 296 | if (info->pipe == 0) |
314 | return; | 297 | return; |
315 | 298 | ||
316 | switch (info->type) { | ||
317 | case M66592_BULK: | ||
318 | if (is_bulk_pipe(info->pipe)) | ||
319 | m66592->bi_bufnum -= 16; | ||
320 | break; | ||
321 | case M66592_ISO: | ||
322 | if (is_isoc_pipe(info->pipe)) | ||
323 | m66592->bi_bufnum -= 16; | ||
324 | break; | ||
325 | } | ||
326 | |||
327 | if (is_bulk_pipe(info->pipe)) { | 299 | if (is_bulk_pipe(info->pipe)) { |
328 | m66592->bulk--; | 300 | m66592->bulk--; |
329 | } else if (is_interrupt_pipe(info->pipe)) | 301 | } else if (is_interrupt_pipe(info->pipe)) |
@@ -340,6 +312,7 @@ static void pipe_buffer_release(struct m66592 *m66592, | |||
340 | static void pipe_initialize(struct m66592_ep *ep) | 312 | static void pipe_initialize(struct m66592_ep *ep) |
341 | { | 313 | { |
342 | struct m66592 *m66592 = ep->m66592; | 314 | struct m66592 *m66592 = ep->m66592; |
315 | unsigned short mbw; | ||
343 | 316 | ||
344 | m66592_mdfy(m66592, 0, M66592_CURPIPE, ep->fifosel); | 317 | m66592_mdfy(m66592, 0, M66592_CURPIPE, ep->fifosel); |
345 | 318 | ||
@@ -351,7 +324,12 @@ static void pipe_initialize(struct m66592_ep *ep) | |||
351 | 324 | ||
352 | ndelay(450); | 325 | ndelay(450); |
353 | 326 | ||
354 | m66592_bset(m66592, M66592_MBW, ep->fifosel); | 327 | if (m66592->pdata->on_chip) |
328 | mbw = M66592_MBW_32; | ||
329 | else | ||
330 | mbw = M66592_MBW_16; | ||
331 | |||
332 | m66592_bset(m66592, mbw, ep->fifosel); | ||
355 | } | 333 | } |
356 | } | 334 | } |
357 | 335 | ||
@@ -367,15 +345,13 @@ static void m66592_ep_setting(struct m66592 *m66592, struct m66592_ep *ep, | |||
367 | ep->fifosel = M66592_D0FIFOSEL; | 345 | ep->fifosel = M66592_D0FIFOSEL; |
368 | ep->fifoctr = M66592_D0FIFOCTR; | 346 | ep->fifoctr = M66592_D0FIFOCTR; |
369 | ep->fifotrn = M66592_D0FIFOTRN; | 347 | ep->fifotrn = M66592_D0FIFOTRN; |
370 | #if !defined(CONFIG_SUPERH_BUILT_IN_M66592) | 348 | } else if (!m66592->pdata->on_chip && m66592->num_dma == 1) { |
371 | } else if (m66592->num_dma == 1) { | ||
372 | m66592->num_dma++; | 349 | m66592->num_dma++; |
373 | ep->use_dma = 1; | 350 | ep->use_dma = 1; |
374 | ep->fifoaddr = M66592_D1FIFO; | 351 | ep->fifoaddr = M66592_D1FIFO; |
375 | ep->fifosel = M66592_D1FIFOSEL; | 352 | ep->fifosel = M66592_D1FIFOSEL; |
376 | ep->fifoctr = M66592_D1FIFOCTR; | 353 | ep->fifoctr = M66592_D1FIFOCTR; |
377 | ep->fifotrn = M66592_D1FIFOTRN; | 354 | ep->fifotrn = M66592_D1FIFOTRN; |
378 | #endif | ||
379 | } else { | 355 | } else { |
380 | ep->use_dma = 0; | 356 | ep->use_dma = 0; |
381 | ep->fifoaddr = M66592_CFIFO; | 357 | ep->fifoaddr = M66592_CFIFO; |
@@ -620,76 +596,120 @@ static void start_ep0(struct m66592_ep *ep, struct m66592_request *req) | |||
620 | } | 596 | } |
621 | } | 597 | } |
622 | 598 | ||
623 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) | ||
624 | static void init_controller(struct m66592 *m66592) | 599 | static void init_controller(struct m66592 *m66592) |
625 | { | 600 | { |
626 | m66592_bset(m66592, M66592_HSE, M66592_SYSCFG); /* High spd */ | 601 | unsigned int endian; |
627 | m66592_bclr(m66592, M66592_USBE, M66592_SYSCFG); | ||
628 | m66592_bclr(m66592, M66592_DPRPU, M66592_SYSCFG); | ||
629 | m66592_bset(m66592, M66592_USBE, M66592_SYSCFG); | ||
630 | 602 | ||
631 | /* This is a workaound for SH7722 2nd cut */ | 603 | if (m66592->pdata->on_chip) { |
632 | m66592_bset(m66592, 0x8000, M66592_DVSTCTR); | 604 | if (m66592->pdata->endian) |
633 | m66592_bset(m66592, 0x1000, M66592_TESTMODE); | 605 | endian = 0; /* big endian */ |
634 | m66592_bclr(m66592, 0x8000, M66592_DVSTCTR); | 606 | else |
607 | endian = M66592_LITTLE; /* little endian */ | ||
635 | 608 | ||
636 | m66592_bset(m66592, M66592_INTL, M66592_INTENB1); | 609 | m66592_bset(m66592, M66592_HSE, M66592_SYSCFG); /* High spd */ |
610 | m66592_bclr(m66592, M66592_USBE, M66592_SYSCFG); | ||
611 | m66592_bclr(m66592, M66592_DPRPU, M66592_SYSCFG); | ||
612 | m66592_bset(m66592, M66592_USBE, M66592_SYSCFG); | ||
637 | 613 | ||
638 | m66592_write(m66592, 0, M66592_CFBCFG); | 614 | /* This is a workaound for SH7722 2nd cut */ |
639 | m66592_write(m66592, 0, M66592_D0FBCFG); | 615 | m66592_bset(m66592, 0x8000, M66592_DVSTCTR); |
640 | m66592_bset(m66592, endian, M66592_CFBCFG); | 616 | m66592_bset(m66592, 0x1000, M66592_TESTMODE); |
641 | m66592_bset(m66592, endian, M66592_D0FBCFG); | 617 | m66592_bclr(m66592, 0x8000, M66592_DVSTCTR); |
642 | } | ||
643 | #else /* #if defined(CONFIG_SUPERH_BUILT_IN_M66592) */ | ||
644 | static void init_controller(struct m66592 *m66592) | ||
645 | { | ||
646 | m66592_bset(m66592, (vif & M66592_LDRV) | (endian & M66592_BIGEND), | ||
647 | M66592_PINCFG); | ||
648 | m66592_bset(m66592, M66592_HSE, M66592_SYSCFG); /* High spd */ | ||
649 | m66592_mdfy(m66592, clock & M66592_XTAL, M66592_XTAL, M66592_SYSCFG); | ||
650 | 618 | ||
651 | m66592_bclr(m66592, M66592_USBE, M66592_SYSCFG); | 619 | m66592_bset(m66592, M66592_INTL, M66592_INTENB1); |
652 | m66592_bclr(m66592, M66592_DPRPU, M66592_SYSCFG); | ||
653 | m66592_bset(m66592, M66592_USBE, M66592_SYSCFG); | ||
654 | 620 | ||
655 | m66592_bset(m66592, M66592_XCKE, M66592_SYSCFG); | 621 | m66592_write(m66592, 0, M66592_CFBCFG); |
622 | m66592_write(m66592, 0, M66592_D0FBCFG); | ||
623 | m66592_bset(m66592, endian, M66592_CFBCFG); | ||
624 | m66592_bset(m66592, endian, M66592_D0FBCFG); | ||
625 | } else { | ||
626 | unsigned int clock, vif, irq_sense; | ||
656 | 627 | ||
657 | msleep(3); | 628 | if (m66592->pdata->endian) |
629 | endian = M66592_BIGEND; /* big endian */ | ||
630 | else | ||
631 | endian = 0; /* little endian */ | ||
658 | 632 | ||
659 | m66592_bset(m66592, M66592_RCKE | M66592_PLLC, M66592_SYSCFG); | 633 | if (m66592->pdata->vif) |
634 | vif = M66592_LDRV; /* 3.3v */ | ||
635 | else | ||
636 | vif = 0; /* 1.5v */ | ||
660 | 637 | ||
661 | msleep(1); | 638 | switch (m66592->pdata->xtal) { |
639 | case M66592_PLATDATA_XTAL_12MHZ: | ||
640 | clock = M66592_XTAL12; | ||
641 | break; | ||
642 | case M66592_PLATDATA_XTAL_24MHZ: | ||
643 | clock = M66592_XTAL24; | ||
644 | break; | ||
645 | case M66592_PLATDATA_XTAL_48MHZ: | ||
646 | clock = M66592_XTAL48; | ||
647 | break; | ||
648 | default: | ||
649 | pr_warning("m66592-udc: xtal configuration error\n"); | ||
650 | clock = 0; | ||
651 | } | ||
662 | 652 | ||
663 | m66592_bset(m66592, M66592_SCKE, M66592_SYSCFG); | 653 | switch (m66592->irq_trigger) { |
654 | case IRQF_TRIGGER_LOW: | ||
655 | irq_sense = M66592_INTL; | ||
656 | break; | ||
657 | case IRQF_TRIGGER_FALLING: | ||
658 | irq_sense = 0; | ||
659 | break; | ||
660 | default: | ||
661 | pr_warning("m66592-udc: irq trigger config error\n"); | ||
662 | irq_sense = 0; | ||
663 | } | ||
664 | |||
665 | m66592_bset(m66592, | ||
666 | (vif & M66592_LDRV) | (endian & M66592_BIGEND), | ||
667 | M66592_PINCFG); | ||
668 | m66592_bset(m66592, M66592_HSE, M66592_SYSCFG); /* High spd */ | ||
669 | m66592_mdfy(m66592, clock & M66592_XTAL, M66592_XTAL, | ||
670 | M66592_SYSCFG); | ||
671 | m66592_bclr(m66592, M66592_USBE, M66592_SYSCFG); | ||
672 | m66592_bclr(m66592, M66592_DPRPU, M66592_SYSCFG); | ||
673 | m66592_bset(m66592, M66592_USBE, M66592_SYSCFG); | ||
674 | |||
675 | m66592_bset(m66592, M66592_XCKE, M66592_SYSCFG); | ||
676 | |||
677 | msleep(3); | ||
664 | 678 | ||
665 | m66592_bset(m66592, irq_sense & M66592_INTL, M66592_INTENB1); | 679 | m66592_bset(m66592, M66592_RCKE | M66592_PLLC, M66592_SYSCFG); |
666 | m66592_write(m66592, M66592_BURST | M66592_CPU_ADR_RD_WR, | 680 | |
667 | M66592_DMA0CFG); | 681 | msleep(1); |
682 | |||
683 | m66592_bset(m66592, M66592_SCKE, M66592_SYSCFG); | ||
684 | |||
685 | m66592_bset(m66592, irq_sense & M66592_INTL, M66592_INTENB1); | ||
686 | m66592_write(m66592, M66592_BURST | M66592_CPU_ADR_RD_WR, | ||
687 | M66592_DMA0CFG); | ||
688 | } | ||
668 | } | 689 | } |
669 | #endif /* #if defined(CONFIG_SUPERH_BUILT_IN_M66592) */ | ||
670 | 690 | ||
671 | static void disable_controller(struct m66592 *m66592) | 691 | static void disable_controller(struct m66592 *m66592) |
672 | { | 692 | { |
673 | #if !defined(CONFIG_SUPERH_BUILT_IN_M66592) | 693 | if (!m66592->pdata->on_chip) { |
674 | m66592_bclr(m66592, M66592_SCKE, M66592_SYSCFG); | 694 | m66592_bclr(m66592, M66592_SCKE, M66592_SYSCFG); |
675 | udelay(1); | 695 | udelay(1); |
676 | m66592_bclr(m66592, M66592_PLLC, M66592_SYSCFG); | 696 | m66592_bclr(m66592, M66592_PLLC, M66592_SYSCFG); |
677 | udelay(1); | 697 | udelay(1); |
678 | m66592_bclr(m66592, M66592_RCKE, M66592_SYSCFG); | 698 | m66592_bclr(m66592, M66592_RCKE, M66592_SYSCFG); |
679 | udelay(1); | 699 | udelay(1); |
680 | m66592_bclr(m66592, M66592_XCKE, M66592_SYSCFG); | 700 | m66592_bclr(m66592, M66592_XCKE, M66592_SYSCFG); |
681 | #endif | 701 | } |
682 | } | 702 | } |
683 | 703 | ||
684 | static void m66592_start_xclock(struct m66592 *m66592) | 704 | static void m66592_start_xclock(struct m66592 *m66592) |
685 | { | 705 | { |
686 | #if !defined(CONFIG_SUPERH_BUILT_IN_M66592) | ||
687 | u16 tmp; | 706 | u16 tmp; |
688 | 707 | ||
689 | tmp = m66592_read(m66592, M66592_SYSCFG); | 708 | if (!m66592->pdata->on_chip) { |
690 | if (!(tmp & M66592_XCKE)) | 709 | tmp = m66592_read(m66592, M66592_SYSCFG); |
691 | m66592_bset(m66592, M66592_XCKE, M66592_SYSCFG); | 710 | if (!(tmp & M66592_XCKE)) |
692 | #endif | 711 | m66592_bset(m66592, M66592_XCKE, M66592_SYSCFG); |
712 | } | ||
693 | } | 713 | } |
694 | 714 | ||
695 | /*-------------------------------------------------------------------------*/ | 715 | /*-------------------------------------------------------------------------*/ |
@@ -1177,8 +1197,7 @@ static irqreturn_t m66592_irq(int irq, void *_m66592) | |||
1177 | intsts0 = m66592_read(m66592, M66592_INTSTS0); | 1197 | intsts0 = m66592_read(m66592, M66592_INTSTS0); |
1178 | intenb0 = m66592_read(m66592, M66592_INTENB0); | 1198 | intenb0 = m66592_read(m66592, M66592_INTENB0); |
1179 | 1199 | ||
1180 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) | 1200 | if (m66592->pdata->on_chip && !intsts0 && !intenb0) { |
1181 | if (!intsts0 && !intenb0) { | ||
1182 | /* | 1201 | /* |
1183 | * When USB clock stops, it cannot read register. Even if a | 1202 | * When USB clock stops, it cannot read register. Even if a |
1184 | * clock stops, the interrupt occurs. So this driver turn on | 1203 | * clock stops, the interrupt occurs. So this driver turn on |
@@ -1188,7 +1207,6 @@ static irqreturn_t m66592_irq(int irq, void *_m66592) | |||
1188 | intsts0 = m66592_read(m66592, M66592_INTSTS0); | 1207 | intsts0 = m66592_read(m66592, M66592_INTSTS0); |
1189 | intenb0 = m66592_read(m66592, M66592_INTENB0); | 1208 | intenb0 = m66592_read(m66592, M66592_INTENB0); |
1190 | } | 1209 | } |
1191 | #endif | ||
1192 | 1210 | ||
1193 | savepipe = m66592_read(m66592, M66592_CFIFOSEL); | 1211 | savepipe = m66592_read(m66592, M66592_CFIFOSEL); |
1194 | 1212 | ||
@@ -1534,9 +1552,11 @@ static int __exit m66592_remove(struct platform_device *pdev) | |||
1534 | iounmap(m66592->reg); | 1552 | iounmap(m66592->reg); |
1535 | free_irq(platform_get_irq(pdev, 0), m66592); | 1553 | free_irq(platform_get_irq(pdev, 0), m66592); |
1536 | m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); | 1554 | m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); |
1537 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) && defined(CONFIG_HAVE_CLK) | 1555 | #ifdef CONFIG_HAVE_CLK |
1538 | clk_disable(m66592->clk); | 1556 | if (m66592->pdata->on_chip) { |
1539 | clk_put(m66592->clk); | 1557 | clk_disable(m66592->clk); |
1558 | clk_put(m66592->clk); | ||
1559 | } | ||
1540 | #endif | 1560 | #endif |
1541 | kfree(m66592); | 1561 | kfree(m66592); |
1542 | return 0; | 1562 | return 0; |
@@ -1548,11 +1568,10 @@ static void nop_completion(struct usb_ep *ep, struct usb_request *r) | |||
1548 | 1568 | ||
1549 | static int __init m66592_probe(struct platform_device *pdev) | 1569 | static int __init m66592_probe(struct platform_device *pdev) |
1550 | { | 1570 | { |
1551 | struct resource *res; | 1571 | struct resource *res, *ires; |
1552 | int irq; | ||
1553 | void __iomem *reg = NULL; | 1572 | void __iomem *reg = NULL; |
1554 | struct m66592 *m66592 = NULL; | 1573 | struct m66592 *m66592 = NULL; |
1555 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) && defined(CONFIG_HAVE_CLK) | 1574 | #ifdef CONFIG_HAVE_CLK |
1556 | char clk_name[8]; | 1575 | char clk_name[8]; |
1557 | #endif | 1576 | #endif |
1558 | int ret = 0; | 1577 | int ret = 0; |
@@ -1565,10 +1584,11 @@ static int __init m66592_probe(struct platform_device *pdev) | |||
1565 | goto clean_up; | 1584 | goto clean_up; |
1566 | } | 1585 | } |
1567 | 1586 | ||
1568 | irq = platform_get_irq(pdev, 0); | 1587 | ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
1569 | if (irq < 0) { | 1588 | if (!ires) { |
1570 | ret = -ENODEV; | 1589 | ret = -ENODEV; |
1571 | pr_err("platform_get_irq error.\n"); | 1590 | dev_err(&pdev->dev, |
1591 | "platform_get_resource IORESOURCE_IRQ error.\n"); | ||
1572 | goto clean_up; | 1592 | goto clean_up; |
1573 | } | 1593 | } |
1574 | 1594 | ||
@@ -1579,6 +1599,12 @@ static int __init m66592_probe(struct platform_device *pdev) | |||
1579 | goto clean_up; | 1599 | goto clean_up; |
1580 | } | 1600 | } |
1581 | 1601 | ||
1602 | if (pdev->dev.platform_data == NULL) { | ||
1603 | dev_err(&pdev->dev, "no platform data\n"); | ||
1604 | ret = -ENODEV; | ||
1605 | goto clean_up; | ||
1606 | } | ||
1607 | |||
1582 | /* initialize ucd */ | 1608 | /* initialize ucd */ |
1583 | m66592 = kzalloc(sizeof(struct m66592), GFP_KERNEL); | 1609 | m66592 = kzalloc(sizeof(struct m66592), GFP_KERNEL); |
1584 | if (m66592 == NULL) { | 1610 | if (m66592 == NULL) { |
@@ -1586,6 +1612,9 @@ static int __init m66592_probe(struct platform_device *pdev) | |||
1586 | goto clean_up; | 1612 | goto clean_up; |
1587 | } | 1613 | } |
1588 | 1614 | ||
1615 | m66592->pdata = pdev->dev.platform_data; | ||
1616 | m66592->irq_trigger = ires->flags & IRQF_TRIGGER_MASK; | ||
1617 | |||
1589 | spin_lock_init(&m66592->lock); | 1618 | spin_lock_init(&m66592->lock); |
1590 | dev_set_drvdata(&pdev->dev, m66592); | 1619 | dev_set_drvdata(&pdev->dev, m66592); |
1591 | 1620 | ||
@@ -1603,24 +1632,25 @@ static int __init m66592_probe(struct platform_device *pdev) | |||
1603 | m66592->timer.data = (unsigned long)m66592; | 1632 | m66592->timer.data = (unsigned long)m66592; |
1604 | m66592->reg = reg; | 1633 | m66592->reg = reg; |
1605 | 1634 | ||
1606 | m66592->bi_bufnum = M66592_BASE_BUFNUM; | 1635 | ret = request_irq(ires->start, m66592_irq, IRQF_DISABLED | IRQF_SHARED, |
1607 | |||
1608 | ret = request_irq(irq, m66592_irq, IRQF_DISABLED | IRQF_SHARED, | ||
1609 | udc_name, m66592); | 1636 | udc_name, m66592); |
1610 | if (ret < 0) { | 1637 | if (ret < 0) { |
1611 | pr_err("request_irq error (%d)\n", ret); | 1638 | pr_err("request_irq error (%d)\n", ret); |
1612 | goto clean_up; | 1639 | goto clean_up; |
1613 | } | 1640 | } |
1614 | 1641 | ||
1615 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) && defined(CONFIG_HAVE_CLK) | 1642 | #ifdef CONFIG_HAVE_CLK |
1616 | snprintf(clk_name, sizeof(clk_name), "usbf%d", pdev->id); | 1643 | if (m66592->pdata->on_chip) { |
1617 | m66592->clk = clk_get(&pdev->dev, clk_name); | 1644 | snprintf(clk_name, sizeof(clk_name), "usbf%d", pdev->id); |
1618 | if (IS_ERR(m66592->clk)) { | 1645 | m66592->clk = clk_get(&pdev->dev, clk_name); |
1619 | dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name); | 1646 | if (IS_ERR(m66592->clk)) { |
1620 | ret = PTR_ERR(m66592->clk); | 1647 | dev_err(&pdev->dev, "cannot get clock \"%s\"\n", |
1621 | goto clean_up2; | 1648 | clk_name); |
1649 | ret = PTR_ERR(m66592->clk); | ||
1650 | goto clean_up2; | ||
1651 | } | ||
1652 | clk_enable(m66592->clk); | ||
1622 | } | 1653 | } |
1623 | clk_enable(m66592->clk); | ||
1624 | #endif | 1654 | #endif |
1625 | INIT_LIST_HEAD(&m66592->gadget.ep_list); | 1655 | INIT_LIST_HEAD(&m66592->gadget.ep_list); |
1626 | m66592->gadget.ep0 = &m66592->ep[0].ep; | 1656 | m66592->gadget.ep0 = &m66592->ep[0].ep; |
@@ -1662,12 +1692,14 @@ static int __init m66592_probe(struct platform_device *pdev) | |||
1662 | return 0; | 1692 | return 0; |
1663 | 1693 | ||
1664 | clean_up3: | 1694 | clean_up3: |
1665 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) && defined(CONFIG_HAVE_CLK) | 1695 | #ifdef CONFIG_HAVE_CLK |
1666 | clk_disable(m66592->clk); | 1696 | if (m66592->pdata->on_chip) { |
1667 | clk_put(m66592->clk); | 1697 | clk_disable(m66592->clk); |
1698 | clk_put(m66592->clk); | ||
1699 | } | ||
1668 | clean_up2: | 1700 | clean_up2: |
1669 | #endif | 1701 | #endif |
1670 | free_irq(irq, m66592); | 1702 | free_irq(ires->start, m66592); |
1671 | clean_up: | 1703 | clean_up: |
1672 | if (m66592) { | 1704 | if (m66592) { |
1673 | if (m66592->ep0_req) | 1705 | if (m66592->ep0_req) |
diff --git a/drivers/usb/gadget/m66592-udc.h b/drivers/usb/gadget/m66592-udc.h index 286ce07e7960..8b960deed680 100644 --- a/drivers/usb/gadget/m66592-udc.h +++ b/drivers/usb/gadget/m66592-udc.h | |||
@@ -23,10 +23,12 @@ | |||
23 | #ifndef __M66592_UDC_H__ | 23 | #ifndef __M66592_UDC_H__ |
24 | #define __M66592_UDC_H__ | 24 | #define __M66592_UDC_H__ |
25 | 25 | ||
26 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) && defined(CONFIG_HAVE_CLK) | 26 | #ifdef CONFIG_HAVE_CLK |
27 | #include <linux/clk.h> | 27 | #include <linux/clk.h> |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #include <linux/usb/m66592.h> | ||
31 | |||
30 | #define M66592_SYSCFG 0x00 | 32 | #define M66592_SYSCFG 0x00 |
31 | #define M66592_XTAL 0xC000 /* b15-14: Crystal selection */ | 33 | #define M66592_XTAL 0xC000 /* b15-14: Crystal selection */ |
32 | #define M66592_XTAL48 0x8000 /* 48MHz */ | 34 | #define M66592_XTAL48 0x8000 /* 48MHz */ |
@@ -76,11 +78,11 @@ | |||
76 | #define M66592_P_TST_J 0x0001 /* PERI TEST J */ | 78 | #define M66592_P_TST_J 0x0001 /* PERI TEST J */ |
77 | #define M66592_P_TST_NORMAL 0x0000 /* PERI Normal Mode */ | 79 | #define M66592_P_TST_NORMAL 0x0000 /* PERI Normal Mode */ |
78 | 80 | ||
79 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) | 81 | /* built-in registers */ |
80 | #define M66592_CFBCFG 0x0A | 82 | #define M66592_CFBCFG 0x0A |
81 | #define M66592_D0FBCFG 0x0C | 83 | #define M66592_D0FBCFG 0x0C |
82 | #define M66592_LITTLE 0x0100 /* b8: Little endian mode */ | 84 | #define M66592_LITTLE 0x0100 /* b8: Little endian mode */ |
83 | #else | 85 | /* external chip case */ |
84 | #define M66592_PINCFG 0x0A | 86 | #define M66592_PINCFG 0x0A |
85 | #define M66592_LDRV 0x8000 /* b15: Drive Current Adjust */ | 87 | #define M66592_LDRV 0x8000 /* b15: Drive Current Adjust */ |
86 | #define M66592_BIGEND 0x0100 /* b8: Big endian mode */ | 88 | #define M66592_BIGEND 0x0100 /* b8: Big endian mode */ |
@@ -100,8 +102,8 @@ | |||
100 | #define M66592_PKTM 0x0020 /* b5: Packet mode */ | 102 | #define M66592_PKTM 0x0020 /* b5: Packet mode */ |
101 | #define M66592_DENDE 0x0010 /* b4: Dend enable */ | 103 | #define M66592_DENDE 0x0010 /* b4: Dend enable */ |
102 | #define M66592_OBUS 0x0004 /* b2: OUTbus mode */ | 104 | #define M66592_OBUS 0x0004 /* b2: OUTbus mode */ |
103 | #endif /* #if defined(CONFIG_SUPERH_BUILT_IN_M66592) */ | ||
104 | 105 | ||
106 | /* common case */ | ||
105 | #define M66592_CFIFO 0x10 | 107 | #define M66592_CFIFO 0x10 |
106 | #define M66592_D0FIFO 0x14 | 108 | #define M66592_D0FIFO 0x14 |
107 | #define M66592_D1FIFO 0x18 | 109 | #define M66592_D1FIFO 0x18 |
@@ -113,13 +115,9 @@ | |||
113 | #define M66592_REW 0x4000 /* b14: Buffer rewind */ | 115 | #define M66592_REW 0x4000 /* b14: Buffer rewind */ |
114 | #define M66592_DCLRM 0x2000 /* b13: DMA buffer clear mode */ | 116 | #define M66592_DCLRM 0x2000 /* b13: DMA buffer clear mode */ |
115 | #define M66592_DREQE 0x1000 /* b12: DREQ output enable */ | 117 | #define M66592_DREQE 0x1000 /* b12: DREQ output enable */ |
116 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) | 118 | #define M66592_MBW_8 0x0000 /* 8bit */ |
117 | #define M66592_MBW 0x0800 /* b11: Maximum bit width for FIFO */ | 119 | #define M66592_MBW_16 0x0400 /* 16bit */ |
118 | #else | 120 | #define M66592_MBW_32 0x0800 /* 32bit */ |
119 | #define M66592_MBW 0x0400 /* b10: Maximum bit width for FIFO */ | ||
120 | #define M66592_MBW_8 0x0000 /* 8bit */ | ||
121 | #define M66592_MBW_16 0x0400 /* 16bit */ | ||
122 | #endif /* #if defined(CONFIG_SUPERH_BUILT_IN_M66592) */ | ||
123 | #define M66592_TRENB 0x0200 /* b9: Transaction counter enable */ | 121 | #define M66592_TRENB 0x0200 /* b9: Transaction counter enable */ |
124 | #define M66592_TRCLR 0x0100 /* b8: Transaction counter clear */ | 122 | #define M66592_TRCLR 0x0100 /* b8: Transaction counter clear */ |
125 | #define M66592_DEZPM 0x0080 /* b7: Zero-length packet mode */ | 123 | #define M66592_DEZPM 0x0080 /* b7: Zero-length packet mode */ |
@@ -480,9 +478,11 @@ struct m66592_ep { | |||
480 | struct m66592 { | 478 | struct m66592 { |
481 | spinlock_t lock; | 479 | spinlock_t lock; |
482 | void __iomem *reg; | 480 | void __iomem *reg; |
483 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) && defined(CONFIG_HAVE_CLK) | 481 | #ifdef CONFIG_HAVE_CLK |
484 | struct clk *clk; | 482 | struct clk *clk; |
485 | #endif | 483 | #endif |
484 | struct m66592_platdata *pdata; | ||
485 | unsigned long irq_trigger; | ||
486 | 486 | ||
487 | struct usb_gadget gadget; | 487 | struct usb_gadget gadget; |
488 | struct usb_gadget_driver *driver; | 488 | struct usb_gadget_driver *driver; |
@@ -506,7 +506,6 @@ struct m66592 { | |||
506 | int interrupt; | 506 | int interrupt; |
507 | int isochronous; | 507 | int isochronous; |
508 | int num_dma; | 508 | int num_dma; |
509 | int bi_bufnum; /* bulk and isochronous's bufnum */ | ||
510 | }; | 509 | }; |
511 | 510 | ||
512 | #define gadget_to_m66592(_gadget) container_of(_gadget, struct m66592, gadget) | 511 | #define gadget_to_m66592(_gadget) container_of(_gadget, struct m66592, gadget) |
@@ -547,13 +546,13 @@ static inline void m66592_read_fifo(struct m66592 *m66592, | |||
547 | { | 546 | { |
548 | unsigned long fifoaddr = (unsigned long)m66592->reg + offset; | 547 | unsigned long fifoaddr = (unsigned long)m66592->reg + offset; |
549 | 548 | ||
550 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) | 549 | if (m66592->pdata->on_chip) { |
551 | len = (len + 3) / 4; | 550 | len = (len + 3) / 4; |
552 | insl(fifoaddr, buf, len); | 551 | insl(fifoaddr, buf, len); |
553 | #else | 552 | } else { |
554 | len = (len + 1) / 2; | 553 | len = (len + 1) / 2; |
555 | insw(fifoaddr, buf, len); | 554 | insw(fifoaddr, buf, len); |
556 | #endif | 555 | } |
557 | } | 556 | } |
558 | 557 | ||
559 | static inline void m66592_write(struct m66592 *m66592, u16 val, | 558 | static inline void m66592_write(struct m66592 *m66592, u16 val, |
@@ -567,33 +566,34 @@ static inline void m66592_write_fifo(struct m66592 *m66592, | |||
567 | void *buf, unsigned long len) | 566 | void *buf, unsigned long len) |
568 | { | 567 | { |
569 | unsigned long fifoaddr = (unsigned long)m66592->reg + offset; | 568 | unsigned long fifoaddr = (unsigned long)m66592->reg + offset; |
570 | #if defined(CONFIG_SUPERH_BUILT_IN_M66592) | 569 | |
571 | unsigned long count; | 570 | if (m66592->pdata->on_chip) { |
572 | unsigned char *pb; | 571 | unsigned long count; |
573 | int i; | 572 | unsigned char *pb; |
574 | 573 | int i; | |
575 | count = len / 4; | 574 | |
576 | outsl(fifoaddr, buf, count); | 575 | count = len / 4; |
577 | 576 | outsl(fifoaddr, buf, count); | |
578 | if (len & 0x00000003) { | 577 | |
579 | pb = buf + count * 4; | 578 | if (len & 0x00000003) { |
580 | for (i = 0; i < (len & 0x00000003); i++) { | 579 | pb = buf + count * 4; |
581 | if (m66592_read(m66592, M66592_CFBCFG)) /* little */ | 580 | for (i = 0; i < (len & 0x00000003); i++) { |
582 | outb(pb[i], fifoaddr + (3 - i)); | 581 | if (m66592_read(m66592, M66592_CFBCFG)) /* le */ |
583 | else | 582 | outb(pb[i], fifoaddr + (3 - i)); |
584 | outb(pb[i], fifoaddr + i); | 583 | else |
584 | outb(pb[i], fifoaddr + i); | ||
585 | } | ||
586 | } | ||
587 | } else { | ||
588 | unsigned long odd = len & 0x0001; | ||
589 | |||
590 | len = len / 2; | ||
591 | outsw(fifoaddr, buf, len); | ||
592 | if (odd) { | ||
593 | unsigned char *p = buf + len*2; | ||
594 | outb(*p, fifoaddr); | ||
585 | } | 595 | } |
586 | } | 596 | } |
587 | #else | ||
588 | unsigned long odd = len & 0x0001; | ||
589 | |||
590 | len = len / 2; | ||
591 | outsw(fifoaddr, buf, len); | ||
592 | if (odd) { | ||
593 | unsigned char *p = buf + len*2; | ||
594 | outb(*p, fifoaddr); | ||
595 | } | ||
596 | #endif /* #if defined(CONFIG_SUPERH_BUILT_IN_M66592) */ | ||
597 | } | 597 | } |
598 | 598 | ||
599 | static inline void m66592_mdfy(struct m66592 *m66592, u16 val, u16 pat, | 599 | static inline void m66592_mdfy(struct m66592 *m66592, u16 val, u16 pat, |
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 1a920c70b5a1..f21ca7d27a43 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -336,13 +336,6 @@ config USB_R8A66597_HCD | |||
336 | To compile this driver as a module, choose M here: the | 336 | To compile this driver as a module, choose M here: the |
337 | module will be called r8a66597-hcd. | 337 | module will be called r8a66597-hcd. |
338 | 338 | ||
339 | config SUPERH_ON_CHIP_R8A66597 | ||
340 | boolean "Enable SuperH on-chip R8A66597 USB" | ||
341 | depends on USB_R8A66597_HCD && (CPU_SUBTYPE_SH7366 || CPU_SUBTYPE_SH7723 || CPU_SUBTYPE_SH7724) | ||
342 | help | ||
343 | This driver enables support for the on-chip R8A66597 in the | ||
344 | SH7366, SH7723 and SH7724 processors. | ||
345 | |||
346 | config USB_WHCI_HCD | 339 | config USB_WHCI_HCD |
347 | tristate "Wireless USB Host Controller Interface (WHCI) driver (EXPERIMENTAL)" | 340 | tristate "Wireless USB Host Controller Interface (WHCI) driver (EXPERIMENTAL)" |
348 | depends on EXPERIMENTAL | 341 | depends on EXPERIMENTAL |
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index e18f74946e68..749b53742828 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c | |||
@@ -91,43 +91,43 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597) | |||
91 | u16 tmp; | 91 | u16 tmp; |
92 | int i = 0; | 92 | int i = 0; |
93 | 93 | ||
94 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | 94 | if (r8a66597->pdata->on_chip) { |
95 | #if defined(CONFIG_HAVE_CLK) | 95 | #ifdef CONFIG_HAVE_CLK |
96 | clk_enable(r8a66597->clk); | 96 | clk_enable(r8a66597->clk); |
97 | #endif | 97 | #endif |
98 | do { | 98 | do { |
99 | r8a66597_write(r8a66597, SCKE, SYSCFG0); | 99 | r8a66597_write(r8a66597, SCKE, SYSCFG0); |
100 | tmp = r8a66597_read(r8a66597, SYSCFG0); | 100 | tmp = r8a66597_read(r8a66597, SYSCFG0); |
101 | if (i++ > 1000) { | 101 | if (i++ > 1000) { |
102 | printk(KERN_ERR "r8a66597: register access fail.\n"); | 102 | printk(KERN_ERR "r8a66597: reg access fail.\n"); |
103 | return -ENXIO; | 103 | return -ENXIO; |
104 | } | 104 | } |
105 | } while ((tmp & SCKE) != SCKE); | 105 | } while ((tmp & SCKE) != SCKE); |
106 | r8a66597_write(r8a66597, 0x04, 0x02); | 106 | r8a66597_write(r8a66597, 0x04, 0x02); |
107 | #else | 107 | } else { |
108 | do { | 108 | do { |
109 | r8a66597_write(r8a66597, USBE, SYSCFG0); | 109 | r8a66597_write(r8a66597, USBE, SYSCFG0); |
110 | tmp = r8a66597_read(r8a66597, SYSCFG0); | 110 | tmp = r8a66597_read(r8a66597, SYSCFG0); |
111 | if (i++ > 1000) { | 111 | if (i++ > 1000) { |
112 | printk(KERN_ERR "r8a66597: register access fail.\n"); | 112 | printk(KERN_ERR "r8a66597: reg access fail.\n"); |
113 | return -ENXIO; | 113 | return -ENXIO; |
114 | } | 114 | } |
115 | } while ((tmp & USBE) != USBE); | 115 | } while ((tmp & USBE) != USBE); |
116 | r8a66597_bclr(r8a66597, USBE, SYSCFG0); | 116 | r8a66597_bclr(r8a66597, USBE, SYSCFG0); |
117 | r8a66597_mdfy(r8a66597, get_xtal_from_pdata(r8a66597->pdata), XTAL, | 117 | r8a66597_mdfy(r8a66597, get_xtal_from_pdata(r8a66597->pdata), |
118 | SYSCFG0); | 118 | XTAL, SYSCFG0); |
119 | 119 | ||
120 | i = 0; | 120 | i = 0; |
121 | r8a66597_bset(r8a66597, XCKE, SYSCFG0); | 121 | r8a66597_bset(r8a66597, XCKE, SYSCFG0); |
122 | do { | 122 | do { |
123 | msleep(1); | 123 | msleep(1); |
124 | tmp = r8a66597_read(r8a66597, SYSCFG0); | 124 | tmp = r8a66597_read(r8a66597, SYSCFG0); |
125 | if (i++ > 500) { | 125 | if (i++ > 500) { |
126 | printk(KERN_ERR "r8a66597: register access fail.\n"); | 126 | printk(KERN_ERR "r8a66597: reg access fail.\n"); |
127 | return -ENXIO; | 127 | return -ENXIO; |
128 | } | 128 | } |
129 | } while ((tmp & SCKE) != SCKE); | 129 | } while ((tmp & SCKE) != SCKE); |
130 | #endif /* #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) */ | 130 | } |
131 | 131 | ||
132 | return 0; | 132 | return 0; |
133 | } | 133 | } |
@@ -136,15 +136,16 @@ static void r8a66597_clock_disable(struct r8a66597 *r8a66597) | |||
136 | { | 136 | { |
137 | r8a66597_bclr(r8a66597, SCKE, SYSCFG0); | 137 | r8a66597_bclr(r8a66597, SCKE, SYSCFG0); |
138 | udelay(1); | 138 | udelay(1); |
139 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | 139 | |
140 | #if defined(CONFIG_HAVE_CLK) | 140 | if (r8a66597->pdata->on_chip) { |
141 | clk_disable(r8a66597->clk); | 141 | #ifdef CONFIG_HAVE_CLK |
142 | #endif | 142 | clk_disable(r8a66597->clk); |
143 | #else | ||
144 | r8a66597_bclr(r8a66597, PLLC, SYSCFG0); | ||
145 | r8a66597_bclr(r8a66597, XCKE, SYSCFG0); | ||
146 | r8a66597_bclr(r8a66597, USBE, SYSCFG0); | ||
147 | #endif | 143 | #endif |
144 | } else { | ||
145 | r8a66597_bclr(r8a66597, PLLC, SYSCFG0); | ||
146 | r8a66597_bclr(r8a66597, XCKE, SYSCFG0); | ||
147 | r8a66597_bclr(r8a66597, USBE, SYSCFG0); | ||
148 | } | ||
148 | } | 149 | } |
149 | 150 | ||
150 | static void r8a66597_enable_port(struct r8a66597 *r8a66597, int port) | 151 | static void r8a66597_enable_port(struct r8a66597 *r8a66597, int port) |
@@ -205,7 +206,7 @@ static int enable_controller(struct r8a66597 *r8a66597) | |||
205 | 206 | ||
206 | r8a66597_bset(r8a66597, SIGNE | SACKE, INTENB1); | 207 | r8a66597_bset(r8a66597, SIGNE | SACKE, INTENB1); |
207 | 208 | ||
208 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) | 209 | for (port = 0; port < r8a66597->max_root_hub; port++) |
209 | r8a66597_enable_port(r8a66597, port); | 210 | r8a66597_enable_port(r8a66597, port); |
210 | 211 | ||
211 | return 0; | 212 | return 0; |
@@ -218,7 +219,7 @@ static void disable_controller(struct r8a66597 *r8a66597) | |||
218 | r8a66597_write(r8a66597, 0, INTENB0); | 219 | r8a66597_write(r8a66597, 0, INTENB0); |
219 | r8a66597_write(r8a66597, 0, INTSTS0); | 220 | r8a66597_write(r8a66597, 0, INTSTS0); |
220 | 221 | ||
221 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) | 222 | for (port = 0; port < r8a66597->max_root_hub; port++) |
222 | r8a66597_disable_port(r8a66597, port); | 223 | r8a66597_disable_port(r8a66597, port); |
223 | 224 | ||
224 | r8a66597_clock_disable(r8a66597); | 225 | r8a66597_clock_disable(r8a66597); |
@@ -249,11 +250,12 @@ static int is_hub_limit(char *devpath) | |||
249 | return ((strlen(devpath) >= 4) ? 1 : 0); | 250 | return ((strlen(devpath) >= 4) ? 1 : 0); |
250 | } | 251 | } |
251 | 252 | ||
252 | static void get_port_number(char *devpath, u16 *root_port, u16 *hub_port) | 253 | static void get_port_number(struct r8a66597 *r8a66597, |
254 | char *devpath, u16 *root_port, u16 *hub_port) | ||
253 | { | 255 | { |
254 | if (root_port) { | 256 | if (root_port) { |
255 | *root_port = (devpath[0] & 0x0F) - 1; | 257 | *root_port = (devpath[0] & 0x0F) - 1; |
256 | if (*root_port >= R8A66597_MAX_ROOT_HUB) | 258 | if (*root_port >= r8a66597->max_root_hub) |
257 | printk(KERN_ERR "r8a66597: Illegal root port number.\n"); | 259 | printk(KERN_ERR "r8a66597: Illegal root port number.\n"); |
258 | } | 260 | } |
259 | if (hub_port) | 261 | if (hub_port) |
@@ -355,7 +357,8 @@ static int make_r8a66597_device(struct r8a66597 *r8a66597, | |||
355 | INIT_LIST_HEAD(&dev->device_list); | 357 | INIT_LIST_HEAD(&dev->device_list); |
356 | list_add_tail(&dev->device_list, &r8a66597->child_device); | 358 | list_add_tail(&dev->device_list, &r8a66597->child_device); |
357 | 359 | ||
358 | get_port_number(urb->dev->devpath, &dev->root_port, &dev->hub_port); | 360 | get_port_number(r8a66597, urb->dev->devpath, |
361 | &dev->root_port, &dev->hub_port); | ||
359 | if (!is_child_device(urb->dev->devpath)) | 362 | if (!is_child_device(urb->dev->devpath)) |
360 | r8a66597->root_hub[dev->root_port].dev = dev; | 363 | r8a66597->root_hub[dev->root_port].dev = dev; |
361 | 364 | ||
@@ -420,7 +423,7 @@ static void free_usb_address(struct r8a66597 *r8a66597, | |||
420 | list_del(&dev->device_list); | 423 | list_del(&dev->device_list); |
421 | kfree(dev); | 424 | kfree(dev); |
422 | 425 | ||
423 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) { | 426 | for (port = 0; port < r8a66597->max_root_hub; port++) { |
424 | if (r8a66597->root_hub[port].dev == dev) { | 427 | if (r8a66597->root_hub[port].dev == dev) { |
425 | r8a66597->root_hub[port].dev = NULL; | 428 | r8a66597->root_hub[port].dev = NULL; |
426 | break; | 429 | break; |
@@ -495,10 +498,20 @@ static void r8a66597_pipe_toggle(struct r8a66597 *r8a66597, | |||
495 | r8a66597_bset(r8a66597, SQCLR, pipe->pipectr); | 498 | r8a66597_bset(r8a66597, SQCLR, pipe->pipectr); |
496 | } | 499 | } |
497 | 500 | ||
501 | static inline unsigned short mbw_value(struct r8a66597 *r8a66597) | ||
502 | { | ||
503 | if (r8a66597->pdata->on_chip) | ||
504 | return MBW_32; | ||
505 | else | ||
506 | return MBW_16; | ||
507 | } | ||
508 | |||
498 | /* this function must be called with interrupt disabled */ | 509 | /* this function must be called with interrupt disabled */ |
499 | static inline void cfifo_change(struct r8a66597 *r8a66597, u16 pipenum) | 510 | static inline void cfifo_change(struct r8a66597 *r8a66597, u16 pipenum) |
500 | { | 511 | { |
501 | r8a66597_mdfy(r8a66597, MBW | pipenum, MBW | CURPIPE, CFIFOSEL); | 512 | unsigned short mbw = mbw_value(r8a66597); |
513 | |||
514 | r8a66597_mdfy(r8a66597, mbw | pipenum, mbw | CURPIPE, CFIFOSEL); | ||
502 | r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, pipenum); | 515 | r8a66597_reg_wait(r8a66597, CFIFOSEL, CURPIPE, pipenum); |
503 | } | 516 | } |
504 | 517 | ||
@@ -506,11 +519,13 @@ static inline void cfifo_change(struct r8a66597 *r8a66597, u16 pipenum) | |||
506 | static inline void fifo_change_from_pipe(struct r8a66597 *r8a66597, | 519 | static inline void fifo_change_from_pipe(struct r8a66597 *r8a66597, |
507 | struct r8a66597_pipe *pipe) | 520 | struct r8a66597_pipe *pipe) |
508 | { | 521 | { |
522 | unsigned short mbw = mbw_value(r8a66597); | ||
523 | |||
509 | cfifo_change(r8a66597, 0); | 524 | cfifo_change(r8a66597, 0); |
510 | r8a66597_mdfy(r8a66597, MBW | 0, MBW | CURPIPE, D0FIFOSEL); | 525 | r8a66597_mdfy(r8a66597, mbw | 0, mbw | CURPIPE, D0FIFOSEL); |
511 | r8a66597_mdfy(r8a66597, MBW | 0, MBW | CURPIPE, D1FIFOSEL); | 526 | r8a66597_mdfy(r8a66597, mbw | 0, mbw | CURPIPE, D1FIFOSEL); |
512 | 527 | ||
513 | r8a66597_mdfy(r8a66597, MBW | pipe->info.pipenum, MBW | CURPIPE, | 528 | r8a66597_mdfy(r8a66597, mbw | pipe->info.pipenum, mbw | CURPIPE, |
514 | pipe->fifosel); | 529 | pipe->fifosel); |
515 | r8a66597_reg_wait(r8a66597, pipe->fifosel, CURPIPE, pipe->info.pipenum); | 530 | r8a66597_reg_wait(r8a66597, pipe->fifosel, CURPIPE, pipe->info.pipenum); |
516 | } | 531 | } |
@@ -742,9 +757,13 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597, | |||
742 | struct r8a66597_pipe *pipe, | 757 | struct r8a66597_pipe *pipe, |
743 | struct urb *urb) | 758 | struct urb *urb) |
744 | { | 759 | { |
745 | #if !defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | ||
746 | int i; | 760 | int i; |
747 | struct r8a66597_pipe_info *info = &pipe->info; | 761 | struct r8a66597_pipe_info *info = &pipe->info; |
762 | unsigned short mbw = mbw_value(r8a66597); | ||
763 | |||
764 | /* pipe dma is only for external controlles */ | ||
765 | if (r8a66597->pdata->on_chip) | ||
766 | return; | ||
748 | 767 | ||
749 | if ((pipe->info.pipenum != 0) && (info->type != R8A66597_INT)) { | 768 | if ((pipe->info.pipenum != 0) && (info->type != R8A66597_INT)) { |
750 | for (i = 0; i < R8A66597_MAX_DMA_CHANNEL; i++) { | 769 | for (i = 0; i < R8A66597_MAX_DMA_CHANNEL; i++) { |
@@ -763,8 +782,8 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597, | |||
763 | set_pipe_reg_addr(pipe, i); | 782 | set_pipe_reg_addr(pipe, i); |
764 | 783 | ||
765 | cfifo_change(r8a66597, 0); | 784 | cfifo_change(r8a66597, 0); |
766 | r8a66597_mdfy(r8a66597, MBW | pipe->info.pipenum, | 785 | r8a66597_mdfy(r8a66597, mbw | pipe->info.pipenum, |
767 | MBW | CURPIPE, pipe->fifosel); | 786 | mbw | CURPIPE, pipe->fifosel); |
768 | 787 | ||
769 | r8a66597_reg_wait(r8a66597, pipe->fifosel, CURPIPE, | 788 | r8a66597_reg_wait(r8a66597, pipe->fifosel, CURPIPE, |
770 | pipe->info.pipenum); | 789 | pipe->info.pipenum); |
@@ -772,7 +791,6 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597, | |||
772 | break; | 791 | break; |
773 | } | 792 | } |
774 | } | 793 | } |
775 | #endif /* #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) */ | ||
776 | } | 794 | } |
777 | 795 | ||
778 | /* this function must be called with interrupt disabled */ | 796 | /* this function must be called with interrupt disabled */ |
@@ -1769,7 +1787,7 @@ static void r8a66597_timer(unsigned long _r8a66597) | |||
1769 | 1787 | ||
1770 | spin_lock_irqsave(&r8a66597->lock, flags); | 1788 | spin_lock_irqsave(&r8a66597->lock, flags); |
1771 | 1789 | ||
1772 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) | 1790 | for (port = 0; port < r8a66597->max_root_hub; port++) |
1773 | r8a66597_root_hub_control(r8a66597, port); | 1791 | r8a66597_root_hub_control(r8a66597, port); |
1774 | 1792 | ||
1775 | spin_unlock_irqrestore(&r8a66597->lock, flags); | 1793 | spin_unlock_irqrestore(&r8a66597->lock, flags); |
@@ -1807,7 +1825,7 @@ static void set_address_zero(struct r8a66597 *r8a66597, struct urb *urb) | |||
1807 | u16 root_port, hub_port; | 1825 | u16 root_port, hub_port; |
1808 | 1826 | ||
1809 | if (usb_address == 0) { | 1827 | if (usb_address == 0) { |
1810 | get_port_number(urb->dev->devpath, | 1828 | get_port_number(r8a66597, urb->dev->devpath, |
1811 | &root_port, &hub_port); | 1829 | &root_port, &hub_port); |
1812 | set_devadd_reg(r8a66597, 0, | 1830 | set_devadd_reg(r8a66597, 0, |
1813 | get_r8a66597_usb_speed(urb->dev->speed), | 1831 | get_r8a66597_usb_speed(urb->dev->speed), |
@@ -2082,7 +2100,7 @@ static int r8a66597_hub_status_data(struct usb_hcd *hcd, char *buf) | |||
2082 | 2100 | ||
2083 | *buf = 0; /* initialize (no change) */ | 2101 | *buf = 0; /* initialize (no change) */ |
2084 | 2102 | ||
2085 | for (i = 0; i < R8A66597_MAX_ROOT_HUB; i++) { | 2103 | for (i = 0; i < r8a66597->max_root_hub; i++) { |
2086 | if (r8a66597->root_hub[i].port & 0xffff0000) | 2104 | if (r8a66597->root_hub[i].port & 0xffff0000) |
2087 | *buf |= 1 << (i + 1); | 2105 | *buf |= 1 << (i + 1); |
2088 | } | 2106 | } |
@@ -2097,11 +2115,11 @@ static void r8a66597_hub_descriptor(struct r8a66597 *r8a66597, | |||
2097 | { | 2115 | { |
2098 | desc->bDescriptorType = 0x29; | 2116 | desc->bDescriptorType = 0x29; |
2099 | desc->bHubContrCurrent = 0; | 2117 | desc->bHubContrCurrent = 0; |
2100 | desc->bNbrPorts = R8A66597_MAX_ROOT_HUB; | 2118 | desc->bNbrPorts = r8a66597->max_root_hub; |
2101 | desc->bDescLength = 9; | 2119 | desc->bDescLength = 9; |
2102 | desc->bPwrOn2PwrGood = 0; | 2120 | desc->bPwrOn2PwrGood = 0; |
2103 | desc->wHubCharacteristics = cpu_to_le16(0x0011); | 2121 | desc->wHubCharacteristics = cpu_to_le16(0x0011); |
2104 | desc->bitmap[0] = ((1 << R8A66597_MAX_ROOT_HUB) - 1) << 1; | 2122 | desc->bitmap[0] = ((1 << r8a66597->max_root_hub) - 1) << 1; |
2105 | desc->bitmap[1] = ~0; | 2123 | desc->bitmap[1] = ~0; |
2106 | } | 2124 | } |
2107 | 2125 | ||
@@ -2129,7 +2147,7 @@ static int r8a66597_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
2129 | } | 2147 | } |
2130 | break; | 2148 | break; |
2131 | case ClearPortFeature: | 2149 | case ClearPortFeature: |
2132 | if (wIndex > R8A66597_MAX_ROOT_HUB) | 2150 | if (wIndex > r8a66597->max_root_hub) |
2133 | goto error; | 2151 | goto error; |
2134 | if (wLength != 0) | 2152 | if (wLength != 0) |
2135 | goto error; | 2153 | goto error; |
@@ -2162,12 +2180,12 @@ static int r8a66597_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
2162 | *buf = 0x00; | 2180 | *buf = 0x00; |
2163 | break; | 2181 | break; |
2164 | case GetPortStatus: | 2182 | case GetPortStatus: |
2165 | if (wIndex > R8A66597_MAX_ROOT_HUB) | 2183 | if (wIndex > r8a66597->max_root_hub) |
2166 | goto error; | 2184 | goto error; |
2167 | *(__le32 *)buf = cpu_to_le32(rh->port); | 2185 | *(__le32 *)buf = cpu_to_le32(rh->port); |
2168 | break; | 2186 | break; |
2169 | case SetPortFeature: | 2187 | case SetPortFeature: |
2170 | if (wIndex > R8A66597_MAX_ROOT_HUB) | 2188 | if (wIndex > r8a66597->max_root_hub) |
2171 | goto error; | 2189 | goto error; |
2172 | if (wLength != 0) | 2190 | if (wLength != 0) |
2173 | goto error; | 2191 | goto error; |
@@ -2216,7 +2234,7 @@ static int r8a66597_bus_suspend(struct usb_hcd *hcd) | |||
2216 | 2234 | ||
2217 | dbg("%s", __func__); | 2235 | dbg("%s", __func__); |
2218 | 2236 | ||
2219 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) { | 2237 | for (port = 0; port < r8a66597->max_root_hub; port++) { |
2220 | struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; | 2238 | struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; |
2221 | unsigned long dvstctr_reg = get_dvstctr_reg(port); | 2239 | unsigned long dvstctr_reg = get_dvstctr_reg(port); |
2222 | 2240 | ||
@@ -2247,7 +2265,7 @@ static int r8a66597_bus_resume(struct usb_hcd *hcd) | |||
2247 | 2265 | ||
2248 | dbg("%s", __func__); | 2266 | dbg("%s", __func__); |
2249 | 2267 | ||
2250 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) { | 2268 | for (port = 0; port < r8a66597->max_root_hub; port++) { |
2251 | struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; | 2269 | struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; |
2252 | unsigned long dvstctr_reg = get_dvstctr_reg(port); | 2270 | unsigned long dvstctr_reg = get_dvstctr_reg(port); |
2253 | 2271 | ||
@@ -2305,16 +2323,16 @@ static struct hc_driver r8a66597_hc_driver = { | |||
2305 | }; | 2323 | }; |
2306 | 2324 | ||
2307 | #if defined(CONFIG_PM) | 2325 | #if defined(CONFIG_PM) |
2308 | static int r8a66597_suspend(struct platform_device *pdev, pm_message_t state) | 2326 | static int r8a66597_suspend(struct device *dev) |
2309 | { | 2327 | { |
2310 | struct r8a66597 *r8a66597 = dev_get_drvdata(&pdev->dev); | 2328 | struct r8a66597 *r8a66597 = dev_get_drvdata(dev); |
2311 | int port; | 2329 | int port; |
2312 | 2330 | ||
2313 | dbg("%s", __func__); | 2331 | dbg("%s", __func__); |
2314 | 2332 | ||
2315 | disable_controller(r8a66597); | 2333 | disable_controller(r8a66597); |
2316 | 2334 | ||
2317 | for (port = 0; port < R8A66597_MAX_ROOT_HUB; port++) { | 2335 | for (port = 0; port < r8a66597->max_root_hub; port++) { |
2318 | struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; | 2336 | struct r8a66597_root_hub *rh = &r8a66597->root_hub[port]; |
2319 | 2337 | ||
2320 | rh->port = 0x00000000; | 2338 | rh->port = 0x00000000; |
@@ -2323,9 +2341,9 @@ static int r8a66597_suspend(struct platform_device *pdev, pm_message_t state) | |||
2323 | return 0; | 2341 | return 0; |
2324 | } | 2342 | } |
2325 | 2343 | ||
2326 | static int r8a66597_resume(struct platform_device *pdev) | 2344 | static int r8a66597_resume(struct device *dev) |
2327 | { | 2345 | { |
2328 | struct r8a66597 *r8a66597 = dev_get_drvdata(&pdev->dev); | 2346 | struct r8a66597 *r8a66597 = dev_get_drvdata(dev); |
2329 | struct usb_hcd *hcd = r8a66597_to_hcd(r8a66597); | 2347 | struct usb_hcd *hcd = r8a66597_to_hcd(r8a66597); |
2330 | 2348 | ||
2331 | dbg("%s", __func__); | 2349 | dbg("%s", __func__); |
@@ -2335,9 +2353,17 @@ static int r8a66597_resume(struct platform_device *pdev) | |||
2335 | 2353 | ||
2336 | return 0; | 2354 | return 0; |
2337 | } | 2355 | } |
2356 | |||
2357 | static struct dev_pm_ops r8a66597_dev_pm_ops = { | ||
2358 | .suspend = r8a66597_suspend, | ||
2359 | .resume = r8a66597_resume, | ||
2360 | .poweroff = r8a66597_suspend, | ||
2361 | .restore = r8a66597_resume, | ||
2362 | }; | ||
2363 | |||
2364 | #define R8A66597_DEV_PM_OPS (&r8a66597_dev_pm_ops) | ||
2338 | #else /* if defined(CONFIG_PM) */ | 2365 | #else /* if defined(CONFIG_PM) */ |
2339 | #define r8a66597_suspend NULL | 2366 | #define R8A66597_DEV_PM_OPS NULL |
2340 | #define r8a66597_resume NULL | ||
2341 | #endif | 2367 | #endif |
2342 | 2368 | ||
2343 | static int __init_or_module r8a66597_remove(struct platform_device *pdev) | 2369 | static int __init_or_module r8a66597_remove(struct platform_device *pdev) |
@@ -2348,8 +2374,9 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev) | |||
2348 | del_timer_sync(&r8a66597->rh_timer); | 2374 | del_timer_sync(&r8a66597->rh_timer); |
2349 | usb_remove_hcd(hcd); | 2375 | usb_remove_hcd(hcd); |
2350 | iounmap((void *)r8a66597->reg); | 2376 | iounmap((void *)r8a66597->reg); |
2351 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | 2377 | #ifdef CONFIG_HAVE_CLK |
2352 | clk_put(r8a66597->clk); | 2378 | if (r8a66597->pdata->on_chip) |
2379 | clk_put(r8a66597->clk); | ||
2353 | #endif | 2380 | #endif |
2354 | usb_put_hcd(hcd); | 2381 | usb_put_hcd(hcd); |
2355 | return 0; | 2382 | return 0; |
@@ -2357,7 +2384,7 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev) | |||
2357 | 2384 | ||
2358 | static int __devinit r8a66597_probe(struct platform_device *pdev) | 2385 | static int __devinit r8a66597_probe(struct platform_device *pdev) |
2359 | { | 2386 | { |
2360 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | 2387 | #ifdef CONFIG_HAVE_CLK |
2361 | char clk_name[8]; | 2388 | char clk_name[8]; |
2362 | #endif | 2389 | #endif |
2363 | struct resource *res = NULL, *ires; | 2390 | struct resource *res = NULL, *ires; |
@@ -2419,15 +2446,20 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) | |||
2419 | r8a66597->pdata = pdev->dev.platform_data; | 2446 | r8a66597->pdata = pdev->dev.platform_data; |
2420 | r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW; | 2447 | r8a66597->irq_sense_low = irq_trigger == IRQF_TRIGGER_LOW; |
2421 | 2448 | ||
2422 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | 2449 | if (r8a66597->pdata->on_chip) { |
2423 | snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id); | 2450 | #ifdef CONFIG_HAVE_CLK |
2424 | r8a66597->clk = clk_get(&pdev->dev, clk_name); | 2451 | snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id); |
2425 | if (IS_ERR(r8a66597->clk)) { | 2452 | r8a66597->clk = clk_get(&pdev->dev, clk_name); |
2426 | dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name); | 2453 | if (IS_ERR(r8a66597->clk)) { |
2427 | ret = PTR_ERR(r8a66597->clk); | 2454 | dev_err(&pdev->dev, "cannot get clock \"%s\"\n", |
2428 | goto clean_up2; | 2455 | clk_name); |
2429 | } | 2456 | ret = PTR_ERR(r8a66597->clk); |
2457 | goto clean_up2; | ||
2458 | } | ||
2430 | #endif | 2459 | #endif |
2460 | r8a66597->max_root_hub = 1; | ||
2461 | } else | ||
2462 | r8a66597->max_root_hub = 2; | ||
2431 | 2463 | ||
2432 | spin_lock_init(&r8a66597->lock); | 2464 | spin_lock_init(&r8a66597->lock); |
2433 | init_timer(&r8a66597->rh_timer); | 2465 | init_timer(&r8a66597->rh_timer); |
@@ -2457,8 +2489,9 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) | |||
2457 | return 0; | 2489 | return 0; |
2458 | 2490 | ||
2459 | clean_up3: | 2491 | clean_up3: |
2460 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | 2492 | #ifdef CONFIG_HAVE_CLK |
2461 | clk_put(r8a66597->clk); | 2493 | if (r8a66597->pdata->on_chip) |
2494 | clk_put(r8a66597->clk); | ||
2462 | clean_up2: | 2495 | clean_up2: |
2463 | #endif | 2496 | #endif |
2464 | usb_put_hcd(hcd); | 2497 | usb_put_hcd(hcd); |
@@ -2473,11 +2506,10 @@ clean_up: | |||
2473 | static struct platform_driver r8a66597_driver = { | 2506 | static struct platform_driver r8a66597_driver = { |
2474 | .probe = r8a66597_probe, | 2507 | .probe = r8a66597_probe, |
2475 | .remove = r8a66597_remove, | 2508 | .remove = r8a66597_remove, |
2476 | .suspend = r8a66597_suspend, | ||
2477 | .resume = r8a66597_resume, | ||
2478 | .driver = { | 2509 | .driver = { |
2479 | .name = (char *) hcd_name, | 2510 | .name = (char *) hcd_name, |
2480 | .owner = THIS_MODULE, | 2511 | .owner = THIS_MODULE, |
2512 | .pm = R8A66597_DEV_PM_OPS, | ||
2481 | }, | 2513 | }, |
2482 | }; | 2514 | }; |
2483 | 2515 | ||
diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h index d72680b433f9..228e3fb23854 100644 --- a/drivers/usb/host/r8a66597.h +++ b/drivers/usb/host/r8a66597.h | |||
@@ -26,390 +26,16 @@ | |||
26 | #ifndef __R8A66597_H__ | 26 | #ifndef __R8A66597_H__ |
27 | #define __R8A66597_H__ | 27 | #define __R8A66597_H__ |
28 | 28 | ||
29 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | 29 | #ifdef CONFIG_HAVE_CLK |
30 | #include <linux/clk.h> | 30 | #include <linux/clk.h> |
31 | #endif | 31 | #endif |
32 | 32 | ||
33 | #include <linux/usb/r8a66597.h> | 33 | #include <linux/usb/r8a66597.h> |
34 | 34 | ||
35 | #define SYSCFG0 0x00 | ||
36 | #define SYSCFG1 0x02 | ||
37 | #define SYSSTS0 0x04 | ||
38 | #define SYSSTS1 0x06 | ||
39 | #define DVSTCTR0 0x08 | ||
40 | #define DVSTCTR1 0x0A | ||
41 | #define TESTMODE 0x0C | ||
42 | #define PINCFG 0x0E | ||
43 | #define DMA0CFG 0x10 | ||
44 | #define DMA1CFG 0x12 | ||
45 | #define CFIFO 0x14 | ||
46 | #define D0FIFO 0x18 | ||
47 | #define D1FIFO 0x1C | ||
48 | #define CFIFOSEL 0x20 | ||
49 | #define CFIFOCTR 0x22 | ||
50 | #define CFIFOSIE 0x24 | ||
51 | #define D0FIFOSEL 0x28 | ||
52 | #define D0FIFOCTR 0x2A | ||
53 | #define D1FIFOSEL 0x2C | ||
54 | #define D1FIFOCTR 0x2E | ||
55 | #define INTENB0 0x30 | ||
56 | #define INTENB1 0x32 | ||
57 | #define INTENB2 0x34 | ||
58 | #define BRDYENB 0x36 | ||
59 | #define NRDYENB 0x38 | ||
60 | #define BEMPENB 0x3A | ||
61 | #define SOFCFG 0x3C | ||
62 | #define INTSTS0 0x40 | ||
63 | #define INTSTS1 0x42 | ||
64 | #define INTSTS2 0x44 | ||
65 | #define BRDYSTS 0x46 | ||
66 | #define NRDYSTS 0x48 | ||
67 | #define BEMPSTS 0x4A | ||
68 | #define FRMNUM 0x4C | ||
69 | #define UFRMNUM 0x4E | ||
70 | #define USBADDR 0x50 | ||
71 | #define USBREQ 0x54 | ||
72 | #define USBVAL 0x56 | ||
73 | #define USBINDX 0x58 | ||
74 | #define USBLENG 0x5A | ||
75 | #define DCPCFG 0x5C | ||
76 | #define DCPMAXP 0x5E | ||
77 | #define DCPCTR 0x60 | ||
78 | #define PIPESEL 0x64 | ||
79 | #define PIPECFG 0x68 | ||
80 | #define PIPEBUF 0x6A | ||
81 | #define PIPEMAXP 0x6C | ||
82 | #define PIPEPERI 0x6E | ||
83 | #define PIPE1CTR 0x70 | ||
84 | #define PIPE2CTR 0x72 | ||
85 | #define PIPE3CTR 0x74 | ||
86 | #define PIPE4CTR 0x76 | ||
87 | #define PIPE5CTR 0x78 | ||
88 | #define PIPE6CTR 0x7A | ||
89 | #define PIPE7CTR 0x7C | ||
90 | #define PIPE8CTR 0x7E | ||
91 | #define PIPE9CTR 0x80 | ||
92 | #define PIPE1TRE 0x90 | ||
93 | #define PIPE1TRN 0x92 | ||
94 | #define PIPE2TRE 0x94 | ||
95 | #define PIPE2TRN 0x96 | ||
96 | #define PIPE3TRE 0x98 | ||
97 | #define PIPE3TRN 0x9A | ||
98 | #define PIPE4TRE 0x9C | ||
99 | #define PIPE4TRN 0x9E | ||
100 | #define PIPE5TRE 0xA0 | ||
101 | #define PIPE5TRN 0xA2 | ||
102 | #define DEVADD0 0xD0 | ||
103 | #define DEVADD1 0xD2 | ||
104 | #define DEVADD2 0xD4 | ||
105 | #define DEVADD3 0xD6 | ||
106 | #define DEVADD4 0xD8 | ||
107 | #define DEVADD5 0xDA | ||
108 | #define DEVADD6 0xDC | ||
109 | #define DEVADD7 0xDE | ||
110 | #define DEVADD8 0xE0 | ||
111 | #define DEVADD9 0xE2 | ||
112 | #define DEVADDA 0xE4 | ||
113 | |||
114 | /* System Configuration Control Register */ | ||
115 | #define XTAL 0xC000 /* b15-14: Crystal selection */ | ||
116 | #define XTAL48 0x8000 /* 48MHz */ | ||
117 | #define XTAL24 0x4000 /* 24MHz */ | ||
118 | #define XTAL12 0x0000 /* 12MHz */ | ||
119 | #define XCKE 0x2000 /* b13: External clock enable */ | ||
120 | #define PLLC 0x0800 /* b11: PLL control */ | ||
121 | #define SCKE 0x0400 /* b10: USB clock enable */ | ||
122 | #define PCSDIS 0x0200 /* b9: not CS wakeup */ | ||
123 | #define LPSME 0x0100 /* b8: Low power sleep mode */ | ||
124 | #define HSE 0x0080 /* b7: Hi-speed enable */ | ||
125 | #define DCFM 0x0040 /* b6: Controller function select */ | ||
126 | #define DRPD 0x0020 /* b5: D+/- pull down control */ | ||
127 | #define DPRPU 0x0010 /* b4: D+ pull up control */ | ||
128 | #define USBE 0x0001 /* b0: USB module operation enable */ | ||
129 | |||
130 | /* System Configuration Status Register */ | ||
131 | #define OVCBIT 0x8000 /* b15-14: Over-current bit */ | ||
132 | #define OVCMON 0xC000 /* b15-14: Over-current monitor */ | ||
133 | #define SOFEA 0x0020 /* b5: SOF monitor */ | ||
134 | #define IDMON 0x0004 /* b3: ID-pin monitor */ | ||
135 | #define LNST 0x0003 /* b1-0: D+, D- line status */ | ||
136 | #define SE1 0x0003 /* SE1 */ | ||
137 | #define FS_KSTS 0x0002 /* Full-Speed K State */ | ||
138 | #define FS_JSTS 0x0001 /* Full-Speed J State */ | ||
139 | #define LS_JSTS 0x0002 /* Low-Speed J State */ | ||
140 | #define LS_KSTS 0x0001 /* Low-Speed K State */ | ||
141 | #define SE0 0x0000 /* SE0 */ | ||
142 | |||
143 | /* Device State Control Register */ | ||
144 | #define EXTLP0 0x0400 /* b10: External port */ | ||
145 | #define VBOUT 0x0200 /* b9: VBUS output */ | ||
146 | #define WKUP 0x0100 /* b8: Remote wakeup */ | ||
147 | #define RWUPE 0x0080 /* b7: Remote wakeup sense */ | ||
148 | #define USBRST 0x0040 /* b6: USB reset enable */ | ||
149 | #define RESUME 0x0020 /* b5: Resume enable */ | ||
150 | #define UACT 0x0010 /* b4: USB bus enable */ | ||
151 | #define RHST 0x0007 /* b1-0: Reset handshake status */ | ||
152 | #define HSPROC 0x0004 /* HS handshake is processing */ | ||
153 | #define HSMODE 0x0003 /* Hi-Speed mode */ | ||
154 | #define FSMODE 0x0002 /* Full-Speed mode */ | ||
155 | #define LSMODE 0x0001 /* Low-Speed mode */ | ||
156 | #define UNDECID 0x0000 /* Undecided */ | ||
157 | |||
158 | /* Test Mode Register */ | ||
159 | #define UTST 0x000F /* b3-0: Test select */ | ||
160 | #define H_TST_PACKET 0x000C /* HOST TEST Packet */ | ||
161 | #define H_TST_SE0_NAK 0x000B /* HOST TEST SE0 NAK */ | ||
162 | #define H_TST_K 0x000A /* HOST TEST K */ | ||
163 | #define H_TST_J 0x0009 /* HOST TEST J */ | ||
164 | #define H_TST_NORMAL 0x0000 /* HOST Normal Mode */ | ||
165 | #define P_TST_PACKET 0x0004 /* PERI TEST Packet */ | ||
166 | #define P_TST_SE0_NAK 0x0003 /* PERI TEST SE0 NAK */ | ||
167 | #define P_TST_K 0x0002 /* PERI TEST K */ | ||
168 | #define P_TST_J 0x0001 /* PERI TEST J */ | ||
169 | #define P_TST_NORMAL 0x0000 /* PERI Normal Mode */ | ||
170 | |||
171 | /* Data Pin Configuration Register */ | ||
172 | #define LDRV 0x8000 /* b15: Drive Current Adjust */ | ||
173 | #define VIF1 0x0000 /* VIF = 1.8V */ | ||
174 | #define VIF3 0x8000 /* VIF = 3.3V */ | ||
175 | #define INTA 0x0001 /* b1: USB INT-pin active */ | ||
176 | |||
177 | /* DMAx Pin Configuration Register */ | ||
178 | #define DREQA 0x4000 /* b14: Dreq active select */ | ||
179 | #define BURST 0x2000 /* b13: Burst mode */ | ||
180 | #define DACKA 0x0400 /* b10: Dack active select */ | ||
181 | #define DFORM 0x0380 /* b9-7: DMA mode select */ | ||
182 | #define CPU_ADR_RD_WR 0x0000 /* Address + RD/WR mode (CPU bus) */ | ||
183 | #define CPU_DACK_RD_WR 0x0100 /* DACK + RD/WR mode (CPU bus) */ | ||
184 | #define CPU_DACK_ONLY 0x0180 /* DACK only mode (CPU bus) */ | ||
185 | #define SPLIT_DACK_ONLY 0x0200 /* DACK only mode (SPLIT bus) */ | ||
186 | #define DENDA 0x0040 /* b6: Dend active select */ | ||
187 | #define PKTM 0x0020 /* b5: Packet mode */ | ||
188 | #define DENDE 0x0010 /* b4: Dend enable */ | ||
189 | #define OBUS 0x0004 /* b2: OUTbus mode */ | ||
190 | |||
191 | /* CFIFO/DxFIFO Port Select Register */ | ||
192 | #define RCNT 0x8000 /* b15: Read count mode */ | ||
193 | #define REW 0x4000 /* b14: Buffer rewind */ | ||
194 | #define DCLRM 0x2000 /* b13: DMA buffer clear mode */ | ||
195 | #define DREQE 0x1000 /* b12: DREQ output enable */ | ||
196 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | ||
197 | #define MBW 0x0800 | ||
198 | #else | ||
199 | #define MBW 0x0400 /* b10: Maximum bit width for FIFO access */ | ||
200 | #endif | ||
201 | #define MBW_8 0x0000 /* 8bit */ | ||
202 | #define MBW_16 0x0400 /* 16bit */ | ||
203 | #define BIGEND 0x0100 /* b8: Big endian mode */ | ||
204 | #define BYTE_LITTLE 0x0000 /* little dendian */ | ||
205 | #define BYTE_BIG 0x0100 /* big endifan */ | ||
206 | #define ISEL 0x0020 /* b5: DCP FIFO port direction select */ | ||
207 | #define CURPIPE 0x000F /* b2-0: PIPE select */ | ||
208 | |||
209 | /* CFIFO/DxFIFO Port Control Register */ | ||
210 | #define BVAL 0x8000 /* b15: Buffer valid flag */ | ||
211 | #define BCLR 0x4000 /* b14: Buffer clear */ | ||
212 | #define FRDY 0x2000 /* b13: FIFO ready */ | ||
213 | #define DTLN 0x0FFF /* b11-0: FIFO received data length */ | ||
214 | |||
215 | /* Interrupt Enable Register 0 */ | ||
216 | #define VBSE 0x8000 /* b15: VBUS interrupt */ | ||
217 | #define RSME 0x4000 /* b14: Resume interrupt */ | ||
218 | #define SOFE 0x2000 /* b13: Frame update interrupt */ | ||
219 | #define DVSE 0x1000 /* b12: Device state transition interrupt */ | ||
220 | #define CTRE 0x0800 /* b11: Control transfer stage transition interrupt */ | ||
221 | #define BEMPE 0x0400 /* b10: Buffer empty interrupt */ | ||
222 | #define NRDYE 0x0200 /* b9: Buffer not ready interrupt */ | ||
223 | #define BRDYE 0x0100 /* b8: Buffer ready interrupt */ | ||
224 | |||
225 | /* Interrupt Enable Register 1 */ | ||
226 | #define OVRCRE 0x8000 /* b15: Over-current interrupt */ | ||
227 | #define BCHGE 0x4000 /* b14: USB us chenge interrupt */ | ||
228 | #define DTCHE 0x1000 /* b12: Detach sense interrupt */ | ||
229 | #define ATTCHE 0x0800 /* b11: Attach sense interrupt */ | ||
230 | #define EOFERRE 0x0040 /* b6: EOF error interrupt */ | ||
231 | #define SIGNE 0x0020 /* b5: SETUP IGNORE interrupt */ | ||
232 | #define SACKE 0x0010 /* b4: SETUP ACK interrupt */ | ||
233 | |||
234 | /* BRDY Interrupt Enable/Status Register */ | ||
235 | #define BRDY9 0x0200 /* b9: PIPE9 */ | ||
236 | #define BRDY8 0x0100 /* b8: PIPE8 */ | ||
237 | #define BRDY7 0x0080 /* b7: PIPE7 */ | ||
238 | #define BRDY6 0x0040 /* b6: PIPE6 */ | ||
239 | #define BRDY5 0x0020 /* b5: PIPE5 */ | ||
240 | #define BRDY4 0x0010 /* b4: PIPE4 */ | ||
241 | #define BRDY3 0x0008 /* b3: PIPE3 */ | ||
242 | #define BRDY2 0x0004 /* b2: PIPE2 */ | ||
243 | #define BRDY1 0x0002 /* b1: PIPE1 */ | ||
244 | #define BRDY0 0x0001 /* b1: PIPE0 */ | ||
245 | |||
246 | /* NRDY Interrupt Enable/Status Register */ | ||
247 | #define NRDY9 0x0200 /* b9: PIPE9 */ | ||
248 | #define NRDY8 0x0100 /* b8: PIPE8 */ | ||
249 | #define NRDY7 0x0080 /* b7: PIPE7 */ | ||
250 | #define NRDY6 0x0040 /* b6: PIPE6 */ | ||
251 | #define NRDY5 0x0020 /* b5: PIPE5 */ | ||
252 | #define NRDY4 0x0010 /* b4: PIPE4 */ | ||
253 | #define NRDY3 0x0008 /* b3: PIPE3 */ | ||
254 | #define NRDY2 0x0004 /* b2: PIPE2 */ | ||
255 | #define NRDY1 0x0002 /* b1: PIPE1 */ | ||
256 | #define NRDY0 0x0001 /* b1: PIPE0 */ | ||
257 | |||
258 | /* BEMP Interrupt Enable/Status Register */ | ||
259 | #define BEMP9 0x0200 /* b9: PIPE9 */ | ||
260 | #define BEMP8 0x0100 /* b8: PIPE8 */ | ||
261 | #define BEMP7 0x0080 /* b7: PIPE7 */ | ||
262 | #define BEMP6 0x0040 /* b6: PIPE6 */ | ||
263 | #define BEMP5 0x0020 /* b5: PIPE5 */ | ||
264 | #define BEMP4 0x0010 /* b4: PIPE4 */ | ||
265 | #define BEMP3 0x0008 /* b3: PIPE3 */ | ||
266 | #define BEMP2 0x0004 /* b2: PIPE2 */ | ||
267 | #define BEMP1 0x0002 /* b1: PIPE1 */ | ||
268 | #define BEMP0 0x0001 /* b0: PIPE0 */ | ||
269 | |||
270 | /* SOF Pin Configuration Register */ | ||
271 | #define TRNENSEL 0x0100 /* b8: Select transaction enable period */ | ||
272 | #define BRDYM 0x0040 /* b6: BRDY clear timing */ | ||
273 | #define INTL 0x0020 /* b5: Interrupt sense select */ | ||
274 | #define EDGESTS 0x0010 /* b4: */ | ||
275 | #define SOFMODE 0x000C /* b3-2: SOF pin select */ | ||
276 | #define SOF_125US 0x0008 /* SOF OUT 125us Frame Signal */ | ||
277 | #define SOF_1MS 0x0004 /* SOF OUT 1ms Frame Signal */ | ||
278 | #define SOF_DISABLE 0x0000 /* SOF OUT Disable */ | ||
279 | |||
280 | /* Interrupt Status Register 0 */ | ||
281 | #define VBINT 0x8000 /* b15: VBUS interrupt */ | ||
282 | #define RESM 0x4000 /* b14: Resume interrupt */ | ||
283 | #define SOFR 0x2000 /* b13: SOF frame update interrupt */ | ||
284 | #define DVST 0x1000 /* b12: Device state transition interrupt */ | ||
285 | #define CTRT 0x0800 /* b11: Control transfer stage transition interrupt */ | ||
286 | #define BEMP 0x0400 /* b10: Buffer empty interrupt */ | ||
287 | #define NRDY 0x0200 /* b9: Buffer not ready interrupt */ | ||
288 | #define BRDY 0x0100 /* b8: Buffer ready interrupt */ | ||
289 | #define VBSTS 0x0080 /* b7: VBUS input port */ | ||
290 | #define DVSQ 0x0070 /* b6-4: Device state */ | ||
291 | #define DS_SPD_CNFG 0x0070 /* Suspend Configured */ | ||
292 | #define DS_SPD_ADDR 0x0060 /* Suspend Address */ | ||
293 | #define DS_SPD_DFLT 0x0050 /* Suspend Default */ | ||
294 | #define DS_SPD_POWR 0x0040 /* Suspend Powered */ | ||
295 | #define DS_SUSP 0x0040 /* Suspend */ | ||
296 | #define DS_CNFG 0x0030 /* Configured */ | ||
297 | #define DS_ADDS 0x0020 /* Address */ | ||
298 | #define DS_DFLT 0x0010 /* Default */ | ||
299 | #define DS_POWR 0x0000 /* Powered */ | ||
300 | #define DVSQS 0x0030 /* b5-4: Device state */ | ||
301 | #define VALID 0x0008 /* b3: Setup packet detected flag */ | ||
302 | #define CTSQ 0x0007 /* b2-0: Control transfer stage */ | ||
303 | #define CS_SQER 0x0006 /* Sequence error */ | ||
304 | #define CS_WRND 0x0005 /* Control write nodata status stage */ | ||
305 | #define CS_WRSS 0x0004 /* Control write status stage */ | ||
306 | #define CS_WRDS 0x0003 /* Control write data stage */ | ||
307 | #define CS_RDSS 0x0002 /* Control read status stage */ | ||
308 | #define CS_RDDS 0x0001 /* Control read data stage */ | ||
309 | #define CS_IDST 0x0000 /* Idle or setup stage */ | ||
310 | |||
311 | /* Interrupt Status Register 1 */ | ||
312 | #define OVRCR 0x8000 /* b15: Over-current interrupt */ | ||
313 | #define BCHG 0x4000 /* b14: USB bus chenge interrupt */ | ||
314 | #define DTCH 0x1000 /* b12: Detach sense interrupt */ | ||
315 | #define ATTCH 0x0800 /* b11: Attach sense interrupt */ | ||
316 | #define EOFERR 0x0040 /* b6: EOF-error interrupt */ | ||
317 | #define SIGN 0x0020 /* b5: Setup ignore interrupt */ | ||
318 | #define SACK 0x0010 /* b4: Setup acknowledge interrupt */ | ||
319 | |||
320 | /* Frame Number Register */ | ||
321 | #define OVRN 0x8000 /* b15: Overrun error */ | ||
322 | #define CRCE 0x4000 /* b14: Received data error */ | ||
323 | #define FRNM 0x07FF /* b10-0: Frame number */ | ||
324 | |||
325 | /* Micro Frame Number Register */ | ||
326 | #define UFRNM 0x0007 /* b2-0: Micro frame number */ | ||
327 | |||
328 | /* Default Control Pipe Maxpacket Size Register */ | ||
329 | /* Pipe Maxpacket Size Register */ | ||
330 | #define DEVSEL 0xF000 /* b15-14: Device address select */ | ||
331 | #define MAXP 0x007F /* b6-0: Maxpacket size of default control pipe */ | ||
332 | |||
333 | /* Default Control Pipe Control Register */ | ||
334 | #define BSTS 0x8000 /* b15: Buffer status */ | ||
335 | #define SUREQ 0x4000 /* b14: Send USB request */ | ||
336 | #define CSCLR 0x2000 /* b13: complete-split status clear */ | ||
337 | #define CSSTS 0x1000 /* b12: complete-split status */ | ||
338 | #define SUREQCLR 0x0800 /* b11: stop setup request */ | ||
339 | #define SQCLR 0x0100 /* b8: Sequence toggle bit clear */ | ||
340 | #define SQSET 0x0080 /* b7: Sequence toggle bit set */ | ||
341 | #define SQMON 0x0040 /* b6: Sequence toggle bit monitor */ | ||
342 | #define PBUSY 0x0020 /* b5: pipe busy */ | ||
343 | #define PINGE 0x0010 /* b4: ping enable */ | ||
344 | #define CCPL 0x0004 /* b2: Enable control transfer complete */ | ||
345 | #define PID 0x0003 /* b1-0: Response PID */ | ||
346 | #define PID_STALL11 0x0003 /* STALL */ | ||
347 | #define PID_STALL 0x0002 /* STALL */ | ||
348 | #define PID_BUF 0x0001 /* BUF */ | ||
349 | #define PID_NAK 0x0000 /* NAK */ | ||
350 | |||
351 | /* Pipe Window Select Register */ | ||
352 | #define PIPENM 0x0007 /* b2-0: Pipe select */ | ||
353 | |||
354 | /* Pipe Configuration Register */ | ||
355 | #define R8A66597_TYP 0xC000 /* b15-14: Transfer type */ | ||
356 | #define R8A66597_ISO 0xC000 /* Isochronous */ | ||
357 | #define R8A66597_INT 0x8000 /* Interrupt */ | ||
358 | #define R8A66597_BULK 0x4000 /* Bulk */ | ||
359 | #define R8A66597_BFRE 0x0400 /* b10: Buffer ready interrupt mode select */ | ||
360 | #define R8A66597_DBLB 0x0200 /* b9: Double buffer mode select */ | ||
361 | #define R8A66597_CNTMD 0x0100 /* b8: Continuous transfer mode select */ | ||
362 | #define R8A66597_SHTNAK 0x0080 /* b7: Transfer end NAK */ | ||
363 | #define R8A66597_DIR 0x0010 /* b4: Transfer direction select */ | ||
364 | #define R8A66597_EPNUM 0x000F /* b3-0: Eendpoint number select */ | ||
365 | |||
366 | /* Pipe Buffer Configuration Register */ | ||
367 | #define BUFSIZE 0x7C00 /* b14-10: Pipe buffer size */ | ||
368 | #define BUFNMB 0x007F /* b6-0: Pipe buffer number */ | ||
369 | #define PIPE0BUF 256 | ||
370 | #define PIPExBUF 64 | ||
371 | |||
372 | /* Pipe Maxpacket Size Register */ | ||
373 | #define MXPS 0x07FF /* b10-0: Maxpacket size */ | ||
374 | |||
375 | /* Pipe Cycle Configuration Register */ | ||
376 | #define IFIS 0x1000 /* b12: Isochronous in-buffer flush mode select */ | ||
377 | #define IITV 0x0007 /* b2-0: Isochronous interval */ | ||
378 | |||
379 | /* Pipex Control Register */ | ||
380 | #define BSTS 0x8000 /* b15: Buffer status */ | ||
381 | #define INBUFM 0x4000 /* b14: IN buffer monitor (Only for PIPE1 to 5) */ | ||
382 | #define CSCLR 0x2000 /* b13: complete-split status clear */ | ||
383 | #define CSSTS 0x1000 /* b12: complete-split status */ | ||
384 | #define ATREPM 0x0400 /* b10: Auto repeat mode */ | ||
385 | #define ACLRM 0x0200 /* b9: Out buffer auto clear mode */ | ||
386 | #define SQCLR 0x0100 /* b8: Sequence toggle bit clear */ | ||
387 | #define SQSET 0x0080 /* b7: Sequence toggle bit set */ | ||
388 | #define SQMON 0x0040 /* b6: Sequence toggle bit monitor */ | ||
389 | #define PBUSY 0x0020 /* b5: pipe busy */ | ||
390 | #define PID 0x0003 /* b1-0: Response PID */ | ||
391 | |||
392 | /* PIPExTRE */ | ||
393 | #define TRENB 0x0200 /* b9: Transaction counter enable */ | ||
394 | #define TRCLR 0x0100 /* b8: Transaction counter clear */ | ||
395 | |||
396 | /* PIPExTRN */ | ||
397 | #define TRNCNT 0xFFFF /* b15-0: Transaction counter */ | ||
398 | |||
399 | /* DEVADDx */ | ||
400 | #define UPPHUB 0x7800 | ||
401 | #define HUBPORT 0x0700 | ||
402 | #define USBSPD 0x00C0 | ||
403 | #define RTPORT 0x0001 | ||
404 | |||
405 | #define R8A66597_MAX_NUM_PIPE 10 | 35 | #define R8A66597_MAX_NUM_PIPE 10 |
406 | #define R8A66597_BUF_BSIZE 8 | 36 | #define R8A66597_BUF_BSIZE 8 |
407 | #define R8A66597_MAX_DEVICE 10 | 37 | #define R8A66597_MAX_DEVICE 10 |
408 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | ||
409 | #define R8A66597_MAX_ROOT_HUB 1 | ||
410 | #else | ||
411 | #define R8A66597_MAX_ROOT_HUB 2 | 38 | #define R8A66597_MAX_ROOT_HUB 2 |
412 | #endif | ||
413 | #define R8A66597_MAX_SAMPLING 5 | 39 | #define R8A66597_MAX_SAMPLING 5 |
414 | #define R8A66597_RH_POLL_TIME 10 | 40 | #define R8A66597_RH_POLL_TIME 10 |
415 | #define R8A66597_MAX_DMA_CHANNEL 2 | 41 | #define R8A66597_MAX_DMA_CHANNEL 2 |
@@ -487,7 +113,7 @@ struct r8a66597_root_hub { | |||
487 | struct r8a66597 { | 113 | struct r8a66597 { |
488 | spinlock_t lock; | 114 | spinlock_t lock; |
489 | unsigned long reg; | 115 | unsigned long reg; |
490 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) | 116 | #ifdef CONFIG_HAVE_CLK |
491 | struct clk *clk; | 117 | struct clk *clk; |
492 | #endif | 118 | #endif |
493 | struct r8a66597_platdata *pdata; | 119 | struct r8a66597_platdata *pdata; |
@@ -504,6 +130,7 @@ struct r8a66597 { | |||
504 | unsigned short interval_map; | 130 | unsigned short interval_map; |
505 | unsigned char pipe_cnt[R8A66597_MAX_NUM_PIPE]; | 131 | unsigned char pipe_cnt[R8A66597_MAX_NUM_PIPE]; |
506 | unsigned char dma_map; | 132 | unsigned char dma_map; |
133 | unsigned int max_root_hub; | ||
507 | 134 | ||
508 | struct list_head child_device; | 135 | struct list_head child_device; |
509 | unsigned long child_connect_map[4]; | 136 | unsigned long child_connect_map[4]; |
@@ -550,21 +177,22 @@ static inline void r8a66597_read_fifo(struct r8a66597 *r8a66597, | |||
550 | unsigned long offset, u16 *buf, | 177 | unsigned long offset, u16 *buf, |
551 | int len) | 178 | int len) |
552 | { | 179 | { |
553 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | ||
554 | unsigned long fifoaddr = r8a66597->reg + offset; | 180 | unsigned long fifoaddr = r8a66597->reg + offset; |
555 | unsigned long count; | 181 | unsigned long count; |
556 | 182 | ||
557 | count = len / 4; | 183 | if (r8a66597->pdata->on_chip) { |
558 | insl(fifoaddr, buf, count); | 184 | count = len / 4; |
185 | insl(fifoaddr, buf, count); | ||
559 | 186 | ||
560 | if (len & 0x00000003) { | 187 | if (len & 0x00000003) { |
561 | unsigned long tmp = inl(fifoaddr); | 188 | unsigned long tmp = inl(fifoaddr); |
562 | memcpy((unsigned char *)buf + count * 4, &tmp, len & 0x03); | 189 | memcpy((unsigned char *)buf + count * 4, &tmp, |
190 | len & 0x03); | ||
191 | } | ||
192 | } else { | ||
193 | len = (len + 1) / 2; | ||
194 | insw(fifoaddr, buf, len); | ||
563 | } | 195 | } |
564 | #else | ||
565 | len = (len + 1) / 2; | ||
566 | insw(r8a66597->reg + offset, buf, len); | ||
567 | #endif | ||
568 | } | 196 | } |
569 | 197 | ||
570 | static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val, | 198 | static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val, |
@@ -578,33 +206,33 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, | |||
578 | int len) | 206 | int len) |
579 | { | 207 | { |
580 | unsigned long fifoaddr = r8a66597->reg + offset; | 208 | unsigned long fifoaddr = r8a66597->reg + offset; |
581 | #if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) | ||
582 | unsigned long count; | 209 | unsigned long count; |
583 | unsigned char *pb; | 210 | unsigned char *pb; |
584 | int i; | 211 | int i; |
585 | 212 | ||
586 | count = len / 4; | 213 | if (r8a66597->pdata->on_chip) { |
587 | outsl(fifoaddr, buf, count); | 214 | count = len / 4; |
215 | outsl(fifoaddr, buf, count); | ||
216 | |||
217 | if (len & 0x00000003) { | ||
218 | pb = (unsigned char *)buf + count * 4; | ||
219 | for (i = 0; i < (len & 0x00000003); i++) { | ||
220 | if (r8a66597_read(r8a66597, CFIFOSEL) & BIGEND) | ||
221 | outb(pb[i], fifoaddr + i); | ||
222 | else | ||
223 | outb(pb[i], fifoaddr + 3 - i); | ||
224 | } | ||
225 | } | ||
226 | } else { | ||
227 | int odd = len & 0x0001; | ||
588 | 228 | ||
589 | if (len & 0x00000003) { | 229 | len = len / 2; |
590 | pb = (unsigned char *)buf + count * 4; | 230 | outsw(fifoaddr, buf, len); |
591 | for (i = 0; i < (len & 0x00000003); i++) { | 231 | if (unlikely(odd)) { |
592 | if (r8a66597_read(r8a66597, CFIFOSEL) & BIGEND) | 232 | buf = &buf[len]; |
593 | outb(pb[i], fifoaddr + i); | 233 | outb((unsigned char)*buf, fifoaddr); |
594 | else | ||
595 | outb(pb[i], fifoaddr + 3 - i); | ||
596 | } | 234 | } |
597 | } | 235 | } |
598 | #else | ||
599 | int odd = len & 0x0001; | ||
600 | |||
601 | len = len / 2; | ||
602 | outsw(fifoaddr, buf, len); | ||
603 | if (unlikely(odd)) { | ||
604 | buf = &buf[len]; | ||
605 | outb((unsigned char)*buf, fifoaddr); | ||
606 | } | ||
607 | #endif | ||
608 | } | 236 | } |
609 | 237 | ||
610 | static inline void r8a66597_mdfy(struct r8a66597 *r8a66597, | 238 | static inline void r8a66597_mdfy(struct r8a66597 *r8a66597, |
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 3b54b3940178..7e2c9774f08f 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig | |||
@@ -1867,7 +1867,7 @@ config FB_W100 | |||
1867 | 1867 | ||
1868 | config FB_SH_MOBILE_LCDC | 1868 | config FB_SH_MOBILE_LCDC |
1869 | tristate "SuperH Mobile LCDC framebuffer support" | 1869 | tristate "SuperH Mobile LCDC framebuffer support" |
1870 | depends on FB && SUPERH | 1870 | depends on FB && SUPERH && HAVE_CLK |
1871 | select FB_SYS_FILLRECT | 1871 | select FB_SYS_FILLRECT |
1872 | select FB_SYS_COPYAREA | 1872 | select FB_SYS_COPYAREA |
1873 | select FB_SYS_IMAGEBLIT | 1873 | select FB_SYS_IMAGEBLIT |
diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c index 07f22b625632..fc3f9662ceae 100644 --- a/drivers/video/sh_mobile_lcdcfb.c +++ b/drivers/video/sh_mobile_lcdcfb.c | |||
@@ -42,11 +42,9 @@ struct sh_mobile_lcdc_chan { | |||
42 | struct sh_mobile_lcdc_priv { | 42 | struct sh_mobile_lcdc_priv { |
43 | void __iomem *base; | 43 | void __iomem *base; |
44 | int irq; | 44 | int irq; |
45 | #ifdef CONFIG_HAVE_CLK | ||
46 | atomic_t clk_usecnt; | 45 | atomic_t clk_usecnt; |
47 | struct clk *dot_clk; | 46 | struct clk *dot_clk; |
48 | struct clk *clk; | 47 | struct clk *clk; |
49 | #endif | ||
50 | unsigned long lddckr; | 48 | unsigned long lddckr; |
51 | struct sh_mobile_lcdc_chan ch[2]; | 49 | struct sh_mobile_lcdc_chan ch[2]; |
52 | int started; | 50 | int started; |
@@ -156,6 +154,7 @@ static void lcdc_sys_write_index(void *handle, unsigned long data) | |||
156 | lcdc_write(ch->lcdc, _LDDWD0R, data | 0x10000000); | 154 | lcdc_write(ch->lcdc, _LDDWD0R, data | 0x10000000); |
157 | lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0); | 155 | lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0); |
158 | lcdc_write(ch->lcdc, _LDDWAR, 1 | (lcdc_chan_is_sublcd(ch) ? 2 : 0)); | 156 | lcdc_write(ch->lcdc, _LDDWAR, 1 | (lcdc_chan_is_sublcd(ch) ? 2 : 0)); |
157 | lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0); | ||
159 | } | 158 | } |
160 | 159 | ||
161 | static void lcdc_sys_write_data(void *handle, unsigned long data) | 160 | static void lcdc_sys_write_data(void *handle, unsigned long data) |
@@ -165,6 +164,7 @@ static void lcdc_sys_write_data(void *handle, unsigned long data) | |||
165 | lcdc_write(ch->lcdc, _LDDWD0R, data | 0x11000000); | 164 | lcdc_write(ch->lcdc, _LDDWD0R, data | 0x11000000); |
166 | lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0); | 165 | lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0); |
167 | lcdc_write(ch->lcdc, _LDDWAR, 1 | (lcdc_chan_is_sublcd(ch) ? 2 : 0)); | 166 | lcdc_write(ch->lcdc, _LDDWAR, 1 | (lcdc_chan_is_sublcd(ch) ? 2 : 0)); |
167 | lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0); | ||
168 | } | 168 | } |
169 | 169 | ||
170 | static unsigned long lcdc_sys_read_data(void *handle) | 170 | static unsigned long lcdc_sys_read_data(void *handle) |
@@ -175,8 +175,9 @@ static unsigned long lcdc_sys_read_data(void *handle) | |||
175 | lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0); | 175 | lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0); |
176 | lcdc_write(ch->lcdc, _LDDRAR, 1 | (lcdc_chan_is_sublcd(ch) ? 2 : 0)); | 176 | lcdc_write(ch->lcdc, _LDDRAR, 1 | (lcdc_chan_is_sublcd(ch) ? 2 : 0)); |
177 | udelay(1); | 177 | udelay(1); |
178 | lcdc_wait_bit(ch->lcdc, _LDSR, 2, 0); | ||
178 | 179 | ||
179 | return lcdc_read(ch->lcdc, _LDDRDR) & 0xffff; | 180 | return lcdc_read(ch->lcdc, _LDDRDR) & 0x3ffff; |
180 | } | 181 | } |
181 | 182 | ||
182 | struct sh_mobile_lcdc_sys_bus_ops sh_mobile_lcdc_sys_bus_ops = { | 183 | struct sh_mobile_lcdc_sys_bus_ops sh_mobile_lcdc_sys_bus_ops = { |
@@ -185,7 +186,6 @@ struct sh_mobile_lcdc_sys_bus_ops sh_mobile_lcdc_sys_bus_ops = { | |||
185 | lcdc_sys_read_data, | 186 | lcdc_sys_read_data, |
186 | }; | 187 | }; |
187 | 188 | ||
188 | #ifdef CONFIG_HAVE_CLK | ||
189 | static void sh_mobile_lcdc_clk_on(struct sh_mobile_lcdc_priv *priv) | 189 | static void sh_mobile_lcdc_clk_on(struct sh_mobile_lcdc_priv *priv) |
190 | { | 190 | { |
191 | if (atomic_inc_and_test(&priv->clk_usecnt)) { | 191 | if (atomic_inc_and_test(&priv->clk_usecnt)) { |
@@ -203,10 +203,6 @@ static void sh_mobile_lcdc_clk_off(struct sh_mobile_lcdc_priv *priv) | |||
203 | clk_disable(priv->clk); | 203 | clk_disable(priv->clk); |
204 | } | 204 | } |
205 | } | 205 | } |
206 | #else | ||
207 | static void sh_mobile_lcdc_clk_on(struct sh_mobile_lcdc_priv *priv) {} | ||
208 | static void sh_mobile_lcdc_clk_off(struct sh_mobile_lcdc_priv *priv) {} | ||
209 | #endif | ||
210 | 206 | ||
211 | static int sh_mobile_lcdc_sginit(struct fb_info *info, | 207 | static int sh_mobile_lcdc_sginit(struct fb_info *info, |
212 | struct list_head *pagelist) | 208 | struct list_head *pagelist) |
@@ -520,7 +516,6 @@ static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv) | |||
520 | board_cfg = &ch->cfg.board_cfg; | 516 | board_cfg = &ch->cfg.board_cfg; |
521 | if (board_cfg->display_off) | 517 | if (board_cfg->display_off) |
522 | board_cfg->display_off(board_cfg->board_data); | 518 | board_cfg->display_off(board_cfg->board_data); |
523 | |||
524 | } | 519 | } |
525 | 520 | ||
526 | /* stop the lcdc */ | 521 | /* stop the lcdc */ |
@@ -579,9 +574,7 @@ static int sh_mobile_lcdc_setup_clocks(struct platform_device *pdev, | |||
579 | int clock_source, | 574 | int clock_source, |
580 | struct sh_mobile_lcdc_priv *priv) | 575 | struct sh_mobile_lcdc_priv *priv) |
581 | { | 576 | { |
582 | #ifdef CONFIG_HAVE_CLK | ||
583 | char clk_name[8]; | 577 | char clk_name[8]; |
584 | #endif | ||
585 | char *str; | 578 | char *str; |
586 | int icksel; | 579 | int icksel; |
587 | 580 | ||
@@ -595,7 +588,6 @@ static int sh_mobile_lcdc_setup_clocks(struct platform_device *pdev, | |||
595 | 588 | ||
596 | priv->lddckr = icksel << 16; | 589 | priv->lddckr = icksel << 16; |
597 | 590 | ||
598 | #ifdef CONFIG_HAVE_CLK | ||
599 | atomic_set(&priv->clk_usecnt, -1); | 591 | atomic_set(&priv->clk_usecnt, -1); |
600 | snprintf(clk_name, sizeof(clk_name), "lcdc%d", pdev->id); | 592 | snprintf(clk_name, sizeof(clk_name), "lcdc%d", pdev->id); |
601 | priv->clk = clk_get(&pdev->dev, clk_name); | 593 | priv->clk = clk_get(&pdev->dev, clk_name); |
@@ -603,7 +595,7 @@ static int sh_mobile_lcdc_setup_clocks(struct platform_device *pdev, | |||
603 | dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name); | 595 | dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name); |
604 | return PTR_ERR(priv->clk); | 596 | return PTR_ERR(priv->clk); |
605 | } | 597 | } |
606 | 598 | ||
607 | if (str) { | 599 | if (str) { |
608 | priv->dot_clk = clk_get(&pdev->dev, str); | 600 | priv->dot_clk = clk_get(&pdev->dev, str); |
609 | if (IS_ERR(priv->dot_clk)) { | 601 | if (IS_ERR(priv->dot_clk)) { |
@@ -612,7 +604,6 @@ static int sh_mobile_lcdc_setup_clocks(struct platform_device *pdev, | |||
612 | return PTR_ERR(priv->dot_clk); | 604 | return PTR_ERR(priv->dot_clk); |
613 | } | 605 | } |
614 | } | 606 | } |
615 | #endif | ||
616 | 607 | ||
617 | return 0; | 608 | return 0; |
618 | } | 609 | } |
@@ -947,11 +938,9 @@ static int sh_mobile_lcdc_remove(struct platform_device *pdev) | |||
947 | framebuffer_release(info); | 938 | framebuffer_release(info); |
948 | } | 939 | } |
949 | 940 | ||
950 | #ifdef CONFIG_HAVE_CLK | ||
951 | if (priv->dot_clk) | 941 | if (priv->dot_clk) |
952 | clk_put(priv->dot_clk); | 942 | clk_put(priv->dot_clk); |
953 | clk_put(priv->clk); | 943 | clk_put(priv->clk); |
954 | #endif | ||
955 | 944 | ||
956 | if (priv->base) | 945 | if (priv->base) |
957 | iounmap(priv->base); | 946 | iounmap(priv->base); |