AnsweredAssumed Answered

i.MX6 PCIe I/O problem

Question asked by Luis Mendes on Jun 11, 2017

Hi,

I'm trying to use a WCH WC382 2 Serial + 1 Parallel printer card port on an i.MX6 Quad. The card is enumerated and device driver loads, however device driver is unable to probe the parallel port hardware.

[    4.287438] lp: driver loaded but no devices found
[    4.301532] ppdev: user-space parallel port driver

The serial ports are probed:

[    5.895525] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[    5.906105] serial 0000:01:00.0: enabling device (0140 -> 0143)
[    5.914874] 0000:01:00.0: ttyS0 at I/O 0x10c0 (irq = 317, base_baud = 115200) is a XR16850
[    5.915934] 0000:01:00.0: ttyS1 at I/O 0x10c8 (irq = 317, base_baud = 115200) is a XR16850

However I'm unable to send or receive data through them, I/O accesses do not work.

Serial Parport kernel module always read back as 0 for PCIe I/O access with inb() and outb(), while PCIe memory accesses work fine.

How can I access PCIe I/O resources?

 

I've also tried to access the card from /sys/bus/pci/devices/0000:01:00.0/resource2 which corresponds to the I/O ports at 1400 [size=4], but I get the following (mmap fails):

sudo ./pcimem /sys/bus/pci/devices/0000\:01\:00.0/resource2 0x0 b
/sys/bus/pci/devices/0000:01:00.0/resource2 opened.
Target offset is 0x0, page size is 4096 map mask is 0xFFF
mmap(0, 4096, 0x3, 0x1, 3, 0x0)
PCI Memory mapped ERROR.
Error at line 90, file pcimem.c (22) [Invalid argument]

 

Similarly I/O resource0 produces the same outcome.

 

However the memory resource1 Memory at 01100000 (32-bit, prefetchable) [size=32K] again work fine:

sudo ./pcimem /sys/bus/pci/devices/0000\:01\:00.0/resource1 0x0 b
/sys/bus/pci/devices/0000:01:00.0/resource1 opened.
Target offset is 0x0, page size is 4096 map mask is 0xFFF
mmap(0, 4096, 0x3, 0x1, 3, 0x0)
mmap(0, 4096, 0x3, 0x1, 3, 0x0)
PCI Memory mapped 4096 byte region to map_base 0x76f3e000.
PCI Memory mapped access 0x 76F3E000.
Read 0x7F

 

The pcimem program source code follows in attachment.

 

00:00.0 PCI bridge: Synopsys, Inc. Device abcd (rev 01) (prog-if 00 [Normal decode])
    Flags: bus master, fast devsel, latency 0, IRQ 317
    Memory at 01000000 (32-bit, non-prefetchable) [size=1M]
    Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
    I/O behind bridge: 00001000-00001fff
    Prefetchable memory behind bridge: 01100000-011fffff
    [virtual] Expansion ROM at 01200000 [disabled] [size=64K]
    Capabilities: [40] Power Management version 3
    Capabilities: [50] MSI: Enable- Count=1/1 Maskable+ 64bit+
    Capabilities: [70] Express Root Port (Slot-), MSI 00
    Capabilities: [100] Advanced Error Reporting
    Capabilities: [140] Virtual Channel
    Kernel driver in use: pcieport

 

01:00.0 Serial controller: Device 1c00:3250 (rev 10) (prog-if 05 [16850])
    Subsystem: Device 1c00:3250
    Flags: fast devsel, IRQ 317
    I/O ports at 1000 [size=256]
    Memory at 01100000 (32-bit, prefetchable) [size=32K]
    I/O ports at 1400 [size=4]
    [virtual] Expansion ROM at 01108000 [disabled] [size=32K]
    Capabilities: [60] Power Management version 3
    Capabilities: [68] MSI: Enable- Count=1/32 Maskable+ 64bit+
    Capabilities: [80] Express Legacy Endpoint, MSI 00
    Capabilities: [100] Advanced Error Reporting
    Kernel driver in use: parport_serial
    Kernel modules: 8250_pci, parport_serial

 

I've also seen related topic https://community.nxp.com/message/630870?commentID=630870#comment-630870 , but nothing worked.

Original Attachment has been moved to: pcimem.c.zip

Outcomes