diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2011-07-23 08:08:15 +0800 |
---|---|---|
committer | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2011-07-29 14:05:22 +0800 |
commit | ee80cbcd61fdad8b6b75be23b8417dc1dc188d59 (patch) | |
tree | 358f1ac445640d172eb2ecdbec006d26b1f1a7fc /drivers | |
parent | 06c36cf09e08cfd054c2d1e61be8492c4e5dc929 (diff) | |
download | barebox-ee80cbcd61fdad8b6b75be23b8417dc1dc188d59.tar.gz barebox-ee80cbcd61fdad8b6b75be23b8417dc1dc188d59.tar.xz |
resource: introduce add_usb_ehci_device to register echi device
pass the hccr and hcor register base via resource
instroduce add_generic_usb_echi_device with hccr = base + 0x100 and
hcor = base + 0x140
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/resource.c | 21 | ||||
-rw-r--r-- | drivers/usb/host/ehci-hcd.c | 22 |
2 files changed, 33 insertions, 10 deletions
diff --git a/drivers/base/resource.c b/drivers/base/resource.c index 98fc68a24e..5fc705f2ab 100644 --- a/drivers/base/resource.c +++ b/drivers/base/resource.c @@ -97,3 +97,24 @@ struct device_d *add_dm9000_device(int id, resource_size_t base, } EXPORT_SYMBOL(add_dm9000_device); #endif + +#ifdef CONFIG_USB_EHCI +struct device_d *add_usb_ehci_device(int id, resource_size_t hccr, + resource_size_t hcor, void *pdata) +{ + struct device_d *dev; + + dev = alloc_device("ehci", id, pdata); + dev->resource = xzalloc(sizeof(struct resource) * 2); + dev->num_resources = 2; + dev->resource[0].start = hccr; + dev->resource[0].flags = IORESOURCE_MEM; + dev->resource[1].start = hcor; + dev->resource[1].flags = IORESOURCE_MEM; + + register_device(dev); + + return dev; +} +EXPORT_SYMBOL(add_usb_ehci_device); +#endif diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 844dc1db2a..60fc1819eb 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -900,20 +900,22 @@ static int ehci_probe(struct device_d *dev) host = &ehci->host; dev->priv = ehci; - if (pdata) { + /* default to EHCI_HAS_TT to not change behaviour of boards + * without platform_data + */ + if (pdata) ehci->flags = pdata->flags; - ehci->hccr = (void *)(dev->map_base + pdata->hccr_offset); - ehci->hcor = (void *)(dev->map_base + pdata->hcor_offset); - } - else { - /* default to EHCI_HAS_TT to not change behaviour of boards - * with platform_data - */ + else ehci->flags = EHCI_HAS_TT; - ehci->hccr = (void *)(dev->map_base + 0x100); - ehci->hcor = (void *)(dev->map_base + 0x140); + + if (dev->num_resources < 2) { + printf("echi: need 2 resources base and data"); + return -ENODEV; } + ehci->hccr = dev_request_mem_region(dev, 0); + ehci->hcor = dev_request_mem_region(dev, 1); + host->init = ehci_init; host->submit_int_msg = submit_int_msg; host->submit_control_msg = submit_control_msg; |