how i open file to access more than 1 SPI slave

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

how i open file to access more than 1 SPI slave

868件の閲覧回数
johnmxq
Contributor I

i want to access 3 spi slave(ad7799),i config dts like this

&ecspi3 {
fsl,spi-num-chipselects = <3>;
cs-gpio = <
&gpio1 20 GPIO_ACTIVE_LOW
&gpio2 30 GPIO_ACTIVE_HIGH
&gpio3 19 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi3>;
status = "okay";


spidev: ad7799@0 {
compatible = "ad7799";
spi-max-frequency = <8000000>;
reg = <0>;
};
spidev: ad7799@1 {
compatible = "ad7799";
spi-max-frequency = <8000000>;
reg = <0>;
};
spidev: ad7799@3 {
compatible = "ad7799";
spi-max-frequency = <8000000>;
reg = <0>;
};

i write a driver like this

static const struct of_device_id ad7799_of_match[] = {
{ .compatible = "ad7799" },
{ /* Sentinel */ }
};

static struct spi_driver ad7799_driver = {
.probe = ad7799_probe,
.remove = ad7799_remove,
.driver = {
.owner = THIS_MODULE,
.name = "ad7799",
.of_match_table = ad7799_of_match,
},
.id_table = ad7799_id,
};

i write app to access spi slave like this 

fd1=open("/dev/ad7799@0", O_RDWR);//error No such file or directory

fd2=open("/dev/ad7799@1", O_RDWR);//error No such file or directory

fd3=open("/dev/ad7799@2", O_RDWR);//error No such file or directory

but how i access three chip use same driver,

タグ(1)
0 件の賞賛
返信
1 返信

856件の閲覧回数
igorpadykov
NXP Employee
NXP Employee

Hi Johnmxq

 

one can look at unit test ecspi example:

https://source.codeaurora.org/external/imx/imx-test/tree/test/mxc_spi_test?h=lf-5.10.52_2.1.0

 

Best regards
igor

0 件の賞賛
返信