aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/omap2
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@nokia.com>2010-04-12 03:40:12 -0400
committerTomi Valkeinen <tomi.valkeinen@nokia.com>2010-08-03 08:18:47 -0400
commit4ffa35713e263fbf4975e14bc6f4a515b7701349 (patch)
treeb665f11e169a5c6615535e57242333a8c4dcfdf3 /drivers/video/omap2
parentb63ac1e31422077bed8257a519c6668f8868ed2b (diff)
OMAP: DSS2: DSI: change DSI timeout functions
Using nanoseconds as arguments to functions that set the DSI timeouts was perhaps not so good idea. The timeouts are based on different DSI clocks, so the possible range for the timeouts vary greatly depending on the clocks. Also, the multipliers used with the timeouts cause big gaps in the timeout range, meaning that the nanosecond based functions could cause the timeout to be quite far from the intended value. This patch changes the functions to take the plain tick values with the multiplier enable/disable bits, and sets the TA/LP_RX/HS_TX timeouts to maximum. While the timeouts could be much lower, the fact is that when TA/LP_RX/HS_TX timeout happens, we are in an error situation and not in a hurry anyway. STOP_STATE_COUNTER is a different matter, but it is only used at initialization time, and won't normally affect the performance. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@nokia.com>
Diffstat (limited to 'drivers/video/omap2')
-rw-r--r--drivers/video/omap2/dss/dsi.c216
1 files changed, 56 insertions, 160 deletions
diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c
index 5b6217674559..613796b54f07 100644
--- a/drivers/video/omap2/dss/dsi.c
+++ b/drivers/video/omap2/dss/dsi.c
@@ -2277,212 +2277,108 @@ int dsi_vc_set_max_rx_packet_size(int channel, u16 len)
2277} 2277}
2278EXPORT_SYMBOL(dsi_vc_set_max_rx_packet_size); 2278EXPORT_SYMBOL(dsi_vc_set_max_rx_packet_size);
2279 2279
2280static void dsi_set_lp_rx_timeout(unsigned long ns) 2280static void dsi_set_lp_rx_timeout(unsigned ticks, bool x4, bool x16)
2281{ 2281{
2282 u32 r;
2283 unsigned x4, x16;
2284 unsigned long fck; 2282 unsigned long fck;
2285 unsigned long ticks; 2283 unsigned long total_ticks;
2284 u32 r;
2286 2285
2287 /* ticks in DSI_FCK */ 2286 BUG_ON(ticks > 0x1fff);
2288 2287
2288 /* ticks in DSI_FCK */
2289 fck = dsi_fclk_rate(); 2289 fck = dsi_fclk_rate();
2290 ticks = (fck / 1000 / 1000) * ns / 1000;
2291 x4 = 0;
2292 x16 = 0;
2293
2294 if (ticks > 0x1fff) {
2295 ticks = (fck / 1000 / 1000) * ns / 1000 / 4;
2296 x4 = 1;
2297 x16 = 0;
2298 }
2299
2300 if (ticks > 0x1fff) {
2301 ticks = (fck / 1000 / 1000) * ns / 1000 / 16;
2302 x4 = 0;
2303 x16 = 1;
2304 }
2305
2306 if (ticks > 0x1fff) {
2307 ticks = (fck / 1000 / 1000) * ns / 1000 / (4 * 16);
2308 x4 = 1;
2309 x16 = 1;
2310 }
2311
2312 if (ticks > 0x1fff) {
2313 DSSWARN("LP_TX_TO over limit, setting it to max\n");
2314 ticks = 0x1fff;
2315 x4 = 1;
2316 x16 = 1;
2317 }
2318 2290
2319 r = dsi_read_reg(DSI_TIMING2); 2291 r = dsi_read_reg(DSI_TIMING2);
2320 r = FLD_MOD(r, 1, 15, 15); /* LP_RX_TO */ 2292 r = FLD_MOD(r, 1, 15, 15); /* LP_RX_TO */
2321 r = FLD_MOD(r, x16, 14, 14); /* LP_RX_TO_X16 */ 2293 r = FLD_MOD(r, x16 ? 1 : 0, 14, 14); /* LP_RX_TO_X16 */
2322 r = FLD_MOD(r, x4, 13, 13); /* LP_RX_TO_X4 */ 2294 r = FLD_MOD(r, x4 ? 1 : 0, 13, 13); /* LP_RX_TO_X4 */
2323 r = FLD_MOD(r, ticks, 12, 0); /* LP_RX_COUNTER */ 2295 r = FLD_MOD(r, ticks, 12, 0); /* LP_RX_COUNTER */
2324 dsi_write_reg(DSI_TIMING2, r); 2296 dsi_write_reg(DSI_TIMING2, r);
2325 2297
2326 DSSDBG("LP_RX_TO %lu ns (%#lx ticks%s%s)\n", 2298 total_ticks = ticks * (x16 ? 16 : 1) * (x4 ? 4 : 1);
2327 (ticks * (x16 ? 16 : 1) * (x4 ? 4 : 1) * 1000) / 2299
2328 (fck / 1000 / 1000), 2300 DSSDBG("LP_RX_TO %lu ticks (%#x%s%s) = %lu ns\n",
2329 ticks, x4 ? " x4" : "", x16 ? " x16" : ""); 2301 total_ticks,
2302 ticks, x4 ? " x4" : "", x16 ? " x16" : "",
2303 (total_ticks * 1000) / (fck / 1000 / 1000));
2330} 2304}
2331 2305
2332static void dsi_set_ta_timeout(unsigned long ns) 2306static void dsi_set_ta_timeout(unsigned ticks, bool x8, bool x16)
2333{ 2307{
2334 u32 r;
2335 unsigned x8, x16;
2336 unsigned long fck; 2308 unsigned long fck;
2337 unsigned long ticks; 2309 unsigned long total_ticks;
2310 u32 r;
2311
2312 BUG_ON(ticks > 0x1fff);
2338 2313
2339 /* ticks in DSI_FCK */ 2314 /* ticks in DSI_FCK */
2340 fck = dsi_fclk_rate(); 2315 fck = dsi_fclk_rate();
2341 ticks = (fck / 1000 / 1000) * ns / 1000;
2342 x8 = 0;
2343 x16 = 0;
2344
2345 if (ticks > 0x1fff) {
2346 ticks = (fck / 1000 / 1000) * ns / 1000 / 8;
2347 x8 = 1;
2348 x16 = 0;
2349 }
2350
2351 if (ticks > 0x1fff) {
2352 ticks = (fck / 1000 / 1000) * ns / 1000 / 16;
2353 x8 = 0;
2354 x16 = 1;
2355 }
2356
2357 if (ticks > 0x1fff) {
2358 ticks = (fck / 1000 / 1000) * ns / 1000 / (8 * 16);
2359 x8 = 1;
2360 x16 = 1;
2361 }
2362
2363 if (ticks > 0x1fff) {
2364 DSSWARN("TA_TO over limit, setting it to max\n");
2365 ticks = 0x1fff;
2366 x8 = 1;
2367 x16 = 1;
2368 }
2369 2316
2370 r = dsi_read_reg(DSI_TIMING1); 2317 r = dsi_read_reg(DSI_TIMING1);
2371 r = FLD_MOD(r, 1, 31, 31); /* TA_TO */ 2318 r = FLD_MOD(r, 1, 31, 31); /* TA_TO */
2372 r = FLD_MOD(r, x16, 30, 30); /* TA_TO_X16 */ 2319 r = FLD_MOD(r, x16 ? 1 : 0, 30, 30); /* TA_TO_X16 */
2373 r = FLD_MOD(r, x8, 29, 29); /* TA_TO_X8 */ 2320 r = FLD_MOD(r, x8 ? 1 : 0, 29, 29); /* TA_TO_X8 */
2374 r = FLD_MOD(r, ticks, 28, 16); /* TA_TO_COUNTER */ 2321 r = FLD_MOD(r, ticks, 28, 16); /* TA_TO_COUNTER */
2375 dsi_write_reg(DSI_TIMING1, r); 2322 dsi_write_reg(DSI_TIMING1, r);
2376 2323
2377 DSSDBG("TA_TO %lu ns (%#lx ticks%s%s)\n", 2324 total_ticks = ticks * (x16 ? 16 : 1) * (x8 ? 8 : 1);
2378 (ticks * (x16 ? 16 : 1) * (x8 ? 8 : 1) * 1000) / 2325
2379 (fck / 1000 / 1000), 2326 DSSDBG("TA_TO %lu ticks (%#x%s%s) = %lu ns\n",
2380 ticks, x8 ? " x8" : "", x16 ? " x16" : ""); 2327 total_ticks,
2328 ticks, x8 ? " x8" : "", x16 ? " x16" : "",
2329 (total_ticks * 1000) / (fck / 1000 / 1000));
2381} 2330}
2382 2331
2383static void dsi_set_stop_state_counter(unsigned long ns) 2332static void dsi_set_stop_state_counter(unsigned ticks, bool x4, bool x16)
2384{ 2333{
2385 u32 r;
2386 unsigned x4, x16;
2387 unsigned long fck; 2334 unsigned long fck;
2388 unsigned long ticks; 2335 unsigned long total_ticks;
2336 u32 r;
2389 2337
2390 /* ticks in DSI_FCK */ 2338 BUG_ON(ticks > 0x1fff);
2391 2339
2340 /* ticks in DSI_FCK */
2392 fck = dsi_fclk_rate(); 2341 fck = dsi_fclk_rate();
2393 ticks = (fck / 1000 / 1000) * ns / 1000;
2394 x4 = 0;
2395 x16 = 0;
2396
2397 if (ticks > 0x1fff) {
2398 ticks = (fck / 1000 / 1000) * ns / 1000 / 4;
2399 x4 = 1;
2400 x16 = 0;
2401 }
2402
2403 if (ticks > 0x1fff) {
2404 ticks = (fck / 1000 / 1000) * ns / 1000 / 16;
2405 x4 = 0;
2406 x16 = 1;
2407 }
2408
2409 if (ticks > 0x1fff) {
2410 ticks = (fck / 1000 / 1000) * ns / 1000 / (4 * 16);
2411 x4 = 1;
2412 x16 = 1;
2413 }
2414
2415 if (ticks > 0x1fff) {
2416 DSSWARN("STOP_STATE_COUNTER_IO over limit, "
2417 "setting it to max\n");
2418 ticks = 0x1fff;
2419 x4 = 1;
2420 x16 = 1;
2421 }
2422 2342
2423 r = dsi_read_reg(DSI_TIMING1); 2343 r = dsi_read_reg(DSI_TIMING1);
2424 r = FLD_MOD(r, 1, 15, 15); /* FORCE_TX_STOP_MODE_IO */ 2344 r = FLD_MOD(r, 1, 15, 15); /* FORCE_TX_STOP_MODE_IO */
2425 r = FLD_MOD(r, x16, 14, 14); /* STOP_STATE_X16_IO */ 2345 r = FLD_MOD(r, x16 ? 1 : 0, 14, 14); /* STOP_STATE_X16_IO */
2426 r = FLD_MOD(r, x4, 13, 13); /* STOP_STATE_X4_IO */ 2346 r = FLD_MOD(r, x4 ? 1 : 0, 13, 13); /* STOP_STATE_X4_IO */
2427 r = FLD_MOD(r, ticks, 12, 0); /* STOP_STATE_COUNTER_IO */ 2347 r = FLD_MOD(r, ticks, 12, 0); /* STOP_STATE_COUNTER_IO */
2428 dsi_write_reg(DSI_TIMING1, r); 2348 dsi_write_reg(DSI_TIMING1, r);
2429 2349
2430 DSSDBG("STOP_STATE_COUNTER %lu ns (%#lx ticks%s%s)\n", 2350 total_ticks = ticks * (x16 ? 16 : 1) * (x4 ? 4 : 1);
2431 (ticks * (x16 ? 16 : 1) * (x4 ? 4 : 1) * 1000) / 2351
2432 (fck / 1000 / 1000), 2352 DSSDBG("STOP_STATE_COUNTER %lu ticks (%#x%s%s) = %lu ns\n",
2433 ticks, x4 ? " x4" : "", x16 ? " x16" : ""); 2353 total_ticks,
2354 ticks, x4 ? " x4" : "", x16 ? " x16" : "",
2355 (total_ticks * 1000) / (fck / 1000 / 1000));
2434} 2356}
2435 2357
2436static void dsi_set_hs_tx_timeout(unsigned long ns) 2358static void dsi_set_hs_tx_timeout(unsigned ticks, bool x4, bool x16)
2437{ 2359{
2438 u32 r;
2439 unsigned x4, x16;
2440 unsigned long fck; 2360 unsigned long fck;
2441 unsigned long ticks; 2361 unsigned long total_ticks;
2362 u32 r;
2442 2363
2443 /* ticks in TxByteClkHS */ 2364 BUG_ON(ticks > 0x1fff);
2444 2365
2366 /* ticks in TxByteClkHS */
2445 fck = dsi_get_txbyteclkhs(); 2367 fck = dsi_get_txbyteclkhs();
2446 ticks = (fck / 1000 / 1000) * ns / 1000;
2447 x4 = 0;
2448 x16 = 0;
2449
2450 if (ticks > 0x1fff) {
2451 ticks = (fck / 1000 / 1000) * ns / 1000 / 4;
2452 x4 = 1;
2453 x16 = 0;
2454 }
2455
2456 if (ticks > 0x1fff) {
2457 ticks = (fck / 1000 / 1000) * ns / 1000 / 16;
2458 x4 = 0;
2459 x16 = 1;
2460 }
2461
2462 if (ticks > 0x1fff) {
2463 ticks = (fck / 1000 / 1000) * ns / 1000 / (4 * 16);
2464 x4 = 1;
2465 x16 = 1;
2466 }
2467
2468 if (ticks > 0x1fff) {
2469 DSSWARN("HS_TX_TO over limit, setting it to max\n");
2470 ticks = 0x1fff;
2471 x4 = 1;
2472 x16 = 1;
2473 }
2474 2368
2475 r = dsi_read_reg(DSI_TIMING2); 2369 r = dsi_read_reg(DSI_TIMING2);
2476 r = FLD_MOD(r, 1, 31, 31); /* HS_TX_TO */ 2370 r = FLD_MOD(r, 1, 31, 31); /* HS_TX_TO */
2477 r = FLD_MOD(r, x16, 30, 30); /* HS_TX_TO_X16 */ 2371 r = FLD_MOD(r, x16 ? 1 : 0, 30, 30); /* HS_TX_TO_X16 */
2478 r = FLD_MOD(r, x4, 29, 29); /* HS_TX_TO_X8 (4 really) */ 2372 r = FLD_MOD(r, x4 ? 1 : 0, 29, 29); /* HS_TX_TO_X8 (4 really) */
2479 r = FLD_MOD(r, ticks, 28, 16); /* HS_TX_TO_COUNTER */ 2373 r = FLD_MOD(r, ticks, 28, 16); /* HS_TX_TO_COUNTER */
2480 dsi_write_reg(DSI_TIMING2, r); 2374 dsi_write_reg(DSI_TIMING2, r);
2481 2375
2482 DSSDBG("HS_TX_TO %lu ns (%#lx ticks%s%s)\n", 2376 total_ticks = ticks * (x16 ? 16 : 1) * (x4 ? 4 : 1);
2483 (ticks * (x16 ? 16 : 1) * (x4 ? 4 : 1) * 1000) / 2377
2484 (fck / 1000 / 1000), 2378 DSSDBG("HS_TX_TO %lu ticks (%#x%s%s) = %lu ns\n",
2485 ticks, x4 ? " x4" : "", x16 ? " x16" : ""); 2379 total_ticks,
2380 ticks, x4 ? " x4" : "", x16 ? " x16" : "",
2381 (total_ticks * 1000) / (fck / 1000 / 1000));
2486} 2382}
2487static int dsi_proto_config(struct omap_dss_device *dssdev) 2383static int dsi_proto_config(struct omap_dss_device *dssdev)
2488{ 2384{
@@ -2500,10 +2396,10 @@ static int dsi_proto_config(struct omap_dss_device *dssdev)
2500 DSI_FIFO_SIZE_32); 2396 DSI_FIFO_SIZE_32);
2501 2397
2502 /* XXX what values for the timeouts? */ 2398 /* XXX what values for the timeouts? */
2503 dsi_set_stop_state_counter(1000); 2399 dsi_set_stop_state_counter(0x1000, false, false);
2504 dsi_set_ta_timeout(6400000); 2400 dsi_set_ta_timeout(0x1fff, true, true);
2505 dsi_set_lp_rx_timeout(48000); 2401 dsi_set_lp_rx_timeout(0x1fff, true, true);
2506 dsi_set_hs_tx_timeout(8000000); 2402 dsi_set_hs_tx_timeout(0x1fff, true, true);
2507 2403
2508 switch (dssdev->ctrl.pixel_size) { 2404 switch (dssdev->ctrl.pixel_size) {
2509 case 16: 2405 case 16: