linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* WCH CH-382 support: help with patching
@ 2014-01-22 11:51 Sergej Pupykin
  2014-07-09 14:47 ` Matwey V. Kornilov
  0 siblings, 1 reply; 3+ messages in thread
From: Sergej Pupykin @ 2014-01-22 11:51 UTC (permalink / raw)
  To: linux-serial

[-- 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 */
 };
 
 /*

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: WCH CH-382 support: help with patching
  2014-01-22 11:51 WCH CH-382 support: help with patching Sergej Pupykin
@ 2014-07-09 14:47 ` Matwey V. Kornilov
  2014-10-14 15:13   ` Sergej Pupykin
  0 siblings, 1 reply; 3+ messages in thread
From: Matwey V. Kornilov @ 2014-07-09 14:47 UTC (permalink / raw)
  To: linux-serial


Hi,

I am just received the similar board, but it is strange that I have
different device-id, which is 3050.

Where did you get vendor driver from?


22.01.2014 15:51, Sergej Pupykin пишет:
> 
> 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.
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: WCH CH-382 support: help with patching
  2014-07-09 14:47 ` Matwey V. Kornilov
@ 2014-10-14 15:13   ` Sergej Pupykin
  0 siblings, 0 replies; 3+ messages in thread
From: Sergej Pupykin @ 2014-10-14 15:13 UTC (permalink / raw)
  To: Matwey V. Kornilov; +Cc: linux-serial


At Wed, 09 Jul 2014 18:47:44 +0400,
"Matwey V. Kornilov" <matwey.kornilov@gmail.com> wrote:
> 
> 
> Hi,
> 
> I am just received the similar board, but it is strange that I have
> different device-id, which is 3050.
> 
> Where did you get vendor driver from?

I think driver was on CD that I got with card.

I've made patch for current git and sending it now.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-10-14 15:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-22 11:51 WCH CH-382 support: help with patching Sergej Pupykin
2014-07-09 14:47 ` Matwey V. Kornilov
2014-10-14 15:13   ` Sergej Pupykin

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).