diff options
| author | Ajay Kumar <ajaykumar.rs@samsung.com> | 2015-01-20 11:38:47 -0500 |
|---|---|---|
| committer | Thierry Reding <treding@nvidia.com> | 2015-01-28 02:47:29 -0500 |
| commit | 5bbb9a2ef87a9c62fc7ce89337a2aa90802be080 (patch) | |
| tree | c9f16d9d5a6a086d0f29b72050ae9ab7618570e6 /drivers/gpu | |
| parent | 801855671ad1dc751aa5aa66047cfe314170a566 (diff) | |
drm/bridge: ptn3460: support drm_panel
Add drm_panel calls to the driver to make the panel and
bridge work together in tandem.
Signed-off-by: Ajay Kumar <ajaykumar.rs@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Tested-by: Rahul Sharma <rahul.sharma@samsung.com>
Tested-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Tested-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Tested-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'drivers/gpu')
| -rw-r--r-- | drivers/gpu/drm/bridge/Kconfig | 1 | ||||
| -rw-r--r-- | drivers/gpu/drm/bridge/ptn3460.c | 42 |
2 files changed, 43 insertions, 0 deletions
diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index ffa3e061a618..f38bbcdf929b 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig | |||
| @@ -8,5 +8,6 @@ config DRM_PTN3460 | |||
| 8 | depends on DRM | 8 | depends on DRM |
| 9 | depends on OF | 9 | depends on OF |
| 10 | select DRM_KMS_HELPER | 10 | select DRM_KMS_HELPER |
| 11 | select DRM_PANEL | ||
| 11 | ---help--- | 12 | ---help--- |
| 12 | ptn3460 eDP-LVDS bridge chip driver. | 13 | ptn3460 eDP-LVDS bridge chip driver. |
diff --git a/drivers/gpu/drm/bridge/ptn3460.c b/drivers/gpu/drm/bridge/ptn3460.c index 7adeb607f6fb..e6d5ae741a41 100644 --- a/drivers/gpu/drm/bridge/ptn3460.c +++ b/drivers/gpu/drm/bridge/ptn3460.c | |||
| @@ -19,6 +19,9 @@ | |||
| 19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
| 20 | #include <linux/of.h> | 20 | #include <linux/of.h> |
| 21 | #include <linux/of_gpio.h> | 21 | #include <linux/of_gpio.h> |
| 22 | #include <linux/of_graph.h> | ||
| 23 | |||
| 24 | #include <drm/drm_panel.h> | ||
| 22 | 25 | ||
| 23 | #include "bridge/ptn3460.h" | 26 | #include "bridge/ptn3460.h" |
| 24 | 27 | ||
| @@ -38,6 +41,7 @@ struct ptn3460_bridge { | |||
| 38 | struct i2c_client *client; | 41 | struct i2c_client *client; |
| 39 | struct drm_bridge bridge; | 42 | struct drm_bridge bridge; |
| 40 | struct edid *edid; | 43 | struct edid *edid; |
| 44 | struct drm_panel *panel; | ||
| 41 | int gpio_pd_n; | 45 | int gpio_pd_n; |
| 42 | int gpio_rst_n; | 46 | int gpio_rst_n; |
| 43 | u32 edid_emulation; | 47 | u32 edid_emulation; |
| @@ -137,6 +141,11 @@ static void ptn3460_pre_enable(struct drm_bridge *bridge) | |||
| 137 | gpio_set_value(ptn_bridge->gpio_rst_n, 1); | 141 | gpio_set_value(ptn_bridge->gpio_rst_n, 1); |
| 138 | } | 142 | } |
| 139 | 143 | ||
| 144 | if (drm_panel_prepare(ptn_bridge->panel)) { | ||
| 145 | DRM_ERROR("failed to prepare panel\n"); | ||
| 146 | return; | ||
| 147 | } | ||
| 148 | |||
| 140 | /* | 149 | /* |
| 141 | * There's a bug in the PTN chip where it falsely asserts hotplug before | 150 | * There's a bug in the PTN chip where it falsely asserts hotplug before |
| 142 | * it is fully functional. We're forced to wait for the maximum start up | 151 | * it is fully functional. We're forced to wait for the maximum start up |
| @@ -153,6 +162,12 @@ static void ptn3460_pre_enable(struct drm_bridge *bridge) | |||
| 153 | 162 | ||
| 154 | static void ptn3460_enable(struct drm_bridge *bridge) | 163 | static void ptn3460_enable(struct drm_bridge *bridge) |
| 155 | { | 164 | { |
| 165 | struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge); | ||
| 166 | |||
| 167 | if (drm_panel_enable(ptn_bridge->panel)) { | ||
| 168 | DRM_ERROR("failed to enable panel\n"); | ||
| 169 | return; | ||
| 170 | } | ||
| 156 | } | 171 | } |
| 157 | 172 | ||
| 158 | static void ptn3460_disable(struct drm_bridge *bridge) | 173 | static void ptn3460_disable(struct drm_bridge *bridge) |
| @@ -164,6 +179,11 @@ static void ptn3460_disable(struct drm_bridge *bridge) | |||
| 164 | 179 | ||
| 165 | ptn_bridge->enabled = false; | 180 | ptn_bridge->enabled = false; |
| 166 | 181 | ||
| 182 | if (drm_panel_disable(ptn_bridge->panel)) { | ||
| 183 | DRM_ERROR("failed to disable panel\n"); | ||
| 184 | return; | ||
| 185 | } | ||
| 186 | |||
| 167 | if (gpio_is_valid(ptn_bridge->gpio_rst_n)) | 187 | if (gpio_is_valid(ptn_bridge->gpio_rst_n)) |
| 168 | gpio_set_value(ptn_bridge->gpio_rst_n, 1); | 188 | gpio_set_value(ptn_bridge->gpio_rst_n, 1); |
| 169 | 189 | ||
| @@ -173,6 +193,12 @@ static void ptn3460_disable(struct drm_bridge *bridge) | |||
| 173 | 193 | ||
| 174 | static void ptn3460_post_disable(struct drm_bridge *bridge) | 194 | static void ptn3460_post_disable(struct drm_bridge *bridge) |
| 175 | { | 195 | { |
| 196 | struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge); | ||
| 197 | |||
| 198 | if (drm_panel_unprepare(ptn_bridge->panel)) { | ||
| 199 | DRM_ERROR("failed to unprepare panel\n"); | ||
| 200 | return; | ||
| 201 | } | ||
| 176 | } | 202 | } |
| 177 | 203 | ||
| 178 | static int ptn3460_get_modes(struct drm_connector *connector) | 204 | static int ptn3460_get_modes(struct drm_connector *connector) |
| @@ -267,6 +293,9 @@ int ptn3460_bridge_attach(struct drm_bridge *bridge) | |||
| 267 | drm_mode_connector_attach_encoder(&ptn_bridge->connector, | 293 | drm_mode_connector_attach_encoder(&ptn_bridge->connector, |
| 268 | bridge->encoder); | 294 | bridge->encoder); |
| 269 | 295 | ||
| 296 | if (ptn_bridge->panel) | ||
| 297 | drm_panel_attach(ptn_bridge->panel, &ptn_bridge->connector); | ||
| 298 | |||
| 270 | return ret; | 299 | return ret; |
| 271 | } | 300 | } |
| 272 | 301 | ||
| @@ -283,6 +312,7 @@ static int ptn3460_probe(struct i2c_client *client, | |||
| 283 | { | 312 | { |
| 284 | struct device *dev = &client->dev; | 313 | struct device *dev = &client->dev; |
| 285 | struct ptn3460_bridge *ptn_bridge; | 314 | struct ptn3460_bridge *ptn_bridge; |
| 315 | struct device_node *endpoint, *panel_node; | ||
| 286 | int ret; | 316 | int ret; |
| 287 | 317 | ||
| 288 | ptn_bridge = devm_kzalloc(dev, sizeof(*ptn_bridge), GFP_KERNEL); | 318 | ptn_bridge = devm_kzalloc(dev, sizeof(*ptn_bridge), GFP_KERNEL); |
| @@ -290,6 +320,17 @@ static int ptn3460_probe(struct i2c_client *client, | |||
| 290 | return -ENOMEM; | 320 | return -ENOMEM; |
| 291 | } | 321 | } |
| 292 | 322 | ||
| 323 | endpoint = of_graph_get_next_endpoint(dev->of_node, NULL); | ||
| 324 | if (endpoint) { | ||
| 325 | panel_node = of_graph_get_remote_port_parent(endpoint); | ||
| 326 | if (panel_node) { | ||
| 327 | ptn_bridge->panel = of_drm_find_panel(panel_node); | ||
| 328 | of_node_put(panel_node); | ||
| 329 | if (!ptn_bridge->panel) | ||
| 330 | return -EPROBE_DEFER; | ||
| 331 | } | ||
| 332 | } | ||
| 333 | |||
| 293 | ptn_bridge->client = client; | 334 | ptn_bridge->client = client; |
| 294 | ptn_bridge->gpio_pd_n = of_get_named_gpio(dev->of_node, | 335 | ptn_bridge->gpio_pd_n = of_get_named_gpio(dev->of_node, |
| 295 | "powerdown-gpio", 0); | 336 | "powerdown-gpio", 0); |
| @@ -327,6 +368,7 @@ static int ptn3460_probe(struct i2c_client *client, | |||
| 327 | } | 368 | } |
| 328 | 369 | ||
| 329 | ptn_bridge->bridge.funcs = &ptn3460_bridge_funcs; | 370 | ptn_bridge->bridge.funcs = &ptn3460_bridge_funcs; |
| 371 | ptn_bridge->bridge.of_node = dev->of_node; | ||
| 330 | ret = drm_bridge_add(&ptn_bridge->bridge); | 372 | ret = drm_bridge_add(&ptn_bridge->bridge); |
| 331 | if (ret) { | 373 | if (ret) { |
| 332 | DRM_ERROR("Failed to add bridge\n"); | 374 | DRM_ERROR("Failed to add bridge\n"); |
