atmel_lcdfb: AT91/AT32 LCD Controller framebuffer driver
PATCH 1/1 atmel_lcdfb: AT91/AT32 LCD Controller framebuffer driver
From: Nicolas Ferre <[email protected]>
Adds a framebuffer driver to ATMEL AT91SAM9x and AT32 aka AVR32 platforms. Those chips share quite the same IP and this code is suitable for both architectures.
---
The header file resides in an arch neutral directory.
AT91 platform informations are directly submitted trough the at91 maintainer.
drivers/video/Kconfig | 16 drivers/video/Makefile | 1 drivers/video/atmel_lcdfb.c | 772 ++++++++++++++++++++++++++++++++++include/video/atmel_lcdc.h | 195 ++++++++
4 files changed, 984 insertions(+)
include/video/atmel_lcdc.h new file +195 -0
@@ -0,0 +1,195 @@ +/* +* Header file for AT91/AT32 LCD Controller +* +* Data structure and register user interface +* +* Copyright (C) 2007 Atmel Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#ifndef __ATMEL_LCDC_H__ +#define __ATMEL_LCDC_H__ + +/* LCD Controller info data structure */ +struct atmel_lcdfb_info { +spinlock_t lock; +struct fb_info *info; +void __iomem *mmio; +unsigned long irq_base; + +unsigned int guard_time; +struct platform_device *pdev; +struct clk *bus_clk; +struct clk *lcdc_clk; +unsigned int default_bpp; +unsigned int default_lcdcon2; +unsigned int default_dmacon; +void (*atmel_lcdfb_power_control)(int on); +struct fb_monspecs *default_monspecs; +}; + +#define ATMEL_LCDC_DMABADDR1 0x00 +#define ATMEL_LCDC_DMABADDR2 0x04 +#define ATMEL_LCDC_DMAFRMPT1 0x08 +#define ATMEL_LCDC_DMAFRMPT2 0x0c +#define ATMEL_LCDC_DMAFRMADD1 0x10 +#define ATMEL_LCDC_DMAFRMADD2 0x14 + +#define ATMEL_LCDC_DMAFRMCFG 0x18 +#define ATMEL_LCDC_FRSIZE (0x7fffff << 0) +#define ATMEL_LCDC_BLENGTH_OFFSET 24 +#define ATMEL_LCDC_BLENGTH (0x7f << ATMEL_LCDC_BLENGTH_OFFSET) + +#define ATMEL_LCDC_DMACON 0x1c +#define ATMEL_LCDC_DMAEN (0x1 << 0) +#define ATMEL_LCDC_DMARST (0x1 << 1) +#define ATMEL_LCDC_DMABUSY (0x1 << 2) +#define ATMEL_LCDC_DMAUPDT (0x1 << 3) +#define ATMEL_LCDC_DMA2DEN (0x1 << 4) + +#define ATMEL_LCDC_DMA2DCFG 0x20 +#define ATMEL_LCDC_ADDRINC_OFFSET 0 +#define ATMEL_LCDC_ADDRINC (0xffff) +#define ATMEL_LCDC_PIXELOFF_OFFSET 24 +#define ATMEL_LCDC_PIXELOFF (0x1f << 24) + +#define ATMEL_LCDC_LCDCON1 0x0800 +#define ATMEL_LCDC_BYPASS (1 << 0) +#define ATMEL_LCDC_CLKVAL_OFFSET 12 +#define ATMEL_LCDC_CLKVAL (0x1ff << ATMEL_LCDC_CLKVAL_OFFSET) +#define ATMEL_LCDC_LINCNT (0x7ff << 21) + +#define ATMEL_LCDC_LCDCON2 0x0804 +#define ATMEL_LCDC_DISTYPE (3 << 0) +#define ATMEL_LCDC_DISTYPE_STNMONO (0 << 0) +#define ATMEL_LCDC_DISTYPE_STNCOLOR (1 << 0) +#define ATMEL_LCDC_DISTYPE_TFT (2 << 0) +#define ATMEL_LCDC_SCANMOD (1 << 2) +#define ATMEL_LCDC_SCANMOD_SINGLE (0 << 2) +#define ATMEL_LCDC_SCANMOD_DUAL (1 << 2) +#define ATMEL_LCDC_IFWIDTH (3 << 3) +#define ATMEL_LCDC_IFWIDTH_4 (0 << 3) +#define ATMEL_LCDC_IFWIDTH_8 (1 << 3) +#define ATMEL_LCDC_IFWIDTH_16 (2 << 3) +#define ATMEL_LCDC_PIXELSIZE (7 << 5) +#define ATMEL_LCDC_PIXELSIZE_1 (0 << 5) +#define ATMEL_LCDC_PIXELSIZE_2 (1 << 5) +#define ATMEL_LCDC_PIXELSIZE_4 (2 << 5) +#define ATMEL_LCDC_PIXELSIZE_8 (3 << 5) +#define ATMEL_LCDC_PIXELSIZE_16 (4 << 5) +#define ATMEL_LCDC_PIXELSIZE_24 (5 << 5) +#define ATMEL_LCDC_PIXELSIZE_32 (6 << 5) +#define ATMEL_LCDC_INVVD (1 << 8) +#define ATMEL_LCDC_INVVD_NORMAL (0 << 8) +#define ATMEL_LCDC_INVVD_INVERTED (1 << 8) +#define ATMEL_LCDC_INVFRAME (1 << 9 ) +#define ATMEL_LCDC_INVFRAME_NORMAL (0 << 9) +#define ATMEL_LCDC_INVFRAME_INVERTED (1 << 9) +#define ATMEL_LCDC_INVLINE (1 << 10) +#define ATMEL_LCDC_INVLINE_NORMAL (0 << 10) +#define ATMEL_LCDC_INVLINE_INVERTED (1 << 10) +#define ATMEL_LCDC_INVCLK (1 << 11) +#define ATMEL_LCDC_INVCLK_NORMAL (0 << 11) +#define ATMEL_LCDC_INVCLK_INVERTED (1 << 11) +#define ATMEL_LCDC_INVDVAL (1 << 12) +#define ATMEL_LCDC_INVDVAL_NORMAL (0 << 12) +#define ATMEL_LCDC_INVDVAL_INVERTED (1 << 12) +#define ATMEL_LCDC_CLKMOD (1 << 15) +#define ATMEL_LCDC_CLKMOD_ACTIVEDISPLAY (0 << 15) +#define ATMEL_LCDC_CLKMOD_ALWAYSACTIVE (1 << 15) +#define ATMEL_LCDC_MEMOR (1 << 31) +#define ATMEL_LCDC_MEMOR_BIG (0 << 31) +#define ATMEL_LCDC_MEMOR_LITTLE (1 << 31) + +#define ATMEL_LCDC_TIM1 0x0808 +#define ATMEL_LCDC_VFP (0xff << 0) +#define ATMEL_LCDC_VBP_OFFSET 8 +#define ATMEL_LCDC_VBP (0xff << ATMEL_LCDC_VBP_OFFSET) +#define ATMEL_LCDC_VPW_OFFSET 16 +#define ATMEL_LCDC_VPW (0x3f << ATMEL_LCDC_VPW_OFFSET) +#define ATMEL_LCDC_VHDLY_OFFSET 24 +#define ATMEL_LCDC_VHDLY (0xf << ATMEL_LCDC_VHDLY_OFFSET) + +#define ATMEL_LCDC_TIM2 0x080c +#define ATMEL_LCDC_HBP (0xff << 0) +#define ATMEL_LCDC_HPW_OFFSET 8 +#define ATMEL_LCDC_HPW (0x3f << ATMEL_LCDC_HPW_OFFSET) +#define ATMEL_LCDC_HFP_OFFSET 21 +#define ATMEL_LCDC_HFP (0x7ff << ATMEL_LCDC_HFP_OFFSET) + +#define ATMEL_LCDC_LCDFRMCFG 0x0810 +#define ATMEL_LCDC_LINEVAL (0x7ff << 0) +#define ATMEL_LCDC_HOZVAL_OFFSET 21 +#define ATMEL_LCDC_HOZVAL (0x7ff << ATMEL_LCDC_HOZVAL_OFFSET) + +#define ATMEL_LCDC_FIFO 0x0814 +#define ATMEL_LCDC_FIFOTH (0xffff) + +#define ATMEL_LCDC_MVAL 0x0818 + +#define ATMEL_LCDC_DP1_2 0x081c +#define ATMEL_LCDC_DP4_7 0x0820 +#define ATMEL_LCDC_DP3_5 0x0824 +#define ATMEL_LCDC_DP2_3 0x0828 +#define ATMEL_LCDC_DP5_7 0x082c +#define ATMEL_LCDC_DP3_4 0x0830 +#define ATMEL_LCDC_DP4_5 0x0834 +#define ATMEL_LCDC_DP6_7 0x0838 +#define ATMEL_LCDC_DP1_2_VAL (0xff) +#define ATMEL_LCDC_DP4_7_VAL (0xfffffff) +#define ATMEL_LCDC_DP3_5_VAL (0xfffff) +#define ATMEL_LCDC_DP2_3_VAL (0xfff) +#define ATMEL_LCDC_DP5_7_VAL (0xfffffff) +#define ATMEL_LCDC_DP3_4_VAL (0xffff) +#define ATMEL_LCDC_DP4_5_VAL (0xfffff) +#define ATMEL_LCDC_DP6_7_VAL (0xfffffff) + +#define ATMEL_LCDC_PWRCON 0x083c +#define ATMEL_LCDC_PWR (1 << 0) +#define ATMEL_LCDC_GUARDT_OFFSET 1 +#define ATMEL_LCDC_GUARDT (0x7f << ATMEL_LCDC_GUARDT_OFFSET) +#define ATMEL_LCDC_BUSY (1 << 31) + +#define ATMEL_LCDC_CONTRAST_CTR 0x0840 +#define ATMEL_LCDC_PS (3 << 0) +#define ATMEL_LCDC_PS_DIV1 (0 << 0) +#define ATMEL_LCDC_PS_DIV2 (1 << 0) +#define ATMEL_LCDC_PS_DIV4 (2 << 0) +#define ATMEL_LCDC_PS_DIV8 (3 << 0) +#define ATMEL_LCDC_POL (1 << 2) +#define ATMEL_LCDC_POL_NEGATIVE (0 << 2) +#define ATMEL_LCDC_POL_POSITIVE (1 << 2) +#define ATMEL_LCDC_ENA (1 << 3) +#define ATMEL_LCDC_ENA_PWMDISABLE (0 << 3) +#define ATMEL_LCDC_ENA_PWMENABLE (1 << 3) + +#define ATMEL_LCDC_CONTRAST_VAL 0x0844 +#define ATMEL_LCDC_CVAL (0xff) + +#define ATMEL_LCDC_IER 0x0848 +#define ATMEL_LCDC_IDR 0x084c +#define ATMEL_LCDC_IMR 0x0850 +#define ATMEL_LCDC_ISR 0x0854 +#define ATMEL_LCDC_ICR 0x0858 +#define ATMEL_LCDC_LNI (1 << 0) +#define ATMEL_LCDC_LSTLNI (1 << 1) +#define ATMEL_LCDC_EOFI (1 << 2) +#define ATMEL_LCDC_UFLWI (1 << 4) +#define ATMEL_LCDC_OWRI (1 << 5) +#define ATMEL_LCDC_MERI (1 << 6) + +#define ATMEL_LCDC_LUT (n) (0x0c00 + ((n)*4)) + +#endif /* __ATMEL_LCDC_H__ */
drivers/video/atmel_lcdfb.c new file +772 -0
772 lines not on this page · raw message
drivers/video/Kconfig +0 -0
@@ -674,6 +674,22 @@
working with S1D13806). Product specs at <http://www.erd.epson.com/vdc/html/legacy_13xxx.htm>
+config FB_ATMEL
+ tristate "AT91/AT32 LCD Controller support"
+ depends on FB && (ARCH_AT91SAM9261 || ARCH_AT91SAM9263 || AVR32)
+ select FB_CFB_FILLRECT
+ select FB_CFB_COPYAREA
+ select FB_CFB_IMAGEBLIT
+ help
+ This enables support for the AT91/AT32 LCD Controller.
+
+config FB_INTSRAM
+ bool "Frame Buffer in internal SRAM"
+ depends on FB_ATMEL && ARCH_AT91SAM9261
+ help
+ Say Y if you want to map Frame Buffer in internal SRAM. Say N if you want
+ to let frame buffer in external SDRAM.
+
config FB_NVIDIA
tristate "nVidia Framebuffer Support" depends on FB && PCI
drivers/video/Makefile +0 -0
@@ -75,6 +75,7 @@
obj-$(CONFIG_FB_SA1100) += sa1100fb.o
obj-$(CONFIG_FB_HIT) += hitfb.o
obj-$(CONFIG_FB_EPSON1355) += epson1355fb.o
+obj-$(CONFIG_FB_ATMEL) += atmel_lcdfb.o
obj-$(CONFIG_FB_PVR2) += pvr2fb.o
obj-$(CONFIG_FB_VOODOO1) += sstfb.o
obj-$(CONFIG_FB_ARMCLCD) += amba-clcd.o
Signature · 1 line
Nicolas Ferre
RFC 1/1 AVR32: Implement platform hooks for atmel_lcdfb driver
This modifies and extends the existing AVR32 lcdc platform code to support the new atmel_lcdfb driver. The ATSTK1000 board code is set up to use the on-board Samsung LTV350QV LCD panel.
---
I'm planning to push this upstream through the AVR32 tree unless someone finds any problems with the platform interface to the atmel_lcdfb driver. Posted as a follow-up to show one user of the driver.
arch/avr32/boards/atstk1000/atstk1000.h | 15 ++++++ arch/avr32/boards/atstk1000/atstk1002.c | 10 ++-- arch/avr32/boards/atstk1000/setup.c | 45 +++++++++++++++++- arch/avr32/mach-at32ap/at32ap7000.c | 77 ++++++++++++++++++++++++------- include/asm-avr32/arch-at32ap/board.h | 8 +-- 5 files changed, 127 insertions(+), 28 deletions(-)
arch/avr32/boards/atstk1000/atstk1000.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* ATSTK1000 setup code: Daughterboard interface +* +* Copyright (C) 2007 Atmel Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ +#ifndef __ARCH_AVR32_BOARDS_ATSTK1000_ATSTK1000_H +#define __ARCH_AVR32_BOARDS_ATSTK1000_ATSTK1000_H + +extern struct atmel_lcdfb_info atstk1000_lcdc_data; + +#endif /* __ARCH_AVR32_BOARDS_ATSTK1000_ATSTK1000_H */
arch/avr32/boards/atstk1000/atstk1002.c +5 -5
@@ -16,6 +16,8 @@#include <linux/types.h> #include <linux/spi/spi.h> +#include <video/atmel_lcdc.h> +#include <asm/io.h> #include <asm/setup.h> #include <asm/arch/at32ap7000.h>
@@ -23,6 +25,7 @@#include <asm/arch/init.h> #include <asm/arch/portmux.h> +#include "atstk1000.h" #define SW2_DEFAULT /* MMCI and UART_A available */
@@ -31,9 +34,7 @@ struct eth_addr { };static struct eth_addr __initdata hw_addr[2 ]; -static struct eth_platform_data __initdata eth_data[2 ]; -static struct lcdc_platform_data atstk1000_fb0_data;static struct spi_board_info spi0_board_info[]__initdata = { {
@@ -148,9 +149,8 @@ static int __init atstk1002_init(void)set_hw_addr (at32_add_device_eth (0 , ð_data[0 ]));at32_add_device_spi (0 , spi0_board_info,ARRAY_SIZE (spi0_board_info)); - atstk1000_fb0_data.fbmem_start = fbmem_start; - atstk1000_fb0_data.fbmem_size = fbmem_size; -at32_add_device_lcdc (0 , &atstk1000_fb0_data); +at32_add_device_lcdc (0 , &atstk1000_lcdc_data, + fbmem_start, fbmem_size);return 0 ; }
arch/avr32/boards/atstk1000/setup.c +44 -1
57 lines not on this page · raw message
arch/avr32/mach-at32ap/at32ap7000.c +60 -17
139 lines not on this page · raw message
include/asm-avr32/arch-at32ap/board.h +3 -5
@@ -30,11 +30,9 @@ struct spi_board_info;struct platform_device *at32_add_device_spi (unsigned int id,struct spi_board_info *b,unsigned int n); -struct lcdc_platform_data { -unsigned long fbmem_start; -unsigned long fbmem_size; -}; +struct atmel_lcdfb_info ;struct platform_device * -at32_add_device_lcdc (unsigned int id,struct lcdc_platform_data *data); +at32_add_device_lcdc (unsigned int id,struct atmel_lcdfb_info *data, +unsigned long fbmem_start,unsigned long fbmem_len);#endif /* __ASM_ARCH_BOARD_H */
Signature · 1 line
1.4.4.4
Quoted 9 lines · Nicolas Ferre
From: Nicolas Ferre <[email protected]>
Adds a framebuffer driver to ATMEL AT91SAM9x and AT32 aka AVR32 platforms. Those chips share quite the same IP and this code is suitable for both architectures.
Signed-off-by Nicolas Ferre <[email protected]>---
drivers/video/atmel_lcdfb.c line 46
Quoted 8 lines
drivers/video/atmel_lcdfb.c new file +8
-0+#if defined(CONFIG_ARCH_AT91 ) +#define ATMEL_LCDFB_FBINFO_DEFAULT FBINFO_DEFAULT + +static inline void atmel_lcdfb_update_dma2d (struct atmel_lcdfb_info *sinfo, +struct fb_var_screeninfo *var) +{ + +}
Or
#define atmel_lcdfb_update(...) do {} while (0)
?
drivers/video/atmel_lcdfb.c line 81
Quoted 10 lines
drivers/video/atmel_lcdfb.c new file +10
-0+ +static struct fb_fix_screeninfo atmel_lcdfb_fix__initdata = { + .type =FB_TYPE_PACKED_PIXELS , + .visual =FB_VISUAL_TRUECOLOR , + .xpanstep =0 , + .ypanstep =0 , + .ywrapstep =0 , + .accel =FB_ACCEL_NONE , +}; +
This driver has fb_pan_display() which I assume works. However, you also need to set ypanstep and/or xpanstep and/or ywrapstep to a nonzero value, depending on the hardware/drive capability.
Quoted 9 lines
drivers/video/atmel_lcdfb.c new file +9
-0+static u32 pseudo_palette[16 ] = { +0x000000 , +0xaa0000 , +0x00aa00 , +0xaa5500 , +0x0000aa , +0xaa00aa , +0x00aaaa , +0xaaaaaa ,
drivers/video/atmel_lcdfb.c line 100
Quoted 10 lines
drivers/video/atmel_lcdfb.c new file +10
-0+0x555555 , +0xff5555 , +0x55ff55 , +0xffff55 , +0x5555ff , +0xff55ff , +0x55ffff , + 0xffffff +}; +
Do you really need to pre-fill pseudo_palette[]? The contents are going to be overwritten by the console anyway (The pseudo_palette is for fbcon's use only).
You can also include pseudo_palette[] as part of struct atmel_lcdfb_info, then in your probe routine:
info->pseudo_palette = par->pseudo_palette;
to reduce the size of the kernel image.
drivers/video/atmel_lcdfb.c line 368
Quoted 2 lines
drivers/video/atmel_lcdfb.c new file +2
-0+ +static inline u_int chan_to_field (u_int chan,const struct fb_bitfield *bf)
Might as well change u_int to u32 or unsigned int, for consistency.
Quoted 5 lines
drivers/video/atmel_lcdfb.c new file +5
-0+{ + chan &=0xffff ; + chan >>=16 - bf->length; +return chan << bf->offset; +}
drivers/video/atmel_lcdfb.c line 484
Quoted 10 lines
drivers/video/atmel_lcdfb.c new file +10
-0+ + + + +static int __init atmel_lcdfb_init_fbinfo (struct atmel_lcdfb_info *sinfo) +{ +struct fb_info *info = sinfo->info; +int ret =0 ; + +memset (info->screen_base,0 , info->fix.smem_len);
memset_io?
Quoted 41 lines
drivers/video/atmel_lcdfb.c new file +40
-0+ info->var.activate |=FB_ACTIVATE_FORCE |FB_ACTIVATE_NOW ; + +dev_info (info->device, +"%luKiB frame buffer at %08lx (mapped at %p)\n" , + (unsigned long )info->fix.smem_len /1024 , + (unsigned long )info->fix.smem_start, + info->screen_base); + +/* Allocate colormap */ + ret =fb_alloc_cmap (&info->cmap,256 ,0 ); +if (ret <0 ) +dev_err (info->device,"Alloc color map failed\n" ); + +return ret; +} + + + +static int __init atmel_lcdfb_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct fb_info *info; +struct atmel_lcdfb_info *sinfo; +struct atmel_lcdfb_info *pdata_sinfo; +struct resource *regs =NULL ; +struct resource *map =NULL ; +int ret; + +dev_dbg (dev,"%s BEGIN\n" , __func__); + + ret = -ENOMEM ; + info =framebuffer_alloc (sizeof (struct atmel_lcdfb_info ), dev); +if (!info) { +dev_err (dev,"cannot allocate memory\n" ); + goto out; + } + + sinfo = info->par; + +if (dev->platform_data) {
drivers/video/atmel_lcdfb.c line 547
Quoted 10 lines
drivers/video/atmel_lcdfb.c new file +10
-0+ pdata_sinfo = (struct atmel_lcdfb_info *)dev->platform_data; + sinfo->default_bpp = pdata_sinfo->default_bpp; + sinfo->default_dmacon = pdata_sinfo->default_dmacon; + sinfo->default_lcdcon2 = pdata_sinfo->default_lcdcon2; + sinfo->default_monspecs = pdata_sinfo->default_monspecs; + sinfo->atmel_lcdfb_power_control = pdata_sinfo->atmel_lcdfb_power_control; + sinfo->guard_time = pdata_sinfo->guard_time; + }else { +dev_err (dev,"cannot get default configuration\n" ); + goto out;
Wrong goto? Should be goto free_info?
Quoted 10 lines
drivers/video/atmel_lcdfb.c new file +10
-0+ +free_cmap: +fb_dealloc_cmap (&info->cmap); +unregister_irqs: +free_irq (sinfo->irq_base, info); +unmap_mmio: +iounmap (sinfo->mmio); +release_mem: +release_mem_region (info->fix.mmio_start, info->fix.mmio_len); +free_fb:
drivers/video/atmel_lcdfb.c line 702
Quoted 10 lines
drivers/video/atmel_lcdfb.c new file +10
-0+if (map) { +iounmap (info->screen_base); + }else { +atmel_lcdfb_free_video_memory (sinfo); + } + +release_intmem: +if (map) { +release_mem_region (info->fix.smem_start, info->fix.smem_len); + }
Unnecessary curly braces
drivers/video/atmel_lcdfb.c line 760
Quoted 13 lines
drivers/video/atmel_lcdfb.c new file +13
-0+ +static struct platform_driver atmel_lcdfb_driver = { + .remove =__exit_p (atmel_lcdfb_remove), + .driver = { + .name ="atmel_lcdfb" , + .owner =THIS_MODULE , + }, +}; + +static int __init atmel_lcdfb_init (void ) +{ +return platform_driver_probe (&atmel_lcdfb_driver, atmel_lcdfb_probe); +}
Is this intentional? Why not platform_driver_register()?
drivers/video/atmel_lcdfb.c line 766
Quoted 6 lines
drivers/video/atmel_lcdfb.c new file +6
-0+ +static void __exit atmel_lcdfb_exit(void) +{ +platform_driver_unregister (&atmel_lcdfb_driver); +} +
Tony
Hi Antonio,
Thanks for the feedback. I'm just going to reply to one of your comments and leave the rest for Nicolas...
Quoted 6 lines · On Tue, 08 May 2007 05:40:17 +0800 "Antonino A. Daplas" <[email protected]>…
drivers/video/atmel_lcdfb.c line 760
Quoted 4 lines
drivers/video/atmel_lcdfb.c new file +4
-0+static int __init atmel_lcdfb_init (void ) +{ +return platform_driver_probe (&atmel_lcdfb_driver, atmel_lcdfb_probe); +}Is this intentional? Why not
platform_driver_register()?
Yes, it's intentional. This way, the atmel_lcdfb_probe function can be __init since it doesn't need to be referenced from atmel_lcdfb_driver. Saves a bit of memory at run time.
The downside is that hot plugging won't work, but that isn't very relevant for on-chip devices anyway.
Haavard
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
PATCH 1/1 atmel_lcdfb: AT91/AT32 LCD Controller framebuffer driver
In reply to Antonino A. DaplasFrom: Nicolas Ferre <[email protected]>
Adds a framebuffer driver to ATMEL AT91SAM9x and AT32 aka AVR32 platforms. Those chips share quite the same IP and this code is suitable for both architectures.
---
This second patch is rebuild following Antonio A. Daplas comments. Thank you Tony.
The header file resides in an arch neutral directory.
AT91 platform informations are directly submitted trough the at91 maintainer.
drivers/video/Kconfig | 16 drivers/video/Makefile | 1 drivers/video/atmel_lcdfb.c | 752 ++++++++++++++++++++++++++++++++++include/video/atmel_lcdc.h | 196 ++++++++
4 files changed, 965 insertions(+)
include/video/atmel_lcdc.h new file +196 -0
@@ -0,0 +1,196 @@ +/* +* Header file for AT91/AT32 LCD Controller +* +* Data structure and register user interface +* +* Copyright (C) 2007 Atmel Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#ifndef __ATMEL_LCDC_H__ +#define __ATMEL_LCDC_H__ + +/* LCD Controller info data structure */ +struct atmel_lcdfb_info { +spinlock_t lock; +struct fb_info *info; +void __iomem *mmio; +unsigned long irq_base; + +unsigned int guard_time; +struct platform_device *pdev; +struct clk *bus_clk; +struct clk *lcdc_clk; +unsigned int default_bpp; +unsigned int default_lcdcon2; +unsigned int default_dmacon; +void (*atmel_lcdfb_power_control)(int on); +struct fb_monspecs *default_monspecs; +u32 pseudo_palette[16 ]; +}; + +#define ATMEL_LCDC_DMABADDR1 0x00 +#define ATMEL_LCDC_DMABADDR2 0x04 +#define ATMEL_LCDC_DMAFRMPT1 0x08 +#define ATMEL_LCDC_DMAFRMPT2 0x0c +#define ATMEL_LCDC_DMAFRMADD1 0x10 +#define ATMEL_LCDC_DMAFRMADD2 0x14 + +#define ATMEL_LCDC_DMAFRMCFG 0x18 +#define ATMEL_LCDC_FRSIZE (0x7fffff << 0) +#define ATMEL_LCDC_BLENGTH_OFFSET 24 +#define ATMEL_LCDC_BLENGTH (0x7f << ATMEL_LCDC_BLENGTH_OFFSET) + +#define ATMEL_LCDC_DMACON 0x1c +#define ATMEL_LCDC_DMAEN (0x1 << 0) +#define ATMEL_LCDC_DMARST (0x1 << 1) +#define ATMEL_LCDC_DMABUSY (0x1 << 2) +#define ATMEL_LCDC_DMAUPDT (0x1 << 3) +#define ATMEL_LCDC_DMA2DEN (0x1 << 4) + +#define ATMEL_LCDC_DMA2DCFG 0x20 +#define ATMEL_LCDC_ADDRINC_OFFSET 0 +#define ATMEL_LCDC_ADDRINC (0xffff) +#define ATMEL_LCDC_PIXELOFF_OFFSET 24 +#define ATMEL_LCDC_PIXELOFF (0x1f << 24) + +#define ATMEL_LCDC_LCDCON1 0x0800 +#define ATMEL_LCDC_BYPASS (1 << 0) +#define ATMEL_LCDC_CLKVAL_OFFSET 12 +#define ATMEL_LCDC_CLKVAL (0x1ff << ATMEL_LCDC_CLKVAL_OFFSET) +#define ATMEL_LCDC_LINCNT (0x7ff << 21) + +#define ATMEL_LCDC_LCDCON2 0x0804 +#define ATMEL_LCDC_DISTYPE (3 << 0) +#define ATMEL_LCDC_DISTYPE_STNMONO (0 << 0) +#define ATMEL_LCDC_DISTYPE_STNCOLOR (1 << 0) +#define ATMEL_LCDC_DISTYPE_TFT (2 << 0) +#define ATMEL_LCDC_SCANMOD (1 << 2) +#define ATMEL_LCDC_SCANMOD_SINGLE (0 << 2) +#define ATMEL_LCDC_SCANMOD_DUAL (1 << 2) +#define ATMEL_LCDC_IFWIDTH (3 << 3) +#define ATMEL_LCDC_IFWIDTH_4 (0 << 3) +#define ATMEL_LCDC_IFWIDTH_8 (1 << 3) +#define ATMEL_LCDC_IFWIDTH_16 (2 << 3) +#define ATMEL_LCDC_PIXELSIZE (7 << 5) +#define ATMEL_LCDC_PIXELSIZE_1 (0 << 5) +#define ATMEL_LCDC_PIXELSIZE_2 (1 << 5) +#define ATMEL_LCDC_PIXELSIZE_4 (2 << 5) +#define ATMEL_LCDC_PIXELSIZE_8 (3 << 5) +#define ATMEL_LCDC_PIXELSIZE_16 (4 << 5) +#define ATMEL_LCDC_PIXELSIZE_24 (5 << 5) +#define ATMEL_LCDC_PIXELSIZE_32 (6 << 5) +#define ATMEL_LCDC_INVVD (1 << 8) +#define ATMEL_LCDC_INVVD_NORMAL (0 << 8) +#define ATMEL_LCDC_INVVD_INVERTED (1 << 8) +#define ATMEL_LCDC_INVFRAME (1 << 9 ) +#define ATMEL_LCDC_INVFRAME_NORMAL (0 << 9) +#define ATMEL_LCDC_INVFRAME_INVERTED (1 << 9) +#define ATMEL_LCDC_INVLINE (1 << 10) +#define ATMEL_LCDC_INVLINE_NORMAL (0 << 10) +#define ATMEL_LCDC_INVLINE_INVERTED (1 << 10) +#define ATMEL_LCDC_INVCLK (1 << 11) +#define ATMEL_LCDC_INVCLK_NORMAL (0 << 11) +#define ATMEL_LCDC_INVCLK_INVERTED (1 << 11) +#define ATMEL_LCDC_INVDVAL (1 << 12) +#define ATMEL_LCDC_INVDVAL_NORMAL (0 << 12) +#define ATMEL_LCDC_INVDVAL_INVERTED (1 << 12) +#define ATMEL_LCDC_CLKMOD (1 << 15) +#define ATMEL_LCDC_CLKMOD_ACTIVEDISPLAY (0 << 15) +#define ATMEL_LCDC_CLKMOD_ALWAYSACTIVE (1 << 15) +#define ATMEL_LCDC_MEMOR (1 << 31) +#define ATMEL_LCDC_MEMOR_BIG (0 << 31) +#define ATMEL_LCDC_MEMOR_LITTLE (1 << 31) + +#define ATMEL_LCDC_TIM1 0x0808 +#define ATMEL_LCDC_VFP (0xff << 0) +#define ATMEL_LCDC_VBP_OFFSET 8 +#define ATMEL_LCDC_VBP (0xff << ATMEL_LCDC_VBP_OFFSET) +#define ATMEL_LCDC_VPW_OFFSET 16 +#define ATMEL_LCDC_VPW (0x3f << ATMEL_LCDC_VPW_OFFSET) +#define ATMEL_LCDC_VHDLY_OFFSET 24 +#define ATMEL_LCDC_VHDLY (0xf << ATMEL_LCDC_VHDLY_OFFSET) + +#define ATMEL_LCDC_TIM2 0x080c +#define ATMEL_LCDC_HBP (0xff << 0) +#define ATMEL_LCDC_HPW_OFFSET 8 +#define ATMEL_LCDC_HPW (0x3f << ATMEL_LCDC_HPW_OFFSET) +#define ATMEL_LCDC_HFP_OFFSET 21 +#define ATMEL_LCDC_HFP (0x7ff << ATMEL_LCDC_HFP_OFFSET) + +#define ATMEL_LCDC_LCDFRMCFG 0x0810 +#define ATMEL_LCDC_LINEVAL (0x7ff << 0) +#define ATMEL_LCDC_HOZVAL_OFFSET 21 +#define ATMEL_LCDC_HOZVAL (0x7ff << ATMEL_LCDC_HOZVAL_OFFSET) + +#define ATMEL_LCDC_FIFO 0x0814 +#define ATMEL_LCDC_FIFOTH (0xffff) + +#define ATMEL_LCDC_MVAL 0x0818 + +#define ATMEL_LCDC_DP1_2 0x081c +#define ATMEL_LCDC_DP4_7 0x0820 +#define ATMEL_LCDC_DP3_5 0x0824 +#define ATMEL_LCDC_DP2_3 0x0828 +#define ATMEL_LCDC_DP5_7 0x082c +#define ATMEL_LCDC_DP3_4 0x0830 +#define ATMEL_LCDC_DP4_5 0x0834 +#define ATMEL_LCDC_DP6_7 0x0838 +#define ATMEL_LCDC_DP1_2_VAL (0xff) +#define ATMEL_LCDC_DP4_7_VAL (0xfffffff) +#define ATMEL_LCDC_DP3_5_VAL (0xfffff) +#define ATMEL_LCDC_DP2_3_VAL (0xfff) +#define ATMEL_LCDC_DP5_7_VAL (0xfffffff) +#define ATMEL_LCDC_DP3_4_VAL (0xffff) +#define ATMEL_LCDC_DP4_5_VAL (0xfffff) +#define ATMEL_LCDC_DP6_7_VAL (0xfffffff) + +#define ATMEL_LCDC_PWRCON 0x083c +#define ATMEL_LCDC_PWR (1 << 0) +#define ATMEL_LCDC_GUARDT_OFFSET 1 +#define ATMEL_LCDC_GUARDT (0x7f << ATMEL_LCDC_GUARDT_OFFSET) +#define ATMEL_LCDC_BUSY (1 << 31) + +#define ATMEL_LCDC_CONTRAST_CTR 0x0840 +#define ATMEL_LCDC_PS (3 << 0) +#define ATMEL_LCDC_PS_DIV1 (0 << 0) +#define ATMEL_LCDC_PS_DIV2 (1 << 0) +#define ATMEL_LCDC_PS_DIV4 (2 << 0) +#define ATMEL_LCDC_PS_DIV8 (3 << 0) +#define ATMEL_LCDC_POL (1 << 2) +#define ATMEL_LCDC_POL_NEGATIVE (0 << 2) +#define ATMEL_LCDC_POL_POSITIVE (1 << 2) +#define ATMEL_LCDC_ENA (1 << 3) +#define ATMEL_LCDC_ENA_PWMDISABLE (0 << 3) +#define ATMEL_LCDC_ENA_PWMENABLE (1 << 3) + +#define ATMEL_LCDC_CONTRAST_VAL 0x0844 +#define ATMEL_LCDC_CVAL (0xff) + +#define ATMEL_LCDC_IER 0x0848 +#define ATMEL_LCDC_IDR 0x084c +#define ATMEL_LCDC_IMR 0x0850 +#define ATMEL_LCDC_ISR 0x0854 +#define ATMEL_LCDC_ICR 0x0858 +#define ATMEL_LCDC_LNI (1 << 0) +#define ATMEL_LCDC_LSTLNI (1 << 1) +#define ATMEL_LCDC_EOFI (1 << 2) +#define ATMEL_LCDC_UFLWI (1 << 4) +#define ATMEL_LCDC_OWRI (1 << 5) +#define ATMEL_LCDC_MERI (1 << 6) + +#define ATMEL_LCDC_LUT (n) (0x0c00 + ((n)*4)) + +#endif /* __ATMEL_LCDC_H__ */
drivers/video/atmel_lcdfb.c new file +752 -0
752 lines not on this page · raw message
drivers/video/Kconfig +0 -0
@@ -674,6 +674,22 @@
working with S1D13806). Product specs at <http://www.erd.epson.com/vdc/html/legacy_13xxx.htm>
+config FB_ATMEL
+ tristate "AT91/AT32 LCD Controller support"
+ depends on FB && (ARCH_AT91SAM9261 || ARCH_AT91SAM9263 || AVR32)
+ select FB_CFB_FILLRECT
+ select FB_CFB_COPYAREA
+ select FB_CFB_IMAGEBLIT
+ help
+ This enables support for the AT91/AT32 LCD Controller.
+
+config FB_INTSRAM
+ bool "Frame Buffer in internal SRAM"
+ depends on FB_ATMEL && ARCH_AT91SAM9261
+ help
+ Say Y if you want to map Frame Buffer in internal SRAM. Say N if you want
+ to let frame buffer in external SDRAM.
+
config FB_NVIDIA
tristate "nVidia Framebuffer Support" depends on FB && PCI
drivers/video/Makefile +0 -0
@@ -75,6 +75,7 @@
obj-$(CONFIG_FB_SA1100) += sa1100fb.o
obj-$(CONFIG_FB_HIT) += hitfb.o
obj-$(CONFIG_FB_EPSON1355) += epson1355fb.o
+obj-$(CONFIG_FB_ATMEL) += atmel_lcdfb.o
obj-$(CONFIG_FB_PVR2) += pvr2fb.o
obj-$(CONFIG_FB_VOODOO1) += sstfb.o
obj-$(CONFIG_FB_ARMCLCD) += amba-clcd.o
Hi Nicolas,
drivers/video/atmel_lcdfb.c line 249
Quoted 1 line
drivers/video/atmel_lcdfb.c new file +1
-0+ info->fix.line_length = info->var.xres_virtual * (info->var.bits_per_pixel /8 );
line_length will always be 0 for bits_per_pixel < 8.
Jan
PATCH 1/1 atmel_lcdfb: Fix wrong line_length calculation
As Jan Altenberg pointed out, line_length will always be 0 if bits_per_pixel < 8. Fix this and also make sure that we round up to the nearest byte.
---
I haven't tested this with any real program that uses the frame buffer, but fbset seems to report sane values for line_length:
-sh-3.2# fbset -i
mode "320x240-68"
# D: 6.891 MHz, H: 17.852 kHz, V: 68.400 Hz
geometry 320 240 320 240 4
timings 145116 17 33 10 10 16 1
rgba 4/0,4/0,4/0,0/0endmode
Frame buffer device information:
Name :
Address : 0x102c0000
Size : 230400
Type : PACKED PIXELS
Visual : PSEUDOCOLOR
XPanStep : 0
YPanStep : 0
YWrapStep : 0
LineLength : 160
MMIO Address: 0xff000000
MMIO Size : 4096
Accelerator : NoThe XPanStep and YPanStep values are wrong though. Nicolas, I suspect YPanStep should be 1 on AT91 as well since the only thing required is the ability to change the DMA base address. The DMA2D stuff is only required for X panning if I understand it correctly.
drivers/video/atmel_lcdfb.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/video/atmel_lcdfb.c +3 -1
@@ -230,6 +230,7 @@ static int atmel_lcdfb_set_par(struct fb_info *info)struct atmel_lcdfb_info *sinfo = info->par;unsigned long value;unsigned long clk_value_khz; +unsigned long bits_per_line;dev_dbg (info->device,"%s:\n" , __func__); dev_dbg(info->device, " * resolution: %ux%u (%ux%u virtual)\n",
@@ -246,7 +247,8 @@ static int atmel_lcdfb_set_par(struct fb_info *info)else info->fix.visual =FB_VISUAL_TRUECOLOR ; - info->fix.line_length = info->var.xres_virtual * (info->var.bits_per_pixel /8 ); + bits_per_line = info->var.xres_virtual * info->var.bits_per_pixel; + info->fix.line_length =DIV_ROUND_UP (bits_per_line,8 );/* Re-initialize the DMA engine... */ dev_dbg (info->device," * update DMA engine\n" );
Signature · 1 line
1.4.4.4
Re: [PATCH] atmel_lcdfb: Fix wrong line_length calculation
Haavard Skinnemoen :
Quoted 8 lines
As Jan Altenberg pointed out,
line_lengthwill always be 0 ifbits_per_pixel< 8. Fix this and also make sure that we round up to the nearest byte.Signed-off-by Haavard Skinnemoen <[email protected]>---
I haven't tested this with any real program that uses the frame buffer, but fbset seems to report sane values forline_length:
Thank you Haavard.
I have a bigger patch for all the support for STN display (tested with mono STN display). It is based on the work from Jan Altenberg.
This bigger patch includes your modifications.
I send it right now. As a separate message.
Haavard, can you check if the compute_hozval()
function is ok on avr32 (I have reviewed with the at32ap7000 and hope that it is ok) ?
Regards,
Signature · 9 lines
Nicolas Ferre ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/
Re: [Linux-fbdev-devel] [PATCH] atmel_lcdfb: AT91/AT32 LCDController framebuffer driver
In reply to Antonino A. DaplasAntonino A. Daplas :
Quoted 17 lines · Nicolas Ferre
drivers/video/atmel_lcdfb.c line 81
Quoted 12 lines
From: Nicolas Ferre <[email protected]>
drivers/video/atmel_lcdfb.c new file +10
-0+ +static struct fb_fix_screeninfo atmel_lcdfb_fix__initdata = { + .type =FB_TYPE_PACKED_PIXELS , + .visual =FB_VISUAL_TRUECOLOR , + .xpanstep =0 , + .ypanstep =0 , + .ywrapstep =0 , + .accel =FB_ACCEL_NONE , +}; +This driver has
fb_pan_display()which I assume works. However, you also need to set ypanstep and/or xpanstep and/or ywrapstep to a nonzero value, depending on the hardware/drive capability.
True, this function is here because one of our products can do pan display. The technique is not used for the moment but will be in a future version of this driver.
Quoted 15 lines
Quoted 15 lines
drivers/video/atmel_lcdfb.c new file +15
-0+static u32 pseudo_palette[16 ] = { +0x000000 , +0xaa0000 , +0x00aa00 , +0xaa5500 , +0x0000aa , +0xaa00aa , +0x00aaaa , +0xaaaaaa , +0x555555 , +0xff5555 , +0x55ff55 , +0xffff55 , +0x5555ff , +0xff55ff ,
Quoted 8 lines
drivers/video/atmel_lcdfb.c line 100
Quoted 4 lines
drivers/video/atmel_lcdfb.c new file +4
-0+0x55ffff , + 0xffffff +}; +Do you really need to pre-fill pseudo_palette[]? The contents are going to be overwritten by the console anyway (The
pseudo_paletteis for fbcon's use only).
Ok, I have tested it with fbcon and no pre-fill : colors seem ok.
Quoted 6 lines
You can also include pseudo_palette[] as part of struct
atmel_lcdfb_info, then in your probe routine:
info->pseudo_palette=par->pseudo_palette;to reduce the size of the kernel image.
Done.
Quoted 3 lines
Quoted 1 line
+static inline
u_intchan_to_field(u_int chan, const struct fb_bitfield *bf)Might as well change
u_intto u32 or unsigned int, for consistency.
Ok, changed to unsigned int.
Quoted 8 lines
drivers/video/atmel_lcdfb.c line 484
Quoted 6 lines
drivers/video/atmel_lcdfb.c new file +6
-0+static int __init atmel_lcdfb_init_fbinfo (struct atmel_lcdfb_info *sinfo) +{ +struct fb_info *info = sinfo->info; +int ret =0 ; + +memset (info->screen_base,0 , info->fix.smem_len);
memset_io?
ok, modified.
Quoted 5 lines
Quoted 5 lines
drivers/video/atmel_lcdfb.c new file +5
-0+if (dev->platform_data) { + pdata_sinfo = (struct atmel_lcdfb_info *)dev->platform_data; + sinfo->default_bpp = pdata_sinfo->default_bpp; + sinfo->default_dmacon = pdata_sinfo->default_dmacon; + sinfo->default_lcdcon2 = pdata_sinfo->default_lcdcon2;
Quoted 8 lines
drivers/video/atmel_lcdfb.c line 547
Quoted 6 lines
drivers/video/atmel_lcdfb.c new file +6
-0+ sinfo->default_monspecs = pdata_sinfo->default_monspecs; + sinfo->atmel_lcdfb_power_control = pdata_sinfo->atmel_lcdfb_power_control; + sinfo->guard_time = pdata_sinfo->guard_time; + }else { +dev_err (dev,"cannot get default configuration\n" ); + goto out;Wrong goto? Should be goto
free_info?
Right. modified to "goto free_info".
Quoted 6 lines
drivers/video/atmel_lcdfb.c line 702
Quoted 4 lines
drivers/video/atmel_lcdfb.c new file +4
-0+release_intmem: +if (map) { +release_mem_region (info->fix.smem_start, info->fix.smem_len); + }Unnecessary curly braces
I like curly braces... Anyway, removed.
Thanks you for your comments.
I resend a modified driver now in the following email.
Regards,
Signature · 9 lines
Nicolas Ferre ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/