devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jacky Huang <ychuang570808@gmail.com>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org,
	lee@kernel.org, mturquette@baylibre.com, sboyd@kernel.org,
	p.zabel@pengutronix.de,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jirislaby@kernel.org>,
	devicetree@vger.kernel.org, linux-clk@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>,
	linux-serial <linux-serial@vger.kernel.org>,
	schung@nuvoton.com, Jacky Huang <ychuang3@nuvoton.com>,
	mjchen@nuvoton.com
Subject: Re: [PATCH 14/15] tty: serial: Add Nuvoton ma35d1 serial driver support
Date: Tue, 21 Mar 2023 22:23:04 +0800	[thread overview]
Message-ID: <fff88562-2bb4-fe7f-8963-c9da4e7017b2@gmail.com> (raw)
In-Reply-To: <b6995749-4b54-59d1-99d2-6b64b438f22f@linux.intel.com>

Dear Ilpo,


On 2023/3/20 下午 06:04, Ilpo Järvinen wrote:
> On Mon, 20 Mar 2023, Jacky Huang wrote:
>
>> Dear Ilpo,
>>
>>
>> Thanks for your advice.
>>
>> On 2023/3/16 下午 10:54, Ilpo Järvinen wrote:
>>> Hi,
>>>
>>> I'll not note all things below because others have already seemingly
>>> commented many things.
>>>
>>> On Wed, 15 Mar 2023, Jacky Huang wrote:
>>>
>>>> From: Jacky Huang <ychuang3@nuvoton.com>
>>>>
>>>> This adds UART and console driver for Nuvoton ma35d1 Soc.
>>>> +		}
>>>> +		ch = (u8)serial_in(up, UART_REG_RBR);
>>> Drop the case.
>> I  will fix it.
> I meant "cast" in case it wasn't obvious.


I know that, thank you.


>>>> +/* Enable or disable the rs485 support */
>>>> +static int ma35d1serial_config_rs485(struct uart_port *port,
>>>> +				     struct ktermios *termios,
>>>> +				     struct serial_rs485 *rs485conf)
>>>> +{
>>>> +	struct uart_ma35d1_port *p = to_ma35d1_uart_port(port);
>>>> +
>>>> +	p->rs485 = *rs485conf;
>>>> +
>>>> +	if (p->rs485.delay_rts_before_send >= 1000)
>>>> +		p->rs485.delay_rts_before_send = 1000;
>>> Don't do this in driver, the core handles the delay limits. You don't seem
>>> to be using the value anyway for anything???
>>>
>>> Please separate the RS485 support into its own patch.
>>
>> OK, we will remove RS485 support from this initial patch.
>> Once this initial patch was merged, we will submit the patch for RS485
>> support.
> You could do that but you could just as well include it into the same
> series as another patch after the main patch.
>>>> +	serial_out(p, UART_FUN_SEL,
>>>> +		   (serial_in(p, UART_FUN_SEL) & ~FUN_SEL_MASK));
>>>> +
>>>> +	if (rs485conf->flags & SER_RS485_ENABLED) {
>>>> +		serial_out(p, UART_FUN_SEL,
>>>> +			   (serial_in(p, UART_FUN_SEL) | FUN_SEL_RS485));
>>> Does this pair of serial_out()s glitch the RS485 line if ->rs485_config()
>>> is called while RS485 mode is already set?
>>>
>>> Why you need to do serial_in() from the UART_FUN_SEL twice?
>> UART_FUN_SEL (2 bits) definition:
>> 00 - UART function
>> 01 - IrDA function
>> 11 - RS485 function
>>
>> The first searial_in() is used to clear set as UART function.
>> The second one is used to set RS485 function if SER_RS485_ENABLED is true.
> I got that, but it doesn't answer either of my questions which are:
>
> Can you clear the UART function without causing a glitch in the RS485?
> ->rs485_config() can be called while already in RS485 mode so does it
> cause the UART to temporarily switch away from RS485 mode to "UART
> function" until the second write.
>
> Also, you didn't explain why you need to read the register again, does
> the HW play with other bits when you do the clearing or to they remain
> the same (in which case you can just use a temporary variable to store
> the value)? ...It would be better to just write once too so this question
> might not matter in the end.


Thank you for the detailed explanation.

OK, the register won't change. I will modify the code to read once and 
write once only.


>>>> +	if (pdev->dev.of_node) {
>>>> +		ret = of_alias_get_id(pdev->dev.of_node, "serial");
>>>> +		if (ret < 0) {
>>>> +			dev_err(&pdev->dev,
>>>> +				"failed to get alias/pdev id, errno %d\n",
>>>> +				ret);
>>> Just put error prints to one line if you don't break 100 chars limit.
>> But the checkpatch limitation is 80 characters.
> No, it isn't. It was changed years ago already.


I have a test on the checkpatch script.

You are right. It won't complain about over 80 characters now.


>>>> +++ b/drivers/tty/serial/ma35d1_serial.h
>>>> @@ -0,0 +1,93 @@
>>>> +/* SPDX-License-Identifier: GPL-2.0 */
>>>> +/*
>>>> + *  MA35D1 serial driver header file
>>>> + *  Copyright (C) 2023 Nuvoton Technology Corp.
>>>> + */
>>>> +#ifndef __MA35D1_SERIAL_H__
>>>> +#define __MA35D1_SERIAL_H__
>>>> +
>>>> +/* UART Receive/Transmit Buffer Register */
>>>> +#define UART_REG_RBR	0x00
>>>> +#define UART_REG_THR	0x00
>>>> +
>>>> +/* UART Interrupt Enable Register */
>>>> +#define UART_REG_IER	0x04
>>>> +#define RDA_IEN		0x00000001 /* RBR Available Interrupt Enable
>>>> */
>>>> +#define THRE_IEN	0x00000002 /* THR Empty Interrupt Enable */
>>>> +#define RLS_IEN		0x00000004 /* RX Line Status Interrupt Enable
>>>> */
>>>> +#define RTO_IEN		0x00000010 /* RX Time-out Interrupt Enable */
>>>> +#define BUFERR_IEN	0x00000020 /* Buffer Error Interrupt Enable */
>>>> +#define TIME_OUT_EN	0x00000800 /* RX Buffer Time-out Counter
>>>> Enable */
>>>> +
>>>> +/* UART FIFO Control Register */
>>>> +#define UART_REG_FCR	0x08
>>>> +#define RFR		0x00000002 /* RX Field Software Reset */
>>>> +#define TFR		0x00000004 /* TX Field Software Reset */
>>>> +
>>>> +/* UART Line Control Register */
>>>> +#define UART_REG_LCR	0x0C
>>>> +#define	NSB		0x00000004 /* Number of “STOP Bit” */
>>>> +#define PBE		0x00000008 /* Parity Bit Enable */
>>>> +#define EPE		0x00000010 /* Even Parity Enable */
>>>> +#define SPE		0x00000020 /* Stick Parity Enable */
>>>> +#define BCB		0x00000040 /* Break Control */
>>>> +
>>>> +/* UART Modem Control Register */
>>>> +#define UART_REG_MCR	0x10
>>>> +#define RTS		0x00000020 /* nRTS Signal Control */
>>>> +#define RTSACTLV	0x00000200 /* nRTS Pin Active Level */
>>>> +#define RTSSTS		0x00002000 /* nRTS Pin Status (Read Only) */
>>>> +
>>>> +/* UART Modem Status Register */
>>>> +#define UART_REG_MSR	0x14
>>>> +#define CTSDETF		0x00000001 /* Detect nCTS State Change Flag */
>>>> +#define CTSSTS		0x00000010 /* nCTS Pin Status (Read Only) */
>>>> +#define CTSACTLV	0x00000100 /* nCTS Pin Active Level */
>>>> +
>>>> +/* UART FIFO Status Register */
>>>> +#define UART_REG_FSR	0x18
>>>> +#define RX_OVER_IF	0x00000001 /* RX Overflow Error Interrupt Flag */
>>>> +#define PEF		0x00000010 /* Parity Error Flag*/
>>>> +#define FEF		0x00000020 /* Framing Error Flag */
>>>> +#define BIF		0x00000040 /* Break Interrupt Flag */
>>>> +#define RX_EMPTY	0x00004000 /* Receiver FIFO Empty (Read Only) */
>>>> +#define RX_FULL		0x00008000 /* Receiver FIFO Full (Read Only)
>>>> */
>>>> +#define TX_EMPTY	0x00400000 /* Transmitter FIFO Empty (Read Only) */
>>>> +#define TX_FULL		0x00800000 /* Transmitter FIFO Full (Read
>>>> Only) */
>>>> +#define TX_OVER_IF	0x01000000 /* TX Overflow Error Interrupt Flag */
>>>> +#define TE_FLAG		0x10000000 /* Transmitter Empty Flag (Read
>>>> Only) */
>>>> +
>>>> +/* UART Interrupt Status Register */
>>>> +#define UART_REG_ISR	0x1C
>>>> +#define RDA_IF		0x00000001 /* RBR Available Interrupt Flag */
>>>> +#define THRE_IF		0x00000002 /* THR Empty Interrupt Flag */
>>>> +#define RLSIF		0x00000004 /* Receive Line Interrupt Flag */
>>>> +#define MODEMIF		0x00000008 /* MODEM Interrupt Flag */
>>>> +#define RXTO_IF		0x00000010 /* RX Time-out Interrupt Flag */
>>>> +#define BUFEIF		0x00000020 /* Buffer Error Interrupt Flag */
>>>> +#define WK_IF		0x00000040 /* UART Wake-up Interrupt Flag */
>>>> +#define RDAINT		0x00000100 /* RBR Available Interrupt
>>>> Indicator */
>>>> +#define THRE_INT	0x00000200 /* THR Empty Interrupt Indicator */
> I forgot to mention earlier, there are many defines above which should use
> BIT().
>
Sure we will fix them all.


Best regards,

Jacky Huang



  reply	other threads:[~2023-03-21 14:23 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-15  7:28 [PATCH 00/15] Introduce Nuvoton ma35d1 SoC Jacky Huang
2023-03-15  7:28 ` [PATCH 01/15] arm64: Kconfig.platforms: Add config for Nuvoton MA35 platform Jacky Huang
2023-03-15  7:28 ` [PATCH 02/15] arm64: defconfig: Add Nuvoton MA35 family support Jacky Huang
2023-03-16 14:23   ` Arnd Bergmann
2023-03-17  9:05     ` Jacky Huang
2023-03-15  7:28 ` [PATCH 03/15] mfd: Add the header file of Nuvoton ma35d1 system manager Jacky Huang
2023-03-16 13:30   ` Ilpo Järvinen
2023-03-17  6:51     ` Jacky Huang
2023-03-16 14:44   ` Arnd Bergmann
2023-03-17  9:28     ` Jacky Huang
2023-03-15  7:28 ` [PATCH 04/15] dt-bindings: clock: nuvoton: add binding for ma35d1 clock controller Jacky Huang
2023-03-16  7:31   ` Krzysztof Kozlowski
2023-03-16 13:35     ` Jacky Huang
2023-03-16 14:09       ` Krzysztof Kozlowski
2023-03-15  7:28 ` [PATCH 05/15] dt-bindings: reset: nuvoton: add binding for ma35d1 IP reset control Jacky Huang
2023-03-16  7:31   ` Krzysztof Kozlowski
2023-03-15  7:28 ` [PATCH 06/15] dt-bindings: mfd: syscon: Add nuvoton,ma35d1-sys compatible Jacky Huang
2023-03-16  7:31   ` Krzysztof Kozlowski
2023-03-17  1:03     ` Jacky Huang
2023-03-15  7:28 ` [PATCH 07/15] dt-bindings: arm: Add initial bindings for Nuvoton platform Jacky Huang
2023-03-16  7:33   ` Krzysztof Kozlowski
2023-03-16 14:32     ` Arnd Bergmann
2023-03-18  1:26       ` Jacky Huang
2023-03-15  7:28 ` [PATCH 08/15] dt-bindings: clock: Document ma35d1 clock controller bindings Jacky Huang
2023-03-15 21:59   ` Stephen Boyd
2023-03-16  3:24     ` Jacky Huang
2023-03-16  7:35   ` Krzysztof Kozlowski
2023-03-17  3:47     ` Jacky Huang
2023-03-17  9:13       ` Krzysztof Kozlowski
2023-03-17  9:52         ` Jacky Huang
2023-03-17 16:03           ` Krzysztof Kozlowski
2023-03-18  2:11             ` Jacky Huang
2023-03-15  7:28 ` [PATCH 09/15] dt-bindings: reset: Document ma35d1 reset " Jacky Huang
2023-03-16  7:37   ` Krzysztof Kozlowski
2023-03-16  7:39     ` Krzysztof Kozlowski
2023-03-18  4:30       ` Jacky Huang
2023-03-19 11:05         ` Krzysztof Kozlowski
2023-03-20  6:26           ` Jacky Huang
2023-03-15  7:28 ` [PATCH 10/15] dt-bindings: serial: Document ma35d1 uart " Jacky Huang
2023-03-16  7:40   ` Krzysztof Kozlowski
2023-03-17  4:18     ` Jacky Huang
2023-03-15  7:28 ` [PATCH 11/15] arm64: dts: nuvoton: Add initial ma35d1 device tree Jacky Huang
2023-03-16  7:45   ` Krzysztof Kozlowski
2023-03-18  6:07     ` Jacky Huang
2023-03-19 11:06       ` Krzysztof Kozlowski
2023-03-19 14:16         ` Jacky Huang
2023-03-16 14:17   ` Arnd Bergmann
2023-03-16 16:44     ` Lee Jones
2023-03-18 13:32       ` Jacky Huang
2023-03-18 13:17     ` Jacky Huang
2023-03-18 14:04       ` Arnd Bergmann
2023-03-20 15:38         ` Jacky Huang
2023-03-15  7:28 ` [PATCH 12/15] clk: nuvoton: Add clock driver for ma35d1 clock controller Jacky Huang
2023-03-15 22:07   ` kernel test robot
2023-03-15 22:30   ` Stephen Boyd
2023-03-17  3:07     ` Jacky Huang
2023-03-16  7:51   ` Krzysztof Kozlowski
2023-03-19  2:55     ` Jacky Huang
2023-03-16 15:56   ` Ilpo Järvinen
2023-03-19  5:16     ` Jacky Huang
2023-03-20 10:31       ` Ilpo Järvinen
2023-03-21 15:03         ` Jacky Huang
2023-03-15  7:29 ` [PATCH 13/15] reset: Add Nuvoton ma35d1 reset driver support Jacky Huang
2023-03-16  7:51   ` Krzysztof Kozlowski
2023-03-17  7:13     ` Jacky Huang
2023-03-16 15:05   ` Ilpo Järvinen
2023-03-19 13:10     ` Jacky Huang
2023-03-15  7:29 ` [PATCH 14/15] tty: serial: Add Nuvoton ma35d1 serial " Jacky Huang
2023-03-15  7:37   ` Greg KH
2023-03-15  9:40     ` Jacky Huang
2023-03-15  9:48   ` kernel test robot
2023-03-15 10:13   ` Jiri Slaby
2023-03-16 13:28     ` Jacky Huang
2023-03-16 14:54   ` Ilpo Järvinen
2023-03-20  8:23     ` Jacky Huang
2023-03-20 10:04       ` Ilpo Järvinen
2023-03-21 14:23         ` Jacky Huang [this message]
2023-03-15  7:29 ` [PATCH 15/15] MAINTAINERS: Add entry for NUVOTON MA35 Jacky Huang
2023-03-16 14:38   ` Arnd Bergmann
2023-03-19 12:01     ` Jacky Huang
2023-03-19 12:36       ` Tomer Maimon
2023-03-16  7:41 ` [PATCH 00/15] Introduce Nuvoton ma35d1 SoC Krzysztof Kozlowski
2023-03-16 14:05 ` Arnd Bergmann
2023-03-17  6:30   ` Jacky Huang
2023-03-17 13:21     ` Arnd Bergmann
2023-03-17 16:06       ` Krzysztof Kozlowski
2023-03-18  3:07         ` Jacky Huang
2023-03-18  9:07           ` Arnd Bergmann
2023-03-18  3:00       ` Jacky Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fff88562-2bb4-fe7f-8963-c9da4e7017b2@gmail.com \
    --to=ychuang570808@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jirislaby@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lee@kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=mjchen@nuvoton.com \
    --cc=mturquette@baylibre.com \
    --cc=p.zabel@pengutronix.de \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=schung@nuvoton.com \
    --cc=ychuang3@nuvoton.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).