# PCI-E OXPCIe952 dual serial card



## prix (Mar 23, 2012)

Hello!

I have been trying to setup PCI-E OXPCIe952 dual serial card which I got from Ebay. It's an "el cheapo" serial expansion card but I thought it should work since this chipset seems to be supported under freebsd FreeBSD.

This is `pciconf -lv`:

```
# pciconf -lv:

none1@pci0:2:0:0:       class=0x070002 card=0xc1401415 chip=0xc1401415 rev=0x00 hdr=0x00
    vendor     = 'Oxford Semiconductor Ltd'
    class      = simple comms
    subclass   = UART
none2@pci0:2:0:1:       class=0x070002 card=0xc1411415 chip=0xc1411415 rev=0x00 hdr=0x00
    vendor     = 'Oxford Semiconductor Ltd'
    class      = simple comms
    subclass   = UART
```

I have checked under pucdata.c:

```
{   0x1415, 0xc138, 0xffff, 0,
            "Oxford Semiconductor OXPCIe952 UARTs",
            DEFAULT_RCLK * 0x22,
            PUC_PORT_NONSTANDARD, 0x10, 0, -1,
            .config_function = puc_config_oxford_pcie
        },
```

I manually edited pucdata.c and added chip 0xc140:

```
{   0x1415, 0xc140, 0xffff, 0,
            "Oxford Semiconductor OXPCIe952 UARTs",
            DEFAULT_RCLK * 0x22,
            PUC_PORT_NONSTANDARD, 0x10, 0, -1,
            .config_function = puc_config_oxford_pcie
        },
```

I rebooted the machine and hoped for the best; nothing changes. Can you tell me what I am doing wrong?

This is *dmesg | grep -i pci2*:

```
pci2: <ACPI PCI bus> on pcib2
pci2: <simple comms, UART> at device 0.0 (no driver attached)
pci2: <simple comms, UART> at device 0.1 (no driver attached)
```

And I am using GENERIC kernel with FreeBSD 9.0. (kernel modules puc, uart, ppc)


Thanks for answers!

Prix


----------



## Uniballer (Mar 23, 2012)

You'll need to rebuild the kernel for there to be any hope of your changes being incorporated.

At a minimum:


```
cd /usr/src
make buildkernel
make installkernel
```


----------



## prix (Mar 23, 2012)

Will try that... I also thought this it the case since this pucdat.c is C source but didn't know how to "apply" changes to the file 

CU, Prix


----------



## prix (Mar 24, 2012)

Hello!

Now I have recompiled kernel with modified pucdata.c.
This is added description of the chip:

```
{   0x1415, 0xc140, 0xffff, 0,
            "Oxford Semiconductor OXPCIe952 UARTs",
            DEFAULT_RCLK * 0x22,
            PUC_PORT_NONSTANDARD, 0x10, 0, -1,
            .config_function = puc_config_oxford_pcie
        },

        {   0x1415, 0xc141, 0xffff, 0,
            "Oxford Semiconductor OXPCIe952 UARTs",
            DEFAULT_RCLK * 0x22,
            PUC_PORT_NONSTANDARD, 0x10, 0, -1,
            .config_function = puc_config_oxford_pcie
        },
```

Now puc driver is asigned with pci-e serial card but there is no UART:

output of *dmesg | grep -i pci2*:

```
pci2: <ACPI PCI bus> on pcib2
puc0: <Oxford Semiconductor OXPCIe952 UARTs> port 0xd800-0xd807 irq 18 at device 0.0 on pci2
puc1: <Oxford Semiconductor OXPCIe952 UARTs> port 0xd400-0xd407 irq 19 at device 0.1 on pci2
```

output of *dmesg | grep -i uart*:

```
puc0: <Oxford Semiconductor OXPCIe952 UARTs> port 0xd800-0xd807 irq 18 at device 0.0 on pci2
puc0: -2133601977 UARTs detected
puc1: <Oxford Semiconductor OXPCIe952 UARTs> port 0xd400-0xd407 irq 19 at device 0.1 on pci2
puc1: -2133601977 UARTs detected
```

I was at least expecting something like this:

```
uart0: <16550 or compatible> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0
uart0: [FILTER]
```

Is there anything else that I should do... Where to look for somekind of output/logs? 
ps. Also I don't have any /dev/ttyu..

Thanks!


----------



## hishnik (Nov 15, 2019)

Did you solve this issue?
Same here, but FreeBSDs 12.0 and 12.1 are hangs or panics with this code in kernel when such expresscard plugged in.


----------



## Phishfry (Nov 15, 2019)

I addition to adding the VID+PID to the driver you must enable the new UART's in /boot/device.hints
Take a look at the file and replicate the existing UART's with your new ones in /boot/devive.hints


----------



## hishnik (Nov 18, 2019)

Thank you for paying attention to my problems.

Can you give me a link to manual or smth. on this hints?
I need to insert this card in runtime. device.hints can help me with this?
Where should I get all those bus, port, flags, irq and hint.uart.* device numbers for the new expresscard COM-ports?

Thank you very much for setting me on the proper path.


----------



## Phishfry (Nov 18, 2019)

hishnik said:


> Where should I get all those bus, port, flags, irq and hint.uart.* device numbers for the new expresscard COM-ports?


After inserting expresscard check here: `pciconf -lvcbe`

More reading for you:








						Frequently Asked Questions for FreeBSD 12.X and 13.X
					

