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

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Andre Albsmeier
I have a MosChip 9912 card (PCIe card with 1 parallel and 2 serial
ports) sitting here which does not get detected on 11.1. I tried
to simply add it to the uart and ppc drivers with

--- sys/dev/uart/uart_bus_pci.c.ORI     2018-02-12 06:17:57.000000000 +0100
+++ sys/dev/uart/uart_bus_pci.c 2018-03-01 18:27:05.212040000 +0100
@@ -158,6 +158,8 @@
        "MosChip MCS9904 PCIe to Peripheral Controller", 0x10 },
 { 0x9710, 0x9922, 0xa000, 0x1000,
        "MosChip MCS9922 PCIe to Peripheral Controller", 0x10 },
+{ 0x9710, 0x9912, 0xa000, 0x1000,
+       "MosChip MCS9912 PCIe to Peripheral Controller", 0x10 },
 { 0xdeaf, 0x9051, 0xffff, 0, "Middle Digital PC Weasel Serial Port", 0x10 },
 { 0xffff, 0, 0xffff, 0, NULL, 0, 0}
 };


and

--- sys/dev/ppc/ppc_pci.c.ORI   2017-09-03 17:55:53.000000000 +0200
+++ sys/dev/ppc/ppc_pci.c       2018-03-01 18:27:23.000000000 +0100
@@ -93,6 +93,7 @@
        { 0x98659710, "MosChip MCS9865 1284 Printer port", 0x10 },
        { 0x99009710, "MosChip MCS9900 PCIe to Peripheral Controller", 0x10 },
        { 0x99019710, "MosChip MCS9901 PCIe to Peripheral Controller", 0x10 },
+       { 0x99129710, "MosChip MCS9912 PCIe to Peripheral Controller", 0x10 },
        { 0xffff }
 };


Now, when loading ppc.ko and uart.ko it gives me in dmesg:

ppc1: <MosChip MCS9912 PCIe to Peripheral Controller> port 0xd010-0xd017,0xd000-0xd007 mem 0x89201000-0x89201fff,0x89200000-0x89200fff irq 20 at device 0.2 on pci9
ppc1: Generic chipset (EPP/NIBBLE) in COMPATIBLE mode
ppbus0: <Parallel port bus> on ppc1
lpt0: <Printer> on ppbus0
lpt0: Interrupt-driven port
driver bug: Unable to set devclass (class: ppc devname: (unknown))
ppc0: parallel port not found.
ppc0: parallel port not found.
uart2: <MosChip MCS9912 PCIe to Peripheral Controller> port 0xd030-0xd037 mem 0x89205000-0x89205fff,0x89204000-0x89204fff irq 22 at device 0.0 on pci9
uart3: <MosChip MCS9912 PCIe to Peripheral Controller> port 0xd020-0xd027 mem 0x89203000-0x89203fff,0x89202000-0x89202fff irq 23 at device 0.1 on pci9
driver bug: Unable to set devclass (class: uart devname: (unknown))
driver bug: Unable to set devclass (class: uart devname: (unknown))
driver bug: Unable to set devclass (class: ppc devname: (unknown))
uart4: <16550 or compatible> port 0x3e8-0x3ef irq 7 on acpi0

What am I missing here?
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

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

Daniel Eischen
On Fri, 2 Mar 2018, Andre Albsmeier wrote:

> I have a MosChip 9912 card (PCIe card with 1 parallel and 2 serial
> ports) sitting here which does not get detected on 11.1. I tried
> to simply add it to the uart and ppc drivers with
>
[ ... ]

Do you try adding similar support to puc_pci_devices[] in
sys/dev/puc/pucdata.c?

--
DE
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

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

Andre Albsmeier
On Fri, 02-Mar-2018 at 08:36:40 -0500, Daniel Eischen wrote:

> On Fri, 2 Mar 2018, Andre Albsmeier wrote:
>
> > I have a MosChip 9912 card (PCIe card with 1 parallel and 2 serial
> > ports) sitting here which does not get detected on 11.1. I tried
> > to simply add it to the uart and ppc drivers with
> >
> [ ... ]
>
> Do you try adding similar support to puc_pci_devices[] in
> sys/dev/puc/pucdata.c?

Just tried that:

@@ -1204,6 +1204,11 @@
            PUC_PORT_1S1P, 0x10, 4, 0,
        },
 
