Skip to contentSkip to conversation

Add support for Pinebook

PATCH New Vasily Khoruzhick 2 participants 6 messages Nov 6, 2018 – Nov 13, 2018

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v5 cover Add support for Pinebook

This series adds support for the Pinebook, an allwinner A64 laptop produced by Pine64. It also adds support for mmc delay calibration, R_I2C controller, and addresses the issue with activating video bridge when any of GPIOs is missing.

This series depends on André's "sunxi: A64/H3/H5 DT updates"

v2: - sync sun50i-a64.dtsi with linux instead of adding missing nodes
- take sun50i-a64-pinebook.dts from linux
- don't introduce new Kconfig for A64 MMC calibration
- improve code in video bridge uclass to check for presensce of GPIO instead of ingoring EINVAL errors
v3: - enable calibration for H6 as well
- init ret variable in video_bridge_set_active()
- fix order of dts files Makefile
- split anx6345 binding into sun50i-a64-pinebook-u-boot.dts
- drop speaker_amp node from pinebook dts
- drop unnecessary options from defconfig
v4: - sync device tree files with linux-next
v5: - drop patch to sync device tree files with linux-next

Vasily Khoruzhick (4):
mmc: sunxi: add support for automatic delay calibration
dm: video: bridge: don't fail to activate bridge if reset or sleep
GPIO is missing
sun50i: A64: add support for R_I2C controller
sunxi: DT: add support for Pinebook

 arch/arm/dts/Makefile                        |   1 +
 arch/arm/dts/sun50i-a64-pinebook-u-boot.dtsi |  15 +
 arch/arm/dts/sun50i-a64-pinebook.dts         | 294 +++++++++++++++++++
 arch/arm/include/asm/arch-sunxi/gpio.h       |   1 +
 arch/arm/include/asm/arch-sunxi/mmc.h        |   6 +-
 arch/arm/mach-sunxi/Kconfig                  |   1 +
 board/sunxi/board.c                          |   6 +
 configs/pinebook_defconfig                   |  22 ++
 drivers/mmc/sunxi_mmc.c                      |  21 +-
 drivers/video/bridge/video-bridge-uclass.c   |  16 +-
 10 files changed, 376 insertions(+), 7 deletions(-)
 create mode 100644 arch/arm/dts/sun50i-a64-pinebook-u-boot.dtsi
 create mode 100644 arch/arm/dts/sun50i-a64-pinebook.dts
 create mode 100644 configs/pinebook_defconfig
Signature · 1 line
2.19.1
#1 lore raw

PATCH v5 1/4 mmc: sunxi: add support for automatic delay calibration

A64 and H6 support automatic delay calibration and Linux driver uses it instead of hardcoded delays. Add support for it to u-boot driver.

Fixes eMMC instability on Pinebook

---
 arch/arm/include/asm/arch-sunxi/mmc.h |  6 +++++-
 drivers/mmc/sunxi_mmc.c               | 21 ++++++++++++++++++++-
 2 files changed, 25 insertions(+), 2 deletions(-)
arch/arm/include/asm/arch-sunxi/mmc.h +5 -1
index d98c53faaa..f2deafddd2 100644
@@ -46,7 +46,9 @@ struct sunxi_mmc {
 	u32 cbda;		/* 0x94 */
 	u32 res2[26];
 #if defined(CONFIG_SUNXI_GEN_SUN6I) || defined(CONFIG_MACH_SUN50I_H6)
-	u32 res3[64];
+	u32 res3[17];
+	u32 samp_dl;
+	u32 res4[46];
 #endif
 	u32 fifo;		/* 0x100 / 0x200 FIFO access address */
 };
