aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/sh_mobile_meram.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2011-07-13 06:13:47 -0400
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2011-08-19 02:22:42 -0400
commitf0a260fef6943c60bae65ae52fc4fa52e7f078b1 (patch)
tree1760bb0ea8daf442fd3edd0bafadf6d5be86b7ac /drivers/video/sh_mobile_meram.c
parent2427bb241b1db35c6e699ad55adf4a30083b79cd (diff)
fbdev: sh_mobile_meram: Replace hardcoded register values with macros
Instead of hardcoding register values through the driver, define macros for individual register bits using the register name and the bit name, and use the macros. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'drivers/video/sh_mobile_meram.c')
-rw-r--r--drivers/video/sh_mobile_meram.c97
1 files changed, 71 insertions, 26 deletions
diff --git a/drivers/video/sh_mobile_meram.c b/drivers/video/sh_mobile_meram.c
index 39f28a1aa074..85577cf9ff58 100644
--- a/drivers/video/sh_mobile_meram.c
+++ b/drivers/video/sh_mobile_meram.c
@@ -20,22 +20,67 @@
20#include "sh_mobile_meram.h" 20#include "sh_mobile_meram.h"
21 21
22/* meram registers */ 22/* meram registers */
23#define MExxCTL 0x0 23#define MEVCR1 0x4
24#define MExxBSIZE 0x4 24#define MEVCR1_RST (1 << 31)
25#define MExxMNCF 0x8 25#define MEVCR1_WD (1 << 30)
26#define MExxSARA 0x10 26#define MEVCR1_AMD1 (1 << 29)
27#define MExxSARB 0x14 27#define MEVCR1_AMD0 (1 << 28)
28#define MExxSBSIZE 0x18 28#define MEQSEL1 0x40
29 29#define MEQSEL2 0x44
30#define MERAM_MExxCTL_VAL(ctl, next_icb, addr) \ 30
31 ((ctl) | (((next_icb) & 0x1f) << 11) | (((addr) & 0x7ff) << 16)) 31#define MExxCTL 0x400
32#define MERAM_MExxBSIZE_VAL(a, b, c) \ 32#define MExxCTL_BV (1 << 31)
33 (((a) << 28) | ((b) << 16) | (c)) 33#define MExxCTL_BSZ_SHIFT 28
34 34#define MExxCTL_MSAR_MASK (0x7ff << MExxCTL_MSAR_SHIFT)
35#define MEVCR1 0x4 35#define MExxCTL_MSAR_SHIFT 16
36#define MEACTS 0x10 36#define MExxCTL_NXT_MASK (0x1f << MExxCTL_NXT_SHIFT)
37#define MEQSEL1 0x40 37#define MExxCTL_NXT_SHIFT 11
38#define MEQSEL2 0x44 38#define MExxCTL_WD1 (1 << 10)
39#define MExxCTL_WD0 (1 << 9)
40#define MExxCTL_WS (1 << 8)
41#define MExxCTL_CB (1 << 7)
42#define MExxCTL_WBF (1 << 6)
43#define MExxCTL_WF (1 << 5)
44#define MExxCTL_RF (1 << 4)
45#define MExxCTL_CM (1 << 3)
46#define MExxCTL_MD_READ (1 << 0)
47#define MExxCTL_MD_WRITE (2 << 0)
48#define MExxCTL_MD_ICB_WB (3 << 0)
49#define MExxCTL_MD_ICB (4 << 0)
50#define MExxCTL_MD_FB (7 << 0)
51#define MExxCTL_MD_MASK (7 << 0)
52#define MExxBSIZE 0x404
53#define MExxBSIZE_RCNT_SHIFT 28
54#define MExxBSIZE_YSZM1_SHIFT 16
55#define MExxBSIZE_XSZM1_SHIFT 0
56#define MExxMNCF 0x408
57#define MExxMNCF_KWBNM_SHIFT 28
58#define MExxMNCF_KRBNM_SHIFT 24
59#define MExxMNCF_BNM_SHIFT 16
60#define MExxMNCF_XBV (1 << 15)
61#define MExxMNCF_CPL_YCBCR444 (1 << 12)
62#define MExxMNCF_CPL_YCBCR420 (2 << 12)
63#define MExxMNCF_CPL_YCBCR422 (3 << 12)
64#define MExxMNCF_CPL_MSK (3 << 12)
65#define MExxMNCF_BL (1 << 2)
66#define MExxMNCF_LNM_SHIFT 0
67#define MExxSARA 0x410
68#define MExxSARB 0x414
69#define MExxSBSIZE 0x418
70#define MExxSBSIZE_HDV (1 << 31)
71#define MExxSBSIZE_HSZ16 (0 << 28)
72#define MExxSBSIZE_HSZ32 (1 << 28)
73#define MExxSBSIZE_HSZ64 (2 << 28)
74#define MExxSBSIZE_HSZ128 (3 << 28)
75#define MExxSBSIZE_SBSIZZ_SHIFT 0
76
77#define MERAM_MExxCTL_VAL(next, addr) \
78 ((((next) << MExxCTL_NXT_SHIFT) & MExxCTL_NXT_MASK) | \
79 (((addr) << MExxCTL_MSAR_SHIFT) & MExxCTL_MSAR_MASK))
80#define MERAM_MExxBSIZE_VAL(rcnt, yszm1, xszm1) \
81 (((rcnt) << MExxBSIZE_RCNT_SHIFT) | \
82 ((yszm1) << MExxBSIZE_YSZM1_SHIFT) | \
83 ((xszm1) << MExxBSIZE_XSZM1_SHIFT))
39 84
40static unsigned long common_regs[] = { 85static unsigned long common_regs[] = {
41 MEVCR1, 86 MEVCR1,
@@ -72,8 +117,7 @@ struct sh_mobile_meram_priv {
72 * MERAM/ICB access functions 117 * MERAM/ICB access functions
73 */ 118 */
74 119
75#define MERAM_ICB_OFFSET(base, idx, off) \ 120#define MERAM_ICB_OFFSET(base, idx, off) ((base) + (off) + (idx) * 0x20)
76 ((base) + (0x400 + ((idx) * 0x20) + (off)))
77 121
78static inline void meram_write_icb(void __iomem *base, int idx, int off, 122static inline void meram_write_icb(void __iomem *base, int idx, int off,
79 unsigned long val) 123 unsigned long val)
@@ -308,17 +352,18 @@ static int meram_init(struct sh_mobile_meram_priv *priv,
308 /* 352 /*
309 * Set MERAM for framebuffer 353 * Set MERAM for framebuffer
310 * 354 *
311 * 0x70f: WD = 0x3, WS=0x1, CM=0x1, MD=FB mode
312 * we also chain the cache_icb and the marker_icb. 355 * we also chain the cache_icb and the marker_icb.
313 * we also split the allocated MERAM buffer between two ICBs. 356 * we also split the allocated MERAM buffer between two ICBs.
314 */ 357 */
315 meram_write_icb(priv->base, icb->cache_icb, MExxCTL, 358 meram_write_icb(priv->base, icb->cache_icb, MExxCTL,
316 MERAM_MExxCTL_VAL(0x70f, icb->marker_icb, 359 MERAM_MExxCTL_VAL(icb->marker_icb, icb->meram_offset) |
317 icb->meram_offset)); 360 MExxCTL_WD1 | MExxCTL_WD0 | MExxCTL_WS | MExxCTL_CM |
361 MExxCTL_MD_FB);
318 meram_write_icb(priv->base, icb->marker_icb, MExxCTL, 362 meram_write_icb(priv->base, icb->marker_icb, MExxCTL,
319 MERAM_MExxCTL_VAL(0x70f, icb->cache_icb, 363 MERAM_MExxCTL_VAL(icb->cache_icb, icb->meram_offset +
320 icb->meram_offset + 364 icb->meram_size / 2) |
321 icb->meram_size / 2)); 365 MExxCTL_WD1 | MExxCTL_WD0 | MExxCTL_WS | MExxCTL_CM |
366 MExxCTL_MD_FB);
322 367
323 return 0; 368 return 0;
324} 369}
@@ -507,7 +552,7 @@ static int sh_mobile_meram_runtime_suspend(struct device *dev)
507 /* Reset ICB on resume */ 552 /* Reset ICB on resume */
508 if (icb_regs[k] == MExxCTL) 553 if (icb_regs[k] == MExxCTL)
509 priv->icb_saved_regs[j * ICB_REGS_SIZE + k] = 554 priv->icb_saved_regs[j * ICB_REGS_SIZE + k] =
510 0x70; 555 MExxCTL_WBF | MExxCTL_WF | MExxCTL_RF;
511 } 556 }
512 } 557 }
513 return 0; 558 return 0;
@@ -592,7 +637,7 @@ static int __devinit sh_mobile_meram_probe(struct platform_device *pdev)
592 637
593 /* initialize ICB addressing mode */ 638 /* initialize ICB addressing mode */
594 if (pdata->addr_mode == SH_MOBILE_MERAM_MODE1) 639 if (pdata->addr_mode == SH_MOBILE_MERAM_MODE1)
595 meram_write_reg(priv->base, MEVCR1, 1 << 29); 640 meram_write_reg(priv->base, MEVCR1, MEVCR1_AMD1);
596 641
597 pm_runtime_enable(&pdev->dev); 642 pm_runtime_enable(&pdev->dev);
598 643