+{   0x9710, 0x9912, 0xa000, 0x3012,
+    "NetMos NM9912 Dual UART and 1284 Printer port",
+    DEFAULT_RCLK,
+    PUC_PORT_2S1P, 0x10, 4, 0,
+},
        {   0x9710, 0x9865, 0xa000, 0x3012,
            "NetMos NM9865 Dual UART and 1284 Printer port",
            DEFAULT_RCLK,

But the results are exactly the same. It also doesn't
matter if puc.ko is loaded at all.

        -Andre
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

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

Daniel Eischen
On Sat, 3 Mar 2018, Andre Albsmeier wrote:

> On Fri, 02-Mar-2018 at 08:36:40 -0500, Daniel Eischen wrote:
>> On Fri, 2 Mar 2018, Andre Albsmeier wrote:
>>
>>> I have a MosChip 9912 card (PCIe card with 1 parallel and 2 serial
>>> ports) sitting here which does not get detected on 11.1. I tried
>>> to simply add it to the uart and ppc drivers with
>>>
>> [ ... ]
>>
>> Do you try adding similar support to puc_pci_devices[] in
>> sys/dev/puc/pucdata.c?
>
> Just tried that:
>
> @@ -1204,6 +1204,11 @@
>            PUC_PORT_1S1P, 0x10, 4, 0,
>        },
>
> +{   0x9710, 0x9912, 0xa000, 0x3012,
> +    "NetMos NM9912 Dual UART and 1284 Printer port",
> +    DEFAULT_RCLK,
> +    PUC_PORT_2S1P, 0x10, 4, 0,
> +},
>        {   0x9710, 0x9865, 0xa000, 0x3012,
>            "NetMos NM9865 Dual UART and 1284 Printer port",
>            DEFAULT_RCLK,
>
> But the results are exactly the same. It also doesn't
> matter if puc.ko is loaded at all.

Are you sure your subvendor and subdevice are correct?  I would
add some device_printf()'s in puc_pci.c::puc_pci_match() and
boot with/enable bootverbose.  Try to see where it's failing.

--
DE
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

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

Andre Albsmeier
On Sat, 03-Mar-2018 at 10:53:20 -0500, Daniel Eischen wrote:

> On Sat, 3 Mar 2018, Andre Albsmeier wrote:
>
> > On Fri, 02-Mar-2018 at 08:36:40 -0500, Daniel Eischen wrote:
> >> On Fri, 2 Mar 2018, Andre Albsmeier wrote:
> >>
> >>> I have a MosChip 9912 card (PCIe card with 1 parallel and 2 serial
> >>> ports) sitting here which does not get detected on 11.1. I tried
> >>> to simply add it to the uart and ppc drivers with
> >>>
> >> [ ... ]
> >>
> >> Do you try adding similar support to puc_pci_devices[] in
> >> sys/dev/puc/pucdata.c?
> >
> > Just tried that:
> >
> > @@ -1204,6 +1204,11 @@
> >            PUC_PORT_1S1P, 0x10, 4, 0,
> >        },
> >
> > +{   0x9710, 0x9912, 0xa000, 0x3012,
> > +    "NetMos NM9912 Dual UART and 1284 Printer port",
> > +    DEFAULT_RCLK,
> > +    PUC_PORT_2S1P, 0x10, 4, 0,
> > +},
> >        {   0x9710, 0x9865, 0xa000, 0x3012,
> >            "NetMos NM9865 Dual UART and 1284 Printer port",
> >            DEFAULT_RCLK,
> >
> > But the results are exactly the same. It also doesn't
> > matter if puc.ko is loaded at all.
>
> Are you sure your subvendor and subdevice are correct?  I would

No ;-). I have to use: 0x9710, 0x9912, 0xa000, 0x2000,

Now I have the following behaviour:

When I load puc.ko I get:
puc0: <NetMos NM9912 Dual UART and 1284 Printer port> at device 0.2 on pci9

If I load ppc.ko now, I get:
ppc0: parallel port not found.

But if I unload puc and ppc and load ppc again, I get:

ppc0: <MosChip MCS9912 PCIe to Peripheral Controller> port 0xd000-0xd007,0xd008-0xd00f mem 0x89200000-0x89200fff irq 20 at device 0.2 on pci9
ppc0: Generic chipset (EPP/NIBBLE) in COMPATIBLE mode
ppbus0: <Parallel port bus> on ppc0
lpt0: <Printer> on ppbus0
lpt0: Interrupt-driven port

For all this I have to disable /boot/device.hints -- otherwise
the messages "driver bug: Unable to set devclass" comes back.

So I think there are two problems:

First the settings of the ISA stuff in /boot/device.hints conflicted
with the settings the driver probed. This would be easy to solve --
just disable them in /boot/device.hints.

Second it appears that ppc only attaches if puc did some kind of
initialisation first. But we have to detach puc so the ppc can attach.

        -Andre
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

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

Daniel Eischen
On Sat, 3 Mar 2018, Andre Albsmeier wrote:

> On Sat, 03-Mar-2018 at 10:53:20 -0500, Daniel Eischen wrote:
>> On Sat, 3 Mar 2018, Andre Albsmeier wrote:
>>
>>> On Fri, 02-Mar-2018 at 08:36:40 -0500, Daniel Eischen wrote:
>>>> On Fri, 2 Mar 2018, Andre Albsmeier wrote:
>>>>
>>>>> I have a MosChip 9912 card (PCIe card with 1 parallel and 2 serial
>>>>> ports) sitting here which does not get detected on 11.1. I tried
>>>>> to simply add it to the uart and ppc drivers with
>>>>>
>>>> [ ... ]
>>>>
>>>> Do you try adding similar support to puc_pci_devices[] in
>>>> sys/dev/puc/pucdata.c?
>>>
>>> Just tried that:
>>>
>>> @@ -1204,6 +1204,11 @@
>>>            PUC_PORT_1S1P, 0x10, 4, 0,
>>>        },
>>>
>>> +{   0x9710, 0x9912, 0xa000, 0x3012,
>>> +    "NetMos NM9912 Dual UART and 1284 Printer port",
>>> +    DEFAULT_RCLK,
>>> +    PUC_PORT_2S1P, 0x10, 4, 0,
>>> +},
>>>        {   0x9710, 0x9865, 0xa000, 0x3012,
>>>            "NetMos NM9865 Dual UART and 1284 Printer port",
>>>            DEFAULT_RCLK,
>>>
>>> But the results are exactly the same. It also doesn't
>>> matter if puc.ko is loaded at all.
>>
>> Are you sure your subvendor and subdevice are correct?  I would
>
> No ;-). I have to use: 0x9710, 0x9912, 0xa000, 0x2000,
>
> Now I have the following behaviour:
>
> When I load puc.ko I get:
> puc0: <NetMos NM9912 Dual UART and 1284 Printer port> at device 0.2 on pci9
>
> If I load ppc.ko now, I get:
> ppc0: parallel port not found.
>
> But if I unload puc and ppc and load ppc again, I get:
>
> ppc0: <MosChip MCS9912 PCIe to Peripheral Controller> port 0xd000-0xd007,0xd008-0xd00f mem 0x89200000-0x89200fff irq 20 at device 0.2 on pci9
> ppc0: Generic chipset (EPP/NIBBLE) in COMPATIBLE mode
> ppbus0: <Parallel port bus> on ppc0
> lpt0: <Printer> on ppbus0
> lpt0: Interrupt-driven port
>
> For all this I have to disable /boot/device.hints -- otherwise
> the messages "driver bug: Unable to set devclass" comes back.
>
> So I think there are two problems:
>
> First the settings of the ISA stuff in /boot/device.hints conflicted
> with the settings the driver probed. This would be easy to solve --
> just disable them in /boot/device.hints.
>
> Second it appears that ppc only attaches if puc did some kind of
> initialisation first. But we have to detach puc so the ppc can attach.

Strange.  Did you try setting puc_load="YES" in /boot/loader.conf
and rebooting?  Or are you just loading and unloading modules
for now?

--
DE
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

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

Andre Albsmeier
On Sat, 03-Mar-2018 at 14:41:58 -0500, Daniel Eischen wrote:

