All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ji-Ze Hong (Peter Hong)" <hpeter@gmail.com>
To: gregkh@linuxfoundation.org, jirislaby@kernel.org
Cc: ilpo.jarvinen@linux.intel.com, l.sanfilippo@kunbus.com,
	andy.shevchenko@gmail.com, peter_hong@fintek.com.tw,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Ji-Ze Hong (Peter Hong)" <hpeter+linux_kernel@gmail.com>
Subject: [PATCH] serial: 8250_fintek: Add using BIOS IRQ default setting
Date: Fri, 17 Feb 2023 16:49:53 +0800	[thread overview]
Message-ID: <20230217084953.2580-1-hpeter+linux_kernel@gmail.com> (raw)

In 8250_fintek.c probe_setup_port(), we'll detect the IRQ trigger mode by
irq_get_irq_data() and pass it to fintek_8250_set_irq_mode(). If detected
Edge mode, we'll set the UART with Edge/High mode, otherwise Level/Low.

But in some motherboard, The APIC maybe setting to Level/High. In this case
the driver will setting wrong configuration into UART. So we add a option
to kernel parameter to control the driver as following:

	fintek_uart_irq_mode_override= [SERIAL]
		{default, bios}
		If the parameter is "default", the driver will using
		former IRQ override methed(By IRQ trigger type).
		otherwise, we'll don't change the UART IRQ setting.

Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
---
 drivers/tty/serial/8250/8250_fintek.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_fintek.c b/drivers/tty/serial/8250/8250_fintek.c
index dba5950b8d0e..c5fea0a7c79b 100644
--- a/drivers/tty/serial/8250/8250_fintek.c
+++ b/drivers/tty/serial/8250/8250_fintek.c
@@ -92,6 +92,9 @@
 #define F81866_UART_CLK_18_432MHZ BIT(0)
 #define F81866_UART_CLK_24MHZ BIT(1)

+#define FINTEK_IRQ_MODE_BY_DETECT	0
+#define FINTEK_IRQ_MODE_BY_BIOS		1
+
 struct fintek_8250 {
 	u16 pid;
 	u16 base_port;
@@ -99,6 +102,24 @@ struct fintek_8250 {
 	u8 key;
 };

+static int not_override_irq_mode = FINTEK_IRQ_MODE_BY_DETECT;
+
+static int __init parse_uart_irq_mode_override(char *arg)
+{
+	if (!arg)
+		return -EINVAL;
+
+	if (strcmp(arg, "bios") == 0)
+		not_override_irq_mode = FINTEK_IRQ_MODE_BY_BIOS;
+	else if (strcmp(arg, "default") == 0)
+		not_override_irq_mode = FINTEK_IRQ_MODE_BY_DETECT;
+	else
+		return -EINVAL;
+
+	return 0;
+}
+early_param("fintek_uart_irq_mode_override", parse_uart_irq_mode_override);
+
 static u8 sio_read_reg(struct fintek_8250 *pdata, u8 reg)
 {
 	outb(reg, pdata->base_port + ADDR_PORT);
@@ -248,6 +269,12 @@ static int fintek_8250_rs485_config(struct uart_port *port,

 static void fintek_8250_set_irq_mode(struct fintek_8250 *pdata, bool is_level)
 {
+	if (not_override_irq_mode == FINTEK_IRQ_MODE_BY_BIOS) {
+		pr_info("Fintek UART(%04x) irq mode is using BIOS default",
+				pdata->pid);
+		return;
+	}
+
 	sio_write_reg(pdata, LDN, pdata->index);

 	switch (pdata->pid) {
--
2.17.1

             reply	other threads:[~2023-02-17  8:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-17  8:49 Ji-Ze Hong (Peter Hong) [this message]
2023-02-17  9:17 ` [PATCH] serial: 8250_fintek: Add using BIOS IRQ default setting Greg KH
2023-02-17  9:18 ` Greg KH
2023-02-17 12:32 ` kernel test robot

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=20230217084953.2580-1-hpeter+linux_kernel@gmail.com \
    --to=hpeter@gmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpeter+linux_kernel@gmail.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jirislaby@kernel.org \
    --cc=l.sanfilippo@kunbus.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=peter_hong@fintek.com.tw \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.