From patchwork Mon Jul 21 15:50:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 33988 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BF91C20672 for ; Mon, 21 Jul 2014 15:50:55 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id kx10sf56596773pab.4 for ; Mon, 21 Jul 2014 08:50:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:date :message-id:subject:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=uMyQTu+29PyrO35bdwEh4uBX26ac23pNWyvReeJ41qI=; b=CfLX/OgUagj29XG/hgYDu5a7kDAmYpM0U8/MnlKlBqwxwrhJPhQuBOw+WM0gcWHQIK PpvGg0rYw0jMwY6vLcguHaxNa6gmMsQaDEcIyprQQ5xW1+juEhfIbvF7kZGN/s7ISwVZ LAHL3zN+OKjZLbw8KYiLEdc2zVu9K42LbSQ9Ci2FXtdypbSrYzu34WdcIWbSXDP8b1Uv wekuOKIeFf6iYQf6fDjU/GXLv47aYrCCKIpXD+5Vdlwak5zFetuhLblFglQFVSZcgNpn Pgrt7j7zR+ZAifSNJ3BrzboTqFH3LsVbRis+SE8fEE7GE0fIFOEom0t3giqMPi+MckwK HW3A== X-Gm-Message-State: ALoCoQlgtq5rmndI5NPfHx2Iz81KqB/bm5NpkuobVAYoqWbhhA5Gq3nywJCijIaUArmzNWO6NaUd X-Received: by 10.66.160.34 with SMTP id xh2mr12405291pab.6.1405957854812; Mon, 21 Jul 2014 08:50:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.93.166 with SMTP id d35ls2000482qge.3.gmail; Mon, 21 Jul 2014 08:50:54 -0700 (PDT) X-Received: by 10.52.35.81 with SMTP id f17mr4687408vdj.13.1405957854508; Mon, 21 Jul 2014 08:50:54 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id r6si11678143vei.7.2014.07.21.08.50.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Jul 2014 08:50:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id hu12so12546203vcb.0 for ; Mon, 21 Jul 2014 08:50:49 -0700 (PDT) X-Received: by 10.52.244.81 with SMTP id xe17mr25814752vdc.24.1405957848992; Mon, 21 Jul 2014 08:50:48 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp123480vcb; Mon, 21 Jul 2014 08:50:48 -0700 (PDT) X-Received: by 10.66.65.169 with SMTP id y9mr3168826pas.145.1405957848108; Mon, 21 Jul 2014 08:50:48 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id au5si14629556pbc.93.2014.07.21.08.50.47; Mon, 21 Jul 2014 08:50:47 -0700 (PDT) Received-SPF: none (google.com: linux-serial-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932501AbaGUPur (ORCPT + 1 other); Mon, 21 Jul 2014 11:50:47 -0400 Received: from mezzanine.sirena.org.uk ([106.187.55.193]:48034 "EHLO mezzanine.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932322AbaGUPuq (ORCPT ); Mon, 21 Jul 2014 11:50:46 -0400 Received: from cpc11-sgyl31-2-0-cust672.sgyl.cable.virginm.net ([94.175.94.161] helo=debutante) by mezzanine.sirena.org.uk with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1X9FrJ-00024v-KA; Mon, 21 Jul 2014 15:50:42 +0000 Received: from broonie by debutante with local (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1X9FrG-0001gf-NU; Mon, 21 Jul 2014 16:50:34 +0100 From: Mark Brown To: Greg Kroah-Hartman , Jiri Slaby Cc: linux-serial@vger.kernel.org, linaro-kernel@lists.linaro.org, Victor Kamensky , Mark Brown Date: Mon, 21 Jul 2014 16:50:32 +0100 Message-Id: <1405957832-6444-1-git-send-email-broonie@kernel.org> X-Mailer: git-send-email 2.0.1 X-SA-Exim-Connect-IP: 94.175.94.161 X-SA-Exim-Mail-From: broonie@sirena.org.uk X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on mezzanine.sirena.org.uk X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.3.2 Subject: [PATCH] exynos: serial clear and set big endian fix X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on mezzanine.sirena.org.uk) Sender: linux-serial-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-serial@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: broonie@kernel.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Victor Kamensky The Samsung serial driver uses __set_bit and __clear_bit functions directly with h/w registers but these functions do not account for any difference between the endianess of the CPU and the hardware so if running in big endian mode we need to byte swap. Handle this by wrapping these functions with open coded versions when configured for big endian. [Rewrote commit message -- broonie] Signed-off-by: Victor Kamensky Signed-off-by: Mark Brown --- drivers/tty/serial/samsung.c | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index 8df6c173d6ed..7191adefe40e 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c @@ -78,6 +78,41 @@ static void dbg(const char *fmt, ...) #define S3C24XX_SERIAL_MAJOR 204 #define S3C24XX_SERIAL_MINOR 64 +#ifndef CONFIG_CPU_BIG_ENDIAN /* little endian */ +static inline void __hw_set_bit(int nr, volatile unsigned long *addr) +{ + __set_bit(nr, addr); +} + +static inline void __hw_clear_bit(int nr, volatile unsigned long *addr) +{ + __clear_bit(nr, addr); +} +#else +static inline void __hw_set_bit(int nr, volatile unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); + unsigned long val = le32_to_cpu(*p); + + val |= mask; + + *p = cpu_to_le32(val); +} + +static inline void __hw_clear_bit(int nr, volatile unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); + + unsigned long val = le32_to_cpu(*p); + + val &= ~mask; + + *p = cpu_to_le32(val); +} +#endif + /* macros to change one thing to another */ #define tx_enabled(port) ((port)->unused[0]) @@ -157,7 +192,7 @@ static void s3c24xx_serial_stop_tx(struct uart_port *port) if (tx_enabled(port)) { if (s3c24xx_serial_has_interrupt_mask(port)) - __set_bit(S3C64XX_UINTM_TXD, + __hw_set_bit(S3C64XX_UINTM_TXD, portaddrl(port, S3C64XX_UINTM)); else disable_irq_nosync(ourport->tx_irq); @@ -176,7 +211,7 @@ static void s3c24xx_serial_start_tx(struct uart_port *port) s3c24xx_serial_rx_disable(port); if (s3c24xx_serial_has_interrupt_mask(port)) - __clear_bit(S3C64XX_UINTM_TXD, + __hw_clear_bit(S3C64XX_UINTM_TXD, portaddrl(port, S3C64XX_UINTM)); else enable_irq(ourport->tx_irq); @@ -191,7 +226,7 @@ static void s3c24xx_serial_stop_rx(struct uart_port *port) if (rx_enabled(port)) { dbg("s3c24xx_serial_stop_rx: port=%p\n", port); if (s3c24xx_serial_has_interrupt_mask(port)) - __set_bit(S3C64XX_UINTM_RXD, + __hw_set_bit(S3C64XX_UINTM_RXD, portaddrl(port, S3C64XX_UINTM)); else disable_irq_nosync(ourport->rx_irq); @@ -548,7 +583,7 @@ static int s3c64xx_serial_startup(struct uart_port *port) ourport->tx_claimed = 1; /* Enable Rx Interrupt */ - __clear_bit(S3C64XX_UINTM_RXD, portaddrl(port, S3C64XX_UINTM)); + __hw_clear_bit(S3C64XX_UINTM_RXD, portaddrl(port, S3C64XX_UINTM)); dbg("s3c64xx_serial_startup ok\n"); return ret; }