Skip to contentSkip to conversation

[U-Boot] [PATCH 0/5]

PATCH New Vagrant Cascadian 5 participants 19 messages Sep 29, 2018 – Oct 1, 2018

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

cover [U-Boot] [PATCH 0/5]

This series adds support for the Pinebook, an allwinner A64 laptop produced by Pine64. It also adds support for mmc delay calibration, and the anx6345 video bridge, used on the Pinebook.

Vasily Khoruzhick (5):
mmc: sunxi: add support for automatic delay calibration
dm: video: bridge: don't fail to activate bridge if sleep gpio is
missing
video: anx6345: don't fail if there's no sleep or reset GPIOs
sun50i: a64: add support for R_I2C controller
sunxi: add support for Pinebook

 arch/arm/dts/Makefile                      |  3 +-
 arch/arm/dts/sun50i-a64-pinebook.dts       | 99 ++++++++++++++++++++++++++++++
 arch/arm/dts/sun50i-a64.dtsi               | 17 +++++
 arch/arm/include/asm/arch-sunxi/gpio.h     |  1 +
 arch/arm/include/asm/arch-sunxi/mmc.h      |  6 +-
 arch/arm/mach-sunxi/Kconfig                |  2 +
 board/sunxi/board.c                        |  6 ++
 configs/pinebook_defconfig                 | 32 ++++++++++
 drivers/mmc/Kconfig                        |  4 ++
 drivers/mmc/sunxi_mmc.c                    | 20 +++++-
 drivers/video/bridge/anx6345.c             |  2 +-
 drivers/video/bridge/video-bridge-uclass.c |  4 +-
 12 files changed, 190 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/dts/sun50i-a64-pinebook.dts
 create mode 100644 configs/pinebook_defconfig
Signature · 1 line
2.11.0
#1 lore raw

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

From: Vasily Khoruzhick <[email protected]>

A64 supports 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 +++++-
 arch/arm/mach-sunxi/Kconfig           |  1 +
 drivers/mmc/Kconfig                   |  4 ++++
 drivers/mmc/sunxi_mmc.c               | 20 +++++++++++++++++++-
 4 files changed, 29 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 */
arch/arm/mach-sunxi/Kconfig +1 -0
index 686f38fec4..ae77ee9e8e 100644
@@ -271,6 +271,7 @@ config MACH_SUN50I
 	bool "sun50i (Allwinner A64)"
 	select ARM64
 	select DM_I2C
+	select MMC_SUNXI_SUPPORTS_CALIBRATION
 	select PHY_SUN4I_USB
 	select SUNXI_DE2
 	select SUNXI_GEN_SUN6I
drivers/mmc/Kconfig +4 -0
index 0a0d4aaf6c..fb8f6697d4 100644
@@ -569,6 +569,10 @@ config MMC_SUNXI_HAS_NEW_MODE
 	bool
 	depends on MMC_SUNXI
 
+config MMC_SUNXI_SUPPORTS_CALIBRATION
+	bool
+	depends on MMC_SUNXI
+
 config GENERIC_ATMEL_MCI
 	bool "Atmel Multimedia Card Interface support"
 	depends on DM_MMC && BLK && ARCH_AT91
drivers/mmc/sunxi_mmc.c +19 -1
index 39f15eb423..7b064b482c 100644
@@ -99,11 +99,15 @@ 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 (IS_ENABLED(CONFIG_MMC_SUNXI_SUPPORTS_CALIBRATION))
+		calibrate = true;
+
 	/*
 	 * The MMC clock has an extra /2 post-divider when operating in the new
 	 * mode.
@@ -174,7 +178,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 +236,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);
 
+#ifdef CONFIG_MMC_SUNXI_SUPPORTS_CALIBRATION
+	/* 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.11.0
#2 lore raw

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

Quoted 4 lines · Vagrant Cascadian

From: Vasily Khoruzhick <[email protected]>

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

So technically that should be derived from the node's compatible string, like we do in Linux. But I see that we are not there yet in U-Boot. Meanwhile I don't think you should introduce a new Kconfig option, you could keep the hacky U-Boot style and just add an
#if defined(CONFIG_MACH_SUN50I) || defined(CONFIG_MACH_SUN50I_H6) to the two places instead.
A better way would be to introduce a "can_calibrate" member to struct sunxi_mmc_priv, then set this once in sunxi_mmc_init(), guarded by the two MACH symbols as above. This would allow an easy transition to being DT driven later and would prevent us from forgetting about this.

Cheers,
Andre.

Quoted 111 lines

---

 arch/arm/include/asm/arch-sunxi/mmc.h |  6 +++++-
 arch/arm/mach-sunxi/Kconfig           |  1 +
 drivers/mmc/Kconfig                   |  4 ++++
 drivers/mmc/sunxi_mmc.c               | 20 +++++++++++++++++++-
 4 files changed, 29 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 */
arch/arm/mach-sunxi/Kconfig +1 -0
index 686f38fec4..ae77ee9e8e 100644
@@ -271,6 +271,7 @@ config MACH_SUN50I
 	bool "sun50i (Allwinner A64)"
 	select ARM64
 	select DM_I2C
+	select MMC_SUNXI_SUPPORTS_CALIBRATION
 	select PHY_SUN4I_USB
 	select SUNXI_DE2
 	select SUNXI_GEN_SUN6I
drivers/mmc/Kconfig +4 -0
index 0a0d4aaf6c..fb8f6697d4 100644
@@ -569,6 +569,10 @@ config MMC_SUNXI_HAS_NEW_MODE
 	bool
 	depends on MMC_SUNXI
 
