drm/rockchip: add support for lvds controller and external encoders
Subsystems (5)
Heiko Stuebner
maintainerv2 cover drm/rockchip: add support for lvds controller and external encoders
changes since v1:
- add separate components subdirectory
- implement the already existing bindings for adv7123 and vga-connector instead of defining a new one
- use component graph for subsequent lvds-panel or connected external encoders instead of defining special properties.
This series still adds support for the soc-level lvds encoder that also controls the generic rgb output pins. Also generic components for "dumb" vga encoders and connectors are added to a new subdirectory which implement the already existing bindings for adv7123 and vga-connector.
While the major comment from Laurent Pinchart gets addressed with these separate components, it still needs to address others like the lvds setting in dt and how to handle the atomic mode setting conversion correctly.
But I'd still like to solicit opinions if the general concept looks sane especially wrt. introducing the new components element and of_graph structure.
Tested on a firefly board using the vga connector.
Thanks
Heiko
Heiko Stuebner (10):
drm/encoder: add functionality to register encoders to a global list drm/connector: add functionality to register connectors to a global
list
drm: add components subdirectory and infrastructure drm/components: add generic vga encoder driver drm/components: add generic vga connector driver drm/rockchip: lvds: register a bridge when no panel is set drm/rockchip: enable rgb output of vops for all other connectors
ARM: dts: rockchip: add rk3288 lcdc0 pinmux settings
ARM: dts: rockchip: add rk3288 lvds node
ARM: dts: rockchip: add vga encoder and enable lvds on rk3288-firefly
Mark Yao (2):
dt-bindings: Add documentation for rockchip lvds drm/rockchip: Add support for Rockchip Soc LVDS
.../devicetree/bindings/video/rockchip-lvds.txt | 74 ++ arch/arm/boot/dts/rk3288-firefly.dtsi | 68 ++ arch/arm/boot/dts/rk3288.dtsi | 51 ++ drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/components/Kconfig | 15 + drivers/gpu/drm/components/Makefile | 4 + drivers/gpu/drm/components/vga-connector.c | 254 ++++++ drivers/gpu/drm/components/vga-encoder.c | 315 ++++++++ drivers/gpu/drm/drm_crtc.c | 82 ++ drivers/gpu/drm/rockchip/Kconfig | 9 + drivers/gpu/drm/rockchip/Makefile | 1 + drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 10 +- drivers/gpu/drm/rockchip/rockchip_lvds.c | 851 +++++++++++++++++++++ drivers/gpu/drm/rockchip/rockchip_lvds.h | 107 +++ include/drm/drm_crtc.h | 15 + 16 files changed, 1852 insertions(+), 7 deletions(-) create mode 100644 Documentation/devicetree/bindings/video/rockchip-lvds.txt create mode 100644 drivers/gpu/drm/components/Kconfig create mode 100644 drivers/gpu/drm/components/Makefile create mode 100644 drivers/gpu/drm/components/vga-connector.c create mode 100644 drivers/gpu/drm/components/vga-encoder.c create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.c create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.h
Signature · 1 line
2.1.4
Heiko Stuebner
maintainerRFC PATCH v2 1/12 drm/encoder: add functionality to register encoders to a global list
This allows standalone encoders to be registered and found again through their devicetree node when going through their connection graph.
Setting the of_node property is of course still optional, as it is not necessary in most cases to lookup encoders that are part of a bigger component.
--- drivers/gpu/drm/drm_crtc.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/drm/drm_crtc.h | 8 ++++++++ 2 files changed, 49 insertions(+)
drivers/gpu/drm/drm_crtc.c +41 -0
@@ -1066,6 +1066,47 @@ void drm_connector_unplug_all(struct drm_device *dev) }EXPORT_SYMBOL (drm_connector_unplug_all); +static DEFINE_MUTEX (encoder_lock); +static LIST_HEAD (encoder_list); + +int drm_encoder_add (struct drm_encoder *encoder) +{ +mutex_lock (&encoder_lock); +list_add_tail (&encoder->list, &encoder_list); +mutex_unlock (&encoder_lock); + +return 0 ; +} +EXPORT_SYMBOL (drm_encoder_add); + +void drm_encoder_remove (struct drm_encoder *encoder) +{ +mutex_lock (&encoder_lock); +list_del_init (&encoder->list); +mutex_unlock (&encoder_lock); +} +EXPORT_SYMBOL (drm_encoder_remove); + +#ifdef CONFIG_OF +struct drm_encoder *of_drm_find_encoder (struct device_node *np) +{ +struct drm_encoder *encoder; + +mutex_lock (&encoder_lock); + +list_for_each_entry (encoder, &encoder_list, list) { +if (encoder->of_node == np) { +mutex_unlock (&encoder_lock); +return encoder; + } + } + +mutex_unlock (&encoder_lock); +return NULL ; +} +EXPORT_SYMBOL (of_drm_find_encoder); +#endif +/** * drm_encoder_init - Init a preallocated encoder * @dev: drm device
include/drm/drm_crtc.h +8 -0
@@ -569,6 +569,7 @@ struct drm_encoder_funcs {/** * struct drm_encoder - central DRM encoder structure * @dev: parent DRM device +* @of_node: device node pointer to the bridge * @head: list management * @base: base KMS object * @name: encoder name
@@ -585,6 +586,10 @@ struct drm_encoder_funcs {*/ struct drm_encoder {struct drm_device *dev; +#ifdef CONFIG_OF +struct device_node *of_node; +#endif +struct list_head list;struct list_head head;struct drm_mode_object base;
@@ -1225,6 +1230,9 @@ extern void drm_bridge_remove(struct drm_bridge *bridge);extern struct drm_bridge *of_drm_find_bridge (struct device_node *np);extern int drm_bridge_attach (struct drm_device *dev,struct drm_bridge *bridge); +extern int drm_encoder_add (struct drm_encoder *encoder); +extern void drm_encoder_remove (struct drm_encoder *encoder); +extern struct drm_encoder *of_drm_find_encoder (struct device_node *np); extern int drm_encoder_init(struct drm_device *dev, struct drm_encoder *encoder, const struct drm_encoder_funcs *funcs,
Signature · 1 line
2.1.4
A message that is not in the archive (sent off-list or not yet received): 1427882986-19110-1-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org
RFC PATCH v2 2/12 drm/connector: add functionality to register connectors to a global list
This allows standalone connectors to be registered and found again through their devicetree node when going through their connection graph.
Setting the of_node property is of course still optional, as it is not necessary in most cases to lookup connectors that are part of a bigger component.
--- drivers/gpu/drm/drm_crtc.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/drm/drm_crtc.h | 7 +++++++ 2 files changed, 48 insertions(+)
drivers/gpu/drm/drm_crtc.c +41 -0
@@ -852,6 +852,47 @@ static void drm_connector_get_cmdline_mode(struct drm_connector *connector) mode->interlace ? " interlaced" : ""); } +static DEFINE_MUTEX (connector_lock); +static LIST_HEAD (connector_list); + +int drm_connector_add (struct drm_connector *connector) +{ +mutex_lock (&connector_lock); +list_add_tail (&connector->list, &connector_list); +mutex_unlock (&connector_lock); + +return 0 ; +} +EXPORT_SYMBOL (drm_connector_add); + +void drm_connector_remove (struct drm_connector *connector) +{ +mutex_lock (&connector_lock); +list_del_init (&connector->list); +mutex_unlock (&connector_lock); +} +EXPORT_SYMBOL (drm_connector_remove); + +#ifdef CONFIG_OF +struct drm_connector *of_drm_find_connector (struct device_node *np) +{ +struct drm_connector *connector; + +mutex_lock (&connector_lock); + +list_for_each_entry (connector, &connector_list, list) { +if (connector->of_node == np) { +mutex_unlock (&connector_lock); +return connector; + } + } + +mutex_unlock (&connector_lock); +return NULL ; +} +EXPORT_SYMBOL (of_drm_find_connector); +#endif +/** * drm_connector_init - Init a preallocated connector * @dev: DRM device
include/drm/drm_crtc.h +7 -0
@@ -671,6 +671,10 @@ struct drm_encoder {*/ struct drm_connector {struct drm_device *dev; +#ifdef CONFIG_OF +struct device_node *of_node; +#endif +struct list_head list;struct device *kdev;struct device_attribute *attr;struct list_head head;
@@ -1213,6 +1217,9 @@ static inline uint32_t drm_crtc_mask(struct drm_crtc *crtc)extern void drm_connector_ida_init (void );extern void drm_connector_ida_destroy (void ); +extern int drm_connector_add (struct drm_connector *connector); +extern void drm_connector_remove (struct drm_connector *connector); +extern struct drm_connector *of_drm_find_connector (struct device_node *np); extern int drm_connector_init(struct drm_device *dev, struct drm_connector *connector, const struct drm_connector_funcs *funcs,
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH v2 3/12 drm: add components subdirectory and infrastructure
In reply to a message not in the archiveUntil there are only the specialized bridge and i2c directories available to hold generic support code like external components. But as there are also things like external encoders that do not use i2c, those do not match all cases.
Therefore introduce a new subdirectories to hold generic components like the mentioned external encoders that can be used by component-based drm drivers.
--- drivers/gpu/drm/Kconfig | 2 ++ drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/components/Kconfig | 4 ++++ drivers/gpu/drm/components/Makefile | 1 + 4 files changed, 8 insertions(+) create mode 100644 drivers/gpu/drm/components/Kconfig create mode 100644 drivers/gpu/drm/components/Makefile
drivers/gpu/drm/Kconfig +2 -0
@@ -81,6 +81,8 @@ source "drivers/gpu/drm/i2c/Kconfig" source "drivers/gpu/drm/bridge/Kconfig" +source "drivers/gpu/drm/components/Kconfig" + config DRM_TDFX tristate "3dfx Banshee/Voodoo3+" depends on DRM && PCI
drivers/gpu/drm/Makefile +1 -0
@@ -69,3 +69,4 @@ obj-$(CONFIG_DRM_IMX) += imx/ obj-y += i2c/ obj-y += panel/ obj-y += bridge/ +obj-y += components/
drivers/gpu/drm/components/Kconfig new file +4 -0
@@ -0,0 +1,4 @@ +menu "Standalone components for use with the component framework" + depends on DRM && DRM_KMS_HELPER + +endmenu
drivers/gpu/drm/components/Makefile new file +1 -0
@@ -0,0 +1 @@ +ccflags-y := -Iinclude/drm
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH v2 5/12 drm/components: add generic vga connector driver
In reply to a message not in the archiveThis adds a driver for generic vga connectors using a system i2c-bus for ddc.
An exception is included for rcar-du which implements the vga-connector binding interally already and is not yet converted to the component framework.
--- drivers/gpu/drm/components/Kconfig | 6 + drivers/gpu/drm/components/Makefile | 1 + drivers/gpu/drm/components/vga-connector.c | 254 +++++++++++++++++++++++++++++ 3 files changed, 261 insertions(+) create mode 100644 drivers/gpu/drm/components/vga-connector.c
drivers/gpu/drm/components/Kconfig +6 -0
@@ -6,4 +6,10 @@ config DRM_COMPONENTS_VGA_ENCODER help Support for generic vga encoder chips without any special controls. +config DRM_COMPONENTS_VGA_CONNECTOR: + tristate "Generic vga connector" + help + Support for simple vga connectors using a system i2c bus + for ddc. + endmenu
drivers/gpu/drm/components/Makefile +1 -0
@@ -1,3 +1,4 @@ ccflags-y := -Iinclude/drm obj-$(CONFIG_DRM_COMPONENTS_VGA_ENCODER) += vga-encoder.o +obj-$(CONFIG_DRM_COMPONENTS_VGA_CONNECTOR) += vga-connector.o
drivers/gpu/drm/components/vga-connector.c new file +254 -0
254 lines not on this page · raw message
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH v2 7/12 drm/rockchip: Add support for Rockchip Soc LVDS
In reply to a message not in the archiveFrom: Mark Yao <[email protected]>
This adds support for Rockchip soc lvds found on rk3288
---
This still needs to address Laurent's comment about trying to get the lvds settings from the panel/connected device instead of encoding them as separate properties in the devicetree.
drivers/gpu/drm/rockchip/Kconfig | 9 + drivers/gpu/drm/rockchip/Makefile | 1 + drivers/gpu/drm/rockchip/rockchip_lvds.c | 640 +++++++++++++++++++++++++++++++ drivers/gpu/drm/rockchip/rockchip_lvds.h | 107 ++++++ 4 files changed, 757 insertions(+) create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.c create mode 100644 drivers/gpu/drm/rockchip/rockchip_lvds.h
drivers/gpu/drm/rockchip/Kconfig +9 -0
@@ -25,3 +25,12 @@ config ROCKCHIP_DW_HDMI for the Synopsys DesignWare HDMI driver. If you want to enable HDMI on RK3288 based SoC, you should selet this option. + +config ROCKCHIP_LVDS + tristate "Rockchip lvds support" + depends on DRM_ROCKCHIP + help + Choose this option to enable support for Rockchip LVDS controllers. + Rockchip rk3288 SoC has LVDS TX Controller can be used, and it + support lvds, rgb, dual lvds output mode. say Y to enable its + driver.
drivers/gpu/drm/rockchip/Makefile +1 -0
@@ -6,5 +6,6 @@ rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o rockchip_drm_fbdev.o \ rockchip_drm_gem.o obj-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o +obj-$(CONFIG_ROCKCHIP_LVDS) += rockchip_lvds.o obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o rockchip_drm_vop.o
drivers/gpu/drm/rockchip/rockchip_lvds.c new file +640 -0
640 lines not on this page · raw message
drivers/gpu/drm/rockchip/rockchip_lvds.h new file +107 -0
107 lines not on this page · raw message
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH v2 8/12 drm/rockchip: lvds: register a bridge when no panel is set
In reply to a message not in the archiveOn socs using the lvds components it also controls the use of the general rgb outputs and must thus be configured for things like external encoders.
Therefore register a drm_bridge in this case and try to find the encoder in the output port.
--- drivers/gpu/drm/rockchip/rockchip_lvds.c | 255 ++++++++++++++++++++++++++++--- 1 file changed, 233 insertions(+), 22 deletions(-)
drivers/gpu/drm/rockchip/rockchip_lvds.c +233 -22
@@ -43,6 +43,9 @@#define encoder_to_lvds (c) \ container_of(c, struct rockchip_lvds, encoder) +#define bridge_to_lvds (c) \ + container_of(c, struct rockchip_lvds, bridge) +/* * @grf_offset: offset inside the grf regmap for setting the rockchip lvds */
@@ -68,6 +71,8 @@ struct rockchip_lvds {struct drm_panel *panel;struct drm_connector connector;struct drm_encoder encoder; +struct drm_bridge bridge; +struct drm_encoder *ext_encoder;struct mutex suspend_lock;int suspend;
@@ -248,11 +253,10 @@ rockchip_lvds_encoder_mode_fixup(struct drm_encoder *encoder,return true; } -static void rockchip_lvds_encoder_mode_set (struct drm_encoder *encoder, -struct drm_display_mode *mode, -struct drm_display_mode *adjusted) +static void rockchip_lvds_mode_set (struct rockchip_lvds *lvds, +struct drm_display_mode *mode, +struct drm_display_mode *adjusted) { -struct rockchip_lvds *lvds =encoder_to_lvds (encoder);u32 h_bp = mode->htotal - mode->hsync_start;u8 pin_hsync = (mode->flags &DRM_MODE_FLAG_PHSYNC ) ?1 :0 ;u8 pin_dclk = (mode->flags &DRM_MODE_FLAG_PCSYNC ) ?1 :0 ;
@@ -347,32 +351,52 @@ static void rockchip_lvds_encoder_mode_set(struct drm_encoder *encoder,dsb (); } -static void rockchip_lvds_encoder_prepare (struct drm_encoder *encoder) +static void rockchip_lvds_encoder_mode_set (struct drm_encoder *encoder, +struct drm_display_mode *mode, +struct drm_display_mode *adjusted) +{ +rockchip_lvds_mode_set (encoder_to_lvds (encoder), mode, adjusted); +} + +static int rockchip_lvds_set_vop_source (struct rockchip_lvds *lvds, +struct drm_encoder *encoder) { -struct rockchip_lvds *lvds =encoder_to_lvds (encoder);u32 val;int ret; - ret =rockchip_drm_crtc_mode_config (encoder->crtc, - lvds->connector.connector_type, -ROCKCHIP_OUT_MODE_P888 ); -if (ret <0 ) { -dev_err (lvds->dev,"Could not set crtc mode config: %d\n" , ret); -return ; - } - ret =rockchip_drm_encoder_get_mux_id (lvds->dev->of_node, encoder);if (ret <0 ) -return ; +return ret;if (ret) val =RK3288_LVDS_SOC_CON6_SEL_VOP_LIT | (RK3288_LVDS_SOC_CON6_SEL_VOP_LIT <<16 );else val =RK3288_LVDS_SOC_CON6_SEL_VOP_LIT <<16 ; + ret =regmap_write (lvds->grf, lvds->soc_data->grf_soc_con6, val); -if (ret !=0 ) { -dev_err (lvds->dev,"Could not write to GRF: %d\n" , ret); +if (ret <0 ) +return ret; + +return 0 ; +} + +static void rockchip_lvds_encoder_prepare (struct drm_encoder *encoder) +{ +struct rockchip_lvds *lvds =encoder_to_lvds (encoder); +int ret; + + ret =rockchip_drm_crtc_mode_config (encoder->crtc, + lvds->connector.connector_type, +ROCKCHIP_OUT_MODE_P888 ); +if (ret <0 ) { +dev_err (lvds->dev,"Could not set crtc mode config: %d\n" , ret); +return ; + } + + ret =rockchip_lvds_set_vop_source (lvds, encoder); +if (ret <0 ) { +dev_err (lvds->dev,"Could not set vop source: %d\n" , ret);return ; } }
@@ -405,6 +429,97 @@ static struct drm_encoder_funcs rockchip_lvds_encoder_funcs = { .destroy = rockchip_lvds_encoder_destroy, }; +static void rockchip_lvds_bridge_mode_set (struct drm_bridge *bridge, +struct drm_display_mode *mode, +struct drm_display_mode *adjusted) +{ +rockchip_lvds_mode_set (bridge_to_lvds (bridge), mode, adjusted); +} + +static void rockchip_lvds_bridge_pre_enable (struct drm_bridge *bridge) +{ +} + +/* +* post_disable is called right after encoder prepare, so do lvds and crtc +* mode config here. +*/ +static void rockchip_lvds_bridge_post_disable (struct drm_bridge *bridge) +{ +struct rockchip_lvds *lvds =bridge_to_lvds (bridge); +struct drm_connector *connector; +int ret, connector_type = DRM_MODE_CONNECTOR_Unknown; + +if (!bridge->encoder->crtc) +return ; + +list_for_each_entry (connector, &bridge->dev->mode_config.connector_list, + head) { +if (connector->encoder == bridge->encoder) + connector_type = connector->connector_type; + } + + ret =rockchip_drm_crtc_mode_config (bridge->encoder->crtc, + connector_type, +ROCKCHIP_OUT_MODE_P888 ); +if (ret <0 ) { +dev_err (lvds->dev,"Could not set crtc mode config: %d\n" , ret); +return ; + } + + ret =rockchip_lvds_set_vop_source (lvds, bridge->encoder); +if (ret <0 ) { +dev_err (lvds->dev,"Could not set vop source: %d\n" , ret); +return ; + } +} + +static void rockchip_lvds_bridge_enable (struct drm_bridge *bridge) +{ +struct rockchip_lvds *lvds =bridge_to_lvds (bridge); +int ret; + +mutex_lock (&lvds->suspend_lock); + +if (!lvds->suspend) + goto out; + + ret =rockchip_lvds_poweron (lvds); +if (ret <0 ) { +dev_err (lvds->dev,"could not enable lvds\n" ); + goto out; + } + + lvds->suspend = false; + +out: +mutex_unlock (&lvds->suspend_lock); +} + +static void rockchip_lvds_bridge_disable (struct drm_bridge *bridge) +{ +struct rockchip_lvds *lvds =bridge_to_lvds (bridge); + +mutex_lock (&lvds->suspend_lock); + +if (lvds->suspend) + goto out; + +rockchip_lvds_poweroff (lvds); + lvds->suspend = true; + +out: +mutex_unlock (&lvds->suspend_lock); +} + +static struct drm_bridge_funcs rockchip_lvds_bridge_funcs = { + .mode_set = rockchip_lvds_bridge_mode_set, + .enable = rockchip_lvds_bridge_enable, + .disable = rockchip_lvds_bridge_disable, + .pre_enable = rockchip_lvds_bridge_pre_enable, + .post_disable = rockchip_lvds_bridge_post_disable, +}; +static struct rockchip_lvds_soc_data rk3288_lvds_data = { .grf_soc_con6 =0x025c , .grf_soc_con7 =0x0260 ,
@@ -430,6 +545,35 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master, lvds->drm_dev = drm_dev; +if (!lvds->panel) { +struct drm_bridge *bridge = &lvds->bridge; + +if (!lvds->ext_encoder->of_node) +return -ENODEV ; + + ret =component_bind_all (dev, drm_dev); +if (ret <0 ) +return ret; + +/** +* Override any possible crtcs set by the encoder itself, +* as they are connected to the lvds instead. +*/ + encoder =of_drm_find_encoder (lvds->ext_encoder->of_node); + encoder->possible_crtcs =drm_of_find_possible_crtcs (drm_dev, + dev->of_node); + + encoder->bridge = bridge; + bridge->encoder = encoder; + ret =drm_bridge_attach (drm_dev, bridge); +if (ret <0 ) { +component_unbind_all (dev, drm_dev); +return ret; + } + +return 0 ; + } + encoder = &lvds->encoder; encoder->possible_crtcs =drm_of_find_possible_crtcs (drm_dev, dev->of_node);
@@ -482,6 +626,7 @@ static void rockchip_lvds_unbind(struct device *dev, struct device *master, void *data) {struct rockchip_lvds *lvds =dev_get_drvdata (dev); +struct drm_device *drm_dev = data;if (lvds->panel) {rockchip_lvds_encoder_dpms (&lvds->encoder,DRM_MODE_DPMS_OFF );
@@ -490,6 +635,8 @@ static void rockchip_lvds_unbind(struct device *dev, struct device *master,drm_connector_cleanup (&lvds->connector);drm_encoder_cleanup (&lvds->encoder); + }else { +component_unbind_all (dev, drm_dev); } }static const struct component_ops rockchip_lvds_component_ops = {
@@ -497,6 +644,26 @@ static const struct component_ops rockchip_lvds_component_ops = { .unbind = rockchip_lvds_unbind, }; +static int compare_of (struct device *dev,void *data) +{ +return dev->of_node == data; +} + +static int rockchip_lvds_master_bind (struct device *dev) +{ +return 0 ; +} + +static void rockchip_lvds_master_unbind (struct device *dev) +{ +/* do nothing */ +} + +static const struct component_master_ops rockchip_lvds_master_ops = { + .bind = rockchip_lvds_master_bind, + .unbind = rockchip_lvds_master_unbind, +}; +static int rockchip_lvds_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -596,18 +763,58 @@ static int rockchip_lvds_probe(struct platform_device *pdev)if (!output_node) {dev_err (&pdev->dev,"no output defined\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto err_unprepare_pclk; } lvds->panel =of_drm_find_panel (output_node); -of_node_put (output_node);if (!lvds->panel) { -dev_err (&pdev->dev,"panel not found\n" ); -return -EPROBE_DEFER ; +struct drm_encoder *encoder; +struct component_match *match =NULL ; + +/* Try to find an encoder in the output node */ + encoder =of_drm_find_encoder (output_node); +if (!encoder) { +dev_err (&pdev->dev,"neither panel nor encoder found\n" ); +of_node_put (output_node); + ret = -EPROBE_DEFER ; + goto err_unprepare_pclk; + } + + lvds->ext_encoder = encoder; + +component_match_add (dev, &match, compare_of, output_node); +of_node_put (output_node); + + lvds->bridge.funcs = &rockchip_lvds_bridge_funcs; + lvds->bridge.of_node = dev->of_node; + ret =drm_bridge_add (&lvds->bridge); +if (ret) { +dev_err (&pdev->dev,"failed to add bridge %d\n" , ret); + goto err_unprepare_pclk; + } + + ret =component_master_add_with_match (dev, + &rockchip_lvds_master_ops, + match); +if (ret <0 ) + goto err_bridge_remove; + }else { +of_node_put (output_node); } -return component_add (&pdev->dev, &rockchip_lvds_component_ops); + ret =component_add (&pdev->dev, &rockchip_lvds_component_ops); +if (ret <0 ) + goto err_master_remove; + +return 0 ; +err_master_remove: +if (!lvds->panel) +component_master_del (&pdev->dev, &rockchip_lvds_master_ops); +err_bridge_remove: +if (!lvds->panel) +drm_bridge_remove (&lvds->bridge); err_unprepare_pclk:clk_unprepare (lvds->pclk);return ret;
@@ -618,6 +825,10 @@ static int rockchip_lvds_remove(struct platform_device *pdev)struct rockchip_lvds *lvds =dev_get_drvdata (&pdev->dev);component_del (&pdev->dev, &rockchip_lvds_component_ops); +if (!lvds->panel) { +component_master_del (&pdev->dev, &rockchip_lvds_master_ops); +drm_bridge_remove (&lvds->bridge); + }clk_unprepare (lvds->pclk);
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Heiko Stuebner
maintainerRFC PATCH v2 4/12 drm/components: add generic vga encoder driver
In reply to Heiko StuebnerThis adds a driver for generic vga encoders like the Analog Devices adv7123 and similar ics. These chips do not have any special configuration options except a powersafe gpio.
An exception is added for the rcar-du driver which also implements support for the adv7123 internally but is not yet converted to the component framework.
--- drivers/gpu/drm/components/Kconfig | 5 + drivers/gpu/drm/components/Makefile | 2 + drivers/gpu/drm/components/vga-encoder.c | 315 +++++++++++++++++++++++++++++++ 3 files changed, 322 insertions(+) create mode 100644 drivers/gpu/drm/components/vga-encoder.c
drivers/gpu/drm/components/Kconfig +5 -0
@@ -1,4 +1,9 @@ menu "Standalone components for use with the component framework" depends on DRM && DRM_KMS_HELPER +config DRM_COMPONENTS_VGA_ENCODER + tristate "Generic vga encoder" + help + Support for generic vga encoder chips without any special controls. + endmenu
drivers/gpu/drm/components/Makefile +2 -0
@@ -1 +1,3 @@ ccflags-y := -Iinclude/drm + +obj-$(CONFIG_DRM_COMPONENTS_VGA_ENCODER) += vga-encoder.o
drivers/gpu/drm/components/vga-encoder.c new file +315 -0
315 lines not on this page · raw message
Signature · 1 line
2.1.4
A message that is not in the archive (sent off-list or not yet received): 1427882986-19110-5-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org
Re: [PATCH RFC v2 04/12] drm/components: add generic vga encoder driver
Quoted 6 lines · Heiko Stuebner
This adds a driver for generic vga encoders like the Analog Devices adv7123 and similar ics. These chips do not have any special configuration options except a powersafe gpio.
An exception is added for the rcar-du driver which also implements support for the adv7123 internally but is not yet converted to the component framework.
Why is this implemented as a master? It's not the top level card device, it shouldn't be a master. It should be a component.
I wonder if this is why you need your previous patches. Componentised DRM works fine without needing to build lists of connectors and encoders.
Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up according to speedtest.net.
Heiko Stübner
maintainerRe: [PATCH RFC v2 04/12] drm/components: add generic vga encoder driver
Hi Russell,
Am Mittwoch, 1. April 2015, 11:27:51 schrieb Russell King - ARM Linux:
Quoted 6 lines · Heiko Stuebner
Quoted 5 lines
This adds a driver for generic vga encoders like the Analog Devices adv7123
and similar ics. These chips do not have any special configuration options except a powersafe gpio.
Quoted 8 lines
Quoted 3 lines
An exception is added for the rcar-du driver which also implements support for the adv7123 internally but is not yet converted to the component framework.
Why is this implemented as a master? It's not the top level card device, it shouldn't be a master. It should be a component.
I wonder if this is why you need your previous patches. Componentised DRM works fine without needing to build lists of connectors and encoders.
It is a component to the upper drm driver (rockchip or whatever) but a master to the vga connector below, simply because the drm driver above (the lvds controller in this case) does not know and also probably shouldn't care what the structure below is.
So in this case the lvds knows there is either a panel or an encoder connected, but does not need to handle if this downstream component is some one-piece i2c component like a tv encoder or contains another component down below, like the vga-connector in this case.
Of course I may very well have overlooked some simpler method to achieve this, but got inspired to this by the similar way done in sti/sti_tvout.c
Heiko
Heiko Stuebner
maintainerRFC PATCH v2 6/12 dt-bindings: Add documentation for rockchip lvds
In reply to Heiko StuebnerFrom: Mark Yao <[email protected]>
Add binding documentation for Rockchip SoC LVDS driver.
--- .../devicetree/bindings/video/rockchip-lvds.txt | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Documentation/devicetree/bindings/video/rockchip-lvds.txt
Documentation/devicetree/bindings/video/rockchip-lvds.txt new file +74 -0
@@ -0,0 +1,74 @@ +Rockchip RK3288 LVDS interface +================================ + +Required properties: +- compatible: "rockchip,rk3288-lvds"; + +- reg: physical base address of the controller and length + of memory mapped region. +- clocks: must include clock specifiers corresponding to entries in the + clock-names property. +- clock-names: must contain "pclk_lvds" + +- avdd1v0-supply: regulator phandle for 1.0V analog power +- avdd1v8-supply: regulator phandle for 1.8V analog power +- avdd3v3-supply: regulator phandle for 3.3V analog power + +- rockchip,grf: phandle to the general register files syscon + +- rockchip,data-mapping: should be "vesa" or "jeida", + This describes how the color bits are laid out in the + serialized LVDS signal. +- rockchip,data-width : should be <18> or <24>; +- rockchip,output: should be "rgb", "lvds" or "duallvds", + This describes the output face. + +Required nodes: + +The lvds has two video ports as described by + Documentation/devicetree/bindings/media/video-interfaces.txt. +Their connections are modeled using the OF graph bindings specified in + Documentation/devicetree/bindings/graph.txt. + +- video port 0 for the VOP inputs +- video port 1 for either a panel or subsequent encoder + +Example: + lvds: lvds at ff96c000 { + compatible = "rockchip,rk3288-lvds"; + rockchip,grf = <&grf>; + reg = <0xff96c000 0x4000>; + clocks = <&cru PCLK_LVDS_PHY>; + clock-names = "pclk_lvds"; + avdd1v0-supply = <&vdd10_lcd>; + avdd1v8-supply = <&vcc18_lcd>; + avdd3v3-supply = <&vcca_33>; + rockchip,data-mapping = "jeida"; + rockchip,data-width = <24>; + rockchip,output = "rgb"; + ports { + #address-cells = <1>; + #size-cells = <0>; + + lvds_in: port at 0 { + reg = <0>; + + lvds_in_vopb: endpoint at 0 { + reg = <0>; + remote-endpoint = <&vopb_out_lvds>; + }; + lvds_in_vopl: endpoint at 1 { + reg = <1>; + remote-endpoint = <&vopl_out_lvds>; + }; + }; + + lvds_out: port at 1 { + reg = <1>; + + lvds_out_panel: endpoint { + remote-endpoint = <&panel_in>; + }; + }; + }; + };
Signature · 1 line
2.1.4
Heiko Stuebner
maintainerRFC PATCH v2 9/12 drm/rockchip: enable rgb output of vops for all other connectors
In reply to Heiko StuebnerThe socs itself contains encoders for a lot of different outputs. But every unsupported connector will be routed through the lvds, as it controls the pins in question.
Therefore enable the lvds output for all of those.
--- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +3 -7
@@ -862,20 +862,16 @@ static int vop_crtc_mode_set(struct drm_crtc *crtc,clk_disable (vop->dclk);switch (vop->connector_type) { -case DRM_MODE_CONNECTOR_LVDS : -VOP_CTRL_SET (vop, rgb_en,1 ); -break ;case DRM_MODE_CONNECTOR_eDP:VOP_CTRL_SET (vop, edp_en,1 );break ;case DRM_MODE_CONNECTOR_HDMIA :VOP_CTRL_SET (vop, hdmi_en,1 );break ; +case DRM_MODE_CONNECTOR_LVDS :default : -DRM_ERROR ("unsupport connector_type[%d]\n" , - vop->connector_type); - ret = -EINVAL ; - goto out; +VOP_CTRL_SET (vop, rgb_en,1 ); +break ; };VOP_CTRL_SET (vop, out_mode, vop->connector_out_mode);
Signature · 1 line
2.1.4
Heiko Stuebner
maintainerRFC PATCH v2 10/12 ARM: dts: rockchip: add rk3288 lcdc0 pinmux settings
In reply to Heiko StuebnerAdd pinctrl settings for the configurable lcdc0 signals dclk, den, hsync and vsync. The lcdc0 data pin configuration is not software controlable.
--- arch/arm/boot/dts/rk3288.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm/boot/dts/rk3288.dtsi +9 -0
@@ -945,6 +945,15 @@ }; }; + lcdc0 { + lcdc0_ctl: lcdc0-ctl { + rockchip,pins = <1 24 RK_FUNC_1 &pcfg_pull_none>, + <1 25 RK_FUNC_1 &pcfg_pull_none>, + <1 26 RK_FUNC_1 &pcfg_pull_none>, + <1 27 RK_FUNC_1 &pcfg_pull_none>; + }; + }; + sdmmc { sdmmc_clk: sdmmc-clk { rockchip,pins = <6 20 RK_FUNC_1 &pcfg_pull_none>;
Signature · 1 line
2.1.4
Heiko Stuebner
maintainerRFC PATCH v2 11/12 ARM: dts: rockchip: add rk3288 lvds node
In reply to Heiko StuebnerAdd the basic node for the lvds controller of rk3288 and hook it into the display-subsystem hirarchy.
--- arch/arm/boot/dts/rk3288.dtsi | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
arch/arm/boot/dts/rk3288.dtsi +42 -0
@@ -621,6 +621,11 @@ reg = <0>; remote-endpoint = <&hdmi_in_vopb>; }; + + vopb_out_lvds: endpoint at 1 { + reg = <1>; + remote-endpoint = <&lvds_in_vopb>; + }; }; };
@@ -652,6 +657,11 @@ reg = <0>; remote-endpoint = <&hdmi_in_vopl>; }; + + vopl_out_lvds: endpoint at 1 { + reg = <1>; + remote-endpoint = <&lvds_in_vopl>; + }; }; };
@@ -664,6 +674,38 @@ status = "disabled"; }; + lvds: lvds at ff96c000 { + compatible = "rockchip,rk3288-lvds"; + reg = <0xff96c000 0x4000>; + clocks = <&cru PCLK_LVDS_PHY>; + clock-names = "pclk_lvds"; + pinctrl-names = "default"; + pinctrl-0 = <&lcdc0_ctl>; + rockchip,grf = <&grf>; + status = "disabled"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + lvds_in: port at 0 { + reg = <0>; + + #address-cells = <1>; + #size-cells = <0>; + + lvds_in_vopb: endpoint at 0 { + reg = <0>; + remote-endpoint = <&vopb_out_lvds>; + }; + lvds_in_vopl: endpoint at 1 { + reg = <1>; + remote-endpoint = <&vopl_out_lvds>; + }; + }; + }; + }; + hdmi: hdmi at ff980000 { compatible = "rockchip,rk3288-dw-hdmi"; reg = <0xff980000 0x20000>;
Signature · 1 line
2.1.4
Heiko Stuebner
maintainerRFC PATCH v2 12/12 ARM: dts: rockchip: add vga encoder and enable lvds on rk3288-firefly
In reply to Heiko StuebnerAdd the sda7123 simple vga encoder, connect it to the vop outputs and enable the lvds controller with the correct settings.
--- arch/arm/boot/dts/rk3288-firefly.dtsi | 68 +++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+)
arch/arm/boot/dts/rk3288-firefly.dtsi +68 -0
@@ -159,6 +159,51 @@ regulator-always-on; vin-supply = <&vcc_5v>; }; + + sda7123: vga-encoder { + compatible = "adi,adv7123"; + psave-gpios = <&gpio0 17 GPIO_ACTIVE_HIGH>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port at 0 { + reg = <0>; + + #address-cells = <1>; + #size-cells = <0>; + + sda7123_in: endpoint at 0 { + remote-endpoint = <&lvds_out>; + }; + }; + + port at 1 { + reg = <1>; + + #address-cells = <1>; + #size-cells = <0>; + + sda7123_out: endpoint at 0 { + remote-endpoint = <&vga_connector_in>; + }; + }; + }; + }; + + vga: vga-connector { + compatible = "vga-connector"; + label = "vga"; + + ddc-i2c-bus = <&i2c4>; + + port { + vga_connector_in: endpoint { + remote-endpoint = <&sda7123_out>; + }; + }; + }; }; &cpu0 {
@@ -347,6 +392,29 @@ status = "okay"; }; +&lvds { + avdd1v0-supply = <&vdd10_lcd>; + avdd1v8-supply = <&vcc18_lcd>; + avdd3v3-supply = <&vcca_33>; + rockchip,data-mapping = "jeida"; + rockchip,data-width = <24>; + rockchip,output = "rgb"; + status = "okay"; + + ports { + port at 1 { + reg = <1>; + + #address-cells = <1>; + #size-cells = <0>; + + lvds_out: endpoint at 0 { + remote-endpoint = <&sda7123_in>; + }; + }; + }; +}; + &pinctrl { pcfg_output_high: pcfg-output-high { output-high;
Signature · 1 line
2.1.4