2 * Driver for AT91 LCD Controller
4 * Copyright (C) 2007 Atmel Corporation
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive for
11 #include <linux/kernel.h>
12 #include <linux/platform_device.h>
13 #include <linux/dma-mapping.h>
14 #include <linux/interrupt.h>
15 #include <linux/clk.h>
17 #include <linux/init.h>
18 #include <linux/delay.h>
19 #include <linux/backlight.h>
20 #include <linux/gfp.h>
21 #include <linux/gpio/consumer.h>
22 #include <linux/module.h>
24 #include <linux/of_device.h>
25 #include <video/of_videomode.h>
26 #include <video/of_display_timing.h>
27 #include <linux/regulator/consumer.h>
28 #include <video/videomode.h>
30 #include <video/atmel_lcdc.h>
32 struct atmel_lcdfb_config
{
33 bool have_alt_pixclock
;
35 bool have_intensity_bit
;
38 /* LCD Controller info data structure, stored in device platform_data */
39 struct atmel_lcdfb_info
{
44 struct work_struct task
;
46 unsigned int smem_len
;
47 struct platform_device
*pdev
;
51 struct backlight_device
*backlight
;
55 u32 pseudo_palette
[16];
56 bool have_intensity_bit
;
58 struct atmel_lcdfb_pdata pdata
;
60 struct atmel_lcdfb_config
*config
;
61 struct regulator
*reg_lcd
;
64 struct atmel_lcdfb_power_ctrl_gpio
{
65 struct gpio_desc
*gpiod
;
67 struct list_head list
;
70 #define lcdc_readl(sinfo, reg) __raw_readl((sinfo)->mmio+(reg))
71 #define lcdc_writel(sinfo, reg, val) __raw_writel((val), (sinfo)->mmio+(reg))
73 /* configurable parameters */
74 #define ATMEL_LCDC_CVAL_DEFAULT 0xc8
75 #define ATMEL_LCDC_DMA_BURST_LEN 8 /* words */
76 #define ATMEL_LCDC_FIFO_SIZE 512 /* words */
78 static struct atmel_lcdfb_config at91sam9261_config
= {
80 .have_intensity_bit
= true,
83 static struct atmel_lcdfb_config at91sam9263_config
= {
84 .have_intensity_bit
= true,
87 static struct atmel_lcdfb_config at91sam9g10_config
= {
91 static struct atmel_lcdfb_config at91sam9g45_config
= {
92 .have_alt_pixclock
= true,
95 static struct atmel_lcdfb_config at91sam9g45es_config
= {
98 static struct atmel_lcdfb_config at91sam9rl_config
= {
99 .have_intensity_bit
= true,
102 static u32 contrast_ctr
= ATMEL_LCDC_PS_DIV8
103 | ATMEL_LCDC_POL_POSITIVE
104 | ATMEL_LCDC_ENA_PWMENABLE
;
106 #ifdef CONFIG_BACKLIGHT_ATMEL_LCDC
108 /* some bl->props field just changed */
109 static int atmel_bl_update_status(struct backlight_device
*bl
)
111 struct atmel_lcdfb_info
*sinfo
= bl_get_data(bl
);
112 int power
= sinfo
->bl_power
;
113 int brightness
= bl
->props
.brightness
;
115 /* REVISIT there may be a meaningful difference between
116 * fb_blank and power ... there seem to be some cases
117 * this doesn't handle correctly.
119 if (bl
->props
.fb_blank
!= sinfo
->bl_power
)
120 power
= bl
->props
.fb_blank
;
121 else if (bl
->props
.power
!= sinfo
->bl_power
)
122 power
= bl
->props
.power
;
124 if (brightness
< 0 && power
== FB_BLANK_UNBLANK
)
125 brightness
= lcdc_readl(sinfo
, ATMEL_LCDC_CONTRAST_VAL
);
126 else if (power
!= FB_BLANK_UNBLANK
)
129 lcdc_writel(sinfo
, ATMEL_LCDC_CONTRAST_VAL
, brightness
);
130 if (contrast_ctr
& ATMEL_LCDC_POL_POSITIVE
)
131 lcdc_writel(sinfo
, ATMEL_LCDC_CONTRAST_CTR
,
132 brightness
? contrast_ctr
: 0);
134 lcdc_writel(sinfo
, ATMEL_LCDC_CONTRAST_CTR
, contrast_ctr
);
136 bl
->props
.fb_blank
= bl
->props
.power
= sinfo
->bl_power
= power
;
141 static int atmel_bl_get_brightness(struct backlight_device
*bl
)
143 struct atmel_lcdfb_info
*sinfo
= bl_get_data(bl
);
145 return lcdc_readl(sinfo
, ATMEL_LCDC_CONTRAST_VAL
);
148 static const struct backlight_ops atmel_lcdc_bl_ops
= {
149 .update_status
= atmel_bl_update_status
,
150 .get_brightness
= atmel_bl_get_brightness
,
153 static void init_backlight(struct atmel_lcdfb_info
*sinfo
)
155 struct backlight_properties props
;
156 struct backlight_device
*bl
;
158 sinfo
->bl_power
= FB_BLANK_UNBLANK
;
160 if (sinfo
->backlight
)
163 memset(&props
, 0, sizeof(struct backlight_properties
));
164 props
.type
= BACKLIGHT_RAW
;
165 props
.max_brightness
= 0xff;
166 bl
= backlight_device_register("backlight", &sinfo
->pdev
->dev
, sinfo
,
167 &atmel_lcdc_bl_ops
, &props
);
169 dev_err(&sinfo
->pdev
->dev
, "error %ld on backlight register\n",
173 sinfo
->backlight
= bl
;
175 bl
->props
.power
= FB_BLANK_UNBLANK
;
176 bl
->props
.fb_blank
= FB_BLANK_UNBLANK
;
177 bl
->props
.brightness
= atmel_bl_get_brightness(bl
);
180 static void exit_backlight(struct atmel_lcdfb_info
*sinfo
)
182 if (!sinfo
->backlight
)
185 if (sinfo
->backlight
->ops
) {
186 sinfo
->backlight
->props
.power
= FB_BLANK_POWERDOWN
;
187 sinfo
->backlight
->ops
->update_status(sinfo
->backlight
);
189 backlight_device_unregister(sinfo
->backlight
);
194 static void init_backlight(struct atmel_lcdfb_info
*sinfo
)
196 dev_warn(&sinfo
->pdev
->dev
, "backlight control is not available\n");
199 static void exit_backlight(struct atmel_lcdfb_info
*sinfo
)
205 static void init_contrast(struct atmel_lcdfb_info
*sinfo
)
207 struct atmel_lcdfb_pdata
*pdata
= &sinfo
->pdata
;
209 /* contrast pwm can be 'inverted' */
210 if (pdata
->lcdcon_pol_negative
)
211 contrast_ctr
&= ~(ATMEL_LCDC_POL_POSITIVE
);
213 /* have some default contrast/backlight settings */
214 lcdc_writel(sinfo
, ATMEL_LCDC_CONTRAST_CTR
, contrast_ctr
);
215 lcdc_writel(sinfo
, ATMEL_LCDC_CONTRAST_VAL
, ATMEL_LCDC_CVAL_DEFAULT
);
217 if (pdata
->lcdcon_is_backlight
)
218 init_backlight(sinfo
);
221 static inline void atmel_lcdfb_power_control(struct atmel_lcdfb_info
*sinfo
, int on
)
224 struct atmel_lcdfb_pdata
*pdata
= &sinfo
->pdata
;
226 if (pdata
->atmel_lcdfb_power_control
)
227 pdata
->atmel_lcdfb_power_control(pdata
, on
);
228 else if (sinfo
->reg_lcd
) {
230 ret
= regulator_enable(sinfo
->reg_lcd
);
232 dev_err(&sinfo
->pdev
->dev
,
233 "lcd regulator enable failed: %d\n", ret
);
235 ret
= regulator_disable(sinfo
->reg_lcd
);
237 dev_err(&sinfo
->pdev
->dev
,
238 "lcd regulator disable failed: %d\n", ret
);
243 static const struct fb_fix_screeninfo atmel_lcdfb_fix __initconst
= {
244 .type
= FB_TYPE_PACKED_PIXELS
,
245 .visual
= FB_VISUAL_TRUECOLOR
,
249 .accel
= FB_ACCEL_NONE
,
252 static unsigned long compute_hozval(struct atmel_lcdfb_info
*sinfo
,
255 unsigned long lcdcon2
;
258 if (!sinfo
->config
->have_hozval
)
261 lcdcon2
= lcdc_readl(sinfo
, ATMEL_LCDC_LCDCON2
);
263 if ((lcdcon2
& ATMEL_LCDC_DISTYPE
) != ATMEL_LCDC_DISTYPE_TFT
) {
265 if ((lcdcon2
& ATMEL_LCDC_DISTYPE
) == ATMEL_LCDC_DISTYPE_STNCOLOR
) {
268 if ( (lcdcon2
& ATMEL_LCDC_IFWIDTH
) == ATMEL_LCDC_IFWIDTH_4
269 || ( (lcdcon2
& ATMEL_LCDC_IFWIDTH
) == ATMEL_LCDC_IFWIDTH_8
270 && (lcdcon2
& ATMEL_LCDC_SCANMOD
) == ATMEL_LCDC_SCANMOD_DUAL
))
271 value
= DIV_ROUND_UP(value
, 4);
273 value
= DIV_ROUND_UP(value
, 8);
279 static void atmel_lcdfb_stop_nowait(struct atmel_lcdfb_info
*sinfo
)
281 struct atmel_lcdfb_pdata
*pdata
= &sinfo
->pdata
;
283 /* Turn off the LCD controller and the DMA controller */
284 lcdc_writel(sinfo
, ATMEL_LCDC_PWRCON
,
285 pdata
->guard_time
<< ATMEL_LCDC_GUARDT_OFFSET
);
287 /* Wait for the LCDC core to become idle */
288 while (lcdc_readl(sinfo
, ATMEL_LCDC_PWRCON
) & ATMEL_LCDC_BUSY
)
291 lcdc_writel(sinfo
, ATMEL_LCDC_DMACON
, 0);
294 static void atmel_lcdfb_stop(struct atmel_lcdfb_info
*sinfo
)
296 atmel_lcdfb_stop_nowait(sinfo
);
298 /* Wait for DMA engine to become idle... */
299 while (lcdc_readl(sinfo
, ATMEL_LCDC_DMACON
) & ATMEL_LCDC_DMABUSY
)
303 static void atmel_lcdfb_start(struct atmel_lcdfb_info
*sinfo
)
305 struct atmel_lcdfb_pdata
*pdata
= &sinfo
->pdata
;
307 lcdc_writel(sinfo
, ATMEL_LCDC_DMACON
, pdata
->default_dmacon
);
308 lcdc_writel(sinfo
, ATMEL_LCDC_PWRCON
,
309 (pdata
->guard_time
<< ATMEL_LCDC_GUARDT_OFFSET
)
313 static void atmel_lcdfb_update_dma(struct fb_info
*info
,
314 struct fb_var_screeninfo
*var
)
316 struct atmel_lcdfb_info
*sinfo
= info
->par
;
317 struct fb_fix_screeninfo
*fix
= &info
->fix
;
318 unsigned long dma_addr
;
320 dma_addr
= (fix
->smem_start
+ var
->yoffset
* fix
->line_length
321 + var
->xoffset
* info
->var
.bits_per_pixel
/ 8);
325 /* Set framebuffer DMA base address and pixel offset */
326 lcdc_writel(sinfo
, ATMEL_LCDC_DMABADDR1
, dma_addr
);
329 static inline void atmel_lcdfb_free_video_memory(struct atmel_lcdfb_info
*sinfo
)
331 struct fb_info
*info
= sinfo
->info
;
333 dma_free_wc(info
->device
, info
->fix
.smem_len
, info
->screen_base
,
334 info
->fix
.smem_start
);
338 * atmel_lcdfb_alloc_video_memory - Allocate framebuffer memory
339 * @sinfo: the frame buffer to allocate memory for
341 * This function is called only from the atmel_lcdfb_probe()
342 * so no locking by fb_info->mm_lock around smem_len setting is needed.
344 static int atmel_lcdfb_alloc_video_memory(struct atmel_lcdfb_info
*sinfo
)
346 struct fb_info
*info
= sinfo
->info
;
347 struct fb_var_screeninfo
*var
= &info
->var
;
348 unsigned int smem_len
;
350 smem_len
= (var
->xres_virtual
* var
->yres_virtual
351 * ((var
->bits_per_pixel
+ 7) / 8));
352 info
->fix
.smem_len
= max(smem_len
, sinfo
->smem_len
);
354 info
->screen_base
= dma_alloc_wc(info
->device
, info
->fix
.smem_len
,
355 (dma_addr_t
*)&info
->fix
.smem_start
,
358 if (!info
->screen_base
) {
362 memset(info
->screen_base
, 0, info
->fix
.smem_len
);
367 static const struct fb_videomode
*atmel_lcdfb_choose_mode(struct fb_var_screeninfo
*var
,
368 struct fb_info
*info
)
370 struct fb_videomode varfbmode
;
371 const struct fb_videomode
*fbmode
= NULL
;
373 fb_var_to_videomode(&varfbmode
, var
);
374 fbmode
= fb_find_nearest_mode(&varfbmode
, &info
->modelist
);
376 fb_videomode_to_var(var
, fbmode
);
382 * atmel_lcdfb_check_var - Validates a var passed in.
383 * @var: frame buffer variable screen structure
384 * @info: frame buffer structure that represents a single frame buffer
386 * Checks to see if the hardware supports the state requested by
387 * var passed in. This function does not alter the hardware
388 * state!!! This means the data stored in struct fb_info and
389 * struct atmel_lcdfb_info do not change. This includes the var
390 * inside of struct fb_info. Do NOT change these. This function
391 * can be called on its own if we intent to only test a mode and
392 * not actually set it. The stuff in modedb.c is a example of
393 * this. If the var passed in is slightly off by what the
394 * hardware can support then we alter the var PASSED in to what
395 * we can do. If the hardware doesn't support mode change a
396 * -EINVAL will be returned by the upper layers. You don't need
397 * to implement this function then. If you hardware doesn't
398 * support changing the resolution then this function is not
399 * needed. In this case the driver would just provide a var that
400 * represents the static state the screen is in.
402 * Returns negative errno on error, or zero on success.
404 static int atmel_lcdfb_check_var(struct fb_var_screeninfo
*var
,
405 struct fb_info
*info
)
407 struct device
*dev
= info
->device
;
408 struct atmel_lcdfb_info
*sinfo
= info
->par
;
409 struct atmel_lcdfb_pdata
*pdata
= &sinfo
->pdata
;
410 unsigned long clk_value_khz
;
412 clk_value_khz
= clk_get_rate(sinfo
->lcdc_clk
) / 1000;
414 dev_dbg(dev
, "%s:\n", __func__
);
416 if (!(var
->pixclock
&& var
->bits_per_pixel
)) {
417 /* choose a suitable mode if possible */
418 if (!atmel_lcdfb_choose_mode(var
, info
)) {
419 dev_err(dev
, "needed value not specified\n");
424 dev_dbg(dev
, " resolution: %ux%u\n", var
->xres
, var
->yres
);
425 dev_dbg(dev
, " pixclk: %lu KHz\n", PICOS2KHZ(var
->pixclock
));
426 dev_dbg(dev
, " bpp: %u\n", var
->bits_per_pixel
);
427 dev_dbg(dev
, " clk: %lu KHz\n", clk_value_khz
);
429 if (PICOS2KHZ(var
->pixclock
) > clk_value_khz
) {
430 dev_err(dev
, "%lu KHz pixel clock is too fast\n", PICOS2KHZ(var
->pixclock
));
434 /* Do not allow to have real resoulution larger than virtual */
435 if (var
->xres
> var
->xres_virtual
)
436 var
->xres_virtual
= var
->xres
;
438 if (var
->yres
> var
->yres_virtual
)
439 var
->yres_virtual
= var
->yres
;
441 /* Force same alignment for each line */
442 var
->xres
= (var
->xres
+ 3) & ~3UL;
443 var
->xres_virtual
= (var
->xres_virtual
+ 3) & ~3UL;
445 var
->red
.msb_right
= var
->green
.msb_right
= var
->blue
.msb_right
= 0;
446 var
->transp
.msb_right
= 0;
447 var
->transp
.offset
= var
->transp
.length
= 0;
448 var
->xoffset
= var
->yoffset
= 0;
450 if (info
->fix
.smem_len
) {
451 unsigned int smem_len
= (var
->xres_virtual
* var
->yres_virtual
452 * ((var
->bits_per_pixel
+ 7) / 8));
453 if (smem_len
> info
->fix
.smem_len
) {
454 dev_err(dev
, "Frame buffer is too small (%u) for screen size (need at least %u)\n",
455 info
->fix
.smem_len
, smem_len
);
460 /* Saturate vertical and horizontal timings at maximum values */
461 var
->vsync_len
= min_t(u32
, var
->vsync_len
,
462 (ATMEL_LCDC_VPW
>> ATMEL_LCDC_VPW_OFFSET
) + 1);
463 var
->upper_margin
= min_t(u32
, var
->upper_margin
,
464 ATMEL_LCDC_VBP
>> ATMEL_LCDC_VBP_OFFSET
);
465 var
->lower_margin
= min_t(u32
, var
->lower_margin
,
467 var
->right_margin
= min_t(u32
, var
->right_margin
,
468 (ATMEL_LCDC_HFP
>> ATMEL_LCDC_HFP_OFFSET
) + 1);
469 var
->hsync_len
= min_t(u32
, var
->hsync_len
,
470 (ATMEL_LCDC_HPW
>> ATMEL_LCDC_HPW_OFFSET
) + 1);
471 var
->left_margin
= min_t(u32
, var
->left_margin
,
474 /* Some parameters can't be zero */
475 var
->vsync_len
= max_t(u32
, var
->vsync_len
, 1);
476 var
->right_margin
= max_t(u32
, var
->right_margin
, 1);
477 var
->hsync_len
= max_t(u32
, var
->hsync_len
, 1);
478 var
->left_margin
= max_t(u32
, var
->left_margin
, 1);
480 switch (var
->bits_per_pixel
) {
485 var
->red
.offset
= var
->green
.offset
= var
->blue
.offset
= 0;
486 var
->red
.length
= var
->green
.length
= var
->blue
.length
487 = var
->bits_per_pixel
;
490 /* Older SOCs use IBGR:555 rather than BGR:565. */
491 if (sinfo
->config
->have_intensity_bit
)
492 var
->green
.length
= 5;
494 var
->green
.length
= 6;
496 if (pdata
->lcd_wiring_mode
== ATMEL_LCDC_WIRING_RGB
) {
498 var
->red
.offset
= var
->green
.length
+ 5;
499 var
->blue
.offset
= 0;
503 var
->blue
.offset
= var
->green
.length
+ 5;
505 var
->green
.offset
= 5;
506 var
->red
.length
= var
->blue
.length
= 5;
509 var
->transp
.offset
= 24;
510 var
->transp
.length
= 8;
513 if (pdata
->lcd_wiring_mode
== ATMEL_LCDC_WIRING_RGB
) {
515 var
->red
.offset
= 16;
516 var
->blue
.offset
= 0;
520 var
->blue
.offset
= 16;
522 var
->green
.offset
= 8;
523 var
->red
.length
= var
->green
.length
= var
->blue
.length
= 8;
526 dev_err(dev
, "color depth %d not supported\n",
527 var
->bits_per_pixel
);
537 static void atmel_lcdfb_reset(struct atmel_lcdfb_info
*sinfo
)
541 atmel_lcdfb_stop(sinfo
);
542 atmel_lcdfb_start(sinfo
);
546 * atmel_lcdfb_set_par - Alters the hardware state.
547 * @info: frame buffer structure that represents a single frame buffer
549 * Using the fb_var_screeninfo in fb_info we set the resolution
550 * of the this particular framebuffer. This function alters the
551 * par AND the fb_fix_screeninfo stored in fb_info. It doesn't
552 * not alter var in fb_info since we are using that data. This
553 * means we depend on the data in var inside fb_info to be
554 * supported by the hardware. atmel_lcdfb_check_var is always called
555 * before atmel_lcdfb_set_par to ensure this. Again if you can't
556 * change the resolution you don't need this function.
559 static int atmel_lcdfb_set_par(struct fb_info
*info
)
561 struct atmel_lcdfb_info
*sinfo
= info
->par
;
562 struct atmel_lcdfb_pdata
*pdata
= &sinfo
->pdata
;
563 unsigned long hozval_linesz
;
565 unsigned long clk_value_khz
;
566 unsigned long bits_per_line
;
567 unsigned long pix_factor
= 2;
571 dev_dbg(info
->device
, "%s:\n", __func__
);
572 dev_dbg(info
->device
, " * resolution: %ux%u (%ux%u virtual)\n",
573 info
->var
.xres
, info
->var
.yres
,
574 info
->var
.xres_virtual
, info
->var
.yres_virtual
);
576 atmel_lcdfb_stop_nowait(sinfo
);
578 if (info
->var
.bits_per_pixel
== 1)
579 info
->fix
.visual
= FB_VISUAL_MONO01
;
580 else if (info
->var
.bits_per_pixel
<= 8)
581 info
->fix
.visual
= FB_VISUAL_PSEUDOCOLOR
;
583 info
->fix
.visual
= FB_VISUAL_TRUECOLOR
;
585 bits_per_line
= info
->var
.xres_virtual
* info
->var
.bits_per_pixel
;
586 info
->fix
.line_length
= DIV_ROUND_UP(bits_per_line
, 8);
588 /* Re-initialize the DMA engine... */
589 dev_dbg(info
->device
, " * update DMA engine\n");
590 atmel_lcdfb_update_dma(info
, &info
->var
);
592 /* ...set frame size and burst length = 8 words (?) */
593 value
= (info
->var
.yres
* info
->var
.xres
* info
->var
.bits_per_pixel
) / 32;
594 value
|= ((ATMEL_LCDC_DMA_BURST_LEN
- 1) << ATMEL_LCDC_BLENGTH_OFFSET
);
595 lcdc_writel(sinfo
, ATMEL_LCDC_DMAFRMCFG
, value
);
597 /* Now, the LCDC core... */
599 /* Set pixel clock */
600 if (sinfo
->config
->have_alt_pixclock
)
603 clk_value_khz
= clk_get_rate(sinfo
->lcdc_clk
) / 1000;
605 value
= DIV_ROUND_UP(clk_value_khz
, PICOS2KHZ(info
->var
.pixclock
));
607 if (value
< pix_factor
) {
608 dev_notice(info
->device
, "Bypassing pixel clock divider\n");
609 lcdc_writel(sinfo
, ATMEL_LCDC_LCDCON1
, ATMEL_LCDC_BYPASS
);
611 value
= (value
/ pix_factor
) - 1;
612 dev_dbg(info
->device
, " * programming CLKVAL = 0x%08lx\n",
614 lcdc_writel(sinfo
, ATMEL_LCDC_LCDCON1
,
615 value
<< ATMEL_LCDC_CLKVAL_OFFSET
);
617 KHZ2PICOS(clk_value_khz
/ (pix_factor
* (value
+ 1)));
618 dev_dbg(info
->device
, " updated pixclk: %lu KHz\n",
619 PICOS2KHZ(info
->var
.pixclock
));
623 /* Initialize control register 2 */
624 value
= pdata
->default_lcdcon2
;
626 if (!(info
->var
.sync
& FB_SYNC_HOR_HIGH_ACT
))
627 value
|= ATMEL_LCDC_INVLINE_INVERTED
;
628 if (!(info
->var
.sync
& FB_SYNC_VERT_HIGH_ACT
))
629 value
|= ATMEL_LCDC_INVFRAME_INVERTED
;
631 switch (info
->var
.bits_per_pixel
) {
632 case 1: value
|= ATMEL_LCDC_PIXELSIZE_1
; break;
633 case 2: value
|= ATMEL_LCDC_PIXELSIZE_2
; break;
634 case 4: value
|= ATMEL_LCDC_PIXELSIZE_4
; break;
635 case 8: value
|= ATMEL_LCDC_PIXELSIZE_8
; break;
636 case 15: fallthrough
;
637 case 16: value
|= ATMEL_LCDC_PIXELSIZE_16
; break;
638 case 24: value
|= ATMEL_LCDC_PIXELSIZE_24
; break;
639 case 32: value
|= ATMEL_LCDC_PIXELSIZE_32
; break;
640 default: BUG(); break;
642 dev_dbg(info
->device
, " * LCDCON2 = %08lx\n", value
);
643 lcdc_writel(sinfo
, ATMEL_LCDC_LCDCON2
, value
);
645 /* Vertical timing */
646 value
= (info
->var
.vsync_len
- 1) << ATMEL_LCDC_VPW_OFFSET
;
647 value
|= info
->var
.upper_margin
<< ATMEL_LCDC_VBP_OFFSET
;
648 value
|= info
->var
.lower_margin
;
649 dev_dbg(info
->device
, " * LCDTIM1 = %08lx\n", value
);
650 lcdc_writel(sinfo
, ATMEL_LCDC_TIM1
, value
);
652 /* Horizontal timing */
653 value
= (info
->var
.right_margin
- 1) << ATMEL_LCDC_HFP_OFFSET
;
654 value
|= (info
->var
.hsync_len
- 1) << ATMEL_LCDC_HPW_OFFSET
;
655 value
|= (info
->var
.left_margin
- 1);
656 dev_dbg(info
->device
, " * LCDTIM2 = %08lx\n", value
);
657 lcdc_writel(sinfo
, ATMEL_LCDC_TIM2
, value
);
659 /* Horizontal value (aka line size) */
660 hozval_linesz
= compute_hozval(sinfo
, info
->var
.xres
);
663 value
= (hozval_linesz
- 1) << ATMEL_LCDC_HOZVAL_OFFSET
;
664 value
|= info
->var
.yres
- 1;
665 dev_dbg(info
->device
, " * LCDFRMCFG = %08lx\n", value
);
666 lcdc_writel(sinfo
, ATMEL_LCDC_LCDFRMCFG
, value
);
668 /* FIFO Threshold: Use formula from data sheet */
669 value
= ATMEL_LCDC_FIFO_SIZE
- (2 * ATMEL_LCDC_DMA_BURST_LEN
+ 3);
670 lcdc_writel(sinfo
, ATMEL_LCDC_FIFO
, value
);
672 /* Toggle LCD_MODE every frame */
673 lcdc_writel(sinfo
, ATMEL_LCDC_MVAL
, 0);
675 /* Disable all interrupts */
676 lcdc_writel(sinfo
, ATMEL_LCDC_IDR
, ~0U);
677 /* Enable FIFO & DMA errors */
678 lcdc_writel(sinfo
, ATMEL_LCDC_IER
, ATMEL_LCDC_UFLWI
| ATMEL_LCDC_OWRI
| ATMEL_LCDC_MERI
);
680 /* ...wait for DMA engine to become idle... */
681 while (lcdc_readl(sinfo
, ATMEL_LCDC_DMACON
) & ATMEL_LCDC_DMABUSY
)
684 atmel_lcdfb_start(sinfo
);
686 dev_dbg(info
->device
, " * DONE\n");
691 static inline unsigned int chan_to_field(unsigned int chan
, const struct fb_bitfield
*bf
)
694 chan
>>= 16 - bf
->length
;
695 return chan
<< bf
->offset
;
699 * atmel_lcdfb_setcolreg - Optional function. Sets a color register.
700 * @regno: Which register in the CLUT we are programming
701 * @red: The red value which can be up to 16 bits wide
702 * @green: The green value which can be up to 16 bits wide
703 * @blue: The blue value which can be up to 16 bits wide.
704 * @transp: If supported the alpha value which can be up to 16 bits wide.
705 * @info: frame buffer info structure
707 * Set a single color register. The values supplied have a 16 bit
708 * magnitude which needs to be scaled in this function for the hardware.
709 * Things to take into consideration are how many color registers, if
710 * any, are supported with the current color visual. With truecolor mode
711 * no color palettes are supported. Here a pseudo palette is created
712 * which we store the value in pseudo_palette in struct fb_info. For
713 * pseudocolor mode we have a limited color palette. To deal with this
714 * we can program what color is displayed for a particular pixel value.
715 * DirectColor is similar in that we can program each color field. If
716 * we have a static colormap we don't need to implement this function.
718 * Returns negative errno on error, or zero on success. In an
719 * ideal world, this would have been the case, but as it turns
720 * out, the other drivers return 1 on failure, so that's what
723 static int atmel_lcdfb_setcolreg(unsigned int regno
, unsigned int red
,
724 unsigned int green
, unsigned int blue
,
725 unsigned int transp
, struct fb_info
*info
)
727 struct atmel_lcdfb_info
*sinfo
= info
->par
;
728 struct atmel_lcdfb_pdata
*pdata
= &sinfo
->pdata
;
733 if (info
->var
.grayscale
)
734 red
= green
= blue
= (19595 * red
+ 38470 * green
735 + 7471 * blue
) >> 16;
737 switch (info
->fix
.visual
) {
738 case FB_VISUAL_TRUECOLOR
:
740 pal
= info
->pseudo_palette
;
742 val
= chan_to_field(red
, &info
->var
.red
);
743 val
|= chan_to_field(green
, &info
->var
.green
);
744 val
|= chan_to_field(blue
, &info
->var
.blue
);
751 case FB_VISUAL_PSEUDOCOLOR
:
753 if (sinfo
->config
->have_intensity_bit
) {
754 /* old style I+BGR:555 */
755 val
= ((red
>> 11) & 0x001f);
756 val
|= ((green
>> 6) & 0x03e0);
757 val
|= ((blue
>> 1) & 0x7c00);
760 * TODO: intensity bit. Maybe something like
761 * ~(red[10] ^ green[10] ^ blue[10]) & 1
764 /* new style BGR:565 / RGB:565 */
765 if (pdata
->lcd_wiring_mode
== ATMEL_LCDC_WIRING_RGB
) {
766 val
= ((blue
>> 11) & 0x001f);
767 val
|= ((red
>> 0) & 0xf800);
769 val
= ((red
>> 11) & 0x001f);
770 val
|= ((blue
>> 0) & 0xf800);
773 val
|= ((green
>> 5) & 0x07e0);
776 lcdc_writel(sinfo
, ATMEL_LCDC_LUT(regno
), val
);
781 case FB_VISUAL_MONO01
:
783 val
= (regno
== 0) ? 0x00 : 0x1F;
784 lcdc_writel(sinfo
, ATMEL_LCDC_LUT(regno
), val
);
794 static int atmel_lcdfb_pan_display(struct fb_var_screeninfo
*var
,
795 struct fb_info
*info
)
797 dev_dbg(info
->device
, "%s\n", __func__
);
799 atmel_lcdfb_update_dma(info
, var
);
804 static int atmel_lcdfb_blank(int blank_mode
, struct fb_info
*info
)
806 struct atmel_lcdfb_info
*sinfo
= info
->par
;
808 switch (blank_mode
) {
809 case FB_BLANK_UNBLANK
:
810 case FB_BLANK_NORMAL
:
811 atmel_lcdfb_start(sinfo
);
813 case FB_BLANK_VSYNC_SUSPEND
:
814 case FB_BLANK_HSYNC_SUSPEND
:
816 case FB_BLANK_POWERDOWN
:
817 atmel_lcdfb_stop(sinfo
);
823 /* let fbcon do a soft blank for us */
824 return ((blank_mode
== FB_BLANK_NORMAL
) ? 1 : 0);
827 static const struct fb_ops atmel_lcdfb_ops
= {
828 .owner
= THIS_MODULE
,
829 .fb_check_var
= atmel_lcdfb_check_var
,
830 .fb_set_par
= atmel_lcdfb_set_par
,
831 .fb_setcolreg
= atmel_lcdfb_setcolreg
,
832 .fb_blank
= atmel_lcdfb_blank
,
833 .fb_pan_display
= atmel_lcdfb_pan_display
,
834 .fb_fillrect
= cfb_fillrect
,
835 .fb_copyarea
= cfb_copyarea
,
836 .fb_imageblit
= cfb_imageblit
,
839 static irqreturn_t
atmel_lcdfb_interrupt(int irq
, void *dev_id
)
841 struct fb_info
*info
= dev_id
;
842 struct atmel_lcdfb_info
*sinfo
= info
->par
;
845 status
= lcdc_readl(sinfo
, ATMEL_LCDC_ISR
);
846 if (status
& ATMEL_LCDC_UFLWI
) {
847 dev_warn(info
->device
, "FIFO underflow %#x\n", status
);
848 /* reset DMA and FIFO to avoid screen shifting */
849 schedule_work(&sinfo
->task
);
851 lcdc_writel(sinfo
, ATMEL_LCDC_ICR
, status
);
856 * LCD controller task (to reset the LCD)
858 static void atmel_lcdfb_task(struct work_struct
*work
)
860 struct atmel_lcdfb_info
*sinfo
=
861 container_of(work
, struct atmel_lcdfb_info
, task
);
863 atmel_lcdfb_reset(sinfo
);
866 static int __init
atmel_lcdfb_init_fbinfo(struct atmel_lcdfb_info
*sinfo
)
868 struct fb_info
*info
= sinfo
->info
;
871 info
->var
.activate
|= FB_ACTIVATE_FORCE
| FB_ACTIVATE_NOW
;
873 dev_info(info
->device
,
874 "%luKiB frame buffer at %08lx (mapped at %p)\n",
875 (unsigned long)info
->fix
.smem_len
/ 1024,
876 (unsigned long)info
->fix
.smem_start
,
879 /* Allocate colormap */
880 ret
= fb_alloc_cmap(&info
->cmap
, 256, 0);
882 dev_err(info
->device
, "Alloc color map failed\n");
887 static void atmel_lcdfb_start_clock(struct atmel_lcdfb_info
*sinfo
)
889 clk_prepare_enable(sinfo
->bus_clk
);
890 clk_prepare_enable(sinfo
->lcdc_clk
);
893 static void atmel_lcdfb_stop_clock(struct atmel_lcdfb_info
*sinfo
)
895 clk_disable_unprepare(sinfo
->bus_clk
);
896 clk_disable_unprepare(sinfo
->lcdc_clk
);
899 static const struct of_device_id atmel_lcdfb_dt_ids
[] = {
900 { .compatible
= "atmel,at91sam9261-lcdc" , .data
= &at91sam9261_config
, },
901 { .compatible
= "atmel,at91sam9263-lcdc" , .data
= &at91sam9263_config
, },
902 { .compatible
= "atmel,at91sam9g10-lcdc" , .data
= &at91sam9g10_config
, },
903 { .compatible
= "atmel,at91sam9g45-lcdc" , .data
= &at91sam9g45_config
, },
904 { .compatible
= "atmel,at91sam9g45es-lcdc" , .data
= &at91sam9g45es_config
, },
905 { .compatible
= "atmel,at91sam9rl-lcdc" , .data
= &at91sam9rl_config
, },
909 MODULE_DEVICE_TABLE(of
, atmel_lcdfb_dt_ids
);
911 static const char *atmel_lcdfb_wiring_modes
[] = {
912 [ATMEL_LCDC_WIRING_BGR
] = "BRG",
913 [ATMEL_LCDC_WIRING_RGB
] = "RGB",
916 static int atmel_lcdfb_get_of_wiring_modes(struct device_node
*np
)
921 err
= of_property_read_string(np
, "atmel,lcd-wiring-mode", &mode
);
923 return ATMEL_LCDC_WIRING_BGR
;
925 for (i
= 0; i
< ARRAY_SIZE(atmel_lcdfb_wiring_modes
); i
++)
926 if (!strcasecmp(mode
, atmel_lcdfb_wiring_modes
[i
]))
932 static void atmel_lcdfb_power_control_gpio(struct atmel_lcdfb_pdata
*pdata
, int on
)
934 struct atmel_lcdfb_power_ctrl_gpio
*og
;
936 list_for_each_entry(og
, &pdata
->pwr_gpios
, list
)
937 gpiod_set_value(og
->gpiod
, on
);
940 static int atmel_lcdfb_of_init(struct atmel_lcdfb_info
*sinfo
)
942 struct fb_info
*info
= sinfo
->info
;
943 struct atmel_lcdfb_pdata
*pdata
= &sinfo
->pdata
;
944 struct fb_var_screeninfo
*var
= &info
->var
;
945 struct device
*dev
= &sinfo
->pdev
->dev
;
946 struct device_node
*np
=dev
->of_node
;
947 struct device_node
*display_np
;
948 struct atmel_lcdfb_power_ctrl_gpio
*og
;
949 bool is_gpio_power
= false;
950 struct fb_videomode fb_vm
;
951 struct gpio_desc
*gpiod
;
956 sinfo
->config
= (struct atmel_lcdfb_config
*)
957 of_match_device(atmel_lcdfb_dt_ids
, dev
)->data
;
959 display_np
= of_parse_phandle(np
, "display", 0);
961 dev_err(dev
, "failed to find display phandle\n");
965 ret
= of_property_read_u32(display_np
, "bits-per-pixel", &var
->bits_per_pixel
);
967 dev_err(dev
, "failed to get property bits-per-pixel\n");
968 goto put_display_node
;
971 ret
= of_property_read_u32(display_np
, "atmel,guard-time", &pdata
->guard_time
);
973 dev_err(dev
, "failed to get property atmel,guard-time\n");
974 goto put_display_node
;
977 ret
= of_property_read_u32(display_np
, "atmel,lcdcon2", &pdata
->default_lcdcon2
);
979 dev_err(dev
, "failed to get property atmel,lcdcon2\n");
980 goto put_display_node
;
983 ret
= of_property_read_u32(display_np
, "atmel,dmacon", &pdata
->default_dmacon
);
985 dev_err(dev
, "failed to get property bits-per-pixel\n");
986 goto put_display_node
;
989 INIT_LIST_HEAD(&pdata
->pwr_gpios
);
990 for (i
= 0; i
< gpiod_count(dev
, "atmel,power-control"); i
++) {
992 gpiod
= devm_gpiod_get_index(dev
, "atmel,power-control",
997 og
= devm_kzalloc(dev
, sizeof(*og
), GFP_KERNEL
);
999 goto put_display_node
;
1002 is_gpio_power
= true;
1004 ret
= gpiod_direction_output(gpiod
, gpiod_is_active_low(gpiod
));
1006 dev_err(dev
, "set direction output gpio atmel,power-control[%d] failed\n", i
);
1007 goto put_display_node
;
1009 list_add(&og
->list
, &pdata
->pwr_gpios
);
1013 pdata
->atmel_lcdfb_power_control
= atmel_lcdfb_power_control_gpio
;
1015 ret
= atmel_lcdfb_get_of_wiring_modes(display_np
);
1017 dev_err(dev
, "invalid atmel,lcd-wiring-mode\n");
1018 goto put_display_node
;
1020 pdata
->lcd_wiring_mode
= ret
;
1022 pdata
->lcdcon_is_backlight
= of_property_read_bool(display_np
, "atmel,lcdcon-backlight");
1023 pdata
->lcdcon_pol_negative
= of_property_read_bool(display_np
, "atmel,lcdcon-backlight-inverted");
1025 ret
= of_get_videomode(display_np
, &vm
, OF_USE_NATIVE_MODE
);
1027 dev_err(dev
, "failed to get videomode from DT\n");
1028 goto put_display_node
;
1031 ret
= fb_videomode_from_videomode(&vm
, &fb_vm
);
1033 goto put_display_node
;
1035 fb_add_videomode(&fb_vm
, &info
->modelist
);
1038 of_node_put(display_np
);
1042 static int __init
atmel_lcdfb_probe(struct platform_device
*pdev
)
1044 struct device
*dev
= &pdev
->dev
;
1045 struct fb_info
*info
;
1046 struct atmel_lcdfb_info
*sinfo
;
1047 struct resource
*regs
= NULL
;
1048 struct resource
*map
= NULL
;
1049 struct fb_modelist
*modelist
;
1052 dev_dbg(dev
, "%s BEGIN\n", __func__
);
1055 info
= framebuffer_alloc(sizeof(struct atmel_lcdfb_info
), dev
);
1063 INIT_LIST_HEAD(&info
->modelist
);
1065 if (pdev
->dev
.of_node
) {
1066 ret
= atmel_lcdfb_of_init(sinfo
);
1070 dev_err(dev
, "cannot get default configuration\n");
1077 sinfo
->reg_lcd
= devm_regulator_get(&pdev
->dev
, "lcd");
1078 if (IS_ERR(sinfo
->reg_lcd
))
1079 sinfo
->reg_lcd
= NULL
;
1081 info
->flags
= FBINFO_DEFAULT
| FBINFO_PARTIAL_PAN_OK
|
1082 FBINFO_HWACCEL_YPAN
;
1083 info
->pseudo_palette
= sinfo
->pseudo_palette
;
1084 info
->fbops
= &atmel_lcdfb_ops
;
1086 info
->fix
= atmel_lcdfb_fix
;
1087 strcpy(info
->fix
.id
, sinfo
->pdev
->name
);
1089 /* Enable LCDC Clocks */
1090 sinfo
->bus_clk
= clk_get(dev
, "hclk");
1091 if (IS_ERR(sinfo
->bus_clk
)) {
1092 ret
= PTR_ERR(sinfo
->bus_clk
);
1095 sinfo
->lcdc_clk
= clk_get(dev
, "lcdc_clk");
1096 if (IS_ERR(sinfo
->lcdc_clk
)) {
1097 ret
= PTR_ERR(sinfo
->lcdc_clk
);
1100 atmel_lcdfb_start_clock(sinfo
);
1102 modelist
= list_first_entry(&info
->modelist
,
1103 struct fb_modelist
, list
);
1104 fb_videomode_to_var(&info
->var
, &modelist
->mode
);
1106 atmel_lcdfb_check_var(&info
->var
, info
);
1108 regs
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
1110 dev_err(dev
, "resources unusable\n");
1115 sinfo
->irq_base
= platform_get_irq(pdev
, 0);
1116 if (sinfo
->irq_base
< 0) {
1117 ret
= sinfo
->irq_base
;
1121 /* Initialize video memory */
1122 map
= platform_get_resource(pdev
, IORESOURCE_MEM
, 1);
1124 /* use a pre-allocated memory buffer */
1125 info
->fix
.smem_start
= map
->start
;
1126 info
->fix
.smem_len
= resource_size(map
);
1127 if (!request_mem_region(info
->fix
.smem_start
,
1128 info
->fix
.smem_len
, pdev
->name
)) {
1133 info
->screen_base
= ioremap_wc(info
->fix
.smem_start
,
1134 info
->fix
.smem_len
);
1135 if (!info
->screen_base
) {
1137 goto release_intmem
;
1141 * Don't clear the framebuffer -- someone may have set
1142 * up a splash image.
1145 /* allocate memory buffer */
1146 ret
= atmel_lcdfb_alloc_video_memory(sinfo
);
1148 dev_err(dev
, "cannot allocate framebuffer: %d\n", ret
);
1153 /* LCDC registers */
1154 info
->fix
.mmio_start
= regs
->start
;
1155 info
->fix
.mmio_len
= resource_size(regs
);
1157 if (!request_mem_region(info
->fix
.mmio_start
,
1158 info
->fix
.mmio_len
, pdev
->name
)) {
1163 sinfo
->mmio
= ioremap(info
->fix
.mmio_start
, info
->fix
.mmio_len
);
1165 dev_err(dev
, "cannot map LCDC registers\n");
1170 /* Initialize PWM for contrast or backlight ("off") */
1171 init_contrast(sinfo
);
1174 ret
= request_irq(sinfo
->irq_base
, atmel_lcdfb_interrupt
, 0, pdev
->name
, info
);
1176 dev_err(dev
, "request_irq failed: %d\n", ret
);
1180 /* Some operations on the LCDC might sleep and
1181 * require a preemptible task context */
1182 INIT_WORK(&sinfo
->task
, atmel_lcdfb_task
);
1184 ret
= atmel_lcdfb_init_fbinfo(sinfo
);
1186 dev_err(dev
, "init fbinfo failed: %d\n", ret
);
1187 goto unregister_irqs
;
1190 ret
= atmel_lcdfb_set_par(info
);
1192 dev_err(dev
, "set par failed: %d\n", ret
);
1193 goto unregister_irqs
;
1196 dev_set_drvdata(dev
, info
);
1199 * Tell the world that we're ready to go
1201 ret
= register_framebuffer(info
);
1203 dev_err(dev
, "failed to register framebuffer device: %d\n", ret
);
1207 /* Power up the LCDC screen */
1208 atmel_lcdfb_power_control(sinfo
, 1);
1210 dev_info(dev
, "fb%d: Atmel LCDC at 0x%08lx (mapped at %p), irq %d\n",
1211 info
->node
, info
->fix
.mmio_start
, sinfo
->mmio
, sinfo
->irq_base
);
1216 dev_set_drvdata(dev
, NULL
);
1217 fb_dealloc_cmap(&info
->cmap
);
1219 cancel_work_sync(&sinfo
->task
);
1220 free_irq(sinfo
->irq_base
, info
);
1222 exit_backlight(sinfo
);
1223 iounmap(sinfo
->mmio
);
1225 release_mem_region(info
->fix
.mmio_start
, info
->fix
.mmio_len
);
1228 iounmap(info
->screen_base
);
1230 atmel_lcdfb_free_video_memory(sinfo
);
1234 release_mem_region(info
->fix
.smem_start
, info
->fix
.smem_len
);
1236 atmel_lcdfb_stop_clock(sinfo
);
1237 clk_put(sinfo
->lcdc_clk
);
1239 clk_put(sinfo
->bus_clk
);
1241 framebuffer_release(info
);
1243 dev_dbg(dev
, "%s FAILED\n", __func__
);
1247 static int __exit
atmel_lcdfb_remove(struct platform_device
*pdev
)
1249 struct device
*dev
= &pdev
->dev
;
1250 struct fb_info
*info
= dev_get_drvdata(dev
);
1251 struct atmel_lcdfb_info
*sinfo
;
1253 if (!info
|| !info
->par
)
1257 cancel_work_sync(&sinfo
->task
);
1258 exit_backlight(sinfo
);
1259 atmel_lcdfb_power_control(sinfo
, 0);
1260 unregister_framebuffer(info
);
1261 atmel_lcdfb_stop_clock(sinfo
);
1262 clk_put(sinfo
->lcdc_clk
);
1263 clk_put(sinfo
->bus_clk
);
1264 fb_dealloc_cmap(&info
->cmap
);
1265 free_irq(sinfo
->irq_base
, info
);
1266 iounmap(sinfo
->mmio
);
1267 release_mem_region(info
->fix
.mmio_start
, info
->fix
.mmio_len
);
1268 if (platform_get_resource(pdev
, IORESOURCE_MEM
, 1)) {
1269 iounmap(info
->screen_base
);
1270 release_mem_region(info
->fix
.smem_start
, info
->fix
.smem_len
);
1272 atmel_lcdfb_free_video_memory(sinfo
);
1275 framebuffer_release(info
);
1282 static int atmel_lcdfb_suspend(struct platform_device
*pdev
, pm_message_t mesg
)
1284 struct fb_info
*info
= platform_get_drvdata(pdev
);
1285 struct atmel_lcdfb_info
*sinfo
= info
->par
;
1288 * We don't want to handle interrupts while the clock is
1289 * stopped. It may take forever.
1291 lcdc_writel(sinfo
, ATMEL_LCDC_IDR
, ~0U);
1293 sinfo
->saved_lcdcon
= lcdc_readl(sinfo
, ATMEL_LCDC_CONTRAST_CTR
);
1294 lcdc_writel(sinfo
, ATMEL_LCDC_CONTRAST_CTR
, 0);
1295 atmel_lcdfb_power_control(sinfo
, 0);
1296 atmel_lcdfb_stop(sinfo
);
1297 atmel_lcdfb_stop_clock(sinfo
);
1302 static int atmel_lcdfb_resume(struct platform_device
*pdev
)
1304 struct fb_info
*info
= platform_get_drvdata(pdev
);
1305 struct atmel_lcdfb_info
*sinfo
= info
->par
;
1307 atmel_lcdfb_start_clock(sinfo
);
1308 atmel_lcdfb_start(sinfo
);
1309 atmel_lcdfb_power_control(sinfo
, 1);
1310 lcdc_writel(sinfo
, ATMEL_LCDC_CONTRAST_CTR
, sinfo
->saved_lcdcon
);
1312 /* Enable FIFO & DMA errors */
1313 lcdc_writel(sinfo
, ATMEL_LCDC_IER
, ATMEL_LCDC_UFLWI
1314 | ATMEL_LCDC_OWRI
| ATMEL_LCDC_MERI
);
1320 #define atmel_lcdfb_suspend NULL
1321 #define atmel_lcdfb_resume NULL
1324 static struct platform_driver atmel_lcdfb_driver
= {
1325 .remove
= __exit_p(atmel_lcdfb_remove
),
1326 .suspend
= atmel_lcdfb_suspend
,
1327 .resume
= atmel_lcdfb_resume
,
1329 .name
= "atmel_lcdfb",
1330 .of_match_table
= of_match_ptr(atmel_lcdfb_dt_ids
),
1334 module_platform_driver_probe(atmel_lcdfb_driver
, atmel_lcdfb_probe
);
1336 MODULE_DESCRIPTION("AT91 LCD Controller framebuffer driver");
1337 MODULE_AUTHOR("Nicolas Ferre <nicolas.ferre@atmel.com>");
1338 MODULE_LICENSE("GPL");