+config MMC_SUNXI_SUPPORTS_CALIBRATION
+	bool
+	depends on MMC_SUNXI
+
 config GENERIC_ATMEL_MCI
 	bool "Atmel Multimedia Card Interface support"
 	depends on DM_MMC && BLK && ARCH_AT91
drivers/mmc/sunxi_mmc.c +19 -1
index 39f15eb423..7b064b482c 100644
@@ -99,11 +99,15 @@ 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 (IS_ENABLED(CONFIG_MMC_SUNXI_SUPPORTS_CALIBRATION))
+		calibrate = true;
+
 	/*
 	 * The MMC clock has an extra /2 post-divider when operating in the new
 	 * mode.
@@ -174,7 +178,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 +236,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);
 
+#ifdef CONFIG_MMC_SUNXI_SUPPORTS_CALIBRATION
+	/* 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);
#3 lore raw

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

Quoted 6 lines · André Przywara
Quoted 4 lines · Vagrant Cascadian

From: Vasily Khoruzhick <[email protected]>

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

Quoted 6 lines

So technically that should be derived from the node's compatible string, like we do in Linux. But I see that we are not there yet in U-Boot. Meanwhile I don't think you should introduce a new Kconfig option, you could keep the hacky U-Boot style and just add an
#if defined(CONFIG_MACH_SUN50I) || defined(CONFIG_MACH_SUN50I_H6) to the two places instead.

IIRC, the calibration is only needed for the eMMC though, so we'd need to check that against the MMC number too.

Maxime

Signature · 10 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181001/790e1b7c/attachment.sig>
#4 lore raw

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

Quoted 15 lines · On Mon, 1 Oct 2018 10:09:55 +0200 Maxime Ripard <[email protected]>…
Quoted 7 lines · André Przywara
Quoted 5 lines · Vagrant Cascadian

From: Vasily Khoruzhick <[email protected]>

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

Quoted 6 lines

So technically that should be derived from the node's compatible string, like we do in Linux. But I see that we are not there yet in U-Boot. Meanwhile I don't think you should introduce a new Kconfig option, you could keep the hacky U-Boot style and just add an #if defined(CONFIG_MACH_SUN50I) || defined(CONFIG_MACH_SUN50I_H6) to the two places instead.

Quoted 2 lines

IIRC, the calibration is only needed for the eMMC though, so we'd need to check that against the MMC number too.

Is that so? I was looking at the Linux driver, and that one sets can_calibrate for both the "normal" and eMMC A64 compatible strings. Isn't the difference between the two the new timing mode, which the eMMC doesn't have? This looks to be covered in U-Boot, though in a similar hacky way.

Cheers,
Andre.

#5 lore raw

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

Quoted 18 lines · Andre Przywara
Quoted 15 lines · On Mon, 1 Oct 2018 10:09:55 +0200 Maxime Ripard <[email protected]>…
Quoted 13 lines · André Przywara
Quoted 5 lines · Vagrant Cascadian

From: Vasily Khoruzhick <[email protected]>

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

So technically that should be derived from the node's compatible string, like we do in Linux. But I see that we are not there yet in U-Boot. Meanwhile I don't think you should introduce a new Kconfig option, you could keep the hacky U-Boot style and just add an #if defined(CONFIG_MACH_SUN50I) || defined(CONFIG_MACH_SUN50I_H6) to the two places instead.

Quoted 8 lines
Quoted 2 lines

IIRC, the calibration is only needed for the eMMC though, so we'd need to check that against the MMC number too.

Is that so? I was looking at the Linux driver, and that one sets can_calibrate for both the "normal" and eMMC A64 compatible strings. Isn't the difference between the two the new timing mode, which the eMMC doesn't have? This looks to be covered in U-Boot, though in a similar hacky way.

You're right, sorry for the noise...

Maxime

Signature · 10 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181001/22d46f2a/attachment.sig>
#6 lore raw

PATCH 2/5 dm: video: bridge: don't fail to activate bridge if sleep gpio is missing

In reply to Vagrant Cascadian

From: Vasily Khoruzhick <[email protected]>

Sleep gpio is optional, so it's possible to have reset gpio, but no sleep gpio. We shouldn't fail early in case of missing sleep gpio, otherwise we won't deassert reset.

---

 drivers/video/bridge/video-bridge-uclass.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/bridge/video-bridge-uclass.c +2 -2
index cd4959cc71..46936a0626 100644
@@ -110,7 +110,7 @@ int video_bridge_set_active(struct udevice *dev, bool active)
 
 	debug("%s: %d\n", __func__, active);
 	ret = dm_gpio_set_value(&uc_priv->sleep, !active);
-	if (ret)
+	if (ret != -ENOENT)
 		return ret;
 	if (active) {
 		ret = dm_gpio_set_value(&uc_priv->reset, true);
@@ -120,7 +120,7 @@ int video_bridge_set_active(struct udevice *dev, bool active)
 		ret = dm_gpio_set_value(&uc_priv->reset, false);
 	}
 
-	return ret;
+	return 0;
 }
 
 UCLASS_DRIVER(video_bridge) = {
Signature · 1 line
2.11.0
#7 lore raw

PATCH 2/5 dm: video: bridge: don't fail to activate bridge if sleep gpio is missing

Hi Vagrant,

Quoted 19 lines · Vagrant Cascadian

From: Vasily Khoruzhick <[email protected]>

Sleep gpio is optional, so it's possible to have reset gpio, but no sleep gpio. We shouldn't fail early in case of missing sleep gpio, otherwise we won't deassert reset.

---

 drivers/video/bridge/video-bridge-uclass.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/bridge/video-bridge-uclass.c +0 -0
index cd4959cc71..46936a0626 100644

drivers/video/bridge/video-bridge-uclass.c int video_bridge_set_active(struct udevice *dev, bool active) · line 113

Quoted 5 lines
drivers/video/bridge/video-bridge-uclass.c +1 -1
@@ -110,7 +110,7 @@ int video_bridge_set_active(struct udevice *dev, bool active)
 
        debug("%s: %d\n", __func__, active);
        ret = dm_gpio_set_value(&uc_priv->sleep, !active);
-       if (ret)
+       if (ret != -ENOENT)

It should be 'if (ret && ret != -ENOENT)'. Btw, I fixed it in pinebook-wip-20180909 branch.

Quoted 15 lines
drivers/video/bridge/video-bridge-uclass.c +1 -2
                return ret;
        if (active) {
                ret = dm_gpio_set_value(&uc_priv->reset, true);
@@ -120,7 +120,7 @@ int video_bridge_set_active(struct udevice *dev, bool active)
                ret = dm_gpio_set_value(&uc_priv->reset, false);
        }
 
-       return ret;
+       return 0;
 }
 
 UCLASS_DRIVER(video_bridge) = {
--

2.11.0

#8 lore raw

PATCH 2/5 dm: video: bridge: don't fail to activate bridge if sleep gpio is missing

Quoted 4 lines · Vasily Khoruzhick
Quoted 3 lines · Vagrant Cascadian

Sleep gpio is optional, so it's possible to have reset gpio, but no sleep gpio. We shouldn't fail early in case of missing sleep gpio, otherwise we won't deassert reset.

...

Quoted 6 lines
Quoted 6 lines
drivers/video/bridge/video-bridge-uclass.c +0 -0
index cd4959cc71..46936a0626 100644
@@ -110,7 +110,7 @@ int video_bridge_set_active(struct udevice *dev, bool active)
 
Quoted 7 lines

drivers/video/bridge/video-bridge-uclass.c int video_bridge_set_active(struct udevice *dev, bool active) · line 113

Quoted 4 lines
drivers/video/bridge/video-bridge-uclass.c +1 -1
        debug("%s: %d\n", __func__, active);
        ret = dm_gpio_set_value(&uc_priv->sleep, !active);
-       if (ret)
+       if (ret != -ENOENT)

It should be 'if (ret && ret != -ENOENT)'. Btw, I fixed it in pinebook-wip-20180909 branch.

That's where I pulled the patch from; it's present in the patch to anx6345.c, but apparently unpatched in this patch against video-bridge-uclass.c.

I'll submit the fixed version in a new patch series after collecting more comments...

Thanks for all your work on it!

live well,
vagrant
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 227 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180930/a5659602/attachment.sig>

#9 lore raw

PATCH 2/5 dm: video: bridge: don't fail to activate bridge if sleep gpio is missing

Quoted 21 lines · Vagrant Cascadian
Quoted 4 lines · Vasily Khoruzhick
Quoted 3 lines · Vagrant Cascadian

Sleep gpio is optional, so it's possible to have reset gpio, but no sleep gpio. We shouldn't fail early in case of missing sleep gpio, otherwise we won't deassert reset.

...

Quoted 6 lines
Quoted 6 lines
drivers/video/bridge/video-bridge-uclass.c +0 -0
index cd4959cc71..46936a0626 100644
@@ -110,7 +110,7 @@ int video_bridge_set_active(struct udevice *dev, bool active)
 
Quoted 7 lines

drivers/video/bridge/video-bridge-uclass.c int video_bridge_set_active(struct udevice *dev, bool active) · line 113

Quoted 4 lines
drivers/video/bridge/video-bridge-uclass.c +1 -1
        debug("%s: %d\n", __func__, active);
        ret = dm_gpio_set_value(&uc_priv->sleep, !active);
-       if (ret)
+       if (ret != -ENOENT)

It should be 'if (ret && ret != -ENOENT)'. Btw, I fixed it in pinebook-wip-20180909 branch.

Quoted 3 lines

That's where I pulled the patch from; it's present in the patch to anx6345.c, but apparently unpatched in this patch against video-bridge-uclass.c.

You're right, I fixed it but forgot to push it. Sorry for the noise.

Quoted 4 lines

I'll submit the fixed version in a new patch series after collecting more comments...

Thanks for all your work on it!

Thanks a lot for submitting it!

Quoted 2 lines

live well,
vagrant

#10 lore raw

PATCH 2/5 dm: video: bridge: don't fail to activate bridge if sleep gpio is missing

In reply to Vagrant Cascadian
Quoted 18 lines · Vagrant Cascadian

From: Vasily Khoruzhick <[email protected]>

Sleep gpio is optional, so it's possible to have reset gpio, but no sleep gpio. We shouldn't fail early in case of missing sleep gpio, otherwise we won't deassert reset.

---

 drivers/video/bridge/video-bridge-uclass.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/bridge/video-bridge-uclass.c +0 -0
index cd4959cc71..46936a0626 100644

drivers/video/bridge/video-bridge-uclass.c int video_bridge_set_active(struct udevice *dev, bool active) · line 112

Quoted 3 lines
drivers/video/bridge/video-bridge-uclass.c +0 -0
@@ -110,7 +110,7 @@ int video_bridge_set_active(struct udevice *dev, bool active)
 
 	debug("%s: %d\n", __func__, active);
 	ret = dm_gpio_set_value(&uc_priv->sleep, !active);

So if I get this correctly, uc_priv->sleep.dev would be NULL if there was no GPIO specified? So wouldn't it be cleaner to say:

	if (uc_priv->sleep.dev) {
		ret = dm_gpio_set_value(&uc_priv->sleep, !active);
		...

drivers/video/bridge/video-bridge-uclass.c int video_bridge_set_active(struct udevice *dev, bool active) · line 123

Quoted 11 lines
drivers/video/bridge/video-bridge-uclass.c +2 -2
-	if (ret)
+	if (ret != -ENOENT)
 		return ret;
 	if (active) {
 		ret = dm_gpio_set_value(&uc_priv->reset, true);
@@ -120,7 +120,7 @@ int video_bridge_set_active(struct udevice *dev, bool active)
 		ret = dm_gpio_set_value(&uc_priv->reset, false);
 	}
 
-	return ret;
+	return 0;

This would loose the return value from the last statement in the if clause. So what about negating this clause:

	if (!active)
		return 0;

and change the rest accordingly?

Cheers,
Andre.

Quoted 4 lines
drivers/video/bridge/video-bridge-uclass.c +0 -0
 }
 
 UCLASS_DRIVER(video_bridge) = {
#11 lore raw

PATCH 3/5 video: anx6345: don't fail if there's no sleep or reset GPIOs

In reply to Vagrant Cascadian

From: Vasily Khoruzhick <[email protected]>

If there's no sleep or reset GPIOs, video_bridge_set_active() returns -ENOENT. Don't fail in this case, since these GPIOs are optional.

---

 drivers/video/bridge/anx6345.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/bridge/anx6345.c +1 -1
index 3e3f0e2ce6..28cf2a9c2d 100644
@@ -274,7 +274,7 @@ static int anx6345_enable(struct udevice *dev)
 
 	/* Deassert reset and enable power */
 	ret = video_bridge_set_active(dev, true);
