9
0
Fork 0

USB ehci: Allow to register independently from device

The EHCI core often is part of a otg core. Allow it to be registered
separately from another driver.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2012-11-27 23:34:25 +01:00
parent 0ccb9aebcd
commit 15fd89d0a4
2 changed files with 43 additions and 20 deletions

View File

@ -807,32 +807,18 @@ submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
return -1;
}
static int ehci_probe(struct device_d *dev)
int ehci_register(struct device_d *dev, struct ehci_data *data)
{
struct usb_host *host;
struct ehci_priv *ehci;
uint32_t reg;
struct ehci_platform_data *pdata = dev->platform_data;
ehci = xzalloc(sizeof(struct ehci_priv));
host = &ehci->host;
dev->priv = ehci;
/* default to EHCI_HAS_TT to not change behaviour of boards
* without platform_data
*/
if (pdata)
ehci->flags = pdata->flags;
else
ehci->flags = EHCI_HAS_TT;
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);
ehci->flags = data->flags;
ehci->hccr = data->hccr;
ehci->hcor = data->hcor;
ehci->qh_list = dma_alloc_coherent(sizeof(struct QH) * NUM_TD);
ehci->td = dma_alloc_coherent(sizeof(struct qTD) * NUM_TD);
@ -854,6 +840,30 @@ static int ehci_probe(struct device_d *dev)
return 0;
}
static int ehci_probe(struct device_d *dev)
{
struct ehci_data data;
struct ehci_platform_data *pdata = dev->platform_data;
/* default to EHCI_HAS_TT to not change behaviour of boards
* without platform_data
*/
if (pdata)
data.flags = pdata->flags;
else
data.flags = EHCI_HAS_TT;
if (dev->num_resources < 2) {
printf("echi: need 2 resources base and data");
return -ENODEV;
}
data.hccr = dev_request_mem_region(dev, 0);
data.hcor = dev_request_mem_region(dev, 1);
return ehci_register(dev, &data);
}
static void ehci_remove(struct device_d *dev)
{
struct ehci_priv *ehci = dev->priv;

View File

@ -5,8 +5,21 @@
struct ehci_platform_data {
unsigned long flags;
unsigned long hccr_offset;
unsigned long hcor_offset;
};
struct ehci_data {
void __iomem *hccr;
void __iomem *hcor;
unsigned long flags;
};
#ifdef CONFIG_USB_EHCI
int ehci_register(struct device_d *dev, struct ehci_data *data);
#else
static inline int ehci_register(struct device_d *dev, struct ehci_data *data)
{
return -ENOSYS;
}
#endif
#endif /* __USB_EHCI_H */