Commit 96e7b5a174365c87adabbafed56f2258de04b207

Authored by Neil Armstrong
Committed by Tom Rini
1 parent f49638e9f9

arm: Add LibreTech CC support based on Meson GXL family

This adds platform code for the Libre Computer CC "Le Potato" board based on a
Meson GXL (S905X) SoC with the Meson GXL configuration.

This initial submission supports UART, MMC/SDCard and Ethernet with the
Internal RMII PHY.

The meson-gxl-s905x-libretech-cc.dts is synchronised from the linux 4.13
stable tree as of 4.13.8.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>

Showing 10 changed files with 413 additions and 1 deletions Side-by-side Diff

arch/arm/dts/Makefile
... ... @@ -56,7 +56,8 @@
56 56 rv1108-evb.dtb
57 57 dtb-$(CONFIG_ARCH_MESON) += \
58 58 meson-gxbb-odroidc2.dtb \
59   - meson-gxl-s905x-p212.dtb
  59 + meson-gxl-s905x-p212.dtb \
  60 + meson-gxl-s905x-libretech-cc.dtb
60 61 dtb-$(CONFIG_TEGRA) += tegra20-harmony.dtb \
61 62 tegra20-medcom-wide.dtb \
62 63 tegra20-paz00.dtb \
arch/arm/dts/meson-gxl-s905x-libretech-cc.dts
  1 +/*
  2 + * Copyright (c) 2017 BayLibre, SAS.
  3 + * Author: Neil Armstrong <narmstrong@baylibre.com>
  4 + * Author: Jerome Brunet <jbrunet@baylibre.com>
  5 + *
  6 + * SPDX-License-Identifier: (GPL-2.0+ OR MIT)
  7 + */
  8 +
  9 +/dts-v1/;
  10 +
  11 +#include <dt-bindings/input/input.h>
  12 +
  13 +#include "meson-gxl-s905x.dtsi"
  14 +
  15 +/ {
  16 + compatible = "libretech,cc", "amlogic,s905x", "amlogic,meson-gxl";
  17 + model = "Libre Technology CC";
  18 +
  19 + aliases {
  20 + serial0 = &uart_AO;
  21 + };
  22 +
  23 + chosen {
  24 + stdout-path = "serial0:115200n8";
  25 + };
  26 +
  27 + cvbs-connector {
  28 + compatible = "composite-video-connector";
  29 +
  30 + port {
  31 + cvbs_connector_in: endpoint {
  32 + remote-endpoint = <&cvbs_vdac_out>;
  33 + };
  34 + };
  35 + };
  36 +
  37 + emmc_pwrseq: emmc-pwrseq {
  38 + compatible = "mmc-pwrseq-emmc";
  39 + reset-gpios = <&gpio BOOT_9 GPIO_ACTIVE_LOW>;
  40 + };
  41 +
  42 + hdmi-connector {
  43 + compatible = "hdmi-connector";
  44 + type = "a";
  45 +
  46 + port {
  47 + hdmi_connector_in: endpoint {
  48 + remote-endpoint = <&hdmi_tx_tmds_out>;
  49 + };
  50 + };
  51 + };
  52 +
  53 + leds {
  54 + compatible = "gpio-leds";
  55 +
  56 + system {
  57 + label = "librecomputer:system-status";
  58 + gpios = <&gpio GPIODV_24 GPIO_ACTIVE_HIGH>;
  59 + default-state = "on";
  60 + panic-indicator;
  61 + };
  62 +
  63 + blue {
  64 + label = "librecomputer:blue";
  65 + gpios = <&gpio_ao GPIOAO_2 GPIO_ACTIVE_HIGH>;
  66 + linux,default-trigger = "heartbeat";
  67 + };
  68 + };
  69 +
  70 + memory@0 {
  71 + device_type = "memory";
  72 + reg = <0x0 0x0 0x0 0x80000000>;
  73 + };
  74 +
  75 + vcc_3v3: regulator-vcc_3v3 {
  76 + compatible = "regulator-fixed";
  77 + regulator-name = "VCC_3V3";
  78 + regulator-min-microvolt = <3300000>;
  79 + regulator-max-microvolt = <3300000>;
  80 + };
  81 +
  82 + vcc_card: regulator-vcc-card {
  83 + compatible = "regulator-gpio";
  84 +
  85 + regulator-name = "VCC_CARD";
  86 + regulator-min-microvolt = <1800000>;
  87 + regulator-max-microvolt = <3300000>;
  88 +
  89 + gpios = <&gpio_ao GPIOAO_3 GPIO_ACTIVE_HIGH>;
  90 + gpios-states = <0>;
  91 +
  92 + states = <3300000 0>,
  93 + <1800000 1>;
  94 + };
  95 +
  96 + vddio_boot: regulator-vddio_boot {
  97 + compatible = "regulator-fixed";
  98 + regulator-name = "VDDIO_BOOT";
  99 + regulator-min-microvolt = <3300000>;
  100 + regulator-max-microvolt = <3300000>;
  101 + };
  102 +};
  103 +
  104 +&cvbs_vdac_port {
  105 + cvbs_vdac_out: endpoint {
  106 + remote-endpoint = <&cvbs_connector_in>;
  107 + };
  108 +};
  109 +
  110 +&ethmac {
  111 + status = "okay";
  112 +};
  113 +
  114 +&ir {
  115 + status = "okay";
  116 + pinctrl-0 = <&remote_input_ao_pins>;
  117 + pinctrl-names = "default";
  118 +};
  119 +
  120 +&hdmi_tx {
  121 + status = "okay";
  122 + pinctrl-0 = <&hdmi_hpd_pins>, <&hdmi_i2c_pins>;
  123 + pinctrl-names = "default";
  124 +};
  125 +
  126 +&hdmi_tx_tmds_port {
  127 + hdmi_tx_tmds_out: endpoint {
  128 + remote-endpoint = <&hdmi_connector_in>;
  129 + };
  130 +};
  131 +
  132 +/* SD card */
  133 +&sd_emmc_b {
  134 + status = "okay";
  135 + pinctrl-0 = <&sdcard_pins>;
  136 + pinctrl-names = "default";
  137 +
  138 + bus-width = <4>;
  139 + cap-sd-highspeed;
  140 + max-frequency = <100000000>;
  141 + disable-wp;
  142 +
  143 + cd-gpios = <&gpio CARD_6 GPIO_ACTIVE_HIGH>;
  144 + cd-inverted;
  145 +
  146 + vmmc-supply = <&vcc_3v3>;
  147 + vqmmc-supply = <&vcc_card>;
  148 +};
  149 +
  150 +/* eMMC */
  151 +&sd_emmc_c {
  152 + status = "okay";
  153 + pinctrl-0 = <&emmc_pins>;
  154 + pinctrl-names = "default";
  155 +
  156 + bus-width = <8>;
  157 + cap-mmc-highspeed;
  158 + max-frequency = <50000000>;
  159 + non-removable;
  160 + disable-wp;
  161 +
  162 + mmc-pwrseq = <&emmc_pwrseq>;
  163 + vmmc-supply = <&vcc_3v3>;
  164 + vqmmc-supply = <&vddio_boot>;
  165 +};
  166 +
  167 +&uart_AO {
  168 + status = "okay";
  169 + pinctrl-0 = <&uart_ao_a_pins>;
  170 + pinctrl-names = "default";
  171 +};