-	if (ret)
+	if (ret && ret != -ENOENT)
 		return ret;
 
 	/* Reset */
Signature · 1 line
2.11.0
#12 lore raw

PATCH 3/5 video: anx6345: don't fail if there's no sleep or reset GPIOs

On 9/30/18 12:45 AM, Vagrant Cascadian wrote:

(CC:ing Anatolij)

Quoted 4 lines

From: Vasily Khoruzhick <[email protected]>

If there's no sleep or reset GPIOs, video_bridge_set_active() returns -ENOENT. Don't fail in this case, since these GPIOs are optional.

Are really *both* optional?
If yes, you should apply the same check I suggested in the last patch there as well, to also cover reset. Something like:

int video_bridge_set_active(struct udevice *dev, bool active)

{
	int ret = 0;

	/* The sleep GPIO is optional. */
	if (uc_priv->sleep.dev) {
		ret = dm_gpio_set_value(&uc_priv->sleep, !active);
		if (ret)
			return ret;
	}
	if (uc_priv->reset.dev && active) {
		ret = dm_gpio_set_value(&uc_priv->reset, true);
		...
	}

	return ret;
}

This avoids any attempts of cleverly ignoring errors, also allows you to get rid of this patch at all. Plus it's a more suitable approach for this generic driver file.

Cheers,
Andre.

Quoted 21 lines

---

 drivers/video/bridge/anx6345.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/bridge/anx6345.c +1 -1
index 3e3f0e2ce6..28cf2a9c2d 100644
@@ -274,7 +274,7 @@ static int anx6345_enable(struct udevice *dev)
 
 	/* Deassert reset and enable power */
 	ret = video_bridge_set_active(dev, true);
-	if (ret)
+	if (ret && ret != -ENOENT)
 		return ret;
 
 	/* Reset */
#13 lore raw

PATCH 4/5 sun50i: a64: add support for R_I2C controller

In reply to Vagrant Cascadian

From: Vasily Khoruzhick <[email protected]>

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/dts/sun50i-a64.dtsi           | 17 +++++++++++++++++
 arch/arm/include/asm/arch-sunxi/gpio.h |  1 +
 arch/arm/mach-sunxi/Kconfig            |  1 +
 board/sunxi/board.c                    |  6 ++++++
 4 files changed, 25 insertions(+)
arch/arm/dts/sun50i-a64.dtsi +17 -0
index 7a083637c4..80ddcf0af3 100644
@@ -627,6 +627,18 @@
 			};
 		};
 
+		r_i2c: i2c at 1f02400 {
+			compatible = "allwinner,sun50i-a64-i2c",
+				     "allwinner,sun6i-a31-i2c";
+			reg = <0x01f02400 0x400>;
+			interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&r_ccu 9>;
+			resets = <&r_ccu 5>;
+			status = "disabled";
+			#address-cells = <1>;
+			#size-cells = <0>;
+		};
+
 		gic: interrupt-controller at 1c81000 {
 			compatible = "arm,gic-400";
 			reg = <0x01c81000 0x1000>,
@@ -679,6 +691,11 @@
 				pins = "PL0", "PL1";
 				function = "s_rsb";
 			};