> On Sat, 3 Mar 2018, Andre Albsmeier wrote:
>
> > On Sat, 03-Mar-2018 at 10:53:20 -0500, Daniel Eischen wrote:
> >> On Sat, 3 Mar 2018, Andre Albsmeier wrote:
> >>
> >>> On Fri, 02-Mar-2018 at 08:36:40 -0500, Daniel Eischen wrote:
> >>>> On Fri, 2 Mar 2018, Andre Albsmeier wrote:
> >>>>
> >>>>> I have a MosChip 9912 card (PCIe card with 1 parallel and 2 serial
> >>>>> ports) sitting here which does not get detected on 11.1. I tried
> >>>>> to simply add it to the uart and ppc drivers with
> >>>>>
> >>>> [ ... ]
> >>>>
> >>>> Do you try adding similar support to puc_pci_devices[] in
> >>>> sys/dev/puc/pucdata.c?
> >>>
> >>> Just tried that:
> >>>
> >>> @@ -1204,6 +1204,11 @@
> >>>            PUC_PORT_1S1P, 0x10, 4, 0,
> >>>        },
> >>>
> >>> +{   0x9710, 0x9912, 0xa000, 0x3012,
> >>> +    "NetMos NM9912 Dual UART and 1284 Printer port",
> >>> +    DEFAULT_RCLK,
> >>> +    PUC_PORT_2S1P, 0x10, 4, 0,
> >>> +},
> >>>        {   0x9710, 0x9865, 0xa000, 0x3012,
> >>>            "NetMos NM9865 Dual UART and 1284 Printer port",
> >>>            DEFAULT_RCLK,
> >>>
> >>> But the results are exactly the same. It also doesn't
> >>> matter if puc.ko is loaded at all.
> >>
> >> Are you sure your subvendor and subdevice are correct?  I would
> >
> > No ;-). I have to use: 0x9710, 0x9912, 0xa000, 0x2000,
> >
> > Now I have the following behaviour:
> >
> > When I load puc.ko I get:
> > puc0: <NetMos NM9912 Dual UART and 1284 Printer port> at device 0.2 on pci9
> >
> > If I load ppc.ko now, I get:
> > ppc0: parallel port not found.
> >
> > But if I unload puc and ppc and load ppc again, I get:
> >
> > ppc0: <MosChip MCS9912 PCIe to Peripheral Controller> port 0xd000-0xd007,0xd008-0xd00f mem 0x89200000-0x89200fff irq 20 at device 0.2 on pci9
> > ppc0: Generic chipset (EPP/NIBBLE) in COMPATIBLE mode
> > ppbus0: <Parallel port bus> on ppc0
> > lpt0: <Printer> on ppbus0
> > lpt0: Interrupt-driven port
> >
> > For all this I have to disable /boot/device.hints -- otherwise
> > the messages "driver bug: Unable to set devclass" comes back.
> >
> > So I think there are two problems:
> >
> > First the settings of the ISA stuff in /boot/device.hints conflicted
> > with the settings the driver probed. This would be easy to solve --
> > just disable them in /boot/device.hints.
> >
> > Second it appears that ppc only attaches if puc did some kind of
> > initialisation first. But we have to detach puc so the ppc can attach.
>
> Strange.  Did you try setting puc_load="YES" in /boot/loader.conf
> and rebooting?  Or are you just loading and unloading modules
> for now?

The latter. After each successful try I reboot to get rid of that
magic initialisation puc does.

But maybe I am getting closer: The card has 2 serial and 1 parallel
port. But these 3 ports appear in pciconf as 3 seperate devices:

none7@pci0:9:0:0:       class=0x070002 card=0x1000a000 chip=0x99129710 rev=0x00 hdr=0x00
    vendor     = 'MosChip Semiconductor Technology Ltd.'
    device     = 'PCIe 9912 Multi-I/O Controller'
    class      = simple comms
    subclass   = UART
none8@pci0:9:0:1:       class=0x070002 card=0x1000a000 chip=0x99129710 rev=0x00 hdr=0x00
    vendor     = 'MosChip Semiconductor Technology Ltd.'
    device     = 'PCIe 9912 Multi-I/O Controller'
    class      = simple comms
    subclass   = UART
none9@pci0:9:0:2:       class=0x070103 card=0x2000a000 chip=0x99129710 rev=0x00 hdr=0x00
    vendor     = 'MosChip Semiconductor Technology Ltd.'
    device     = 'PCIe 9912 Multi-I/O Controller'
    class      = simple comms
    subclass   = parallel port

