From patchwork Fri May 19 15:07:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Elwell X-Patchwork-Id: 9737423 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B19B8601A1 for ; Fri, 19 May 2017 15:17:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A870228898 for ; Fri, 19 May 2017 15:17:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99C59288F1; Fri, 19 May 2017 15:17:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EB6C328898 for ; Fri, 19 May 2017 15:17:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Date:Message-ID:Subject: From:To:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=2R7yPDUZUThHkjF0VrC12X+VvWjJq7P0w9ccsY5BQuM=; b=sYz918MgNnLPFf pBkwpUXXE1B4YjKuMR3Pqb2fY2uhUG+o4EnNSFsacTpClqGUJBpViBcb6SMTsG2RZiOGAHtYwV+lG lyXqNPmqV1SlmikXCWY0venQXitWviw0Ebdfi+4AXQbSg6u0IcgrypLh6TUQwM1wYBFmyTEymzW0D tMZKdLeA13Wwzv8LgzZQNgTs2pYwLsKXFlT3UwtihEKf9tTtCL2z1Jz4lpnw/pvWodVoOmByUp92d L1yM1SzSoKtzMmJr+6O4XHVowO8OpcFuKEqL4qP+ZjJRYGfVEx1hjguRZQOGjuBI3KwsA69E362wg csSqh/URjzD+imIHc3XQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dBjeU-0003Fe-3N; Fri, 19 May 2017 15:17:14 +0000 Received: from mx08-00252a01.pphosted.com ([91.207.212.211]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dBjVK-0005rk-Tw for linux-arm-kernel@lists.infradead.org; Fri, 19 May 2017 15:07:52 +0000 Received: from pps.filterd (m0102629.ppops.net [127.0.0.1]) by mx08-00252a01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4JF7GNt015131 for ; Fri, 19 May 2017 16:07:23 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.org; h=to : from : subject : message-id : date : mime-version : content-type : content-transfer-encoding; s=pp; bh=WBDj5uFnc1H1AE3cGBv3jKu4oDFnBgt1VoNvhpSOXug=; b=BhRItzdHoPW3noFwFfBrNVy3GYgoYId+7P1mYgaSDE1RacrqkWHTlPYvdqj3jP/WMBoV 5fxqJNFumd+t10+A01GL0JkTplQ+s9fWbtwAyCnvxuTLUeTjoMqtdhx8LzCvz2c0YUW+ FSZ68qB37qSsRhtjuUFAXP4c3kOVJxdU78X1h5NR9cuS4lhbePhtwnaGcimd49rk9T6/ f8IEk9RMFYnOX+4RffdQn7XMYH7HPDWR37S1QaIdI0ZgC8tirjOdDCL0y1pVaISyGaJ2 ndqBpPX7URSDqSdykovomEyHfGZdoQdoqkaO8H3UT9M8sYbFc6p8fcUkLyDcyFjg0pxx iQ== Received: from mail-wm0-f70.google.com (mail-wm0-f70.google.com [74.125.82.70]) by mx08-00252a01.pphosted.com with ESMTP id 2adpmek3pc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=OK) for ; Fri, 19 May 2017 16:07:22 +0100 Received: by mail-wm0-f70.google.com with SMTP id b84so15352972wmh.0 for ; Fri, 19 May 2017 08:07:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi-org.20150623.gappssmtp.com; s=20150623; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=WBDj5uFnc1H1AE3cGBv3jKu4oDFnBgt1VoNvhpSOXug=; b=SUmqcD7WrmTPZb6WQ/Wkyfj5EoZ49BHhCeKZ5MeGcICqsP8Heg1/uw2n3dKt83P9mZ wCNSZcbZ+5QksFgybQx1f3QLsLfGypGpMntBiEL95kFsYcketxIL6yFMJtVLz2Y9OsHn 3Kk18dFaJ29Yy2pv7dqEuBKLQSQ4ngK3LXZ+7ue5czVzAI/mD6He6lC7PGavZEqLnDxX 7RRf3FJlqFl0erTbgTGzGLX9szL1oV+u7BmnImz6sXp+8VMpvesUfuttiGRGmYMNj1+L uffbxK2s6zNV6Hb9u5m2ZFvJTUEyZ4+uyhWRpND6Rp/80JYS52yIPos9UZBzi1EQL1v8 KL0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=WBDj5uFnc1H1AE3cGBv3jKu4oDFnBgt1VoNvhpSOXug=; b=qDkp43mqRaQdvavBEC6FO39RnmVGd3CuxEUt0UNfFj+N7sDb6lQ8CCfYx+J2XXwRyM U1913dUWwZ/u1LxmWY54OlwvEaLlIr9/TlVKfATt/t8qNmeHXyuicdjQKwlG3IboeYmc +o3Ar/DZvvdwgFqI4GaDtMGtX4fBeQgk4zjRKZ8aylQ5f6JsIgAPIto0Zb6tIv3C9j5a 2npZlcVq7UaPWygC3FZWt/npH1B2yuWWM0OvgN5NfxsmYDgbTjC8lYDL/5Uspc/Umj66 CsXXYxj/71H3/r0/41ZIpOY6K9+re8DkyYV9WSou/1IHao5N8ie2UYTPXpA+AuRwX3fH 2Icw== X-Gm-Message-State: AODbwcAbVrxdHTnMu2UpUd+2LDtJfhK7nYzACeILAM0PmtLXPhaRnB/a YtoeekH7O8YWz14s24im2e8hY2SNTgtX+XkJbzQebppWiKT31+wtyz3M8uvw1QsExIT2enpjdm6 Lrd9qTR76zocO9JIv/Bnm9x+5EQ== X-Received: by 10.223.165.71 with SMTP id j7mr4028659wrb.35.1495206441309; Fri, 19 May 2017 08:07:21 -0700 (PDT) X-Received: by 10.223.165.71 with SMTP id j7mr4028642wrb.35.1495206441027; Fri, 19 May 2017 08:07:21 -0700 (PDT) Received: from ?IPv6:2a00:2381:fdf7:14:9999:63e5:7f18:e923? ([2a00:2381:fdf7:14:9999:63e5:7f18:e923]) by smtp.gmail.com with ESMTPSA id m17sm8084560wmi.6.2017.05.19.08.07.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 May 2017 08:07:20 -0700 (PDT) To: Greg Kroah-Hartman , Eric Anholt , Stefan Wahren , linux-serial@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org From: Phil Elwell Subject: [PATCH] serial: 8250: Add CAP_MINI, set for bcm2835aux Message-ID: <8d9c605a-bff7-607c-2c5b-4ec75e68ac2d@raspberrypi.org> Date: Fri, 19 May 2017 16:07:23 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-19_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_spam_notspam policy=outbound_spam score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705190094 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170519_080747_453034_16AE8F33 X-CRM114-Status: GOOD ( 15.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The AUX/mini-UART in the BCM2835 family of procesors is a cut-down 8250 clone. In particular it is lacking support for the following features: CSTOPB PARENB PARODD CMSPAR CS5 CS6 Add a new capability (UART_CAP_MINI) that exposes the restrictions to the user of the termios API by turning off the unsupported features in the request. N.B. It is almost possible to automatically discover the missing features by reading back the LCR register, but the CSIZE bits don't cooperate (contrary to the documentation, both bits are significant, but CS5 and CS6 are mapped to CS7) and the code is much longer. See: https://github.com/raspberrypi/linux/issues/1561 Signed-off-by: Phil Elwell Acked-by: Eric Anholt --- drivers/tty/serial/8250/8250.h | 3 +++ drivers/tty/serial/8250/8250_bcm2835aux.c | 2 +- drivers/tty/serial/8250/8250_port.c | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h index ce8d4ff..b2bdc35 100644 --- a/drivers/tty/serial/8250/8250.h +++ b/drivers/tty/serial/8250/8250.h @@ -81,6 +81,9 @@ struct serial8250_config { #define UART_CAP_HFIFO (1 << 14) /* UART has a "hidden" FIFO */ #define UART_CAP_RPM (1 << 15) /* Runtime PM is active while idle */ #define UART_CAP_IRDA (1 << 16) /* UART supports IrDA line discipline */ +#define UART_CAP_MINI (1 << 17) /* Mini UART on BCM283X family lacks: + * STOP PARITY EPAR SPAR WLEN5 WLEN6 + */ #define UART_BUG_QUOT (1 << 0) /* UART has buggy quot LSB */ #define UART_BUG_TXEN (1 << 1) /* UART has buggy TX IIR status */ diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c index e10f124..a23c7da 100644 --- a/drivers/tty/serial/8250/8250_bcm2835aux.c +++ b/drivers/tty/serial/8250/8250_bcm2835aux.c @@ -39,7 +39,7 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev) /* initialize data */ spin_lock_init(&data->uart.port.lock); - data->uart.capabilities = UART_CAP_FIFO; + data->uart.capabilities = UART_CAP_FIFO | UART_CAP_MINI; data->uart.port.dev = &pdev->dev; data->uart.port.regshift = 2; data->uart.port.type = PORT_16550; diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 09a65a3..dd218a1 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -2584,6 +2584,12 @@ static unsigned int serial8250_get_baud_rate(struct uart_port *port, unsigned long flags; unsigned int baud, quot, frac = 0; + if (up->capabilities & UART_CAP_MINI) { + termios->c_cflag &= ~(CSTOPB | PARENB | PARODD | CMSPAR); + if ((termios->c_cflag & CSIZE) == CS5 || + (termios->c_cflag & CSIZE) == CS6) + termios->c_cflag = (termios->c_cflag & ~CSIZE) | CS7; + } cval = serial8250_compute_lcr(up, termios->c_cflag); baud = serial8250_get_baud_rate(port, termios, old);