From: "Chen, Alvin" <alvin.chen@intel.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
Jingoo Han <jg1.han@samsung.com>,
David Laight <David.Laight@ACULAB.COM>,
Boon Leong Ong <boon.leong.ong@intel.com>
Subject: [PATCH v2] USB: ehci-pci: USB host controller support for Intel Quark X1000
Date: Fri, 27 Jun 2014 04:24:36 -0700 [thread overview]
Message-ID: <1403868276-12558-2-git-send-email-alvin.chen@intel.com> (raw)
In-Reply-To: <1403868276-12558-1-git-send-email-alvin.chen@intel.com>
From: Bryan O'Donoghue <bryan.odonoghue@intel.com>
The EHCI packet buffer in/out threshold is programmable for Intel Quark X1000 USB host
controller, and the default value is 0x20 dwords. The in/out threshold can be programmed
to 0x80 dwords, but only when isochronous/interrupt transactions are not initiated by
the USB host controller. This patch is to reconfigure the packet buffer in/out threshold
as maximal as possible, and it is 0x7F dwords since the USB host controller initiates
isochronous/interrupt transactions.
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@intel.com>
Signed-off-by: Alvin (Weike) Chen <alvin.chen@intel.com>
---
changelog v2:
*Change the function name from 'usb_is_intel_qrk' to 'usb_is_intel_quark_x1000'.
*Move the functions 'usb_is_intel_quark_x1000' and 'usb_set_qrk_bulk_thresh'
from 'pci-quirks.c' to 'ehci-pci.c'.
*Remove unnecessary kernel message in the function of 'usb_set_qrk_bulk_thresh'.
*Remove 'unlikely' in the functions of 'ehci_pci_reinit'.
*Add white space after 'if'.
*Update the descriptions to make it more clearly.
*Add Micros to avoid magic number.
drivers/usb/host/ehci-pci.c | 45 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 3e86bf4..ca29f34 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -35,6 +35,47 @@ static const char hcd_name[] = "ehci-pci";
#define PCI_DEVICE_ID_INTEL_CE4100_USB 0x2e70
/*-------------------------------------------------------------------------*/
+#define PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC 0x0939
+static inline bool usb_is_intel_quark_x1000(struct pci_dev *pdev)
+{
+ return pdev->vendor == PCI_VENDOR_ID_INTEL &&
+ pdev->device == PCI_DEVICE_ID_INTEL_QUARK_X1000_SOC;
+
+}
+
+/* Register offset of in/out threshold */
+#define EHCI_INSNREG01 0x84
+/* The maximal threshold is 0x80 Dword */
+#define EHCI_MAX_THRESHOLD 0X80
+/* Lower word is 'in' threshold, and higher word is 'out' threshold*/
+#define EHCI_INSNREG01_THRESH \
+ ((EHCI_MAX_THRESHOLD - 1)<<16 | (EHCI_MAX_THRESHOLD - 1))
+static void usb_set_qrk_bulk_thresh(struct pci_dev *pdev)
+{
+ void __iomem *base, *op_reg_base;
+ u8 cap_length;
+ u32 val;
+ u16 cmd;
+
+ if (!pci_resource_start(pdev, 0))
+ return;
+
+ if (pci_read_config_word(pdev, PCI_COMMAND, &cmd)
+ || !(cmd & PCI_COMMAND_MEMORY))
+ return;
+
+ base = pci_ioremap_bar(pdev, 0);
+ if (base == NULL)
+ return;
+
+ cap_length = readb(base);
+ op_reg_base = base + cap_length;
+
+ val = EHCI_INSNREG01_THRESH;
+ writel(val, op_reg_base + EHCI_INSNREG01);
+
+ iounmap(base);
+}
/* called after powerup, by probe or system-pm "wakeup" */
static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev)
@@ -50,6 +91,10 @@ static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev)
if (!retval)
ehci_dbg(ehci, "MWI active\n");
+ /* Reset the threshold limit */
+ if (usb_is_intel_quark_x1000(pdev))
+ usb_set_qrk_bulk_thresh(pdev);
+
return 0;
}
--
1.7.9.5
next prev parent reply other threads:[~2014-06-27 3:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-27 11:24 [PATCH v2] USB: ehci-pci: Add support for Intel Quark X1000 USB host controller Chen, Alvin
2014-06-27 11:24 ` Chen, Alvin [this message]
2014-06-27 4:33 ` [PATCH v2] USB: ehci-pci: USB host controller support for Intel Quark X1000 Jingoo Han
2014-06-27 4:36 ` Jingoo Han
2014-06-27 7:15 ` Chen, Alvin
2014-06-27 8:08 ` David Laight
2014-06-27 8:20 ` Chen, Alvin
2014-06-27 14:31 ` Alan Stern
2014-06-30 8:38 ` Chen, Alvin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1403868276-12558-2-git-send-email-alvin.chen@intel.com \
--to=alvin.chen@intel.com \
--cc=David.Laight@ACULAB.COM \
--cc=boon.leong.ong@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jg1.han@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=sergei.shtylyov@cogentembedded.com \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox