【应用环境】
系统:uos v20 1031版的uos系统
CPU:龙芯 loongson-3A4000
PCI芯片:CH384 ( 支持4串口1并口)
【问题】目前问一下如何访问CH384的I/O基地1的寄存器设置为ECP模式
【应用环境】
系统:uos v20 1031版的uos系统
CPU:龙芯 loongson-3A4000
PCI芯片:CH384 ( 支持4串口1并口)
【问题】目前问一下如何访问CH384的I/O基地1的寄存器设置为ECP模式
您好,可以在相应的linux系统驱动中通过代码配置相关寄存器进行设定。
struct pci_dev *pdev = NULL; // 寻找VID厂商标识:Vendor ID : 1C00H Device ID :3450H (芯片 CH384 :4 串口+并口) pdev = pci_get_device(wch_pci_board_id[0].vendor, wch_pci_board_id[0].device, pdev); pci_disable_device(pdev); pci_enable_device(pdev); //获取I/O基址2地址 io_bar_addr = pci_resource_start(pdev, 2); //但是手册上好像没给出I/O基址2的寄存器的介绍 //读取寄存器 (I/O基址2+offset地址) data = inl(io_bar_addr + offset); //写寄存器 outl(vuale,io_bar_addr + offset);
好像关于并口部分的寄存器不知道如何配置的,能否给一个配置ECP的配置呢
您好,关于CH384的并口寄存器详细介绍,请参考CH384DS1手册中的6.6小节《并口寄存器》,包含详细介绍。
如果是想在Linux 应用层来操作CH384的基础寄存器如何操作呢?
目前无法确认寄存器的基地址是如何确定的??
测试代码如下:
#include #include #include #include #include #include #include #include #define PCI_REG_BASE 0x59508000 //该数值无效 #define MAP_SIZE 0x1 int main(int argc, char *argv[]) { int dev_fd; //打开linux系统dev目录下的/dev/mem文件; dev_fd = open( "/dev/mem", O_RDWR|O_SYNC ); if (dev_fd < 0){ printf("open(/dev/mem) failed."); return 0; } //将寄存器地址映射到用户空间; unsigned char *map_base= (unsigned char * )mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, dev_fd, PCI_REG_BASE ); //打印该寄存器地址的value //打印并口寄存器数据 printf("PIR %x \n", *(volatile unsigned char *)(map_base+0x00)); printf("PSR %x \n", *(volatile unsigned char *)(map_base+0x01)); printf("PCR %x \n", *(volatile unsigned char *)(map_base+0x02)); printf("PXR %x \n", *(volatile unsigned char *)(map_base+0x03)); //对PXR寄存器进行MODEECP模式设置 *(volatile unsigned char *)(map_base + 0x03) = 0x01; printf("PXR %x \n", *(volatile unsigned char *)(map_base+0x03)); //解除映射关系; munmap(map_base,MAP_SIZE); if(dev_fd) close(dev_fd); return 0; }
寄存器定义
目前使用lspci -v查询结果
generic@generic-PC:~/Desktop/mmap$ lspci -v 05:00.0 Serial controller: Device 1c00:3450 (rev 10) (prog-if 05 [16850]) Subsystem: Device 1c00:3450 Flags: bus master, fast devsel, latency 0, IRQ 53, NUMA node 0 I/O ports at 7000 [size=256] Memory at 59500000 (32-bit, prefetchable) [size=32K] I/O ports at 7400 [size=4] Expansion ROM at 59508000 [disabled] [size=32K] Capabilities: Kernel driver in use: parport_serial Kernel modules: wch
generic@generic-PC:~/Desktop/mmap$ sudo lspci -s 05:00.0 -xxx 05:00.0 Serial controller: Device 1c00:3450 (rev 10) 00: 00 1c 50 34 07 00 10 00 10 05 00 07 00 00 00 00 10: 01 70 00 00 08 00 50 59 01 74 00 00 00 00 00 00 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 1c 50 34 30: 00 80 ff ff 60 00 00 00 00 00 00 00 65 01 00 00 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 60: 01 68 c3 c9 00 00 00 00 05 80 8a 01 00 00 00 00 70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80: 10 00 12 00 41 8b 00 00 30 18 10 00 11 fc 07 00 90: 00 00 11 10 00 00 00 00 00 00 00 00 00 00 00 00 a0: 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
cat /proc/iomem查询结果
root@generic-PC:/home/generic/Desktop/mmap# cat /proc/iomem 00200000-0effffff : System RAM 00200000-00de5c53 : Kernel code 00de5c54-0122ffff : Kernel data 012b0000-023fe51f : Kernel bss 0fffe000-0fffffff : reserved 10080000-100800ff : serial 10090000-10090007 : 10090000.i2c 10090100-10090107 : 10090100.i2c 10090200-10090207 : 10090200.i2c 10090300-10090307 : 10090300.i2c 10090400-10090407 : 10090400.i2c 10090500-10090507 : 10090500.i2c 100a0000-100a000f : pwm@100a0000 100a0100-100a010f : pwm@100a0100 100a0200-100a020f : pwm@100a0200 100a0300-100a030f : pwm@100a0300 100d0100-100d01ff : 100d0100.rtc 100e0000-100e0bff : 100e0000.gpio 1fe0011c-1fe00120 : loongson-gpio.0 1fe0011c-1fe00120 : loongson-gpio 1fe001e0-1fe001e7 : serial 40000000-7fffffff : pci memory space 40000000-57ffffff : PCI Bus 0000:06 40000000-4fffffff : 0000:06:00.0 50000000-5001ffff : 0000:06:00.0 58000000-58ffffff : 0000:00:16.0 59000000-590fffff : PCI Bus 0000:01 59000000-59007fff : 0000:01:00.0 59000000-59007fff : xhci-hcd 59100000-591fffff : PCI Bus 0000:02 59100000-5911ffff : 0000:02:00.0 59100000-5911ffff : igb 59120000-59123fff : 0000:02:00.0 59120000-59123fff : igb 59200000-592fffff : PCI Bus 0000:03 59200000-5921ffff : 0000:03:00.0 59200000-5921ffff : igb 59220000-59223fff : 0000:03:00.0 59220000-59223fff : igb 59300000-593fffff : PCI Bus 0000:04 59300000-593001ff : 0000:04:00.0 59300000-593001ff : ahci 59400000-594fffff : PCI Bus 0000:04 59400000-5940ffff : 0000:04:00.0 59500000-595fffff : PCI Bus 0000:05 59500000-59507fff : 0000:05:00.0 59508000-5950ffff : 0000:05:00.0 59600000-596fffff : PCI Bus 0000:06 59600000-5963ffff : 0000:06:00.0 59640000-59643fff : 0000:06:00.1 59640000-59643fff : ICH HD audio 59700000-5973ffff : 0000:00:06.0 59740000-5974ffff : 0000:00:06.0 59750000-5975ffff : 0000:00:06.1 59760000-5976ffff : 0000:00:07.0 59760000-5976ffff : Loongson HDA 59770000-59777fff : 0000:00:04.0 59770000-59777fff : ohci_hcd 59778000-5977ffff : 0000:00:04.1 59778000-5977ffff : ehci_hcd 59780000-59787fff : 0000:00:05.0 59780000-59787fff : ohci_hcd 59788000-5978ffff : 0000:00:05.1 59788000-5978ffff : ehci_hcd 59790000-59791fff : 0000:00:08.0 59790000-59791fff : ahci 59792000-59793fff : 0000:00:08.1 59792000-59793fff : ahci 59794000-59795fff : 0000:00:08.2 59794000-59795fff : ahci 59796000-59796fff : 0000:00:06.0 59797000-59797fff : 0000:00:0a.0 59798000-59798fff : 0000:00:0b.0 59799000-59799fff : 0000:00:0c.0 5979a000-5979afff : 0000:00:0d.0 5979b000-5979bfff : 0000:00:0e.0 5979c000-5979cfff : 0000:00:0f.0 5979d000-5979dfff : ls-spi.0 5979d000-5979dfff : 0000:00:16.0 5979d000-5979dfff : ls-spi io 90200000-25fffffff : System RAM
您好,应用层还没有可以直接操作该寄存器的实例。目前您这边的情况是对端设备,必须强制支持ECP并口还是?默认的驱动启用的是SPP模式。
目前默认并口驱动启用的是SPP模式。想开启ECP并口模式。
【知识点】
EPP:增强并行端口 (Enhanced Parallel Port),增强型工作模式,EPP采用双向半双工数据传输,其传输速度比SPP高,可达 2MB/s,EPP可细分为EPP 1.7和EPP 1.9两种模式,目前多数外设使用此工作模式;
ECP:扩展性能端口 (Enhanced Capability Port),采用双向全双工数据传输,传输速率比EPP要高。可以算是目前最先进的并口模式,但是该模式需要设置DMA通道,既消耗资源,又容易引起冲突。同时,目前支持ECP的外设很少,因此,一般而言不要选择该模式;
您好,稍麻烦的实现方式是可以通过修改parport_pc驱动来强制切换,至于不干预驱动从软件层能否切换我们做下调研回复您。
辛苦你了。