Recipe to give vocore 2nd serial port

docbee
 
Posts: 34
Joined: Wed Nov 02, 2016 9:15 am

Recipe to give vocore 2nd serial port

Sat Nov 05, 2016 10:55 pm

The RT5350 chip of vocore provides two UART ports. One with full control line support (RTS/CTS/DTR/DSR/DTS) called uartf (uartfull) and another one just with RX/TX lines called uart (uartlite). vocore is configured to make use only of the uartlite port and to use it as a serial console mapped to "/dev/ttyS0".

As I needed another serial port, I worked on bringing the 2nd uart port to live as /dev/ttyS1. When you replace the files "VOCORE.dts" and "rt5350.dtsi" with versions shown below, you are done. These files add the uartfull port in a way that just lines GPIO 7-10 are used for the serial communication and keep GPIO 11 - 14 as GPIO lines.

VOCORE.dtsi
Code: Select all
/dts-v1/;

/include/ "rt5350.dtsi"

/ {
   compatible = "VoCore", "ralink,rt5350-soc";
   model = "VoCore";

   palmbus@10000000 {
      sysc@0 {
         ralink,uartmux = "gpio uartf";
      };

      gpio1: gpio@660 {
         status = "okay";
      };

      i2c@900 {
         status = "okay";
      };

      spi@b00 {
         status = "okay";

         m25p80@0 {
            #address-cells = <1>;
            #size-cells = <1>;
            compatible = "s25fl064k";
            reg = <0>;
            linux,modalias = "m25p80", "s25fl064k";
            spi-max-frequency = <10000000>;

            partition@0 {
               label = "uboot";
               reg = <0x0 0x30000>;
               read-only;
            };

            partition@30000 {
               label = "uboot-env";
               reg = <0x30000 0x10000>;
               read-only;
            };

            factory: partition@40000 {
               label = "factory";
               reg = <0x40000 0x10000>;
               read-only;
            };

            partition@50000 {      // 16 MB FLASH MODEL
               label = "firmware";
               reg = <0x50000 0xfb0000>;
            };
         };

         spidev@1 {
            compatible = "linux,spidev";
            spi-max-frequency = <10000000>;
            reg = <1>;
         };
      };
   };

   pinctrl {
      state_default: pinctrl0 {
         gpio {
            ralink,group = "jtag", "led";   // "uartf" removed to have 2nd UART working
            ralink,function = "gpio";
         };
      };
   };

   ethernet@10100000 {
      mtd-mac-address = <&factory 0x4>;
   };

   esw@10110000 {
      ralink,portmap = <0x17>;
   };

   wmac@10180000 {
      ralink,mtd-eeprom = <&factory 0>;
   };

   ehci@101c0000 {
      status = "okay";
   };

   ohci@101c1000 {
      status = "okay";
   };

   gpio-export {
      compatible = "gpio-export";
      #size-cells = <0>;

      gpio0 {
         gpio-export,name = "gpio0";
         gpio-export,direction_may_change = <1>;
         gpios = <&gpio0 0 0>;
      };

      /* SHARED UARTF */
      gpio11 {
         // UARTF_CTS_N
         gpio-export,name = "gpio9";
         gpio-export,direction_may_change = <1>;
         gpios = <&gpio0 9 0>;
      };
      gpio12 {
         // UARTF_DCD_N
         gpio-export,name = "gpio12";
         gpio-export,direction_may_change = <1>;
         gpios = <&gpio0 12 0>;
      };
      gpio13 {
         // UARTF_DSR_N
         gpio-export,name = "gpio13";
         gpio-export,direction_may_change = <1>;
         gpios = <&gpio0 13 0>;
      };
      gpio14 {
         // UARTF_RIN
         gpio-export,name = "gpio14";
         gpio-export,direction_may_change = <1>;
         gpios = <&gpio0 14 0>;
      };

      /* JTAG */
      gpio17 {
         /* JTAG_TDO */
         gpio-export,name = "gpio17";
         gpio-export,direction_may_change = <1>;
         gpios = <&gpio0 17 0>;
      };
      gpio18 {
         /* JTAG_TDI */
         gpio-export,name = "gpio18";
         gpio-export,direction_may_change = <1>;
         gpios = <&gpio0 18 0>;
      };
      gpio19 {
         /* JTAG_TMS */
         gpio-export,name = "gpio19";
         gpio-export,direction_may_change = <1>;
         gpios = <&gpio0 19 0>;
      };
      gpio20 {
         /* JTAG_TCLK */
         gpio-export,name = "gpio20";
         gpio-export,direction_may_change = <1>;
         gpios = <&gpio0 20 0>;
      };
      gpio21 {
         /* JTAG_TRST_N */
         gpio-export,name = "gpio21";
         gpio-export,direction_may_change = <1>;
         gpios = <&gpio0 21 0>;
      };

      /* ETH LEDs */
      gpio22 {
         /* ETH0_LED */
         gpio-export,name = "gpio22";
         gpio-export,direction_may_change = <1>;
         gpios = <&gpio1 0 0>;
      };
/*
      gpio23 {
         // ETH1_LED
         gpio-export,name = "gpio23";
         gpio-export,direction_may_change = <1>;
         gpios = <&gpio1 1 0>;
      };
      gpio24 {
         // ETH2_LED
         gpio-export,name = "gpio24";
         gpio-export,direction_may_change = <1>;
         gpios = <&gpio1 2 0>;
      };
      gpio25 {
         // ETH3_LED
         gpio-export,name = "gpio25";
         gpio-export,direction_may_change = <1>;
         gpios = <&gpio1 3 0>;
      };
*/
      gpio26 {
         /* ETH4_LED */
         gpio-export,name = "gpio26";
         gpio-export,direction_may_change = <1>;
         gpios = <&gpio1 4 0>;
      };
   };

   gpio-leds {
      compatible = "gpio-leds";
      status {
         /* UARTF_RXD */
         label = "vocore:green:status";
         gpios = <&gpio0 10 0>;
      };
      eth {
         /* UARTF_DTR_N */
         label = "vocore:orange:eth";
         gpios = <&gpio0 11 0>;
      };
      signal {
         // GPIO 23
         label = "vocore:red:signal";
         gpios = <&gpio0 1 0>;
      };
   };

   gpio-keys-polled {
      compatible = "gpio-keys-polled";
      #address-cells = <1>;
      #size-cells = <0>;
      poll-interval = <20>;
/*
      reset {
         label = "reset";
         gpios = <&gpio1 3 0>;   // reset button, gpio 25
         linux,code = <0x198>;
      };
*/
      BTN_0 {
         label = "mode";
         gpios = <&gpio1 3 0>;   // mode button, gpio 25
         linux,code = <0x100>;   // BTN_0
      };
      BTN_1 {
         label = "showip";
         gpios = <&gpio1 2 0>;   // showip button, gpio 24
         linux,code = <0x100>;   // BTN_0
      };
   };
};


rt5350.dts
Code: Select all
/ {
   #address-cells = <1>;
   #size-cells = <1>;
   compatible = "ralink,rt5350-soc";

   cpus {
      cpu@0 {
         compatible = "mips,mips24KEc";
      };
   };

   chosen {
      bootargs = "console=ttyS0,57600";
   };

   cpuintc: cpuintc@0 {
      #address-cells = <0>;
      #interrupt-cells = <1>;
      interrupt-controller;
      compatible = "mti,cpu-interrupt-controller";
   };

   palmbus@10000000 {
      compatible = "palmbus";
      reg = <0x10000000 0x200000>;
      ranges = <0x0 0x10000000 0x1FFFFF>;

      #address-cells = <1>;
      #size-cells = <1>;

      sysc@0 {
         compatible = "ralink,rt5350-sysc", "ralink,rt3050-sysc";
         reg = <0x0 0x100>;
      };

      timer@100 {
         compatible = "ralink,rt5350-timer", "ralink,rt2880-timer";
         reg = <0x100 0x20>;

         interrupt-parent = <&intc>;
         interrupts = <1>;
      };

      watchdog@120 {
         compatible = "ralink,rt5350-wdt", "ralink,rt2880-wdt";
         reg = <0x120 0x10>;

         resets = <&rstctrl 8>;
         reset-names = "wdt";

         interrupt-parent = <&intc>;
         interrupts = <1>;
      };

      intc: intc@200 {
         compatible = "ralink,rt5350-intc", "ralink,rt2880-intc";
         reg = <0x200 0x100>;

         resets = <&rstctrl 19>;
         reset-names = "intc";

         interrupt-controller;
         #interrupt-cells = <1>;

         interrupt-parent = <&cpuintc>;
         interrupts = <2>;
      };

      memc@300 {
         compatible = "ralink,rt5350-memc", "ralink,rt3050-memc";
         reg = <0x300 0x100>;

         resets = <&rstctrl 20>;
         reset-names = "mc";

         interrupt-parent = <&intc>;
         interrupts = <3>;
      };

      uartlite@c00 {
         compatible = "ralink,rt5350-uart", "ralink,rt2880-uart", "ns16550a";
         reg = <0xc00 0x100>;

         resets = <&rstctrl 19>;
         reset-names = "uartl";

         interrupt-parent = <&intc>;
         interrupts = <12>;

         pinctrl-names = "default";
         pinctrl-0 = <&uartlite_pins>;

         reg-shift = <2>;
      };

      uart@500 {
         compatible = "ralink,rt5350-uart", "ralink,rt2880-uart", "ns16550a";
         reg = <0x500 0x100>;

         resets = <&rstctrl 12>;
         reset-names = "uart";

         interrupt-parent = <&intc>;
         interrupts = <5>;

         reg-shift = <2>;

         pinctrl-names = "default";
         pinctrl-0 = <&uartf_pins>;

//         status = "disabled";
      };

      gpio0: gpio@600 {
         compatible = "ralink,rt5350-gpio", "ralink,rt2880-gpio";
         reg = <0x600 0x34>;

         resets = <&rstctrl 13>;
         reset-names = "pio";

         interrupt-parent = <&intc>;
         interrupts = <6>;

         gpio-controller;
         #gpio-cells = <2>;

         ralink,gpio-base = <0>;
         ralink,num-gpios = <22>;
         ralink,register-map = [ 00 04 08 0c
                  20 24 28 2c
                  30 34 ];
      };

      gpio1: gpio@660 {
         compatible = "ralink,rt5350-gpio", "ralink,rt2880-gpio";
         reg = <0x660 0x24>;

         interrupt-parent = <&intc>;
         interrupts = <6>;

         gpio-controller;
         #gpio-cells = <2>;

         ralink,gpio-base = <22>;
         ralink,num-gpios = <6>;
         ralink,register-map = [ 00 04 08 0c
                  10 14 18 1c
                  20 24 ];

         status = "disabled";
      };

      i2c@900 {
         compatible = "link,rt5350-i2c", "ralink,rt2880-i2c";
         reg = <0x900 0x100>;

         resets = <&rstctrl 16>;
         reset-names = "i2c";

         #address-cells = <1>;
         #size-cells = <0>;

         pinctrl-names = "default";
         pinctrl-0 = <&i2c_pins>;

         status = "disabled";
      };

      spi@b00 {
         compatible = "ralink,rt5350-spi";
         reg = <0xb00 0x100>;

         resets = <&rstctrl 18>;
         reset-names = "spi";

         #address-cells = <1>;
         #size-cells = <1>;

         pinctrl-names = "default";
         pinctrl-0 = <&spi_pins &spi_cs1>;

         status = "disabled";
      };

      systick@d00 {
         compatible = "ralink,rt5350-systick", "ralink,cevt-systick";
         reg = <0xd00 0x10>;

         interrupt-parent = <&cpuintc>;
         interrupts = <7>;
      };
   };

   pinctrl {
      compatible = "ralink,rt2880-pinmux";

      pinctrl-names = "default";
      pinctrl-0 = <&state_default>;

      state_default: pinctrl0 {
      };

      spi_pins: spi {
         spi {
            ralink,group = "spi";
            ralink,function = "spi";
         };
      };
      i2c_pins: i2c {
         i2c {
            ralink,group = "i2c";
            ralink,function = "i2c";
         };
      };
      phy_led_pins: phy_led {
         phy_led {
            ralink,group = "led";
            ralink,function = "led";
         };
      };
      uartlite_pins: uartlite {
         uart {
            ralink,group = "uartlite";
            ralink,function = "uartlite";
         };
      };
      uartf_pins: uartf {
         uartf {
            ralink,group = "uartf";
            ralink,function = "uartf";
         };
      };
      spi_cs1: spi1 {
         spi1 {
            ralink,group = "spi_cs1";
            ralink,function = "spi_cs1";
         };
      };
   };

   rstctrl: rstctrl {
      compatible = "ralink,rt5350-reset", "ralink,rt2880-reset";
      #reset-cells = <1>;
   };

   usbphy {
      compatible = "ralink,rt3xxx-usbphy";

      resets = <&rstctrl 22 &rstctrl 25>;
      reset-names = "host", "device";
   };

   ethernet@10100000 {
      compatible = "ralink,rt5350-eth";
      reg = <0x10100000 10000>;

      interrupt-parent = <&cpuintc>;
      interrupts = <5>;
   };

   esw@10110000 {
      compatible = "ralink,rt3050-esw";
      reg = <0x10110000 8000>;

      interrupt-parent = <&intc>;
      interrupts = <17>;
   };

   wmac@10180000 {
      compatible = "ralink,rt5350-wmac", "ralink,rt2880-wmac";
      reg = <0x10180000 40000>;

      interrupt-parent = <&cpuintc>;
      interrupts = <6>;

      ralink,eeprom = "soc_wmac.eeprom";
   };

   ehci@101c0000 {
      compatible = "ralink,rt3xxx-ehci", "ehci-platform";
      reg = <0x101c0000 0x1000>;

      interrupt-parent = <&intc>;
      interrupts = <18>;
   };

   ohci@101c1000 {
      compatible = "ralink,rt3xxx-ohci", "ohci-platform";
      reg = <0x101c1000 0x1000>;

      interrupt-parent = <&intc>;
      interrupts = <18>;
   };
};

docbee
 
Posts: 34
Joined: Wed Nov 02, 2016 9:15 am

Re: Recipe to give vocore 2nd serial port

Sat Nov 05, 2016 10:59 pm

To spare you looking into the manual, the pins to use for /dev/ttyS1 are:
TX -> GPIO 08
RX -> GPIO 10
and
CTS -> GPIO 09
RTS -> GPIO 07
in case you need hardware handshake

chrisck87
 
Posts: 3
Joined: Fri Mar 17, 2017 10:33 pm

Re: Recipe to give vocore 2nd serial port

Fri Mar 17, 2017 10:43 pm

Hi!
I'm a new Vocore and linux user, where do I need to replace those files? are there in my PC or in some direction inside the vocore?. In my PC I have two paths with the dts and dtsi files you mentioned, the first in in ...openwrt/target/linux/ramips/dts and the other is in ...openwrt/buil_dir/target_mipsel.../openwrt-sdk.../target/linux/ramips/dts
Thanks for helping

Return to VoCore & VoCore+Dock

Who is online

Users browsing this forum: No registered users and 5 guests