Armadilloフォーラム

Linux3.14のCSPI、UARTサポート状況について その2

kenmoku

2020年11月16日 12時52分

SPIによる通信はPIOのみ対応とありましたので、CSPI3を使用するための
コンフィグ設定を行ってみたのですが、SPIのデバイスが認識されません。
期待していたデバイス
/dev/spidev2.0
/dev/spidev2.1
/dev/spidev2.2

起動ログを見てもSPIの認識が無いようです。

[root@armadillo440-0 (ttymxc1) ~]# dmesg | grep "spi"
spi_imx imx35-cspi.0: probed
spi_imx imx35-cspi.2: probed

コンフィグ設定は以下の通りですが、不足や勘違い等があれば
教えて頂けないでしょうか。

Linux Kernel Configuration
Device Drivers --->
[*] SPI support ---> チェックを入れる
<*> User mode SPI device driver support チェックを入れる
-*- Utilities for Bitbanging SPI Master チェックを入れる

System Type --->
Freescale i.MX Support --->
Device Option --->
[*] Enable SPI3 module チェックを入れる

尚、Linu2.6に在った
Armadillo-400 Board option --->
[*] Enable SPI3 at CPN9
[*] Enable SPI3_SS0 at CON9_16
[*] Enable SPI3_SS1 at CON9_18
[*] Enable SPI3_SS2 at CON9_15
[ ] Enable SPI3_SS3 at CON9_17
が無くなっています。

コメント

at_mizo

2020年11月16日 16時59分

> SPIによる通信はPIOのみ対応とありましたので、CSPI3を使用するための
> コンフィグ設定を行ってみたのですが、SPIのデバイスが認識されません。

以下のドキュメントを参考にLinuxカーネルの設定を行ってみていただけますか。

https://manual.atmark-techno.com/armadillo-guide/armadillo-guide-3_ja-3…

kenmoku

2020年11月17日 11時06分

情報有難うございます。教えて頂いたURLのドキュメントを参考にLinuxカーネル
の設定を行ってみました。

atmark@atde5:~/linux-3.14-at12$ atmark@atde5:~/linux-3.14-at12$ make ARCH=arm armadillo4x0_defconfig # # configuration written to .config # atmark@atde5:~/linux-3.14-at12$ make ARCH=arm menuconfig
HOSTLD scripts/kconfig/mconf
scripts/kconfig/mconf Kconfig
configuration written to .config

*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.

atmark@atde5:~/linux-3.14-at12$

make ARCH=arm menuconfig で、以下のEnableが表示されないままでした。

Linux Kernel Configuration
System Type --->
Freescale i.MX support --->
Armadillo-400 Board options --->
[*] Enable SPI3 at CON9 チェックを入れる
[*] Enable SPI3_SS0 at CON9_16 標準で選択されているのでそのまま
[ ] Enable SPI3_SS1 at CON9_18 チェックを外す
[ ] Enable SPI3_SS2 at CON9_15 チェックを外す
[ ] Enable SPI3_SS3 at CON9_17 チェックを外す

ソース修正を行ってビルドまで行いました。
static struct spi_board_info armadillo4x0_spi2_board_info[] __initdata = { };

static struct spi_board_info armadillo4x0_spi2_board_info[] __initdata = {
{
.modalias = "spidev",
.max_speed_hz = 1000000,
.bus_num = 2,
.chip_select = 0,
},
};

atmark@atde5:~/linux-3.14-12$ make ARCH=arm
CROSS_COMPILE=arm-linux-gnueabi- && gzip -c arch/arm/boot/Image > linux.bin.gz

結果は、起動ログから spi に関する出力が無くなりました。

[root@armadillo440-0 (ttymxc1) ~]# dmesg | grep "spi"
[root@armadillo440-0 (ttymxc1) ~]#

試しに、以下の設定を追加してみたのですが、結果は最初の問合せ時と同じでした。

Linux Kernel Configuration
System Type --->
Freescale i.MX support --->
Device option --->
[*] Enable SPI3 module <--- チェックを入れる

atmark@atde5:~/linux-3.14-12$ make ARCH=arm
CROSS_COMPILE=arm-linux-gnueabi- && gzip -c arch/arm/boot/Image > linux.bin.gz

[root@armadillo440-0 (ttymxc1) ~]# dmesg | grep "spi"
spi_imx imx35-cspi.2: probed

次に、強引に arch/arm/mach-imx/armadillo4x0_extif.c に在るSPI3の#if
definedを変更してみました。