@@ -130,5 +132,7 @@ struct sunxi_mmc {
 #define SUNXI_MMC_COMMON_CLK_GATE		(1 << 16)
 #define SUNXI_MMC_COMMON_RESET			(1 << 18)
 
+#define SUNXI_MMC_CAL_DL_SW_EN		(0x1 << 7)
+
 struct mmc *sunxi_mmc_init(int sdc_no);
 #endif /* _SUNXI_MMC_H */
drivers/mmc/sunxi_mmc.c +20 -1
index 39f15eb423..147eb9b4d5 100644
@@ -99,11 +99,16 @@ static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
 {
 	unsigned int pll, pll_hz, div, n, oclk_dly, sclk_dly;
 	bool new_mode = false;
+	bool calibrate = false;
 	u32 val = 0;
 
 	if (IS_ENABLED(CONFIG_MMC_SUNXI_HAS_NEW_MODE) && (priv->mmc_no == 2))
 		new_mode = true;
 
+#if defined(CONFIG_MACH_SUN50I) || defined(CONFIG_MACH_SUN50I_H6)
+	calibrate = true;
+#endif
+
 	/*
 	 * The MMC clock has an extra /2 post-divider when operating in the new
 	 * mode.
@@ -174,7 +179,11 @@ static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
 		val = CCM_MMC_CTRL_MODE_SEL_NEW;
 		setbits_le32(&priv->reg->ntsr, SUNXI_MMC_NTSR_MODE_SEL_NEW);
 #endif
-	} else {
+	} else if (!calibrate) {
+		/*
+		 * Use hardcoded delay values if controller doesn't support
+		 * calibration
+		 */
 		val = CCM_MMC_CTRL_OCLK_DLY(oclk_dly) |
 			CCM_MMC_CTRL_SCLK_DLY(sclk_dly);
 	}
@@ -228,6 +237,16 @@ static int mmc_config_clock(struct sunxi_mmc_priv *priv, struct mmc *mmc)
 	rval &= ~SUNXI_MMC_CLK_DIVIDER_MASK;
 	writel(rval, &priv->reg->clkcr);
 
+#if defined(CONFIG_MACH_SUN50I) || defined(CONFIG_MACH_SUN50I_H6)
+	/* A64 supports calibration of delays on MMC controller and we
+	 * have to set delay of zero before starting calibration.
+	 * Allwinner BSP driver sets a delay only in the case of
+	 * using HS400 which is not supported by mainline U-Boot or
+	 * Linux at the moment
+	 */
+	writel(SUNXI_MMC_CAL_DL_SW_EN, &priv->reg->samp_dl);
+#endif
+
 	/* Re-enable Clock */
 	rval |= SUNXI_MMC_CLK_ENABLE;
 	writel(rval, &priv->reg->clkcr);
Signature · 1 line
2.19.1
#2 lore raw

PATCH v5 2/4 dm: video: bridge: don't fail to activate bridge if reset or sleep GPIO is missing

In reply to Vasily Khoruzhick

Both GPIOs are optional, so we shouldn't fail if any is missing. Without this fix reset is not deasserted if sleep GPIO is missing.

---
 drivers/video/bridge/video-bridge-uclass.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/video/bridge/video-bridge-uclass.c +11 -5
index cd4959cc71..5fecb4cfd5 100644
@@ -106,13 +106,19 @@ static int video_bridge_pre_probe(struct udevice *dev)
 int video_bridge_set_active(struct udevice *dev, bool active)
 {
 	struct video_bridge_priv *uc_priv = dev_get_uclass_priv(dev);
-	int ret;
+	int ret = 0;
 
 	debug("%s: %d\n", __func__, active);
-	ret = dm_gpio_set_value(&uc_priv->sleep, !active);
-	if (ret)
-		return ret;
-	if (active) {
+	if (uc_priv->sleep.dev) {
+		ret = dm_gpio_set_value(&uc_priv->sleep, !active);
+		if (ret)
+			return ret;
+	}
+
+	if (!active)
+		return 0;
+
+	if (uc_priv->reset.dev) {
 		ret = dm_gpio_set_value(&uc_priv->reset, true);
 		if (ret)
 			return ret;
Signature · 1 line
2.19.1
#3 lore raw

PATCH v5 3/4 sun50i: A64: add support for R_I2C controller

In reply to Vasily Khoruzhick

Allwinner A64 has a I2C controller, which is in the R_ MMIO zone and has two groups of pinmuxes on PL bank, so it's called R_I2C.

Add support for this I2C controller and the pinmux which doesn't conflict with RSB.

---
 arch/arm/include/asm/arch-sunxi/gpio.h | 1 +
 arch/arm/mach-sunxi/Kconfig            | 1 +
 board/sunxi/board.c                    | 6 ++++++
 3 files changed, 8 insertions(+)
arch/arm/include/asm/arch-sunxi/gpio.h +1 -0
index 6a5eafc3d3..2daf23f6f5 100644
@@ -211,6 +211,7 @@ enum sunxi_gpio_number {
 #define SUN8I_H3_GPL_R_TWI	2
 #define SUN8I_A23_GPL_R_TWI	3
 #define SUN8I_GPL_R_UART	2
+#define SUN50I_GPL_R_TWI	2
 
 #define SUN9I_GPN_R_RSB		3
 
arch/arm/mach-sunxi/Kconfig +1 -0
index 6277abc3cc..560dc9b25d 100644
@@ -278,6 +278,7 @@ config MACH_SUN50I
 	select ARM64
 	select DM_I2C
 	select PHY_SUN4I_USB
+	select SUN6I_PRCM
 	select SUNXI_DE2
 	select SUNXI_GEN_SUN6I
 	select SUPPORT_SPL
board/sunxi/board.c +6 -0
index b196d48674..64ccbc7245 100644
@@ -168,10 +168,16 @@ void i2c_init_board(void)
 #endif
 
 #ifdef CONFIG_R_I2C_ENABLE
+#ifdef CONFIG_MACH_SUN50I
+	clock_twi_onoff(5, 1);
+	sunxi_gpio_set_cfgpin(SUNXI_GPL(8), SUN50I_GPL_R_TWI);
+	sunxi_gpio_set_cfgpin(SUNXI_GPL(9), SUN50I_GPL_R_TWI);
+#else
 	clock_twi_onoff(5, 1);
 	sunxi_gpio_set_cfgpin(SUNXI_GPL(0), SUN8I_H3_GPL_R_TWI);
 	sunxi_gpio_set_cfgpin(SUNXI_GPL(1), SUN8I_H3_GPL_R_TWI);
 #endif
+#endif
 }
 
 #if defined(CONFIG_ENV_IS_IN_MMC) && defined(CONFIG_ENV_IS_IN_FAT)
Signature · 1 line
2.19.1
#4 lore raw

PATCH v5 4/4 sunxi: DT: add support for Pinebook

In reply to Vasily Khoruzhick

Pinebook is a laptop produced by Pine64, with USB-connected keyboard, USB-connected touchpad and an eDP LCD panel connected via a RGB-eDP bridge from Analogix.

---
 arch/arm/dts/Makefile                        |   1 +
 arch/arm/dts/sun50i-a64-pinebook-u-boot.dtsi |  15 +
 arch/arm/dts/sun50i-a64-pinebook.dts         | 294 +++++++++++++++++++
 configs/pinebook_defconfig                   |  22 ++
 4 files changed, 332 insertions(+)
 create mode 100644 arch/arm/dts/sun50i-a64-pinebook-u-boot.dtsi
 create mode 100644 arch/arm/dts/sun50i-a64-pinebook.dts
 create mode 100644 configs/pinebook_defconfig
arch/arm/dts/Makefile +1 -0
index d36447d18d..7778f15091 100644
@@ -405,6 +405,7 @@ dtb-$(CONFIG_MACH_SUN50I) += \
 	sun50i-a64-orangepi-win.dtb \
 	sun50i-a64-pine64-plus.dtb \
 	sun50i-a64-pine64.dtb \
+	sun50i-a64-pinebook.dtb \
 	sun50i-a64-sopine-baseboard.dtb
 dtb-$(CONFIG_MACH_SUN9I) += \
 	sun9i-a80-optimus.dtb \
arch/arm/dts/sun50i-a64-pinebook-u-boot.dtsi new file +15 -0
new file mode 100644
index 0000000000..a99b7171d0
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 Vasily Khoruzhick <[email protected]>
+ *
+ */
+
+/* The ANX6345 eDP-bridge is on r_i2c */
+&r_i2c {
+	anx6345: edp-bridge at 38 {
+		compatible = "analogix,anx6345";
+		reg = <0x38>;
+		reset-gpios = <&pio 3 24 GPIO_ACTIVE_LOW>; /* PD24 */
+		status = "okay";
+	};
+};
arch/arm/dts/sun50i-a64-pinebook.dts new file +294 -0

294 lines not on this page · raw message

configs/pinebook_defconfig new file +22 -0
new file mode 100644
index 0000000000..5294dbd2eb
@@ -0,0 +1,22 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_SPL=y
+CONFIG_MACH_SUN50I=y
+CONFIG_SUNXI_DRAM_LPDDR3_STOCK=y
+CONFIG_DRAM_CLK=552
+CONFIG_DRAM_ZQ=3881949
+CONFIG_MMC_SUNXI_SLOT_EXTRA=2
+CONFIG_R_I2C_ENABLE=y
+# CONFIG_CMD_FLASH is not set
+# CONFIG_SPL_DOS_PARTITION is not set
+# CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pinebook"
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_DM_PWM=y
+CONFIG_PWM_SUNXI=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
+# CONFIG_USB_GADGET is not set
+CONFIG_VIDEO_BRIDGE=y
+CONFIG_VIDEO_BRIDGE_ANALOGIX_ANX6345=y
Signature · 1 line
2.19.1
#5 lore raw

v5 cover Add support for Pinebook

In reply to Vasily Khoruzhick
Quoted 22 lines · Vasily Khoruzhick

This series adds support for the Pinebook, an allwinner A64 laptop produced by Pine64. It also adds support for mmc delay calibration, R_I2C controller, and addresses the issue with activating video bridge when any of GPIOs is missing.

This series depends on André's "sunxi: A64/H3/H5 DT updates"

v2: - sync sun50i-a64.dtsi with linux instead of adding missing nodes
- take sun50i-a64-pinebook.dts from linux
- don't introduce new Kconfig for A64 MMC calibration
- improve code in video bridge uclass to check for presensce of GPIO instead of ingoring EINVAL errors
v3: - enable calibration for H6 as well
- init ret variable in video_bridge_set_active()
- fix order of dts files Makefile
- split anx6345 binding into sun50i-a64-pinebook-u-boot.dts
- drop speaker_amp node from pinebook dts
- drop unnecessary options from defconfig
v4: - sync device tree files with linux-next
v5: - drop patch to sync device tree files with linux-next

Quoted 6 lines

Vasily Khoruzhick (4):
mmc: sunxi: add support for automatic delay calibration
dm: video: bridge: don't fail to activate bridge if reset or sleep
GPIO is missing
sun50i: A64: add support for R_I2C controller
sunxi: DT: add support for Pinebook

Applied to u-boot-sunxi/master