Skip to contentSkip to conversation

sunxi: video: Add support for HDMI output on A64/H3/H5

PATCH Superseded Jernej Skrabec 2 participants 17 messages Mar 27, 2017 – Apr 28, 2017

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

v3 cover sunxi: video: Add support for HDMI output on A64/H3/H5

This series implements support for HDMI output. This is done using DM video framework and sharing the HDMI controller code with RK3288.

Patch 1 splits out TCON code which is completely reusable on all Allwinner SoCs.

Patch 2 converts common TCON code to use DM video compatible timing structure.

Patch 3 adds all necessary clocks which are needed for Display Engine 2, TCON and HDMI.

Patch 4 implement actual DE2 and HDMI driver and patch 5 disables HDMI on all boards which don't have it (default is on).

Patch 6 is included here only for testing HDMI output on A64 due to missing power regulator support (AXP803). Another option is to use ATF which powers on HDMI. Such ATF can be found on Andre Przywara's github.

Code was tested on OrangePi 2 & OrangePi Plus 2E (both H3), OrangePi PC 2 (H5) and Pine64 (A64). It was tested on A10, A13 and A20 boards by others.

This series was developed on u-boot-sunxi repository with additional, not yet merged, patch: https://patchwork.ozlabs.org/patch/735617/

All Rockchip patches were already merged to u-boot-rockchip repository and are not yet present in u-boot-sunxi. They have to be cherry picked:
a0a2774aebdaa039ce787090c903cf47263f04c9 520c174b3564ae183f0e7c118dc8ce3770ae20b0 3bffe88d68e43b7bead12ef8020267fabc6c7ebf

Best regards,
Jernej Skrabec

Changes in v3:
- drop patch 1 because it was merged
- changed video output to 32 bpp
- collect acked by tags
- convert preprocessor symbol to Kconfig option (patch 3)
- Kconfig option in patch 4 depends on new option

Changes in v2:
- patch 1 & 2 were removed because they were merged
- collect reviewed by and tested by tags
- TCON split out patch is splitted in two patches
- fixed lcdc_enable() calls in video driver for old SoCs
- defconfigs should disable video driver, not enable it
- minor constant style fix

Icenowy Zheng (1):
[DO NOT MERGE] sunxi: add AXP803 support

Jernej Skrabec (5):
sunxi: video: Split out TCON code
sunxi: video: Convert lcdc to use struct display_timing
sunxi: Add clock support for DE2/HDMI/TCON on newer SoCs
sunxi: video: Add A64/H3/H5 HDMI driver
sunxi: Disable DE2 video driver where not needed

 arch/arm/include/asm/arch-sunxi/clock_sun6i.h |  54 ++++
 arch/arm/include/asm/arch-sunxi/cpu_sun4i.h   |   8 +
 arch/arm/include/asm/arch-sunxi/display.h     | 103 -------
 arch/arm/include/asm/arch-sunxi/display2.h    | 124 ++++++++
 arch/arm/include/asm/arch-sunxi/lcdc.h        | 128 +++++++++
 arch/arm/mach-sunxi/Makefile                  |   3 +
 arch/arm/mach-sunxi/clock_sun6i.c             |  40 ++-
 arch/arm/mach-sunxi/pmic_bus.c                |   6 +-
 arch/arm/mach-sunxi/rsb.c                     |   2 +-
 board/sunxi/Kconfig                           |  16 ++
 board/sunxi/board.c                           |  31 +-
 configs/nanopi_neo_air_defconfig              |   1 +
 configs/nanopi_neo_defconfig                  |   1 +
 configs/orangepi_zero_defconfig               |   1 +
 drivers/power/Kconfig                         |  87 +++---
 drivers/power/Makefile                        |   1 +
 drivers/power/axp803.c                        | 256 +++++++++++++++++
 drivers/power/axp818.c                        |   2 +-
 drivers/video/Makefile                        |   2 +-
 drivers/video/sunxi/Makefile                  |   9 +
 drivers/video/sunxi/lcdc.c                    | 209 ++++++++++++++
 drivers/video/sunxi/sunxi_de2.c               | 258 +++++++++++++++++
 drivers/video/{ => sunxi}/sunxi_display.c     | 220 +++------------
 drivers/video/sunxi/sunxi_dw_hdmi.c           | 389 ++++++++++++++++++++++++++
 include/axp803.h                              |  73 +++++
 include/axp_pmic.h                            |   3 +
 include/configs/sunxi-common.h                |   5 +
 27 files changed, 1701 insertions(+), 331 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-sunxi/display2.h
 create mode 100644 arch/arm/include/asm/arch-sunxi/lcdc.h
 create mode 100644 drivers/power/axp803.c
 create mode 100644 drivers/video/sunxi/Makefile
 create mode 100644 drivers/video/sunxi/lcdc.c
 create mode 100644 drivers/video/sunxi/sunxi_de2.c
 rename drivers/video/{ => sunxi}/sunxi_display.c (87%)
 create mode 100644 drivers/video/sunxi/sunxi_dw_hdmi.c
 create mode 100644 include/axp803.h
Signature · 1 line
2.12.1
#1 lore raw

PATCH v3 1/6 sunxi: video: Split out TCON code

TCON unit has similar layout and functionality also on newer SoCs. This commit splits out TCON code for easier reuse later.

---
Changes in v3:
- add acked by tag

Changes in v2:
- lcdc conversion to use struct display_timing is done in a new patch
- fix issue with lcdc_enable() calls

 arch/arm/include/asm/arch-sunxi/display.h | 103 ---------------
 arch/arm/include/asm/arch-sunxi/lcdc.h    | 128 ++++++++++++++++++
 drivers/video/Makefile                    |   2 +-
 drivers/video/sunxi/Makefile              |   8 ++
 drivers/video/sunxi/lcdc.c                | 207 ++++++++++++++++++++++++++++++
 drivers/video/{ => sunxi}/sunxi_display.c | 199 +++-------------------------
 6 files changed, 362 insertions(+), 285 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-sunxi/lcdc.h
 create mode 100644 drivers/video/sunxi/Makefile
 create mode 100644 drivers/video/sunxi/lcdc.c
 rename drivers/video/{ => sunxi}/sunxi_display.c (86%)
arch/arm/include/asm/arch-sunxi/display.h +0 -103
index b64f310b8b..93803addfb 100644
@@ -157,52 +157,6 @@ struct sunxi_de_be_reg {
 	u32 output_color_coef[12];	/* 0x9d0 */
 };
 
