This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

求助:AM335x在linux环境下,如何更改SPI1数据线SPI1_D0,SPI1_D1的方向?

Other Parts Discussed in Thread: DAC7760

大家好!请帮忙看看:

AM335x使用linux自带的SPI驱动,master模式,用示波器测试发现SPI1_D0数据线方向默认为输入,SPI1_D1数据线方向为输出。

想把SPI1_D0数据线方向配置成输出,SPI1_D1配置为输入,应该如何更改内核?先谢谢了!

AM335x的Table 24-4. McSPI Pin List中有写:SPIx_D0和SPIx_D1都能配置为输入或输出“(Can be configured as either input or output (MOSI or MISO)”,因为我硬件电路上已经做死了(SPI1_D0输出,SPI1_D1输入)。

    • 你只需要在device tree 文件 am33xx.dtsi. 的地方 spi1: spi@481a0000 node 增加一句话:

    • spi1: spi@481a0000 {
      compatible = "ti,omap4-mcspi";
      #address-cells = <1>;
      #size-cells = <0>;
      reg = <0x481a0000 0x400>;
      interrupts = <125>;
      ti,spi-num-cs = <2>;
      ti,hwmods = "spi1";

    • ti,pindir-d0-out-d1-in = <1>;  

    • dmas = <&edma 42 0
      &edma 43 0
      &edma 44 0
      &edma 45 0>;
      dma-names = "tx0", "rx0", "tx1", "rx1";
      status = "disabled";
      };

  • 谢谢Eggsy Pang的回复!

    但是我们在linux系统源码里找不到am33xx.dtsi这个文件,在arch/arm/boot/dts/目录下只看到omap2.dtsi比较接近一些,如下,但是里面也没有对SPI的描述,应该怎么办?再次谢谢!

    /*
    * Device Tree Source for OMAP2 SoC
    *
    * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
    *
    * This file is licensed under the terms of the GNU General Public License
    * version 2. This program is licensed "as is" without any warranty of any
    * kind, whether express or implied.
    */

    /include/ "skeleton.dtsi"

    / {
    compatible = "ti,omap2430", "ti,omap2420", "ti,omap2";

    aliases {
    serial0 = &uart1;
    serial1 = &uart2;
    serial2 = &uart3;
    };

    cpus {
    cpu@0 {
    compatible = "arm,arm1136jf-s";
    };
    };

    soc {
    compatible = "ti,omap-infra";
    mpu {
    compatible = "ti,omap2-mpu";
    ti,hwmods = "mpu";
    };
    };

    ocp {
    compatible = "simple-bus";
    #address-cells = <1>;
    #size-cells = <1>;
    ranges;
    ti,hwmods = "l3_main";

    intc: interrupt-controller@1 {
    compatible = "ti,omap2-intc";
    interrupt-controller;
    #interrupt-cells = <1>;
    };

    uart1: serial@4806a000 {
    compatible = "ti,omap2-uart";
    ti,hwmods = "uart1";
    clock-frequency = <48000000>;
    };

    uart2: serial@4806c000 {
    compatible = "ti,omap2-uart";
    ti,hwmods = "uart2";
    clock-frequency = <48000000>;
    };

    uart3: serial@4806e000 {
    compatible = "ti,omap2-uart";
    ti,hwmods = "uart3";
    clock-frequency = <48000000>;
    };
    };
    };


  • 请问您用的是哪个版本的SDK

  • SDK版本?我们用的linux内核版本是3.2.0,是指这个吗?

  • 是的

    这个版本没有使用device tree功能

    所以解决方法是:

    打开文件 Spi-omap2-mcspi.c (c:\sitara\sitara\linux\drivers\spi) 定位到函数:

    static int omap2_mcspi_setup_transfer(struct spi_device *spi, struct spi_transfer *t){

    。。。。

    l &= ~(OMAP2_MCSPI_CHCONF_IS|OMAP2_MCSPI_CHCONF_DPE1);
    l |= OMAP2_MCSPI_CHCONF_DPE0;

    。。。

    }

    修改为

    static int omap2_mcspi_setup_transfer(struct spi_device *spi, struct spi_transfer *t){

    。。。。

    l &=~( OMAP2_MCSPI_CHCONF_DPE0);

    l |= (OMAP2_MCSPI_CHCONF_IS|OMAP2_MCSPI_CHCONF_DPE1);

    。。。

    }

    然后重新编译内核 module ,放到文件系统中

  • 非常感谢!这样可以!

  • 使用SPI1配置DAC7760,CS的时序不匹配DAC7760的Latch,准备将SPI1的CS改为GPIO的方式片选DAC7760,怎么修改dts文件让SPI的cs信号采用GPIO的方式驱动?

  • 准备将SPI1的CS改为GPIO的方式片选DAC7760?",请问此问题有解码?"

  • 您好,原来读取ID时的时d1没有输出数据,d0能检测到输出指令。按着这个方法改了后,现在d1有输出信号,但是cs片选线和d1的信号一样,这是为什么?