Looking at the source code of puc, I find a place where it checks
the number of ports a device provides and aborts if it has only
one port. This would match my understanding that puc only exists
in order to help uart and ppc to work with multi-port devices
where all ports are handled by a single device in pciconf.

Until now, I used PUC_PORT_2S1P in my puc entry. So puc assumes
that the card 0x2000a000 has 2 serial and 1 parallel port but
this is probably wrong as this 0x2000a000 card only has one
parallel port and the serials are handled by other devices.
So the correct entry would be PUC_PORT_1P but with one single
port puc does not attach.

If all this is correct, I assume that puc should be left alone
and ppc_pci.c is the thing I have to look at.

This also matches the fact that uart attaches well to these two
serial ports without the need of loading and unloading puc first
so there is probably some kind of device specific initialisation
missing in ppc_pci.c...

        -Andre
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

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

Stefan Blachmann
In the forums there is a thread where a guy had to download the chips'
datasheet to obtain the correct IDs to add to pucdata.c.

You find code and links here:
https://forums.freebsd.org/threads/pcie-6-port-serial-card.63489/

HTH

On 3/3/18, Andre Albsmeier <[hidden email]> wrote:

> On Sat, 03-Mar-2018 at 14:41:58 -0500, Daniel Eischen wrote:
>> On Sat, 3 Mar 2018, Andre Albsmeier wrote:
>>
>> > On Sat, 03-Mar-2018 at 10:53:20 -0500, Daniel Eischen wrote:
>> >> On Sat, 3 Mar 2018, Andre Albsmeier wrote:
>> >>
>> >>> On Fri, 02-Mar-2018 at 08:36:40 -0500, Daniel Eischen wrote:
>> >>>> On Fri, 2 Mar 2018, Andre Albsmeier wrote:
>> >>>>
>> >>>>> I have a MosChip 9912 card (PCIe card with 1 parallel and 2 serial
>> >>>>> ports) sitting here which does not get detected on 11.1. I tried
>> >>>>> to simply add it to the uart and ppc drivers with
>> >>>>>
>> >>>> [ ... ]
>> >>>>
>> >>>> Do you try adding similar support to puc_pci_devices[] in
>> >>>> sys/dev/puc/pucdata.c?
>> >>>
>> >>> Just tried that:
>> >>>
>> >>> @@ -1204,6 +1204,11 @@
>> >>>            PUC_PORT_1S1P, 0x10, 4, 0,
>> >>>        },
>> >>>
>> >>> +{   0x9710, 0x9912, 0xa000, 0x3012,
>> >>> +    "NetMos NM9912 Dual UART and 1284 Printer port",
>> >>> +    DEFAULT_RCLK,
>> >>> +    PUC_PORT_2S1P, 0x10, 4, 0,
>> >>> +},
>> >>>        {   0x9710, 0x9865, 0xa000, 0x3012,
>> >>>            "NetMos NM9865 Dual UART and 1284 Printer port",
>> >>>            DEFAULT_RCLK,
>> >>>
>> >>> But the results are exactly the same. It also doesn't
>> >>> matter if puc.ko is loaded at all.
>> >>
>> >> Are you sure your subvendor and subdevice are correct?  I would
>> >
>> > No ;-). I have to use: 0x9710, 0x9912, 0xa000, 0x2000,
>> >
>> > Now I have the following behaviour:
>> >
>> > When I load puc.ko I get:
>> > puc0: <NetMos NM9912 Dual UART and 1284 Printer port> at device 0.2 on
>> > pci9
>> >
>> > If I load ppc.ko now, I get:
>> > ppc0: parallel port not found.
>> >
>> > But if I unload puc and ppc and load ppc again, I get:
>> >
>> > ppc0: <MosChip MCS9912 PCIe to Peripheral Controller> port
>> > 0xd000-0xd007,0xd008-0xd00f mem 0x89200000-0x89200fff irq 20 at device
>> > 0.2 on pci9
>> > ppc0: Generic chipset (EPP/NIBBLE) in COMPATIBLE mode
>> > ppbus0: <Parallel port bus> on ppc0
>> > lpt0: <Printer> on ppbus0
>> > lpt0: Interrupt-driven port
>> >
>> > For all this I have to disable /boot/device.hints -- otherwise
>> > the messages "driver bug: Unable to set devclass" comes back.
>> >
>> > So I think there are two problems:
>> >
>> > First the settings of the ISA stuff in /boot/device.hints conflicted
>> > with the settings the driver probed. This would be easy to solve --
>> > just disable them in /boot/device.hints.
>> >
>> > Second it appears that ppc only attaches if puc did some kind of
>> > initialisation first. But we have to detach puc so the ppc can attach.
>>
>> Strange.  Did you try setting puc_load="YES" in /boot/loader.conf
>> and rebooting?  Or are you just loading and unloading modules
>> for now?
>
> The latter. After each successful try I reboot to get rid of that
> magic initialisation puc does.
>
> But maybe I am getting closer: The card has 2 serial and 1 parallel
> port. But these 3 ports appear in pciconf as 3 seperate devices:
>
> none7@pci0:9:0:0:       class=0x070002 card=0x1000a000 chip=0x99129710
> rev=0x00 hdr=0x00
>     vendor     = 'MosChip Semiconductor Technology Ltd.'
>     device     = 'PCIe 9912 Multi-I/O Controller'
>     class      = simple comms
>     subclass   = UART
> none8@pci0:9:0:1:       class=0x070002 card=0x1000a000 chip=0x99129710
> rev=0x00 hdr=0x00
>     vendor     = 'MosChip Semiconductor Technology Ltd.'
>     device     = 'PCIe 9912 Multi-I/O Controller'
>     class      = simple comms
>     subclass   = UART
> none9@pci0:9:0:2:       class=0x070103 card=0x2000a000 chip=0x99129710
> rev=0x00 hdr=0x00
>     vendor     = 'MosChip Semiconductor Technology Ltd.'
>     device     = 'PCIe 9912 Multi-I/O Controller'
>     class      = simple comms
>     subclass   = parallel port
>
> Looking at the source code of puc, I find a place where it checks
> the number of ports a device provides and aborts if it has only
> one port. This would match my understanding that puc only exists
> in order to help uart and ppc to work with multi-port devices
> where all ports are handled by a single device in pciconf.
>
> Until now, I used PUC_PORT_2S1P in my puc entry. So puc assumes
> that the card 0x2000a000 has 2 serial and 1 parallel port but
> this is probably wrong as this 0x2000a000 card only has one
> parallel port and the serials are handled by other devices.
> So the correct entry would be PUC_PORT_1P but with one single
> port puc does not attach.
>
> If all this is correct, I assume that puc should be left alone
> and ppc_pci.c is the thing I have to look at.
>
> This also matches the fact that uart attaches well to these two
> serial ports without the need of loading and unloading puc first
> so there is probably some kind of device specific initialisation
> missing in ppc_pci.c...
>
> -Andre
> _______________________________________________
> [hidden email] mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "[hidden email]"
>
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

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

