diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 6b1d52b94780..5b0db641326c 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -80,6 +80,13 @@ u32 odroid_model(void) { return __odroid_model; } + +static bool __odroid_amlogic_usb3 = true; + +bool odroid_amlogic_usb3(void) +{ + return __odroid_amlogic_usb3; +} #endif /* @@ -221,9 +228,11 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys) if (!strcmp(machine_name, "Hardkernel ODROID-N2")) { system_rev = 0x0400; __odroid_model = BOARD_ODROIDN2; + __odroid_amlogic_usb3 = true; } else if (!strcmp(machine_name, "Hardkernel ODROID-C4")) { system_rev = 0x0500; __odroid_model = BOARD_ODROIDC4; + __odroid_amlogic_usb3 = false; } #endif } diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index ce4689e5020f..746f624254b0 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -1317,13 +1317,15 @@ int usb_hcd_check_unlink_urb(struct usb_hcd *hcd, struct urb *urb, } #ifdef CONFIG_AMLOGIC_USB - if (!(HCD_DWC_OTG(hcd))) { - if (tmp != &urb->urb_list) - return -EIDRM; - } -#else + if (HCD_DWC_OTG(hcd)) + goto err_usb_hcd_check_unlink_urb; +#endif + if (tmp != &urb->urb_list) return -EIDRM; + +#ifdef CONFIG_AMLOGIC_USB +err_usb_hcd_check_unlink_urb: #endif /* Any status except -EINPROGRESS means something already started to diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 508c9ef22898..7f78fc35944d 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -2175,7 +2175,7 @@ free_interfaces: usb_enable_ltm(dev); #ifdef CONFIG_AMLOGIC_USB - if (usb_host_test_vid > 0) { + if (odroid_amlogic_usb3() && (usb_host_test_vid > 0)) { if (dev->descriptor.idVendor == USB_HSET_TEST_VID) { usb_host_test_vid = dev->descriptor.idVendor; usb_host_test_pid = dev->descriptor.idProduct; diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index e2f0d2881e14..f1b8cb10d3d6 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -9,6 +9,10 @@ #include "u_f.h" #include "u_os_desc.h" +#ifdef CONFIG_AMLOGIC_USB +#include +#endif + #ifdef CONFIG_USB_CONFIGFS_UEVENT #include #include @@ -1298,7 +1302,8 @@ static int configfs_composite_bind(struct usb_gadget *gadget, cdev->gadget = gadget; set_gadget_data(gadget, cdev); #ifdef CONFIG_AMLOGIC_USB - wakeup_source_init(&Gadget_Lock.wakesrc, "gadget-connect"); + if (odroid_amlogic_usb3()) + wakeup_source_init(&Gadget_Lock.wakesrc, "gadget-connect"); #endif ret = composite_dev_prepare(composite, cdev); if (ret) @@ -1465,7 +1470,8 @@ static void android_work(struct work_struct *data) pr_info("%s: sent uevent %s\n", __func__, configured[0]); uevent_sent = true; #ifdef CONFIG_AMLOGIC_USB - gadget_hold(&Gadget_Lock); + if (odroid_amlogic_usb3()) + gadget_hold(&Gadget_Lock); #endif } @@ -1475,7 +1481,8 @@ static void android_work(struct work_struct *data) pr_info("%s: sent uevent %s\n", __func__, disconnected[0]); uevent_sent = true; #ifdef CONFIG_AMLOGIC_USB - gadget_drop(&Gadget_Lock); + if (odroid_amlogic_usb3()) + gadget_drop(&Gadget_Lock); #endif } @@ -1502,7 +1509,8 @@ static void configfs_composite_unbind(struct usb_gadget *gadget) composite_dev_cleanup(cdev); usb_ep_autoconfig_reset(cdev->gadget); #ifdef CONFIG_AMLOGIC_USB - wakeup_source_trash(&Gadget_Lock.wakesrc); + if (odroid_amlogic_usb3()) + wakeup_source_trash(&Gadget_Lock.wakesrc); #endif cdev->gadget = NULL; set_gadget_data(gadget, NULL); diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index ef0bd14ff9d7..30c99b361a55 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -281,14 +281,21 @@ static void xhci_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci, struct usb_hub_descriptor *desc) { #ifdef CONFIG_AMLOGIC_USB - if (xhci->quirks & XHCI_AML_SUPER_SPEED_SUPPORT) { + if (odroid_amlogic_usb3()) { + if (xhci->quirks & XHCI_AML_SUPER_SPEED_SUPPORT) { + if (hcd->speed >= HCD_USB3) + xhci_usb3_hub_descriptor(hcd, xhci, desc); + else + xhci_usb2_hub_descriptor(hcd, xhci, desc); + } else { + if (hcd->speed < HCD_USB3) + xhci_usb2_hub_descriptor(hcd, xhci, desc); + } + } else { if (hcd->speed >= HCD_USB3) xhci_usb3_hub_descriptor(hcd, xhci, desc); else xhci_usb2_hub_descriptor(hcd, xhci, desc); - } else { - if (hcd->speed < HCD_USB3) - xhci_usb2_hub_descriptor(hcd, xhci, desc); } #else if (hcd->speed >= HCD_USB3) @@ -552,12 +559,14 @@ static void xhci_clear_port_change_bit(struct xhci_hcd *xhci, u16 wValue, xhci_dbg(xhci, "clear port %s change, actual port %d status = 0x%x\n", port_change_bit, wIndex, port_status); #ifdef CONFIG_AMLOGIC_USB - if (DEV_HIGHSPEED(port_status) && - (wValue == USB_PORT_FEAT_C_RESET)) - set_usb_phy_host_tuning(wIndex, 0); - if (DEV_LOWSPEED(port_status) && - (wValue == USB_PORT_FEAT_C_RESET)) - set_usb_phy_host_low_reset(wIndex); + if (odroid_amlogic_usb3()) { + if (DEV_HIGHSPEED(port_status) && + (wValue == USB_PORT_FEAT_C_RESET)) + set_usb_phy_host_tuning(wIndex, 0); + if (DEV_LOWSPEED(port_status) && + (wValue == USB_PORT_FEAT_C_RESET)) + set_usb_phy_host_low_reset(wIndex); + } #endif } @@ -1234,8 +1243,10 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, if (wValue == USB_PORT_FEAT_REMOTE_WAKE_MASK) wake_mask = wIndex & 0xff00; #ifdef CONFIG_AMLOGIC_USB - if (wValue == USB_PORT_FEAT_TEST) - test_mode = (wIndex & 0xff00) >> 8; + if (odroid_amlogic_usb3()) { + if (wValue == USB_PORT_FEAT_TEST) + test_mode = (wIndex & 0xff00) >> 8; + } #endif /* The MSB of wIndex is the U1/U2 timeout */ timeout = (wIndex & 0xff00) >> 8; diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 8ae87c2a7b2c..472d0a4d6391 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -2218,10 +2218,11 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports, if ((xhci->hci_version >= 0x100) && (major_revision != 0x03)) { xhci_dbg_trace(xhci, trace_xhci_dbg_init, "xHCI 1.0: support USB2 software lpm"); -#ifdef CONFIG_AMLOGIC_USB - xhci->sw_lpm_support = 0; -#else + xhci->sw_lpm_support = 1; +#ifdef CONFIG_AMLOGIC_USB + if (odroid_amlogic_usb3()) + xhci->sw_lpm_support = 0; #endif if (temp & XHCI_HLC) { xhci_dbg_trace(xhci, trace_xhci_dbg_init, @@ -2254,17 +2255,17 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports, continue; } xhci->port_array[i] = major_revision; - if (major_revision == 0x03) -#ifdef CONFIG_AMLOGIC_USB - if (xhci->quirks & XHCI_AML_SUPER_SPEED_SUPPORT) - xhci->num_usb3_ports++; - else - xhci->num_usb3_ports = 0; -#else + if (major_revision == 0x03) { xhci->num_usb3_ports++; +#ifdef CONFIG_AMLOGIC_USB + if (odroid_amlogic_usb3()) { + if (!(xhci->quirks & XHCI_AML_SUPER_SPEED_SUPPORT)) + xhci->num_usb3_ports = 0; + } #endif - else + } else { xhci->num_usb2_ports++; + } } /* FIXME: Should we disable ports not in the Extended Capabilities? */ } diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 64d38cc407ab..32307470c9d4 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1710,8 +1710,10 @@ cleanup: set_bit(HCD_FLAG_POLL_RH, &hcd->flags); spin_unlock(&xhci->lock); #ifdef CONFIG_AMLOGIC_USB - if (!(temp & PORT_CONNECT) || !(temp & PORT_PE)) - set_usb_phy_host_tuning(faked_port_index, 1); + if (odroid_amlogic_usb3()) { + if (!(temp & PORT_CONNECT) || !(temp & PORT_PE)) + set_usb_phy_host_tuning(faked_port_index, 1); + } #endif /* Pass this up to the core */ usb_hcd_poll_rh_status(hcd); diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 47695d41d881..7c7a79851489 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1411,9 +1411,11 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags) if (xhci->xhc_state & XHCI_STATE_DYING) goto dying; -#ifdef CONFIG_AMLOGIC_USB +#ifdef CONFIG_AMLOGIC_USB // FIXME: setup = (struct usb_ctrlrequest *) urb->setup_packet; - if ((setup->bRequestType == 0x80) && (setup->bRequest == 0x06) + if (odroid_amlogic_usb3() + && (setup->bRequestType == 0x80) + && (setup->bRequest == 0x06) && (setup->wValue == 0x0100) && (setup->wIndex != 0x0)) { if ((((setup->wIndex)>>8) & 0xff) == 7) { @@ -3646,7 +3648,8 @@ void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev) } #ifdef CONFIG_AMLOGIC_USB - virt_dev->udev = NULL; + if (odroid_amlogic_usb3()) + virt_dev->udev = NULL; #endif spin_lock_irqsave(&xhci->lock, flags); @@ -4867,9 +4870,11 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) hcd->self.sg_tablesize = ~0; #if defined(CONFIG_ARCH_MESON64_ODROID_COMMON) - if (kpara_sg_tablesize > 0) - hcd->self.sg_tablesize = kpara_sg_tablesize; - pr_info("usb: xhci: determined sg_tablesize: %u", hcd->self.sg_tablesize); + if (odroid_amlogic_usb3()) { + if (kpara_sg_tablesize > 0) + hcd->self.sg_tablesize = kpara_sg_tablesize; + pr_info("usb: xhci: determined sg_tablesize: %u", hcd->self.sg_tablesize); + } #endif /* support to build packet from discontinuous buffers */ diff --git a/include/linux/platform_data/board_odroid.h b/include/linux/platform_data/board_odroid.h index c30d3e7ef875..ca2e8a99b19f 100644 --- a/include/linux/platform_data/board_odroid.h +++ b/include/linux/platform_data/board_odroid.h @@ -6,10 +6,11 @@ #define BOARD_ODROIDN2 0x09221000 #define BOARD_ODROIDC4 0x09051000 -extern bool odroid_amlogic_usb(void); extern u32 odroid_model(void); #define board_is_odroidn2() (odroid_model() == BOARD_ODROIDN2) #define board_is_odroidc4() (odroid_model() == BOARD_ODROIDC4) +extern bool odroid_amlogic_usb3(void); + #endif diff --git a/include/linux/usb.h b/include/linux/usb.h index 34098da971be..fa1fbd676018 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -4,6 +4,10 @@ #include #include +#if defined(CONFIG_ARCH_MESON64_ODROID_COMMON) +#include +#endif + #define USB_MAJOR 180 #define USB_DEVICE_MAJOR 189