2021-11-22 11:34 PM
Hi ,
We are using stm32mp157a processor in our custom board.We want to configure Spi1 to Ethernet Switch(ksz9893rnxia) (Note : we have 2 slaves for Spi1 at Uboot level(Source code ver 2018.11). I have done Pin control and node creations in dts files.
1) we are using spi_setup_slave(unsigned int bus, unsigned int cs,unsigned int max_hz, unsigned int mode) (In my case we gave parameters as follows spi_setup_slave(1,0,1000,0) for slave setup but We are getting 0 as return value.We confused about bus,cs,max_hz,mode parameters in spi_setup_slave() function.
path for spi_setup_slave Function :"https://elixir.bootlin.com/u-boot/v2018.11/source/drivers/spi/spi-uclass.c#L103".
2.if we have more than 1 slave how do we differentiate the cs numbers for spi.
3.which driver function is used for spi transmitting and receiving data.
Our spi related dts as follows.
board_level dts:
&spi1 {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&spi1_pins_a>;
pinctrl-1 = <&spi1_sleep_pins_a>;
cs-gpios = <&gpioz 3 0>;
status = "okay";
ethernet-switch@0 {
compatible = "microchip,KSZ9893RNXIA";
reg = <0>; /* CS #0 */
spi-max-frequency = <10000000>;
#address-cells = <1>;
#size-cells = <1>;
spi-rx-bus-width = <8>;
spi-tx-bus-width = <8>;
};
};
Processor Related Dts:
spi1_pins_a: spi1-0 {
pins1 {
pinmux = <STM32_PINMUX('Z', 0, AF5)>, /* SPI1_SCK */
<STM32_PINMUX('Z', 2, AF5)>, /* SPI1_MOSI */
bias-disable;
drive-push-pull;
slew-rate = <1>;
};
pins2 {
pinmux = <STM32_PINMUX('Z', 1, AF5)>; /* SPI1_MISO */
bias-disable;
};
};
spi1_sleep_pins_a: spi1-sleep-0 {
pins {
pinmux = <STM32_PINMUX('Z', 0, ANALOG)>, /* SPI1_SCK */
<STM32_PINMUX('Z', 1, ANALOG)>, /* SPI1_MISO */
<STM32_PINMUX('Z', 2, ANALOG)>, /* SPI1_MOSI */
};
};
Is this correct way to configure spi?
Thanks in advance.