Re: [PATCH v2 18/19] video: sunxi: Add DW HDMI PHY driver

2021-03-08 Thread Jernej Škrabec
Dne ponedeljek, 08. marec 2021 ob 08:57:31 CET je Jagan Teki napisal(a):
> On Sun, Mar 7, 2021 at 1:25 AM Jernej Skrabec  
wrote:
> > This commit adds standalone driver for DW HDMI PHY. It deprecates code
> > which is included in sunxi dw-hdmi platform driver.
> > 
> > Signed-off-by: Jernej Skrabec 
> > ---
> > 
> >  arch/arm/mach-sunxi/Kconfig |   1 +
> >  drivers/video/sunxi/Makefile|   2 +-
> >  drivers/video/sunxi/sunxi_dw_hdmi_phy.c | 423 
> >  drivers/video/sunxi/sunxi_dw_hdmi_phy.h |  24 ++
> 
> Would be good if this PHY management code handles via drivers/phy.
> Hope this would possible?

You mean move this code there? Yeah, it's possible, but then we have to move 
sunxi_dw_hdmi_phy.h to general or arch includes folder, because it implements 
additional functionality which is not covered by general PHY interface.

Best regards,
Jernej





Re: [PATCH v2 18/19] video: sunxi: Add DW HDMI PHY driver

2021-03-07 Thread Jagan Teki
On Sun, Mar 7, 2021 at 1:25 AM Jernej Skrabec  wrote:
>
> This commit adds standalone driver for DW HDMI PHY. It deprecates code
> which is included in sunxi dw-hdmi platform driver.
>
> Signed-off-by: Jernej Skrabec 
> ---
>  arch/arm/mach-sunxi/Kconfig |   1 +
>  drivers/video/sunxi/Makefile|   2 +-
>  drivers/video/sunxi/sunxi_dw_hdmi_phy.c | 423 
>  drivers/video/sunxi/sunxi_dw_hdmi_phy.h |  24 ++

Would be good if this PHY management code handles via drivers/phy.
Hope this would possible?

Jagan.


[PATCH v2 18/19] video: sunxi: Add DW HDMI PHY driver

2021-03-06 Thread Jernej Skrabec
This commit adds standalone driver for DW HDMI PHY. It deprecates code
which is included in sunxi dw-hdmi platform driver.

Signed-off-by: Jernej Skrabec 
---
 arch/arm/mach-sunxi/Kconfig |   1 +
 drivers/video/sunxi/Makefile|   2 +-
 drivers/video/sunxi/sunxi_dw_hdmi_phy.c | 423 
 drivers/video/sunxi/sunxi_dw_hdmi_phy.h |  24 ++
 4 files changed, 449 insertions(+), 1 deletion(-)
 create mode 100644 drivers/video/sunxi/sunxi_dw_hdmi_phy.c
 create mode 100644 drivers/video/sunxi/sunxi_dw_hdmi_phy.h

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index 34ef1f4b030f..5f2df7727357 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -973,6 +973,7 @@ config VIDEO_DE2
select CLK_SUN8I_DE2
select DM_VIDEO
select DISPLAY
+   select PHY
select VIDEO_DW_HDMI
imply VIDEO_DT_SIMPLEFB
default y
diff --git a/drivers/video/sunxi/Makefile b/drivers/video/sunxi/Makefile
index 4321673312bf..22ec17fb4fd2 100644
--- a/drivers/video/sunxi/Makefile
+++ b/drivers/video/sunxi/Makefile
@@ -4,4 +4,4 @@
 # Wolfgang Denk, DENX Software Engineering, w...@denx.de.
 
 obj-$(CONFIG_VIDEO_SUNXI) += sunxi_display.o simplefb_common.o lcdc.o 
