【應(yīng)用環(huán)境】
系統(tǒng):uos v20 1031版的uos系統(tǒng)
CPU:龍芯 loongson-3A4000
PCI芯片:CH384 ( 支持4串口1并口)
【問題】目前問一下如何訪問CH384的I/O基地1的寄存器設(shè)置為ECP模式
【應(yīng)用環(huán)境】
系統(tǒng):uos v20 1031版的uos系統(tǒng)
CPU:龍芯 loongson-3A4000
PCI芯片:CH384 ( 支持4串口1并口)
【問題】目前問一下如何訪問CH384的I/O基地1的寄存器設(shè)置為ECP模式
您好,可以在相應(yīng)的linux系統(tǒng)驅(qū)動中通過代碼配置相關(guān)寄存器進行設(shè)定。
?struct?pci_dev?*pdev?=?NULL; ??//?尋找VID廠商標(biāo)識: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);
好像關(guān)于并口部分的寄存器不知道如何配置的,能否給一個配置ECP的配置呢
您好,關(guān)于CH384的并口寄存器詳細(xì)介紹,請參考CH384DS1手冊中的6.6小節(jié)《并口寄存器》,包含詳細(xì)介紹。
如果是想在Linux 應(yīng)用層來操作CH384的基礎(chǔ)寄存器如何操作呢?
目前無法確認(rèn)寄存器的基地址是如何確定的??
測試代碼如下:
#include? #include? #include? #include? #include? #include? #include? #include? #define?PCI_REG_BASE????????0x59508000?//該數(shù)值無效 #define?MAP_SIZE????????0x1?? int?main(int?argc,?char?*argv[]) { ????int?dev_fd; ???????//打開linux系統(tǒng)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? ????//打印并口寄存器數(shù)據(jù) ????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模式設(shè)置 ???*(volatile?unsigned?char?*)(map_base?+?0x03)?=?0x01; ????printf("PXR??%x?\n",?*(volatile?unsigned?char?*)(map_base+0x03)); ????//解除映射關(guān)系; ????munmap(map_base,MAP_SIZE); ????if(dev_fd) ????????close(dev_fd); ????return?0; }
寄存器定義
目前使用lspci -v查詢結(jié)果
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查詢結(jié)果
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
您好,應(yīng)用層還沒有可以直接操作該寄存器的實例。目前您這邊的情況是對端設(shè)備,必須強制支持ECP并口還是?默認(rèn)的驅(qū)動啟用的是SPP模式。
目前默認(rèn)并口驅(qū)動啟用的是SPP模式。想開啟ECP并口模式。
【知識點】
? ?
EPP:增強并行端口 (Enhanced Parallel Port),增強型工作模式,EPP采用雙向半雙工數(shù)據(jù)傳輸,其傳輸速度比SPP高,可達 2MB/s,EPP可細(xì)分為EPP 1.7和EPP 1.9兩種模式,目前多數(shù)外設(shè)使用此工作模式; ? ?
ECP:擴展性能端口 (Enhanced Capability Port),采用雙向全雙工數(shù)據(jù)傳輸,傳輸速率比EPP要高??梢运闶悄壳白钕冗M的并口模式,但是該模式需要設(shè)置DMA通道,既消耗資源,又容易引起沖突。同時,目前支持ECP的外設(shè)很少,因此,一般而言不要選擇該模式;
您好,稍麻煩的實現(xiàn)方式是可以通過修改parport_pc驅(qū)動來強制切換,至于不干預(yù)驅(qū)動從軟件層能否切換我們做下調(diào)研回復(fù)您。
辛苦你了。