Re: [U-Boot] [PATCH v4 05/15] dm: Add a dsi host uclass

2019-09-16 Thread Simon Glass
Hi,

On Fri, 13 Sep 2019 at 02:48, Yannick Fertré  wrote:
>
> DSI host can usefully be modelled as their own uclass.

What is DSI?

>
> Signed-off-by: Yannick Fertré 
> ---
>  arch/sandbox/dts/sandbox.dts |  6 ++-
>  configs/sandbox_defconfig|  1 +
>  drivers/video/Kconfig|  7 
>  drivers/video/Makefile   |  2 +
>  drivers/video/dsi-host-uclass.c  | 39 +++
>  drivers/video/sandbox_dsi_host.c | 83 
> 
>  include/dm/uclass-id.h   |  1 +
>  include/dsi_host.h   | 57 +++
>  test/dm/Makefile |  1 +
>  test/dm/dsi_host.c   | 58 
>  10 files changed, 254 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/video/dsi-host-uclass.c
>  create mode 100644 drivers/video/sandbox_dsi_host.c
>  create mode 100644 include/dsi_host.h
>  create mode 100644 test/dm/dsi_host.c
>
> diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
> index 16a33db..f1637c8 100644
> --- a/arch/sandbox/dts/sandbox.dts
> +++ b/arch/sandbox/dts/sandbox.dts
> @@ -25,6 +25,11 @@
> compatible = "google,cros-ec-sandbox";
> };
>
> +   dsi_host: dsi_host {
> +   compatible = "sandbox,dsi-host";
> +   status = "okay";
> +   };
> +
> ethrawbus {
> compatible = "sandbox,eth-raw-bus";
> skip-localhost = <0>;
> @@ -63,7 +68,6 @@
> compatible = "sandbox,spi";
> cs-gpios = <0>, <&gpio_a 0>;
> };
> -
>  };
>
>  #include "sandbox.dtsi"
> diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
> index 7355e3a..90f3e26 100644
> --- a/configs/sandbox_defconfig
> +++ b/configs/sandbox_defconfig
> @@ -205,6 +205,7 @@ CONFIG_CONSOLE_ROTATION=y
>  CONFIG_CONSOLE_TRUETYPE=y
>  CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
>  CONFIG_VIDEO_SANDBOX_SDL=y
> +CONFIG_VIDEO_DSI_HOST_SANDBOX=y
>  CONFIG_OSD=y
>  CONFIG_SANDBOX_OSD=y
>  CONFIG_W1=y
> diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
> index 36f666e..554b7db 100644
> --- a/drivers/video/Kconfig
> +++ b/drivers/video/Kconfig
> @@ -686,6 +686,13 @@ config VIDEO_DW_HDMI
>   rather requires a SoC-specific glue driver to call it), it
>   can not be enabled from the configuration menu.
>
> +config VIDEO_DSI_HOST_SANDBOX
> +   bool "Enable sandbox for dsi host"

What is DSI?

> +   depends on SANDBOX
> +   help
> + Enable support for sandbox dsi host device used for testing
> + purposes.

Should have help here explaining what DSI is

> +
>  config VIDEO_SIMPLE
> bool "Simple display driver for preconfigured display"
> help
> diff --git a/drivers/video/Makefile b/drivers/video/Makefile
> index 7df9b0b..5ed3590 100644
> --- a/drivers/video/Makefile
> +++ b/drivers/video/Makefile
> @@ -11,6 +11,7 @@ obj-$(CONFIG_CONSOLE_ROTATION) += console_rotate.o
>  obj-$(CONFIG_CONSOLE_TRUETYPE) += console_truetype.o fonts/
>  obj-$(CONFIG_DISPLAY) += display-uclass.o
>  obj-$(CONFIG_DM_VIDEO) += backlight-uclass.o
> +obj-$(CONFIG_DM_VIDEO) += dsi-host-uclass.o
>  obj-$(CONFIG_DM_VIDEO) += panel-uclass.o simple_panel.o
>  obj-$(CONFIG_DM_VIDEO) += video-uclass.o vidconsole-uclass.o
>  obj-$(CONFIG_DM_VIDEO) += video_bmp.o
> @@ -58,6 +59,7 @@ obj-$(CONFIG_VIDEO_MVEBU) += mvebu_lcd.o
>  obj-$(CONFIG_VIDEO_MX3) += mx3fb.o videomodes.o
>  obj-$(CONFIG_VIDEO_MXS) += mxsfb.o videomodes.o
>  obj-$(CONFIG_VIDEO_OMAP3) += omap3_dss.o
> +obj-$(CONFIG_VIDEO_DSI_HOST_SANDBOX) += sandbox_dsi_host.o
>  obj-$(CONFIG_VIDEO_SANDBOX_SDL) += sandbox_sdl.o
>  obj-$(CONFIG_VIDEO_SIMPLE) += simplefb.o
>  obj-$(CONFIG_VIDEO_TEGRA20) += tegra.o
> diff --git a/drivers/video/dsi-host-uclass.c b/drivers/video/dsi-host-uclass.c
> new file mode 100644
> index 000..1db1f88
> --- /dev/null
> +++ b/drivers/video/dsi-host-uclass.c
> @@ -0,0 +1,39 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2019 STMicroelectronics - All Rights Reserved
> + * Author(s): Yannick Fertre  for STMicroelectronics.
> + *
> + */
> +
> +#include 
> +#include 
> +#include 
> +
> +int dsi_host_init(struct udevice *dev,
> + struct mipi_dsi_device *device,
> + struct display_timing *timings,
> + unsigned int max_data_lanes,
> + const struct mipi_dsi_phy_ops *phy_ops)
> +{
> +   struct dsi_host_ops *ops = dsi_host_get_ops(dev);
> +
> +   if (!ops->init)
> +   return -ENOSYS;
> +
> +   return ops->init(dev, device, timings, max_data_lanes, phy_ops);
> +}
> +
> +int dsi_host_enable(struct udevice *dev)
> +{
> +   struct dsi_host_ops *ops = dsi_host_get_ops(dev);
> +
> +   if (!ops->enable)
> +   return -ENOSYS;
> +
> +   return ops->enable(dev);
> +}
> +
> +UCLASS_DRIVER(dsi_host) = {
> +   .id = UCLASS_DSI_HOST,
> +   .name

[U-Boot] [PATCH v4 05/15] dm: Add a dsi host uclass

2019-09-13 Thread Yannick Fertré
DSI host can usefully be modelled as their own uclass.

Signed-off-by: Yannick Fertré 
---
 arch/sandbox/dts/sandbox.dts |  6 ++-
 configs/sandbox_defconfig|  1 +
 drivers/video/Kconfig|  7 
 drivers/video/Makefile   |  2 +
 drivers/video/dsi-host-uclass.c  | 39 +++
 drivers/video/sandbox_dsi_host.c | 83 
 include/dm/uclass-id.h   |  1 +
 include/dsi_host.h   | 57 +++
 test/dm/Makefile |  1 +
 test/dm/dsi_host.c   | 58 
 10 files changed, 254 insertions(+), 1 deletion(-)
 create mode 100644 drivers/video/dsi-host-uclass.c
 create mode 100644 drivers/video/sandbox_dsi_host.c
 create mode 100644 include/dsi_host.h
 create mode 100644 test/dm/dsi_host.c

diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index 16a33db..f1637c8 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -25,6 +25,11 @@
compatible = "google,cros-ec-sandbox";
};
 
+   dsi_host: dsi_host {
+   compatible = "sandbox,dsi-host";
+   status = "okay";
+   };
+
ethrawbus {
compatible = "sandbox,eth-raw-bus";
skip-localhost = <0>;
@@ -63,7 +68,6 @@
compatible = "sandbox,spi";
cs-gpios = <0>, <&gpio_a 0>;
};
-
 };
 
 #include "sandbox.dtsi"
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 7355e3a..90f3e26 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -205,6 +205,7 @@ CONFIG_CONSOLE_ROTATION=y
 CONFIG_CONSOLE_TRUETYPE=y
 CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
 CONFIG_VIDEO_SANDBOX_SDL=y