+
+			r_i2c_pins_a: i2c-a {
+				pins = "PL8", "PL9";
+				function = "s_i2c";
+			};
 		};
 
 		r_rsb: rsb at 1f03400 {
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 ae77ee9e8e..fccef9d706 100644
@@ -273,6 +273,7 @@ config MACH_SUN50I
 	select DM_I2C
 	select MMC_SUNXI_SUPPORTS_CALIBRATION
 	select PHY_SUN4I_USB
+	select SUN6I_PRCM
 	select SUNXI_DE2
 	select SUNXI_GEN_SUN6I
 	select SUPPORT_SPL
board/sunxi/board.c +6 -0
index d1d7f9f400..90f8bc0a6e 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.11.0
#14 lore raw

PATCH 4/5 sun50i: a64: add support for R_I2C controller

Hi,

Quoted 42 lines · Vagrant Cascadian

From: Vasily Khoruzhick <[email protected]>

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/dts/sun50i-a64.dtsi           | 17 +++++++++++++++++
 arch/arm/include/asm/arch-sunxi/gpio.h |  1 +
 arch/arm/mach-sunxi/Kconfig            |  1 +
 board/sunxi/board.c                    |  6 ++++++
 4 files changed, 25 insertions(+)
arch/arm/dts/sun50i-a64.dtsi +12 -0
index 7a083637c4..80ddcf0af3 100644
@@ -627,6 +627,18 @@
 			};
 		};
 
+		r_i2c: i2c at 1f02400 {
+			compatible = "allwinner,sun50i-a64-i2c",
+				     "allwinner,sun6i-a31-i2c";
+			reg = <0x01f02400 0x400>;
+			interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&r_ccu 9>;
+			resets = <&r_ccu 5>;
+			status = "disabled";
+			#address-cells = <1>;
+			#size-cells = <0>;
+		};
+
 		gic: interrupt-controller at 1c81000 {
 			compatible = "arm,gic-400";
 			reg = <0x01c81000 0x1000>,

arch/arm/dts/sun50i-a64.dtsi line 698

Quoted 8 lines
arch/arm/dts/sun50i-a64.dtsi +5 -0
@@ -679,6 +691,11 @@
 				pins = "PL0", "PL1";
 				function = "s_rsb";
 			};
+
+			r_i2c_pins_a: i2c-a {
+				pins = "PL8", "PL9";
+				function = "s_i2c";
+			};

These changes are in the Linux DT, so we'd be better off syncing that DT, instead of adding just those two nodes.

Thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181001/463c2079/attachment.sig>
#15 lore raw

PATCH 5/5 sunxi: add support for Pinebook

In reply to Vagrant Cascadian

From: Vasily Khoruzhick <[email protected]>

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                |  3 +-
 arch/arm/dts/sun50i-a64-pinebook.dts | 99 ++++++++++++++++++++++++++++++++++++
 configs/pinebook_defconfig           | 32 ++++++++++++
 3 files changed, 133 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/sun50i-a64-pinebook.dts
 create mode 100644 configs/pinebook_defconfig
arch/arm/dts/Makefile +2 -1
index 44ebc50bfa..1bb5d0d47e 100644
@@ -403,7 +403,8 @@ dtb-$(CONFIG_MACH_SUN50I) += \
 	sun50i-a64-orangepi-win.dtb \
 	sun50i-a64-pine64-plus.dtb \
 	sun50i-a64-pine64.dtb \
-	sun50i-a64-sopine-baseboard.dtb
+	sun50i-a64-sopine-baseboard.dtb \
+	sun50i-a64-pinebook.dtb
 dtb-$(CONFIG_MACH_SUN9I) += \
 	sun9i-a80-optimus.dtb \
 	sun9i-a80-cubieboard4.dtb \
arch/arm/dts/sun50i-a64-pinebook.dts new file +99 -0

99 lines not on this page · raw message

configs/pinebook_defconfig new file +32 -0
new file mode 100644
index 0000000000..15d0f50c41
@@ -0,0 +1,32 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_SPL=y
+CONFIG_MACH_SUN50I=y
+CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=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_SYS_MALLOC_CLEAR_ON_INIT is not set
+# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
+# CONFIG_SPL_LEGACY_IMAGE_SUPPORT is not set
+CONFIG_CMD_POWEROFF=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_I2C_SET_DEFAULT_BUS_NUM=y
+CONFIG_DM_I2C_GPIO=y
+# CONFIG_MMC_VERBOSE is not set
+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_USB_HOST_ETHER=y
+CONFIG_USB_ETHER_ASIX=y
+CONFIG_VIDEO_BRIDGE=y
+CONFIG_VIDEO_BRIDGE_ANALOGIX_ANX6345=y
Signature · 1 line
2.11.0
#16 lore raw

PATCH 5/5 sunxi: add support for Pinebook

Quoted 24 lines · Vagrant Cascadian

From: Vasily Khoruzhick <[email protected]>

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                |  3 +-
 arch/arm/dts/sun50i-a64-pinebook.dts | 99 ++++++++++++++++++++++++++++++++++++
 configs/pinebook_defconfig           | 32 ++++++++++++
 3 files changed, 133 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/sun50i-a64-pinebook.dts
 create mode 100644 configs/pinebook_defconfig
arch/arm/dts/Makefile +0 -0
index 44ebc50bfa..1bb5d0d47e 100644

arch/arm/dts/Makefile dtb-$(CONFIG_MACH_SUN50I) += \ · line 407

Quoted 6 lines
arch/arm/dts/Makefile +2 -1
@@ -403,7 +403,8 @@ dtb-$(CONFIG_MACH_SUN50I) += \
 	sun50i-a64-orangepi-win.dtb \
 	sun50i-a64-pine64-plus.dtb \
 	sun50i-a64-pine64.dtb \
-	sun50i-a64-sopine-baseboard.dtb
+	sun50i-a64-sopine-baseboard.dtb \
+	sun50i-a64-pinebook.dtb

You should keep them sorted alphabetically.