arch/arm/mach-meson/Kconfig
... ... @@ -38,6 +38,13 @@
38 38 with 2 GiB of RAM, Ethernet, HDMI, 2 USB, micro-SD slot,
39 39 eMMC, IR receiver, CVBS+Audio jack and a SDIO WiFi module.
40 40  
  41 +config TARGET_LIBRETECH_CC
  42 + bool "LIBRETECH-CC"
  43 + help
  44 + LibreTech CC is a single board computer based on Meson GXL
  45 + with 2 GiB of RAM, Ethernet, HDMI, 4 USB, micro-SD slot,
  46 + eMMC, IR receiver and a 40-pin GPIO header.
  47 +
41 48 endif
42 49  
43 50 config SYS_SOC
... ... @@ -49,6 +56,8 @@
49 56 source "board/amlogic/odroid-c2/Kconfig"
50 57  
51 58 source "board/amlogic/p212/Kconfig"
  59 +
  60 +source "board/amlogic/libretech-cc/Kconfig"
52 61  
53 62 endif
board/amlogic/libretech-cc/Kconfig
  1 +if TARGET_LIBRETECH_CC
  2 +
  3 +config SYS_BOARD
  4 + default "libretech-cc"
  5 +
  6 +config SYS_VENDOR
  7 + default "amlogic"
  8 +
  9 +config SYS_CONFIG_NAME
  10 + default "libretech-cc"
  11 +
  12 +endif
board/amlogic/libretech-cc/MAINTAINERS
  1 +LIBRETECH-CC
  2 +M: Neil Armstrong <narmstrong@baylibre.com>
  3 +S: Maintained
  4 +F: board/amlogic/libretech-cc/
  5 +F: include/configs/libretech-cc.h
  6 +F: configs/libretech-cc_defconfig
board/amlogic/libretech-cc/Makefile
  1 +#
  2 +# (C) Copyright 2016 BayLibre, SAS
  3 +# Author: Neil Armstrong <narmstrong@baylibre.com>
  4 +#
  5 +# SPDX-License-Identifier: GPL-2.0+
  6 +#
  7 +
  8 +obj-y := libretech-cc.o
board/amlogic/libretech-cc/README
  1 +U-Boot for LibreTech CC
  2 +=======================
  3 +
  4 +LibreTech CC is a single board computer manufactured by Libre Technology
  5 +with the following specifications:
  6 +
  7 + - Amlogic S905X ARM Cortex-A53 quad-core SoC @ 2GHz
  8 + - ARM Mali 450 GPU
  9 + - 2GB DDR3 SDRAM
  10 + - Gigabit Ethernet
  11 + - HDMI 2.0 4K/60Hz display
  12 + - 40-pin GPIO header
  13 + - 4 x USB 2.0 Host, 1 x USB OTG
  14 + - eMMC, microSD
  15 + - Infrared receiver
  16 +
  17 +Schematics are available on the manufacturer website.
  18 +
  19 +Currently the U-Boot port supports the following devices:
  20 + - serial
  21 + - eMMC, microSD
  22 + - Ethernet
  23 +
  24 +U-Boot compilation
  25 +==================
  26 +
  27 + > export ARCH=arm
  28 + > export CROSS_COMPILE=aarch64-none-elf-
  29 + > make libretech-cc_defconfig
  30 + > make
  31 +
  32 +Image creation
  33 +==============
  34 +
  35 +Amlogic doesn't provide sources for the firmware and for tools needed
  36 +to create the bootloader image, so it is necessary to obtain them from
  37 +the git tree published by the board vendor:
  38 +
  39 + > wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
  40 + > wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
  41 + > tar xvfJ gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
  42 + > tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
  43 + > export PATH=$PWD/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux/bin:$PWD/gcc-linaro-arm-none-eabi-4.8-2013.11_linux/bin:$PATH
  44 + > git clone https://github.com/BayLibre/u-boot.git -b libretech-cc amlogic-u-boot
  45 + > cd amlogic-u-boot
  46 + > make libretech_cc_defconfig
  47 + > make
  48 + > export FIPDIR=$PWD/fip
  49 +
  50 +Go back to mainline U-Boot source tree then :
  51 + > mkdir fip
  52 +
  53 + > cp $FIPDIR/gxl/bl2.bin fip/
  54 + > cp $FIPDIR/gxl/acs.bin fip/
  55 + > cp $FIPDIR/gxl/bl21.bin fip/
  56 + > cp $FIPDIR/gxl/bl30.bin fip/
  57 + > cp $FIPDIR/gxl/bl301.bin fip/
  58 + > cp $FIPDIR/gxl/bl31.img fip/
  59 + > cp u-boot.bin fip/bl33.bin
  60 +
  61 + > $FIPDIR/blx_fix.sh \
  62 + fip/bl30.bin \
  63 + fip/zero_tmp \
  64 + fip/bl30_zero.bin \
  65 + fip/bl301.bin \
  66 + fip/bl301_zero.bin \
  67 + fip/bl30_new.bin \
  68 + bl30
  69 +
  70 + > $FIPDIR/acs_tool.pyc fip/bl2.bin fip/bl2_acs.bin fip/acs.bin 0
  71 +
  72 + > $FIPDIR/blx_fix.sh \
  73 + fip/bl2_acs.bin \
  74 + fip/zero_tmp \
  75 + fip/bl2_zero.bin \
  76 + fip/bl21.bin \
  77 + fip/bl21_zero.bin \
  78 + fip/bl2_new.bin \
  79 + bl2
  80 +
  81 + > $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl30_new.bin
  82 + > $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl31.img
  83 + > $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl33.bin
  84 + > $FIPDIR/gxl/aml_encrypt_gxl --bl2sig --input fip/bl2_new.bin --output fip/bl2.n.bin.sig
  85 + > $FIPDIR/gxl/aml_encrypt_gxl --bootmk \
  86 + --output fip/u-boot.bin \
  87 + --bl2 fip/bl2.n.bin.sig \
  88 + --bl30 fip/bl30_new.bin.enc \
  89 + --bl31 fip/bl31.img.enc \
  90 + --bl33 fip/bl33.bin.enc
  91 +
  92 +and then write the image to SD with:
  93 +
  94 + > DEV=/dev/your_sd_device
  95 + > dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1
  96 + > dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=444
board/amlogic/libretech-cc/libretech-cc.c
  1 +/*
  2 + * Copyright (C) 2016 BayLibre, SAS
  3 + * Author: Neil Armstrong <narmstrong@baylibre.com>
  4 + *
  5 + * SPDX-License-Identifier: GPL-2.0+
  6 + */
  7 +
  8 +#include <common.h>
  9 +#include <dm.h>
  10 +#include <asm/io.h>
  11 +#include <asm/arch/gxbb.h>
  12 +#include <asm/arch/sm.h>
  13 +#include <asm/arch/eth.h>
  14 +
  15 +#define EFUSE_SN_OFFSET 20
  16 +#define EFUSE_SN_SIZE 16
  17 +#define EFUSE_MAC_OFFSET 52
  18 +#define EFUSE_MAC_SIZE 6
  19 +
  20 +int board_init(void)
  21 +{
  22 + return 0;
  23 +}
  24 +
  25 +int misc_init_r(void)
  26 +{
  27 + u8 mac_addr[EFUSE_MAC_SIZE];
  28 + char serial[EFUSE_SN_SIZE];
  29 + ssize_t len;
  30 +
  31 + meson_gx_eth_init(PHY_INTERFACE_MODE_RMII,
  32 + MESON_GXL_USE_INTERNAL_RMII_PHY);
  33 +
  34 + /* Enable power and clock gate */
  35 + setbits_le32(GXBB_GCLK_MPEG_1, GXBB_GCLK_MPEG_1_ETH);
  36 + clrbits_le32(GXBB_MEM_PD_REG_0, GXBB_MEM_PD_REG_0_ETH_MASK);
  37 +
  38 + if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
  39 + len = meson_sm_read_efuse(EFUSE_MAC_OFFSET,
  40 + mac_addr, EFUSE_MAC_SIZE);
  41 + if (len == EFUSE_MAC_SIZE && is_valid_ethaddr(mac_addr))
  42 + eth_env_set_enetaddr("ethaddr", mac_addr);
  43 + }
  44 +
  45 + if (!env_get("serial#")) {
  46 + len = meson_sm_read_efuse(EFUSE_SN_OFFSET, serial,
  47 + EFUSE_SN_SIZE);
  48 + if (len == EFUSE_SN_SIZE)
  49 + env_set("serial#", serial);
  50 + }
  51 +
  52 + return 0;
  53 +}
configs/libretech-cc_defconfig
  1 +CONFIG_ARM=y
  2 +CONFIG_ARCH_MESON=y
  3 +CONFIG_MESON_GXL=y
  4 +CONFIG_TARGET_LIBRETECH_CC=y
  5 +CONFIG_IDENT_STRING=" libretech-cc"
  6 +CONFIG_DEFAULT_DEVICE_TREE="meson-gxl-s905x-libretech-cc"
  7 +CONFIG_DEBUG_UART=y
  8 +CONFIG_ENV_IS_NOWHERE=y
  9 +# CONFIG_DISPLAY_CPUINFO is not set
  10 +# CONFIG_DISPLAY_BOARDINFO is not set
  11 +# CONFIG_CMD_BDI is not set
  12 +# CONFIG_CMD_IMI is not set
  13 +# CONFIG_CMD_IMLS is not set
  14 +# CONFIG_CMD_LOADS is not set
  15 +CONFIG_CMD_MMC=y
  16 +# CONFIG_CMD_FPGA is not set
  17 +CONFIG_CMD_GPIO=y
  18 +# CONFIG_CMD_SETEXPR is not set
  19 +CONFIG_OF_CONTROL=y
  20 +CONFIG_DM_GPIO=y
  21 +CONFIG_DM_MMC=y
  22 +CONFIG_MMC_MESON_GX=y
  23 +CONFIG_DM_ETH=y
  24 +CONFIG_ETH_DESIGNWARE=y
  25 +CONFIG_PHY_MESON_GXL=y
  26 +CONFIG_NET_RANDOM_ETHADDR=y
  27 +CONFIG_PINCTRL=y
  28 +CONFIG_PINCTRL_MESON_GXL=y
  29 +CONFIG_DEBUG_UART_MESON=y
  30 +CONFIG_DEBUG_UART_BASE=0xc81004c0
  31 +CONFIG_DEBUG_UART_CLOCK=24000000
  32 +CONFIG_DEBUG_UART_ANNOUNCE=y
  33 +CONFIG_DEBUG_UART_SKIP_INIT=y
  34 +CONFIG_MESON_SERIAL=y
  35 +CONFIG_OF_LIBFDT_OVERLAY=y
include/configs/libretech-cc.h
  1 +/*
  2 + * Configuration for LibreTech CC
  3 + *
  4 + * Copyright (C) 2017 Baylibre, SAS
  5 + * Author: Neil Armstrong <narmstrong@baylibre.com>
  6 + *
  7 + * SPDX-License-Identifier: GPL-2.0+
  8 + */
  9 +
  10 +#ifndef __CONFIG_H
  11 +#define __CONFIG_H
  12 +
  13 +#define CONFIG_MISC_INIT_R
  14 +
  15 +#define CONFIG_PHY_ADDR 8
  16 +
  17 +#define MESON_FDTFILE_SETTING "fdtfile=amlogic/meson-gxl-s905x-libretech-cc.dtb\0"
  18 +
  19 +#include <configs/meson-gxbb-common.h>
  20 +
  21 +#endif /* __CONFIG_H */