+CONFIG_VIDEO_DSI_HOST_SANDBOX=y
 CONFIG_OSD=y
 CONFIG_SANDBOX_OSD=y
 CONFIG_W1=y
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 36f666e..554b7db 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -686,6 +686,13 @@ config VIDEO_DW_HDMI
  rather requires a SoC-specific glue driver to call it), it
  can not be enabled from the configuration menu.
 
+config VIDEO_DSI_HOST_SANDBOX
+   bool "Enable sandbox for dsi host"
+   depends on SANDBOX
+   help
+ Enable support for sandbox dsi host device used for testing
+ purposes.
+
 config VIDEO_SIMPLE
bool "Simple display driver for preconfigured display"
help
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 7df9b0b..5ed3590 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_CONSOLE_ROTATION) += console_rotate.o
 obj-$(CONFIG_CONSOLE_TRUETYPE) += console_truetype.o fonts/
 obj-$(CONFIG_DISPLAY) += display-uclass.o
 obj-$(CONFIG_DM_VIDEO) += backlight-uclass.o
+obj-$(CONFIG_DM_VIDEO) += dsi-host-uclass.o
 obj-$(CONFIG_DM_VIDEO) += panel-uclass.o simple_panel.o
 obj-$(CONFIG_DM_VIDEO) += video-uclass.o vidconsole-uclass.o
 obj-$(CONFIG_DM_VIDEO) += video_bmp.o
@@ -58,6 +59,7 @@ obj-$(CONFIG_VIDEO_MVEBU) += mvebu_lcd.o
 obj-$(CONFIG_VIDEO_MX3) += mx3fb.o videomodes.o
 obj-$(CONFIG_VIDEO_MXS) += mxsfb.o videomodes.o
 obj-$(CONFIG_VIDEO_OMAP3) += omap3_dss.o
+obj-$(CONFIG_VIDEO_DSI_HOST_SANDBOX) += sandbox_dsi_host.o
 obj-$(CONFIG_VIDEO_SANDBOX_SDL) += sandbox_sdl.o
 obj-$(CONFIG_VIDEO_SIMPLE) += simplefb.o
 obj-$(CONFIG_VIDEO_TEGRA20) += tegra.o
diff --git a/drivers/video/dsi-host-uclass.c b/drivers/video/dsi-host-uclass.c
new file mode 100644
index 000..1db1f88
--- /dev/null
+++ b/drivers/video/dsi-host-uclass.c
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 STMicroelectronics - All Rights Reserved
+ * Author(s): Yannick Fertre  for STMicroelectronics.
+ *
+ */
+
+#include 
+#include 
+#include 
+
+int dsi_host_init(struct udevice *dev,
+ struct mipi_dsi_device *device,
+ struct display_timing *timings,
+ unsigned int max_data_lanes,
+ const struct mipi_dsi_phy_ops *phy_ops)
+{
+   struct dsi_host_ops *ops = dsi_host_get_ops(dev);
+
+   if (!ops->init)
+   return -ENOSYS;
+
+   return ops->init(dev, device, timings, max_data_lanes, phy_ops);
+}
+
+int dsi_host_enable(struct udevice *dev)
+{
+   struct dsi_host_ops *ops = dsi_host_get_ops(dev);
+
+   if (!ops->enable)
+   return -ENOSYS;
+
+   return ops->enable(dev);
+}
+
+UCLASS_DRIVER(dsi_host) = {
+   .id = UCLASS_DSI_HOST,
+   .name   = "dsi_host",
+};
diff --git a/drivers/video/sandbox_dsi_host.c b/drivers/video/sandbox_dsi_host.c
new file mode 100644
index 000..ee01ed1
--- /dev/null
+++ b/drivers/video/sandbox_dsi_host.c
@@ -0,0 +1,83 @@
+// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
+/*
+ * Copyright (C) 2019, STMicroelectronics - All Rights Reserved
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+struct