aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/video/omap2/dss/dsi.c146
-rw-r--r--include/video/omapdss.h6
2 files changed, 142 insertions, 10 deletions
diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c
index c26a91435e50..20cad1b529bd 100644
--- a/drivers/video/omap2/dss/dsi.c
+++ b/drivers/video/omap2/dss/dsi.c
@@ -3217,8 +3217,44 @@ static int dsi_vc_dcs_send_read_request(struct omap_dss_device *dssdev,
3217 return 0; 3217 return 0;
3218} 3218}
3219 3219
3220static int dsi_vc_dcs_read_rx_fifo(struct platform_device *dsidev, int channel, 3220static int dsi_vc_generic_send_read_request(struct omap_dss_device *dssdev,
3221 u8 *buf, int buflen) 3221 int channel, u8 *reqdata, int reqlen)
3222{
3223 struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
3224 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
3225 u16 data;
3226 u8 data_type;
3227 int r;
3228
3229 if (dsi->debug_read)
3230 DSSDBG("dsi_vc_generic_send_read_request(ch %d, reqlen %d)\n",
3231 channel, reqlen);
3232
3233 if (reqlen == 0) {
3234 data_type = MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM;
3235 data = 0;
3236 } else if (reqlen == 1) {
3237 data_type = MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM;
3238 data = reqdata[0];
3239 } else if (reqlen == 2) {
3240 data_type = MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM;
3241 data = reqdata[0] | (reqdata[1] << 8);
3242 } else {
3243 BUG();
3244 }
3245
3246 r = dsi_vc_send_short(dsidev, channel, data_type, data, 0);
3247 if (r) {
3248 DSSERR("dsi_vc_generic_send_read_request(ch %d, reqlen %d)"
3249 " failed\n", channel, reqlen);
3250 return r;
3251 }
3252
3253 return 0;
3254}
3255
3256static int dsi_vc_read_rx_fifo(struct platform_device *dsidev, int channel,
3257 u8 *buf, int buflen, enum dss_dsi_content_type type)
3222{ 3258{
3223 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); 3259 struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
3224 u32 val; 3260 u32 val;
@@ -3242,10 +3278,14 @@ static int dsi_vc_dcs_read_rx_fifo(struct platform_device *dsidev, int channel,
3242 r = -EIO; 3278 r = -EIO;
3243 goto err; 3279 goto err;
3244 3280
3245 } else if (dt == MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_1BYTE) { 3281 } else if (dt == (type == DSS_DSI_CONTENT_GENERIC ?
3282 MIPI_DSI_RX_GENERIC_SHORT_READ_RESPONSE_1BYTE :
3283 MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_1BYTE)) {
3246 u8 data = FLD_GET(val, 15, 8); 3284 u8 data = FLD_GET(val, 15, 8);
3247 if (dsi->debug_read) 3285 if (dsi->debug_read)
3248 DSSDBG("\tDCS short response, 1 byte: %02x\n", data); 3286 DSSDBG("\t%s short response, 1 byte: %02x\n",
3287 type == DSS_DSI_CONTENT_GENERIC ? "GENERIC" :
3288 "DCS", data);
3249 3289
3250 if (buflen < 1) { 3290 if (buflen < 1) {
3251 r = -EIO; 3291 r = -EIO;
@@ -3255,10 +3295,14 @@ static int dsi_vc_dcs_read_rx_fifo(struct platform_device *dsidev, int channel,
3255 buf[0] = data; 3295 buf[0] = data;
3256 3296
3257 return 1; 3297 return 1;
3258 } else if (dt == MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_2BYTE) { 3298 } else if (dt == (type == DSS_DSI_CONTENT_GENERIC ?
3299 MIPI_DSI_RX_GENERIC_SHORT_READ_RESPONSE_2BYTE :
3300 MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_2BYTE)) {
3259 u16 data = FLD_GET(val, 23, 8); 3301 u16 data = FLD_GET(val, 23, 8);
3260 if (dsi->debug_read) 3302 if (dsi->debug_read)
3261 DSSDBG("\tDCS short response, 2 byte: %04x\n", data); 3303 DSSDBG("\t%s short response, 2 byte: %04x\n",
3304 type == DSS_DSI_CONTENT_GENERIC ? "GENERIC" :
3305 "DCS", data);
3262 3306
3263 if (buflen < 2) { 3307 if (buflen < 2) {
3264 r = -EIO; 3308 r = -EIO;
@@ -3269,11 +3313,15 @@ static int dsi_vc_dcs_read_rx_fifo(struct platform_device *dsidev, int channel,
3269 buf[1] = (data >> 8) & 0xff; 3313 buf[1] = (data >> 8) & 0xff;
3270 3314
3271 return 2; 3315 return 2;
3272 } else if (dt == MIPI_DSI_RX_DCS_LONG_READ_RESPONSE) { 3316 } else if (dt == (type == DSS_DSI_CONTENT_GENERIC ?
3317 MIPI_DSI_RX_GENERIC_LONG_READ_RESPONSE :
3318 MIPI_DSI_RX_DCS_LONG_READ_RESPONSE)) {
3273 int w; 3319 int w;
3274 int len = FLD_GET(val, 23, 8); 3320 int len = FLD_GET(val, 23, 8);
3275 if (dsi->debug_read) 3321 if (dsi->debug_read)
3276 DSSDBG("\tDCS long response, len %d\n", len); 3322 DSSDBG("\t%s long response, len %d\n",
3323 type == DSS_DSI_CONTENT_GENERIC ? "GENERIC" :
3324 "DCS", len);
3277 3325
3278 if (len > buflen) { 3326 if (len > buflen) {
3279 r = -EIO; 3327 r = -EIO;
@@ -3309,7 +3357,8 @@ static int dsi_vc_dcs_read_rx_fifo(struct platform_device *dsidev, int channel,
3309 3357
3310 BUG(); 3358 BUG();
3311err: 3359err:
3312 DSSERR("dsi_vc_dcs_read_rx_fifo(ch %d) failed\n", channel); 3360 DSSERR("dsi_vc_read_rx_fifo(ch %d type %s) failed\n", channel,
3361 type == DSS_DSI_CONTENT_GENERIC ? "GENERIC" : "DCS");
3313 3362
3314 return r; 3363 return r;
3315} 3364}
@@ -3328,7 +3377,8 @@ int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
3328 if (r) 3377 if (r)
3329 goto err; 3378 goto err;
3330 3379
3331 r = dsi_vc_dcs_read_rx_fifo(dsidev, channel, buf, buflen); 3380 r = dsi_vc_read_rx_fifo(dsidev, channel, buf, buflen,
3381 DSS_DSI_CONTENT_DCS);
3332 if (r < 0) 3382 if (r < 0)
3333 goto err; 3383 goto err;
3334 3384
@@ -3344,6 +3394,82 @@ err:
3344} 3394}
3345EXPORT_SYMBOL(dsi_vc_dcs_read); 3395EXPORT_SYMBOL(dsi_vc_dcs_read);
3346 3396
3397static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int channel,
3398 u8 *reqdata, int reqlen, u8 *buf, int buflen)
3399{
3400 struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
3401 int r;
3402
3403 r = dsi_vc_generic_send_read_request(dssdev, channel, reqdata, reqlen);
3404 if (r)
3405 return r;
3406
3407 r = dsi_vc_send_bta_sync(dssdev, channel);
3408 if (r)
3409 return r;
3410
3411 r = dsi_vc_read_rx_fifo(dsidev, channel, buf, buflen,
3412 DSS_DSI_CONTENT_GENERIC);
3413 if (r < 0)
3414 return r;
3415
3416 if (r != buflen) {
3417 r = -EIO;
3418 return r;
3419 }
3420
3421 return 0;
3422}
3423
3424int dsi_vc_generic_read_0(struct omap_dss_device *dssdev, int channel, u8 *buf,
3425 int buflen)
3426{
3427 int r;
3428
3429 r = dsi_vc_generic_read(dssdev, channel, NULL, 0, buf, buflen);
3430 if (r) {
3431 DSSERR("dsi_vc_generic_read_0(ch %d) failed\n", channel);
3432 return r;
3433 }
3434
3435 return 0;
3436}
3437EXPORT_SYMBOL(dsi_vc_generic_read_0);
3438
3439int dsi_vc_generic_read_1(struct omap_dss_device *dssdev, int channel, u8 param,
3440 u8 *buf, int buflen)
3441{
3442 int r;
3443
3444 r = dsi_vc_generic_read(dssdev, channel, &param, 1, buf, buflen);
3445 if (r) {
3446 DSSERR("dsi_vc_generic_read_1(ch %d) failed\n", channel);
3447 return r;
3448 }
3449
3450 return 0;
3451}
3452EXPORT_SYMBOL(dsi_vc_generic_read_1);
3453
3454int dsi_vc_generic_read_2(struct omap_dss_device *dssdev, int channel,
3455 u8 param1, u8 param2, u8 *buf, int buflen)
3456{
3457 int r;
3458 u8 reqdata[2];
3459
3460 reqdata[0] = param1;
3461 reqdata[1] = param2;
3462
3463 r = dsi_vc_generic_read(dssdev, channel, reqdata, 2, buf, buflen);
3464 if (r) {
3465 DSSERR("dsi_vc_generic_read_2(ch %d) failed\n", channel);
3466 return r;
3467 }
3468
3469 return 0;
3470}
3471EXPORT_SYMBOL(dsi_vc_generic_read_2);
3472
3347int dsi_vc_set_max_rx_packet_size(struct omap_dss_device *dssdev, int channel, 3473int dsi_vc_set_max_rx_packet_size(struct omap_dss_device *dssdev, int channel,
3348 u16 len) 3474 u16 len)
3349{ 3475{
diff --git a/include/video/omapdss.h b/include/video/omapdss.h
index a8a43de3dd81..abe8b1e51529 100644
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -241,6 +241,12 @@ int dsi_vc_generic_write_nosync(struct omap_dss_device *dssdev, int channel,
241 u8 *data, int len); 241 u8 *data, int len);
242int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd, 242int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
243 u8 *buf, int buflen); 243 u8 *buf, int buflen);
244int dsi_vc_generic_read_0(struct omap_dss_device *dssdev, int channel, u8 *buf,
245 int buflen);
246int dsi_vc_generic_read_1(struct omap_dss_device *dssdev, int channel, u8 param,
247 u8 *buf, int buflen);
248int dsi_vc_generic_read_2(struct omap_dss_device *dssdev, int channel,
249 u8 param1, u8 param2, u8 *buf, int buflen);
244int dsi_vc_set_max_rx_packet_size(struct omap_dss_device *dssdev, int channel, 250int dsi_vc_set_max_rx_packet_size(struct omap_dss_device *dssdev, int channel,
245 u16 len); 251 u16 len);
246int dsi_vc_send_null(struct omap_dss_device *dssdev, int channel); 252int dsi_vc_send_null(struct omap_dss_device *dssdev, int channel);