On 2013年01月25日 08:52, Sarah Sharp wrote: > Please combine this patch with patch three, so that I can clearly see > what is being replaced in xhci-mem.c:xhci_find_real_port_number. > Ok, I will refresh it soon. > Sarah Sharp > > On Sat, Jan 19, 2013 at 12:43:32AM +0800, Lan Tianyu wrote: >> xhci driver divides the root hub into two logical hubs which work >> respectively for usb 2.0 and usb 3.0 devices. They are independent >> devices in the usb core. But in the ACPI table, it's one device node >> and all usb2.0 and usb3.0 ports are under it. Binding usb port with >> its acpi node needs the raw port number which is reflected in the xhci >> extended capabilities table. This patch is to add find_raw_port_number >> callback to struct hc_driver() and fill it with xhci_find_raw_port_number(). >> >> Signed-off-by: Lan Tianyu <tianyu.lan@xxxxxxxxx> >> --- >> Change since v1: >> Don't export usb_hcd_find_raw_port_number() symbol since there is no >> its user outside of usb core. >> >> This patchset is rebased on the usb-next tree commit 74ff31b81d9 >> "usb: misc: usb3503_probe() can be static" >> --- >> drivers/usb/core/hcd.c | 8 ++++++++ >> drivers/usb/host/xhci-pci.c | 1 + >> drivers/usb/host/xhci.c | 22 ++++++++++++++++++++++ >> drivers/usb/host/xhci.h | 1 + >> include/linux/usb/hcd.h | 2 ++ >> 5 files changed, 34 insertions(+) >> >> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c >> index 5f6da8b..0277bd2 100644 >> --- a/drivers/usb/core/hcd.c >> +++ b/drivers/usb/core/hcd.c >> @@ -2364,6 +2364,14 @@ int usb_hcd_is_primary_hcd(struct usb_hcd *hcd) >> } >> EXPORT_SYMBOL_GPL(usb_hcd_is_primary_hcd); >> >> +int usb_hcd_find_raw_port_number(struct usb_hcd *hcd, int port1) >> +{ >> + if (!hcd->driver->find_raw_port_number) >> + return port1; >> + >> + return hcd->driver->find_raw_port_number(hcd, port1); >> +} >> + >> static int usb_hcd_request_irqs(struct usb_hcd *hcd, >> unsigned int irqnum, unsigned long irqflags) >> { >> diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c >> index af259e0..1a30c38 100644 >> --- a/drivers/usb/host/xhci-pci.c >> +++ b/drivers/usb/host/xhci-pci.c >> @@ -313,6 +313,7 @@ static const struct hc_driver xhci_pci_hc_driver = { >> .set_usb2_hw_lpm = xhci_set_usb2_hardware_lpm, >> .enable_usb3_lpm_timeout = xhci_enable_usb3_lpm_timeout, >> .disable_usb3_lpm_timeout = xhci_disable_usb3_lpm_timeout, >> + .find_raw_port_number = xhci_find_raw_port_number, >> }; >> >> /*-------------------------------------------------------------------------*/ >> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c >> index f1f01a8..0780d8f 100644 >> --- a/drivers/usb/host/xhci.c >> +++ b/drivers/usb/host/xhci.c >> @@ -3778,6 +3778,28 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev) >> return 0; >> } >> >> +/* >> + * Transfer the port index into real index in the HW port status >> + * registers. Caculate offset between the port's PORTSC register >> + * and port status base. Divide the number of per port register >> + * to get the real index. The raw port number bases 1. >> + */ >> +int xhci_find_raw_port_number(struct usb_hcd *hcd, int port1) >> +{ >> + struct xhci_hcd *xhci = hcd_to_xhci(hcd); >> + __le32 __iomem *base_addr = &xhci->op_regs->port_status_base; >> + __le32 __iomem *addr; >> + int raw_port; >> + >> + if (hcd->speed != HCD_USB3) >> + addr = xhci->usb2_ports[port1 - 1]; >> + else >> + addr = xhci->usb3_ports[port1 - 1]; >> + >> + raw_port = (addr - base_addr)/NUM_PORT_REGS + 1; >> + return raw_port; >> +} >> + >> #ifdef CONFIG_USB_SUSPEND >> >> /* BESL to HIRD Encoding array for USB2 LPM */ >> diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h >> index f791bd0..55345d9 100644 >> --- a/drivers/usb/host/xhci.h >> +++ b/drivers/usb/host/xhci.h >> @@ -1829,6 +1829,7 @@ void xhci_test_and_clear_bit(struct xhci_hcd *xhci, __le32 __iomem **port_array, >> int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, >> char *buf, u16 wLength); >> int xhci_hub_status_data(struct usb_hcd *hcd, char *buf); >> +int xhci_find_raw_port_number(struct usb_hcd *hcd, int port1); >> >> #ifdef CONFIG_PM >> int xhci_bus_suspend(struct usb_hcd *hcd); >> diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h >> index 608050b..61b88b5 100644 >> --- a/include/linux/usb/hcd.h >> +++ b/include/linux/usb/hcd.h >> @@ -357,6 +357,7 @@ struct hc_driver { >> */ >> int (*disable_usb3_lpm_timeout)(struct usb_hcd *, >> struct usb_device *, enum usb3_link_state state); >> + int (*find_raw_port_number)(struct usb_hcd *, int); >> }; >> >> extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb); >> @@ -396,6 +397,7 @@ extern int usb_hcd_is_primary_hcd(struct usb_hcd *hcd); >> extern int usb_add_hcd(struct usb_hcd *hcd, >> unsigned int irqnum, unsigned long irqflags); >> extern void usb_remove_hcd(struct usb_hcd *hcd); >> +extern int usb_hcd_find_raw_port_number(struct usb_hcd *hcd, int port1); >> >> struct platform_device; >> extern void usb_hcd_platform_shutdown(struct platform_device *dev); >> -- >> 1.7.10.4 >> -- Best regards Tianyu Lan -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html