linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergej Pupykin <ml@sergej.pp.ru>
To: linux-serial@vger.kernel.org
Subject: WCH CH-382 support: help with patching
Date: Wed, 22 Jan 2014 15:51:54 +0400	[thread overview]
Message-ID: <87iotc6xph.wl%ml@sergej.pp.ru> (raw)

[-- Attachment #1: Type: text/plain, Size: 1001 bytes --]


Hi,

I have wch ch382 board which is mostly similar to already supported
ch353 I think. But 382 works in PCI-E slot whereas 353 in PCI.

I've written a patch and LPT looks working with
parport_serial. (Actually it works even using "modprobe parport_pc
io=0xe100")

But I have some problems with ttyS*.

Here are changes between CH353-2S1P and CH382-2S1P in vendor driver:

           CH353  CH382
type       16550  16750
IntrBar    3      0
IntrOffset 0x0F   0xE9
ofs1       0,0    0xC0,0xC8

As I understand last line is offset to uart I/O ports, so I put 0xC0
to pci_parport_serial_boards[].first_offset and uart_offset is 8, so
/sys/class/tty/ttyS0/port is 0xE0C0
/sys/class/tty/ttyS1/port is 0xE0C8
and lspci -v reports "I/O ports at e000 [size=256]"

But I cannot find where should I put interrupt parameters IntrBar and
IntrOffset. Probably this is the reason why ttyS* don't work.

Here is vendor WCH driver:
https://home.p5n.pp.ru/~sergej/files/wch-driver.tar.gz

My patch is in attachment.


[-- Attachment #2: wch-serial.diff --]
[-- Type: application/octet-stream, Size: 3359 bytes --]

diff -wbBur linux-3.12.org/drivers/parport/parport_serial.c linux-3.12/drivers/parport/parport_serial.c
--- linux-3.12.org/drivers/parport/parport_serial.c	2013-11-04 03:41:51.000000000 +0400
+++ linux-3.12/drivers/parport/parport_serial.c	2014-01-22 14:00:43.825687591 +0400
@@ -63,6 +63,7 @@
 	timedia_9079b,
 	timedia_9079c,
 	wch_ch353_2s1p,
+	wch_ch382_2s1p,
 	sunix_2s1p,
 };
 
@@ -149,6 +150,7 @@
 	/* timedia_9079b */             { 1, { { 2, 3 }, } },
 	/* timedia_9079c */             { 1, { { 2, 3 }, } },
 	/* wch_ch353_2s1p*/             { 1, { { 2, -1}, } },
+	/* wch_ch382_2s1p*/             { 1, { { 2, -1}, } },
 	/* sunix_2s1p */                { 1, { { 3, -1 }, } },
 };
 
@@ -254,6 +256,7 @@
 
 	/* WCH CARDS */
 	{ 0x4348, 0x7053, 0x4348, 0x3253, 0, 0, wch_ch353_2s1p},
+	{ 0x1c00, 0x3250, 0x1c00, 0x3250, 0, 0, wch_ch382_2s1p},
 
 	/*
 	 * More SUNIX variations. At least one of these has part number
@@ -485,6 +488,13 @@
 		.base_baud      = 115200,
 		.uart_offset    = 8,
 	},
+	[wch_ch382_2s1p] = {
+		.flags          = FL_BASE0,
+		.num_ports      = 2,
+		.base_baud      = 115200,
+		.uart_offset    = 8,
+		.first_offset   = 0xC0,
+	},
 	[sunix_2s1p] = {
 		.flags		= FL_BASE0|FL_BASE_BARS,
 		.num_ports	= 2,
diff -wbBur linux-3.12.org/drivers/tty/serial/8250/8250_pci.c linux-3.12/drivers/tty/serial/8250/8250_pci.c
--- linux-3.12.org/drivers/tty/serial/8250/8250_pci.c	2013-11-04 03:41:51.000000000 +0400
+++ linux-3.12/drivers/tty/serial/8250/8250_pci.c	2014-01-22 13:59:59.585688109 +0400
@@ -1521,6 +1521,22 @@
 	return pci_default_setup(priv, board, port, idx);
 }
 
+static int
+pci_wch_ch382_setup(struct serial_private *priv,
+                    const struct pciserial_board *board,
+                    struct uart_8250_port *port, int idx)
+{
+#if 0
+	unsigned int bar = FL_GET_BASE(board->flags);
+	unsigned int offset = board->first_offset;
+	offset += idx * board->uart_offset;
+	return setup_port(priv, port, bar, offset, board->reg_shift);
+#endif
+	port->port.flags |= UPF_FIXED_TYPE;
+	port->port.type = PORT_16750;
+	return pci_default_setup(priv, board, port, idx);
+}
+
 #define PCI_VENDOR_ID_SBSMODULARIO	0x124B
 #define PCI_SUBVENDOR_ID_SBSMODULARIO	0x124B
 #define PCI_DEVICE_ID_OCTPRO		0x0001
@@ -1554,10 +1570,12 @@
 #define PCI_DEVICE_ID_PLX_CRONYX_OMEGA	0xc001
 #define PCI_DEVICE_ID_INTEL_PATSBURG_KT 0x1d3d
 #define PCI_VENDOR_ID_WCH		0x4348
+#define PCIE_VENDOR_ID_WCH		0x1c00
 #define PCI_DEVICE_ID_WCH_CH352_2S	0x3253
 #define PCI_DEVICE_ID_WCH_CH353_4S	0x3453
 #define PCI_DEVICE_ID_WCH_CH353_2S1PF	0x5046
 #define PCI_DEVICE_ID_WCH_CH353_2S1P	0x7053
+#define PCIE_DEVICE_ID_WCH_CH382_2S1P	0x3250
 #define PCI_VENDOR_ID_AGESTAR		0x5372
 #define PCI_DEVICE_ID_AGESTAR_9375	0x6872
 #define PCI_VENDOR_ID_ASIX		0x9710
@@ -2182,6 +2200,14 @@
 		.subdevice	= PCI_ANY_ID,
 		.setup		= pci_wch_ch353_setup,
 	},
+	/* WCH CH382 2S1P card (16750 clone) */
+	{
+		.vendor         = PCIE_VENDOR_ID_WCH,
+		.device         = PCIE_DEVICE_ID_WCH_CH382_2S1P,
+		.subvendor      = PCI_ANY_ID,
+		.subdevice      = PCI_ANY_ID,
+		.setup          = pci_wch_ch382_setup,
+	},
 	/*
 	 * ASIX devices with FIFO bug
 	 */
@@ -3212,6 +3238,7 @@
 
 	/* multi-io cards handled by parport_serial */
 	{ PCI_DEVICE(0x4348, 0x7053), }, /* WCH CH353 2S1P */
+	{ PCI_DEVICE(0x1c00, 0x3250), }, /* WCH CH382 2S1P */
 };
 
 /*

             reply	other threads:[~2014-01-22 12:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-22 11:51 Sergej Pupykin [this message]
2014-07-09 14:47 ` WCH CH-382 support: help with patching Matwey V. Kornilov
2014-10-14 15:13   ` Sergej Pupykin

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=87iotc6xph.wl%ml@sergej.pp.ru \
    --to=ml@sergej.pp.ru \
    --cc=linux-serial@vger.kernel.org \
    /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).