From patchwork Fri Nov 17 13:26:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Brodkin X-Patchwork-Id: 838986 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3ydf5y6Qkgz9ryQ for ; Sat, 18 Nov 2017 00:26:46 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 92F6FC21DDF; Fri, 17 Nov 2017 13:26:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 7CBDFC21C4C; Fri, 17 Nov 2017 13:26:42 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 161E3C21C4C; Fri, 17 Nov 2017 13:26:41 +0000 (UTC) Received: from smtprelay.synopsys.com (smtprelay2.synopsys.com [198.182.60.111]) by lists.denx.de (Postfix) with ESMTPS id 9147BC21C45 for ; Fri, 17 Nov 2017 13:26:40 +0000 (UTC) Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 48F0710C0E31; Fri, 17 Nov 2017 05:26:37 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 0F105D7C; Fri, 17 Nov 2017 05:26:37 -0800 (PST) Received: from abrodkin-7440l.internal.synopsys.com (unknown [10.225.15.245]) by mailhost.synopsys.com (Postfix) with ESMTP id 010ACD6F; Fri, 17 Nov 2017 05:26:34 -0800 (PST) From: Alexey Brodkin To: u-boot@lists.denx.de Date: Fri, 17 Nov 2017 16:26:30 +0300 Message-Id: <1510925190-13103-1-git-send-email-abrodkin@synopsys.com> X-Mailer: git-send-email 2.7.5 Cc: Vladimir Boroda , Marek Vasut , Alexey Brodkin Subject: [U-Boot] [PATCH] usb: ehci: Fix accessors for big-endian platforms and descriptors X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Commit 9000eddbae0d ("drivers/usb/ehci: Use platform-specific accessors") broke USB 2.0 on big-endian platforms because for them writel/readl() does automatic conversion of BE data to LE. Proper implementation requires to use "raw" variant of these accessors which read/write data without messing with endianess. While at it replace cpu_to_be32() to be32_to_cpu() in readl() to keep sane semantics. Signed-off-by: Alexey Brodkin Cc: Marek Vasut Reported-by: Vladimir Boroda --- drivers/usb/host/ehci.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 7c39becd247e..18692b732ea6 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -101,11 +101,11 @@ struct usb_linux_config_descriptor { } __attribute__ ((packed)); #if defined CONFIG_EHCI_DESC_BIG_ENDIAN -#define ehci_readl(x) cpu_to_be32(readl(x)) -#define ehci_writel(a, b) writel(cpu_to_be32(b), a) +#define ehci_readl(x) be32_to_cpu(__raw_readl(x)) +#define ehci_writel(a, b) __raw_writel(cpu_to_be32(b), a) #else -#define ehci_readl(x) cpu_to_le32(readl(x)) -#define ehci_writel(a, b) writel(cpu_to_le32(b), a) +#define ehci_readl(x) readl(x) +#define ehci_writel(a, b) writel(b, a) #endif #if defined CONFIG_EHCI_MMIO_BIG_ENDIAN