From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Viacheslav Bocharov Date: Thu, 27 Jun 2024 16:20:54 +0300 Subject: Add JetHub D2 --- arch/arm/dts/Makefile | 3 +- arch/arm/dts/meson-sm1-jethome-jethub-j200-u-boot.dtsi | 13 + arch/arm/dts/meson-sm1-jethome-jethub-j200.dts | 711 ++++++++++ board/amlogic/jethub-j200/MAINTAINERS | 8 + board/amlogic/jethub-j200/Makefile | 6 + board/amlogic/jethub-j200/jethub-j200.c | 89 ++ configs/jethub_j200_defconfig | 120 ++ doc/board/amlogic/index.rst | 1 + doc/board/amlogic/jethub-j200.rst | 50 + drivers/power/regulator/regulator-uclass.c | 2 +- include/configs/jethub.h | 9 + 11 files changed, 1010 insertions(+), 2 deletions(-) diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index 111111111111..222222222222 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -78,7 +78,8 @@ dtb-$(CONFIG_ARCH_S5P4418) += \ s5p4418-nanopi2.dtb dtb-$(CONFIG_ARCH_MESON) += \ - meson-a1-ad401.dtb + meson-a1-ad401.dtb \ + meson-sm1-jethome-jethub-j200.dtb dtb-$(CONFIG_ARCH_TEGRA) += \ tegra20-acer-a500-picasso.dtb \ diff --git a/arch/arm/dts/meson-sm1-jethome-jethub-j200-u-boot.dtsi b/arch/arm/dts/meson-sm1-jethome-jethub-j200-u-boot.dtsi new file mode 100644 index 000000000000..111111111111 --- /dev/null +++ b/arch/arm/dts/meson-sm1-jethome-jethub-j200-u-boot.dtsi @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +/* + * Replace emmc_data_8b_pins to emmc_data_4b_pins from sd_emmc_c pinctrl-0, and change bus-width to 4 then spifc can be enabled. + */ +&sd_emmc_c { + pinctrl-0 = <&emmc_ctrl_pins>, <&emmc_data_4b_pins>, <&emmc_ds_pins>; + bus-width = <4>; +}; + +&spifc { + status = "okay"; +}; diff --git a/arch/arm/dts/meson-sm1-jethome-jethub-j200.dts b/arch/arm/dts/meson-sm1-jethome-jethub-j200.dts new file mode 100644 index 000000000000..111111111111 --- /dev/null +++ b/arch/arm/dts/meson-sm1-jethome-jethub-j200.dts @@ -0,0 +1,711 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2024 JetHome + * Author: Viacheslav Bocharov + */ + +/dts-v1/; + +#include "meson-sm1.dtsi" + +#include +#include +#include + + +/ { + + compatible = "jethome,jethub-j200", "amlogic,sm1"; + model = "JetHome JetHub D2"; + + aliases { + serial0 = &uart_AO; + ethernet0 = ðmac; + rtc0 = &rtc; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + memory@0 { + device_type = "memory"; + reg = <0x0 0x0 0x0 0x40000000>; + }; + + emmc_pwrseq: emmc-pwrseq { + compatible = "mmc-pwrseq-emmc"; + reset-gpios = <&gpio BOOT_12 GPIO_ACTIVE_LOW>; + }; + + tflash_vdd: regulator-tflash_vdd { + compatible = "regulator-fixed"; + + regulator-name = "TFLASH_VDD"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + + gpio = <&gpio_ao GPIOAO_3 GPIO_OPEN_DRAIN>; + enable-active-high; + regulator-always-on; + }; + + tf_io: gpio-regulator-tf_io { + compatible = "regulator-gpio"; + + regulator-name = "TF_IO"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + vin-supply = <&vcc_5v>; + + enable-gpios = <&gpio_ao GPIOE_2 GPIO_OPEN_DRAIN>; + enable-active-high; + regulator-always-on; + + gpios = <&gpio_ao GPIOAO_6 GPIO_OPEN_SOURCE>; + gpios-states = <0>; + + states = <3300000 0>, + <1800000 1>; + }; + + flash_1v8: regulator-flash_1v8 { + compatible = "regulator-fixed"; + regulator-name = "FLASH_1V8"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + vin-supply = <&vcc_3v3>; + regulator-always-on; + }; + + main_12v: regulator-main_12v { + compatible = "regulator-fixed"; + regulator-name = "12V"; + regulator-min-microvolt = <12000000>; + regulator-max-microvolt = <12000000>; + regulator-always-on; + }; + + vcc_5v: regulator-vcc_5v { + compatible = "regulator-fixed"; + regulator-name = "5V"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-always-on; + vin-supply = <&main_12v>; + gpio = <&gpio GPIOH_8 GPIO_OPEN_DRAIN>; + enable-active-high; + }; + + vcc_1v8: regulator-vcc_1v8 { + compatible = "regulator-fixed"; + regulator-name = "VCC_1V8"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + vin-supply = <&vcc_3v3>; + regulator-always-on; + }; + + vcc_3v3: regulator-vcc_3v3 { + compatible = "regulator-fixed"; + regulator-name = "VCC_3V3"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + vin-supply = <&vddao_3v3>; + regulator-always-on; + }; + + vddcpu: regulator-vddcpu { + /* + * MP8756GD Regulator. + */ + compatible = "pwm-regulator"; + + regulator-name = "VDDCPU"; + regulator-min-microvolt = <721000>; + regulator-max-microvolt = <1022000>; + + pwm-supply = <&main_12v>; + + pwms = <&pwm_AO_cd 1 1250 0>; + pwm-dutycycle-range = <100 0>; + + regulator-boot-on; + regulator-always-on; + }; + + usb_pwr_en: regulator-usb_pwr_en { + compatible = "regulator-fixed"; + regulator-name = "USB_PWR_EN"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + vin-supply = <&vcc_5v>; + + /* Connected to the internal USB-Hub */ + gpio = <&gpio_ao GPIOAO_2 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + + vddao_1v8: regulator-vddao_1v8 { + compatible = "regulator-fixed"; + regulator-name = "VDDAO_1V8"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + vin-supply = <&vddao_3v3>; + regulator-always-on; + }; + + vddao_3v3: regulator-vddao_3v3 { + compatible = "regulator-fixed"; + regulator-name = "VDDAO_3V3"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + vin-supply = <&main_12v>; + regulator-always-on; + }; + + hdmi-connector { + compatible = "hdmi-connector"; + type = "a"; + + port { + hdmi_connector_in: endpoint { + remote-endpoint = <&hdmi_tx_tmds_out>; + }; + }; + }; + + sound { + compatible = "amlogic,axg-sound-card"; + audio-aux-devs = <&tdmout_b>; + audio-routing = "TDM_B Playback", "TDMOUT_B OUT"; + + assigned-clocks = <&clkc CLKID_MPLL2>, + <&clkc CLKID_MPLL0>, + <&clkc CLKID_MPLL1>; + assigned-clock-parents = <0>, <0>, <0>; + assigned-clock-rates = <294912000>, + <270950400>, + <393216000>; + + /* 8ch hdmi interface */ + dai-link-0 { + sound-dai = <&tdmif_b>; + dai-format = "i2s"; + dai-tdm-slot-tx-mask-0 = <1 1>; + dai-tdm-slot-tx-mask-1 = <1 1>; + dai-tdm-slot-tx-mask-2 = <1 1>; + dai-tdm-slot-tx-mask-3 = <1 1>; + mclk-fs = <256>; + + codec { + sound-dai = <&tohdmitx TOHDMITX_I2S_IN_B>; + }; + }; + + /* hdmi glue */ + dai-link-1 { + sound-dai = <&tohdmitx TOHDMITX_I2S_OUT>; + + codec { + sound-dai = <&hdmi_tx>; + }; + }; + }; + + meson64-reboot { + compatible = "meson64,reboot"; + sys_reset = <0x84000009>; + sys_poweroff = <0x84000008>; + + sd-vqen = <&gpio GPIOE_2 GPIO_ACTIVE_HIGH>; + sd-vqsw = <&gpio_ao GPIOAO_6 GPIO_ACTIVE_HIGH>; + sd-vmmc = <&gpio_ao GPIOAO_3 GPIO_ACTIVE_HIGH>; + }; + + leds { + compatible = "gpio-leds"; + + led-green { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&gpio_ao GPIOAO_11 GPIO_ACTIVE_LOW>; + linux,default-trigger = "heartbeat"; + panic-indicator; + }; + + led-red { + color = ; + function = LED_FUNCTION_POWER; + gpios = <&gpio GPIOH_5 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + }; + + sound { + model = "JETHUB-D2"; + }; + +}; + +&arb { + status = "okay"; +}; + +&cec_AO { + pinctrl-0 = <&cec_ao_a_h_pins>; + pinctrl-names = "default"; + status = "disabled"; + hdmi-phandle = <&hdmi_tx>; +}; + +&cecb_AO { + pinctrl-0 = <&cec_ao_b_h_pins>; + pinctrl-names = "default"; + status = "okay"; + hdmi-phandle = <&hdmi_tx>; +}; + +&clkc_audio { + status = "okay"; +}; + +&cpu0 { + cpu-supply = <&vddcpu>; + operating-points-v2 = <&cpu_opp_table>; + clocks = <&clkc CLKID_CPU_CLK>; + clock-latency = <50000>; +}; + +&cpu1 { + cpu-supply = <&vddcpu>; + operating-points-v2 = <&cpu_opp_table>; + clocks = <&clkc CLKID_CPU1_CLK>; + clock-latency = <50000>; +}; + +&cpu2 { + cpu-supply = <&vddcpu>; + operating-points-v2 = <&cpu_opp_table>; + clocks = <&clkc CLKID_CPU2_CLK>; + clock-latency = <50000>; +}; + +&cpu3 { + cpu-supply = <&vddcpu>; + operating-points-v2 = <&cpu_opp_table>; + clocks = <&clkc CLKID_CPU3_CLK>; + clock-latency = <50000>; +}; + +&ext_mdio { + external_phy: ethernet-phy@0 { + /* Realtek RTL8211F (0x001cc916) */ + reg = <0>; + max-speed = <1000>; + + reset-assert-us = <10000>; + reset-deassert-us = <80000>; + reset-gpios = <&gpio GPIOZ_15 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>; + + interrupt-parent = <&gpio_intc>; + /* MAC_INTR on GPIOZ_14 */ + interrupts = ; + }; +}; + +ðmac { + pinctrl-0 = <ð_pins>, <ð_rgmii_pins>; + pinctrl-names = "default"; + status = "okay"; + phy-mode = "rgmii"; + phy-handle = <&external_phy>; + amlogic,tx-delay-ns = <2>; +}; + +&gpio { + gpio-line-names = + /* GPIOZ */ + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", + /* GPIOH */ + "", "", "", "", + "HUB_RESET", /* GPIOH_4 */ + "LED_RED", /* GPIOH_5 */ + "I2C_SDA_MODULES", /* GPIOH_6 */ + "I2C_SCL_MODULES", /* GPIOH_7 */ + "", + /* BOOT */ + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", + /* GPIOC */ + "", "", "", "", "", "", "", "", + /* GPIOA */ + "", "", "", "", "", "", "", "", + "", "", "", "", "", "", + "I2C_SDA_SYSBUS", /* GPIOA_14 */ + "I2C_SCL_SYSBUS", /* GPIOA_15 */ + /* GPIOX */ + "", /* GPIOX_0 */ + "", /* GPIOX_1 */ + "", /* GPIOX_2 */ + "", /* GPIOX_3 */ + "", /* GPIOX_4 */ + "", /* GPIOX_5 */ + "RS485_TX", /* GPIOX_6 */ + "RS485_RX", /* GPIOX_7 */ + "", /* GPIOX_8 */ + "", /* GPIOX_9 */ + "", /* GPIOX_10 */ + "", /* GPIOX_11 */ + "", /* GPIOX_12 */ + "", /* GPIOX_13 */ + "", /* GPIOX_14 */ + "", /* GPIOX_15 */ + "", /* GPIOX_16 */ + "I2C_SDA_LCDBUS", /* GPIOX_17 */ + "I2C_SCL_LCDBUS", /* GPIOX_18 */ + ""; /* GPIOX_19 */ + /* + * WARNING: The USB Hub needs a reset signal to be turned low in + * order to be detected by the USB Controller. This signal should + * be handled by a USB specific power sequence to reset the Hub + * when the USB bus is powered down. + */ + usb-hub-hog { + gpio-hog; + gpios = ; + output-low; + line-name = "usb-hub-reset"; + }; + +}; + +&gpio_ao { + gpio-line-names = + /* GPIOAO */ + "", "", + "USB_PWRON", /* GPIOAO_2 */ + "", + "MCU_RESET", /* GPIOAO_4 */ + "POWER_GOOD", /* GPIOAO_5 */ + "", + "GPIO_EXPANDER", /* GPIOAO_7 */ + "MCU_UART_TX", /* GPIOAO_8 */ + "MCU_UART_RX", /* GPIOAO_9 */ + "BUTTON_USR", /* GPIOAO_10 */ + "LED_GREEN", /* GPIOAO_11 */ + /* GPIOE */ + "", "", ""; +}; + +&hdmi_tx { + status = "okay"; + pinctrl-0 = <&hdmitx_hpd_pins>, <&hdmitx_ddc_pins>; + pinctrl-names = "default"; + hdmi-supply = <&vcc_5v>; +}; + +&hdmi_tx_tmds_port { + hdmi_tx_tmds_out: endpoint { + remote-endpoint = <&hdmi_connector_in>; + }; +}; + +&pwm_AO_cd { + pinctrl-0 = <&pwm_ao_d_e_pins>; // GPIOE_1 + pinctrl-names = "default"; + clocks = <&xtal>; + clock-names = "clkin1"; + status = "okay"; +}; + +&saradc { + status = "okay"; +}; + +/* SD card */ +&sd_emmc_b { + status = "okay"; + pinctrl-0 = <&sdcard_c_pins>; + pinctrl-1 = <&sdcard_clk_gate_c_pins>; + pinctrl-names = "default", "clk-gate"; + + bus-width = <4>; + cap-sd-highspeed; + max-frequency = <200000000>; + sd-uhs-sdr12; + sd-uhs-sdr25; + sd-uhs-sdr50; + sd-uhs-sdr104; + disable-wp; + + cd-gpios = <&gpio GPIOC_6 GPIO_ACTIVE_LOW>; + vmmc-supply = <&tflash_vdd>; + vqmmc-supply = <&tf_io>; +}; + +/* eMMC */ +&sd_emmc_c { + status = "okay"; + pinctrl-0 = <&emmc_ctrl_pins>, <&emmc_data_8b_pins>, <&emmc_ds_pins>; + pinctrl-1 = <&emmc_clk_gate_pins>; + pinctrl-names = "default", "clk-gate"; + + bus-width = <8>; + cap-mmc-highspeed; + mmc-ddr-1_8v; + mmc-hs200-1_8v; + max-frequency = <200000000>; + disable-wp; + + mmc-pwrseq = <&emmc_pwrseq>; + vmmc-supply = <&vcc_3v3>; + vqmmc-supply = <&flash_1v8>; +}; + +&spifc { + status = "disabled"; + pinctrl-0 = <&nor_pins>; + pinctrl-names = "default"; + + flash: nor-flash@0 { + compatible = "sst,w25q256", "jedec,spi-nor"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0>; + /*spi-max-frequency = <4000000>;*/ /* 4MHz */ + /*spi-max-frequency = <104000000>;*/ + spi-max-frequency = <30000000>; + }; +}; + +&tdmif_b { + status = "okay"; +}; + +&tdmout_b { + status = "okay"; +}; + +&tohdmitx { + status = "okay"; +}; + +&uart_AO { + status = "okay"; + pinctrl-0 = <&uart_ao_a_pins>; + pinctrl-names = "default"; +}; + +&uart_AO_B { + status = "okay"; + pinctrl-0 = <&uart_ao_b_8_9_pins>; + pinctrl-names = "default"; +}; + +&uart_B { + status = "okay"; + pinctrl-0 = <&uart_b_pins>; + pinctrl-names = "default"; +}; + + +&usb { + status = "okay"; + vbus-supply = <&usb_pwr_en>; +}; + +&usb2_phy0 { + phy-supply = <&vcc_5v>; +}; + + +/* I2C for modules */ +&i2c1 { + status = "okay"; + pinctrl-0 = <&i2c1_sda_h6_pins>, <&i2c1_sck_h7_pins>; + pinctrl-names = "default"; + + /* GPIO expander */ + u9: gpio@22 { + compatible = "nxp,pca9535"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + interrupt-parent = <&gpio_intc>; + interrupts = ; + + gpio-line-names = + "RELAY_1", "RELAY_2", + "", "", + "UXM1_RESET", "UXM1_BOOT", + "UXM2_RESET", "UXM2_BOOT", + "DIN_1", "DIN_2", "DIN_3", + "","","","",""; + }; + + /* 1-wire */ + w1: onewire@18 { + compatible = "maxim,ds2482"; + reg = <0x18>; + }; + +}; + + +/* I2C for lcd/etc */ +&i2c2 { + status = "okay"; + pinctrl-0 = <&i2c2_sda_x_pins>, <&i2c2_sck_x_pins>; + pinctrl-names = "default"; +}; + +/* I2C_EE_M3: I2C for CPU board */ +&i2c3 { + status = "okay"; + pinctrl-0 = <&i2c3_sda_a_pins>, <&i2c3_sck_a_pins>; + pinctrl-names = "default"; + + /* I2C for rtc */ + rtc: rtc@51 { + status = "okay"; + compatible = "nxp,pcf8563"; + reg = <0x51>; + wakeup-source; + }; + + /* FRAM on base board */ + fram: eeprom@52 { + compatible = "atmel,24c64"; + reg = <0x52>; + pagesize = <0x20>; + label = "fram"; + address-width = <0x10>; + vcc-supply = <&vddao_3v3>; + }; + + /* EEPROM on CPU board */ + eepromc: eeprom@54 { + compatible = "atmel,24c64"; + reg = <0x54>; + pagesize = <0x20>; + label = "eepromc"; + address-width = <0x10>; + vcc-supply = <&vddao_3v3>; + }; + + /* EEPROM on base board */ + eeprompd: eeprom@56 { + compatible = "atmel,24c64"; + reg = <0x56>; + pagesize = <0x20>; + label = "eeprompd"; + address-width = <0x10>; + vcc-supply = <&vddao_3v3>; + }; + + /* EEPROM on power module */ + eeprompm: eeprom@57 { + compatible = "atmel,24c64"; + reg = <0x57>; + pagesize = <0x20>; + label = "eeprompm"; + address-width = <0x10>; + vcc-supply = <&vddao_3v3>; + }; + + /* temperature sensors */ + temp1: tmp102@48 { + compatible = "ti,tmp102"; + reg = <0x48>; + }; + + temp2: tmp102@49 { + compatible = "ti,tmp102"; + reg = <0x49>; + }; + +}; + +&efuse { + eth_mac: eth-mac@0 { + reg = <0x0 0x6>; + }; + + bt_mac: bt-mac@6 { + reg = <0x6 0x6>; + }; + + wifi_mac: wifi-mac@c { + reg = <0xc 0x6>; + }; + + bid: bid@12 { + reg = <0x12 0x20>; + }; + + sn: sn@32 { + reg = <0x32 0x20>; + }; +}; + +&cpu_thermal { + trips { + cpu_passive: cpu-passive { + temperature = <70000>; /* millicelsius */ + hysteresis = <2000>; /* millicelsius */ + type = "passive"; /* */ + }; + + cpu_hot: cpu-hot { + temperature = <85000>; /* millicelsius */ + hysteresis = <2000>; /* millicelsius */ + type = "hot"; + }; + + cpu_critical: cpu-critical { + temperature = <90000>; /* millicelsius */ + hysteresis = <2000>; /* millicelsius */ + type = "critical"; + }; + }; + + cooling-maps { + map0 { + trip = <&cpu_passive>; + cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + + map1 { + trip = <&cpu_hot>; + cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; +}; + +&ddr_thermal { + trips { + ddr_passive: ddr-passive { + temperature = <70000>; /* millicelsius */ + hysteresis = <2000>; /* millicelsius */ + type = "passive"; + }; + + ddr_critical: ddr-critical { + temperature = <85000>; /* millicelsius */ + hysteresis = <2000>; /* millicelsius */ + type = "critical"; + }; + }; + +}; diff --git a/board/amlogic/jethub-j200/MAINTAINERS b/board/amlogic/jethub-j200/MAINTAINERS new file mode 100644 index 000000000000..111111111111 --- /dev/null +++ b/board/amlogic/jethub-j200/MAINTAINERS @@ -0,0 +1,8 @@ +JetHome JetHub +M: Viacheslav Bocharov +S: Maintained +L: u-boot-amlogic@groups.io +F: board/amlogic/jethub-j200/ +F: configs/jethub_j200_defconfig +F: doc/board/amlogic/jethub-j200.rst +F: include/configs/jethub.h diff --git a/board/amlogic/jethub-j200/Makefile b/board/amlogic/jethub-j200/Makefile new file mode 100644 index 000000000000..111111111111 --- /dev/null +++ b/board/amlogic/jethub-j200/Makefile @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# (C) Copyright 2024 JetHome +# Author: Viacheslav Bocharov + +obj-y := jethub-j200.o diff --git a/board/amlogic/jethub-j200/jethub-j200.c b/board/amlogic/jethub-j200/jethub-j200.c new file mode 100644 index 000000000000..111111111111 --- /dev/null +++ b/board/amlogic/jethub-j200/jethub-j200.c @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2024 JetHome + * Author: Viacheslav Bocharov + * + */ + +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define EFUSE_SN_OFFSET 50 +#define EFUSE_SN_SIZE 32 +#define EFUSE_MAC_OFFSET 0 +#define EFUSE_MAC_SIZE 6 +#define EFUSE_USID_OFFSET 18 +#define EFUSE_USID_SIZE 32 + +int mmc_get_env_dev(void) +{ + if (meson_get_boot_device() == BOOT_DEVICE_EMMC) + return 1; + return 0; +} + +static void init_board_power(void) +{ + struct gpio_desc *usb_hog; + int ret = 0; + + ret = gpio_hog_lookup_name("usb-hub-hog", &usb_hog); + if (ret) + goto err; + + ret = dm_gpio_set_value(usb_hog, false); + if (ret && ret != -EALREADY) + goto err; + + return; +err: + printf("%s: Failed to init USB power %i\n", __func__, ret); +} + +int misc_init_r(void) +{ + u8 mac_addr[EFUSE_MAC_SIZE]; + char serial[EFUSE_SN_SIZE]; + char usid[EFUSE_USID_SIZE]; + ssize_t len; + + init_board_power(); + + if (!eth_env_get_enetaddr("ethaddr", mac_addr)) { + len = meson_sm_read_efuse(EFUSE_MAC_OFFSET, + mac_addr, EFUSE_MAC_SIZE); + if (len == EFUSE_MAC_SIZE && is_valid_ethaddr(mac_addr)) + eth_env_set_enetaddr("ethaddr", mac_addr); + else { + printf("eFuse MAC address is not valid\n"); + meson_generate_serial_ethaddr(); + } + } + + if (!env_get("serial")) { + len = meson_sm_read_efuse(EFUSE_SN_OFFSET, serial, + EFUSE_SN_SIZE); + if (len == EFUSE_SN_SIZE) + env_set("serial", serial); + } + + if (!env_get("usid")) { + len = meson_sm_read_efuse(EFUSE_USID_OFFSET, usid, + EFUSE_USID_SIZE); + if (len == EFUSE_USID_SIZE) + env_set("usid", usid); + } + + return 0; +} + diff --git a/configs/jethub_j200_defconfig b/configs/jethub_j200_defconfig new file mode 100644 index 000000000000..111111111111 --- /dev/null +++ b/configs/jethub_j200_defconfig @@ -0,0 +1,120 @@ +CONFIG_OF_UPSTREAM=n +CONFIG_ARM=y +CONFIG_SYS_BOARD="jethub-j200" +CONFIG_SYS_CONFIG_NAME="jethub" +CONFIG_ARCH_MESON=y +CONFIG_TEXT_BASE=0x01000000 +CONFIG_NR_DRAM_BANKS=1 +CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y +CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x20000000 +CONFIG_ENV_SIZE=0x2000 +CONFIG_DM_GPIO=y +CONFIG_DEFAULT_DEVICE_TREE="meson-sm1-jethome-jethub-j200" +CONFIG_OF_LIBFDT_OVERLAY=y +CONFIG_DM_RESET=y +CONFIG_MESON_G12A=y +CONFIG_DEBUG_UART_BASE=0xff803000 +CONFIG_DEBUG_UART_CLOCK=24000000 +CONFIG_IDENT_STRING=" jethubj200" +CONFIG_SYS_LOAD_ADDR=0x1000000 +CONFIG_DEBUG_UART=y +CONFIG_REMAKE_ELF=y +CONFIG_FIT=y +CONFIG_FIT_SIGNATURE=y +CONFIG_FIT_VERBOSE=y +CONFIG_LEGACY_IMAGE_FORMAT=y +CONFIG_OF_BOARD_SETUP=y +# CONFIG_DISPLAY_CPUINFO is not set +CONFIG_MISC_INIT_R=y +CONFIG_SYS_MAXARGS=32 +# CONFIG_CMD_BDI is not set +# CONFIG_CMD_IMI is not set +CONFIG_CMD_EEPROM=y +CONFIG_CMD_DFU=y +CONFIG_CMD_GPIO=y +CONFIG_CMD_I2C=y +# CONFIG_CMD_LOADS is not set +CONFIG_CMD_MMC=y +CONFIG_CMD_USB=y +CONFIG_CMD_USB_MASS_STORAGE=y +CONFIG_CMD_SETEXPR=y +CONFIG_CMD_RTC=y +CONFIG_CMD_REGULATOR=y +CONFIG_PARTITION_TYPE_GUID=y +CONFIG_OF_CONTROL=y +CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_ADC=y +CONFIG_SARADC_MESON=y +CONFIG_DFU_RAM=y +CONFIG_DM_I2C=y +CONFIG_SYS_I2C_MESON=y +CONFIG_MMC_MESON_GX=y +CONFIG_MTD=y +CONFIG_DM_MTD=y +CONFIG_DM_SPI_FLASH=y +CONFIG_SPI_FLASH_WINBOND=y +CONFIG_SPI_FLASH_XTX=y +CONFIG_SPI_LOAD=y +CONFIG_PHY_REALTEK=y +CONFIG_DM_MDIO=y +CONFIG_DM_MDIO_MUX=y +CONFIG_ETH_DESIGNWARE_MESON8B=y +CONFIG_MDIO_MUX_MESON_G12A=y +CONFIG_MESON_G12A_USB_PHY=y +CONFIG_PINCTRL=y +CONFIG_PINCTRL_MESON_G12A=y +CONFIG_POWER_DOMAIN=y +CONFIG_MESON_EE_POWER_DOMAIN=y +CONFIG_DM_REGULATOR=y +CONFIG_DM_REGULATOR_FIXED=y +CONFIG_DM_REGULATOR_GPIO=y +CONFIG_DM_RTC=y +CONFIG_RTC_PCF8563=y +CONFIG_DEBUG_UART_ANNOUNCE=y +CONFIG_DEBUG_UART_SKIP_INIT=y +CONFIG_MESON_SERIAL=y +CONFIG_SPI=y +CONFIG_DM_SPI=y +CONFIG_MESON_SPIFC=y +CONFIG_SYSINFO=y +CONFIG_SYSINFO_SMBIOS=y +CONFIG_USB=y +CONFIG_DM_USB_GADGET=y +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_XHCI_DWC3=y +CONFIG_USB_DWC3=y +# CONFIG_USB_DWC3_GADGET is not set +CONFIG_USB_DWC3_MESON_G12A=y +CONFIG_USB_KEYBOARD=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_VENDOR_NUM=0x1b8e +CONFIG_USB_GADGET_PRODUCT_NUM=0xfada +CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_GADGET_DWC2_OTG_PHY_BUS_WIDTH_8=y +CONFIG_USB_GADGET_DOWNLOAD=y +CONFIG_VIDEO=y +# CONFIG_VIDEO_BPP8 is not set +# CONFIG_VIDEO_BPP16 is not set +CONFIG_SYS_WHITE_ON_BLACK=y +CONFIG_VIDEO_MESON=y +CONFIG_VIDEO_DT_SIMPLEFB=y +CONFIG_SPLASH_SCREEN=y +CONFIG_SPLASH_SCREEN_ALIGN=y +CONFIG_VIDEO_BMP_RLE8=y +CONFIG_BMP_16BPP=y +CONFIG_BMP_24BPP=y +CONFIG_BMP_32BPP=y + +#CONFIG_MTD_UBI=y +CONFIG_RANDOM_UUID=y +CONFIG_CMD_PART=y + +CONFIG_AML_DRIVER=y +CONFIG_UNIFY_KEY_MANAGE=y +CONFIG_SECURE_STORAGE=y +CONFIG_AML_STORAGE=y +CONFIG_EFUSE=y +CONFIG_AML_PARTITION=y + +CONFIG_GPIO_HOG=y +CONFIG_CMD_SPI=y diff --git a/doc/board/amlogic/index.rst b/doc/board/amlogic/index.rst index 111111111111..222222222222 100644 --- a/doc/board/amlogic/index.rst +++ b/doc/board/amlogic/index.rst @@ -97,6 +97,7 @@ Board Documentation beelink-gtkingpro jethub-j80 jethub-j100 + jethub-j200 khadas-vim khadas-vim2 khadas-vim3 diff --git a/doc/board/amlogic/jethub-j200.rst b/doc/board/amlogic/jethub-j200.rst new file mode 100644 index 000000000000..111111111111 --- /dev/null +++ b/doc/board/amlogic/jethub-j200.rst @@ -0,0 +1,50 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +U-Boot for JetHub D2 (J200) +=================================== + +JetHome Jethub D2 (http://jethome.com/jethub-d2) is a home automation controller device +manufactured by JetHome with the following specifications: + + - Amlogic S905X3 (ARM Cortex-A55) quad-core up to 2.1GHz + - micro-HDMI video out + - 4Gb DDR4 RAM + - 32GB eMMC flash + - 1 x USB 2.0 Type-C + - 1 x 10/100/1000Mbps ethernet + - two module slots (JXM format) + - 2 x gpio LEDS + - GPIO user Button + - DC source with a voltage of 9 to 36V (variable via power module) + - DIN Rail Mounting case + - 1 x 1-Wire + - 1 x RS-485 + - 3 x dry contact digital GPIO inputs + - 2 x relay GPIO outputs + +U-Boot Compilation +------------------ + +.. code-block:: bash + + $ export CROSS_COMPILE=aarch64-none-elf- + $ make jethub_j200_defconfig + $ make + +U-Boot Signing with Pre-Built FIP repo +-------------------------------------- + +.. code-block:: bash + + $ git clone https://github.com/LibreELEC/amlogic-boot-fip --depth=1 + $ cd amlogic-boot-fip + $ mkdir my-output-dir + $ ./build-fip.sh jethub-j200 /path/to/u-boot/u-boot.bin my-output-dir + +Then write U-Boot to SD or eMMC with: + +.. code-block:: bash + + $ DEV=/dev/boot_device + $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1 + $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=440 diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c index 111111111111..222222222222 100644 --- a/drivers/power/regulator/regulator-uclass.c +++ b/drivers/power/regulator/regulator-uclass.c @@ -191,7 +191,7 @@ int regulator_set_enable(struct udevice *dev, bool enable) } } } - + printf("%s: %s, enable=%d, r=%d\n", __func__, dev->name, enable, ret); return ret; } diff --git a/include/configs/jethub.h b/include/configs/jethub.h index 111111111111..222222222222 100644 --- a/include/configs/jethub.h +++ b/include/configs/jethub.h @@ -2,6 +2,7 @@ /* * Configuration for JetHome devices * Copyright (C) 2021 Vyacheslav Bocharov + * Copyright (C) 2024 JetHome * Author: Vyacheslav Bocharov */ @@ -15,6 +16,14 @@ "run bootcmd_mmc0; " \ "run bootcmd_usb0;" \ "fi;\0" +#elif defined(CONFIG_MESON_G12A) +#define BOOTENV_DEV_RESCUE(devtypeu, devtypel, instance) \ + "bootcmd_rescue=" \ + "if gpio input aobus-banks10; then " \ + "run bootcmd_mmc1; " \ + "run bootcmd_mmc0; " \ + "run bootcmd_usb0;" \ + "fi;\0" #else #define BOOTENV_DEV_RESCUE(devtypeu, devtypel, instance) \ "bootcmd_rescue=" \ -- Armbian