imx6 add spi slave mode cause other problems

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

imx6 add spi slave mode cause other problems

5,519 次查看
lixuhui112
Contributor I

HI:

I use imx6ul  ,linux kenerl version branch imx_4.1.15_1.0.0_ga, I refrence branch imx_4.14.98_2.0.0_ga add spi slave mode to imx_4.1.15_1.0.0_ga, and spi slave mode is proper functioning, but it affects ecspi flash and other pad ,such as PAD_GPIO1_IO00,details are as follows:

1 . ecspi flash problem:

my ecspi flash config

   &ecspi1 {
    fsl,spi-num-chipselects = <1>;
    cs-gpios = <&gpio4 26 0>;
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_ecspi1 &pinctrl_ecspi1_cs>;
    status = "okay"; /* pin conflict with WEIM NOR */

    flash: m25p80@0 {
        #address-cells = <1>;
        #size-cells = <1>;
        compatible = "micron,n25q128a13";
        spi-max-frequency = <40000000>;
        reg = <0>;
    };
};

        pinctrl_ecspi1: ecspi1grp {
            fsl,pins = <
                MX6UL_PAD_CSI_DATA04__ECSPI1_SCLK     0x1b0b0
                MX6UL_PAD_CSI_DATA06__ECSPI1_MOSI     0x1b0b0
                MX6UL_PAD_CSI_DATA07__ECSPI1_MISO    0x1b0b0
            >;
        };

        pinctrl_ecspi1_cs: ecspi1cs {
            fsl,pins = <
                MX6UL_PAD_CSI_DATA05__GPIO4_IO26     0x1b0b0
            >;
        };

and ecspi3 slave config

&ecspi3 {
    #address-cells = <1>;
    #size-cells = <0>;
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_ecspi3>;
    status = "okay";
    spi-slave;

    spidev0: spi@0 {
        reg = <0>;
        compatible = "rohm,dh2228fv";
        spi-max-frequency = <20000000>;
    };
};

        pinctrl_ecspi3: ecspi3grp {
            fsl,pins = <
                MX6UL_PAD_NAND_CE0_B__ECSPI3_SCLK    0x5011    //0x70a1
                MX6UL_PAD_NAND_CE1_B__ECSPI3_MOSI    0x5011    //0x70a1
                MX6UL_PAD_NAND_CLE__ECSPI3_MISO     0x5011    //0x70a1
                MX6UL_PAD_NAND_RE_B__ECSPI3_SS2        0x5011    //0x70a1
            SS>;
        };

Starting kernel ...
 
Booting Linux on physical CPU 0x0
Linux version 4.1.15+ (lxh@lxh) (gcc version 5.2.0 (GCC) ) #12 SMP PREEMPT Wed Jun 5 09:29:05 CST 2019
CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c53c7d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine model: Freescale i.MX6 UltraLite 14x14 EVK Board
Reserved memory: created CMA memory pool at 0x8c000000, size 320 MiB
Reserved memory: initialized node linux,cma, compatible id shared-dma-pool
Memory policy: Data cache writealloc
PERCPU: Embedded 12 pages/cpu @8bb2f000 s16704 r8192 d24256 u49152
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
Kernel command line: console=ttymxc1,115200 mtdparts=spi0.0:512k(uboot),256k(env),256k(script),4m(kernel),256k(dtb),3840k(rootfs),2m(config),2m(statistics),-(user)
PID hash table entries: 2048 (order: 1, 8192 bytes)
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 181204K/524288K available (4672K kernel code, 228K rwdata, 1660K rodata, 320K init, 400K bss, 15404K reserved, 327680K cma-reserved, 0K highmem)
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    vmalloc : 0xa0800000 - 0xff000000   (1512 MB)
    lowmem  : 0x80000000 - 0xa0000000   ( 512 MB)
    pkmap   : 0x7fe00000 - 0x80000000   (   2 MB)
    modules : 0x7f000000 - 0x7fe00000   (  14 MB)
      .text : 0x80008000 - 0x80637594   (6334 kB)
      .init : 0x80638000 - 0x80688000   ( 320 kB)
      .data : 0x80688000 - 0x806c1360   ( 229 kB)
       .bss : 0x806c4000 - 0x807281e8   ( 401 kB)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Preemptible hierarchical RCU implementation.
        Additional per-CPU info printed with stalls.
        RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=1.
RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
NR_IRQS:16 nr_irqs:16 16
mxc_clocksource_init 24000000
Switching to timer-based delay loop, resolution 41ns
sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
clocksource mxc_timer1: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
Console: colour dummy device 80x30
Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
/cpus/cpu@0 missing clock-frequency property
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x80008280 - 0x800082d8
Brought up 1 CPUs
SMP: Total of 1 processors activated (48.00 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
clocksource jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
cpuidle: using governor ladder
cpuidle: using governor menu
hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
hw-breakpoint: maximum watchpoint size is 8 bytes.
imx6ul-pinctrl 20e0000.iomuxc: initialized IMX pinctrl driver
mxs-dma 1804000.dma-apbh: initialized
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
PTP clock support registered
Switched to clocksource mxc_timer1
NET: Registered protocol family 2
TCP established hash table entries: 4096 (order: 2, 16384 bytes)
TCP bind hash table entries: 4096 (order: 3, 32768 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
UDP hash table entries: 256 (order: 1, 8192 bytes)
UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
Trying to unpack rootfs image as initramfs...
Freeing initrd memory: 2724K (83800000 - 83aa9000)
imx rpmsg driver is registered.
Bus freq driver module loaded
futex hash table entries: 256 (order: 2, 16384 bytes)
VFS: Disk quotas dquot_6.6.0
VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
NFS: Registering the id_resolver key type
Key type id_resolver registered
Key type id_legacy registered
ntfs: driver 2.1.32 [Flags: R/O].
jffs2: version 2.2. (NAND) ? 2001-2006 Red Hat, Inc.
fuse init (API version 7.23)
io scheduler noop registered (default)
imx-weim 21b8000.weim: Driver registered.
imx-sdma 20ec000.sdma: no event needs to be remapped
imx-sdma 20ec000.sdma: loaded firmware 3.3
imx-sdma 20ec000.sdma: initialized
2020000.serial: ttymxc0 at MMIO 0x2020000 (irq = 22, base_baud = 5000000) is a IMX
21e8000.serial: ttymxc1 at MMIO 0x21e8000 (irq = 224, base_baud = 5000000) is a IMX
console [ttymxc1] enabled
imx sema4 driver is registered.
brd: module loaded
loop: module loaded
m25p80 spi0.0: n25q128a13 (16384 Kbytes)
9 cmdlinepart partitions found on MTD device spi0.0
Creating 9 MTD partitions on "spi0.0":
0x000000000000-0x000000080000 : "uboot"
0x000000080000-0x0000000c0000 : "env"
0x0000000c0000-0x000000100000 : "script"
0x000000100000-0x000000500000 : "kernel"
0x000000500000-0x000000540000 : "dtb"
0x000000540000-0x000000900000 : "rootfs"
0x000000900000-0x000000b00000 : "config"
0x000000b00000-0x000000d00000 : "statistics"
0x000000d00000-0x000001000000 : "user"
spi_imx 2008000.ecspi: probed
spi_slave spi2: /soc/aips-bus@02000000/spba-bus@02000000/ecspi@02010000/spi@0 is not called 'slave'
spi_slave spi2: Failed to create SPI device for /soc/aips-bus@02000000/spba-bus@02000000/ecspi@02010000/spi@0
spi_imx 2010000.ecspi: probed
spi_imx 2014000.ecspi: probed
20b4000.ethernet supply phy not found, using dummy regulator
pps pps0: new PPS source ptp0
fec 20b4000.ethernet (unnamed net_device) (uninitialized): Invalid MAC address: 00:00:00:00:00:00
fec 20b4000.ethernet (unnamed net_device) (uninitialized): Using random MAC address: e6:83:65:7b:d8:9a
libphy: fec_enet_mii_bus: probed
fec 20b4000.ethernet eth0: registered PHC device 0
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci-mxc: Freescale On-Chip EHCI Host driver
usbcore: registered new interface driver cdc_acm
cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
usbcore: registered new interface driver usblp
usbcore: registered new interface driver usb-storage
usbcore: registered new interface driver usbserial
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial support registered for generic
usbcore: registered new interface driver ftdi_sio
usbserial: USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver pl2303
usbserial: USB Serial support registered for pl2303
usbcore: registered new interface driver usb_ehset_test
2184800.usbmisc supply vbus-wakeup not found, using dummy regulator
2184000.usb supply vbus not found, using dummy regulator
2184200.usb supply vbus not found, using dummy regulator
ci_hdrc ci_hdrc.1: EHCI Host Controller
ci_hdrc ci_hdrc.1: new USB bus registered, assigned bus number 1
ci_hdrc ci_hdrc.1: USB 2.0 started, EHCI 1.00
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
input: 20cc000.snvs:snvs-powerkey as /devices/platform/soc/2000000.aips-bus/20cc000.snvs/20cc000.snvs:snvs-powerkey/input/input0
snvs_rtc 20cc000.snvs:snvs-rtc-lp: rtc core: registered 20cc000.snvs:snvs-r as rtc0
i2c /dev entries driver
imx2-wdt 20bc000.wdog: use WDOG_B to reboot.
imx2-wdt 20bc000.wdog: timeout 60 sec (nowayout=0)
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
sdhci-pltfm: SDHCI platform and OF driver helper
NET: Registered protocol family 17
Key type dns_resolver registered
input: gpio_keys as /devices/platform/gpio_keys/input/input1
snvs_rtc 20cc000.snvs:snvs-rtc-lp: setting system clock to 1970-01-01 00:00:00 UTC (0)
gpio_dvfs: disabling
usb_otg2_vbus: disabling
Freeing unused kernel memory: 320K (80638000 - 80688000)
fec 20b4000.ethernet eth0: Freescale FEC PHY driver [Micrel KSZ8081 or KSZ8091] (mii_bus:phy_addr=20b4000.ethernet:01, irq=-1)
 
 
spi_master spi0: I/O Error in DMA RX
spi_master spi0: failed to transfer one message from queue
mount: mounting /dev/mtdblock6 on /home/config/ failed: Input/output error
 
Please press Enter to activate this console. random: nonblocking pool is initialized

root@root:/#

2.then I use spi_slave

root@root:/# echo spidev > /sys/class/spi_slave/spi2/slave

i use  MX6UL_PAD_GPIO1_IO00 as GPIO input, is pulled to high level.

                        MX6UL_PAD_GPIO1_IO00__GPIO1_IO00       0x17059 //0xb0 //0x000010B0

标签 (5)
0 项奖励
回复
8 回复数

4,302 次查看
lixuhui112
Contributor I

and I use imx_4.14.98_2.0.0_ga kernel is the same phenomenon

0 项奖励
回复

4,302 次查看
jimmychan
NXP TechSupport
NXP TechSupport

The patch is available at:

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/patch/?id=71abd29057cb17b6b9... 

 

Basically, NXP kernel 4.1 does not support SPI slave mode. Not even NXP 4.14 supports it.

 

Only kernel 4.15 and 4.16 from mainline supports it.

 

In order to use SPI slave in these kernels the "spi-slave" property needs to be passed in the devicetree as explained at:

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/tree/Documentation/devicetre... 

0 项奖励
回复

4,302 次查看
guochgz
Contributor III

Dear jimmychan:

      我也有类似需求,我用IMX6ULL ecspi2 ,想配置成SPI-SLAVE模式,现在我同步了几个基线,L4.14.98和imx_4.19.35_1.0.0。 

      按照您说的,L4.14.98也不支持,仅L4.15以后的基线才支持。但是您们的另外一个技术支持igor的意思好像是L4.14.98就支持了? 从您给到的Patch来看,L4.14.98已经包含在了L4.14.98的基线中。

      另外,最重要的一点是,好像这两个基线spidev.c都没修改,我在DT文件中添加了SPI-SLAVE,用户空间中没有对应的设备节点出来。是我配置的不对吗?

&ecspi2 {
fsl,spi-num-chipselects = <1>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi2>;
spi-slave;
status = "okay";
spidev@1 {
compatible = "spidev";
spi-max-frequency = <20000000>;
reg = <0>;
};
};

Kernel的引导log如下:

spi_slave spi1: /soc/aips-bus@2000000/spba-bus@2000000/ecspi@200c000/spidev@1 is not called 'slave'
spi_slave spi1: Failed to create SPI device for /soc/aips-bus@2000000/spba-bus@2000000/ecspi@200c000/spidev@1
spi_imx 200c000.ecspi: probed

如果我注释掉

spidev@1 {
compatible = "spidev";
spi-max-frequency = <20000000>;
reg = <0>;
};

这几行,则不会报错。但是,dev目录下依旧没有spidev节点出来。另外两个master设备能够正常在dev中显示。

所以,我现在的问题是,如何使能SPI-SLAVE,并且在dev中显示slave节点?以便我用户空间的程序调用来接收数据?

0 项奖励
回复

4,302 次查看
guochgz
Contributor III

dev下没有接口的问题搞定了,修改dt文件,改name为slave就好。

0 项奖励
回复

4,302 次查看
guochgz
Contributor III

但是现在还有一个问题,通过spidev设备节点,读到的Master发送过来的数据不对,全是0x0。这个可能是什么问题? 是不是slave模式没有正确启动? 需要pastedImage_1.png

在这个目录下执行什么操作吗? 

0 项奖励
回复

4,302 次查看
jimmychan
NXP TechSupport
NXP TechSupport

what is the connection of the SPI on your board?

what is the pins mux setting in the dt file?

0 项奖励
回复

4,302 次查看
guochgz
Contributor III

   前端接了一个CC1200 RF 收发芯片。

   PIN管脚如下所示,其中CS管脚是我们自己接的一个GPIO。会按照我们程序读取数据的逻辑,拉高拉低。

pastedImage_4.png

pastedImage_2.png

      pastedImage_3.png

0 项奖励
回复

4,301 次查看
jimmychan
NXP TechSupport
NXP TechSupport

please add  cs-gpios = <&gpio4 22 0>;

0 项奖励
回复