Received: by 10.223.185.116 with SMTP id b49csp7755936wrg; Thu, 1 Mar 2018 10:31:59 -0800 (PST) X-Google-Smtp-Source: AG47ELspaSnPgROxfoSpWqIee2iY6wxhMVX5/yn0/0KvCrpXZmcbqNZINqohcFKonjXu8oaPAubg X-Received: by 10.98.9.130 with SMTP id 2mr2871002pfj.149.1519929119187; Thu, 01 Mar 2018 10:31:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519929119; cv=none; d=google.com; s=arc-20160816; b=GZEXO/McDdU7QIBr5pkjilJSp0UOOiGR0geDbwaS0wmqJPPretMEXnshoZ31mkHyk2 34jh33sbsEA7EKXzZiJgSMUntEea81nlKTMOBMLGOrDK3TA3zC/0YwDlxLMgdA2S3lfO UneuNDfET2aeETT4smKQPxoF1NPmf7iiXtGimADylZsEIPnRNJaY+ShBJQtixY14mCvs Mg3J17nfF3M1E16MdsSJDdOUG3L6I5rP5zBMvshQu3vErTQuhPuqG7LXoqKEBvBBV11K 49T/I9suHgDE6b8VdbjWd2+tRwzrW2omD8My4Xg1I9K2gKC/aMHSTf/Xv/Jbfgo0nYJ1 eLyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=NR9gDPOfXKT+pmV67HiPLMSn44hx8CAhX/NS3cDLSk0=; b=l2OC/gDJLQdDPeH/lrbJRTnECM3wPkPVBnqxtZWRohChL9AG2zTnAa+jFcGdIVnsL/ M8evLsd74M5Xm4VewAwyNr7sS6E8S/mmLx9YHw6WlHzsXbHQ7GgCt3XqN+4hY417vA3u lBjF7JqQUx1a5igS5X317fhj85ZBYyBLw9MimStY6/FAtQY2JRFef2NBanxT+yg4ieIM eK7M0cTjPqORe1FTHfTOFML3v5zaLLmiEol4YbJ0GIixCc3VV28iI0nWICn/nJY7kpi/ jrM23xU25zZvlO1eBJg4rR5Qz4tHTMKrmdjdz313hA+cdOnbK8MKFOq1iQ5JGyaFne1t UKqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=Ipa/bDD7; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f4-v6si3345597plr.267.2018.03.01.10.31.43; Thu, 01 Mar 2018 10:31:59 -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=@infradead.org header.s=merlin.20170209 header.b=Ipa/bDD7; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033948AbeCASax (ORCPT + 99 others); Thu, 1 Mar 2018 13:30:53 -0500 Received: from merlin.infradead.org ([205.233.59.134]:48824 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033892AbeCASav (ORCPT ); Thu, 1 Mar 2018 13:30:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=NR9gDPOfXKT+pmV67HiPLMSn44hx8CAhX/NS3cDLSk0=; b=Ipa/bDD7WrPJvgSXzFpGg1oEF4 KzrmQFnHuNCaAE/lXxmJ/8Wl25NwhmFmhk0rX8rhPmuMcQmrZAlWHUg87DRyAKukDLLECafH2fRsI XLhuyzEGFtrFCjyN1gxppDE11od4HQpxoRLaR802wdrJKCOm6k7BEe2mP3kt2fI4S0iwJnt5EFxUz 96vm49UKjtjXQ75YeI4QzBSAs41OKHq7x/RFXunzfGxOwW5in4bQUZY7vTg5aCds2jhJhvosyu0jb kLNZPXsuwr9WJcMWev6RQU3wHqmw/WGNPQJsAmABcUJefE8BudSePWfEbM9zNcc1eGuud2b8srLs7 vamIuQrw==; Received: from static-50-53-52-16.bvtn.or.frontiernet.net ([50.53.52.16] helo=midway.dunlab) by merlin.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1erSye-0006hG-HH; Thu, 01 Mar 2018 18:30:48 +0000 Subject: Re: [PATCH] earlycon: Allow specifying a uartclk in options To: Daniel Kurtz Cc: adurbin@chromium.org, briannorris@chromium.org, Greg Kroah-Hartman , Jiri Slaby , "open list:SERIAL DRIVERS" , open list References: <20180301182028.237856-1-djkurtz@chromium.org> From: Randy Dunlap Message-ID: <57fb4f35-fd75-b2cc-75f7-8157ab1081d5@infradead.org> Date: Thu, 1 Mar 2018 10:30:45 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180301182028.237856-1-djkurtz@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/01/2018 10:20 AM, Daniel Kurtz wrote: > 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 Hi, Hopefully there will also be an update to one of Documentation/admin-guide/kernel-parameters.txt or Documentation/admin-guide/serial-console.rst. Thanks. > --- > 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; > }; > > -- ~Randy