Andre Albsmeier
In reply to this post by Daniel Eischen
On Sat, 03-Mar-2018 at 14:41:58 -0500, Daniel Eischen wrote:

> On Sat, 3 Mar 2018, Andre Albsmeier wrote:
>
> > On Sat, 03-Mar-2018 at 10:53:20 -0500, Daniel Eischen wrote:
> >> On Sat, 3 Mar 2018, Andre Albsmeier wrote:
> >>
> >>> On Fri, 02-Mar-2018 at 08:36:40 -0500, Daniel Eischen wrote:
> >>>> On Fri, 2 Mar 2018, Andre Albsmeier wrote:
> >>>>
> >>>>> I have a MosChip 9912 card (PCIe card with 1 parallel and 2 serial
> >>>>> ports) sitting here which does not get detected on 11.1. I tried
> >>>>> to simply add it to the uart and ppc drivers with
> >>>>>
> >>>> [ ... ]
> >>>>
> >>>> Do you try adding similar support to puc_pci_devices[] in
> >>>> sys/dev/puc/pucdata.c?
> >>>
> >>> Just tried that:
> >>>
> >>> @@ -1204,6 +1204,11 @@
> >>>            PUC_PORT_1S1P, 0x10, 4, 0,
> >>>        },
> >>>
> >>> +{   0x9710, 0x9912, 0xa000, 0x3012,
> >>> +    "NetMos NM9912 Dual UART and 1284 Printer port",
> >>> +    DEFAULT_RCLK,
> >>> +    PUC_PORT_2S1P, 0x10, 4, 0,
> >>> +},
> >>>        {   0x9710, 0x9865, 0xa000, 0x3012,
> >>>            "NetMos NM9865 Dual UART and 1284 Printer port",
> >>>            DEFAULT_RCLK,
> >>>
> >>> But the results are exactly the same. It also doesn't
> >>> matter if puc.ko is loaded at all.
> >>
> >> Are you sure your subvendor and subdevice are correct?  I would
> >
> > No ;-). I have to use: 0x9710, 0x9912, 0xa000, 0x2000,
> >
> > Now I have the following behaviour:
> >
> > When I load puc.ko I get:
> > puc0: <NetMos NM9912 Dual UART and 1284 Printer port> at device 0.2 on pci9
> >
> > If I load ppc.ko now, I get:
> > ppc0: parallel port not found.
> >
> > But if I unload puc and ppc and load ppc again, I get:
> >
> > ppc0: <MosChip MCS9912 PCIe to Peripheral Controller> port 0xd000-0xd007,0xd008-0xd00f mem 0x89200000-0x89200fff irq 20 at device 0.2 on pci9
> > ppc0: Generic chipset (EPP/NIBBLE) in COMPATIBLE mode
> > ppbus0: <Parallel port bus> on ppc0
> > lpt0: <Printer> on ppbus0
> > lpt0: Interrupt-driven port
> >
> > For all this I have to disable /boot/device.hints -- otherwise
> > the messages "driver bug: Unable to set devclass" comes back.
> >
> > So I think there are two problems:
> >
> > First the settings of the ISA stuff in /boot/device.hints conflicted
> > with the settings the driver probed. This would be easy to solve --
> > just disable them in /boot/device.hints.
> >
> > Second it appears that ppc only attaches if puc did some kind of
> > initialisation first. But we have to detach puc so the ppc can attach.
>
> Strange.  Did you try setting puc_load="YES" in /boot/loader.conf
> and rebooting?  Or are you just loading and unloading modules
> for now?

