SW 개발

[kernel] ARM PL022 Driver

. . . 2019. 8. 21. 13:59
반응형

드라이버쪽 작업을 하였던 내용을 간단정리

ARM PL022 드라이버

ARM 쪽에서 개발한 표준 컨트롤러인듯?

  • 특징
    • SPI 컨트롤러
    • 일반 SPI / Texas Instruments Synchronous Serial Frame Format / Microwire 의 3가지 통신을 한 컨트롤러에서 지원

즉, 해당 컨트롤러에서 여러가지 통신사양을 지원하기 때문에 어떤 통신을 써야할지 명시해줘야한다.

드라이버내에서 하드코딩하지는 않고... Device Tree 에서 설정 해주면된다.

밑의 커널문서를 보면 해결될듯..

ARM PL022 SPI controller

Required properties:
- compatible : "arm,pl022", "arm,primecell"
- reg : Offset and length of the register set for the device
- interrupts : Should contain SPI controller interrupt
- num-cs : total number of chipselects

Optional properties:
- cs-gpios : should specify GPIOs used for chipselects.
  The gpios will be referred to as reg = <index> in the SPI child nodes.
  If unspecified, a single SPI device without a chip select can be used.
- pl022,autosuspend-delay : delay in ms following transfer completion before
                            the runtime power management system suspends the
                            device. A setting of 0 indicates no delay and the
                            device will be suspended immediately
- pl022,rt : indicates the controller should run the message pump with realtime
             priority to minimise the transfer latency on the bus (boolean)
- dmas : Two or more DMA channel specifiers following the convention outlined
         in bindings/dma/dma.txt
- dma-names: Names for the dma channels, if present. There must be at
             least one channel named "tx" for transmit and named "rx" for
             receive.


SPI slave nodes must be children of the SPI master node and can
contain the following properties.

- pl022,interface : interface type:
    0: SPI
    1: Texas Instruments Synchronous Serial Frame Format
    2: Microwire (Half Duplex)
- pl022,com-mode : specifies the transfer mode:
    0: interrupt mode
    1: polling mode (default mode if property not present)
    2: DMA mode
- pl022,rx-level-trig : Rx FIFO watermark level
- pl022,tx-level-trig : Tx FIFO watermark level
- pl022,ctrl-len : Microwire interface: Control length
- pl022,wait-state : Microwire interface: Wait state
- pl022,duplex : Microwire interface: Full/Half duplex


Example:

    spi@e0100000 {
        compatible = "arm,pl022", "arm,primecell";
        reg = <0xe0100000 0x1000>;
        #address-cells = <1>;
        #size-cells = <0>;
        interrupts = <0 31 0x4>;
        dmas = <&dma-controller 23 1>,
            <&dma-controller 24 0>;
        dma-names = "rx", "tx";

        m25p80@1 {
            compatible = "st,m25p80";
            reg = <1>;
            spi-max-frequency = <12000000>;
            spi-cpol;
            spi-cpha;
            pl022,interface = <0>;
            pl022,com-mode = <0x2>;
            pl022,rx-level-trig = <0>;
            pl022,tx-level-trig = <0>;
            pl022,ctrl-len = <0x11>;
            pl022,wait-state = <0>;
            pl022,duplex = <0>;
        };
    };
  • 즉, client 쪽 device tree 설정에... pl022,xxxx 의 설정들을 해준다.
    • pl022,interface 설정을 하면, 어떤 컨트롤러로 사용할지 설정

pl022 통신안될때...

다음의 사항들을 확인해보자.

  • spi client 의 채널이 맞는지?
  • num-cs 설정이 맞는지?
    • 직접 핀찍어보고 cs 안흔들리면 gpio 설정으로도 잡아본다
  • pl022,interface 설정이 맞는지?
    • 사용하고자 하는 통신인터페이스로 제대로 설정이 되었는지확인
반응형