-struct sunxi_lcdc_reg {
-	u32 ctrl;			/* 0x00 */
-	u32 int0;			/* 0x04 */
-	u32 int1;			/* 0x08 */
-	u8 res0[0x04];			/* 0x0c */
-	u32 tcon0_frm_ctrl;		/* 0x10 */
-	u32 tcon0_frm_seed[6];		/* 0x14 */
-	u32 tcon0_frm_table[4];		/* 0x2c */
-	u8 res1[4];			/* 0x3c */
-	u32 tcon0_ctrl;			/* 0x40 */
-	u32 tcon0_dclk;			/* 0x44 */
-	u32 tcon0_timing_active;	/* 0x48 */
-	u32 tcon0_timing_h;		/* 0x4c */
-	u32 tcon0_timing_v;		/* 0x50 */
-	u32 tcon0_timing_sync;		/* 0x54 */
-	u32 tcon0_hv_intf;		/* 0x58 */
-	u8 res2[0x04];			/* 0x5c */
-	u32 tcon0_cpu_intf;		/* 0x60 */
-	u32 tcon0_cpu_wr_dat;		/* 0x64 */
-	u32 tcon0_cpu_rd_dat0;		/* 0x68 */
-	u32 tcon0_cpu_rd_dat1;		/* 0x6c */
-	u32 tcon0_ttl_timing0;		/* 0x70 */
-	u32 tcon0_ttl_timing1;		/* 0x74 */
-	u32 tcon0_ttl_timing2;		/* 0x78 */
-	u32 tcon0_ttl_timing3;		/* 0x7c */
-	u32 tcon0_ttl_timing4;		/* 0x80 */
-	u32 tcon0_lvds_intf;		/* 0x84 */
-	u32 tcon0_io_polarity;		/* 0x88 */
-	u32 tcon0_io_tristate;		/* 0x8c */
-	u32 tcon1_ctrl;			/* 0x90 */
-	u32 tcon1_timing_source;	/* 0x94 */
-	u32 tcon1_timing_scale;		/* 0x98 */
-	u32 tcon1_timing_out;		/* 0x9c */
-	u32 tcon1_timing_h;		/* 0xa0 */
-	u32 tcon1_timing_v;		/* 0xa4 */
-	u32 tcon1_timing_sync;		/* 0xa8 */
-	u8 res3[0x44];			/* 0xac */
-	u32 tcon1_io_polarity;		/* 0xf0 */
-	u32 tcon1_io_tristate;		/* 0xf4 */
-	u8 res4[0x108];			/* 0xf8 */
-	u32 mux_ctrl;			/* 0x200 */
-	u8 res5[0x1c];			/* 0x204 */
-	u32 lvds_ana0;			/* 0x220 */
-	u32 lvds_ana1;			/* 0x224 */
-};
-
 struct sunxi_hdmi_reg {
 	u32 version_id;			/* 0x000 */
 	u32 ctrl;			/* 0x004 */
@@ -347,63 +301,6 @@ struct sunxi_tve_reg {
 #define SUNXI_DE_BE_OUTPUT_COLOR_CTRL_ENABLE	1
 
 /*
- * LCDC register constants.
- */
-#define SUNXI_LCDC_X(x)				(((x) - 1) << 16)
-#define SUNXI_LCDC_Y(y)				(((y) - 1) << 0)
-#define SUNXI_LCDC_TCON_VSYNC_MASK		(1 << 24)
-#define SUNXI_LCDC_TCON_HSYNC_MASK		(1 << 25)
-#define SUNXI_LCDC_CTRL_IO_MAP_MASK		(1 << 0)
-#define SUNXI_LCDC_CTRL_IO_MAP_TCON0		(0 << 0)
-#define SUNXI_LCDC_CTRL_IO_MAP_TCON1		(1 << 0)
-#define SUNXI_LCDC_CTRL_TCON_ENABLE		(1 << 31)
-#define SUNXI_LCDC_TCON0_FRM_CTRL_RGB666	((1 << 31) | (0 << 4))
-#define SUNXI_LCDC_TCON0_FRM_CTRL_RGB565	((1 << 31) | (5 << 4))
-#define SUNXI_LCDC_TCON0_FRM_SEED		0x11111111
-#define SUNXI_LCDC_TCON0_FRM_TAB0		0x01010000
-#define SUNXI_LCDC_TCON0_FRM_TAB1		0x15151111
-#define SUNXI_LCDC_TCON0_FRM_TAB2		0x57575555
-#define SUNXI_LCDC_TCON0_FRM_TAB3		0x7f7f7777
-#define SUNXI_LCDC_TCON0_CTRL_CLK_DELAY(n)	(((n) & 0x1f) << 4)
-#define SUNXI_LCDC_TCON0_CTRL_ENABLE		(1 << 31)
-#define SUNXI_LCDC_TCON0_DCLK_DIV(n)		((n) << 0)
-#define SUNXI_LCDC_TCON0_DCLK_ENABLE		(0xf << 28)
-#define SUNXI_LCDC_TCON0_TIMING_H_BP(n)		(((n) - 1) << 0)
-#define SUNXI_LCDC_TCON0_TIMING_H_TOTAL(n)	(((n) - 1) << 16)
-#define SUNXI_LCDC_TCON0_TIMING_V_BP(n)		(((n) - 1) << 0)
-#define SUNXI_LCDC_TCON0_TIMING_V_TOTAL(n)	(((n) * 2) << 16)
-#ifdef CONFIG_SUNXI_GEN_SUN6I
-#define SUNXI_LCDC_TCON0_LVDS_CLK_SEL_TCON0	(1 << 20)
-#else
-#define SUNXI_LCDC_TCON0_LVDS_CLK_SEL_TCON0	0 /* NA */
-#endif
-#define SUNXI_LCDC_TCON0_LVDS_INTF_BITWIDTH(n)	((n) << 26)
-#define SUNXI_LCDC_TCON0_LVDS_INTF_ENABLE	(1 << 31)
-#define SUNXI_LCDC_TCON0_IO_POL_DCLK_PHASE(x)	((x) << 28)
-#define SUNXI_LCDC_TCON1_CTRL_CLK_DELAY(n)	(((n) & 0x1f) << 4)
-#define SUNXI_LCDC_TCON1_CTRL_INTERLACE_ENABLE	(1 << 20)
-#define SUNXI_LCDC_TCON1_CTRL_ENABLE		(1 << 31)
-#define SUNXI_LCDC_TCON1_TIMING_H_BP(n)		(((n) - 1) << 0)
-#define SUNXI_LCDC_TCON1_TIMING_H_TOTAL(n)	(((n) - 1) << 16)
-#define SUNXI_LCDC_TCON1_TIMING_V_BP(n)		(((n) - 1) << 0)
-#define SUNXI_LCDC_TCON1_TIMING_V_TOTAL(n)	((n) << 16)
-#define SUNXI_LCDC_MUX_CTRL_SRC0_MASK		(0xf << 0)
-#define SUNXI_LCDC_MUX_CTRL_SRC0(x)		((x) << 0)
-#define SUNXI_LCDC_MUX_CTRL_SRC1_MASK		(0xf << 4)
-#define SUNXI_LCDC_MUX_CTRL_SRC1(x)		((x) << 4)
-#ifdef CONFIG_SUNXI_GEN_SUN6I
-#define SUNXI_LCDC_LVDS_ANA0			0x40040320
-#define SUNXI_LCDC_LVDS_ANA0_EN_MB		(1 << 31)
-#define SUNXI_LCDC_LVDS_ANA0_DRVC		(1 << 24)
-#define SUNXI_LCDC_LVDS_ANA0_DRVD(x)		((x) << 20)
-#else
-#define SUNXI_LCDC_LVDS_ANA0			0x3f310000
-#define SUNXI_LCDC_LVDS_ANA0_UPDATE		(1 << 22)
-#endif
-#define SUNXI_LCDC_LVDS_ANA1_INIT1		(0x1f << 26 | 0x1f << 10)
-#define SUNXI_LCDC_LVDS_ANA1_INIT2		(0x1f << 16 | 0x1f << 00)
-
-/*
  * HDMI register constants.
  */
 #define SUNXI_HDMI_X(x)				(((x) - 1) << 0)
arch/arm/include/asm/arch-sunxi/lcdc.h new file +128 -0

128 lines not on this page · raw message

drivers/video/Makefile +1 -1
index db34904a9a..7230fd9570 100644
@@ -51,7 +51,6 @@ obj-$(CONFIG_VIDEO_MXS) += mxsfb.o videomodes.o
 obj-$(CONFIG_VIDEO_OMAP3) += omap3_dss.o
 obj-$(CONFIG_VIDEO_SANDBOX_SDL) += sandbox_sdl.o
 obj-$(CONFIG_VIDEO_SM501) += sm501.o
-obj-$(CONFIG_VIDEO_SUNXI) += sunxi_display.o videomodes.o
 obj-$(CONFIG_VIDEO_TEGRA20) += tegra.o
 obj-$(CONFIG_VIDEO_VCXK) += bus_vcxk.o
 obj-$(CONFIG_VIDEO_VESA) += vesa.o
@@ -64,3 +63,4 @@ obj-${CONFIG_EXYNOS_FB} += exynos/
 obj-${CONFIG_VIDEO_ROCKCHIP} += rockchip/
 
 obj-y += bridge/
+obj-y += sunxi/
drivers/video/sunxi/Makefile new file +8 -0
new file mode 100644
index 0000000000..dfc9b47a1f
@@ -0,0 +1,8 @@
+#
+# (C) Copyright 2000-2007
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-$(CONFIG_VIDEO_SUNXI) += sunxi_display.o lcdc.o ../videomodes.o
drivers/video/sunxi/lcdc.c new file +207 -0

207 lines not on this page · raw message

drivers/video/sunxi/sunxi_display.c renamed from drivers/video/sunxi_display.c +18 -181

282 lines not on this page · raw message

Signature · 1 line
2.12.1
#2 lore raw

PATCH v3 2/6 sunxi: video: Convert lcdc to use struct display_timing

In reply to Jernej Skrabec

Video driver for older Allwinner SoCs uses cfb console framework which in turn uses struct ctfb_res_modes to hold timing informations. However, DM video framework uses different structure - struct display_timing.

It makes more sense to convert lcdc to use new timing structure because all new drivers should use DM video framework and older drivers might be rewritten to use new framework too.

---
Changes in v3:
- add acked by tag

Changes in v2:
- new patch

 arch/arm/include/asm/arch-sunxi/lcdc.h |  6 ++--
 drivers/video/sunxi/lcdc.c             | 64 ++++++++++++++++------------------
 drivers/video/sunxi/sunxi_display.c    | 35 +++++++++++++++++--
 3 files changed, 67 insertions(+), 38 deletions(-)
arch/arm/include/asm/arch-sunxi/lcdc.h +3 -3
index e4c8c160ed..a751698b4f 100644
@@ -10,7 +10,7 @@
 #ifndef _LCDC_H
 #define _LCDC_H
 
-struct ctfb_res_modes;
+#include <fdtdec.h>
 
 struct sunxi_lcdc_reg {
 	u32 ctrl;			/* 0x00 */
@@ -118,11 +118,11 @@ struct sunxi_lcdc_reg {
 void lcdc_init(struct sunxi_lcdc_reg * const lcdc);
 void lcdc_enable(struct sunxi_lcdc_reg * const lcdc, int depth);
 void lcdc_tcon0_mode_set(struct sunxi_lcdc_reg * const lcdc,
-			 const struct ctfb_res_modes *mode,
+			 const struct display_timing *mode,
 			 int clk_div, bool for_ext_vga_dac,
 			 int depth, int dclk_phase);
 void lcdc_tcon1_mode_set(struct sunxi_lcdc_reg * const lcdc,
-			 const struct ctfb_res_modes *mode,
+			 const struct display_timing *mode,
 			 bool ext_hvsync, bool is_composite);
 
 #endif /* _LCDC_H */
drivers/video/sunxi/lcdc.c +31 -33

131 lines not on this page · raw message

drivers/video/sunxi/sunxi_display.c +33 -2
index 48192ef87e..92c9d06054 100644
@@ -721,12 +721,40 @@ static void sunxi_lcdc_backlight_enable(void)
 		gpio_direction_output(pin, PWM_ON);
 }
 
+static void sunxi_ctfb_mode_to_display_timing(const struct ctfb_res_modes *mode,
+					      struct display_timing *timing)
+{
+	timing->pixelclock.typ = mode->pixclock_khz * 1000;
+
+	timing->hactive.typ = mode->xres;
+	timing->hfront_porch.typ = mode->right_margin;
+	timing->hback_porch.typ = mode->left_margin;
+	timing->hsync_len.typ = mode->hsync_len;
+
+	timing->vactive.typ = mode->yres;
+	timing->vfront_porch.typ = mode->lower_margin;
+	timing->vback_porch.typ = mode->upper_margin;
+	timing->vsync_len.typ = mode->vsync_len;
+
+	if (mode->sync & FB_SYNC_HOR_HIGH_ACT)
+		timing->flags |= DISPLAY_FLAGS_HSYNC_HIGH;
+	else
+		timing->flags |= DISPLAY_FLAGS_HSYNC_LOW;
+	if (mode->sync & FB_SYNC_VERT_HIGH_ACT)
+		timing->flags |= DISPLAY_FLAGS_VSYNC_HIGH;
+	else
+		timing->flags |= DISPLAY_FLAGS_VSYNC_LOW;
+	if (mode->vmode == FB_VMODE_INTERLACED)
+		timing->flags |= DISPLAY_FLAGS_INTERLACED;
+}
+
 static void sunxi_lcdc_tcon0_mode_set(const struct ctfb_res_modes *mode,
 				      bool for_ext_vga_dac)
 {
 	struct sunxi_lcdc_reg * const lcdc =
 		(struct sunxi_lcdc_reg *)SUNXI_LCD0_BASE;
 	int clk_div, clk_double, pin;
+	struct display_timing timing;
 
 #if defined CONFIG_MACH_SUN8I && defined CONFIG_VIDEO_LCD_IF_LVDS
 	for (pin = SUNXI_GPD(18); pin <= SUNXI_GPD(27); pin++) {
@@ -746,7 +774,8 @@ static void sunxi_lcdc_tcon0_mode_set(const struct ctfb_res_modes *mode,
 
 	sunxi_lcdc_pll_set(0, mode->pixclock_khz, &clk_div, &clk_double);
 
-	lcdc_tcon0_mode_set(lcdc, mode, clk_div, for_ext_vga_dac,
+	sunxi_ctfb_mode_to_display_timing(mode, &timing);
+	lcdc_tcon0_mode_set(lcdc, &timing, clk_div, for_ext_vga_dac,
 			    sunxi_display.depth, CONFIG_VIDEO_LCD_DCLK_PHASE);
 }
 
@@ -757,8 +786,10 @@ static void sunxi_lcdc_tcon1_mode_set(const struct ctfb_res_modes *mode,
 {
 	struct sunxi_lcdc_reg * const lcdc =
 		(struct sunxi_lcdc_reg *)SUNXI_LCD0_BASE;
+	struct display_timing timing;
 
-	lcdc_tcon1_mode_set(lcdc, mode, use_portd_hvsync,
+	sunxi_ctfb_mode_to_display_timing(mode, &timing);
+	lcdc_tcon1_mode_set(lcdc, &timing, use_portd_hvsync,
 			    sunxi_is_composite());
 
 	if (use_portd_hvsync) {
Signature · 1 line
2.12.1
#3 lore raw

PATCH v3 3/6 sunxi: Add clock support for DE2/HDMI/TCON on newer SoCs

In reply to Jernej Skrabec

This is needed for HDMI, which will be added later.

---
Changes in v3:
- convert define to Kconfig option

Changes in v2:
- add reviewed by tag
- constant style fix

 arch/arm/include/asm/arch-sunxi/clock_sun6i.h | 54 +++++++++++++++++++++++++++
 arch/arm/mach-sunxi/clock_sun6i.c             | 40 +++++++++++++++++++-
 board/sunxi/Kconfig                           |  6 +++
 drivers/video/sunxi/lcdc.c                    |  4 ++
 4 files changed, 103 insertions(+), 1 deletion(-)
arch/arm/include/asm/arch-sunxi/clock_sun6i.h +54 -0
index 1aefd5a64c..a44ea77576 100644
@@ -67,13 +67,22 @@ struct sunxi_ccm_reg {
 	u32 dram_pll_cfg;	/* 0xf8 PLL_DDR cfg register, A33 only */
 	u32 mbus_reset;		/* 0xfc MBUS reset control, A33 only */
 	u32 dram_clk_gate;	/* 0x100 DRAM module gating */
+#ifdef CONFIG_SUNXI_DE2
+	u32 de_clk_cfg;		/* 0x104 DE module clock */
+#else
 	u32 be0_clk_cfg;	/* 0x104 BE0 module clock */
+#endif
 	u32 be1_clk_cfg;	/* 0x108 BE1 module clock */
 	u32 fe0_clk_cfg;	/* 0x10c FE0 module clock */
 	u32 fe1_clk_cfg;	/* 0x110 FE1 module clock */
 	u32 mp_clk_cfg;		/* 0x114 MP module clock */
+#ifdef CONFIG_SUNXI_DE2
+	u32 lcd0_clk_cfg;	/* 0x118 LCD0 module clock */
+	u32 lcd1_clk_cfg;	/* 0x11c LCD1 module clock */
+#else
 	u32 lcd0_ch0_clk_cfg;	/* 0x118 LCD0 CH0 module clock */
 	u32 lcd1_ch0_clk_cfg;	/* 0x11c LCD1 CH0 module clock */
+#endif
 	u32 reserved14[3];
 	u32 lcd0_ch1_clk_cfg;	/* 0x12c LCD0 CH1 module clock */
 	u32 lcd1_ch1_clk_cfg;	/* 0x130 LCD1 CH1 module clock */
@@ -85,7 +94,11 @@ struct sunxi_ccm_reg {
 	u32 dmic_clk_cfg;	/* 0x148 Digital Mic module clock*/
 	u32 reserved15;
 	u32 hdmi_clk_cfg;	/* 0x150 HDMI module clock */
+#ifdef CONFIG_SUNXI_DE2
+	u32 hdmi_slow_clk_cfg;	/* 0x154 HDMI slow module clock */
+#else
 	u32 ps_clk_cfg;		/* 0x154 PS module clock */
+#endif
 	u32 mtc_clk_cfg;	/* 0x158 MTC module clock */
 	u32 mbus0_clk_cfg;	/* 0x15c MBUS0 module clock */
 	u32 mbus1_clk_cfg;	/* 0x160 MBUS1 module clock */
@@ -193,6 +206,7 @@ struct sunxi_ccm_reg {
 #define CCM_PLL3_CTRL_N_MASK		(0x7f << CCM_PLL3_CTRL_N_SHIFT)
 #define CCM_PLL3_CTRL_N(n)		((((n) - 1) & 0x7f) << 8)
 #define CCM_PLL3_CTRL_INTEGER_MODE	(0x1 << 24)
+#define CCM_PLL3_CTRL_LOCK		(0x1 << 28)
 #define CCM_PLL3_CTRL_EN		(0x1 << 31)
 
 #define CCM_PLL5_CTRL_M(n)		((((n) - 1) & 0x3) << 0)
@@ -222,6 +236,16 @@ struct sunxi_ccm_reg {
 #define CCM_MIPI_PLL_CTRL_LDO_EN	(0x3 << 22)
 #define CCM_MIPI_PLL_CTRL_EN		(0x1 << 31)
 
+#define CCM_PLL10_CTRL_M_SHIFT		0
+#define CCM_PLL10_CTRL_M_MASK		(0xf << CCM_PLL10_CTRL_M_SHIFT)
+#define CCM_PLL10_CTRL_M(n)		((((n) - 1) & 0xf) << 0)
+#define CCM_PLL10_CTRL_N_SHIFT		8
+#define CCM_PLL10_CTRL_N_MASK		(0x7f << CCM_PLL10_CTRL_N_SHIFT)
+#define CCM_PLL10_CTRL_N(n)		((((n) - 1) & 0x7f) << 8)
+#define CCM_PLL10_CTRL_INTEGER_MODE	(0x1 << 24)
+#define CCM_PLL10_CTRL_LOCK		(0x1 << 28)
+#define CCM_PLL10_CTRL_EN		(0x1 << 31)
+
 #define CCM_PLL11_CTRL_N(n)		((((n) - 1) & 0x3f) << 8)
 #define CCM_PLL11_CTRL_SIGMA_DELTA_EN	(0x1 << 24)
 #define CCM_PLL11_CTRL_UPD		(0x1 << 30)
@@ -273,9 +297,15 @@ struct sunxi_ccm_reg {
 #define AHB_GATE_OFFSET_DRC0		25
 #define AHB_GATE_OFFSET_DE_FE0		14
 #define AHB_GATE_OFFSET_DE_BE0		12
+#define AHB_GATE_OFFSET_DE		12
 #define AHB_GATE_OFFSET_HDMI		11
+#ifndef CONFIG_SUNXI_DE2
 #define AHB_GATE_OFFSET_LCD1		5
 #define AHB_GATE_OFFSET_LCD0		4
+#else
+#define AHB_GATE_OFFSET_LCD1		4
+#define AHB_GATE_OFFSET_LCD0		3
+#endif
 
 #define CCM_MMC_CTRL_M(x)		((x) - 1)
 #define CCM_MMC_CTRL_OCLK_DLY(x)	((x) << 8)
@@ -357,6 +387,12 @@ struct sunxi_ccm_reg {
 #define CCM_LCD_CH1_CTRL_PLL7_2X	(3 << 24)
 #define CCM_LCD_CH1_CTRL_GATE		(0x1 << 31)
 
+#define CCM_LCD0_CTRL_GATE		(0x1 << 31)
+#define CCM_LCD0_CTRL_M(n)		((((n) - 1) & 0xf) << 0)
+
+#define CCM_LCD1_CTRL_GATE		(0x1 << 31)
+#define CCM_LCD1_CTRL_M(n)		((((n) - 1) & 0xf) << 0)
+
 #define CCM_HDMI_CTRL_M(n)		((((n) - 1) & 0xf) << 0)
 #define CCM_HDMI_CTRL_PLL_MASK		(3 << 24)
 #define CCM_HDMI_CTRL_PLL3		(0 << 24)
@@ -366,6 +402,8 @@ struct sunxi_ccm_reg {
 #define CCM_HDMI_CTRL_DDC_GATE		(0x1 << 30)
 #define CCM_HDMI_CTRL_GATE		(0x1 << 31)
 
+#define CCM_HDMI_SLOW_CTRL_DDC_GATE	(1 << 31)
+
 #if defined(CONFIG_MACH_SUN50I)
 #define MBUS_CLK_DEFAULT		0x81000002 /* PLL6x2 / 3 */
 #elif defined(CONFIG_MACH_SUN8I)
@@ -393,9 +431,16 @@ struct sunxi_ccm_reg {
 #define AHB_RESET_OFFSET_DRC0		25
 #define AHB_RESET_OFFSET_DE_FE0		14
 #define AHB_RESET_OFFSET_DE_BE0		12
+#define AHB_RESET_OFFSET_DE		12
 #define AHB_RESET_OFFSET_HDMI		11
+#define AHB_RESET_OFFSET_HDMI2		10
+#ifndef CONFIG_SUNXI_DE2
 #define AHB_RESET_OFFSET_LCD1		5
 #define AHB_RESET_OFFSET_LCD0		4
+#else
+#define AHB_RESET_OFFSET_LCD1		4
+#define AHB_RESET_OFFSET_LCD0		3
+#endif
 
 /* ahb_reset2 offsets */
 #define AHB_RESET_OFFSET_EPHY		2
@@ -418,6 +463,13 @@ struct sunxi_ccm_reg {
 #define CCM_DE_CTRL_PLL10		(5 << 24)
 #define CCM_DE_CTRL_GATE		(1 << 31)
 
+/* CCM bits common to all Display Engine 2.0 clock ctrl regs */
+#define CCM_DE2_CTRL_M(n)		((((n) - 1) & 0xf) << 0)
+#define CCM_DE2_CTRL_PLL_MASK		(3 << 24)
+#define CCM_DE2_CTRL_PLL6_2X		(0 << 24)
+#define CCM_DE2_CTRL_PLL10		(1 << 24)
+#define CCM_DE2_CTRL_GATE		(0x1 << 31)
+
 /* CCU security switch, H3 only */
 #define CCM_SEC_SWITCH_MBUS_NONSEC	(1 << 2)
 #define CCM_SEC_SWITCH_BUS_NONSEC	(1 << 1)
@@ -426,7 +478,9 @@ struct sunxi_ccm_reg {
 #ifndef __ASSEMBLY__
 void clock_set_pll1(unsigned int hz);
 void clock_set_pll3(unsigned int hz);
+void clock_set_pll3_factors(int m, int n);
 void clock_set_pll5(unsigned int clk, bool sigma_delta_enable);
+void clock_set_pll10(unsigned int hz);
 void clock_set_pll11(unsigned int clk, bool sigma_delta_enable);
 void clock_set_mipi_pll(unsigned int hz);
 unsigned int clock_get_pll3(void);
arch/arm/mach-sunxi/clock_sun6i.c +39 -1
index 3c8c53fcf7..7a59f4cd74 100644
@@ -35,7 +35,7 @@ void clock_init_safe(void)
 	clrbits_le32(&prcm->pll_ctrl1, PRCM_PLL_CTRL_LDO_KEY_MASK);
 #endif
 
-#ifdef CONFIG_MACH_SUN8I_R40
+#if defined(CONFIG_MACH_SUN8I_R40) || defined(CONFIG_MACH_SUN50I)
 	/* Set PLL lock enable bits and switch to old lock mode */
 	writel(GENMASK(12, 0), &ccm->pll_lock_ctrl);
 #endif
@@ -150,6 +150,22 @@ void clock_set_pll3(unsigned int clk)
 	       &ccm->pll3_cfg);
 }
 
+#ifdef CONFIG_SUNXI_DE2
+void clock_set_pll3_factors(int m, int n)
+{
+	struct sunxi_ccm_reg * const ccm =
+		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+
+	/* PLL3 rate = 24000000 * n / m */
+	writel(CCM_PLL3_CTRL_EN | CCM_PLL3_CTRL_INTEGER_MODE |
+	       CCM_PLL3_CTRL_N(n) | CCM_PLL3_CTRL_M(m),
+	       &ccm->pll3_cfg);
+
+	while (!(readl(&ccm->pll3_cfg) & CCM_PLL3_CTRL_LOCK))
+		;
+}
+#endif
+
 void clock_set_pll5(unsigned int clk, bool sigma_delta_enable)
 {
 	struct sunxi_ccm_reg * const ccm =
@@ -222,6 +238,28 @@ done:
 }
 #endif
 
+#ifdef CONFIG_SUNXI_DE2
+void clock_set_pll10(unsigned int clk)
+{
+	struct sunxi_ccm_reg * const ccm =
+		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+	const int m = 2; /* 12 MHz steps */
+
+	if (clk == 0) {
+		clrbits_le32(&ccm->pll10_cfg, CCM_PLL10_CTRL_EN);
+		return;
+	}
+
+	/* PLL10 rate = 24000000 * n / m */
+	writel(CCM_PLL10_CTRL_EN | CCM_PLL10_CTRL_INTEGER_MODE |
+	       CCM_PLL10_CTRL_N(clk / (24000000 / m)) | CCM_PLL10_CTRL_M(m),
+	       &ccm->pll10_cfg);
+
+	while (!(readl(&ccm->pll10_cfg) & CCM_PLL10_CTRL_LOCK))
+		;
+}
+#endif
+
 #if defined(CONFIG_MACH_SUN8I_A33) || defined(CONFIG_MACH_SUN50I)
 void clock_set_pll11(unsigned int clk, bool sigma_delta_enable)
 {
board/sunxi/Kconfig +6 -0
index 3e0e262473..d9e7059a9b 100644
@@ -56,6 +56,7 @@ config SUNXI_GEN_SUN6I
 
 config MACH_SUNXI_H3_H5
 	bool
+	select SUNXI_DE2
 	select SUNXI_GEN_SUN6I
 	select SUPPORT_SPL
 
@@ -142,6 +143,7 @@ config MACH_SUN9I
 config MACH_SUN50I
 	bool "sun50i (Allwinner A64)"
 	select ARM64
+	select SUNXI_DE2
 	select SUNXI_GEN_SUN6I
 	select SUNXI_HIGH_SRAM
 	select SUPPORT_SPL
@@ -704,6 +706,10 @@ config VIDEO_LCD_TL059WV5C0
 
 endchoice
 
+config SUNXI_DE2
+	bool
+	default n
+
 
 config GMAC_TX_DELAY
 	int "GMAC Transmit Clock Delay Chain"
drivers/video/sunxi/lcdc.c +4 -0
index 8c8fb2e4ee..7d215b713e 100644
@@ -74,9 +74,11 @@ void lcdc_tcon0_mode_set(struct sunxi_lcdc_reg * const lcdc,
 {
 	int bp, clk_delay, total, val;
 
+#ifndef CONFIG_SUNXI_DE2
 	/* Use tcon0 */
 	clrsetbits_le32(&lcdc->ctrl, SUNXI_LCDC_CTRL_IO_MAP_MASK,
 			SUNXI_LCDC_CTRL_IO_MAP_TCON0);
+#endif
 
 	clk_delay = lcdc_get_clk_delay(mode, 0);
 	writel(SUNXI_LCDC_TCON0_CTRL_ENABLE |
@@ -149,9 +151,11 @@ void lcdc_tcon1_mode_set(struct sunxi_lcdc_reg * const lcdc,
 {
 	int bp, clk_delay, total, val, yres;
 
+#ifndef CONFIG_SUNXI_DE2
 	/* Use tcon1 */
 	clrsetbits_le32(&lcdc->ctrl, SUNXI_LCDC_CTRL_IO_MAP_MASK,
 			SUNXI_LCDC_CTRL_IO_MAP_TCON1);
+#endif
 
 	clk_delay = lcdc_get_clk_delay(mode, 1);
 	writel(SUNXI_LCDC_TCON1_CTRL_ENABLE |
Signature · 1 line
2.12.1
#4 lore raw

PATCH v3 3/6 sunxi: Add clock support for DE2/HDMI/TCON on newer SoCs

Quoted 4 lines · Jernej Skrabec

This is needed for HDMI, which will be added later.

Thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170329/dac99bd7/attachment.sig>
#5 lore raw

PATCH v3 4/6 sunxi: video: Add A64/H3/H5 HDMI driver

In reply to Jernej Skrabec

This commit adds support for HDMI output.

---
Changes in v3:
- changed to 32 bpp
- add acked by tag
- VIDEO_DE2 option now depends on SUNXI_DE2

Changes in v2:
- add reviewed by tag

 arch/arm/include/asm/arch-sunxi/cpu_sun4i.h |   8 +
 arch/arm/include/asm/arch-sunxi/display2.h  | 124 +++++++++
 board/sunxi/Kconfig                         |  10 +
 drivers/video/sunxi/Makefile                |   1 +
 drivers/video/sunxi/sunxi_de2.c             | 258 ++++++++++++++++++
 drivers/video/sunxi/sunxi_dw_hdmi.c         | 389 ++++++++++++++++++++++++++++
 include/configs/sunxi-common.h              |   5 +
 7 files changed, 795 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-sunxi/display2.h
 create mode 100644 drivers/video/sunxi/sunxi_de2.c
 create mode 100644 drivers/video/sunxi/sunxi_dw_hdmi.c
arch/arm/include/asm/arch-sunxi/cpu_sun4i.h +8 -0
index ea672fe844..3ce46d024e 100644
@@ -18,6 +18,8 @@
 #define SUNXI_SRAM_D_BASE		0x00010000	/* 4 kiB */
 #define SUNXI_SRAM_B_BASE		0x00020000	/* 64 kiB (secure) */
 
+#define SUNXI_DE2_BASE			0x01000000
+
 #ifdef CONFIG_MACH_SUN8I_A83T
 #define SUNXI_CPUCFG_BASE		0x01700000
 #endif
@@ -46,7 +48,9 @@
 #define SUNXI_USB1_BASE			0x01c14000
 #endif
 #define SUNXI_SS_BASE			0x01c15000
+#if !defined(CONFIG_MACH_SUNXI_H3_H5) && !defined(CONFIG_MACH_SUN50I)
 #define SUNXI_HDMI_BASE			0x01c16000
+#endif
 #define SUNXI_SPI2_BASE			0x01c17000
 #define SUNXI_SATA_BASE			0x01c18000
 #ifdef CONFIG_SUNXI_GEN_SUN4I
@@ -164,6 +168,10 @@ defined(CONFIG_MACH_SUN50I)
 #define SUNXI_MP_BASE			0x01e80000
 #define SUNXI_AVG_BASE			0x01ea0000
 
+#if defined(CONFIG_MACH_SUNXI_H3_H5) || defined(CONFIG_MACH_SUN50I)
+#define SUNXI_HDMI_BASE			0x01ee0000
+#endif
+
 #define SUNXI_RTC_BASE			0x01f00000
 #define SUNXI_PRCM_BASE			0x01f01400
 
arch/arm/include/asm/arch-sunxi/display2.h new file +124 -0

124 lines not on this page · raw message

board/sunxi/Kconfig +10 -0
index d9e7059a9b..52f71f568a 100644
@@ -710,6 +710,16 @@ config SUNXI_DE2
 	bool
 	default n
 
+config VIDEO_DE2
+	bool "Display Engine 2 video driver"
+	depends on SUNXI_DE2
+	select DM_VIDEO
+	select DISPLAY
+	default y
+	---help---
+	Say y here if you want to build DE2 video driver which is present on
+	newer SoCs. Currently only HDMI output is supported.
+
 
 config GMAC_TX_DELAY
 	int "GMAC Transmit Clock Delay Chain"
drivers/video/sunxi/Makefile +1 -0
index dfc9b47a1f..b8afd892ad 100644
@@ -6,3 +6,4 @@
 #
 
 obj-$(CONFIG_VIDEO_SUNXI) += sunxi_display.o lcdc.o ../videomodes.o
+obj-$(CONFIG_VIDEO_DE2) += sunxi_de2.o sunxi_dw_hdmi.o lcdc.o ../dw_hdmi.o
drivers/video/sunxi/sunxi_de2.c new file +258 -0

258 lines not on this page · raw message

drivers/video/sunxi/sunxi_dw_hdmi.c new file +389 -0

389 lines not on this page · raw message

include/configs/sunxi-common.h +5 -0
index 5c9657ad13..936eda5c9b 100644
@@ -463,6 +463,11 @@ extern int soft_i2c_gpio_scl;
 #define CONSOLE_STDOUT_SETTINGS \
 	"stdout=serial,vga\0" \
 	"stderr=serial,vga\0"
+#elif CONFIG_DM_VIDEO
+#define CONFIG_SYS_WHITE_ON_BLACK
+#define CONSOLE_STDOUT_SETTINGS \
+	"stdout=serial,vidconsole\0" \
+	"stderr=serial,vidconsole\0"
 #else
 #define CONSOLE_STDOUT_SETTINGS \
 	"stdout=serial\0" \
Signature · 1 line
2.12.1
#6 lore raw

PATCH v3 5/6 sunxi: Disable DE2 video driver where not needed

In reply to Jernej Skrabec

Because DE2 driver is enabled by default, it is nice to disable it on all boards which don't have any video output. List of such boards is also much shorter.

---
Changes in v3:
- add acked by tag

Changes in v2:
- invert logic (disable instead of enable)

 configs/nanopi_neo_air_defconfig | 1 +
 configs/nanopi_neo_defconfig     | 1 +
 configs/orangepi_zero_defconfig  | 1 +
 3 files changed, 3 insertions(+)
configs/nanopi_neo_air_defconfig +1 -0
index 9598bd5cd5..5400d37bd1 100644
@@ -15,3 +15,4 @@ CONFIG_SPL=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_USB_EHCI_HCD=y
+# CONFIG_VIDEO_DE2 is not set
configs/nanopi_neo_defconfig +1 -0
index 89f5687884..5afd5d565a 100644
@@ -16,3 +16,4 @@ CONFIG_SPL=y
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
 CONFIG_USB_EHCI_HCD=y
+# CONFIG_VIDEO_DE2 is not set
configs/orangepi_zero_defconfig +1 -0
index abb3fcf307..f5947d121b 100644
@@ -15,3 +15,4 @@ CONFIG_SUN8I_EMAC=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SPL_SPI_SUNXI=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
+# CONFIG_VIDEO_DE2 is not set
Signature · 1 line
2.12.1
#7 lore raw

PATCH v3 6/6 sunxi: add AXP803 support

In reply to Jernej Skrabec

From: Icenowy Zheng <[email protected]>

The A64 uses the AXP803 as its PMIC.

---

 arch/arm/mach-sunxi/Makefile   |   3 +
 arch/arm/mach-sunxi/pmic_bus.c |   6 +-
 arch/arm/mach-sunxi/rsb.c      |   2 +-
 board/sunxi/board.c            |  31 ++---
 drivers/power/Kconfig          |  87 ++++++++------
 drivers/power/Makefile         |   1 +
 drivers/power/axp803.c         | 256 +++++++++++++++++++++++++++++++++++++++++
 drivers/power/axp818.c         |   2 +-
 include/axp803.h               |  73 ++++++++++++
 include/axp_pmic.h             |   3 +
 10 files changed, 414 insertions(+), 50 deletions(-)
 create mode 100644 drivers/power/axp803.c
 create mode 100644 include/axp803.h
arch/arm/mach-sunxi/Makefile +3 -0
index efab4811ee..861a52c6d0 100644
@@ -19,9 +19,11 @@ endif
 obj-$(CONFIG_MACH_SUN6I)	+= prcm.o
 obj-$(CONFIG_MACH_SUN8I)	+= prcm.o
 obj-$(CONFIG_MACH_SUN9I)	+= prcm.o
+obj-$(CONFIG_MACH_SUN50I)	+= prcm.o
 obj-$(CONFIG_MACH_SUN6I)	+= p2wi.o
 obj-$(CONFIG_MACH_SUN8I)	+= rsb.o
 obj-$(CONFIG_MACH_SUN9I)	+= rsb.o
+obj-$(CONFIG_MACH_SUN50I)	+= rsb.o
 obj-$(CONFIG_MACH_SUN4I)	+= clock_sun4i.o
 obj-$(CONFIG_MACH_SUN5I)	+= clock_sun4i.o
 obj-$(CONFIG_MACH_SUN6I)	+= clock_sun6i.o
@@ -37,6 +39,7 @@ obj-$(CONFIG_MACH_SUN9I)	+= clock_sun9i.o gtbus_sun9i.o
 obj-$(CONFIG_AXP152_POWER)	+= pmic_bus.o
 obj-$(CONFIG_AXP209_POWER)	+= pmic_bus.o
 obj-$(CONFIG_AXP221_POWER)	+= pmic_bus.o
+obj-$(CONFIG_AXP803_POWER)	+= pmic_bus.o
 obj-$(CONFIG_AXP809_POWER)	+= pmic_bus.o
 obj-$(CONFIG_AXP818_POWER)	+= pmic_bus.o
 
arch/arm/mach-sunxi/pmic_bus.c +3 -3
index 7c57f02792..0ac64a97cf 100644
@@ -36,7 +36,7 @@ int pmic_bus_init(void)
 	if (!needs_init)
 		return 0;
 
-#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
+#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP803_POWER || defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
 # ifdef CONFIG_MACH_SUN6I
 	p2wi_init();
 	ret = p2wi_change_to_p2wi_mode(AXP221_CHIP_ADDR, AXP221_CTRL_ADDR,
@@ -62,7 +62,7 @@ int pmic_bus_read(u8 reg, u8 *data)
 	return i2c_read(AXP152_I2C_ADDR, reg, 1, data, 1);
 #elif defined CONFIG_AXP209_POWER
 	return i2c_read(AXP209_I2C_ADDR, reg, 1, data, 1);
-#elif defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
+#elif defined CONFIG_AXP221_POWER || defined CONFIG_AXP803_POWER || defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
 # ifdef CONFIG_MACH_SUN6I
 	return p2wi_read(reg, data);
 # else
@@ -77,7 +77,7 @@ int pmic_bus_write(u8 reg, u8 data)
 	return i2c_write(AXP152_I2C_ADDR, reg, 1, &data, 1);
 #elif defined CONFIG_AXP209_POWER
 	return i2c_write(AXP209_I2C_ADDR, reg, 1, &data, 1);
-#elif defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
+#elif defined CONFIG_AXP221_POWER || defined CONFIG_AXP803_POWER || defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
 # ifdef CONFIG_MACH_SUN6I
 	return p2wi_write(reg, data);
 # else
arch/arm/mach-sunxi/rsb.c +1 -1
index 6fd11f1529..28d05e962a 100644
@@ -20,7 +20,7 @@ static int rsb_set_device_mode(void);
 
 static void rsb_cfg_io(void)
 {
-#ifdef CONFIG_MACH_SUN8I
+#if defined CONFIG_MACH_SUN8I || defined CONFIG_MACH_SUN50I
 	sunxi_gpio_set_cfgpin(SUNXI_GPL(0), SUN8I_GPL_R_RSB);
 	sunxi_gpio_set_cfgpin(SUNXI_GPL(1), SUN8I_GPL_R_RSB);
 	sunxi_gpio_set_pull(SUNXI_GPL(0), 1);
board/sunxi/board.c +18 -13
index b9660128e5..75e53bebbd 100644
@@ -487,26 +487,27 @@ void sunxi_board_init(void)
 #endif
 
 #if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER || \
-	defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || \
-	defined CONFIG_AXP818_POWER
+	defined CONFIG_AXP221_POWER || defined CONFIG_AXP803_POWER || \
+	defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
 	power_failed = axp_init();
 
-#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || \
-	defined CONFIG_AXP818_POWER
+#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP803_POWER || \
+	defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
 	power_failed |= axp_set_dcdc1(CONFIG_AXP_DCDC1_VOLT);
 #endif
 	power_failed |= axp_set_dcdc2(CONFIG_AXP_DCDC2_VOLT);
 	power_failed |= axp_set_dcdc3(CONFIG_AXP_DCDC3_VOLT);
-#if !defined(CONFIG_AXP209_POWER) && !defined(CONFIG_AXP818_POWER)
+#if !defined(CONFIG_AXP209_POWER) && !defined(CONFIG_AXP803_POWER) && \
+	!defined(CONFIG_AXP818_POWER)
 	power_failed |= axp_set_dcdc4(CONFIG_AXP_DCDC4_VOLT);
 #endif
-#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || \
-	defined CONFIG_AXP818_POWER
+#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP803_POWER || \
+	defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
 	power_failed |= axp_set_dcdc5(CONFIG_AXP_DCDC5_VOLT);
 #endif
 
-#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || \
-	defined CONFIG_AXP818_POWER
+#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP803_POWER || \
+	defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
 	power_failed |= axp_set_aldo1(CONFIG_AXP_ALDO1_VOLT);
 #endif
 	power_failed |= axp_set_aldo2(CONFIG_AXP_ALDO2_VOLT);
@@ -517,8 +518,8 @@ void sunxi_board_init(void)
 	power_failed |= axp_set_aldo4(CONFIG_AXP_ALDO4_VOLT);
 #endif
 
-#if defined(CONFIG_AXP221_POWER) || defined(CONFIG_AXP809_POWER) || \
-	defined(CONFIG_AXP818_POWER)
+#if defined(CONFIG_AXP221_POWER) || defined(CONFIG_AXP803_POWER) || \
+	defined(CONFIG_AXP809_POWER) || defined(CONFIG_AXP818_POWER)
 	power_failed |= axp_set_dldo(1, CONFIG_AXP_DLDO1_VOLT);
 	power_failed |= axp_set_dldo(2, CONFIG_AXP_DLDO2_VOLT);
 #if !defined CONFIG_AXP809_POWER
@@ -530,13 +531,17 @@ void sunxi_board_init(void)
 	power_failed |= axp_set_eldo(3, CONFIG_AXP_ELDO3_VOLT);
 #endif
 
-#ifdef CONFIG_AXP818_POWER
+#if defined CONFIG_AXP803_POWER || defined CONFIG_AXP818_POWER
 	power_failed |= axp_set_fldo(1, CONFIG_AXP_FLDO1_VOLT);
 	power_failed |= axp_set_fldo(2, CONFIG_AXP_FLDO2_VOLT);
+#endif
+
+#ifdef CONFIG_AXP818_POWER
 	power_failed |= axp_set_fldo(3, CONFIG_AXP_FLDO3_VOLT);
 #endif
 
-#if defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
+#if defined CONFIG_AXP803_POWER || defined CONFIG_AXP809_POWER || \
+	defined CONFIG_AXP818_POWER
 	power_failed |= axp_set_sw(IS_ENABLED(CONFIG_AXP_SW_ON));
 #endif
 #endif
drivers/power/Kconfig +55 -32

258 lines not on this page · raw message

drivers/power/Makefile +1 -0
index b43523e628..1449e875ce 100644
@@ -9,6 +9,7 @@ obj-$(CONFIG_AS3722_POWER)	+= as3722.o
 obj-$(CONFIG_AXP152_POWER)	+= axp152.o
 obj-$(CONFIG_AXP209_POWER)	+= axp209.o
 obj-$(CONFIG_AXP221_POWER)	+= axp221.o
+obj-$(CONFIG_AXP803_POWER)	+= axp803.o
 obj-$(CONFIG_AXP809_POWER)	+= axp809.o
 obj-$(CONFIG_AXP818_POWER)	+= axp818.o
 obj-$(CONFIG_EXYNOS_TMU)	+= exynos-tmu.o
drivers/power/axp803.c new file +256 -0

256 lines not on this page · raw message

drivers/power/axp818.c +1 -1
index af4d7a6903..ad0c330ca5 100644
@@ -162,7 +162,7 @@ int axp_set_dldo(int dldo_num, unsigned int mvolt)
 	cfg = axp818_mvolt_to_cfg(mvolt, 700, 3300, 100);
 	if (dldo_num == 2 && mvolt > 3300)
 		cfg += 1 + axp818_mvolt_to_cfg(mvolt, 3400, 4200, 200);
-	ret = pmic_bus_write(AXP818_ELDO1_CTRL + (dldo_num - 1), cfg);
+	ret = pmic_bus_write(AXP818_DLDO1_CTRL + (dldo_num - 1), cfg);
 	if (ret)
 		return ret;
 
include/axp803.h new file +73 -0

73 lines not on this page · raw message

include/axp_pmic.h +3 -0
index d789ad8086..8cb4d5763c 100644
@@ -16,6 +16,9 @@
 #ifdef CONFIG_AXP221_POWER
 #include <axp221.h>
 #endif
+#ifdef CONFIG_AXP803_POWER
+#include <axp803.h>
+#endif
 #ifdef CONFIG_AXP809_POWER
 #include <axp809.h>
 #endif
Signature · 1 line
2.12.1
#8 lore raw

v3 cover sunxi: video: Add support for HDMI output on A64/H3/H5

In reply to Jernej Skrabec

Hi Jernej,

Quoted 11 lines · Jernej Skrabec

This series implements support for HDMI output. This is done using DM video framework and sharing the HDMI controller code with RK3288.

Patch 1 splits out TCON code which is completely reusable on all Allwinner SoCs.

Patch 2 converts common TCON code to use DM video compatible timing structure.

Patch 3 adds all necessary clocks which are needed for Display Engine 2, TCON and HDMI.

I merged all these patches...

Quoted 2 lines

Patch 4 implement actual DE2 and HDMI driver and patch 5 disables HDMI on all boards which don't have it (default is on).

But not this one, since it creates a Kconfig warning due to the dependency of I2C_EDID on DM_I2C.

I think the current state of this discussion is that the i2c driver should be converted to the DM, which seems to be stalled at the moment.

Could you take in that patch and do the minor rework that were suggested by Simon so that we can get this in ?

Thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170421/9b8863b6/attachment.sig>
#9 lore raw

v3 cover sunxi: video: Add support for HDMI output on A64/H3/H5

Dne petek, 21. april 2017 ob 09:04:13 CEST je Maxime Ripard napisal(a):

Quoted 23 lines

Hi Jernej,

Quoted 11 lines · Jernej Skrabec

This series implements support for HDMI output. This is done using DM video framework and sharing the HDMI controller code with RK3288.

Patch 1 splits out TCON code which is completely reusable on all Allwinner SoCs.

Patch 2 converts common TCON code to use DM video compatible timing structure.

Patch 3 adds all necessary clocks which are needed for Display Engine 2, TCON and HDMI.

I merged all these patches...

Quoted 2 lines

Patch 4 implement actual DE2 and HDMI driver and patch 5 disables HDMI on all boards which don't have it (default is on).

But not this one, since it creates a Kconfig warning due to the dependency of I2C_EDID on DM_I2C.

Quoted 6 lines

I think the current state of this discussion is that the i2c driver should be converted to the DM, which seems to be stalled at the moment.

Could you take in that patch and do the minor rework that were suggested by Simon so that we can get this in ?

Yes, of course. Should I also simplify the driver, because since then I learned a bit more about DE2? Or should I sent follow up patch?

Regards,
Jernej

#10 lore raw

v3 cover sunxi: video: Add support for HDMI output on A64/H3/H5

Hi Jernej,

Quoted 28 lines · Jernej Å krabec

Dne petek, 21. april 2017 ob 09:04:13 CEST je Maxime Ripard napisal(a):

Quoted 27 lines

Hi Jernej,

Quoted 11 lines · Jernej Skrabec

This series implements support for HDMI output. This is done using DM video framework and sharing the HDMI controller code with RK3288.

Patch 1 splits out TCON code which is completely reusable on all Allwinner SoCs.

Patch 2 converts common TCON code to use DM video compatible timing structure.

Patch 3 adds all necessary clocks which are needed for Display Engine 2, TCON and HDMI.

I merged all these patches...

Quoted 2 lines

Patch 4 implement actual DE2 and HDMI driver and patch 5 disables HDMI on all boards which don't have it (default is on).

But not this one, since it creates a Kconfig warning due to the dependency of I2C_EDID on DM_I2C.

I think the current state of this discussion is that the i2c driver should be converted to the DM, which seems to be stalled at the moment.

Quoted 5 lines
Quoted 2 lines

Could you take in that patch and do the minor rework that were suggested by Simon so that we can get this in ?

Yes, of course. Should I also simplify the driver, because since then I learned a bit more about DE2? Or should I sent follow up patch?

Which driver are you talking about? DE's or the i2c driver?

If it is something that was already merged, it's better if you send follow up patches. If it's a patch that is still pending, then you can do it in that patch and resend a new version.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170424/63a3b803/attachment.sig>
#11 lore raw

v3 cover sunxi: video: Add support for HDMI output on A64/H3/H5

Hi Maxime,

Dne ponedeljek, 24. april 2017 ob 09:19:40 CEST je Maxime Ripard napisal(a):

Quoted 33 lines

Hi Jernej,

Quoted 30 lines · Jernej Å krabec

Dne petek, 21. april 2017 ob 09:04:13 CEST je Maxime Ripard napisal(a):

Quoted 29 lines

Hi Jernej,

Quoted 11 lines · Jernej Skrabec

This series implements support for HDMI output. This is done using DM video framework and sharing the HDMI controller code with RK3288.

Patch 1 splits out TCON code which is completely reusable on all Allwinner SoCs.

Patch 2 converts common TCON code to use DM video compatible timing structure.

Patch 3 adds all necessary clocks which are needed for Display Engine 2, TCON and HDMI.

I merged all these patches...

Quoted 2 lines

Patch 4 implement actual DE2 and HDMI driver and patch 5 disables HDMI on all boards which don't have it (default is on).

But not this one, since it creates a Kconfig warning due to the dependency of I2C_EDID on DM_I2C.

I think the current state of this discussion is that the i2c driver should be converted to the DM, which seems to be stalled at the moment.

Could you take in that patch and do the minor rework that were suggested by Simon so that we can get this in ?

Sorry I missed what was suggested by Simon?

Quoted 5 lines
Quoted 3 lines

Yes, of course. Should I also simplify the driver, because since then I learned a bit more about DE2? Or should I sent follow up patch?

Which driver are you talking about? DE's or the i2c driver?

DE

Quoted 4 lines

If it is something that was already merged, it's better if you send follow up patches. If it's a patch that is still pending, then you can do it in that patch and resend a new version.

Ok, I will send a new version.

Regards,
Jernej

#12 lore raw

v3 cover sunxi: video: Add support for HDMI output on A64/H3/H5

Quoted 30 lines · Jernej Škrabec

Hi Maxime,

Dne ponedeljek, 24. april 2017 ob 09:19:40 CEST je Maxime Ripard napisal(a):

Quoted 27 lines

Hi Jernej,

Quoted 24 lines · Jernej Škrabec

Dne petek, 21. april 2017 ob 09:04:13 CEST je Maxime Ripard napisal(a):

Quoted 23 lines

Hi Jernej,

Quoted 11 lines · Jernej Skrabec

This series implements support for HDMI output. This is done using DM video framework and sharing the HDMI controller code with RK3288.

Patch 1 splits out TCON code which is completely reusable on all Allwinner SoCs.

Patch 2 converts common TCON code to use DM video compatible timing structure.

Patch 3 adds all necessary clocks which are needed for Display Engine 2, TCON and HDMI.

I merged all these patches...

Quoted 2 lines

Patch 4 implement actual DE2 and HDMI driver and patch 5 disables HDMI on all boards which don't have it (default is on).

But not this one, since it creates a Kconfig warning due to the dependency of I2C_EDID on DM_I2C.

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

I think the current state of this discussion is that the i2c driver should be converted to the DM, which seems to be stalled at the moment.

Could you take in that patch and do the minor rework that were suggested by Simon so that we can get this in ?

Sorry I missed what was suggested by Simon?

You have the history there:
https://patchwork.ozlabs.org/patch/734375/

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170425/48ac1591/attachment.sig>
#13 lore raw

v3 cover sunxi: video: Add support for HDMI output on A64/H3/H5

Hi Maxime,

Dne torek, 25. april 2017 ob 10:57:05 CEST je Maxime Ripard napisal(a):

Quoted 4 lines · Jernej Škrabec
Quoted 3 lines

Hi Maxime,

Dne ponedeljek, 24. april 2017 ob 09:19:40 CEST je Maxime Ripard

napisal(a):

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Hi Jernej,

Quoted 1 line · Jernej Škrabec

Dne petek, 21. april 2017 ob 09:04:13 CEST je Maxime Ripard

napisal(a):

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines

Hi Jernej,

Quoted 7 lines · Jernej Skrabec

This series implements support for HDMI output. This is done using DM video framework and sharing the HDMI controller code with RK3288.

Patch 1 splits out TCON code which is completely reusable on all Allwinner SoCs.

Quoted 6 lines

Patch 2 converts common TCON code to use DM video compatible timing
structure.

Patch 3 adds all necessary clocks which are needed for Display Engine 2, TCON and HDMI.

I merged all these patches...

Quoted 3 lines

Patch 4 implement actual DE2 and HDMI driver and patch 5 disables HDMI
on all boards which don't have it (default is on).

But not this one, since it creates a Kconfig warning due to the dependency of I2C_EDID on DM_I2C.

I think the current state of this discussion is that the i2c driver should be converted to the DM, which seems to be stalled at the moment.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Could you take in that patch and do the minor rework that were suggested by Simon so that we can get this in ?

Sorry I missed what was suggested by Simon?

You have the history there:
https://patchwork.ozlabs.org/patch/734375/

Rework of this patch gives me a bit of a headache.
1. Should I remove DM reset and clk calls since they are not yet supported by sunxi? If so, where should clocks be enabled? In board config?

2. SPL code uses old I2C interface for setting regulators, so all code which is called only in SPL but compiled also for U-Boot proper needs to be wrapped inside "#ifdef CONFIG_SPL_BUILD" or is there a better way? Example for that is drivers/power/sy8106a.c

3. Even if we solve everything nicely, most boards don't have anything attached to I2C besides power regulators, so I2C busses won't be probed anyway. This feels like a step back since you can't use i2c command unless device with available DM driver is defined in DT.

Regards,
Jernej

#14 lore raw

v3 cover sunxi: video: Add support for HDMI output on A64/H3/H5

Hi Jernej,

Quoted 46 lines · Jernej Škrabec

Hi Maxime,

Dne torek, 25. april 2017 ob 10:57:05 CEST je Maxime Ripard napisal(a):

Quoted 4 lines · Jernej Škrabec
Quoted 3 lines

Hi Maxime,

Dne ponedeljek, 24. april 2017 ob 09:19:40 CEST je Maxime Ripard

napisal(a):

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Hi Jernej,

Quoted 1 line · Jernej Škrabec

Dne petek, 21. april 2017 ob 09:04:13 CEST je Maxime Ripard

napisal(a):

Quoted 33 lines
Quoted 33 lines
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines

Hi Jernej,

Quoted 7 lines · Jernej Skrabec

This series implements support for HDMI output. This is done using DM video framework and sharing the HDMI controller code with RK3288.

Patch 1 splits out TCON code which is completely reusable on all Allwinner SoCs.

Quoted 6 lines

Patch 2 converts common TCON code to use DM video compatible timing
structure.

Patch 3 adds all necessary clocks which are needed for Display Engine 2, TCON and HDMI.

I merged all these patches...

Quoted 3 lines

Patch 4 implement actual DE2 and HDMI driver and patch 5 disables HDMI
on all boards which don't have it (default is on).

But not this one, since it creates a Kconfig warning due to the dependency of I2C_EDID on DM_I2C.

I think the current state of this discussion is that the i2c driver should be converted to the DM, which seems to be stalled at the moment.

Could you take in that patch and do the minor rework that were suggested by Simon so that we can get this in ?

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Sorry I missed what was suggested by Simon?

You have the history there:
https://patchwork.ozlabs.org/patch/734375/

Rework of this patch gives me a bit of a headache.
1. Should I remove DM reset and clk calls since they are not yet supported by sunxi? If so, where should clocks be enabled? In board config?

I'd say so, yes. This is not really nice, but this is just temporary, since we also have those patches being worked on at the moment.

Quoted 4 lines

2. SPL code uses old I2C interface for setting regulators, so all code which is called only in SPL but compiled also for U-Boot proper needs to be wrapped inside "#ifdef CONFIG_SPL_BUILD" or is there a better way? Example for that is drivers/power/sy8106a.c

I'm not aware of any way better than either having that ifdef, or having a separate Kconfig option, but that's pretty much the same thing.

Quoted 4 lines

3. Even if we solve everything nicely, most boards don't have anything attached to I2C besides power regulators, so I2C busses won't be probed anyway. This feels like a step back since you can't use i2c command unless device with available DM driver is defined in DT.

This isn't really an issue for me. All the relevant busses should be declared in the DT in the first place, so the fix for that one would be to simply add the bus and be done with it.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170426/9e771224/attachment.sig>
#15 lore raw

v3 cover sunxi: video: Add support for HDMI output on A64/H3/H5

In reply to Maxime Ripard

Hi Maxime,

Dne ponedeljek, 24. april 2017 ob 09:19:40 CEST je Maxime Ripard napisal(a):

Quoted 34 lines

Hi Jernej,

Quoted 31 lines · Jernej Å krabec

Dne petek, 21. april 2017 ob 09:04:13 CEST je Maxime Ripard napisal(a):

Quoted 29 lines

Hi Jernej,

Quoted 11 lines · Jernej Skrabec

This series implements support for HDMI output. This is done using DM video framework and sharing the HDMI controller code with RK3288.

Patch 1 splits out TCON code which is completely reusable on all Allwinner SoCs.

Patch 2 converts common TCON code to use DM video compatible timing structure.

Patch 3 adds all necessary clocks which are needed for Display Engine 2, TCON and HDMI.

I merged all these patches...

Quoted 2 lines

Patch 4 implement actual DE2 and HDMI driver and patch 5 disables HDMI on all boards which don't have it (default is on).

But not this one, since it creates a Kconfig warning due to the dependency of I2C_EDID on DM_I2C.

I think the current state of this discussion is that the i2c driver should be converted to the DM, which seems to be stalled at the moment.

Could you take in that patch and do the minor rework that were suggested by Simon so that we can get this in ?

Quoted 8 lines
Quoted 2 lines

Yes, of course. Should I also simplify the driver, because since then I learned a bit more about DE2? Or should I sent follow up patch?

Which driver are you talking about? DE's or the i2c driver?

If it is something that was already merged, it's better if you send follow up patches. If it's a patch that is still pending, then you can do it in that patch and resend a new version.

I figured out that changes to still pending DE2 patches would be almost only cosmetical, so please go ahead and merge latest posted series once DM I2C changes are in. Sorry for the noise.

Regards,
Jernej

#16 lore raw

v3 cover sunxi: video: Add support for HDMI output on A64/H3/H5

In reply to Jernej Skrabec
Quoted 6 lines · Jernej Skrabec

This series implements support for HDMI output. This is done using DM video framework and sharing the HDMI controller code with RK3288.

Patch 1 splits out TCON code which is completely reusable on all Allwinner SoCs.

Quoted 9 lines

Patch 2 converts common TCON code to use DM video compatible timing structure.

Patch 3 adds all necessary clocks which are needed for Display Engine 2, TCON and HDMI.

Patch 4 implement actual DE2 and HDMI driver and patch 5 disables HDMI on all boards which don't have it (default is on).

Applied patches 4 and 5 after the i2c series.

I'm doing a build test, and will push it when it's done.

Thanks a lot for your work!
Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170428/d3905f92/attachment.sig>