#if defined(CONFIG_ARMADILLO4X0_SPI3_CON9) --> #if
!defined(CONFIG_ARMADILLO4X0_SPI3_CON9)
#if defined(CONFIG_ARMADILLO4X0_SPI3_SS0_CON9_16) --> #if
!defined(CONFIG_ARMADILLO4X0_SPI3_SS0_CON9_16)
#if defined(CONFIG_ARMADILLO4X0_SPI3_SS1_CON9_18) --> #if
!defined(CONFIG_ARMADILLO4X0_SPI3_SS1_CON9_18)
#if defined(CONFIG_ARMADILLO4X0_SPI3_SS2_CON9_15) --> #if
!defined(CONFIG_ARMADILLO4X0_SPI3_SS2_CON9_15)

結果は以下の通りで強引な結果となりました。

[root@armadillo440-0 (ttymxc1) ~]# dmesg | grep "spi"
imx25-pinctrl imx25-pinctrl.0: pin MX25_PAD_CSI_D2 already requested by imx21-uart.4; cannot claim for imx35-cspi.2 imx25-pinctrl imx25-pinctrl.0: pin-72 (imx35-cspi.2) status -22 imx25-pinctrl imx25-pinctrl.0: could not request pin 72
(MX25_PAD_CSI_D2) from group csi_d2__cspi3_mosi on device imx25-pinctrl.0 spi_imx imx35-cspi.2: Error applying setting, reverse things back spi_imx imx35-cspi.2: probed
[root@armadillo440-0 (ttymxc1) ~]#

SPI3 を Enable する術が無いのでしょうか。

at_mizo

2020年11月17日 11時32分

溝渕です。

> make ARCH=arm menuconfig で、以下のEnableが表示されないままでした。
>
> Linux Kernel Configuration
> System Type --->
> Freescale i.MX support --->
> Armadillo-400 Board options --->
> [*] Enable SPI3 at CON9 チェックを入れる
> [*] Enable SPI3_SS0 at CON9_16 標準で選択されているのでそのまま
> [ ] Enable SPI3_SS1 at CON9_18 チェックを外す
> [ ] Enable SPI3_SS2 at CON9_15 チェックを外す
> [ ] Enable SPI3_SS3 at CON9_17 チェックを外す

私の手元で行ってみましたが、表示されました。Linuxカーネルソースは
linux-3.14-12を使っています。

以下のドキュメントに記載の通り、

https://manual.atmark-techno.com/armadillo-guide/armadillo-guide-3_ja-3…

Linux Kernel Configuration
System Type --->
Freescale i.MX support --->
Armadillo-400 Board options --->
[ ] Enable UART5 at CON9 チェックを外す

"Enable UART5 at CON9"のチェックを外したかどうか確認していただけますか。

mikiy.nitto

2020年11月17日 16時17分

前任者から引き継ぎました みき と申します。
フォローありがとうございます。
[ ] Enable UART5 at CON9 のチェックを外したら SPI3 のEnableができる様になりました。
SPI3_SS0,SS1,SS2 を有効にして、make clean できれいにしてから make ARCH=arm
CROSS_COMPILE=arm-linux-gnueabi- && gzip -c arch/arm/boot/Image > linux.bin.gz を実行しました。
カーネルをarmadillo-440に書き込んで実行し、デバイスを確認したら
[root@armadillo440-0 (ttymxc1) ~]# dmesg | grep "spi"
spi_imx imx35-cspi.2: probed
が表示され、やはり、上手くいきませんでした。
此れから、armadillo-440にLinux2.6.xを入れてどのような結果になるか試してみたいと思います。
もし、お気づきの点がありましたら継続フォロー頂けると助かります。

at_mizo

2020年11月17日 16時37分

溝渕です。

> [root@armadillo440-0 (ttymxc1) ~]# dmesg | grep "spi"
> spi_imx imx35-cspi.2: probed
> が表示され、やはり、上手くいきませんでした。

上記、spi bus(cspi.2)ドライバの登録が適切に完了したことを示すメッセー
ジです。

spi deviceのドライバ経由でデバイスを制御する場合は、先に示しましたドキュ
メントの「図2.38 CSPI3、SS0をspidevで使用する修正」内にspidevを指定せ
ず、spi deviceのドライバを指定する必要があります。

spidevを利用する場合は、ユーザーランドドライバを用意する必要があります。

例として、Microchip社製 MCP3202を使う場合は次のようになります。

arch/arm/mach-imx/armadillo_iotg_std_addon/addon_atmark_techno_didoad.c:
static struct spi_board_info addon_spi_board_info_con2[] __initdata = {
{
.modalias = "mcp3202",
.max_speed_hz = 1000000,
.bus_num = 2,
.chip_select = 0,
},
};