&size(24){&color(darkgreen){''PCMCIA''};};
#navi(WPAR)
~''CONTENTS''
#contents
----
~''REFERENCES''
-[[Advanced Configuration and Power Interface (ACPI) Specification>http://www.acpi.info/spec.htm]]
-[[PCI Bus Power Management Interface Specification>http://www.pcisig.com/specifications/conventional/pcipm1.2.pdf]] (pdf)
-[[PCI Local Bus Specification>http://www.ece.mtu.edu/faculty/btdavis/courses/mtu_ee3173_f04/papers/PCI_22.pdf]] (Menbers-Only Donwloadのやつが落ちてたラッキー)
-[[SH7751R>http://www.renesas.com/fmwk.jsp?cnt=sh7751r_root.jsp&fp=/products/mpumcu/superh_family/sh7750_series/sh7751r_group/]]
-[[SH7751R(JA)>http://www.renesas.com/jpn/products/mpumcu/32bit/sh/sh7751r/index.html]]
-[[PCI1510 datasheet>http://focus.ti.com/docs/prod/folders/print/pci1510.html]]
-[[probe_irq_on>http://server1.belchfire.net/protected-cgi-bin/manServer_107.pl/usr/share/man/man9/probe_irq_on.9]]
-[[setup_rts7751r2d.c>http://wiki.wivicom.co.jp/cgi-bin/viewcvs.cgi/celinux-2.4/arch/sh/kernel/setup_rts7751r2d.c]]
----

**WPAR01 Board でPCMCIA I/Fを動かす。 [#t500bacb]

***勉強 [#k0191c23]

-CardBusは動いているが、PCMCIAは動作させたことはない。
--pcmcia関連のドライバは組み込んではある。
--Kernel configurationでPCMCIA networkサポートを有効にする。

-readb, readw, readl, writeb, writew, writelはasm-xx/io.hで定義されているマクロ
-&color(red){ioportにアクセスする場合は、inb,inw,inl,outb,outw,outlを使います。};
-&color(red){Linuxでは、ioportとiomemに対してのアクセスは、区別されています。};
--&color(red){SH的には一緒ですけどね。 :) 他のCPUでは、アクセスの仕方が違うものもあるので…};
|b|w|l|
|8bit|16bit|32bit|

-SH7751RはPCMCIAインターフェースをサポートするBSCを持つ。
-WPAR01ではSH7751のPCIC経由でPCカードを接続している。
-物理アドレス空間
--SH7751Rは32bitの物理アドレス 0000 0000 - ffff ffffを持つ。
--Privilege Modeでは全領域がP0からP4に分割される。
--内蔵I/OはP4 Area E000 0000 - FFFF FFFFにマッピングされる。
-外部メモリ空間
--SH7751Rは29bitの外部メモリ空間 0000 0000 - 1fff ffffを持つ。
-仮想アドレス空間
--外部メモリ空間のArea 7 1c00 0000 - 1fff ffffがP4 Areaにマッピングされる。
--以下,SH7751Rのアドレスは全部P4アドレスで書く。
-PCICが使うメモリ空間
--fd00 0000 - fdff ffff は PCI Memory 空間
--fe20 0000 - fe20 0220 は PCI 謎(歯抜けあり)
--fe24 0000 - fe27 ffff は PCI IO 空間
--&color(red){wpar01では、CPUアドレス空間と、PCIメモリ空間で使うアドレスが同じになるように設定しています。memory window動かすの面倒だから…};
-SH-Linuxにおける定数の命名規則: SH7751_PCIXXX_HOGE

***実験 [#lfb13826]
pcmcia-cs-3.x.x.tar.gzを入手
 ./Configure --arch=sh --ucc=sh4-linux-gcc
まあ適当。用があるのはcardmgr/の
-cardmgr
-cardctl
<
これをwapr01:/sbinにコピー

さらにetc/pcmcia以下をターゲットにコピー

 # cat /proc/iomem
 fd001000-fd001fff : PCI device 16f4:8000
 fd002000-fd002fff : PCI device 16f4:8000
 fd020000-fd03ffff : PCI device 16f4:8000
 fd020000-fd03ffff : vw2010_0
 fd100000-fd100fff : Texas Instruments PCI1510 PC card Cardbus Controller
 fd400000-fd7fffff : PCI CardBus #01
 fd800000-fdbfffff : PCI CardBus #01

 # cat /proc/ioports
 00004000-000040ff : PCI CardBus #01
 00004400-000044ff : PCI CardBus #01
 fe2001c0-fe2001c7 : PCI conf1

-PCI-CardBus Bridgeは TI PCI1510
--Intel 82365SL-DF and 82365SL ExCA とレジスタ互換
--82365のドライバがyenta
--PCI1510の割り込み線は Linuxの&color(red,yellow){''IRQ8''};につながっている。
---普通のPCではIRQ8はRTCなので、アサインされないかも。

 setup_arch : TI PCI1510 detect .
は [[arch/sh/kernel/setup_wpar01.c>http://wiki.wivicom.co.jp/cgi-bin/viewcvs.cgi/linux-2.4-wpa/arch/sh/kernel/setup_wpar01.c]] の
 printk("setup_arch : TI PCI1510 detect .\n");
が出している。

 PCI: Enabling device Texas Instruments PCI1510 PC card Cardbus Controller (0000 -> 0002)
は [[arch/sh/kernel/pcibios.c>http://wiki.wivicom.co.jp/cgi-bin/viewcvs.cgi/linux-2.4-wpa/arch/sh/kernel/pcibios.c]] の
 printk(KERN_INFO "PCI: Enabling device %s (%04x -> %04x)\n", dev->name, old_cmd, cmd);
が出してる。

 Yenta IRQ list 0000, PCI irq8
は [[drivers/pcmcia/yenta.c>http://wiki.wivicom.co.jp/cgi-bin/viewcvs.cgi/linux-2.4-wpa/drivers/pcmcia/yenta.c]] の
 printk("Yenta IRQ list %04x, PCI irq%d\n", socket->cap.irq_mask, socket->cb_irq);
が出している。

 # cardctl status
 Socket 0:
   5V 16-bit PC Card
   function 0: [ready], [wp]

 # cardctl config
 Socket 0:
   Vcc 5.0V  Vpp1 5.0V  Vpp2 5.0V

 # cardctl ident
 Socket 0:
 cs: unable to map card memory!
 cs: unable to map card memory!
   no prodcs: unable to map card memory!
 cs: unable to map card memory!
 cs: unable to map card memory!
 cs: unable to map card memory!
 uct info available

-''yenta.cを改造するも,結局setup_wpar01.cと同じことをやってるだけなのであった。''

レジスタアドレス定数を上書き定義。
 #if defined(CONFIG_SH_WPAR01)
 #define PCI_CB_SYSTEM_CONTROL   0x80    /* System Control Register */
 #define PCI_CB_MULTIFUNCTION    0x8c    /* Multifunction Routing Register */
 #define PCI_CB_RETRY_STATUS     0x90    /* Retry Status Register */
 #define PCI_CB_CARD_CONTROL     0x91    /* Card Control Register */
 #define PCI_CB_DEVICE_CONTROL   0x92    /* Device Control Register */
 #define PCI_CB_DIAGNOSTIC       0x93    /* Diagnostic Register */
 #endif

懸念のIRQ8ですが,
>
Only probe "regular" interrupts,
don't touch dangerous spots like the mouse irq,
because there are mice that apparently get really confused
if they get fondled too intimately.
-Default to 11, 10, 9, 7, 6, 5, 4, 3.
<
だって。
 static u32 isa_interrupts = 0x0ef8;
という変数が定義されている。
 HEX: 0ef8 -> BIN: 111011111000
より
|1|1|1|0|1|1|1|1|1|0|0|0|
|11|10|9|8|7|6|5|4|3|2|1|0|
だな。
8をmaskしてほしくないので
|1|1|1|1|1|1|1|1|1|0|0|0|
|11|10|9|8|7|6|5|4|3|2|1|0|
としよう。
 BIN: 111111111000 -> HEX: ff8
だから
 static u32 isa_interrupts = 0x0ff8;
ということで。

yenta_config_initがかなりちがうなあ。
bridgeing stateの設定に追加処理をやってる。
 #if defined(CONFIG_SH_WPAR01)
         exca_writeb(socket, I365_GBLCTL, I365_GBL_CSC_LEV | I365_GBL_IRQ_0_LEV);
         exca_writeb(socket, I365_INTCTL, I365_INTR_ENA);
 #else
         exca_writeb(socket, I365_GBLCTL, 0x00);
 #endif
         exca_writeb(socket, I365_GENCTL, 0x00);
 
         /* Redo card voltage interrogation */
         cb_writel(socket, CB_SOCKET_FORCE, CB_CVSTEST);
 
 #if defined(CONFIG_SH_WPAR01)
         config_writel(socket, PCI_CB_SYSTEM_CONTROL, 0x28449060);
         config_writeb(socket, PCI_CB_RETRY_STATUS, 0x00);
         config_writeb(socket, PCI_CB_DEVICE_CONTROL, 0x62);
         config_writeb(socket, PCI_CB_DIAGNOSTIC, 0x40);
         config_writel(socket, PCI_CB_MULTIFUNCTION, 0x00001002);
 #endif

-linux-2.4-wpa
--yenta_allocate_res が微妙に進化してるのだが無視。
--yenta_free_resouces が登場してるのだが無視。

>
Different cardbus controllers have slightly different
initialization sequences etc details. List them here..
<
とおっしゃってるので
        { PD(TI,1510),  &ti_ops },
を挿入しておく。

PCI_DEVICE_ID_TI_1510を [[include/linux/pci_ids.h>http://wiki.wivicom.co.jp/cgi-bin/viewcvs.cgi/linux-2.4-wpa/include/linux/pci_ids.h]] で定義しないといけない。
気前よく
 #define PCI_DEVICE_ID_TI_1510		0xac56
 #define PCI_DEVICE_ID_TI_1520		0xac55
だ。


SHなのでioportもiomemoryも当然ちがう。

''/etc/pcmcia/config.opts''
 include port 0x000-0x0ff, port 0x400-0x4ff
 include memory 0xfd000000-0xfdffffff

で。

 # cardctl status
 Socket 0:
   5V 16-bit PC Card
   function 0: [ready]

 # cardctl config
 Socket 0:
   Vcc 5.0V  Vpp1 0.0V  Vpp2 0.0V
   interface type is "memory and I/O"
   irq 8 [exclusive] [level]
   function 0:
     config base 0x0400
       option 0x60 status 0x00 copy 0x00
     io 0x0400-0x041f [auto]

 # cardctl ident
 Socket 0:
   product info: "corega", "FEther PCC-TXF"
   manfid: 0xc00f, 0x0000
   function: 6 (network)

-kernelにスタティックリンクもmoduleも動いた。

***ks29xx-linux [#m328629c]

-Makefileなおすの大変。cross開発なんて考慮されてないようだ。誰だよ書いたの。オレだ‥。
-Makefile.WPAR01作成。イントールは自分でやってくれ。

/etc/pcmcia/config
 device "ks29xx_cs"
   class "network" module "net/ks29xx", "ks29xx_cs"

まああとはCVSでもみてください。で,

 # cardctl status
  Socket 0:
   3.3V 16-bit PC Card
   function 0: [ready], [bat dead], [bat low]

 # cardctl config
 Socket 0:
   Vcc 3.3V  Vpp1 0.0V  Vpp2 0.0V
   interface type is "memory and I/O"
   irq 8 [exclusive] [level]
   function 0:
     config base 0x0200
       option 0x45 status 0x00 pin 0x00 copy 0x00 ext 0x00
     io 0x0400-0x043f [16bit]

 # cardctl ident
 Socket 0:
   product info: "KeyStream Corp.", "KS2970", "", ""
   manfid: 0x005b, 0xf002
   function: 6 (network)

 # cardctl info
 PRODID_1="KeyStream Corp."
 PRODID_2="KS2970"
 PRODID_3=""
 PRODID_4=""
 MANFID=005b,f002
 FUNCID=6

 # ifconfig eth0 192.168.103.98
すると,Dell INSPIRON 700m内蔵11b WLAN経由でsloginできました。

***結局 [#t0033fcf]
+cardmgr copy
+pcmcia service 用設定ファイルのcopy
+module copy
-kernelの変更はいらない。


トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS