Skip to content

Commit 046ad6c

Browse files
Linus Walleijtomba
authored andcommitted
video: ARM CLCD: support Nomadik variant
The Nomadik variant has a few special quirks that need to be respected to make the driver work: - The block need to be clocked during writing of the TIMn registers or the bus will stall. - Special bits in the control register select how many of the output display lines get activated. - Special bits in the control register select how to manage the different 565 and 5551 modes. - There is a packed 24bit graphics mode, i.e 888 pixels can be stored in memory is three consecutive bytes, not evenly aligned to a 32bit word. This patch uses the vendor data pointer from the AMBA matching mechanism to track the quirks for this variant, and adds two hooks that variants can use to initialize boards and panels during start-up. These will later be used to adopt a Nomadik board profile. Cc: Pawel Moll <pawel.moll@arm.com> Cc: Rob Herring <robh@kernel.org> Cc: Russell King <linux@arm.linux.org.uk> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
1 parent 03d14c3 commit 046ad6c

2 files changed

Lines changed: 139 additions & 9 deletions

File tree

‎drivers/video/fbdev/amba-clcd.c‎

Lines changed: 97 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,15 @@ clcdfb_set_bitfields(struct clcd_fb *fb, struct fb_var_screeninfo *var)
225225
var->blue.length = 4;
226226
}
227227
break;
228+
case 24:
229+
if (fb->vendor->packed_24_bit_pixels) {
230+
var->red.length = 8;
231+
var->green.length = 8;
232+
var->blue.length = 8;
233+
} else {
234+
ret = -EINVAL;
235+
}
236+
break;
228237
case 32:
229238
/* If we can't do 888, reject */
230239
caps &= CLCD_CAP_888;
@@ -311,6 +320,12 @@ static int clcdfb_set_par(struct fb_info *info)
311320

312321
clcdfb_disable(fb);
313322

323+
/* Some variants must be clocked here */
324+
if (fb->vendor->clock_timregs && !fb->clk_enabled) {
325+
fb->clk_enabled = true;
326+
clk_enable(fb->clk);
327+
}
328+
314329
writel(regs.tim0, fb->regs + CLCD_TIM0);
315330
writel(regs.tim1, fb->regs + CLCD_TIM1);
316331
writel(regs.tim2, fb->regs + CLCD_TIM2);
@@ -710,6 +725,42 @@ static int clcdfb_of_init_tft_panel(struct clcd_fb *fb, u32 r0, u32 g0, u32 b0)
710725
if (r0 != 0 && b0 == 0)
711726
fb->panel->bgr_connection = true;
712727

728+
if (fb->panel->caps && fb->vendor->st_bitmux_control) {
729+
/*
730+
* Set up the special bits for the Nomadik control register
731+
* (other platforms tend to do this through an external
732+
* register).
733+
*/
734+
735+
/* Offset of the highest used color */
736+
int maxoff = max3(r0, g0, b0);
737+
/* Most significant bit out, highest used bit */
738+
int msb = 0;
739+
740+
if (fb->panel->caps & CLCD_CAP_888) {
741+
msb = maxoff + 8 - 1;
742+
} else if (fb->panel->caps & CLCD_CAP_565) {
743+
msb = maxoff + 5 - 1;
744+
fb->panel->cntl |= CNTL_ST_1XBPP_565;
745+
} else if (fb->panel->caps & CLCD_CAP_5551) {
746+
msb = maxoff + 5 - 1;
747+
fb->panel->cntl |= CNTL_ST_1XBPP_5551;
748+
} else if (fb->panel->caps & CLCD_CAP_444) {
749+
msb = maxoff + 4 - 1;
750+
fb->panel->cntl |= CNTL_ST_1XBPP_444;
751+
}
752+
753+
/* Send out as many bits as we need */
754+
if (msb > 17)
755+
fb->panel->cntl |= CNTL_ST_CDWID_24;
756+
else if (msb > 15)
757+
fb->panel->cntl |= CNTL_ST_CDWID_18;
758+
else if (msb > 11)
759+
fb->panel->cntl |= CNTL_ST_CDWID_16;
760+
else
761+
fb->panel->cntl |= CNTL_ST_CDWID_12;
762+
}
763+
713764
return fb->panel->caps ? 0 : -EINVAL;
714765
}
715766

@@ -725,9 +776,21 @@ static int clcdfb_of_init_display(struct clcd_fb *fb)
725776
if (!fb->panel)
726777
return -ENOMEM;
727778

728-
endpoint = of_graph_get_next_endpoint(fb->dev->dev.of_node, NULL);
729-
if (!endpoint)
730-
return -ENODEV;
779+
/*
780+
* Fetch the panel endpoint.
781+
*/
782+
if (!endpoint) {
783+
endpoint = of_graph_get_next_endpoint(fb->dev->dev.of_node,
784+
NULL);
785+
if (!endpoint)
786+
return -ENODEV;
787+
}
788+
789+
if (fb->vendor->init_panel) {
790+
err = fb->vendor->init_panel(fb, endpoint);
791+
if (err)
792+
return err;
793+
}
731794

732795
err = clcdfb_of_get_backlight(endpoint, fb->panel);
733796
if (err)
@@ -764,11 +827,11 @@ static int clcdfb_of_init_display(struct clcd_fb *fb)
764827

765828
if (of_property_read_u32_array(endpoint,
766829
"arm,pl11x,tft-r0g0b0-pads",
767-
tft_r0b0g0, ARRAY_SIZE(tft_r0b0g0)) == 0)
768-
return clcdfb_of_init_tft_panel(fb, tft_r0b0g0[0],
769-
tft_r0b0g0[1], tft_r0b0g0[2]);
830+
tft_r0b0g0, ARRAY_SIZE(tft_r0b0g0)) != 0)
831+
return -ENOENT;
770832

771-
return -ENOENT;
833+
return clcdfb_of_init_tft_panel(fb, tft_r0b0g0[0],
834+
tft_r0b0g0[1], tft_r0b0g0[2]);
772835
}
773836

774837
static int clcdfb_of_vram_setup(struct clcd_fb *fb)
@@ -889,6 +952,7 @@ static struct clcd_board *clcdfb_of_get_board(struct amba_device *dev)
889952
static int clcdfb_probe(struct amba_device *dev, const struct amba_id *id)
890953
{
891954
struct clcd_board *board = dev_get_platdata(&dev->dev);
955+
struct clcd_vendor_data *vendor = id->data;
892956
struct clcd_fb *fb;
893957
int ret;
894958

@@ -898,6 +962,12 @@ static int clcdfb_probe(struct amba_device *dev, const struct amba_id *id)
898962
if (!board)
899963
return -EINVAL;
900964

965+
if (vendor->init_board) {
966+
ret = vendor->init_board(dev, board);
967+
if (ret)
968+
return ret;
969+
}
970+
901971
ret = dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32));
902972
if (ret)
903973
goto out;
@@ -916,10 +986,11 @@ static int clcdfb_probe(struct amba_device *dev, const struct amba_id *id)
916986
}
917987

918988
fb->dev = dev;
989+
fb->vendor = vendor;
919990
fb->board = board;
920991

921-
dev_info(&fb->dev->dev, "PL%03x rev%u at 0x%08llx\n",
922-
amba_part(dev), amba_rev(dev),
992+
dev_info(&fb->dev->dev, "PL%03x designer %02x rev%u at 0x%08llx\n",
993+
amba_part(dev), amba_manf(dev), amba_rev(dev),
923994
(unsigned long long)dev->res.start);
924995

925996
ret = fb->board->setup(fb);
@@ -962,10 +1033,27 @@ static int clcdfb_remove(struct amba_device *dev)
9621033
return 0;
9631034
}
9641035

