From 2aaf79f9e7595dd73bc0e9e53e982c9d616cb6d3 Mon Sep 17 00:00:00 2001 From: Jason Chen Date: Wed, 7 Dec 2011 11:37:37 +0800 Subject: MXC LDB: add hwtype support some setting related with hwtype. Signed-off-by: Jason Chen --- drivers/video/mxc/ldb.c | 49 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/drivers/video/mxc/ldb.c b/drivers/video/mxc/ldb.c index 983dbc957da..0fbf57444a6 100644 --- a/drivers/video/mxc/ldb.c +++ b/drivers/video/mxc/ldb.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include "mxc_dispdrv.h" @@ -98,6 +99,30 @@ struct ldb_data { int di; } setting[2]; struct notifier_block nb; + uint8_t hwtype; +}; + +enum mxc_ldb_hwtype { + IMX5_LDB, + IMX6_LDB, +}; + +static struct platform_device_id mxc_ldb_devtype[] = { + { + .name = "imx5-ldb", + .driver_data = IMX5_LDB, + }, { + .name = "imx6-ldb", + .driver_data = IMX6_LDB, + }, { + /* sentinel */ + } +}; + +static const struct of_device_id mxc_ldb_dt_ids[] = { + { .compatible = "fsl,imx5-ldb", .data = &mxc_ldb_devtype[IMX5_LDB], }, + { .compatible = "fsl,imx6q-ldb", .data = &mxc_ldb_devtype[IMX6_LDB], }, + { /* sentinel */ } }; static int g_ldb_mode; @@ -408,9 +433,12 @@ static int ldb_ipu_ldb_route(int ipu, int di, struct ldb_data *ldb) return 0; } -static int of_get_ldb_data(struct platform_device *pdev, +static int of_get_ldb_data(struct ldb_data *ldb, struct fsl_mxc_ldb_platform_data *plat_data) { + struct platform_device *pdev = ldb->pdev; + const struct of_device_id *of_id = + of_match_device(mxc_ldb_dt_ids, &pdev->dev); struct device_node *np = pdev->dev.of_node; uint32_t lvds0[2] = {0}, lvds1[2] = {0}; const char *mode, *ext_ref; @@ -419,6 +447,10 @@ static int of_get_ldb_data(struct platform_device *pdev, if (!np) return -EINVAL; + if (of_id) + pdev->id_entry = of_id->data; + ldb->hwtype = pdev->id_entry->driver_data; + ret = of_property_read_string(np, "mode", &mode); if (ret < 0) g_ldb_mode = LDB_SEP0; @@ -499,7 +531,7 @@ static int ldb_disp_init(struct mxc_dispdrv_entry *disp) if (!plat_data) { plat_data = &of_data; - if (of_get_ldb_data(ldb->pdev, plat_data) < 0) { + if (of_get_ldb_data(ldb, plat_data) < 0) { dev_err(&ldb->pdev->dev, "no platform data\n"); return -EINVAL; } @@ -621,7 +653,7 @@ static int ldb_disp_init(struct mxc_dispdrv_entry *disp) writel(reg, ldb->control_reg); /* clock setting */ - if (cpu_is_mx6q() && + if ((ldb->hwtype == IMX6_LDB) && ((ldb->mode == LDB_SEP0) || (ldb->mode == LDB_SEP1))) ldb_clk[6] += lvds_channel; else @@ -669,7 +701,7 @@ static int ldb_disp_init(struct mxc_dispdrv_entry *disp) return -EINVAL; } - if (cpu_is_mx6q()) { + if (ldb->hwtype == IMX6_LDB) { setting->dev_id = plat_data->sec_ipu_id; setting->disp_id = plat_data->sec_disp_id; } else { @@ -707,7 +739,7 @@ static int ldb_disp_init(struct mxc_dispdrv_entry *disp) writel(reg, ldb->control_reg); /* clock setting */ - if (cpu_is_mx6q()) + if (ldb->hwtype == IMX6_LDB) ldb_clk[6] += lvds_channel; else ldb_clk[6] += setting->disp_id; @@ -729,7 +761,7 @@ static int ldb_disp_init(struct mxc_dispdrv_entry *disp) setting_idx = 1; } - if (cpu_is_mx6q()) { + if (ldb->hwtype == IMX6_LDB) { reg = readl(ldb->control_reg); reg &= ~(LDB_CH0_MODE_MASK | LDB_CH1_MODE_MASK); reg |= LDB_CH0_MODE_EN_TO_DI0 | LDB_CH1_MODE_EN_TO_DI1; @@ -851,11 +883,6 @@ static int ldb_remove(struct platform_device *pdev) return 0; } -static const struct of_device_id mxc_ldb_dt_ids[] = { - { .compatible = "fsl,imx6q-ldb", }, - { /* sentinel */ } -}; - static struct platform_driver mxcldb_driver = { .driver = { .name = "mxc_ldb", -- cgit v1.2.3