Skip to content

Commit e4a9e94

Browse files
committed
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>
1 parent 3acc797 commit e4a9e94

5 files changed

Lines changed: 103 additions & 89 deletions

File tree

‎arch/arm/mach-omap2/board-4430sdp.c‎

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,10 @@ static struct nokia_dsi_panel_data dsi1_panel = {
666666
.use_ext_te = false,
667667
.ext_te_gpio = 101,
668668
.esd_interval = 0,
669+
.pin_config = {
670+
.num_pins = 6,
671+
.pins = { 0, 1, 2, 3, 4, 5 },
672+
},
669673
};
670674

671675
static struct omap_dss_device sdp4430_lcd_device = {
@@ -674,13 +678,6 @@ static struct omap_dss_device sdp4430_lcd_device = {
674678
.type = OMAP_DISPLAY_TYPE_DSI,
675679
.data = &dsi1_panel,
676680
.phy.dsi = {
677-
.clk_lane = 1,
678-
.clk_pol = 0,
679-
.data1_lane = 2,
680-
.data1_pol = 0,
681-
.data2_lane = 3,
682-
.data2_pol = 0,
683-
684681
.module = 0,
685682
},
686683

@@ -715,6 +712,10 @@ static struct nokia_dsi_panel_data dsi2_panel = {
715712
.use_ext_te = false,
716713
.ext_te_gpio = 103,
717714
.esd_interval = 0,
715+
.pin_config = {
716+
.num_pins = 6,
717+
.pins = { 0, 1, 2, 3, 4, 5 },
718+
},
718719
};
719720

720721
static struct omap_dss_device sdp4430_lcd2_device = {
@@ -723,12 +724,6 @@ static struct omap_dss_device sdp4430_lcd2_device = {
723724
.type = OMAP_DISPLAY_TYPE_DSI,
724725
.data = &dsi2_panel,
725726
.phy.dsi = {
726-
.clk_lane = 1,
727-
.clk_pol = 0,
728-
.data1_lane = 2,
729-
.data1_pol = 0,
730-
.data2_lane = 3,
731-
.data2_pol = 0,
732727

733728
.module = 1,
734729
},

‎drivers/video/omap2/displays/panel-taal.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,9 +1137,16 @@ static void __exit taal_remove(struct omap_dss_device *dssdev)
11371137
static int taal_power_on(struct omap_dss_device *dssdev)
11381138
{
11391139
struct taal_data *td = dev_get_drvdata(&dssdev->dev);
1140+
struct nokia_dsi_panel_data *panel_data = get_panel_data(dssdev);
11401141
u8 id1, id2, id3;
11411142
int r;
11421143

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+
11431150
r = omapdss_dsi_display_enable(dssdev);
11441151
if (r) {
11451152
dev_err(&dssdev->dev, "failed to enable DSI\n");

‎drivers/video/omap2/dss/dsi.c‎

Lines changed: 68 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,65 +2076,6 @@ static unsigned dsi_get_line_buf_size(struct platform_device *dsidev)
20762076
}
20772077
}
20782078

2079-
static 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-
21382079
static int dsi_set_lane_config(struct omap_dss_device *dssdev)
21392080
{
21402081
struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
@@ -3975,6 +3916,74 @@ static void dsi_proto_timings(struct omap_dss_device *dssdev)
39753916
}
39763917
}
39773918

3919+
int 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+
}
3985+
EXPORT_SYMBOL(omapdss_dsi_configure_pins);
3986+
39783987
int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
39793988
{
39803989
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)
43394348
int dsi_module = dsi_get_dsidev_id(dsidev);
43404349
int r;
43414350

4342-
r = dsi_parse_lane_config(dssdev);
4343-
if (r) {
4344-
DSSERR("illegal lane config");
4345-
goto err0;
4346-
}
4347-
43484351
r = dsi_pll_init(dsidev, true, true);
43494352
if (r)
43504353
goto err0;

‎include/video/omap-panel-nokia-dsi.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ struct omap_dss_device;
1111
* @esd_interval: interval of ESD checks, 0 = disabled (ms)
1212
* @ulps_timeout: time to wait before entering ULPS, 0 = disabled (ms)
1313
* @use_dsi_backlight: true if panel uses DSI command to control backlight
14+
* @pin_config: DSI pin configuration
1415
*/
1516
struct nokia_dsi_panel_data {
1617
const char *name;
@@ -24,6 +25,8 @@ struct nokia_dsi_panel_data {
2425
unsigned ulps_timeout;
2526

2627
bool use_dsi_backlight;
28+
29+
struct omap_dsi_pin_config pin_config;
2730
};
2831

2932
#endif /* __OMAP_NOKIA_DSI_PANEL_H */

‎include/video/omapdss.h‎

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,21 @@ struct omap_overlay_manager {
468468
int (*wait_for_vsync)(struct omap_overlay_manager *mgr);
469469
};
470470

471+
/* 22 pins means 1 clk lane and 10 data lanes */
472+
#define OMAP_DSS_MAX_DSI_PINS 22
473+
474+
struct omap_dsi_pin_config {
475+
int num_pins;
476+
/*
477+
* pin numbers in the following order:
478+
* clk+, clk-
479+
* data1+, data1-
480+
* data2+, data2-
481+
* ...
482+
*/
483+
int pins[OMAP_DSS_MAX_DSI_PINS];
484+
};
485+
471486
struct omap_dss_device {
472487
struct device dev;
473488

@@ -490,17 +505,6 @@ struct omap_dss_device {
490505
} sdi;
491506

492507
struct {
493-
u8 clk_lane;
494-
u8 clk_pol;
495-
u8 data1_lane;
496-
u8 data1_pol;
497-
u8 data2_lane;
498-
u8 data2_pol;
499-
u8 data3_lane;
500-
u8 data3_pol;
501-
u8 data4_lane;
502-
u8 data4_pol;
503-
504508
int module;
505509

506510
bool ext_te;
@@ -687,6 +691,8 @@ int omap_dsi_update(struct omap_dss_device *dssdev, int channel,
687691
int omap_dsi_request_vc(struct omap_dss_device *dssdev, int *channel);
688692
int omap_dsi_set_vc_id(struct omap_dss_device *dssdev, int channel, int vc_id);
689693
void omap_dsi_release_vc(struct omap_dss_device *dssdev, int channel);
694+
int omapdss_dsi_configure_pins(struct omap_dss_device *dssdev,
695+
const struct omap_dsi_pin_config *pin_cfg);
690696

691697
int omapdss_dsi_display_enable(struct omap_dss_device *dssdev);
692698
void omapdss_dsi_display_disable(struct omap_dss_device *dssdev,

0 commit comments

Comments
 (0)