From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 848CCC54EE9 for ; Mon, 19 Sep 2022 15:28:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: MIME-Version:References:Message-ID:In-Reply-To:Subject:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Q8+IP+SZ+TUj0YnYD15w0LO1pI208mLeSFX3/M0UXe8=; b=xgPiY9C6qIFYDKhT53YgCVNKi8 PCn2p9miqE4sy5jIRk3FIRs4utz4t+oB6KM4nzLSUh756rw5XgGRESedDD/76fkkeDdB9p40CSX51 8QXKKu1B1khutiFVs9VXiz0FaXs1f5cwMS/82mFJEH7SjuUBjiFD2Bj6pppdfDpO2EKP2dj/Nycvg PSsrK+hI6RV6bxcoSHfzIN7L8xfOHDhgfqp8uOwF8gvGI3niJ/kRoTJnvDbSuCfChMjKB06guUgLI gipaz0USpxfVIArBWJdhNmDvE8xkfmGYxhiHTt+KAyAT6UT51RjKjYBirB9VbRCYbVAyJbNK8vZI9 yFYqlWKQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaIfs-00CRvk-HC; Mon, 19 Sep 2022 15:27:09 +0000 Received: from mga18.intel.com ([134.134.136.126]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oaIX1-00CMe3-PU for linux-arm-kernel@lists.infradead.org; Mon, 19 Sep 2022 15:18:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663600680; x=1695136680; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=lyWtjXhG3QhRvIlRitPwxiBIgXlP2Igv2zzIEO7c0wk=; b=OdOhjw4vYAMYMstXNgKXpMJGSgM4sprhMJtZGRjnADDrRa5fhZb5Ms7n jTwZN05hNPsmXkJKNCjnDHGFA2Px917Y3zZp09BWmLaypxv+RIjTv6o16 GP6URbiCu83yiDaJeMWBEoTp2MWVXVenns/3iqDbI6MqZf9H5kLbmZHYo eyf4zNHGi6ONjVswk5k6u9jp2SHhqD2vEc3nu5yQ6CvMqIyNwHLDHiZ7i KnaHDCSPccAiaV99pFPpNw5hOGIDvIkf5KZdCI00hgmku+cNS6/UjpcuK VwGe2OZqDJ2xijlqMiTTCgOj2WxtvKRLI3yrri8qH6k+DeMDJOszK65vW w==; X-IronPort-AV: E=McAfee;i="6500,9779,10475"; a="282453180" X-IronPort-AV: E=Sophos;i="5.93,328,1654585200"; d="scan'208";a="282453180" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Sep 2022 08:17:53 -0700 X-IronPort-AV: E=Sophos;i="5.93,328,1654585200"; d="scan'208";a="744148447" Received: from iswiersz-mobl1.ger.corp.intel.com ([10.252.33.172]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Sep 2022 08:17:49 -0700 Date: Mon, 19 Sep 2022 18:17:46 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Sergiu Moga Subject: Re: [PATCH v4 8/9] tty: serial: atmel: Only divide Clock Divisor if the IP is USART In-Reply-To: <20220919150846.1148783-9-sergiu.moga@microchip.com> Message-ID: <7173f82-4f14-6f89-9651-fd3fdc4b9dcc@linux.intel.com> References: <20220919150846.1148783-1-sergiu.moga@microchip.com> <20220919150846.1148783-9-sergiu.moga@microchip.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-390606940-1663600673=:1603" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220919_081800_600699_687BED51 X-CRM114-Status: GOOD ( 29.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, alexandre.belloni@bootlin.com, kavyasree.kotagiri@microchip.com, richard.genoud@gmail.com, gregkh@linuxfoundation.org, radu_nicolae.pirea@upb.ro, lee@kernel.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-serial@vger.kernel.org, linux-spi@vger.kernel.org, jirislaby@kernel.org, claudiu.beznea@microchip.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-390606940-1663600673=:1603 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8BIT On Mon, 19 Sep 2022, Sergiu Moga wrote: > Make sure that the driver only divides the clock divisor if the > IP handled at that point is USART, since UART IP's do not support > implicit peripheral clock division. Instead, in the case of UART, > go with the highest possible clock divisor. > > Signed-off-by: Sergiu Moga Look good. Reviewed-by: Ilpo Järvinen -- i. > --- > > > v1 -> v2: > - Nothing, this patch was not here before and is mainly meant as both cleanup > and as a way to introduce a new field into struct atmel_uart_port that will be > used by the last patch to diferentiate between USART and UART regarding the > location of the Baudrate Clock Source bitmask. > > > > v2 -> v3: > - Use ATMEL_US_CD instead of 65535 > - Previously [PATCH 10] > > > > v3 -> v4: > - Use min_t instead of & > - Previously [PATCH 12] > > > drivers/tty/serial/atmel_serial.c | 17 ++++++++++++++++- > 1 file changed, 16 insertions(+), 1 deletion(-) > > diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c > index ab4a9dfae07d..c983798a4ab2 100644 > --- a/drivers/tty/serial/atmel_serial.c > +++ b/drivers/tty/serial/atmel_serial.c > @@ -150,6 +150,7 @@ struct atmel_uart_port { > u32 rts_low; > bool ms_irq_enabled; > u32 rtor; /* address of receiver timeout register if it exists */ > + bool is_usart; > bool has_frac_baudrate; > bool has_hw_timer; > struct timer_list uart_timer; > @@ -1825,6 +1826,7 @@ static void atmel_get_ip_name(struct uart_port *port) > */ > atmel_port->has_frac_baudrate = false; > atmel_port->has_hw_timer = false; > + atmel_port->is_usart = false; > > if (name == new_uart) { > dev_dbg(port->dev, "Uart with hw timer"); > @@ -1834,6 +1836,7 @@ static void atmel_get_ip_name(struct uart_port *port) > dev_dbg(port->dev, "Usart\n"); > atmel_port->has_frac_baudrate = true; > atmel_port->has_hw_timer = true; > + atmel_port->is_usart = true; > atmel_port->rtor = ATMEL_US_RTOR; > version = atmel_uart_readl(port, ATMEL_US_VERSION); > switch (version) { > @@ -1863,6 +1866,7 @@ static void atmel_get_ip_name(struct uart_port *port) > dev_dbg(port->dev, "This version is usart\n"); > atmel_port->has_frac_baudrate = true; > atmel_port->has_hw_timer = true; > + atmel_port->is_usart = true; > atmel_port->rtor = ATMEL_US_RTOR; > break; > case 0x203: > @@ -2283,10 +2287,21 @@ static void atmel_set_termios(struct uart_port *port, > cd = uart_get_divisor(port, baud); > } > > - if (cd > 65535) { /* BRGR is 16-bit, so switch to slower clock */ > + /* > + * If the current value of the Clock Divisor surpasses the 16 bit > + * ATMEL_US_CD mask and the IP is USART, switch to the Peripheral > + * Clock implicitly divided by 8. > + * If the IP is UART however, keep the highest possible value for > + * the CD and avoid needless division of CD, since UART IP's do not > + * support implicit division of the Peripheral Clock. > + */ > + if (atmel_port->is_usart && cd > ATMEL_US_CD) { > cd /= 8; > mode |= ATMEL_US_USCLKS_MCK_DIV8; > + } else { > + cd = min_t(unsigned int, cd, ATMEL_US_CD); > } > + > quot = cd | fp << ATMEL_US_FP_OFFSET; > > if (!(port->iso7816.flags & SER_ISO7816_ENABLED)) --8323329-390606940-1663600673=:1603 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --8323329-390606940-1663600673=:1603--