MAX14830 not flushing TX

497 views Asked by At

So after a day of struggling I managed to get Debian 11 on a IMX7D, 5.4.129 kernel to recognize the MAX14830 and talk to it via the MAX310X driver. But when I try to send data with echo a > /dev/ttyMAX0 nothing happens. Well except the Tx count going up.

Looking at the SPI traffic this seems to be going correctly and the chip is sending the expected responses (Tx FIFO count returns three if three characters are being send) but nothing seems to happen to the buffer. The driver keeps interrogating the max but the FIFO stays at 3. Then the driver reaches a timeout I guess. Because it then sends 0x81,0x00 which clears the IRQen register, followed by 0x9B 0x40 which sets the baudrate register... which makes it all the more confusing.

So far I've gone through all the stty settings and used -ixon to disable XON/XOFF but that didn't make a difference.

Is there a way/place/file that holds the settings for the driver? Or am I forgetting something? RX doesn't seem to work either but not sure if the max isn't receiving it or just not informing the driver.

The relevant portion of the DTS

&ecspi3 {
    max14830: max14830@3 {
        compatible = "maxim,max14830";
        spi-max-frequency = <15000000>;
        reg = <0>; // SPI chip select number
        clocks = <&clk16m0>;
        clock-names = "osc";
        interrupt-parent = <&gpio5>;
        interrupts = <7 IRQ_TYPE_EDGE_FALLING>;
        gpio-controller; // Marks the device node as a GPIO controller
        #gpio-cells = <2>;
        clk16m0: clk16m0 {
            compatible = "fixed-clock";
            #clock-cells = <0>;
            clock-frequency = <3686400>; // freq of external xtal
            clock-accuracy = <100>;
        };
   };
};

And the comms during startup

OUT          IN            MEANING
0x9F 0xCE               -> Write globalCmd = Enable Extend register map acces
0x05 0x00 -> 0x0F 0xB4  -> Clear SpclChrIntEn= RevID is B4
0x9F 0xCD               -> Write globalCmd = Disable Extend register map access

0x8A 0x01               -> Write UART0 Mode2 = Set RST
0x8A 0x00               -> Write UART0 Mode2 = Clear RST
0x1C 0x00 -> 0x0F 0x01  -> Read UART0 DivLSB = Div0 set
0x89 0x80               -> Set UART0 MODE1 =  ~RTS0 is three state

0xAA 0x01               -> Write UART1 Mode2 = Set RST
0xAA 0x00               -> Write UART1 Mode2 = Clear RST
0x3C 0x00 -> 0x0F 0x01  -> Read UART1 DivLSB = Div0 set
0xA9 0x80               -> Set UART1 MODE1 =  ~RTS1 is three state

0xCA 0x01               -> Write UART2 Mode2 = Set RST
0xCA 0x00               -> Write UART2 Mode2 = Clear RST
0x5C 0x00 -> 0xF 0x01   -> Read UART2 DivLSB = Div0 set
0xC9 0x80               -> Set UART2 MODE1 =  ~RTS2 is three state

0xEA 0x01               -> Write UART3 Mode2 = Set RST
0xEA 0x00               -> Write UART3 Mode2 = Clear RST
0x7C 0x00 -> 0x0F 0x01  -> Read UART3 DivLSB = Div0 set
0xE9 0x80               -> Set UART3 MODE1 = ~RTS3 is three state

0x9A 0x44               -> Write PLLConfig = Set PreDiv5 and PreDiv2
0x9E 0x14               -> Write ClockSource = 0001 0100 -> first 1 at dont care, second PLLen

0x81 0x00              -> Clear IRQen UART0 
0x02 0x00 -> 0x0F 0x60 -> Read ISR UART0 = both fifo empty
0x1B 0x00 -> 0x0F 0x00 -> Read BRConfig UART0 -> all clear
0x9B 0x40              -> Write BRConfig UART0 -> FRACT2 Set

0xA1 0x00              -> Clear IRQen UART1 
0x22 0x00 -> 0x0F 0x60 -> Read ISR UART1 = both fifo empty
0x3B 0x00 -> 0x0F 0x00 -> Read BRConfig UART1 -> all clear
0xBB 0x40              -> Write BRConfig UART1 -> FRACT2 Set

0xC1 0x00              -> Clear IRQen UART2 
0x42 0x00 -> 0x0F 0x60 -> Read ISR UART2 = both fifo empty
0x58 0x00 -> 0x0F 0x00 -> Read BRConfig UART2 -> all clear
0xDB 0x40              -> Write BRConfig UART2 -> FRACT2 Set

0xE1 0x00              -> Clear IRQen UART3 
0x62 0x00 -> 0x0F 0x60 -> Read ISR UART3 = both fifo empty
0x7B 0x00 -> 0x0F 0x00 -> Read BRConfig UART3 -> all clear
0xFB 0x40              -> Write BRConfig UART3 -> FRACT2 Set

ttyMAX0 setup according to stty Result of stty -F /dev/ttyMAX0

-parenb -> don't generate parity
-parodd -> Even parity?
-cmspar -> No stick parity
cs8     -> character size 8 bits
hupcl   -> don't send hangup signal
-cstopb -> use one bit per character
cread   -> allow input to be received
clocal  -> disable modem control signals
-crtscts -> dont enable rts/cts handschaking
-ignbr  -> don't ignore break characters
-brkint -> breaks don't cause an interrupt signal
-ignpar -> don't ignore characters with parity errors
-parmrk -> don't mark parity errors
-inpck  -> don't enable parity checking
-istrip -> don't clear high (8th) bit of input characters
-inlcr  -> dont translate newline to carriage return
-igncr  -> don't ignore carriage return
icrnl   -> don't translate carriage return to newline
-ixon   -> disable XON/XOFF flow control
-ixoff  -> disable sending of start/stop characters
-iuclc  -> don't translate uppercase to lowercase
-ixany  -> Don't let any character restart output
-imaxbel -> don't beep and flush
-iutf8   -> don't assume characters are utf8 encoded
OUTPUT SETTINGS
opost   -> post process output
-olcuc  -> don't translate lower to upper
-ocrnl  -> don't translate carriage return to newline
onlcr   -> translate newline to carriage return newline
-onocr  -> print carriage return in the first column
-onlret -> newline doesn't perform a carriage return
-ofill -> don't use fill characters instead of timing for delays
-ofdel -> don't use delete character for fill instead of null
nl0
cr0
tab0 -> horizontal tab delay style 0
bs0
vt0
ff0    -> form feed delay style
isig   -> enable interrpt,
icanon -> enable special characters: erase, kill, werase, rprnt
iexten -> enable non-POSIX special characters
echo   -> echo input characters
echoe  -> echo erase characters as backspace-space-backspace 
echok  -> echo a newline after a kill character
-echonl
-noflsh -> don't disable flushing after interrupt & quit special
              chars
-xcase
-tostop
-echoprt
echoctl   -> echo control characters in hat notation ('^c')
echoke    -> kill all line by obeying the echoprt and echoe settings
-flusho
-extproc
1

There are 1 answers

1
Craio On BEST ANSWER
  • TX wasn't working because clock-names should have been xtal
  • RX wasn't working because i never opened the port but checked /proc/tty/driver/max310x for received data and the driver disables rx if a port isn't open.

Working node.

&ecspi3 {

    /delete-node/spidev@0;

    max14830: max14830@3 {
        compatible = "maxim,max14830";
        spi-max-frequency = <15000000>;
        reg = <0>; // SPI chip select number
        clocks = <&clk16m0>;
        clock-names = "xtal"; /* because using external xtal */
        interrupt-parent = <&gpio5>;
        interrupts = <11 IRQ_TYPE_EDGE_FALLING>;
        gpio-controller;  /* Marks the device node as a GPIO controller */
        #gpio-cells = <2>;
        clk16m0: clk16m0 {
            compatible = "fixed-clock";
            #clock-cells = <0>;
            clock-frequency = <3686400>; /* external xtal frequency */
            clock-accuracy = <100>;
        };
     };
};
```