Skip to content

Commit 3f17522

Browse files
author
Russell King
committed
Video: ARM CLCD: Better fix for swapped IENB and CNTL registers
On PL111, as found on Realview and other platforms, these registers are always arranged as CNTL then IENB. On PL110, these registers are IENB then CNTL, except on Versatile platforms. Re-arrange the handling of these register swaps so that PL111 always gets it right without resorting to ifdefs, leaving the only case needing special handling being PL110 on Versatile. Fill out amba/clcd.h with the PL110/PL111 register definition differences in case someone tries to use the PL110 specific definitions on PL111. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 1027247 commit 3f17522

2 files changed

Lines changed: 41 additions & 23 deletions

File tree

‎drivers/video/amba-clcd.c‎

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ static void clcdfb_disable(struct clcd_fb *fb)
6565
if (fb->board->disable)
6666
fb->board->disable(fb);
6767

68-
val = readl(fb->regs + CLCD_CNTL);
68+
val = readl(fb->regs + fb->off_cntl);
6969
if (val & CNTL_LCDPWR) {
7070
val &= ~CNTL_LCDPWR;
71-
writel(val, fb->regs + CLCD_CNTL);
71+
writel(val, fb->regs + fb->off_cntl);
7272

7373
clcdfb_sleep(20);
7474
}
7575
if (val & CNTL_LCDEN) {
7676
val &= ~CNTL_LCDEN;
77-
writel(val, fb->regs + CLCD_CNTL);
77+
writel(val, fb->regs + fb->off_cntl);
7878
}
7979

8080
/*
@@ -94,15 +94,15 @@ static void clcdfb_enable(struct clcd_fb *fb, u32 cntl)
9494
* Bring up by first enabling..
9595
*/
9696
cntl |= CNTL_LCDEN;
97-
writel(cntl, fb->regs + CLCD_CNTL);
97+
writel(cntl, fb->regs + fb->off_cntl);
9898

9999
clcdfb_sleep(20);
100100

101101
/*
102102
* and now apply power.
103103
*/
104104
cntl |= CNTL_LCDPWR;
105-
writel(cntl, fb->regs + CLCD_CNTL);
105+
writel(cntl, fb->regs + fb->off_cntl);
106106

107107
/*
108108
* finally, enable the interface.
@@ -233,7 +233,7 @@ static int clcdfb_set_par(struct fb_info *info)
233233
readl(fb->regs + CLCD_TIM0), readl(fb->regs + CLCD_TIM1),
234234
readl(fb->regs + CLCD_TIM2), readl(fb->regs + CLCD_TIM3),
235235
readl(fb->regs + CLCD_UBAS), readl(fb->regs + CLCD_LBAS),
236-
readl(fb->regs + CLCD_IENB), readl(fb->regs + CLCD_CNTL));
236+
readl(fb->regs + fb->off_ienb), readl(fb->regs + fb->off_cntl));
237237
#endif
238238

239239
return 0;
@@ -345,6 +345,23 @@ static int clcdfb_register(struct clcd_fb *fb)
345345
{
346346
int ret;
347347

348+
/*
349+
* ARM PL111 always has IENB at 0x1c; it's only PL110
350+
* which is reversed on some platforms.
351+
*/
352+
if (amba_manf(fb->dev) == 0x41 && amba_part(fb->dev) == 0x111) {
353+
fb->off_ienb = CLCD_PL111_IENB;
354+
fb->off_cntl = CLCD_PL111_CNTL;
355+
} else {
356+
#ifdef CONFIG_ARCH_VERSATILE
357+
fb->off_ienb = CLCD_PL111_IENB;
358+
fb->off_cntl = CLCD_PL111_CNTL;
359+
#else
360+
fb->off_ienb = CLCD_PL110_IENB;
361+
fb->off_cntl = CLCD_PL110_CNTL;
362+
#endif
363+
}
364+
348365
fb->clk = clk_get(&fb->dev->dev, NULL);
349366
if (IS_ERR(fb->clk)) {
350367
ret = PTR_ERR(fb->clk);
@@ -416,7 +433,7 @@ static int clcdfb_register(struct clcd_fb *fb)
416433
/*
417434
* Ensure interrupts are disabled.
418435
*/
419-
writel(0, fb->regs + CLCD_IENB);
436+
writel(0, fb->regs + fb->off_ienb);
420437

421438
fb_set_var(&fb->fb, &fb->fb.var);
422439

‎include/linux/amba/clcd.h‎

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,21 @@
2121
#define CLCD_UBAS 0x00000010
2222
#define CLCD_LBAS 0x00000014
2323

24-
#if !defined(CONFIG_ARCH_VERSATILE) && !defined(CONFIG_ARCH_REALVIEW)
25-
#define CLCD_IENB 0x00000018
26-
#define CLCD_CNTL 0x0000001c
27-
#else
28-
/*
29-
* Someone rearranged these two registers on the Versatile
30-
* platform...
31-
*/
32-
#define CLCD_IENB 0x0000001c
33-
#define CLCD_CNTL 0x00000018
34-
#endif
35-
36-
#define CLCD_STAT 0x00000020
37-
#define CLCD_INTR 0x00000024
38-
#define CLCD_UCUR 0x00000028
39-
#define CLCD_LCUR 0x0000002C
24+
#define CLCD_PL110_IENB 0x00000018
25+
#define CLCD_PL110_CNTL 0x0000001c
26+
#define CLCD_PL110_STAT 0x00000020
27+
#define CLCD_PL110_INTR 0x00000024
28+
#define CLCD_PL110_UCUR 0x00000028
29+
#define CLCD_PL110_LCUR 0x0000002C
30+
31+
#define CLCD_PL111_CNTL 0x00000018
32+
#define CLCD_PL111_IENB 0x0000001c
33+
#define CLCD_PL111_RIS 0x00000020
34+
#define CLCD_PL111_MIS 0x00000024
35+
#define CLCD_PL111_ICR 0x00000028
36+
#define CLCD_PL111_UCUR 0x0000002c
37+
#define CLCD_PL111_LCUR 0x00000030
38+
4039
#define CLCD_PALL 0x00000200
4140
#define CLCD_PALETTE 0x00000200
4241

@@ -147,6 +146,8 @@ struct clcd_fb {
147146
struct clcd_board *board;
148147
void *board_data;
149148
void __iomem *regs;
149+
u16 off_ienb;
150+
u16 off_cntl;
150151
u32 clcd_cntl;
151152
u32 cmap[16];
152153
};

0 commit comments

Comments
 (0)