Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are there examples of device tree for a SPI slave device? #37

Open
codan-soea opened this issue Nov 23, 2024 · 4 comments
Open

Are there examples of device tree for a SPI slave device? #37

codan-soea opened this issue Nov 23, 2024 · 4 comments

Comments

@codan-soea
Copy link

Hello

I am trying to create a device tree for a SPI slave device for Linux OpenWRT 6.6.58, my SPI device will be interfaced to Lima module
via SPI. I have used "target/linux/ath79/dts/qca9531_8dev_lima.dts" as template. However, I found that by just putting another client
as follows will not work.

&spi {
status = "okay";

/* Winbond W25Q256 SPI flash */
flash@0 {
    .....
    };

    /* more clients */
    bmi160: bmi160@1 {
	compatible = "bosch,bmi160";
	reg = <1>;
	spi-max-frequency = <7500000>;
     };

};

I am wondering are there device tree examples of how to connect a SPI slave to Lima module. Thanks!

@mantas-p
Copy link
Contributor

Hi, you probably need to describe how CS (chip select) is connected - see https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/ath79/dts/ar9342_mikrotik_routerboard-911g.dtsi#l158

@codan-soea
Copy link
Author

codan-soea commented Nov 30, 2024

Thanks. I have tried that, pls see my device tree for SPI slaves below, that but not working. My success criteria is that I have made reading of chip ID (I modified the driver so that it will try to read 5 times) and I know it is not reading correct chip ID.

&spi {
status = "okay";
cs-gpios = <0>, <&gpio 0 GPIO_ACTIVE_LOW>, <&gpio 1 GPIO_ACTIVE_LOW>;
......

bmi160: bmi160@1 {
	compatible = "bosch,bmi160";
	gpio-controller;
	#gpio-cells = <2>;
	reg = <1>;
	spi-max-frequency = <7500000>;
	
	vdd-supply = <&vdd_3v3>;  // Power supply for the BMI160 sensor
	vddio-supply = <&vddio_2v5>; // I/O supply if required

        	interrupt-names = "INT1";
        	mount-matrix = "0", "1", "0",
                       "-1", "0", "0",
                       "0", "0", "1";
};

.....

};

and my SPI Chip selects lines are connected to the Lima SoC as shown below:

image

And I believe my issue is with SPI CS lines are not driven correctly. Thanks!

@mantas-p
Copy link
Contributor

mantas-p commented Dec 2, 2024

GPIO[0-3] have JTAG interface by default, you need to disable it to use these pins as GPIO. See: https://github.com/openwrt/openwrt/blob/207bfee855320dc938f39e179b1d2e3b008140cb/target/linux/ath79/dts/qca9531_glinet_gl-xe300.dts#L36

@codan-soea
Copy link
Author

Thanks, I think I have put it in leds block before, but I will try again.

  • leds {
  •   compatible = "gpio-leds";
    
  •   pinctrl-names = "default";
    
  •   pinctrl-0 = <&jtag_disable_pins>;
    
  • };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants