フラッシュメモリが接続されているSPIポートを汎用的に使えないか
考えることはみんな同じで、すでにやっている人が居る
というかOpenWrtのHPに書いてある→Deep MMC Mod
・もともとのCS#1にインバーターを繋いでCS#2とするもの
・GPIOを1つ潰してCS#2に割り当てるもの
実現方法
極力ハードを増やしたくなかったので、GPIOにCS#2を割り当てる方法を考えることにした。
CSは負論理なので、起動時からHのままのGPIO12を使うことにした。
ubootもカスタマイズできれば、どのGPIOでも良いんだろうけど。
SPI通信のためにハードは16pinSPIフラッシュ用のランドから線出し
外れないようにホットボンドで固定
黒なので見栄えが少しイマイチ
ソフトは変更点だけを書き出すとこれだけ・・・。
dtsファイル変更、カーネルコンフィグでSPI_SPIDEV追加。
・gpio-ledsからGPIO12に関する定義をコメントアウト
・spi定義部分にcs-gpios追加
・spi定義部分にspidevを追加
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+&spi0 { | |
+ status = "okay"; | |
+ | |
+ num-chipselects = <2>; | |
+ cs-gpios = <0>,<&gpio0 12 GPIO_ACTIVE_LOW>; | |
+ | |
+ m25p80@0 { | |
+ #address-cells = <1>; | |
+ #size-cells = <1>; | |
+ compatible = "jedec,spi-nor"; | |
+ reg = <0>; | |
+ spi-max-frequency = <10000000>; | |
+ | |
+ partition@0 { | |
+ label = "u-boot"; | |
+ reg = <0x0 0x10000>; | |
+ read-only; | |
+ }; | |
+ | |
+ devconf: partition@10000 { | |
+ label = "devconf"; | |
+ reg = <0x10000 0x10000>; | |
+ read-only; | |
+ }; | |
+ firmware: partition@20000 { | |
+ label = "firmware"; | |
+ reg = <0x20000 0x7b0000>; | |
+ }; | |
+ }; | |
+ | |
+ spidev@1 { | |
+ compatible = "spidev"; | |
+ reg = <1>; | |
+ spi-max-frequency = <10000000>; | |
+ }; | |
+ | |
+}; |
ビルド→ファームアップ→デバイス確認
おぉぉぉ
ちなみに、spidevドライバを組み込むとbootログで注意されるみたい
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ 1.459196] spi spi0.1: force spi mode3 | |
[ 1.467875] spidev spi0.1: buggy DT: spidev listed directly in DT | |
[ 1.480327] ------------[ cut here ]------------ | |
[ 1.489758] WARNING: CPU: 0 PID: 1 at drivers/spi/spidev.c:758 spidev_probe+0x1c0/0x1f0 | |
[ 1.505958] Modules linked in: | |
[ 1.512139] CPU: 0 PID: 1 Comm: swapper Not tainted 4.9.57 #0 | |
[ 1.523776] Stack : 8041751a 00000031 00000000 00000001 8182c284 803caba7 8037fcdc 00000001 | |
[ 1.540724] 80413660 000002f6 803d0000 803e0000 803a0000 8004d540 8038549c 803d0000 | |
[ 1.557718] 00000003 000002f6 8038368c 81827aa4 803a0000 8007b1dc 8041751a 0000004b | |
[ 1.574709] 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 | |
[ 1.591649] 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 | |
[ 1.608636] ... | |
[ 1.613628] Call Trace: | |
[ 1.618611] [<8000e358>] show_stack+0x54/0x88 | |
[ 1.627515] [<80023ec0>] __warn+0xe4/0x118 | |
[ 1.635873] [<80023f88>] warn_slowpath_null+0x1c/0x34 | |
[ 1.646166] [<80229cfc>] spidev_probe+0x1c0/0x1f0 | |
[ 1.655766] [<802095f4>] driver_probe_device+0x140/0x290 | |
[ 1.666574] [<80207ac4>] bus_for_each_drv+0xa0/0xb0 | |
[ 1.676505] [<80209440>] __device_attach+0x8c/0xe4 | |
[ 1.686262] [<802089bc>] bus_probe_device+0x3c/0xb0 | |
[ 1.696191] [<80206b38>] device_add+0x468/0x560 | |
[ 1.705455] [<80226fc4>] spi_add_device+0x118/0x16c | |
[ 1.715399] [<80228e0c>] spi_register_master+0x4d0/0x770 | |
[ 1.726205] [<802290f8>] devm_spi_register_master+0x4c/0x9c | |
[ 1.737539] [<8022a98c>] rt2880_spi_probe+0x160/0x1c4 | |
[ 1.747842] [<8020afdc>] platform_drv_probe+0x28/0x70 | |
[ 1.758127] [<802095f4>] driver_probe_device+0x140/0x290 | |
[ 1.768935] [<802097d0>] __driver_attach+0x8c/0xc4 | |
[ 1.778690] [<80207a00>] bus_for_each_dev+0x9c/0xac | |
[ 1.788622] [<80208c3c>] bus_add_driver+0xec/0x204 | |
[ 1.798381] [<80209f08>] driver_register+0xa8/0xf8 | |
[ 1.808135] [<80004658>] do_one_initcall+0xdc/0x1a4 | |
[ 1.818094] [<803e9d3c>] kernel_init_freeable+0x168/0x220 | |
[ 1.829077] [<8030660c>] kernel_init+0x10/0x10c | |
[ 1.838313] [<80009258>] ret_from_kernel_thread+0x14/0x1c | |
[ 1.849303] ---[ end trace ac6e1c084ca3bbc0 ]--- |
0 件のコメント:
コメントを投稿