diff options
| author | Andrzej Hajda <a.hajda@samsung.com> | 2015-07-09 10:28:09 -0400 |
|---|---|---|
| committer | Inki Dae <inki.dae@samsung.com> | 2015-08-15 21:23:31 -0400 |
| commit | cd240cde91fa637449b564c08b31030073769ad7 (patch) | |
| tree | 439069928e3bf5a9fd6769f2c12eb54835564e7a /drivers | |
| parent | 882a0644fd3427a17d80ad14d1ca3a6228a3860f (diff) | |
drm/exynos/hdmi: add driver data pointer to private context
The patch replaces duplicated driver data fields in private context with
pointer to driver data. It also simplifies driver data lookup code.
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Reviewed-by: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/gpu/drm/exynos/exynos_hdmi.c | 49 |
1 files changed, 20 insertions, 29 deletions
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index f2e909de68fe..f9c4de16d91a 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c | |||
| @@ -32,8 +32,8 @@ | |||
| 32 | #include <linux/clk.h> | 32 | #include <linux/clk.h> |
| 33 | #include <linux/regulator/consumer.h> | 33 | #include <linux/regulator/consumer.h> |
| 34 | #include <linux/io.h> | 34 | #include <linux/io.h> |
| 35 | #include <linux/of.h> | ||
| 36 | #include <linux/of_address.h> | 35 | #include <linux/of_address.h> |
| 36 | #include <linux/of_device.h> | ||
| 37 | #include <linux/of_gpio.h> | 37 | #include <linux/of_gpio.h> |
| 38 | #include <linux/hdmi.h> | 38 | #include <linux/hdmi.h> |
| 39 | #include <linux/component.h> | 39 | #include <linux/component.h> |
| @@ -200,14 +200,12 @@ struct hdmi_context { | |||
| 200 | struct hdmi_conf_regs mode_conf; | 200 | struct hdmi_conf_regs mode_conf; |
| 201 | 201 | ||
| 202 | struct hdmi_resources res; | 202 | struct hdmi_resources res; |
| 203 | const struct hdmi_driver_data *drv_data; | ||
| 203 | 204 | ||
| 204 | int hpd_gpio; | 205 | int hpd_gpio; |
| 205 | void __iomem *regs_hdmiphy; | 206 | void __iomem *regs_hdmiphy; |
| 206 | const struct hdmiphy_config *phy_confs; | ||
| 207 | unsigned int phy_conf_count; | ||
| 208 | 207 | ||
| 209 | struct regmap *pmureg; | 208 | struct regmap *pmureg; |
| 210 | enum hdmi_type type; | ||
| 211 | }; | 209 | }; |
| 212 | 210 | ||
| 213 | static inline struct hdmi_context *display_to_hdmi(struct exynos_drm_display *d) | 211 | static inline struct hdmi_context *display_to_hdmi(struct exynos_drm_display *d) |
| @@ -926,7 +924,7 @@ static void hdmi_v14_regs_dump(struct hdmi_context *hdata, char *prefix) | |||
| 926 | 924 | ||
| 927 | static void hdmi_regs_dump(struct hdmi_context *hdata, char *prefix) | 925 | static void hdmi_regs_dump(struct hdmi_context *hdata, char *prefix) |
| 928 | { | 926 | { |
| 929 | if (hdata->type == HDMI_TYPE13) | 927 | if (hdata->drv_data->type == HDMI_TYPE13) |
| 930 | hdmi_v13_regs_dump(hdata, prefix); | 928 | hdmi_v13_regs_dump(hdata, prefix); |
| 931 | else | 929 | else |
| 932 | hdmi_v14_regs_dump(hdata, prefix); | 930 | hdmi_v14_regs_dump(hdata, prefix); |
| @@ -1087,8 +1085,8 @@ static int hdmi_find_phy_conf(struct hdmi_context *hdata, u32 pixel_clock) | |||
| 1087 | { | 1085 | { |
| 1088 | int i; | 1086 | int i; |
| 1089 | 1087 | ||
| 1090 | for (i = 0; i < hdata->phy_conf_count; i++) | 1088 | for (i = 0; i < hdata->drv_data->phy_conf_count; i++) |
| 1091 | if (hdata->phy_confs[i].pixel_clock == pixel_clock) | 1089 | if (hdata->drv_data->phy_confs[i].pixel_clock == pixel_clock) |
| 1092 | return i; | 1090 | return i; |
| 1093 | 1091 | ||
| 1094 | DRM_DEBUG_KMS("Could not find phy config for %d\n", pixel_clock); | 1092 | DRM_DEBUG_KMS("Could not find phy config for %d\n", pixel_clock); |
| @@ -1253,7 +1251,7 @@ static void hdmi_reg_acr(struct hdmi_context *hdata, u8 *acr) | |||
| 1253 | hdmi_reg_writeb(hdata, HDMI_ACR_CTS1, acr[2]); | 1251 | hdmi_reg_writeb(hdata, HDMI_ACR_CTS1, acr[2]); |
| 1254 | hdmi_reg_writeb(hdata, HDMI_ACR_CTS2, acr[1]); | 1252 | hdmi_reg_writeb(hdata, HDMI_ACR_CTS2, acr[1]); |
| 1255 | 1253 | ||
| 1256 | if (hdata->type == HDMI_TYPE13) | 1254 | if (hdata->drv_data->type == HDMI_TYPE13) |
| 1257 | hdmi_reg_writeb(hdata, HDMI_V13_ACR_CON, 4); | 1255 | hdmi_reg_writeb(hdata, HDMI_V13_ACR_CON, 4); |
| 1258 | else | 1256 | else |
| 1259 | hdmi_reg_writeb(hdata, HDMI_ACR_CON, 4); | 1257 | hdmi_reg_writeb(hdata, HDMI_ACR_CON, 4); |
| @@ -1387,7 +1385,7 @@ static void hdmi_conf_init(struct hdmi_context *hdata) | |||
| 1387 | HDMI_VID_PREAMBLE_DIS | HDMI_GUARD_BAND_DIS); | 1385 | HDMI_VID_PREAMBLE_DIS | HDMI_GUARD_BAND_DIS); |
| 1388 | } | 1386 | } |
| 1389 | 1387 | ||
| 1390 | if (hdata->type == HDMI_TYPE13) { | 1388 | if (hdata->drv_data->type == HDMI_TYPE13) { |
| 1391 | /* choose bluescreen (fecal) color */ | 1389 | /* choose bluescreen (fecal) color */ |
| 1392 | hdmi_reg_writeb(hdata, HDMI_V13_BLUE_SCREEN_0, 0x12); | 1390 | hdmi_reg_writeb(hdata, HDMI_V13_BLUE_SCREEN_0, 0x12); |
| 1393 | hdmi_reg_writeb(hdata, HDMI_V13_BLUE_SCREEN_1, 0x34); | 1391 | hdmi_reg_writeb(hdata, HDMI_V13_BLUE_SCREEN_1, 0x34); |
| @@ -1666,7 +1664,7 @@ static void hdmi_v14_mode_apply(struct hdmi_context *hdata) | |||
| 1666 | 1664 | ||
| 1667 | static void hdmi_mode_apply(struct hdmi_context *hdata) | 1665 | static void hdmi_mode_apply(struct hdmi_context *hdata) |
| 1668 | { | 1666 | { |
| 1669 | if (hdata->type == HDMI_TYPE13) | 1667 | if (hdata->drv_data->type == HDMI_TYPE13) |
| 1670 | hdmi_v13_mode_apply(hdata); | 1668 | hdmi_v13_mode_apply(hdata); |
| 1671 | else | 1669 | else |
| 1672 | hdmi_v14_mode_apply(hdata); | 1670 | hdmi_v14_mode_apply(hdata); |
| @@ -1684,7 +1682,7 @@ static void hdmiphy_conf_reset(struct hdmi_context *hdata) | |||
| 1684 | hdmiphy_reg_writeb(hdata, HDMIPHY_MODE_SET_DONE, | 1682 | hdmiphy_reg_writeb(hdata, HDMIPHY_MODE_SET_DONE, |
| 1685 | HDMI_PHY_ENABLE_MODE_SET); | 1683 | HDMI_PHY_ENABLE_MODE_SET); |
| 1686 | 1684 | ||
| 1687 | if (hdata->type == HDMI_TYPE13) | 1685 | if (hdata->drv_data->type == HDMI_TYPE13) |
| 1688 | reg = HDMI_V13_PHY_RSTOUT; | 1686 | reg = HDMI_V13_PHY_RSTOUT; |
| 1689 | else | 1687 | else |
| 1690 | reg = HDMI_PHY_RSTOUT; | 1688 | reg = HDMI_PHY_RSTOUT; |
| @@ -1698,7 +1696,7 @@ static void hdmiphy_conf_reset(struct hdmi_context *hdata) | |||
| 1698 | 1696 | ||
| 1699 | static void hdmiphy_poweron(struct hdmi_context *hdata) | 1697 | static void hdmiphy_poweron(struct hdmi_context *hdata) |
| 1700 | { | 1698 | { |
| 1701 | if (hdata->type != HDMI_TYPE14) | 1699 | if (hdata->drv_data->type != HDMI_TYPE14) |
| 1702 | return; | 1700 | return; |
| 1703 | 1701 | ||
| 1704 | DRM_DEBUG_KMS("\n"); | 1702 | DRM_DEBUG_KMS("\n"); |
| @@ -1718,7 +1716,7 @@ static void hdmiphy_poweron(struct hdmi_context *hdata) | |||
| 1718 | 1716 | ||
| 1719 | static void hdmiphy_poweroff(struct hdmi_context *hdata) | 1717 | static void hdmiphy_poweroff(struct hdmi_context *hdata) |
| 1720 | { | 1718 | { |
| 1721 | if (hdata->type != HDMI_TYPE14) | 1719 | if (hdata->drv_data->type != HDMI_TYPE14) |
| 1722 | return; | 1720 | return; |
| 1723 | 1721 | ||
| 1724 | DRM_DEBUG_KMS("\n"); | 1722 | DRM_DEBUG_KMS("\n"); |
| @@ -1750,7 +1748,8 @@ static void hdmiphy_conf_apply(struct hdmi_context *hdata) | |||
| 1750 | return; | 1748 | return; |
| 1751 | } | 1749 | } |
| 1752 | 1750 | ||
| 1753 | ret = hdmiphy_reg_write_buf(hdata, 0, hdata->phy_confs[i].conf, 32); | 1751 | ret = hdmiphy_reg_write_buf(hdata, 0, |
| 1752 | hdata->drv_data->phy_confs[i].conf, 32); | ||
| 1754 | if (ret) { | 1753 | if (ret) { |
| 1755 | DRM_ERROR("failed to configure hdmiphy\n"); | 1754 | DRM_ERROR("failed to configure hdmiphy\n"); |
| 1756 | return; | 1755 | return; |
| @@ -2015,7 +2014,7 @@ static void hdmi_mode_set(struct exynos_drm_display *display, | |||
| 2015 | /* preserve mode information for later use. */ | 2014 | /* preserve mode information for later use. */ |
| 2016 | drm_mode_copy(&hdata->current_mode, mode); | 2015 | drm_mode_copy(&hdata->current_mode, mode); |
| 2017 | 2016 | ||
| 2018 | if (hdata->type == HDMI_TYPE13) | 2017 | if (hdata->drv_data->type == HDMI_TYPE13) |
| 2019 | hdmi_v13_mode_set(hdata, mode); | 2018 | hdmi_v13_mode_set(hdata, mode); |
| 2020 | else | 2019 | else |
| 2021 | hdmi_v14_mode_set(hdata, mode); | 2020 | hdmi_v14_mode_set(hdata, mode); |
| @@ -2294,34 +2293,26 @@ static struct device_node *hdmi_legacy_phy_dt_binding(struct device *dev) | |||
| 2294 | static int hdmi_probe(struct platform_device *pdev) | 2293 | static int hdmi_probe(struct platform_device *pdev) |
| 2295 | { | 2294 | { |
| 2296 | struct device_node *ddc_node, *phy_node; | 2295 | struct device_node *ddc_node, *phy_node; |
| 2297 | struct hdmi_driver_data *drv_data; | ||
| 2298 | const struct of_device_id *match; | 2296 | const struct of_device_id *match; |
| 2299 | struct device *dev = &pdev->dev; | 2297 | struct device *dev = &pdev->dev; |
| 2300 | struct hdmi_context *hdata; | 2298 | struct hdmi_context *hdata; |
| 2301 | struct resource *res; | 2299 | struct resource *res; |
| 2302 | int ret; | 2300 | int ret; |
| 2303 | 2301 | ||
| 2304 | if (!dev->of_node) | ||
| 2305 | return -ENODEV; | ||
| 2306 | |||
| 2307 | hdata = devm_kzalloc(dev, sizeof(struct hdmi_context), GFP_KERNEL); | 2302 | hdata = devm_kzalloc(dev, sizeof(struct hdmi_context), GFP_KERNEL); |
| 2308 | if (!hdata) | 2303 | if (!hdata) |
| 2309 | return -ENOMEM; | 2304 | return -ENOMEM; |
| 2310 | 2305 | ||
| 2306 | match = of_match_device(hdmi_match_types, dev); | ||
| 2307 | if (!match) | ||
| 2308 | return -ENODEV; | ||
| 2309 | |||
| 2310 | hdata->drv_data = match->data; | ||
| 2311 | hdata->display.type = EXYNOS_DISPLAY_TYPE_HDMI; | 2311 | hdata->display.type = EXYNOS_DISPLAY_TYPE_HDMI; |
| 2312 | hdata->display.ops = &hdmi_display_ops; | 2312 | hdata->display.ops = &hdmi_display_ops; |
| 2313 | 2313 | ||
| 2314 | platform_set_drvdata(pdev, hdata); | 2314 | platform_set_drvdata(pdev, hdata); |
| 2315 | 2315 | ||
| 2316 | match = of_match_node(hdmi_match_types, dev->of_node); | ||
| 2317 | if (!match) | ||
| 2318 | return -ENODEV; | ||
| 2319 | |||
| 2320 | drv_data = (struct hdmi_driver_data *)match->data; | ||
| 2321 | hdata->type = drv_data->type; | ||
| 2322 | hdata->phy_confs = drv_data->phy_confs; | ||
| 2323 | hdata->phy_conf_count = drv_data->phy_conf_count; | ||
| 2324 | |||
| 2325 | hdata->dev = dev; | 2316 | hdata->dev = dev; |
| 2326 | hdata->hpd_gpio = of_get_named_gpio(dev->of_node, "hpd-gpio", 0); | 2317 | hdata->hpd_gpio = of_get_named_gpio(dev->of_node, "hpd-gpio", 0); |
| 2327 | if (hdata->hpd_gpio < 0) { | 2318 | if (hdata->hpd_gpio < 0) { |
| @@ -2379,7 +2370,7 @@ out_get_ddc_adpt: | |||
| 2379 | } | 2370 | } |
| 2380 | 2371 | ||
| 2381 | out_get_phy_port: | 2372 | out_get_phy_port: |
| 2382 | if (drv_data->is_apb_phy) { | 2373 | if (hdata->drv_data->is_apb_phy) { |
| 2383 | hdata->regs_hdmiphy = of_iomap(phy_node, 0); | 2374 | hdata->regs_hdmiphy = of_iomap(phy_node, 0); |
| 2384 | if (!hdata->regs_hdmiphy) { | 2375 | if (!hdata->regs_hdmiphy) { |
| 2385 | DRM_ERROR("failed to ioremap hdmi phy\n"); | 2376 | DRM_ERROR("failed to ioremap hdmi phy\n"); |
