Adding two different CS for SPI1 for two Child nodes in Verdin AM62

Hi ,

i am trying add two SPI devices in SPI1 for which i need two CS lines,

below are my implementation bet it seems not working.
`/* Verdin SPI_1 */
&main_spi1 {

cs-gpios = 
	<0>,
	<&mcu_gpio0 2 GPIO_ACTIVE_LOW>;
status = "okay";

max14830: max14830@0 {
	compatible = "maxim,max14830";
	spi-max-frequency = <15000000>;
	reg = <0>; // SPI chip select number
	clocks = <&clk16m0>;
	clock-names = "xtal"; /* because using external xtal */
	interrupt-parent = <&mcu_gpio0>;
	interrupts = <1 IRQ_TYPE_EDGE_FALLING>;
	gpio-controller;  /* Marks the device node as a GPIO controller */
	#gpio-cells = <2>;
	
 };
 
 lan9370: switch@1 {
    compatible = "microchip,lan9370";
    reg = <1>;
phy-mode = "rmii";
    spi-max-frequency = <44000000>;
	//cs-gpios = <&mcu_gpio0 2 GPIO_ACTIVE_LOW>; // GPIO pin for chip select 2
	//interrupt-parent = <&mcu_gpio0>;
	//interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
	//gpio-controller;  /* Marks the device node as a GPIO controller */
	//#gpio-cells = <2>;
    ports {
					#address-cells = <1>;
					#size-cells = <0>;
					port@0 {
						reg = <0x0>;
						phy-handle = <&t1phy0>;
						phy-mode = "internal";
						label = "lan1";
					};
					port@1 {
						reg = <0x1>;
						phy-handle = <&t1phy1>;
						phy-mode = "internal";
						label = "lan2";
					};
					port@2 {
						reg = <0x2>;
						phy-handle = <&t1phy2>;
						phy-mode = "internal";
						label = "lan3";
					};
					port@3 {
						reg = <0x3>;
						phy-handle = <&t1phy3>;
						phy-mode = "internal";
						label = "lan4";
					};
					port@4 {
						reg = <4>;
						phy-mode = "rmii";
						label = "cpu";
						ethernet = <&cpsw_port2>;
						fixed-link {
							speed = <100>;
							full-duplex;
						};
					};
			};
				mdio {
					#address-cells = <1>;
					#size-cells = <0>;
					compatible = "microchip,lan937x-mdio";
					
					t1phy0: ethernet-phy@0{
						//interrupt-parent = <&lan9370>;
						//interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
						reg = <0x0>;
					};
					t1phy1: ethernet-phy@1{
						//interrupt-parent = <&lan9370>;
						//interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
						reg = <0x1>;
					};
					t1phy2: ethernet-phy@2{
						//interrupt-parent = <&lan9370>;
						//interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
						reg = <0x2>;
					};
					t1phy3: ethernet-phy@3{
						//interrupt-parent = <&lan9370>;
						//interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
						reg = <0x3>;
					};
				};
		};

};`

kindly help me in this

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello,

To configure two SPI devices on SPI1 with two different chip select (CS) lines on a Verdin module, your device tree (DT) configuration needs to correctly define the cs-gpios property within the SPI master controller node. This property should list all GPIOs used as chip selects for the SPI devices connected to this controller, with each GPIO defined in the order of the devices’ reg property values.

From your snippet, it seems you’re attempting to define a configuration for two devices (max14830 and lan9370) on the same SPI bus (main_spi1) but have encountered issues. Let’s address the configuration:

  1. Correct cs-gpios Definition: Ensure that the cs-gpios property in your SPI controller node (&main_spi1) correctly references the GPIOs intended for use as chip selects for both devices. Each entry in cs-gpios should be a GPIO specifier, which typically includes the GPIO controller node, the GPIO number, and the active state (usually GPIO_ACTIVE_LOW or GPIO_ACTIVE_HIGH). If you’re using two different GPIOs for chip selects, both should be listed here in the order corresponding to the reg property of the SPI devices.

  2. Device reg Property: The reg property for each device on the SPI bus indicates the chip select line (starting from 0) that the device is connected to. It seems you have this correctly set with reg = <0>; for max14830 and reg = <1>; for lan9370, assuming max14830 is connected to the first CS line and lan9370 to the second.

  3. Example cs-gpios Configuration:
    Assuming mcu_gpio0 2 is the GPIO intended for the first device’s CS and another GPIO (let’s say &mcu_gpio1 3) is for the second device’s CS, the cs-gpios property should look like this:

    cs-gpios = <&mcu_gpio0 2 GPIO_ACTIVE_LOW>, <&mcu_gpio1 3 GPIO_ACTIVE_LOW>;
    

    This configuration indicates that the first device (reg = <0>) uses mcu_gpio0 2 as CS, and the second device (reg = <1>) uses mcu_gpio1 3.

  4. Ensure Correct GPIO References: Verify

Please, also check if these links can help you solve your problem:

CAN (Linux) | Toradex Developer Center.

Hi @naveenkumar.muthusam,

As suggested by Toradex AI, have you tried adding SPI CS?
Is issue resolved if not please share git diff and supporting logs to further check along with complete software and hardware version you are using.

Best regards
Ritesh Kumar