aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Chen <jason.chen@linaro.org>2011-12-07 11:37:37 +0800
committerJason Chen <jason.chen@linaro.org>2011-12-07 11:37:37 +0800
commitfd044d182d1634109e2db2fccf75b3818eccd6e6 (patch)
treeb4f73181153f7a6dd672ca596e01c281ef36796a
parente779d1019fba8831899cfdd07007babe4cd31e3a (diff)
downloadlinux-linaro-fd044d182d1634109e2db2fccf75b3818eccd6e6.tar.gz
MXC LDB: add hwtype support
some setting related with hwtype. Signed-off-by: Jason Chen <jason.chen@linaro.org>
-rw-r--r--drivers/video/mxc/ldb.c49
1 files 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 <linux/spinlock.h>
#include <linux/fsl_devices.h>
#include <linux/of_gpio.h>
+#include <linux/of_device.h>
#include <mach/hardware.h>
#include <mach/clock.h>
#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",