Frequently Asked Questions, and answers, covering all aspects of FreeBSD




					www.freebsd.org
				








						puc(4)
					






					www.freebsd.org
				





			Adding support for MosChip 9912 PCIe (serial/parallel) cards
		









						PCIe 6 port serial card
					

Hello, everyone!  I have STLab I-472 PCIe 6 port serial card with Moschip MCS9900 and Moschip MCS9922 chips on it, and I'm trying to get it working with FreeBSD 10.3 (amd64, generic kernel).  According to what I see in the sources of uart driver both chips are supported by the driver:  static...




					forums.freebsd.org


----------



## Phishfry (Nov 18, 2019)

In some cases you might need to disable the UART's in /boot/device.hints. Why?
Well your laptop may have serial ports built on the motherboard even though there are no DB9 connectors.
Here is my HP laptop's non-existent serial port:
`dmesg | grep uart`
uart2: <Intel Panther Point KT Controller> port 0x5050-0x5057 mem 0xd443b000-0xd443bfff irq 17 at device 22.3 on pci0
This laptop has zero serial connectors yet still has a uart showing.
Perhaps this could interfere with an add on serial port expresscard.


----------



## hishnik (Nov 18, 2019)

There is no any built-in uarts or serial ports in my laptop. 
It's lenovo x230t.
``dmesg | grep uart`` gives me nothing.
device.hints has default uart records in it:

```
...
hint.uart.0.at="isa"
hint.uart.0.port="0x3F8"
hint.uart.0.flags="0x10"
hint.uart.0.irq="4"
hint.uart.1.at="isa"
hint.uart.1.port="0x2F8"
hint.uart.1.irq="3"
...
```

expresscard has 2 RS232C COM-ports.

As far as I can see, I could change records in device.hints from 
`hint.uart.*.at="isa"` 
to 
`hint.uart.*.at="pci"`. 
Am I right?
Where can I get correct values for 'flags', 'port' addresses and 'IRQs'?


----------



## Phishfry (Nov 19, 2019)

hishnik said:


> Where can I get correct values for 'flags', 'port' addresses and 'IRQs'?


Those will come from your `dmesg` output.
With no UART's showing in dmesg (or pciconf for hot plugged devices) that means your device is not recognized by FreeBSD.
You might need to do some more work on the source code for the puc driver.
You did recompile after your edits correct?
Does anything show up in the terminal when you hotplug the device.
Why do you need to hotplug the device anyway? That may take extra tweaks to get working.



hishnik said:


> Am I right?


I am unsure what bus the express cards would use.
There is a chance that /boot/device.hints might not need any entries.
You must get the card showing correctly in pciconf before worrying about /boot/device.hints.


----------



## hishnik (Nov 19, 2019)

Phishfry said:


> Those will come from your `dmesg` output.
> With no UART's showing in dmesg (or pciconf for hot plugged devices) that means your device is not recognized by FreeBSD.


When kernel is compiled with no modifications to pucdata.c it shows me the same as topicstarter wrote earlier:


```
pci3: <ACPI PCI bus> on pcib3
pci3: <simple comms, UART> at device 0.0 (no driver attached)
pci3: <simple comms, UART> at device 0.1 (no driver attached)
```

Now I'm recompiling my kernel, so more accurate results I'll give you later.
If memory serves me right, I had the same result.



Phishfry said:


> You might need to do some more work on the source code for the puc driver.
> You did recompile after your edits correct?
> Does anything show up in the terminal when you hotplug the device.


I recompiled my kernel with changes in pucdata.c, of course.
With default kernel results like above `pci3:...`



Phishfry said:


> Why do you need to hotplug the device anyway? That may take extra tweaks to get working.


I have my boot partition on external card, and this card is seizing my expresscard slot.



Phishfry said:


> I am unsure what bus the express cards would use.


It's pci bus in any case.
...

I'll give you more results after recompiling my kernel with default pucdata.c .

<...some time later...>

`pciconf -vl | grep 1415 -A 3`

```
none1@pci0:4:0:0:    class=0x070002 card=0xc1401415 chip=0xc1401415 rev=0x00 hdr=0x00
    vendor     = 'Oxford Semiconductor Ltd'
    class      = simple comms
    subclass   = UART
none2@pci0:4:0:1:    class=0x070002 card=0xc1411415 chip=0xc1411415 rev=0x00 hdr=0x00
    vendor     = 'Oxford Semiconductor Ltd'
    class      = simple comms
    subclass   = UART
```

`dmesg|grep pci3`

```
pci3: <ACPI PCI bus> on pcib3
pci3: <simple comms, UART> at device 0.0 (no driver attached)
pci3: <simple comms, UART> at device 0.1 (no driver attached)
```

Maybe I have to edit ./sys/dev/uart/uart_bus_pci.c ?

<...some more time spent...>
After changing uart_bus_pci.c and pucdata.c and kernel recompile I got system hang after inserting card.
In 1 of 3 insert cases it writes kernel message, like: 

```
pci3: <ACPI PCI bus> on pcib3
puc0: <Oxford Semiconductor OXPCIe952 UARTs> port 0x4000-0x4007 at device 0.0 on pci3
puc0: 8 UARTs detected
puc0: <Oxford Semiconductor OXPCIe952 UARTs> at device 0.1 on pci3
```
...and after such output I'm getting total OS hangup.

Why it sees 8 UARTs at first puc?


----------

