Skip to content

Commit

Permalink
t95 wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jernejsk committed Jun 14, 2021
1 parent e3b64be commit 96418e4
Show file tree
Hide file tree
Showing 10 changed files with 247 additions and 5 deletions.
1 change: 1 addition & 0 deletions arch/arm/dts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ dtb-$(CONFIG_MACH_SUN50I_H6) += \
sun50i-h6-pine-h64.dtb \
sun50i-h6-tanix-tx6.dtb
dtb-$(CONFIG_MACH_SUN50I_H616) += \
sun50i-h616-t95.dtb \
sun50i-h616-orangepi-zero2.dtb
dtb-$(CONFIG_MACH_SUN50I) += \
sun50i-a64-amarula-relic.dtb \
Expand Down
189 changes: 189 additions & 0 deletions arch/arm/dts/sun50i-h616-t95.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
// SPDX-License-Identifier: (GPL-2.0+ or MIT)
/*
* Copyright (C) 2020 Arm Ltd.
*/

/dts-v1/;

#include "sun50i-h616.dtsi"

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/interrupt-controller/arm-gic.h>

/ {
model = "T95";
compatible = "t95", "allwinner,sun50i-h616";

aliases {
ethernet0 = &emac1;
serial0 = &uart0;
};

chosen {
stdout-path = "serial0:115200n8";
};

leds {
compatible = "gpio-leds";

power {
label = "orangepi:red:power";
gpios = <&pio 2 13 GPIO_ACTIVE_HIGH>; /* PC13 */
default-state = "on";
};

status {
label = "orangepi:green:status";
gpios = <&pio 2 12 GPIO_ACTIVE_HIGH>; /* PC12 */
};
};

reg_vcc5v: vcc5v {
/* board wide 5V supply directly from the USB-C socket */
compatible = "regulator-fixed";
regulator-name = "vcc-5v";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
regulator-always-on;
};
};

&emac1 {
pinctrl-names = "default";
pinctrl-0 = <&rmii_pins>;
phy-mode = "rmii";
phy-handle = <&rmii_phy>;
phy-supply = <&reg_aldo1>;
allwinner,rx-delay-ps = <3100>;
allwinner,tx-delay-ps = <700>;
status = "okay";
};

&mdio1 {
rmii_phy: ethernet-phy@1 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <1>;
};
};

&mmc0 {
vmmc-supply = <&reg_dcdce>;
broken-cd;
bus-width = <4>;
status = "okay";
};

&r_i2c {
status = "okay";

axp305: pmic@36 {
compatible = "x-powers,axp305", "x-powers,axp805",
"x-powers,axp806";
reg = <0x36>;

/* dummy interrupt to appease the driver for now */
interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>;
interrupt-controller;
#interrupt-cells = <1>;

x-powers,self-working-mode;
vina-supply = <&reg_vcc5v>;
vinb-supply = <&reg_vcc5v>;
vinc-supply = <&reg_vcc5v>;
vind-supply = <&reg_vcc5v>;
vine-supply = <&reg_vcc5v>;
aldoin-supply = <&reg_vcc5v>;
bldoin-supply = <&reg_vcc5v>;
cldoin-supply = <&reg_vcc5v>;

regulators {
reg_aldo1: aldo1 {
regulator-always-on;
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-name = "vcc-sys";
};

reg_aldo2: aldo2 {
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-name = "vcc3v3-ext";
};

reg_aldo3: aldo3 {
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-name = "vcc3v3-ext2";
};

reg_bldo1: bldo1 {
regulator-always-on;
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-name = "vcc1v8";
};

bldo2 {
/* unused */
};

bldo3 {
/* unused */
};

bldo4 {
/* unused */
};

cldo1 {
/* reserved */
};

cldo2 {
/* unused */
};

cldo3 {
/* unused */
};

reg_dcdca: dcdca {
regulator-always-on;
regulator-min-microvolt = <810000>;
regulator-max-microvolt = <1080000>;
regulator-name = "vdd-cpu";
};

reg_dcdcc: dcdcc {
regulator-always-on;
regulator-min-microvolt = <810000>;
regulator-max-microvolt = <1080000>;
regulator-name = "vdd-gpu-sys";
};

reg_dcdcd: dcdcd {
regulator-always-on;
regulator-min-microvolt = <1500000>;
regulator-max-microvolt = <1500000>;
regulator-name = "vdd-dram";
};

reg_dcdce: dcdce {
regulator-boot-on;
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-name = "vcc-eth-mmc";
};

sw {
/* unused */
};
};
};
};

&uart0 {
pinctrl-names = "default";
pinctrl-0 = <&uart0_ph_pins>;
status = "okay";
};
9 changes: 8 additions & 1 deletion arch/arm/dts/sun50i-h616.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@
bias-pull-up;
};

rmii_pins: rmii-pins {
pins = "PA0", "PA1", "PA2", "PA3", "PA4",
"PA5", "PA6", "PA7", "PA8", "PA9";
function = "emac1";
drive-strength = <40>;
};

spi0_pins: spi0-pins {
pins = "PC0", "PC2", "PC3", "PC4";
function = "spi0";
Expand Down Expand Up @@ -476,7 +483,7 @@
};

