linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Darren Hart <dvhart@linux.intel.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Darren Hart <dvhart@linux.intel.com>,
	Tomoya MORINAGA <tomoya.rohm@gmail.com>,
	Feng Tang <feng.tang@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Alan Cox <alan@linux.intel.com>,
	linux-serial@vger.kernel.org
Subject: [PATCH 2/4] pch_uart: Add Fish River Island II uart clock quirks
Date: Wed, 29 Feb 2012 10:24:45 -0800	[thread overview]
Message-ID: <74aee0c6f54f3cb6b55578163020d243ae79ae49.1330539597.git.dvhart@linux.intel.com> (raw)
In-Reply-To: <8b7e59a1f360a5f1ca9382ff53d9be941ef07f7b.1330539597.git.dvhart@linux.intel.com>
In-Reply-To: <cover.1330539597.git.dvhart@linux.intel.com>

Add support for the Fish River Island II (FRI2) UART clock following the CM-iTC
quirk handling mechanism. Depending on the firmware installed on the device, the
FRI2 uses a 48MHz or a 64MHz UART clock. This is detected with DMI strings.

Add similar UART clock quirk handling to the pch_console_setup() function to
enable kernel messages on boards with non-standard UART clocks.

Per Alan's suggestion, abstract out UART clock selection into
pch_uart_get_uartclk() to avoid code duplication.

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
CC: Tomoya MORINAGA <tomoya.rohm@gmail.com>
CC: Feng Tang <feng.tang@intel.com>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CC: Alan Cox <alan@linux.intel.com>
CC: linux-serial@vger.kernel.org
---
 drivers/tty/serial/pch_uart.c |   42 +++++++++++++++++++++++++++-------------
 1 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index c565817..3a2b0ae 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -203,7 +203,10 @@ enum {
 
 #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
 
-#define DEFAULT_UARTCLK 1843200 /* 1.8432MHz */
+#define DEFAULT_UARTCLK   1843200 /*   1.8432 MHz */
+#define CMITC_UARTCLK   192000000 /* 192.0000 MHz */
+#define FRI2_64_UARTCLK  64000000 /*  64.0000 MHz */
+#define FRI2_48_UARTCLK  48000000 /*  48.0000 MHz */
 
 struct pch_uart_buffer {
 	unsigned char *buf;
@@ -292,6 +295,26 @@ static const int trigger_level_64[4] = { 1, 16, 32, 56 };
 static const int trigger_level_16[4] = { 1, 4, 8, 14 };
 static const int trigger_level_1[4] = { 1, 1, 1, 1 };
 
+/* Return UART clock, checking for board specific clocks. */
+static int pch_uart_get_uartclk(void)
+{
+	const char *cmp;
+
+	cmp = dmi_get_system_info(DMI_BOARD_NAME);
+	if (cmp && strstr(cmp, "CM-iTC"))
+		return CMITC_UARTCLK;
+
+	cmp = dmi_get_system_info(DMI_BIOS_VERSION);
+	if (cmp && strnstr(cmp, "FRI2", 4))
+		return FRI2_64_UARTCLK;
+
+	cmp = dmi_get_system_info(DMI_PRODUCT_NAME);
+	if (cmp && strstr(cmp, "Fish River Island II"))
+		return FRI2_48_UARTCLK;
+
+	return DEFAULT_UARTCLK;
+}
+
 static void pch_uart_hal_request(struct pci_dev *pdev, int fifosize,
 				 int uartclk)
 {
@@ -1506,8 +1529,7 @@ static int __init pch_console_setup(struct console *co, char *options)
 	if (!port || (!port->iobase && !port->membase))
 		return -ENODEV;
 
-	/* setup uartclock */
-	port->uartclk = DEFAULT_UARTCLK;
+	port->uartclk = pch_uart_get_uartclk();
 
 	if (options)
 		uart_parse_options(options, &baud, &parity, &bits, &flow);
@@ -1550,10 +1572,9 @@ static struct eg20t_port *pch_uart_init_port(struct pci_dev *pdev,
 	unsigned int iobase;
 	unsigned int mapbase;
 	unsigned char *rxbuf;
-	int fifosize, uartclk;
+	int fifosize;
 	int port_type;
 	struct pch_uart_driver_data *board;
-	const char *board_name;
 
 	board = &drv_dat[id->driver_data];
 	port_type = board->port_type;
@@ -1566,13 +1587,6 @@ static struct eg20t_port *pch_uart_init_port(struct pci_dev *pdev,
 	if (!rxbuf)
 		goto init_port_free_txbuf;
 
-	uartclk = DEFAULT_UARTCLK;
-
-	/* quirk for CM-iTC board */
-	board_name = dmi_get_system_info(DMI_BOARD_NAME);
-	if (board_name && strstr(board_name, "CM-iTC"))
-		uartclk = 192000000; /* 192.0MHz */
-
 	switch (port_type) {
 	case PORT_UNKNOWN:
 		fifosize = 256; /* EG20T/ML7213: UART0 */
@@ -1597,7 +1611,7 @@ static struct eg20t_port *pch_uart_init_port(struct pci_dev *pdev,
 	priv->rxbuf.size = PAGE_SIZE;
 
 	priv->fifo_size = fifosize;
-	priv->uartclk = uartclk;
+	priv->uartclk = pch_uart_get_uartclk();
 	priv->port_type = PORT_MAX_8250 + port_type + 1;
 	priv->port.dev = &pdev->dev;
 	priv->port.iobase = iobase;
@@ -1614,7 +1628,7 @@ static struct eg20t_port *pch_uart_init_port(struct pci_dev *pdev,
 	spin_lock_init(&priv->port.lock);
 
 	pci_set_drvdata(pdev, priv);
-	pch_uart_hal_request(pdev, fifosize, uartclk);
+	pch_uart_hal_request(pdev, fifosize, priv->uartclk);
 
 #ifdef CONFIG_SERIAL_PCH_UART_CONSOLE
 	pch_uart_ports[board->line_no] = priv;
-- 
1.7.6.5


  parent reply	other threads:[~2012-02-29 18:26 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-29 18:24 [PATCH 0/4 V2] pch_uart: Cleanups, board quirks, and user uartclk parameter Darren Hart
2012-02-29 18:24 ` [PATCH 1/4] pch_uart: Use uartclk instead of base_baud Darren Hart
2012-03-08 18:58   ` Greg Kroah-Hartman
2012-02-29 18:24 ` Darren Hart [this message]
2012-02-29 18:24 ` [PATCH 3/4] pch_uart: Add user_uartclk parameter Darren Hart
2012-03-08 18:56   ` Greg Kroah-Hartman
2012-03-08 21:10     ` Darren Hart
2012-02-29 18:24 ` [PATCH 4/4] pch_uart: Use existing default_baud in setup_console Darren Hart
2012-03-01  0:38 ` [PATCH 0/4 V2] pch_uart: Cleanups, board quirks, and user uartclk parameter Tomoya MORINAGA
2012-03-01  0:47   ` Darren Hart
2012-03-01  0:53     ` Greg Kroah-Hartman
2012-03-07 18:32       ` Darren Hart
2012-03-07 18:39         ` Greg Kroah-Hartman
2012-03-01  1:06     ` Tomoya MORINAGA
2012-03-01  1:12       ` Darren Hart
2012-03-01  2:06         ` Tomoya MORINAGA
2012-03-01  2:07           ` Darren Hart
2012-03-01  2:27             ` Tomoya MORINAGA
2012-03-01  2:40         ` Feng Tang
2012-03-01 19:29           ` Darren Hart
  -- strict thread matches above, loose matches on Subject: below --
2012-02-22  1:59 [PATCH 1/4] pch_uart: Use uartclk instead of base_baud Darren Hart
2012-02-22  1:59 ` [PATCH 0/4] pch_uart: Cleanups, board quirks, and user uartclk parameter Darren Hart
2012-02-22  1:59   ` [PATCH 2/4] pch_uart: Add Fish River Island II uart clock quirks Darren Hart
2012-02-22  8:52     ` Alan Cox
2012-02-22  9:46       ` Darren Hart
2012-02-24 21:53         ` Greg Kroah-Hartman
2012-02-24 22:25           ` Darren Hart
2012-02-24 23:39             ` Greg Kroah-Hartman

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=74aee0c6f54f3cb6b55578163020d243ae79ae49.1330539597.git.dvhart@linux.intel.com \
    --to=dvhart@linux.intel.com \
    --cc=alan@linux.intel.com \
    --cc=feng.tang@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=tomoya.rohm@gmail.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).