Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp424075lqt; Thu, 18 Apr 2024 22:45:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXwkioF1bzgOFsPfhUs8NW8OZwJ+JYSUWiOwHbBavB7kwpMmnUpOSRkB8c/fnIXD8ZLYjio1j208nkO3vowEkVoU/WT0NUshf2Ff9b+yQ== X-Google-Smtp-Source: AGHT+IGFr0LZ+UtUp/kPeZYIcmx72ZNCGC3YLFGuXAsiycrloHJxKoFf4vpHkUSIoAlcrGIOADSE X-Received: by 2002:a17:902:a612:b0:1e8:b768:2c25 with SMTP id u18-20020a170902a61200b001e8b7682c25mr967620plq.15.1713505524280; Thu, 18 Apr 2024 22:45:24 -0700 (PDT) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id k1-20020a170902760100b001ddc7f33e57si2649349pll.417.2024.04.18.22.45.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 22:45:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151021-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-151021-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151021-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 74FFDB219B5 for ; Fri, 19 Apr 2024 05:45:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B6F0BE65; Fri, 19 Apr 2024 05:45:10 +0000 (UTC) Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 225C9BE49; Fri, 19 Apr 2024 05:45:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713505509; cv=none; b=Q4XSpDhTha7pW7U1d6snMIi0kPRRbjpNRux71z+OPSzjoqGQdei28Gy0R1i1qn2NFnUfBpbKHoz9+xv8Ska7xm4KLSkD7gES2zmRr89BCs3HngUglBAKPvdxQG4FLRRT2a2sxFUBhBlRdBxooZU5nWjwf0Q212gkJ+H7bQTnyqU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713505509; c=relaxed/simple; bh=rh1pnq0wAHeiN0BizArHWgSh/qi7Tm3cN2bw41OzXlw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Cf//OMb6yirzNFCPaLyKgRZkF2qnJdKDaoYJuo2PfE2ksPxqlWkR0dMKrk5iVNHobIx8mxeLWy8baUfGlqskRSEEYc1fDlpD4qrA2xqbwjAIsHRSjlFYaKMjoSef9u4Cf0HeKofJp6c5Z1Jk0XTDywVeRF9m0mfuxoUzvIz8iFM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a55602507a9so190801166b.3; Thu, 18 Apr 2024 22:45:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713505506; x=1714110306; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=tx9GPlZFmNFO6IN0jAsuyE0mf6S3h8zFagHqKXxGM0o=; b=dj/yMySrZjcQ4qK1TBA8Rg8zy3iji93PeBCy/Pl/AuyTeajspndQg9G0aghlx8RJVb qzIxq2WF99bx4MBmxFstUVDxa85j0GQlAu0nY1tizegO7CSkmMAYbPLY+7L78rC/wo1F 2kpzEh3XJ9HnWDhuWzqTUfpIUGHmranQzIQORy1DNRyTugAWX9pRGSQ0Vs8WnQ44dk75 V7/a4d70WWE0CxEe9qOn6kJ0YvGybfQBO1LUQaYnTtL0JSb1P7T2FROeyzafOgo1MvRs 9LvrQvSaB4Rnncu834rHZinKxGYukVORWOwJ/UU442DAwY1O9mqaq19243Iz+xR87M8s yJ7A== X-Forwarded-Encrypted: i=1; AJvYcCUz2ujGDRMNT97Y0qacAEmcfIhZsby6Szc4d8OJdO0uDSMVkWq4XfzKuO6aUmsqlt9eNoO2L5SkuMTp3uKbpEMpwYiaLPmc0aKZzmzcqnJTyvRtvKJvFMIuBRbhKva7oPAflV7dPBJR84RO X-Gm-Message-State: AOJu0YyPLY9FPUX0/c/PT2NsQ9eiK5Bhw/k2vgTbgmO9Ib8sJaTeyR4a FjXhECDoc97HaL0YwrsriLyo+2XIz+ucjSU73ZA1QX1B1PalutcM X-Received: by 2002:a17:906:a24c:b0:a55:59e6:13f5 with SMTP id bi12-20020a170906a24c00b00a5559e613f5mr773920ejb.26.1713505506123; Thu, 18 Apr 2024 22:45:06 -0700 (PDT) Received: from ?IPV6:2a0b:e7c0:0:107::aaaa:69? ([2a0b:e7c0:0:107::aaaa:69]) by smtp.gmail.com with ESMTPSA id ww4-20020a170907084400b00a51d88e6164sm1724474ejb.203.2024.04.18.22.45.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Apr 2024 22:45:05 -0700 (PDT) Message-ID: <5cee4da4-1620-449c-8160-ff4168b0688e@kernel.org> Date: Fri, 19 Apr 2024 07:45:04 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/3] serial: sc16is7xx: add support for EXAR XR20M1172 UART To: Konstantin Cc: Konstantin , Greg Kroah-Hartman , Hugo Villeneuve , Andy Shevchenko , Lech Perczak , =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org References: <20240418132508.3447800-1-rilian.la.te@ya.ru> <20240418132508.3447800-4-rilian.la.te@ya.ru> Content-Language: en-US From: Jiri Slaby Autocrypt: addr=jirislaby@kernel.org; keydata= xsFNBE6S54YBEACzzjLwDUbU5elY4GTg/NdotjA0jyyJtYI86wdKraekbNE0bC4zV+ryvH4j rrcDwGs6tFVrAHvdHeIdI07s1iIx5R/ndcHwt4fvI8CL5PzPmn5J+h0WERR5rFprRh6axhOk rSD5CwQl19fm4AJCS6A9GJtOoiLpWn2/IbogPc71jQVrupZYYx51rAaHZ0D2KYK/uhfc6neJ i0WqPlbtIlIrpvWxckucNu6ZwXjFY0f3qIRg3Vqh5QxPkojGsq9tXVFVLEkSVz6FoqCHrUTx wr+aw6qqQVgvT/McQtsI0S66uIkQjzPUrgAEtWUv76rM4ekqL9stHyvTGw0Fjsualwb0Gwdx ReTZzMgheAyoy/umIOKrSEpWouVoBt5FFSZUyjuDdlPPYyPav+hpI6ggmCTld3u2hyiHji2H cDpcLM2LMhlHBipu80s9anNeZhCANDhbC5E+NZmuwgzHBcan8WC7xsPXPaiZSIm7T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9YtlNOPWhbKPlrQ8+AY52Aagi9WNhe6XfJdh5g6ptiOILm330mkR4g W6nEgZVyIyTq3ekOuruftWL99qpP5zi+eNrMmLRQx9iecDNgFr342R9bTDlb1TLuRb+/tJ98 f/bIWIr0cqQmqQ33FgRhrG1+Xml6UXyJ2jExmlO8JljuOGeXYh6ZkIEyzqzffzBLXZCujlYQ DFXpyMNVJ2ZwPmX2mWEoYuaBU0JN7wM+/zWgOf2zRwhEuD3A2cO2PxoiIfyUEfB9SSmffaK/ S4xXoB6wvGENZ85Hg37C7WDNdaAt6Xh2uQIly5grkgvWppkNy4ZHxE+jeNsU7tg= In-Reply-To: <20240418132508.3447800-4-rilian.la.te@ya.ru> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 18. 04. 24, 15:25, Konstantin wrote: > From: Konstantin > > Its register set is mostly compatible with SC16IS762, but > it has a support for additional division rates of UART > with special DLD register. So, add handling this register > via UPF_MAGIC_MULTIPLIER port flag. > > Signed-off-by: Konstantin Pugin > --- > drivers/tty/serial/sc16is7xx.c | 54 ++++++++++++++++++++++++++++++++-- > 1 file changed, 51 insertions(+), 3 deletions(-) > > diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c > index a300eebf1401..7fc1c19b3891 100644 > --- a/drivers/tty/serial/sc16is7xx.c > +++ b/drivers/tty/serial/sc16is7xx.c > @@ -65,6 +65,7 @@ > /* Special Register set: Only if ((LCR[7] == 1) && (LCR != 0xBF)) */ > #define SC16IS7XX_DLL_REG (0x00) /* Divisor Latch Low */ > #define SC16IS7XX_DLH_REG (0x01) /* Divisor Latch High */ > +#define SC16IS7XX_DLD_REG (0x02) /* Divisor Latch Mode (only on EXAR chips) */ > > /* Enhanced Register set: Only if (LCR == 0xBF) */ > #define SC16IS7XX_EFR_REG (0x02) /* Enhanced Features */ > @@ -218,6 +219,20 @@ > #define SC16IS7XX_TCR_RX_HALT(words) ((((words) / 4) & 0x0f) << 0) > #define SC16IS7XX_TCR_RX_RESUME(words) ((((words) / 4) & 0x0f) << 4) > > +/* Divisor Latch Mode bits (EXAR extension) > + * > + * EXAR hardware is mostly compatible with SC16IS7XX, but supports additional feature: > + * 4x and 8x divisor, instead of default 16x. It has a special register to program it. > + * Bits 0 to 3 is fractional divisor, it used to set value of last 16 bits of > + * uartclk * (16 / divisor) / baud, in case of default it will be uartclk / baud. > + * Bits 4 and 5 used as switches, and should not be set to 1 simultaneously. > + */ > + > +#define SC16IS7XX_DLD_16X 0 > +#define SC16IS7XX_DLD_DIV(m) ((m) & 0xf) Why not to use GENMASK() here and FIELD_PREP() in the code? > +#define SC16IS7XX_DLD_8X BIT(4) > +#define SC16IS7XX_DLD_4X BIT(5) > + > /* > * TLR register bits > * If TLR[3:0] or TLR[7:4] are logical 0, the selectable trigger levels via the .. > @@ -559,13 +582,29 @@ static int sc16is7xx_set_baud(struct uart_port *port, int baud) > struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); > u8 lcr; > u8 prescaler = 0; > - unsigned long clk = port->uartclk, div = clk / 16 / baud; > + u8 divisor = 16; > + u8 dld_mode = SC16IS7XX_DLD_16X; > + bool has_dld = !!(port->flags & UPF_MAGIC_MULTIPLIER); No need for !!. > + unsigned long clk = port->uartclk, div, div16; All these locals would deserve better ordering. .. > @@ -1014,6 +1055,7 @@ static void sc16is7xx_set_termios(struct uart_port *port, > unsigned int lcr, flow = 0; > int baud; > unsigned long flags; > + bool has_dld = !!(port->flags & UPF_MAGIC_MULTIPLIER); Ditto. > > kthread_cancel_delayed_work_sync(&one->ms_work); > thanks, -- js suse labs