2 * ADM5120 HCD (Host Controller Driver) for USB
4 * Copyright (C) 2007,2008 Gabor Juhos <juhosg at openwrt.org>
6 * This file was derived from: drivers/usb/host/ohci-au1xxx.c
7 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
8 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
9 * (C) Copyright 2002 Hewlett-Packard Company
11 * Written by Christopher Hoover <ch@hpl.hp.com>
12 * Based on fragments of previous driver by Rusell King et al.
14 * Modified for LH7A404 from ahcd-sa1111.c
15 * by Durgesh Pattamatta <pattamattad@sharpsec.com>
16 * Modified for AMD Alchemy Au1xxx
17 * by Matt Porter <mporter@kernel.crashing.org>
19 * This program is free software; you can redistribute it and/or modify it
20 * under the terms of the GNU General Public License version 2 as published
21 * by the Free Software Foundation.
25 #include <linux/platform_device.h>
26 #include <linux/signal.h>
28 #include <asm/bootinfo.h>
29 #include <adm5120_defs.h>
32 #define HCD_DBG(f, a...) printk(KERN_DEBUG "%s: " f, hcd_name, ## a)
34 #define HCD_DBG(f, a...) do {} while (0)
36 #define HCD_ERR(f, a...) printk(KERN_ERR "%s: " f, hcd_name, ## a)
37 #define HCD_INFO(f, a...) printk(KERN_INFO "%s: " f, hcd_name, ## a)
39 /*-------------------------------------------------------------------------*/
41 static int admhc_adm5120_probe(const struct hc_driver
*driver
,
42 struct platform_device
*dev
)
47 struct resource
*regs
;
50 regs
= platform_get_resource(dev
, IORESOURCE_MEM
, 0);
52 HCD_DBG("no IOMEM resource found\n");
56 irq
= platform_get_irq(dev
, 0);
58 HCD_DBG("no IRQ resource found\n");
62 hcd
= usb_create_hcd(driver
, &dev
->dev
, "ADM5120");
66 hcd
->rsrc_start
= regs
->start
;
67 hcd
->rsrc_len
= regs
->end
- regs
->start
+ 1;
69 if (!request_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
, hcd_name
)) {
70 HCD_DBG("request_mem_region failed\n");
75 hcd
->regs
= ioremap(hcd
->rsrc_start
, hcd
->rsrc_len
);
77 HCD_DBG("ioremap failed\n");
82 admhc_hcd_init(hcd_to_admhcd(hcd
));
84 retval
= usb_add_hcd(hcd
, irq
, IRQF_DISABLED
);
93 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
100 /* may be called without controller electrically present */
101 /* may be called with controller, bus, and devices active */
103 static void admhc_adm5120_remove(struct usb_hcd
*hcd
,
104 struct platform_device
*dev
)
108 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
112 /*-------------------------------------------------------------------------*/
115 admhc_adm5120_start(struct usb_hcd
*hcd
)
117 struct admhcd
*ahcd
= hcd_to_admhcd (hcd
);
120 ret
= admhc_init(ahcd
);
122 HCD_ERR("unable to init %s\n", hcd
->self
.bus_name
);
126 ret
= admhc_run(ahcd
);
128 HCD_ERR("unable to run %s\n", hcd
->self
.bus_name
);
140 /*-------------------------------------------------------------------------*/
142 static const struct hc_driver adm5120_hc_driver
= {
143 .description
= hcd_name
,
144 .product_desc
= "ADM5120 built-in USB 1.1 Host Controller",
145 .hcd_priv_size
= sizeof(struct admhcd
),
148 * generic hardware linkage
151 .flags
= HCD_USB11
| HCD_MEMORY
,
154 * basic lifecycle operations
156 .start
= admhc_adm5120_start
,
158 .shutdown
= admhc_shutdown
,
161 * managing i/o requests and associated device resources
163 .urb_enqueue
= admhc_urb_enqueue
,
164 .urb_dequeue
= admhc_urb_dequeue
,
165 .endpoint_disable
= admhc_endpoint_disable
,
170 .get_frame_number
= admhc_get_frame_number
,
175 .hub_status_data
= admhc_hub_status_data
,
176 .hub_control
= admhc_hub_control
,
177 .hub_irq_enable
= admhc_hub_irq_enable
,
179 .bus_suspend
= admhc_bus_suspend
,
180 .bus_resume
= admhc_bus_resume
,
182 .start_port_reset
= admhc_start_port_reset
,
185 /*-------------------------------------------------------------------------*/
187 static int usb_hcd_adm5120_probe(struct platform_device
*pdev
)
191 ret
= admhc_adm5120_probe(&adm5120_hc_driver
, pdev
);
196 static int usb_hcd_adm5120_remove(struct platform_device
*pdev
)
198 struct usb_hcd
*hcd
= platform_get_drvdata(pdev
);
200 admhc_adm5120_remove(hcd
, pdev
);
207 static int usb_hcd_adm5120_suspend(struct platform_device
*dev
)
209 struct usb_hcd
*hcd
= platform_get_drvdata(dev
);
214 static int usb_hcd_adm5120_resume(struct platform_device
*dev
)
216 struct usb_hcd
*hcd
= platform_get_drvdata(dev
);
221 #define usb_hcd_adm5120_suspend NULL
222 #define usb_hcd_adm5120_resume NULL
223 #endif /* CONFIG_PM */
225 static struct platform_driver usb_hcd_adm5120_driver
= {
226 .probe
= usb_hcd_adm5120_probe
,
227 .remove
= usb_hcd_adm5120_remove
,
228 .shutdown
= usb_hcd_platform_shutdown
,
229 .suspend
= usb_hcd_adm5120_suspend
,
230 .resume
= usb_hcd_adm5120_resume
,
232 .name
= "adm5120-hcd",
233 .owner
= THIS_MODULE
,