Quoted 98 lines
arch/arm/dts/Makefile +0 -0
 dtb-$(CONFIG_MACH_SUN9I) += \
 	sun9i-a80-optimus.dtb \
 	sun9i-a80-cubieboard4.dtb \
arch/arm/dts/sun50i-a64-pinebook.dts new file +89 -0
new file mode 100644
index 0000000000..48bee4cc7f
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2016 ARM Ltd.
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This library is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of the
+ *     License, or (at your option) any later version.
+ *
+ *     This library is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated documentation
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom the
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall be
+ *     included in all copies or substantial portions of the Software.
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include <dt-bindings/pwm/pwm.h>
+#include "sun50i-a64-pine64.dts"
+
+/ {
+	model = "Pinebook";
+	compatible = "pine64,pinebook", "allwinner,sun50i-a64";
+
+	aliases {
+		serial0 = &uart0;
+		i2c0 = "/i2c at 1f02400";
+	};
+
+	vdd_bl: regulator at 0 {
+		compatible = "regulator-fixed";
+		regulator-name = "bl-3v3";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		gpio = <&pio 7 6 GPIO_ACTIVE_HIGH>; /* PH6 */
+		enable-active-high;
+	};
+
+
+	backlight: backlight {
+		compatible = "pwm-backlight";
+		pwms = <&pwm 0 50000 0>;
+		brightness-levels = <0 10 20 30 40 50 60 70 100>;
+		default-brightness-level = <3>;
+		enable-gpios = <&pio 3 23 GPIO_ACTIVE_HIGH>; /* PD23 */
+		power-supply = <&vdd_bl>;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	memory {
+		reg = <0x40000000 0x40000000>;
+	};
+};
+
+&pwm {
+	status = "okay";
+};
+
+&r_i2c {

arch/arm/dts/sun50i-a64-pinebook.dts line 99

Quoted 10 lines
arch/arm/dts/sun50i-a64-pinebook.dts new file +10 -0
+	pinctrl-names = "default";
+	pinctrl-0 = <&r_i2c_pins_a>;
+	status = "okay";
+	anx6345: edp-bridge at 38 {
+		compatible = "analogix,anx6345";
+		reg = <0x38>;
+		reset-gpios = <&pio 3 24 GPIO_ACTIVE_LOW>; /* PD24 */
+		status = "okay";
+	};
+};

I'm not sure why that DT is that different from the one we have in Linux. Ideally, they should be identical.

Quoted 10 lines
configs/pinebook_defconfig new file +4 -0
new file mode 100644
index 0000000000..15d0f50c41
@@ -0,0 +1,32 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_SPL=y
+CONFIG_MACH_SUN50I=y

configs/pinebook_defconfig line 14

Quoted 10 lines
configs/pinebook_defconfig new file +10 -0
+CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=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_SYS_MALLOC_CLEAR_ON_INIT is not set
+# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
+# CONFIG_SPL_LEGACY_IMAGE_SUPPORT is not set
+CONFIG_CMD_POWEROFF=y

So the way we deal with defconfigs usually is that we don't really enable a command solely for one defconfig. Either we enable it for all the boards, or none.

configs/pinebook_defconfig line 20

Quoted 6 lines
configs/pinebook_defconfig new file +6 -0
+# 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_I2C_SET_DEFAULT_BUS_NUM=y
+CONFIG_DM_I2C_GPIO=y

Why are you using a bitbanged i2c bus? As far as I know, this is not enabled anywhere.

configs/pinebook_defconfig line 21

Quoted 1 line
configs/pinebook_defconfig new file +1 -0
+# CONFIG_MMC_VERBOSE is not set

This should go away

configs/pinebook_defconfig line 30

Quoted 9 lines
configs/pinebook_defconfig new file +9 -0
+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_USB_HOST_ETHER=y
+CONFIG_USB_ETHER_ASIX=y

Those last three too.

Thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181001/2b93cb9a/attachment.sig>
#17 lore raw

PATCH 5/5 sunxi: add support for Pinebook

于 2018年10月1日 GMT+08:00 下午4:17:24, Maxime Ripard <[email protected]> 写到:

Quoted 150 lines · Vagrant Cascadian
Quoted 6 lines

From: Vasily Khoruzhick <[email protected]>

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.

Quoted 8 lines

---

 arch/arm/dts/Makefile                |  3 +-
 arch/arm/dts/sun50i-a64-pinebook.dts | 99

++++++++++++++++++++++++++++++++++++

Quoted 10 lines
 configs/pinebook_defconfig           | 32 ++++++++++++
 3 files changed, 133 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/sun50i-a64-pinebook.dts
 create mode 100644 configs/pinebook_defconfig
arch/arm/dts/Makefile +0 -0
index 44ebc50bfa..1bb5d0d47e 100644

arch/arm/dts/Makefile dtb-$(CONFIG_MACH_SUN50I) += \ · line 407

Quoted 6 lines
arch/arm/dts/Makefile +2 -1
@@ -403,7 +403,8 @@ dtb-$(CONFIG_MACH_SUN50I) += \
 	sun50i-a64-orangepi-win.dtb \
 	sun50i-a64-pine64-plus.dtb \
 	sun50i-a64-pine64.dtb \
-	sun50i-a64-sopine-baseboard.dtb
+	sun50i-a64-sopine-baseboard.dtb \
+	sun50i-a64-pinebook.dtb

You should keep them sorted alphabetically.

Review

Quoted 4 lines
arch/arm/dts/Makefile +0 -0
 dtb-$(CONFIG_MACH_SUN9I) += \
 	sun9i-a80-optimus.dtb \
 	sun9i-a80-cubieboard4.dtb \
(quoted diff) +0 -0

b/arch/arm/dts/sun50i-a64-pinebook.dts

arch/arm/dts/sun50i-a64-pinebook.dts line 5

Quoted 10 lines

new file mode 100644
index 0000000000..48bee4cc7f

arch/arm/dts/sun50i-a64-pinebook.dts new file +5 -0
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2016 ARM Ltd.
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this

dual

arch/arm/dts/sun50i-a64-pinebook.dts

Quoted 5 lines
arch/arm/dts/sun50i-a64-pinebook.dts new file +5 -0
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This library is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License

as

arch/arm/dts/sun50i-a64-pinebook.dts line 11

Quoted 1 line
arch/arm/dts/sun50i-a64-pinebook.dts new file +1 -0
+ *     published by the Free Software Foundation; either version 2

of the

arch/arm/dts/sun50i-a64-pinebook.dts

Quoted 3 lines
arch/arm/dts/sun50i-a64-pinebook.dts new file +3 -0
+ *     License, or (at your option) any later version.
+ *
+ *     This library is distributed in the hope that it will be

useful,

arch/arm/dts/sun50i-a64-pinebook.dts line 15

Quoted 1 line
arch/arm/dts/sun50i-a64-pinebook.dts new file +1 -0
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty

of

arch/arm/dts/sun50i-a64-pinebook.dts

Quoted 7 lines
arch/arm/dts/sun50i-a64-pinebook.dts new file +7 -0
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated

documentation

arch/arm/dts/sun50i-a64-pinebook.dts

Quoted 4 lines
arch/arm/dts/sun50i-a64-pinebook.dts new file +4 -0
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom

the

arch/arm/dts/sun50i-a64-pinebook.dts

Quoted 4 lines
arch/arm/dts/sun50i-a64-pinebook.dts new file +4 -0
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall

be

arch/arm/dts/sun50i-a64-pinebook.dts line 31

Quoted 1 line
arch/arm/dts/sun50i-a64-pinebook.dts new file +1 -0
+ *     included in all copies or substantial portions of the

Software.

arch/arm/dts/sun50i-a64-pinebook.dts line 33

Quoted 2 lines
arch/arm/dts/sun50i-a64-pinebook.dts new file +2 -0
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY

KIND,

arch/arm/dts/sun50i-a64-pinebook.dts line 34

Quoted 1 line
arch/arm/dts/sun50i-a64-pinebook.dts new file +1 -0
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE

WARRANTIES

Quoted 60 lines
arch/arm/dts/sun50i-a64-pinebook.dts new file +60 -0
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include <dt-bindings/pwm/pwm.h>
+#include "sun50i-a64-pine64.dts"
+
+/ {
+	model = "Pinebook";
+	compatible = "pine64,pinebook", "allwinner,sun50i-a64";
+
+	aliases {
+		serial0 = &uart0;
+		i2c0 = "/i2c at 1f02400";
+	};
+
+	vdd_bl: regulator at 0 {
+		compatible = "regulator-fixed";
+		regulator-name = "bl-3v3";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		gpio = <&pio 7 6 GPIO_ACTIVE_HIGH>; /* PH6 */
+		enable-active-high;
+	};
+
+
+	backlight: backlight {
+		compatible = "pwm-backlight";
+		pwms = <&pwm 0 50000 0>;
+		brightness-levels = <0 10 20 30 40 50 60 70 100>;
+		default-brightness-level = <3>;
+		enable-gpios = <&pio 3 23 GPIO_ACTIVE_HIGH>; /* PD23 */
+		power-supply = <&vdd_bl>;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	memory {
+		reg = <0x40000000 0x40000000>;
+	};
+};
+
+&pwm {
+	status = "okay";
+};
+
+&r_i2c {
+	pinctrl-names = "default";
+	pinctrl-0 = <&r_i2c_pins_a>;
+	status = "okay";
+	anx6345: edp-bridge at 38 {
+		compatible = "analogix,anx6345";
Quoted 8 lines

arch/arm/dts/sun50i-a64-pinebook.dts line 99

Quoted 5 lines
arch/arm/dts/sun50i-a64-pinebook.dts new file +5 -0
+		reg = <0x38>;
+		reset-gpios = <&pio 3 24 GPIO_ACTIVE_LOW>; /* PD24 */
+		status = "okay";
+	};
+};

I'm not sure why that DT is that different from the one we have in Linux. Ideally, they should be identical.

Linux one has no ANX6345 yet, so they're not identical.

Quoted 54 lines
Quoted 11 lines
configs/pinebook_defconfig new file +4 -0
new file mode 100644
index 0000000000..15d0f50c41
@@ -0,0 +1,32 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_SPL=y
+CONFIG_MACH_SUN50I=y

configs/pinebook_defconfig line 14

Quoted 10 lines
configs/pinebook_defconfig new file +10 -0
+CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=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_SYS_MALLOC_CLEAR_ON_INIT is not set
+# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
+# CONFIG_SPL_LEGACY_IMAGE_SUPPORT is not set
+CONFIG_CMD_POWEROFF=y

So the way we deal with defconfigs usually is that we don't really enable a command solely for one defconfig. Either we enable it for all the boards, or none.

configs/pinebook_defconfig line 20

Quoted 6 lines
configs/pinebook_defconfig new file +6 -0
+# 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_I2C_SET_DEFAULT_BUS_NUM=y
+CONFIG_DM_I2C_GPIO=y

Why are you using a bitbanged i2c bus? As far as I know, this is not enabled anywhere.

configs/pinebook_defconfig line 21

Quoted 1 line
configs/pinebook_defconfig new file +1 -0
+# CONFIG_MMC_VERBOSE is not set

This should go away

configs/pinebook_defconfig line 30

Quoted 9 lines
configs/pinebook_defconfig new file +9 -0
+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_USB_HOST_ETHER=y
+CONFIG_USB_ETHER_ASIX=y

Those last three too.

Thanks!
Maxime

#18 lore raw

PATCH 5/5 sunxi: add support for Pinebook

Quoted 124 lines · Icenowy Zheng
Quoted 115 lines

Review

Quoted 4 lines

dtb-$(CONFIG_MACH_SUN9I) += \

arch/arm/dts/Makefile +0 -0
 	sun9i-a80-optimus.dtb \
 	sun9i-a80-cubieboard4.dtb \
(quoted diff) +0 -0

b/arch/arm/dts/sun50i-a64-pinebook.dts

arch/arm/dts/sun50i-a64-pinebook.dts line 5

Quoted 10 lines

new file mode 100644
index 0000000000..48bee4cc7f

arch/arm/dts/sun50i-a64-pinebook.dts new file +5 -0
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2016 ARM Ltd.
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this

dual

arch/arm/dts/sun50i-a64-pinebook.dts

Quoted 5 lines
arch/arm/dts/sun50i-a64-pinebook.dts new file +5 -0
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This library is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License

as

arch/arm/dts/sun50i-a64-pinebook.dts line 11

Quoted 1 line
arch/arm/dts/sun50i-a64-pinebook.dts new file +1 -0
+ *     published by the Free Software Foundation; either version 2

of the

arch/arm/dts/sun50i-a64-pinebook.dts

Quoted 3 lines
arch/arm/dts/sun50i-a64-pinebook.dts new file +3 -0
+ *     License, or (at your option) any later version.
+ *
+ *     This library is distributed in the hope that it will be

useful,

arch/arm/dts/sun50i-a64-pinebook.dts line 15

Quoted 1 line
arch/arm/dts/sun50i-a64-pinebook.dts new file +1 -0
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty

of

arch/arm/dts/sun50i-a64-pinebook.dts

Quoted 7 lines
arch/arm/dts/sun50i-a64-pinebook.dts new file +7 -0
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated

documentation

arch/arm/dts/sun50i-a64-pinebook.dts

Quoted 4 lines
arch/arm/dts/sun50i-a64-pinebook.dts new file +4 -0
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom

the

arch/arm/dts/sun50i-a64-pinebook.dts

Quoted 4 lines
arch/arm/dts/sun50i-a64-pinebook.dts new file +4 -0
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall

be

arch/arm/dts/sun50i-a64-pinebook.dts line 31

Quoted 1 line
arch/arm/dts/sun50i-a64-pinebook.dts new file +1 -0
+ *     included in all copies or substantial portions of the

Software.

arch/arm/dts/sun50i-a64-pinebook.dts line 33

Quoted 2 lines
arch/arm/dts/sun50i-a64-pinebook.dts new file +2 -0
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY

KIND,

arch/arm/dts/sun50i-a64-pinebook.dts line 34

Quoted 1 line
arch/arm/dts/sun50i-a64-pinebook.dts new file +1 -0
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE

WARRANTIES

Quoted 60 lines
arch/arm/dts/sun50i-a64-pinebook.dts new file +60 -0
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include <dt-bindings/pwm/pwm.h>
+#include "sun50i-a64-pine64.dts"
+
+/ {
+	model = "Pinebook";
+	compatible = "pine64,pinebook", "allwinner,sun50i-a64";
+
+	aliases {
+		serial0 = &uart0;
+		i2c0 = "/i2c at 1f02400";
+	};
+
+	vdd_bl: regulator at 0 {
+		compatible = "regulator-fixed";
+		regulator-name = "bl-3v3";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		gpio = <&pio 7 6 GPIO_ACTIVE_HIGH>; /* PH6 */
+		enable-active-high;
+	};
+
+
+	backlight: backlight {
+		compatible = "pwm-backlight";
+		pwms = <&pwm 0 50000 0>;
+		brightness-levels = <0 10 20 30 40 50 60 70 100>;
+		default-brightness-level = <3>;
+		enable-gpios = <&pio 3 23 GPIO_ACTIVE_HIGH>; /* PD23 */
+		power-supply = <&vdd_bl>;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	memory {
+		reg = <0x40000000 0x40000000>;
+	};
+};
+
+&pwm {
+	status = "okay";
+};
+
+&r_i2c {
+	pinctrl-names = "default";
+	pinctrl-0 = <&r_i2c_pins_a>;
+	status = "okay";
+	anx6345: edp-bridge at 38 {
+		compatible = "analogix,anx6345";
Quoted 8 lines

arch/arm/dts/sun50i-a64-pinebook.dts line 99

Quoted 5 lines
arch/arm/dts/sun50i-a64-pinebook.dts new file +5 -0
+		reg = <0x38>;
+		reset-gpios = <&pio 3 24 GPIO_ACTIVE_LOW>; /* PD24 */
+		status = "okay";
+	};
+};

I'm not sure why that DT is that different from the one we have in Linux. Ideally, they should be identical.

Quoted 1 line

Linux one has no ANX6345 yet, so they're not identical.

Right, but it's far from being the only difference.

Maxime

Signature · 10 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181001/a6a3b6e2/attachment.sig>