Received: by 10.223.185.116 with SMTP id b49csp7746263wrg; Thu, 1 Mar 2018 10:21:31 -0800 (PST) X-Google-Smtp-Source: AG47ELsxFPCG0O4fRzKzAdnNu32DihEs4tZCLYzhM5J/eeJwv9Wax8XMRWozDy7kSmWwgrPG9fhJ X-Received: by 2002:a17:902:9002:: with SMTP id a2-v6mr2713760plp.412.1519928491749; Thu, 01 Mar 2018 10:21:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519928491; cv=none; d=google.com; s=arc-20160816; b=K8raMBBJCnW9XEvvBO44yZOnonVEY1MIWykz6lS/KJuVHCbIDssvvuBYeKUJR+A5HF p2bbyZJY2Xeo6yEzUFCkOXCD1p28Zal02zC4pjxUu7NQjc5Zdy8+EU8KHD+tZ3/VPOLd ho7iFouTAa0qpQxrV1Z6L/Wuxwaj593Gx7VDYDzLSaAPen3aBEzFlNmXE98bF3bdqv1R 4hLqJ1QfPLx5GQRs5ImNgxBNN5Lyllw2ENH3Wdd+Xl6KgIXyJyEXQ1BntquqTVq4YCAc ZcJHzMz6rnTAm3MNSB9dLHAqRD9WoGR3wl8p/cLsPtRzqs/Kg/28usCbBjAghpPgsd// a93w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature:arc-authentication-results; bh=XHPBm1Oej6G2e/fA1Hc8d21OaUT2GbjZdOHBEbOCs+k=; b=vJrZ/9gfEyW+lB/8LVLvSU70cx0VyEPHNHCQh9koewwHxvzxu13ICj7Gsf2Hp2KP3B x9Y7NQ3ruZCTw38jM5JAmSFv40RYaZ5OG1BPXnBg74EOp+5DZTb0UvlyywgGWL0ZHvri Jscm9g0ckRAhb/r2ryWKN7Wv0UuMeSiFssec+DRyP6ioKc6POJy/Pl9YFrB2ocYfRDti hmnqIL5IgU5lHQtDeyYUmYgB4BR+1+2M4iYR/TpEuO/S19/KQELsv063G/JUYkffqwN4 BrG79tT6clWe6lB6ARVCL8LcnnyDCn7bTPWXy1iUr+9laTrn+YrcUQOLb8FBf/L7Iu3l NSIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@chromium.org header.s=google header.b=kWxbw5fa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q10-v6si3420719pll.237.2018.03.01.10.21.17; Thu, 01 Mar 2018 10:21:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@chromium.org header.s=google header.b=kWxbw5fa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033879AbeCASUi (ORCPT + 99 others); Thu, 1 Mar 2018 13:20:38 -0500 Received: from mail-oi0-f66.google.com ([209.85.218.66]:39293 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033860AbeCASUd (ORCPT ); Thu, 1 Mar 2018 13:20:33 -0500 Received: by mail-oi0-f66.google.com with SMTP id t185so5176888oif.6 for ; Thu, 01 Mar 2018 10:20:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=XHPBm1Oej6G2e/fA1Hc8d21OaUT2GbjZdOHBEbOCs+k=; b=kWxbw5fayfyvgPZuoIBgqafR8d72nkv9/xQNTT5AC1tnwP9XGUEvjwf4/b+Xu3a1fK Tmz6A8l/TQ9tYt3pp9YFYU8cUP6uyTJjsbT0hdaS3G4VTbGnrjYRx8Qcb1b1Z8FN+udU aSd0+NmZp+v9/9FjgWcYdTutjZcQjypqs/z2s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=XHPBm1Oej6G2e/fA1Hc8d21OaUT2GbjZdOHBEbOCs+k=; b=DASYRIPgorRBW8uK/CFxvOW404NXfQiwtAKAyXWpCxOlIO5Kov3hRFcXvDOvL/bzrv KhDnRgarSuflGjdMZtaYLqnrD2IAiubMwKKH2tf5G6txpXFI9oBZpZKyp30dptKqQSvP CWMZGZlEqhjdsOBqQyzzoMvDRry/+YUVSOvS4FTAsVvpNZpzgm9DJX1DYx6csw2Rqb1+ 1+p1z9kYLRbUoOQGlBEczHyL0xyg71bm8XtwroZsmyBPHR2AamYo6sLh48+aklDhQDQa m8sRvlCHIBI6j/tB7vqtfjaET+Omc4F8vHog8g93XExN0+iFfoE/IOeVGMlzscBbVEwh Zdmw== X-Gm-Message-State: APf1xPCwL+preVDO+0QeIfmCyvCuxzm95sXLuS3wytaquThcL8GtI17N yUOvoAlsj2uwDZ08hkM6yJXzyw== X-Received: by 10.202.60.215 with SMTP id j206mr1745479oia.242.1519928433254; Thu, 01 Mar 2018 10:20:33 -0800 (PST) Received: from djkurtz2.bld.corp.google.com ([2620:15c:183:0:1cfd:61a5:7215:5f9c]) by smtp.gmail.com with ESMTPSA id z68sm764626oig.37.2018.03.01.10.20.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 10:20:32 -0800 (PST) From: Daniel Kurtz Cc: adurbin@chromium.org, briannorris@chromium.org, Daniel Kurtz , Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org (open list:SERIAL DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] earlycon: Allow specifying a uartclk in options Date: Thu, 1 Mar 2018 11:20:28 -0700 Message-Id: <20180301182028.237856-1-djkurtz@chromium.org> X-Mailer: git-send-email 2.16.2.395.g2e18187dfd-goog To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently when an earlycon is registered, the uartclk is assumed to be BASE_BAUD * 16 = 1843200. If a baud rate is specified in the earlycon options, then 8250_early's init_port will program the UART clock divider registers based on this assumed uartclk. However, not all uarts have a UART clock of 1843200. For example, the 8250_dw uart in AMD's CZ/ST uses a fixed 48 MHz clock (as specified in cz_uart_desc in acpi_apd.c). Thus, specifying a baud when using earlycon on such a device will result in incorrect divider values and a wrong UART clock. Fix this by extending the earlycon options parameter to allow specification of a uartclk, like so: earlycon=uart,mmio32,0xfedc6000,115200,48000000 If none is specified, fall-back to prior behavior - 1843200. Signed-off-by: Daniel Kurtz --- drivers/tty/serial/earlycon.c | 8 ++++++-- include/linux/serial_core.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c index 870e84fb6e39..c9b38f520057 100644 --- a/drivers/tty/serial/earlycon.c +++ b/drivers/tty/serial/earlycon.c @@ -115,12 +115,17 @@ static int __init parse_options(struct earlycon_device *device, char *options) } if (options) { - device->baud = simple_strtoul(options, NULL, 0); + char *uartclk; + device->baud = simple_strtoul(options, &uartclk, 0); + if (*uartclk++ == ',') + port->uartclk = simple_strtoul(uartclk, NULL, 0); length = min(strcspn(options, " ") + 1, (size_t)(sizeof(device->options))); strlcpy(device->options, options, length); } + port->uartclk = (port->uartclk) ?: BASE_BAUD * 16; + return 0; } @@ -134,7 +139,6 @@ static int __init register_earlycon(char *buf, const struct earlycon_id *match) buf = NULL; spin_lock_init(&port->lock); - port->uartclk = BASE_BAUD * 16; if (port->mapbase) port->membase = earlycon_map(port->mapbase, 64); diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index b32df49a3bd5..b772f0d20b18 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -343,7 +343,7 @@ static inline int uart_poll_timeout(struct uart_port *port) struct earlycon_device { struct console *con; struct uart_port port; - char options[16]; /* e.g., 115200n8 */ + char options[32]; /* e.g., 115200n8,48000000 */ unsigned int baud; }; -- 2.16.2.395.g2e18187dfd-goog