I am now using this diff to access the MCS9912. I am (mis)using
puc to initialise whatever is needed for the printer port to work
and let ppc attach to puc. As puc does not attach to single port
devices, I have removed this check. uart works by simply adding
the device. This is all quite ugly but it works...

--- ./puc/puc.c.ORI 2018-03-06 06:21:35.939042000 +0100
+++ ./puc/puc.c 2018-03-06 06:21:10.337686000 +0100
@@ -458,8 +458,10 @@
  sc->sc_cfg = cfg;
 
  /* We don't attach to single-port serial cards. */
+#if 0
  if (cfg->ports == PUC_PORT_1S || cfg->ports == PUC_PORT_1P)
  return (EDOOFUS);
+#endif
  error = puc_config(sc, PUC_CFG_GET_NPORTS, 0, &res);
  if (error)
  return (error);
--- ./puc/pucdata.c.ORI 2016-12-27 14:33:54.000000000 +0100
+++ ./puc/pucdata.c 2018-03-06 06:19:26.764167000 +0100
@@ -1216,6 +1216,12 @@
     PUC_PORT_2P, 0x10, 4, 0,
  },
 
+{   0x9710, 0x9912, 0xa000, 0x2000,
+    "NetMos NM9912 Printer port",
+    DEFAULT_RCLK,
+    PUC_PORT_1P, 0x10, 4, 0,
+},
+
  {   0xb00c, 0x021c, 0xffff, 0,
     "IC Book Labs Gunboat x4 Lite",
     DEFAULT_RCLK,
--- ./uart/uart_bus_pci.c.ORI 2018-02-12 06:17:57.000000000 +0100
+++ ./uart/uart_bus_pci.c 2018-03-06 06:23:20.886245000 +0100
@@ -158,6 +158,8 @@
  "MosChip MCS9904 PCIe to Peripheral Controller", 0x10 },
 { 0x9710, 0x9922, 0xa000, 0x1000,
  "MosChip MCS9922 PCIe to Peripheral Controller", 0x10 },
+{ 0x9710, 0x9912, 0xa000, 0x1000,
+ "MosChip MCS9912 PCIe to Peripheral Controller", 0x10 },
 { 0xdeaf, 0x9051, 0xffff, 0, "Middle Digital PC Weasel Serial Port", 0x10 },
 { 0xffff, 0, 0xffff, 0, NULL, 0, 0}
 };


        -Andre
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[hidden email]"