Hikey board SPI

Hi.

I would like to use SPI-I/F of hikey board.
How should I write the device tree?
Now I try writing .dtsi files, but SPI is NOT registerd.
I cannot find f7106000.spi under /sys/devices/smb .
Maybe, more information for pinmux is necessary.
(Detail is NOT described in Hi6220V100_Multi-Mode_Application_Processor_Function_Description.pdf.)
Please teach me how to register SPI-I/F.

The followings are my trial code. [Base: android-5.1.1_r1(LMY47V)]
Especially, I want to know parts indicated by ‘**’.

■arch/arm64/boot/dts/hi6220.dtsi

             spi_0: spi@f7106000 {
                    compatible = "arm,pl022", "arm,primecell";
                    reg = <0x0 0xf7106000 0x0 0x1000>;
                    #address-cells = <1>;
                    #size-cells = <0>;
                    interrupts = <0 ** 0x4>;
                    clocks = <&clock_sys HI6220_SPI_CLK>;
                    clock-names = "clk_spi";
                    pinctrl-names = "default";
                    pinctrl-0 = <& spi0_pmx_func &spi0_cfg_func>;

                    m25p80@1 {
                            compatible = "st,m25p80";
                            reg = <1>;
                            spi-max-frequency = <50000000>;
                            spi-cpol;
                            spi-cpha;
                            pl022,hierarchy = <0>;
                            pl022,interface = <0>;
                            pl022,slave-tx-disable;
                            pl022,com-mode = <0x0>;
                            pl022,rx-level-trig = <0>;
                            pl022,tx-level-trig = <0>;
                            pl022,ctrl-len = <0x11>;
                            pl022,wait-state = <0>;
                            pl022,duplex = <0>;
                    };
            };

■arch/arm64/boot/dts/hikey-pinctrl.dtsi
spi0_pmx_func: spi0_pmx_func {
pinctrl-single,pins = <
0x** MUX_M0 /* SPI0_DI (IOMG???) /
0x
* MUX_M0 /* SPI0_DO (IOMG???) /
0x
* MUX_M0 /* SPI0_CS_N (IOMG???) /
0x
* MUX_M0 /* SPI0_CLK (IOMG???) */
>;
};

                    spi0_cfg_func: spi0_cfg_func {
                            pinctrl-single,pins = &lt;
                                    0x***  0x0      /* SPI0_DI     (IOCFG???) */
                                    0x***  0x0      /* SPI0_DO     (IOCFG???) */
                                    0x***  0x0      /* SPI0_CS_N   (IOCFG???) */
                                    0x***  0x0      /* SPI0_CLK    (IOCFG???) */
                            &gt;;
                            pinctrl-single,bias-pulldown  = &lt;PULL_DIS  PULL_DOWN PULL_DIS  PULL_DOWN&gt;;
                            pinctrl-single,bias-pullup    = &lt;PULL_DIS  PULL_UP   PULL_DIS  PULL_UP&gt;;
                            pinctrl-single,drive-strength = &lt;DRIVE1_02MA DRIVE_MASK&gt;;
                    };

