aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2012-03-28 08:58:56 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2012-05-09 03:53:05 -0400
commite4a9e94cc58ed6e4efb02b80be3a9bf57f448d07 (patch)
treec4b33461be5176e7c5ae7cc1590501b889f13ad1 /drivers
parent3acc797c1db2eb873b13a07f21fe9572af4b78ee (diff)
OMAPDSS: DSI: implement generic DSI pin config
In preparation for device tree, this patch changes how the DSI pins are configured. The current configuration method is only doable with board files and the configuration data is OMAP specific. This patch moves the configuration data to the panel's platform data, and the data can easily be given via DT in the future. The configuration data format is also changed to a generic one which should be suitable for all platforms. The new format is an array of pin numbers, where the array items start from clock + and -, then data1 + and -, and so on. For example: { 0, // pin num for clock lane + 1, // pin num for clock lane - 2, // pin num for data1 lane + 3, // pin num for data1 lane - ... } The pin numbers are translated by the DSI driver and used to configure the hardware appropriately. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Acked-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/omap2/displays/panel-taal.c7
-rw-r--r--drivers/video/omap2/dss/dsi.c133
2 files changed, 75 insertions, 65 deletions
diff --git a/drivers/video/omap2/displays/panel-taal.c b/drivers/video/omap2/displays/panel-taal.c
index 0888162e9ce9..b2dd88b48420 100644
--- a/drivers/video/omap2/displays/panel-taal.c
+++ b/drivers/video/omap2/displays/panel-taal.c
@@ -1137,9 +1137,16 @@ static void __exit taal_remove(struct omap_dss_device *dssdev)
1137static int taal_power_on(struct omap_dss_device *dssdev) 1137static int taal_power_on(struct omap_dss_device *dssdev)
1138{ 1138{
1139 struct taal_data *td = dev_get_drvdata(&dssdev->dev); 1139 struct taal_data *td = dev_get_drvdata(&dssdev->dev);
1140 struct nokia_dsi_panel_data *panel_data = get_panel_data(dssdev);
1140 u8 id1, id2, id3; 1141 u8 id1, id2, id3;
1141 int r; 1142 int r;
1142 1143
1144 r = omapdss_dsi_configure_pins(dssdev, &panel_data->pin_config);
1145 if (r) {
1146 dev_err(&dssdev->dev, "failed to configure DSI pins\n");
1147 goto err0;
1148 };
1149
1143 r = omapdss_dsi_display_enable(dssdev); 1150 r = omapdss_dsi_display_enable(dssdev);
1144 if (r) { 1151 if (r) {
1145 dev_err(&dssdev->dev, "failed to enable DSI\n"); 1152 dev_err(&dssdev->dev, "failed to enable DSI\n");
diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c
index 662d14f8c2c3..210a3c4f6150 100644
--- a/drivers/video/omap2/dss/dsi.c
+++ b/drivers/video/omap2/dss/dsi.c
@@ -2076,65 +2076,6 @@ static unsigned dsi_get_line_buf_size(struct platform_device *dsidev)
2076 } 2076 }
2077} 2077}
2078 2078
2079static int dsi_parse_lane_config(struct omap_dss_device *dssdev)
2080{
2081 struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
2082 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
2083 u8 lanes[DSI_MAX_NR_LANES];
2084 u8 polarities[DSI_MAX_NR_LANES];
2085 int num_lanes, i;
2086
2087 static const enum dsi_lane_function functions[] = {
2088 DSI_LANE_CLK,
2089 DSI_LANE_DATA1,
2090 DSI_LANE_DATA2,
2091 DSI_LANE_DATA3,
2092 DSI_LANE_DATA4,
2093 };
2094
2095 lanes[0] = dssdev->phy.dsi.clk_lane;
2096 lanes[1] = dssdev->phy.dsi.data1_lane;
2097 lanes[2] = dssdev->phy.dsi.data2_lane;
2098 lanes[3] = dssdev->phy.dsi.data3_lane;
2099 lanes[4] = dssdev->phy.dsi.data4_lane;
2100 polarities[0] = dssdev->phy.dsi.clk_pol;
2101 polarities[1] = dssdev->phy.dsi.data1_pol;
2102 polarities[2] = dssdev->phy.dsi.data2_pol;
2103 polarities[3] = dssdev->phy.dsi.data3_pol;
2104 polarities[4] = dssdev->phy.dsi.data4_pol;
2105
2106 num_lanes = 0;
2107
2108 for (i = 0; i < dsi->num_lanes_supported; ++i)
2109 dsi->lanes[i].function = DSI_LANE_UNUSED;
2110
2111 for (i = 0; i < dsi->num_lanes_supported; ++i) {
2112 int num;
2113
2114 if (lanes[i] == DSI_LANE_UNUSED)
2115 break;
2116
2117 num = lanes[i] - 1;
2118
2119 if (num >= dsi->num_lanes_supported)
2120 return -EINVAL;
2121
2122 if (dsi->lanes[num].function != DSI_LANE_UNUSED)
2123 return -EINVAL;
2124
2125 dsi->lanes[num].function = functions[i];
2126 dsi->lanes[num].polarity = polarities[i];
2127 num_lanes++;
2128 }
2129
2130 if (num_lanes < 2 || num_lanes > dsi->num_lanes_supported)
2131 return -EINVAL;
2132
2133 dsi->num_lanes_used = num_lanes;
2134
2135 return 0;
2136}
2137
2138static int dsi_set_lane_config(struct omap_dss_device *dssdev) 2079static int dsi_set_lane_config(struct omap_dss_device *dssdev)
2139{ 2080{
2140 struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); 2081 struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
@@ -3975,6 +3916,74 @@ static void dsi_proto_timings(struct omap_dss_device *dssdev)
3975 } 3916 }
3976} 3917}
3977 3918
3919int omapdss_dsi_configure_pins(struct omap_dss_device *dssdev,
3920 const struct omap_dsi_pin_config *pin_cfg)
3921{
3922 struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
3923 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
3924 int num_pins;
3925 const int *pins;
3926 struct dsi_lane_config lanes[DSI_MAX_NR_LANES];
3927 int num_lanes;
3928 int i;
3929
3930 static const enum dsi_lane_function functions[] = {
3931 DSI_LANE_CLK,
3932 DSI_LANE_DATA1,
3933 DSI_LANE_DATA2,
3934 DSI_LANE_DATA3,
3935 DSI_LANE_DATA4,
3936 };
3937
3938 num_pins = pin_cfg->num_pins;
3939 pins = pin_cfg->pins;
3940
3941 if (num_pins < 4 || num_pins > dsi->num_lanes_supported * 2
3942 || num_pins % 2 != 0)
3943 return -EINVAL;
3944
3945 for (i = 0; i < DSI_MAX_NR_LANES; ++i)
3946 lanes[i].function = DSI_LANE_UNUSED;
3947
3948 num_lanes = 0;
3949
3950 for (i = 0; i < num_pins; i += 2) {
3951 u8 lane, pol;
3952 int dx, dy;
3953
3954 dx = pins[i];
3955 dy = pins[i + 1];
3956
3957 if (dx < 0 || dx >= dsi->num_lanes_supported * 2)
3958 return -EINVAL;
3959
3960 if (dy < 0 || dy >= dsi->num_lanes_supported * 2)
3961 return -EINVAL;
3962
3963 if (dx & 1) {
3964 if (dy != dx - 1)
3965 return -EINVAL;
3966 pol = 1;
3967 } else {
3968 if (dy != dx + 1)
3969 return -EINVAL;
3970 pol = 0;
3971 }
3972
3973 lane = dx / 2;
3974
3975 lanes[lane].function = functions[i / 2];
3976 lanes[lane].polarity = pol;
3977 num_lanes++;
3978 }
3979
3980 memcpy(dsi->lanes, lanes, sizeof(dsi->lanes));
3981 dsi->num_lanes_used = num_lanes;
3982
3983 return 0;
3984}
3985EXPORT_SYMBOL(omapdss_dsi_configure_pins);
3986
3978int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel) 3987int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
3979{ 3988{
3980 struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); 3989 struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
@@ -4339,12 +4348,6 @@ static int dsi_display_init_dsi(struct omap_dss_device *dssdev)
4339 int dsi_module = dsi_get_dsidev_id(dsidev); 4348 int dsi_module = dsi_get_dsidev_id(dsidev);
4340 int r; 4349 int r;
4341 4350
4342 r = dsi_parse_lane_config(dssdev);
4343 if (r) {
4344 DSSERR("illegal lane config");
4345 goto err0;
4346 }
4347
4348 r = dsi_pll_init(dsidev, true, true); 4351 r = dsi_pll_init(dsidev, true, true);
4349 if (r) 4352 if (r)
4350 goto err0; 4353 goto err0;