Put SPI2 interface into idle mode

Hello,

I’m trying to put the SPI2 interface into idle mode by setting a specific pin configuration but I cannot find a document explaining how to set registries or configure functions.

I tried playing with CS line in hikey960-pinctrl.dtsi as following :

spi2_cfg_csn_idle: spi2_cfg_csn_idle {
pinctrl-single,pins = <
0x0a8 0x0 /* SPI2_CS0_N */
>;
pinctrl-single,bias-pulldown = <
PULL_DOWN
PULL_DOWN
PULL_DIS
PULL_DOWN
>;
pinctrl-single,bias-pullup = <
PULL_DIS
PULL_UP
PULL_DIS
PULL_UP
>;
pinctrl-single,drive-strength = <
DRIVE7_02MA DRIVE6_MASK
>;
};

but no change when I stop communicating over SPI.
Following is my setting for SPI driver:
spi2: spi@ffd68000 {
compatible = “arm,pl022”, “arm,primecell”;
reg = <0x0 0xffd68000 0x0 0x1000>;
#address-cells = <1>;
#size-cells = <0>;
interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&crg_ctrl HI3660_CLK_GATE_SPI2>;
clock-names = “apb_pclk”;
pinctrl-names = “default” , “idle”;
pinctrl-0 = <&spi2_pmx_func>;
pinctrl-1 = <&spi2_cfg_csn_idle>;
num-cs = <1>;
cs-gpios = <&gpio27 2 0>;

Thanks for helping me.

I’m trying to put the SPI2 interface into idle mode by setting a specific pin configuration but I cannot find a document explaining how to set registries or configure functions.

Best place to look into is the Pinctrl Single Kernel documentation. There you can get information about how to configure the pinctrl states. This driver is what used by HiKey960.

but no change when I stop communicating over SPI.

Pin configurations will only be changed when Power management options are selected during kernel compilation. So you need to be sure that the kernel you are running has following Kconfig options selected:

CONFIG_PM=y
CONFIG_PM_SLEEP=y

The rest should be taken care by the SPI and Pinctrl drivers to put the SPI bus and pins to respective states. So for testing this scenario, you can use the sysfs attributes to force the SPI controller to power saving states and observe the specific Pin state using a scope. Additionally, I’d also select CONFIG_PM_DEBUG to get more verbose messages from driver core.

Hello Mani,

Thanks a lot for your clarifications, I will check this out.

Hello Mani, I’m still stuck with this point as I enabled CONFIG_PM and CONFIG_PM_SLEEP, but looks like there is no effect at least when checking with sysfs.

I would say maybe I did something wrong on the device tree trying to define “&spi2_cfg_csn_idle” that is in the code I shared before.
My concern is that I cannot find any documentation on the use of pinctrl and how to configure the SPI lines PULLUP/PULLDOWN… for the Hikey960
Also there no documentation on the functions supported by the SPI cell.

Can you please guide me on a document or a reference ?

Thanks