[ TOP | Recently ]

2009-10-16 STR9105その6 - PCI config register


PCI config base address register に write しても書けなかったのは、PCI tag の作り方が間違ってたからというアホなミスだった。

データシートに

31 RW Enable
30:24 RW Reserved
23:16 RW Bus number
15:11 RW Device number
10:8 RW Function number
7:2 RW Register number
1:0 RW Reserved

と書いてあったので、思わず

bus_space_write_4(sc->sc_iot, sc->sc_ioh_addr, 0,
    0x80000000 | tag | (reg << 2));

としてしまったのですよ。
本当はレジスタは4の倍数しか受けつけないというだけなので

bus_space_write_4(sc->sc_iot, sc->sc_ioh_addr, 0,
    0x80000000 | tag | reg);

が正解。今は後悔している。

上のバグコードでも register 0 の PCI vendor/PCI product は正常に読めてしまうので気づくのに時間がかかった…
よく見たら以前の PCI_CONFIG_DUMP の値がめちゃくちゃだな。ここで気づけよ>俺

というわけで修正するとpci deviceのattachまで来た。

	:
starpci0 at star0 addr 0xa0000000-0xa0000003 irq 8: PCI Host Bridge
pci0 at starpci0
unknown vendor 0xeeee product 0x0000 (undefined subclass 0x00) at pci0 dev 0 function 0: PCI configuration registers:
  Common header:
    0x00: 0x0000eeee 0x04000147 0xff000000 0x0000ff04

    Vendor ID: 0xeeee
    Device ID: 0x0000
    Command register: 0x0147
      I/O space accesses: on
      Memory space accesses: on
      Bus mastering: on
      Special cycles: off
      MWI transactions: off
      Palette snooping: off
      Parity error checking: on
      Address/data stepping: off
      System error (SERR): on
      Fast back-to-back transactions: off
      Interrupt disable: off
    Status register: 0x0400
      Capability List support: off
      66 MHz capable: off
      User Definable Features (UDF) support: off
      Fast back-to-back capable: off
      Data parity error detected: off
      DEVSEL timing: slow (0x2)
      Slave signaled Target Abort: off
      Master received Target Abort: off
      Master received Master Abort: off
      Asserted System Error (SERR): off
      Parity error detected: off
    Class Name: undefined (0xff)
    Subclass ID: 0x00
    Interface: 0x00
    Revision ID: 0x00
    BIST: 0x00
    Header Type: 0x00 (0x00)
    Latency Timer: 0xff
    Cache Line Size: 0x04

  Type 0 ("normal" device) header:
    0x10: 0x00000000 0xa8000001 0x00000000 0x00000000
    0x20: 0x00000000 0x00000000 0x00000000 0x0000eeee
    0x30: 0x00000000 0x00000000 0x00000000 0x00000000

    Base address register at 0x10
      not implemented(?)
    Base address register at 0x14
      type: 32-bit i/o
      base: 0xa8000000, size: 0x01000000
    Base address register at 0x18
      not implemented(?)
    Base address register at 0x1c
      not implemented(?)
    Base address register at 0x20
      not implemented(?)
    Base address register at 0x24
      not implemented(?)
    Cardbus CIS Pointer: 0x00000000
    Subsystem vendor ID: 0xeeee
    Subsystem ID: 0x0000
    Expansion ROM Base Address: 0x00000000
    Reserved @ 0x34: 0x00000000
    Reserved @ 0x38: 0x00000000
    Maximum Latency: 0x00
    Minimum Grant: 0x00
    Interrupt pin: 0x00 (none)
    Interrupt line: 0x00

  Device-dependent header:
    0x40: 0x00000000 0x00000000 0x00000000 0x00000000
    0x50: 0x00000000 0x00000000 0x00000000 0x00000000
    0x60: 0x00000000 0x00000000 0x00000000 0x00000000
    0x70: 0x00000000 0x00000000 0x00000000 0x00000000
    0x80: 0x00000000 0x00000000 0x00000000 0x00000000
    0x90: 0x00000000 0x00000000 0x00000000 0x00000000
    0xa0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xb0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xc0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xd0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xe0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xf0: 0x00000000 0x00000000 0x00000000 0x00000000

    Don't know how to pretty-print device-dependent header.

unknown vendor 0xeeee product 0x0000 (undefined subclass 0x00) at pci0 dev 0 function 0 (intrswiz 0, intrpin 0, i/o on, mem on, no quirks) not configured
ral0 at pci0 dev 2 function 0: PCI configuration registers:
  Common header:
    0x00: 0x03021814 0x04100147 0x02800000 0x0000ff04

    Vendor Name: Ralink Technologies (0x1814)
    Device Name: RT2561 802.11b/g (0x0302)
    Command register: 0x0147
      I/O space accesses: on
      Memory space accesses: on
      Bus mastering: on
      Special cycles: off
      MWI transactions: off
      Palette snooping: off
      Parity error checking: on
      Address/data stepping: off
      System error (SERR): on
      Fast back-to-back transactions: off
      Interrupt disable: off
    Status register: 0x0410
      Capability List support: on
      66 MHz capable: off
      User Definable Features (UDF) support: off
      Fast back-to-back capable: off
      Data parity error detected: off
      DEVSEL timing: slow (0x2)
      Slave signaled Target Abort: off
      Master received Target Abort: off
      Master received Master Abort: off
      Asserted System Error (SERR): off
      Parity error detected: off
    Class Name: network (0x02)
    Subclass Name: miscellaneous (0x80)
    Interface: 0x00
    Revision ID: 0x00
    BIST: 0x00
    Header Type: 0x00 (0x00)
    Latency Timer: 0xff
    Cache Line Size: 0x04

  Type 0 ("normal" device) header:
    0x10: 0xb0000000 0x00000000 0x00000000 0x00000000
    0x20: 0x00000000 0x00000000 0x00000601 0x922116ef
    0x30: 0x00000000 0x00000040 0x00000000 0x00000100

    Base address register at 0x10
      type: 32-bit nonprefetchable memory
      base: 0xb0000000, size: 0x00008000
    Base address register at 0x14
      not implemented(?)
    Base address register at 0x18
      not implemented(?)
    Base address register at 0x1c
      not implemented(?)
    Base address register at 0x20
      not implemented(?)
    Base address register at 0x24
      not implemented(?)
    Cardbus CIS Pointer: 0x00000601
    Subsystem vendor ID: 0x16ef
    Subsystem ID: 0x9221
    Expansion ROM Base Address: 0x00000000
    Capability list pointer: 0x40
    Reserved @ 0x38: 0x00000000
    Maximum Latency: 0x00
    Minimum Grant: 0x00
    Interrupt pin: 0x01 (pin A)
    Interrupt line: 0x00

  Capability register at 0x40
    type: 0x01 (Power Management, rev. 1.0)

  PCI Power Management Capabilities Register
    Capabilities register: 0x0002
      Version: 1.1
      PME# clock: off
      Device specific initialization: off
      3.3V auxiliary current: self-powered
      D1 power management state support: off
      D2 power management state support: off
      PME# support: 0x00
    Control/status register: 0x0000
      Power state: D0
      PCI Express reserved: off
      No soft reset: off
      PME# assertion disabled
      PME# status: off

  Device-dependent header:
    0x40: 0x00020001 0x00000000 0x00000000 0x00000000
    0x50: 0x00000000 0x00000000 0x00000000 0x00000000
    0x60: 0x00000000 0x00000000 0x00000000 0x00000000
    0x70: 0x00000000 0x00000000 0x00000000 0x00000000
    0x80: 0x00000000 0x00000000 0x00000000 0x00000000
    0x90: 0x00000000 0x00000000 0x00000000 0x00000000
    0xa0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xb0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xc0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xd0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xe0: 0x00000000 0x00000000 0x00000000 0x00000000
    0xf0: 0x00000000 0x00000000 0x00000000 0x00000000

    Don't know how to pretty-print device-dependent header.

Ralink Technologies RT2561 802.11b/g (miscellaneous network) at ? dev 2 function 0 (intrswiz 0, intrpin 0x1, i/o on, mem on, no quirks): Ralink Technologies RT2561 802.11b/g (rev. 0x00)
ral0: interrupting at pin 1
ral0: 802.11 address 00:d0:41:b0:ff:32
ral0: MAC/BBP RT2561C, RF RT2527
ral0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps
ral0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps
~#Stopped in pid 0.1 (system) at  netbsd:cpu_Debugger+0x4:        mov     r15, r14

db> bt
netbsd:comintr+0x10
        scp=0xc001bb94 rlv=0xc019f2dc (netbsd:star_intr_dispatch+0x134)
        rsp=0xc03d8f08 rfp=0xc03d8f34
        r10=0xfffffbff r9=0xc03015e8
        r8=0x00000400 r7=0x00000100 r6=0xc1114fe0 r5=0xc03d8f38
        r4=0xa00000d3
netbsd:star_intr_dispatch+0x10
        scp=0xc019f1b8 rlv=0xc00c6770 (netbsd:irq_entry+0x70)
        rsp=0xc03d8f38 rfp=0xc03d8f9c
        r10=0xc03015e8 r9=0x000368b8
        r8=0x00000000 r7=0x000368b8 r6=0x00000000 r5=0x00000002
        r4=0xc03015e8
netbsd:cpu_configure+0x10
        scp=0xc000c3fc rlv=0xc00a9b9c (netbsd:main+0x180)
        rsp=0xc03d8fa0 rfp=0xc03d8fec
        r4=0x20008134
netbsd:main+0x10
        scp=0xc00a9a2c rlv=0xc0008220 (netbsd:kernel_text+0x3c)
        rsp=0xc03d8ff0 rfp=0xc03d8ffc
        r10=0x00000000 r9=0x000368b8
        r8=0x00000000 r7=0x000368b8 r6=0x0003661c r5=0x00000002
        r4=0x20008134
netbsd:kernel_text+0x3c
        scp=0xc0008220 rlv=0xc019fc14 (netbsd:initarm+0x794)
        rsp=0xc03d9000 rfp=0x00000000
db> 

ral0 を attach した直後で止まった。PCIの割り込みまわりっぽいな。


EOF