aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRahul Sharma <rahul.sharma@samsung.com>2012-10-04 11:18:55 -0400
committerInki Dae <inki.dae@samsung.com>2012-10-05 06:15:14 -0400
commit22c4f428979521f3ba3398a1eb5c0be07396f357 (patch)
treea50021add0f143805be60eb6fd53cad622b4ffba /drivers
parent5a325071a0ac9636f07d6328bafc9e42ce13752c (diff)
drm: exynos: hdmi: add support for exynos5 hdmi
This patch adds support for exynos5 hdmi with device tree enabled. Signed-off-by: Rahul Sharma <rahul.sharma@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Inki Dae <inki.dae@samsung.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/exynos/exynos_hdmi.c83
1 files changed, 79 insertions, 4 deletions
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 89e798b47ded..5caf49f366e3 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -32,6 +32,9 @@
32#include <linux/pm_runtime.h> 32#include <linux/pm_runtime.h>
33#include <linux/clk.h> 33#include <linux/clk.h>
34#include <linux/regulator/consumer.h> 34#include <linux/regulator/consumer.h>
35#include <linux/io.h>
36#include <linux/of_gpio.h>
37#include <plat/gpio-cfg.h>
35 38
36#include <drm/exynos_drm.h> 39#include <drm/exynos_drm.h>
37 40
@@ -2250,6 +2253,41 @@ void hdmi_attach_hdmiphy_client(struct i2c_client *hdmiphy)
2250 hdmi_hdmiphy = hdmiphy; 2253 hdmi_hdmiphy = hdmiphy;
2251} 2254}
2252 2255
2256#ifdef CONFIG_OF
2257static struct s5p_hdmi_platform_data *drm_hdmi_dt_parse_pdata
2258 (struct device *dev)
2259{
2260 struct device_node *np = dev->of_node;
2261 struct s5p_hdmi_platform_data *pd;
2262 enum of_gpio_flags flags;
2263 u32 value;
2264
2265 pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
2266 if (!pd) {
2267 DRM_ERROR("memory allocation for pdata failed\n");
2268 goto err_data;
2269 }
2270
2271 if (!of_find_property(np, "hpd-gpio", &value)) {
2272 DRM_ERROR("no hpd gpio property found\n");
2273 goto err_data;
2274 }
2275
2276 pd->hpd_gpio = of_get_named_gpio_flags(np, "hpd-gpio", 0, &flags);
2277
2278 return pd;
2279
2280err_data:
2281 return NULL;
2282}
2283#else
2284static struct s5p_hdmi_platform_data *drm_hdmi_dt_parse_pdata
2285 (struct device *dev)
2286{
2287 return NULL;
2288}
2289#endif
2290
2253static struct platform_device_id hdmi_driver_types[] = { 2291static struct platform_device_id hdmi_driver_types[] = {
2254 { 2292 {
2255 .name = "s5pv210-hdmi", 2293 .name = "s5pv210-hdmi",
@@ -2259,7 +2297,19 @@ static struct platform_device_id hdmi_driver_types[] = {
2259 .driver_data = HDMI_TYPE13, 2297 .driver_data = HDMI_TYPE13,
2260 }, { 2298 }, {
2261 .name = "exynos4-hdmi14", 2299 .name = "exynos4-hdmi14",
2262 .driver_data = HDMI_TYPE14, 2300 .driver_data = HDMI_TYPE14,
2301 }, {
2302 .name = "exynos5-hdmi",
2303 .driver_data = HDMI_TYPE14,
2304 }, {
2305 /* end node */
2306 }
2307};
2308
2309static struct of_device_id hdmi_match_types[] = {
2310 {
2311 .compatible = "samsung,exynos5-hdmi",
2312 .data = (void *)HDMI_TYPE14,
2263 }, { 2313 }, {
2264 /* end node */ 2314 /* end node */
2265 } 2315 }
@@ -2276,7 +2326,16 @@ static int __devinit hdmi_probe(struct platform_device *pdev)
2276 2326
2277 DRM_DEBUG_KMS("[%d]\n", __LINE__); 2327 DRM_DEBUG_KMS("[%d]\n", __LINE__);
2278 2328
2279 pdata = pdev->dev.platform_data; 2329 if (pdev->dev.of_node) {
2330 pdata = drm_hdmi_dt_parse_pdata(dev);
2331 if (IS_ERR(pdata)) {
2332 DRM_ERROR("failed to parse dt\n");
2333 return PTR_ERR(pdata);
2334 }
2335 } else {
2336 pdata = pdev->dev.platform_data;
2337 }
2338
2280 if (!pdata) { 2339 if (!pdata) {
2281 DRM_ERROR("no platform data specified\n"); 2340 DRM_ERROR("no platform data specified\n");
2282 return -EINVAL; 2341 return -EINVAL;
@@ -2303,18 +2362,33 @@ static int __devinit hdmi_probe(struct platform_device *pdev)
2303 2362
2304 platform_set_drvdata(pdev, drm_hdmi_ctx); 2363 platform_set_drvdata(pdev, drm_hdmi_ctx);
2305 2364
2306 hdata->type = (enum hdmi_type)platform_get_device_id 2365 if (dev->of_node) {
2366 const struct of_device_id *match;
2367 match = of_match_node(of_match_ptr(hdmi_match_types),
2368 pdev->dev.of_node);
2369 hdata->type = (enum hdmi_type)match->data;
2370 } else {
2371 hdata->type = (enum hdmi_type)platform_get_device_id
2307 (pdev)->driver_data; 2372 (pdev)->driver_data;
2373 }
2374
2308 hdata->hpd_gpio = pdata->hpd_gpio; 2375 hdata->hpd_gpio = pdata->hpd_gpio;
2309 hdata->dev = dev; 2376 hdata->dev = dev;
2310 2377
2311 ret = hdmi_resources_init(hdata); 2378 ret = hdmi_resources_init(hdata);
2379
2312 if (ret) { 2380 if (ret) {
2313 ret = -EINVAL; 2381 ret = -EINVAL;
2382 DRM_ERROR("hdmi_resources_init failed\n");
2314 goto err_data; 2383 goto err_data;
2315 } 2384 }
2316 2385
2317 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2386 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2387 if (!res) {
2388 DRM_ERROR("failed to find registers\n");
2389 ret = -ENOENT;
2390 goto err_resource;
2391 }
2318 2392
2319 hdata->regs = devm_request_and_ioremap(&pdev->dev, res); 2393 hdata->regs = devm_request_and_ioremap(&pdev->dev, res);
2320 if (!hdata->regs) { 2394 if (!hdata->regs) {
@@ -2462,8 +2536,9 @@ struct platform_driver hdmi_driver = {
2462 .remove = __devexit_p(hdmi_remove), 2536 .remove = __devexit_p(hdmi_remove),
2463 .id_table = hdmi_driver_types, 2537 .id_table = hdmi_driver_types,
2464 .driver = { 2538 .driver = {
2465 .name = "exynos4-hdmi", 2539 .name = "exynos-hdmi",
2466 .owner = THIS_MODULE, 2540 .owner = THIS_MODULE,
2467 .pm = &hdmi_pm_ops, 2541 .pm = &hdmi_pm_ops,
2542 .of_match_table = hdmi_match_types,
2468 }, 2543 },
2469}; 2544};