1036+
static struct clcd_vendor_data vendor_arm = {
1037+
/* No special business */
1038+
};
1039+
1040+
static struct clcd_vendor_data vendor_nomadik = {
1041+
.clock_timregs = true,
1042+
.packed_24_bit_pixels = true,
1043+
.st_bitmux_control = true,
1044+
};
1045+
9651046
static struct amba_id clcdfb_id_table[] = {
9661047
{
9671048
.id = 0x00041110,
9681049
.mask = 0x000ffffe,
1050+
.data = &vendor_arm,
1051+
},
1052+
/* ST Electronics Nomadik variant */
1053+
{
1054+
.id = 0x00180110,
1055+
.mask = 0x00fffffe,
1056+
.data = &vendor_nomadik,
9691057
},
9701058
{ 0, 0 },
9711059
};

‎include/linux/amba/clcd.h‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@
6767
#define CNTL_LDMAFIFOTIME (1 << 15)
6868
#define CNTL_WATERMARK (1 << 16)
6969

70+
/* ST Microelectronics variant bits */
71+
#define CNTL_ST_1XBPP_444 0x0
72+
#define CNTL_ST_1XBPP_5551 (1 << 17)
73+
#define CNTL_ST_1XBPP_565 (1 << 18)
74+
#define CNTL_ST_CDWID_12 0x0
75+
#define CNTL_ST_CDWID_16 (1 << 19)
76+
#define CNTL_ST_CDWID_18 (1 << 20)
77+
#define CNTL_ST_CDWID_24 ((1 << 19)|(1 << 20))
78+
#define CNTL_ST_CEAEN (1 << 21)
79+
#define CNTL_ST_LCDBPP24_PACKED (6 << 1)
80+
7081
enum {
7182
/* individual formats */
7283
CLCD_CAP_RGB444 = (1 << 0),
@@ -179,11 +190,38 @@ struct clcd_board {
179190
struct amba_device;
180191
struct clk;
181192

193+
/**
194+
* struct clcd_vendor_data - holds hardware (IP-block) vendor-specific
195+
* variant information
196+
*
197+
* @clock_timregs: the CLCD needs to be clocked when accessing the
198+
* timer registers, or the hardware will hang.
199+
* @packed_24_bit_pixels: this variant supports 24bit packed pixel data,
200+
* so that RGB accesses 3 bytes at a time, not just on even 32bit
201+
* boundaries, packing the pixel data in memory. ST Microelectronics
202+
* have this.
203+
* @st_bitmux_control: ST Microelectronics have implemented output
204+
* bit line multiplexing into the CLCD control register. This indicates
205+
* that we need to use this.
206+
* @init_board: custom board init function for this variant
207+
* @init_panel: custom panel init function for this variant
208+
*/
209+
struct clcd_vendor_data {
210+
bool clock_timregs;
211+
bool packed_24_bit_pixels;
212+
bool st_bitmux_control;
213+
int (*init_board)(struct amba_device *adev,
214+
struct clcd_board *board);
215+
int (*init_panel)(struct clcd_fb *fb,
216+
struct device_node *panel);
217+
};
218+
182219
/* this data structure describes each frame buffer device we find */
183220
struct clcd_fb {
184221
struct fb_info fb;
185222
struct amba_device *dev;
186223
struct clk *clk;
224+
struct clcd_vendor_data *vendor;
187225
struct clcd_panel *panel;
188226
struct clcd_board *board;
189227
void *board_data;
@@ -285,6 +323,10 @@ static inline void clcdfb_decode(struct clcd_fb *fb, struct clcd_regs *regs)
285323
else
286324
val |= CNTL_LCDBPP16_444;
287325
break;
326+
case 24:
327+
/* Modified variant supporting 24 bit packed pixels */
328+
val |= CNTL_ST_LCDBPP24_PACKED;
329+
break;
288330
case 32:
289331
val |= CNTL_LCDBPP24;
290332
break;

0 commit comments

Comments
 (0)