diff --git a/arch/arm64/boot/dts/hikey-pinctrl.dtsi b/arch/arm64/boot/dts/hikey-pinctrl.dtsi
index 6833236…21319b5 100644
— a/arch/arm64/boot/dts/hikey-pinctrl.dtsi
+++ b/arch/arm64/boot/dts/hikey-pinctrl.dtsi
@@ -221,6 +221,15 @@
0xfc MUX_M0 /* I2C2_SDA (IOMG063) */
>;
};
+

  •                   spi0_pmx_func: spi0_pmx_func {
    
  •                           pinctrl-single,pins = &lt;
    
  •                                   0x1a0  MUX_M1   /* SPI0_DI      (IOMG104) */
    
  •                                   0x1a4  MUX_M1   /* SPI0_DO      (IOMG105) */
    
  •                                   0x1a8  MUX_M1   /* SPI0_CS_N    (IOMG106) */
    
  •                                   0x1ac  MUX_M1   /* SPI0_CLK     (IOMG107) */
    
  •                           &gt;;
    
  •                   };
              };
    
              pmx1: pinmux@f7010800 {
    

@@ -625,6 +634,18 @@
pinctrl-single,bias-pullup = <PULL_DIS PULL_UP PULL_DIS PULL_UP>;
pinctrl-single,drive-strength = <DRIVE1_02MA DRIVE_MASK>;
};
+

  •                   spi0_cfg_func: spi0_cfg_func {
    
  •                           pinctrl-single,pins = &lt;
    
  •                                   0x1b0  0x0      /* SPI0_DI      (IOCFG108) */
    
  •                                   0x1b4  0x0      /* SPI0_DO      (IOCFG109) */
    
  •                                   0x1b8  0x0      /* SPI0_CS_N    (IOCFG110) */
    
  •                                   0x1bc  0x0      /* SPI0_CLK     (IOCFG111) */
    
  •                           &gt;;
    
  •                           pinctrl-single,bias-pulldown  = &lt;PULL_DIS  PULL_DOWN PULL_DIS PULL_DOWN&gt;;
    
  •                           pinctrl-single,bias-pullup    = &lt;PULL_DIS  PULL_UP   PULL_DIS PULL_UP&gt;;
                                                                                                                                  1,1           Top

Just merged the above back into the hikey kernel tree:

see below:
https://github.com/96boards/linux/commit/72811733bdb8c1975a1d34cd793734cb092703a3

Hi.
Thank you for the detail setting about pinmux.
I tried to rebuild, but I could not find f7106000.spi under /sys/devices/smb .
In addition to hikey-pinctrl.dtsi, I modified hi6220.dtsi and hi6220-hikey.dts .
(The others are NOT changed. Is this cause?)
Please teach me what should I do!

The following the difference.
— a/arch… : original
— b/arch… : modified code

— a/arch/arm64/boot/dts/hi6220.dtsi 2015-08-12 09:20:56.000000000 -0700
+++ b/arch/arm64/boot/dts/hi6220.dtsi 2015-09-29 17:36:55.565290865 -0700
@@ -670,6 +670,36 @@
};
};

  •             spi_0: spi@f7106000 {
    
  •                    compatible = "arm,pl022", "arm,primecell";
    
  •                    reg = &lt;0x0 0xf7106000 0x0 0x1000&gt;;
    
  •                    #address-cells = &lt;1&gt;;
    
  •                    #size-cells = &lt;0&gt;;
    
  •                    interrupts = &lt;0 82 0x4&gt;;
    
  •                    clocks = &lt;&amp;clock_sys HI6220_SPI_CLK&gt;;
    
  •                    clock-names = "clk_spi";
    
  •                    pinctrl-names = "default";
    
  •                    pinctrl-0 = &lt;&amp;spi0_pmx_func &amp;spi0_cfg_func&gt;;
    
  •   	status = "ok";
    
  •                    m25p80@1 {
    
  •                            compatible = "st,m25p80";
    
  •                            reg = &lt;1&gt;;
    
  •                            spi-max-frequency = &lt;50000000&gt;;
    
  •                            spi-cpol;
    
  •                            spi-cpha;
    
  •                            pl022,hierarchy = &lt;0&gt;;
    
  •                            pl022,interface = &lt;0&gt;;
    
  •                            pl022,slave-tx-disable;
    
  •                            pl022,com-mode = &lt;0x0&gt;;
    
  •                            pl022,rx-level-trig = &lt;0&gt;;
    
  •                            pl022,tx-level-trig = &lt;0&gt;;
    
  •                            pl022,ctrl-len = &lt;0x11&gt;;
    
  •                            pl022,wait-state = &lt;0&gt;;
    
  •                            pl022,duplex = &lt;0&gt;;
    
  •                    };
    
  •            };
    
  •   display-subsystem {
      	compatible = "hisilicon,hi6220-drm";
      	#address-cells = &lt;2&gt;;
    

— a/arch/arm64/boot/dts/hi6220-hikey.dts 2015-08-12 09:20:56.000000000 -0700
+++ b/arch/arm64/boot/dts/hi6220-hikey.dts 2015-09-17 23:57:06.038697687 -0700
@@ -29,6 +29,7 @@
mshc0 = &dwmmc_0;
mshc1 = &dwmmc_1;
mshc2 = &dwmmc_2;

  •   spi0 = &amp;spi_0;
    

    };

    chosen {

I doubt that it’s caused by SPI0 controller stay in reset mode after reset. Now I make it out of reset in UEFI instead. Could you help to fetch the latest UEFI (#76)? You could build it by yourself, since I didn’t find the UEFI build #76.

Hi,

Is it working for u?
I am trying to understand how we can add spi slave?