tve_common.o ../videomodes.o
-obj-$(CONFIG_VIDEO_DE2) += sunxi_de2.o sunxi_dw_hdmi.o simplefb_common.o 
lcdc.o sunxi_lcd.o
+obj-$(CONFIG_VIDEO_DE2) += sunxi_de2.o sunxi_dw_hdmi.o sunxi_dw_hdmi_phy.o 
simplefb_common.o lcdc.o sunxi_lcd.o
diff --git a/drivers/video/sunxi/sunxi_dw_hdmi_phy.c 
b/drivers/video/sunxi/sunxi_dw_hdmi_phy.c
new file mode 100644
index ..bed5c2fdfe81
--- /dev/null
+++ b/drivers/video/sunxi/sunxi_dw_hdmi_phy.c
@@ -0,0 +1,423 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Allwinner DW HDMI PHY driver
+ *
+ * (C) Copyright 2021 Jernej Skrabec 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "sunxi_dw_hdmi_phy.h"
+
+#define SUN8I_HDMI_PHY_DBG_CTRL_PX_LOCKBIT(0)
+#define SUN8I_HDMI_PHY_DBG_CTRL_POL_MASK   GENMASK(15, 8)
+#define SUN8I_HDMI_PHY_DBG_CTRL_POL_NHSYNC BIT(8)
+#define SUN8I_HDMI_PHY_DBG_CTRL_POL_NVSYNC BIT(9)
+#define SUN8I_HDMI_PHY_DBG_CTRL_ADDR_MASK  GENMASK(23, 16)
+#define SUN8I_HDMI_PHY_DBG_CTRL_ADDR(addr) (addr << 16)
+
+#define SUN8I_HDMI_PHY_REXT_CTRL_REXT_EN   BIT(31)
+
+#define SUN8I_HDMI_PHY_READ_EN_MAGIC   0x54524545
+
+#define SUN8I_HDMI_PHY_UNSCRAMBLE_MAGIC0x42494E47
+
+#define SUN8I_HDMI_PHY_ANA_CFG1_REG_SWIBIT(31)
+#define SUN8I_HDMI_PHY_ANA_CFG1_REG_PWEND  BIT(30)
+#define SUN8I_HDMI_PHY_ANA_CFG1_REG_PWENC  BIT(29)
+#define SUN8I_HDMI_PHY_ANA_CFG1_REG_CALSW  BIT(28)
+#define SUN8I_HDMI_PHY_ANA_CFG1_REG_SVRCAL(x)  ((x) << 26)
+#define SUN8I_HDMI_PHY_ANA_CFG1_REG_SVBH(x)((x) << 24)
+#define SUN8I_HDMI_PHY_ANA_CFG1_AMP_OPTBIT(23)
+#define SUN8I_HDMI_PHY_ANA_CFG1_EMP_OPTBIT(22)
+#define SUN8I_HDMI_PHY_ANA_CFG1_AMPCK_OPT  BIT(21)
+#define SUN8I_HDMI_PHY_ANA_CFG1_EMPCK_OPT  BIT(20)
+#define SUN8I_HDMI_PHY_ANA_CFG1_ENRCAL BIT(19)
+#define SUN8I_HDMI_PHY_ANA_CFG1_ENCALOGBIT(18)
+#define SUN8I_HDMI_PHY_ANA_CFG1_REG_SCKTMDSBIT(17)
+#define SUN8I_HDMI_PHY_ANA_CFG1_TMDSCLK_EN BIT(16)
+#define SUN8I_HDMI_PHY_ANA_CFG1_TXEN_MASK  GENMASK(15, 12)
+#define SUN8I_HDMI_PHY_ANA_CFG1_TXEN_ALL   (0xf << 12)
+#define SUN8I_HDMI_PHY_ANA_CFG1_BIASEN_TMDSCLK BIT(11)
+#define SUN8I_HDMI_PHY_ANA_CFG1_BIASEN_TMDS2   BIT(10)
+#define SUN8I_HDMI_PHY_ANA_CFG1_BIASEN_TMDS1   BIT(9)
+#define SUN8I_HDMI_PHY_ANA_CFG1_BIASEN_TMDS0   BIT(8)
+#define SUN8I_HDMI_PHY_ANA_CFG1_ENP2S_TMDSCLK  BIT(7)
+#define SUN8I_HDMI_PHY_ANA_CFG1_ENP2S_TMDS2BIT(6)
+#define SUN8I_HDMI_PHY_ANA_CFG1_ENP2S_TMDS1BIT(5)
+#define SUN8I_HDMI_PHY_ANA_CFG1_ENP2S_TMDS0BIT(4)
+#define SUN8I_HDMI_PHY_ANA_CFG1_CKEN   BIT(3)
+#define SUN8I_HDMI_PHY_ANA_CFG1_LDOEN  BIT(2)
+#define SUN8I_HDMI_PHY_ANA_CFG1_ENVBS  BIT(1)
+#define SUN8I_HDMI_PHY_ANA_CFG1_ENBI   BIT(0)
+
+#define SUN8I_HDMI_PHY_ANA_CFG2_M_EN   BIT(31)
+#define SUN8I_HDMI_PHY_ANA_CFG2_PLLDBENBIT(30)
+#define SUN8I_HDMI_PHY_ANA_CFG2_SENBIT(29)
+#define SUN8I_HDMI_PHY_ANA_CFG2_REG_HPDPD  BIT(28)
+#define SUN8I_HDMI_PHY_ANA_CFG2_REG_HPDEN  BIT(27)
+#define SUN8I_HDMI_PHY_ANA_CFG2_REG_PLRCK  BIT(26)
+#define SUN8I_HDMI_PHY_ANA_CFG2_REG_PLR(x) ((x) << 23)
+#define SUN8I_HDMI_PHY_ANA_CFG2_REG_DENCK  BIT(22)
+#define SUN8I_HDMI_PHY_ANA_CFG2_REG_DENBIT(21)
+#define SUN8I_HDMI_PHY_ANA_CFG2_REG_CD(x)  ((x) << 19)
+#define SUN8I_HDMI_PHY_ANA_CFG2_REG_CKSS(x)((x) << 17)
+#define SUN8I_HDMI_PHY_ANA_CFG2_REG_BIGSWCKBIT(16)
+#define SUN8I_HDMI_PHY_ANA_CFG2_REG_BIGSW  BIT(15)
+#define SUN8I_HDMI_PHY_ANA_CFG2_REG_CSMPS(x)   ((x) << 13)
+#define SUN8I_HDMI_PHY