AnsweredAssumed Answered

(i.MX8) How SPI driver control the LPSPI3 CS1 pin if it can not config to GPIO ?

Question asked by Andy Huang on Oct 23, 2018
Latest reply on Oct 29, 2018 by Andy Huang

Hi, 

   I am using i.MX8QXP custom board with 4.9.88_beta 2 SDK to develop.

We connect 2 spi slave devices to the LPSPI3 port, but I found the SPI3_CS1 can not config to GPIO.

 

   In the spi-fsl-lpspi.c , the chipselect should be gpio to let the driver control which spi device to be select.

So my questions are

1.  In LPSPI3 ,  the driver how to control SPI3_CS1 if this pin can not config to GPIO

2. IF SPI3_CS0 , SPI3_CS1 can be set to gpio , what is the correct representation in dts ?

     like below ??

     cs-gpios = <&gpio1 16 GPIO_ACTIVE_LOW> ,  <&gpio1 17 GPIO_ACTIVE_LOW> ,  

  

 

 

 

spi-fsl-lpspi.c

 

for (i = 0; i < master->num_chipselect; i++) {
int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);

if (!gpio_is_valid(cs_gpio) && lpspi_platform_info)
cs_gpio = lpspi_platform_info->chipselect[i];

fsl_lpspi->chipselect[i] = cs_gpio;
if (!gpio_is_valid(cs_gpio))
continue;

ret = devm_gpio_request(&pdev->dev, fsl_lpspi->chipselect[i],
DRIVER_NAME);
if (ret) {
dev_err(&pdev->dev, "can't get cs gpios\n");
goto out_master_put;
}
}

 

 

 

my spi3 dts part

 

pinctrl_lpspi3: lpspi3grp {
fsl,pins = <
SC_P_SPI3_SCK_ADMA_SPI3_SCK 0x0600004c
SC_P_SPI3_SDO_ADMA_SPI3_SDO 0x0600004c
SC_P_SPI3_SDI_ADMA_SPI3_SDI 0x0600004c
SC_P_SPI3_CS1_ADMA_SPI3_CS1 0x0600004c
>;
};

pinctrl_lpspi3_cs0: lpspi3_cs0 {
fsl,pins = <
SC_P_SPI3_CS0_LSIO_GPIO0_IO16 0x21

>;
}

&lpspi3 {
#address-cells = <1>;
#size-cells = <0>;
fsl,spi-num-chipselects = <2>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_lpspi3 &pinctrl_lpspi3_cs0>;
cs-gpios = <&gpio1 16 GPIO_ACTIVE_LOW>;
status = "okay";


spidev@0 {
compatible = "rohm,dh2228fv";
spi-max-frequency = <500000>;
reg = <0>;
}

spidev@1 {
compatible = "rohm,dh2228fv";
spi-max-frequency = <500000>;
reg = <0>;
};

};

 

 

Best,

Andy

Outcomes