emac1: ethernet@5030000 {
compatible = "allwinner,sun50i-h616-emac";
compatible = "allwinner,sun50i-h616-emac2";
syscon = <&syscon 1>;
reg = <0x05030000 0x10000>;
interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-sunxi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ config I2C2_ENABLE
---help---
See I2C0_ENABLE help text.

if MACH_SUN6I || MACH_SUN7I
if MACH_SUN6I || MACH_SUN7I || MACH_SUN50I_H616
config I2C3_ENABLE
bool "Enable I2C/TWI controller 3"
default n
Expand Down
1 change: 1 addition & 0 deletions arch/arm/mach-sunxi/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ void board_init_f(ulong dummy)
#ifdef CONFIG_SPL_I2C_SUPPORT
/* Needed early by sunxi_board_init if PMU is enabled */
i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
i2c_set_bus_num(1);
#endif
sunxi_board_init();
}
Expand Down
4 changes: 4 additions & 0 deletions arch/arm/mach-sunxi/clock_sun50i_h6.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ void clock_init_safe(void)
* DRAM initialization code.
*/
writel(MBUS_CLK_SRC_PLL6X2 | MBUS_CLK_M(3), &ccm->mbus_cfg);

writel(0x10001, 0x030017ac);
writel(0x50, 0x0300a028);
writel(0x20, 0x0300a040);
}
#endif

Expand Down
26 changes: 26 additions & 0 deletions board/sunxi/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <dm.h>
#include <env.h>
#include <hang.h>
#include <i2c.h>
#include <image.h>
#include <init.h>
#include <log.h>
Expand Down Expand Up @@ -181,6 +182,13 @@ void i2c_init_board(void)
sunxi_gpio_set_cfgpin(SUNXI_GPI(0), SUN7I_GPI_TWI3);
sunxi_gpio_set_cfgpin(SUNXI_GPI(1), SUN7I_GPI_TWI3);
clock_twi_onoff(3, 1);
#elif defined(CONFIG_MACH_SUN50I_H616)
sunxi_gpio_set_cfgpin(SUNXI_GPA(10), 2);
sunxi_gpio_set_cfgpin(SUNXI_GPA(11), 2);
sunxi_gpio_set_cfgpin(SUNXI_GPA(12), 2);
sunxi_gpio_set_pull(SUNXI_GPA(10), SUNXI_GPIO_PULL_UP);
sunxi_gpio_set_pull(SUNXI_GPA(11), SUNXI_GPIO_PULL_UP);
clock_twi_onoff(3, 1);
#endif
#endif

Expand Down Expand Up @@ -644,6 +652,7 @@ static void sunxi_spl_store_dram_size(phys_addr_t dram_size)
void sunxi_board_init(void)
{
int power_failed = 0;
u8 data[2];

#ifdef CONFIG_SY8106A_POWER
power_failed = sy8106a_set_vout1(CONFIG_SY8106A_VOUT1_VOLT);
Expand Down Expand Up @@ -723,6 +732,23 @@ void sunxi_board_init(void)
clock_set_pll1(CONFIG_SYS_CLK_FREQ);
else
printf("Failed to set core voltage! Can't set CPU frequency\n");

i2c_set_bus_num(0);
data[0] = 0;
data[1] = 0;
i2c_write(0x10, 0xfe, 1, data, 2);
i2c_write(0x10, 2, 1, data, 2);
data[1] = 1;
i2c_write(0x10, 2, 1, data, 2);
data[1] = 0xf;
i2c_write(0x10, 0x16, 1, data, 2);
data[1] = 3;
i2c_write(0x10, 0x14, 1, data, 2);
data[1] = 0x60;
i2c_write(0x10, 0xfe, 1, data, 2);
data[0] = 0x08;
data[1] = 0x14;
i2c_write(0x10, 0, 1, data, 2);
}
#endif

Expand Down
12 changes: 12 additions & 0 deletions configs/t95_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CONFIG_ARM=y
CONFIG_ARCH_SUNXI=y
CONFIG_SPL=y
CONFIG_DRAM_SUN50I_H616_READ_CALIBRATION=y
CONFIG_DRAM_SUN50I_H616_UNKNOWN_FEATURE=y
CONFIG_MACH_SUN50I_H616=y
CONFIG_R_I2C_ENABLE=y
CONFIG_DEFAULT_DEVICE_TREE="sun50i-h616-t95"
# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
CONFIG_SPL_I2C_SUPPORT=y
CONFIG_SUN8I_EMAC=y
CONFIG_I2C3_ENABLE=y
6 changes: 4 additions & 2 deletions drivers/net/sun8i_emac.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ static int sun8i_emac_set_syscon(struct sun8i_eth_pdata *pdata,
return 0;
}

reg = readl(priv->sysctl_reg + 0x30);
reg = readl(priv->sysctl_reg + 0x34);

reg = sun8i_emac_set_syscon_ephy(priv, reg);

Expand Down Expand Up @@ -377,7 +377,7 @@ static int sun8i_emac_set_syscon(struct sun8i_eth_pdata *pdata,
reg |= ((pdata->rx_delay_ps / 100) << SC_ERXDC_OFFSET)
& SC_ERXDC_MASK;

writel(reg, priv->sysctl_reg + 0x30);
writel(reg, priv->sysctl_reg + 0x34);

return 0;
}
Expand Down Expand Up @@ -1009,6 +1009,8 @@ static const struct udevice_id sun8i_emac_eth_ids[] = {
.data = (uintptr_t)R40_GMAC },
{.compatible = "allwinner,sun50i-h6-emac",
.data = (uintptr_t)H6_EMAC },
{.compatible = "allwinner,sun50i-h616-emac2",
.data = (uintptr_t)H6_EMAC },
{ }
};

Expand Down
2 changes: 1 addition & 1 deletion include/configs/sunxi-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
#define CONFIG_SYS_I2C_MVTWSI
#if !CONFIG_IS_ENABLED(DM_I2C)
#define CONFIG_SYS_I2C
#define CONFIG_SYS_I2C_SPEED 400000
#define CONFIG_SYS_I2C_SPEED 100000
#define CONFIG_SYS_I2C_SLAVE 0x7f
#endif
#endif
Expand Down

0 comments on commit 96418e4

Please sign in to comment.