2 * HCD driver for ADM5120 SoC
4 * Copyright (C) 2005 Jeroen Vreeken (pe1rxq@amsat.org)
6 * Based on the ADMtek 2.4 driver
7 * (C) Copyright 2003 Junius Chen <juniusc@admtek.com.tw>
8 * Which again was based on the ohci and uhci drivers.
11 #include <linux/autoconf.h>
12 #include <linux/moduleparam.h>
13 #include <linux/kernel.h>
14 #include <linux/errno.h>
15 #include <linux/interrupt.h>
16 #include <linux/usb.h>
17 #include <linux/platform_device.h>
19 #include "../core/hcd.h"
21 MODULE_DESCRIPTION("ADM5120 USB Host Controller Driver");
22 MODULE_LICENSE("GPL");
23 MODULE_AUTHOR("Jeroen Vreeken (pe1rxq@amsat.org)");
25 #define ADMHCD_REG_CONTROL 0x00
26 #define ADMHCD_REG_INTSTATUS 0x04
27 #define ADMHCD_REG_INTENABLE 0x08
28 #define ADMHCD_REG_HOSTCONTROL 0x10
29 #define ADMHCD_REG_FMINTERVAL 0x18
30 #define ADMHCD_REG_FMNUMBER 0x1c
31 #define ADMHCD_REG_LSTHRESH 0x70
32 #define ADMHCD_REG_RHDESCR 0x74
33 #define ADMHCD_REG_PORTSTATUS0 0x78
34 #define ADMHCD_REG_PORTSTATUS1 0x7c
35 #define ADMHCD_REG_HOSTHEAD 0x80
38 #define ADMHCD_NUMPORTS 2
40 #define ADMHCD_HOST_EN 0x00000001 /* Host enable */
41 #define ADMHCD_SW_INTREQ 0x00000002 /* request software int */
42 #define ADMHCD_SW_RESET 0x00000008 /* Reset */
44 #define ADMHCD_INT_TD 0x00100000 /* TD completed */
45 #define ADMHCD_INT_SW 0x20000000 /* software interrupt */
46 #define ADMHCD_INT_FATAL 0x40000000 /* Fatal interrupt */
47 #define ADMHCD_INT_ACT 0x80000000 /* Interrupt active */
49 #define ADMHCD_STATE_RST 0x00000000 /* bus state reset */
50 #define ADMHCD_STATE_RES 0x00000001 /* bus state resume */
51 #define ADMHCD_STATE_OP 0x00000002 /* bus state operational */
52 #define ADMHCD_STATE_SUS 0x00000003 /* bus state suspended */
53 #define ADMHCD_DMA_EN 0x00000004 /* enable dma engine */
55 #define ADMHCD_NPS 0x00000020 /* No Power Switch */
56 #define ADMHCD_LPSC 0x04000000 /* Local power switch change */
58 #define ADMHCD_CCS 0x00000001 /* current connect status */
59 #define ADMHCD_PES 0x00000002 /* port enable status */
60 #define ADMHCD_PSS 0x00000004 /* port suspend status */
61 #define ADMHCD_POCI 0x00000008 /* port overcurrent indicator */
62 #define ADMHCD_PRS 0x00000010 /* port reset status */
63 #define ADMHCD_PPS 0x00000100 /* port power status */
64 #define ADMHCD_LSDA 0x00000200 /* low speed device attached */
65 #define ADMHCD_CSC 0x00010000 /* connect status change */
66 #define ADMHCD_PESC 0x00020000 /* enable status change */
67 #define ADMHCD_PSSC 0x00040000 /* suspend status change */
68 #define ADMHCD_OCIC 0x00080000 /* overcurrent change*/
69 #define ADMHCD_PRSC 0x00100000 /* reset status change */
73 /* Don't change first four, they used for DMA */
75 struct admhcd_td
*tail
;
76 struct admhcd_td
*head
;
77 struct admhcd_ed
*next
;
78 /* the rest is for the driver only: */
79 struct admhcd_td
*cur
;
80 struct usb_host_endpoint
*ep
;
82 struct admhcd_ed
*real
;
83 } __attribute__ ((packed
));
85 #define ADMHCD_ED_EPSHIFT 7 /* Shift for endpoint number */
86 #define ADMHCD_ED_INT 0x00000800 /* Is this an int endpoint */
87 #define ADMHCD_ED_SPEED 0x00002000 /* Is it a high speed dev? */
88 #define ADMHCD_ED_SKIP 0x00004000 /* Skip this ED */
89 #define ADMHCD_ED_FORMAT 0x00008000 /* Is this an isoc endpoint */
90 #define ADMHCD_ED_MAXSHIFT 16 /* Shift for max packet size */
93 /* Don't change first four, they are used for DMA */
97 struct admhcd_td
*next
;
98 /* the rest is for the driver only: */
100 struct admhcd_td
*real
;
101 } __attribute__ ((packed
));
103 #define ADMHCD_TD_OWN 0x80000000
104 #define ADMHCD_TD_TOGGLE 0x00000000
105 #define ADMHCD_TD_DATA0 0x01000000
106 #define ADMHCD_TD_DATA1 0x01800000
107 #define ADMHCD_TD_OUT 0x00200000
108 #define ADMHCD_TD_IN 0x00400000
109 #define ADMHCD_TD_SETUP 0x00000000
110 #define ADMHCD_TD_ISO 0x00010000
111 #define ADMHCD_TD_R 0x00040000
112 #define ADMHCD_TD_INTEN 0x00010000
114 static int admhcd_td_err
[16] = {
116 -EREMOTEIO
, /* CRC */
117 -EREMOTEIO
, /* bit stuff */
118 -EREMOTEIO
, /* data toggle */
120 -ETIMEDOUT
, /* timeout */
121 -EPROTO
, /* pid err */
122 -EPROTO
, /* unexpected pid */
123 -EREMOTEIO
, /* data overrun */
124 -EREMOTEIO
, /* data underrun */
125 -ETIMEDOUT
, /* 1010 */
126 -ETIMEDOUT
, /* 1011 */
127 -EREMOTEIO
, /* buffer overrun */
128 -EREMOTEIO
, /* buffer underrun */
129 -ETIMEDOUT
, /* 1110 */
130 -ETIMEDOUT
, /* 1111 */
133 #define ADMHCD_TD_ERRMASK 0x38000000
134 #define ADMHCD_TD_ERRSHIFT 27
136 #define TD(td) ((struct admhcd_td *)(((u32)(td)) & ~0xf))
137 #define ED(ed) ((struct admhcd_ed *)(((u32)(ed)) & ~0xf))
146 #define hcd_to_admhcd(hcd) ((struct admhcd *)(hcd)->hcd_priv)
148 static char hcd_name
[] = "adm5120-hcd";
150 static u32
admhcd_reg_get(struct admhcd
*ahcd
, int reg
)
152 return *(volatile u32
*)KSEG1ADDR(ahcd
->base
+reg
);
155 static void admhcd_reg_set(struct admhcd
*ahcd
, int reg
, u32 val
)
157 *(volatile u32
*)KSEG1ADDR(ahcd
->base
+reg
) = val
;
160 static void admhcd_lock(struct admhcd
*ahcd
)
162 spin_lock_irqsave(&ahcd
->lock
, ahcd
->flags
);
163 ahcd
->dma_en
= admhcd_reg_get(ahcd
, ADMHCD_REG_HOSTCONTROL
) &
165 admhcd_reg_set(ahcd
, ADMHCD_REG_HOSTCONTROL
, ADMHCD_STATE_OP
);
168 static void admhcd_unlock(struct admhcd
*ahcd
)
170 admhcd_reg_set(ahcd
, ADMHCD_REG_HOSTCONTROL
,
171 ADMHCD_STATE_OP
| ahcd
->dma_en
);
172 spin_unlock_irqrestore(&ahcd
->lock
, ahcd
->flags
);
175 static struct admhcd_td
*admhcd_td_alloc(struct admhcd_ed
*ed
, struct urb
*urb
)
177 struct admhcd_td
*tdn
, *td
;
179 tdn
= kmalloc(sizeof(struct admhcd_td
), GFP_ATOMIC
);
183 tdn
= (struct admhcd_td
*)KSEG1ADDR(tdn
);
184 memset(tdn
, 0, sizeof(struct admhcd_td
));
185 if (ed
->cur
== NULL
) {
191 /* Supply back the old tail and link in new td as tail */
193 TD(ed
->tail
)->next
= tdn
;
201 static void admhcd_td_free(struct admhcd_ed
*ed
, struct urb
*urb
)
203 struct admhcd_td
*td
, **tdp
;
206 ed
->control
|= ADMHCD_ED_SKIP
;
215 while (td
&& td
->urb
== urb
) {
222 /* Find an endpoint's descriptor, if needed allocate a new one and link it
225 static struct admhcd_ed
*admhcd_get_ed(struct admhcd
*ahcd
,
226 struct usb_host_endpoint
*ep
, struct urb
*urb
)
228 struct admhcd_ed
*hosthead
;
229 struct admhcd_ed
*found
= NULL
, *ed
= NULL
;
230 unsigned int pipe
= urb
->pipe
;
233 hosthead
= (struct admhcd_ed
*)admhcd_reg_get(ahcd
, ADMHCD_REG_HOSTHEAD
);
235 for (ed
= hosthead
;; ed
= ED(ed
->next
)) {
240 if (ED(ed
->next
) == hosthead
)
245 found
= kmalloc(sizeof(struct admhcd_ed
), GFP_ATOMIC
);
248 memset(found
, 0, sizeof(struct admhcd_ed
));
251 found
= (struct admhcd_ed
*)KSEG1ADDR(found
);
252 found
->control
= usb_pipedevice(pipe
) |
253 (usb_pipeendpoint(pipe
) << ADMHCD_ED_EPSHIFT
) |
254 (usb_pipeint(pipe
) ? ADMHCD_ED_INT
: 0) |
255 (urb
->dev
->speed
== USB_SPEED_FULL
? ADMHCD_ED_SPEED
: 0) |
256 (usb_pipeisoc(pipe
) ? ADMHCD_ED_FORMAT
: 0) |
257 (usb_maxpacket(urb
->dev
, pipe
, usb_pipeout(pipe
)) << ADMHCD_ED_MAXSHIFT
);
258 /* Alloc first dummy td */
259 admhcd_td_alloc(found
, NULL
);
261 found
->next
= hosthead
;
265 admhcd_reg_set(ahcd
, ADMHCD_REG_HOSTHEAD
, (u32
)found
);
273 static struct admhcd_td
*admhcd_td_fill(u32 control
, struct admhcd_td
*td
,
274 dma_addr_t data
, int len
)
278 td
->control
= control
;
282 static void admhcd_ed_start(struct admhcd
*ahcd
, struct admhcd_ed
*ed
)
284 struct admhcd_td
*td
= ed
->cur
;
291 td
->control
|= ADMHCD_TD_OWN
;
292 if (TD(td
->next
)->urb
!= td
->urb
) {
293 td
->buflen
|= ADMHCD_TD_INTEN
;
299 ed
->head
= TD(ed
->head
);
300 ahcd
->dma_en
|= ADMHCD_DMA_EN
;
303 static irqreturn_t
adm5120hcd_irq(int irq
, void *ptr
, struct pt_regs
*regs
)
305 struct usb_hcd
*hcd
= (struct usb_hcd
*)ptr
;
306 struct admhcd
*ahcd
= hcd_to_admhcd(hcd
);
309 intstatus
= admhcd_reg_get(ahcd
, ADMHCD_REG_INTSTATUS
);
310 if (intstatus
& ADMHCD_INT_FATAL
) {
311 admhcd_reg_set(ahcd
, ADMHCD_REG_INTSTATUS
, ADMHCD_INT_FATAL
);
314 if (intstatus
& ADMHCD_INT_SW
) {
315 admhcd_reg_set(ahcd
, ADMHCD_REG_INTSTATUS
, ADMHCD_INT_SW
);
318 if (intstatus
& ADMHCD_INT_TD
) {
319 struct admhcd_ed
*ed
, *head
;
321 admhcd_reg_set(ahcd
, ADMHCD_REG_INTSTATUS
, ADMHCD_INT_TD
);
323 head
= (struct admhcd_ed
*)admhcd_reg_get(ahcd
, ADMHCD_REG_HOSTHEAD
);
326 /* Is it a finished TD? */
327 if (ed
->urb
&& !(ed
->cur
->control
& ADMHCD_TD_OWN
)) {
328 struct admhcd_td
*td
;
332 error
= (td
->control
& ADMHCD_TD_ERRMASK
) >>
334 ed
->urb
->status
= admhcd_td_err
[error
];
335 admhcd_td_free(ed
, ed
->urb
);
336 // Calculate real length!!!
337 ed
->urb
->actual_length
= ed
->urb
->transfer_buffer_length
;
338 ed
->urb
->hcpriv
= NULL
;
339 usb_hcd_giveback_urb(hcd
, ed
->urb
);
342 admhcd_ed_start(ahcd
, ed
);
344 } while (ed
!= head
);
350 static int admhcd_urb_enqueue(struct usb_hcd
*hcd
, struct usb_host_endpoint
*ep
,
351 struct urb
*urb
, int mem_flags
)
353 struct admhcd
*ahcd
= hcd_to_admhcd(hcd
);
354 struct admhcd_ed
*ed
;
355 struct admhcd_td
*td
;
356 int size
= 0, i
, zero
= 0, ret
= 0;
357 unsigned int pipe
= urb
->pipe
, toggle
= 0;
358 dma_addr_t data
= (dma_addr_t
)urb
->transfer_buffer
;
359 int data_len
= urb
->transfer_buffer_length
;
361 ed
= admhcd_get_ed(ahcd
, ep
, urb
);
365 switch(usb_pipetype(pipe
)) {
371 size
+= urb
->transfer_buffer_length
/ 4096;
372 if (urb
->transfer_buffer_length
% 4096)
376 else if (urb
->transfer_flags
& URB_ZERO_PACKET
&&
377 !(urb
->transfer_buffer_length
%
378 usb_maxpacket(urb
->dev
, pipe
, usb_pipeout(pipe
)))) {
383 case PIPE_ISOCHRONOUS
:
384 size
= urb
->number_of_packets
;
389 /* Remember the first td */
390 td
= admhcd_td_alloc(ed
, urb
);
395 /* Allocate additionall tds first */
396 for (i
= 1; i
< size
; i
++) {
397 if (admhcd_td_alloc(ed
, urb
) == NULL
) {
398 admhcd_td_free(ed
, urb
);
404 if (usb_gettoggle(urb
->dev
, usb_pipeendpoint(pipe
), usb_pipeout(pipe
)))
405 toggle
= ADMHCD_TD_TOGGLE
;
407 toggle
= ADMHCD_TD_DATA0
;
408 usb_settoggle(urb
->dev
, usb_pipeendpoint(pipe
),
409 usb_pipeout(pipe
), 1);
412 switch(usb_pipetype(pipe
)) {
414 td
= admhcd_td_fill(ADMHCD_TD_SETUP
| ADMHCD_TD_DATA0
,
415 td
, (dma_addr_t
)urb
->setup_packet
, 8);
416 while (data_len
> 0) {
417 td
= admhcd_td_fill(ADMHCD_TD_DATA1
420 ADMHCD_TD_OUT
: ADMHCD_TD_IN
), td
,
421 data
, data_len
% 4097);
424 admhcd_td_fill(ADMHCD_TD_DATA1
| (usb_pipeout(pipe
) ?
425 ADMHCD_TD_IN
: ADMHCD_TD_OUT
), td
,
430 //info ok for interrupt?
432 while(data_len
> 4096) {
433 td
= admhcd_td_fill((usb_pipeout(pipe
) ?
435 ADMHCD_TD_IN
| ADMHCD_TD_R
) |
436 (i
? ADMHCD_TD_TOGGLE
: toggle
), td
,
442 td
= admhcd_td_fill((usb_pipeout(pipe
) ?
443 ADMHCD_TD_OUT
: ADMHCD_TD_IN
) |
444 (i
? ADMHCD_TD_TOGGLE
: toggle
), td
, data
, data_len
);
447 admhcd_td_fill((usb_pipeout(pipe
) ?
448 ADMHCD_TD_OUT
: ADMHCD_TD_IN
) |
449 (i
? ADMHCD_TD_TOGGLE
: toggle
), td
, 0, 0);
451 case PIPE_ISOCHRONOUS
:
452 for (i
= 0; i
< urb
->number_of_packets
; i
++) {
453 td
= admhcd_td_fill(ADMHCD_TD_ISO
|
454 ((urb
->start_frame
+ i
) & 0xffff), td
,
455 data
+ urb
->iso_frame_desc
[i
].offset
,
456 urb
->iso_frame_desc
[i
].length
);
461 admhcd_ed_start(ahcd
, ed
);
467 static int admhcd_urb_dequeue(struct usb_hcd
*hcd
, struct urb
*urb
)
469 struct admhcd
*ahcd
= hcd_to_admhcd(hcd
);
470 struct admhcd_ed
*ed
;
475 if (ed
&& ed
->urb
!= urb
)
476 admhcd_td_free(ed
, urb
);
482 static void admhcd_endpoint_disable(struct usb_hcd
*hcd
, struct usb_host_endpoint
*ep
)
484 struct admhcd
*ahcd
= hcd_to_admhcd(hcd
);
485 struct admhcd_ed
*ed
, *edt
, *head
;
489 head
= (struct admhcd_ed
*)admhcd_reg_get(ahcd
, ADMHCD_REG_HOSTHEAD
);
492 for (ed
= head
; ED(ed
->next
) != head
; ed
= ED(ed
->next
))
498 admhcd_td_free(ed
, ed
->cur
->urb
);
500 if (ED(ed
->next
) == ed
) {
501 admhcd_reg_set(ahcd
, ADMHCD_REG_HOSTHEAD
, 0);
506 for (edt
= head
; ED(edt
->next
) != head
; edt
= ED(edt
->next
));
507 edt
->next
= ED(ed
->next
);
508 admhcd_reg_set(ahcd
, ADMHCD_REG_HOSTHEAD
, (u32
)ed
->next
);
511 for (edt
= head
; edt
->next
!= ed
; edt
= edt
->next
);
512 edt
->next
= ed
->next
;
519 static int admhcd_get_frame_number(struct usb_hcd
*hcd
)
521 struct admhcd
*ahcd
= hcd_to_admhcd(hcd
);
523 return admhcd_reg_get(ahcd
, ADMHCD_REG_FMNUMBER
) & 0x0000ffff;
526 static int admhcd_hub_status_data(struct usb_hcd
*hcd
, char *buf
)
528 struct admhcd
*ahcd
= hcd_to_admhcd(hcd
);
532 for (port
= 0; port
< ADMHCD_NUMPORTS
; port
++) {
533 if (admhcd_reg_get(ahcd
, ADMHCD_REG_PORTSTATUS0
+ port
*4) &
534 (ADMHCD_CSC
| ADMHCD_PESC
| ADMHCD_PSSC
| ADMHCD_OCIC
|
536 *buf
|= (1 << (port
+ 1));
541 static __u8 root_hub_hub_des
[] = {
542 0x09, /* __u8 bLength; */
543 0x29, /* __u8 bDescriptorType; Hub-descriptor */
544 0x02, /* __u8 bNbrPorts; */
545 0x0a, 0x00, /* __u16 wHubCharacteristics; */
546 0x01, /* __u8 bPwrOn2pwrGood; 2ms */
547 0x00, /* __u8 bHubContrCurrent; 0mA */
548 0x00, /* __u8 DeviceRemovable; */
549 0xff, /* __u8 PortPwrCtrlMask; */
552 static int admhcd_hub_control(struct usb_hcd
*hcd
, u16 typeReq
, u16 wValue
,
553 u16 wIndex
, char *buf
, u16 wLength
)
555 struct admhcd
*ahcd
= hcd_to_admhcd(hcd
);
557 unsigned int port
= wIndex
-1;
562 *(__le32
*)buf
= cpu_to_le32(0);
565 if (port
>= ADMHCD_NUMPORTS
)
567 *(__le32
*)buf
= cpu_to_le32(
568 admhcd_reg_get(ahcd
, ADMHCD_REG_PORTSTATUS0
+ port
*4));
570 case SetHubFeature
: /* We don't implement these */
571 case ClearHubFeature
:
573 case C_HUB_OVER_CURRENT
:
574 case C_HUB_LOCAL_POWER
:
580 if (port
>= ADMHCD_NUMPORTS
)
584 case USB_PORT_FEAT_SUSPEND
:
585 admhcd_reg_set(ahcd
, ADMHCD_REG_PORTSTATUS0
+ port
*4,
588 case USB_PORT_FEAT_RESET
:
589 if (admhcd_reg_get(ahcd
, ADMHCD_REG_PORTSTATUS0
+ port
*4)
592 ADMHCD_REG_PORTSTATUS0
+ port
*4,
593 ADMHCD_PRS
| ADMHCD_CSC
);
596 ADMHCD_REG_PORTSTATUS0
+ port
*4,
597 ADMHCD_PES
| ADMHCD_CSC
);
600 case USB_PORT_FEAT_POWER
:
601 admhcd_reg_set(ahcd
, ADMHCD_REG_PORTSTATUS0
+ port
*4,
608 case ClearPortFeature
:
609 if (port
>= ADMHCD_NUMPORTS
)
613 case USB_PORT_FEAT_ENABLE
:
614 admhcd_reg_set(ahcd
, ADMHCD_REG_PORTSTATUS0
+ port
*4,
617 case USB_PORT_FEAT_C_ENABLE
:
618 admhcd_reg_set(ahcd
, ADMHCD_REG_PORTSTATUS0
+ port
*4,
621 case USB_PORT_FEAT_SUSPEND
:
622 admhcd_reg_set(ahcd
, ADMHCD_REG_PORTSTATUS0
+ port
*4,
625 case USB_PORT_FEAT_C_SUSPEND
:
626 admhcd_reg_set(ahcd
, ADMHCD_REG_PORTSTATUS0
+ port
*4,
628 case USB_PORT_FEAT_POWER
:
629 admhcd_reg_set(ahcd
, ADMHCD_REG_PORTSTATUS0
+ port
*4,
632 case USB_PORT_FEAT_C_CONNECTION
:
633 admhcd_reg_set(ahcd
, ADMHCD_REG_PORTSTATUS0
+ port
*4,
636 case USB_PORT_FEAT_C_OVER_CURRENT
:
637 admhcd_reg_set(ahcd
, ADMHCD_REG_PORTSTATUS0
+ port
*4,
640 case USB_PORT_FEAT_C_RESET
:
641 admhcd_reg_set(ahcd
, ADMHCD_REG_PORTSTATUS0
+ port
*4,
648 case GetHubDescriptor
:
649 len
= min_t(unsigned int, sizeof(root_hub_hub_des
), wLength
);
650 memcpy(buf
, root_hub_hub_des
, len
);
660 static struct hc_driver adm5120_hc_driver
= {
661 .description
= hcd_name
,
662 .product_desc
= "ADM5120 HCD",
663 .hcd_priv_size
= sizeof(struct admhcd
),
665 .urb_enqueue
= admhcd_urb_enqueue
,
666 .urb_dequeue
= admhcd_urb_dequeue
,
667 .endpoint_disable
= admhcd_endpoint_disable
,
668 .get_frame_number
= admhcd_get_frame_number
,
669 .hub_status_data
= admhcd_hub_status_data
,
670 .hub_control
= admhcd_hub_control
,
673 static int __init
adm5120hcd_probe(struct platform_device
*pdev
)
677 struct usb_device
*udev
;
680 if (!request_mem_region(pdev
->resource
[0].start
,
681 pdev
->resource
[0].end
- pdev
->resource
[0].start
, hcd_name
)) {
682 pr_debug("couldn't request mem\n");
687 //hcd = usb_create_hcd(&adm5120_hc_driver, pdev, pdev->bus_id);
691 ahcd
= hcd_to_admhcd(hcd
);
692 dev_set_drvdata(pdev
, ahcd
);
693 hcd
->self
.controller
= pdev
;
694 //hcd->self.bus_name = pdev->bus_id;
695 hcd
->irq
= pdev
->resource
[1].start
;
696 hcd
->regs
= (void *)pdev
->resource
[0].start
;
697 hcd
->product_desc
= hcd_name
;
698 ahcd
->base
= pdev
->resource
[0].start
;
700 if (request_irq(pdev
->resource
[1].start
, adm5120hcd_irq
, 0, hcd_name
,
702 pr_debug("couldn't request irq\n");
707 //err = usb_register_bus(&hcd->self);
711 spin_lock_init(&ahcd
->lock
);
713 admhcd_reg_set(ahcd
, ADMHCD_REG_INTENABLE
, 0);
715 admhcd_reg_set(ahcd
, ADMHCD_REG_CONTROL
, ADMHCD_SW_RESET
);
716 while (admhcd_reg_get(ahcd
, ADMHCD_REG_CONTROL
) & ADMHCD_SW_RESET
)
719 admhcd_reg_set(ahcd
, ADMHCD_REG_CONTROL
, ADMHCD_HOST_EN
);
720 admhcd_reg_set(ahcd
, ADMHCD_REG_HOSTHEAD
, 0x00000000);
721 admhcd_reg_set(ahcd
, ADMHCD_REG_FMINTERVAL
, 0x20002edf);
722 admhcd_reg_set(ahcd
, ADMHCD_REG_LSTHRESH
, 0x628);
723 admhcd_reg_set(ahcd
, ADMHCD_REG_INTENABLE
,
724 ADMHCD_INT_ACT
| ADMHCD_INT_FATAL
| ADMHCD_INT_SW
| ADMHCD_INT_TD
);
725 admhcd_reg_set(ahcd
, ADMHCD_REG_INTSTATUS
,
726 ADMHCD_INT_ACT
| ADMHCD_INT_FATAL
| ADMHCD_INT_SW
| ADMHCD_INT_TD
);
727 admhcd_reg_set(ahcd
, ADMHCD_REG_RHDESCR
, ADMHCD_NPS
| ADMHCD_LPSC
);
728 admhcd_reg_set(ahcd
, ADMHCD_REG_HOSTCONTROL
, ADMHCD_STATE_OP
);
730 udev
= usb_alloc_dev(NULL
, &hcd
->self
, 0);
736 udev
->speed
= USB_SPEED_FULL
;
737 hcd
->state
= HC_STATE_RUNNING
;
739 //err = hcd_register_root(udev, hcd);
741 // usb_put_dev(udev);
750 //usb_deregister_bus(&hcd->self);
752 free_irq(pdev
->resource
[1].start
, hcd
);
756 release_mem_region(pdev
->resource
[0].start
,
757 pdev
->resource
[0].end
- pdev
->resource
[0].start
);
762 static int __init_or_module
adm5120hcd_remove(struct platform_device
*pdev
)
764 device_init_wakeup(&pdev
->dev
, 0);
767 static struct platform_driver adm5120hcd_driver
= {
768 .probe
= adm5120hcd_probe
,
769 .remove
= adm5120hcd_remove
,
771 .name
= "adm5120-hcd",
772 .owner
= THIS_MODULE
,
776 static int __init
adm5120hcd_init(void)
781 return platform_driver_register(&adm5120hcd_driver
);
784 static void __exit
adm5120hcd_exit(void)
786 platform_driver_unregister(&adm5120hcd_driver
);
789 module_init(adm5120hcd_init
);
790 module_exit(adm5120hcd_exit
);