[PATCH 3/9] ehci: if caps ressource is not provided discover it via cr_capbase

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Mon Jan 21 15:09:50 EST 2013


Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/usb/host/ehci-hcd.c |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 35b4f71..9315fe3 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -843,9 +843,14 @@ int ehci_register(struct device_d *dev, struct ehci_data *data)
 	dev->priv = ehci;
 	ehci->flags = data->flags;
 	ehci->hccr = data->hccr;
-	ehci->hcor = data->hcor;
 	ehci->dev = dev;
 
+	if (data->hcor)
+		ehci->hcor = data->hcor;
+	else
+		ehci->hcor = (void __iomem *)ehci->hccr +
+			HC_LENGTH(ehci_readl(&ehci->hccr->cr_capbase));
+
 	ehci->qh_list = dma_alloc_coherent(sizeof(struct QH) * NUM_TD);
 	ehci->td = dma_alloc_coherent(sizeof(struct qTD) * NUM_TD);
 
@@ -879,13 +884,16 @@ static int ehci_probe(struct device_d *dev)
 	else
 		data.flags = EHCI_HAS_TT;
 
-	if (dev->num_resources < 2) {
-		printf("echi: need 2 resources base and data");
+	if (dev->num_resources < 1) {
+		printf("echi: need 1 resources base and data");
 		return -ENODEV;
 	}
 
 	data.hccr = dev_request_mem_region(dev, 0);
-	data.hcor = dev_request_mem_region(dev, 1);
+	if (dev->num_resources > 1)
+		data.hcor = dev_request_mem_region(dev, 1);
+	else
+		data.hcor = NULL;
 
 	return ehci_register(dev, &data);
 }
-- 
1.7.10.4




More information about the barebox mailing list