diff options
Diffstat (limited to 'drivers/video')
23 files changed, 150 insertions, 8068 deletions
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 429f15b2b51a..83d3d271ca15 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -3,7 +3,8 @@ # menu "Graphics support" - depends on HAS_IOMEM + +if HAS_IOMEM config HAVE_FB_ATMEL bool @@ -33,6 +34,8 @@ config VIDEOMODE_HELPERS config HDMI bool +endif # HAS_IOMEM + if VT source "drivers/video/console/Kconfig" endif diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 8049e7656daa..deb824bef6e2 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c @@ -580,6 +580,79 @@ struct backlight_device *of_find_backlight_by_node(struct device_node *node) EXPORT_SYMBOL(of_find_backlight_by_node); #endif +/** + * of_find_backlight - Get backlight device + * @dev: Device + * + * This function looks for a property named 'backlight' on the DT node + * connected to @dev and looks up the backlight device. + * + * Call backlight_put() to drop the reference on the backlight device. + * + * Returns: + * A pointer to the backlight device if found. + * Error pointer -EPROBE_DEFER if the DT property is set, but no backlight + * device is found. + * NULL if there's no backlight property. + */ +struct backlight_device *of_find_backlight(struct device *dev) +{ + struct backlight_device *bd = NULL; + struct device_node *np; + + if (!dev) + return NULL; + + if (IS_ENABLED(CONFIG_OF) && dev->of_node) { + np = of_parse_phandle(dev->of_node, "backlight", 0); + if (np) { + bd = of_find_backlight_by_node(np); + of_node_put(np); + if (!bd) + return ERR_PTR(-EPROBE_DEFER); + /* + * Note: gpio_backlight uses brightness as + * power state during probe + */ + if (!bd->props.brightness) + bd->props.brightness = bd->props.max_brightness; + } + } + + return bd; +} +EXPORT_SYMBOL(of_find_backlight); + +static void devm_backlight_release(void *data) +{ + backlight_put(data); +} + +/** + * devm_of_find_backlight - Resource-managed of_find_backlight() + * @dev: Device + * + * Device managed version of of_find_backlight(). + * The reference on the backlight device is automatically + * dropped on driver detach. + */ +struct backlight_device *devm_of_find_backlight(struct device *dev) +{ + struct backlight_device *bd; + int ret; + + bd = of_find_backlight(dev); + if (IS_ERR_OR_NULL(bd)) + return bd; + ret = devm_add_action(dev, devm_backlight_release, bd); + if (ret) { + backlight_put(bd); + return ERR_PTR(ret); + } + return bd; +} +EXPORT_SYMBOL(devm_of_find_backlight); + static void __exit backlight_class_exit(void) { class_destroy(backlight_class); diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig index be63759b6027..4110ba7d7ca9 100644 --- a/drivers/video/console/Kconfig +++ b/drivers/video/console/Kconfig @@ -6,10 +6,9 @@ menu "Console display driver support" config VGA_CONSOLE bool "VGA text console" if EXPERT || !X86 - depends on !4xx && !PPC_8xx && !SPARC && !M68K && !PARISC && !FRV && \ - !SUPERH && !BLACKFIN && !MN10300 && !CRIS && \ + depends on !4xx && !PPC_8xx && !SPARC && !M68K && !PARISC && !SUPERH && \ (!ARM || ARCH_FOOTBRIDGE || ARCH_INTEGRATOR || ARCH_NETWINDER) && \ - !ARM64 && !ARC && !MICROBLAZE && !OPENRISC + !ARM64 && !ARC && !MICROBLAZE && !OPENRISC && !NDS32 && !S390 default y help Saying Y here will allow you to use Linux in text mode through a @@ -85,7 +84,7 @@ config MDA_CONSOLE config SGI_NEWPORT_CONSOLE tristate "SGI Newport Console support" - depends on SGI_IP22 + depends on SGI_IP22 && HAS_IOMEM select FONT_SUPPORT help Say Y here if you want the console on the Newport aka XL graphics @@ -153,7 +152,7 @@ config FRAMEBUFFER_CONSOLE_ROTATION config STI_CONSOLE bool "STI text console" - depends on PARISC + depends on PARISC && HAS_IOMEM select FONT_SUPPORT default y help diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c index b90ef96e43d6..f2eafe2ed980 100644 --- a/drivers/video/console/dummycon.c +++ b/drivers/video/console/dummycon.c @@ -41,12 +41,47 @@ static void dummycon_init(struct vc_data *vc, int init) vc_resize(vc, DUMMY_COLUMNS, DUMMY_ROWS); } -static int dummycon_dummy(void) +static void dummycon_deinit(struct vc_data *vc) { } +static void dummycon_clear(struct vc_data *vc, int sy, int sx, int height, + int width) { } +static void dummycon_putc(struct vc_data *vc, int c, int ypos, int xpos) { } +static void dummycon_putcs(struct vc_data *vc, const unsigned short *s, + int count, int ypos, int xpos) { } +static void dummycon_cursor(struct vc_data *vc, int mode) { } + +static bool dummycon_scroll(struct vc_data *vc, unsigned int top, + unsigned int bottom, enum con_scroll dir, + unsigned int lines) +{ + return false; +} + +static int dummycon_switch(struct vc_data *vc) { - return 0; + return 0; } -#define DUMMY (void *)dummycon_dummy +static int dummycon_blank(struct vc_data *vc, int blank, int mode_switch) +{ + return 0; +} + +static int dummycon_font_set(struct vc_data *vc, struct console_font *font, + unsigned int flags) +{ + return 0; +} + +static int dummycon_font_default(struct vc_data *vc, + struct console_font *font, char *name) +{ + return 0; +} + +static int dummycon_font_copy(struct vc_data *vc, int con) +{ + return 0; +} /* * The console `switch' structure for the dummy console @@ -55,19 +90,19 @@ static int dummycon_dummy(void) */ const struct consw dummy_con = { - .owner = THIS_MODULE, - .con_startup = dummycon_startup, - .con_init = dummycon_init, - .con_deinit = DUMMY, - .con_clear = DUMMY, - .con_putc = DUMMY, - .con_putcs = DUMMY, - .con_cursor = DUMMY, - .con_scroll = DUMMY, - .con_switch = DUMMY, - .con_blank = DUMMY, - .con_font_set = DUMMY, - .con_font_default = DUMMY, - .con_font_copy = DUMMY, + .owner = THIS_MODULE, + .con_startup = dummycon_startup, + .con_init = dummycon_init, + .con_deinit = dummycon_deinit, + .con_clear = dummycon_clear, + .con_putc = dummycon_putc, + .con_putcs = dummycon_putcs, + .con_cursor = dummycon_cursor, + .con_scroll = dummycon_scroll, + .con_switch = dummycon_switch, + .con_blank = dummycon_blank, + .con_font_set = dummycon_font_set, + .con_font_default = dummycon_font_default, + .con_font_copy = dummycon_font_copy, }; EXPORT_SYMBOL_GPL(dummy_con); diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c index 42d02a206059..7f2526b43b33 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -673,12 +673,12 @@ static bool newport_scroll(struct vc_data *vc, unsigned int t, unsigned int b, return true; } -static int newport_dummy(struct vc_data *c) +static int newport_set_origin(struct vc_data *vc) { return 0; } -#define DUMMY (void *) newport_dummy +static void newport_save_screen(struct vc_data *vc) { } const struct consw newport_con = { .owner = THIS_MODULE, @@ -694,8 +694,8 @@ const struct consw newport_con = { .con_blank = newport_blank, .con_font_set = newport_font_set, .con_font_default = newport_font_default, - .con_set_origin = DUMMY, - .con_save_screen = DUMMY + .con_set_origin = newport_set_origin, + .con_save_screen = newport_save_screen }; static int newport_probe(struct gio_device *dev, diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index a17ba1465815..f09e17b60e45 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -1272,7 +1272,8 @@ static int vgacon_adjust_height(struct vc_data *vc, unsigned fontheight) return 0; } -static int vgacon_font_set(struct vc_data *c, struct console_font *font, unsigned flags) +static int vgacon_font_set(struct vc_data *c, struct console_font *font, + unsigned int flags) { unsigned charcount = font->charcount; int rc; @@ -1407,21 +1408,20 @@ static bool vgacon_scroll(struct vc_data *c, unsigned int t, unsigned int b, * The console `switch' structure for the VGA based console */ -static int vgacon_dummy(struct vc_data *c) -{ - return 0; -} - -#define DUMMY (void *) vgacon_dummy +static void vgacon_clear(struct vc_data *vc, int sy, int sx, int height, + int width) { } +static void vgacon_putc(struct vc_data *vc, int c, int ypos, int xpos) { } +static void vgacon_putcs(struct vc_data *vc, const unsigned short *s, + int count, int ypos, int xpos) { } const struct consw vga_con = { .owner = THIS_MODULE, .con_startup = vgacon_startup, .con_init = vgacon_init, .con_deinit = vgacon_deinit, - .con_clear = DUMMY, - .con_putc = DUMMY, - .con_putcs = DUMMY, + .con_clear = vgacon_clear, + .con_putc = vgacon_putc, + .con_putcs = vgacon_putcs, .con_cursor = vgacon_cursor, .con_scroll = vgacon_scroll, .con_switch = vgacon_switch, diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index dbd921d6c40a..d94254263ea5 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -580,109 +580,6 @@ config FB_VGA16 To compile this driver as a module, choose M here: the module will be called vga16fb. -config FB_BF54X_LQ043 - tristate "SHARP LQ043 TFT LCD (BF548 EZKIT)" - depends on FB && (BF54x) && !BF542 - select FB_CFB_FILLRECT - select FB_CFB_COPYAREA - select FB_CFB_IMAGEBLIT - help - This is the framebuffer device driver for a SHARP LQ043T1DG01 TFT LCD - -config FB_BFIN_T350MCQB - tristate "Varitronix COG-T350MCQB TFT LCD display (BF527 EZKIT)" - depends on FB && BLACKFIN - select BFIN_GPTIMERS - select FB_CFB_FILLRECT - select FB_CFB_COPYAREA - select FB_CFB_IMAGEBLIT - help - This is the framebuffer device driver for a Varitronix VL-PS-COG-T350MCQB-01 display TFT LCD - This display is a QVGA 320x240 24-bit RGB display interfaced by an 8-bit wide PPI - It uses PPI[0..7] PPI_FS1, PPI_FS2 and PPI_CLK. - -config FB_BFIN_LQ035Q1 - tristate "SHARP LQ035Q1DH02 TFT LCD" - depends on FB && BLACKFIN && SPI - select FB_CFB_FILLRECT - select FB_CFB_COPYAREA - select FB_CFB_IMAGEBLIT - select BFIN_GPTIMERS - help - This is the framebuffer device driver for a SHARP LQ035Q1DH02 TFT display found on - the Blackfin Landscape LCD EZ-Extender Card. - This display is a QVGA 320x240 18-bit RGB display interfaced by an 16-bit wide PPI - It uses PPI[0..15] PPI_FS1, PPI_FS2 and PPI_CLK. - - To compile this driver as a module, choose M here: the - module will be called bfin-lq035q1-fb. - -config FB_BF537_LQ035 - tristate "SHARP LQ035 TFT LCD (BF537 STAMP)" - depends on FB && (BF534 || BF536 || BF537) && I2C_BLACKFIN_TWI - select FB_CFB_FILLRECT - select FB_CFB_COPYAREA - select FB_CFB_IMAGEBLIT - select BFIN_GPTIMERS - help - This is the framebuffer device for a SHARP LQ035Q7DB03 TFT LCD - attached to a BF537. - - To compile this driver as a module, choose M here: the - module will be called bf537-lq035. - -config FB_BFIN_7393 - tristate "Blackfin ADV7393 Video encoder" - depends on FB && BLACKFIN - select I2C - select FB_CFB_FILLRECT - select FB_CFB_COPYAREA - select FB_CFB_IMAGEBLIT - help - This is the framebuffer device for a ADV7393 video encoder - attached to a Blackfin on the PPI port. - If your Blackfin board has a ADV7393 select Y. - - To compile this driver as a module, choose M here: the - module will be called bfin_adv7393fb. - -choice - prompt "Video mode support" - depends on FB_BFIN_7393 - default NTSC - -config NTSC - bool 'NTSC 720x480' - -config PAL - bool 'PAL 720x576' - -config NTSC_640x480 - bool 'NTSC 640x480 (Experimental)' - -config PAL_640x480 - bool 'PAL 640x480 (Experimental)' - -config NTSC_YCBCR - bool 'NTSC 720x480 YCbCR input' - -config PAL_YCBCR - bool 'PAL 720x576 YCbCR input' - -endchoice - -choice - prompt "Size of ADV7393 frame buffer memory Single/Double Size" - depends on (FB_BFIN_7393) - default ADV7393_1XMEM - -config ADV7393_1XMEM - bool 'Single' - -config ADV7393_2XMEM - bool 'Double' -endchoice - config FB_STI tristate "HP STI frame buffer device support" depends on FB && PARISC diff --git a/drivers/video/fbdev/Makefile b/drivers/video/fbdev/Makefile index 115961e0721b..55282a21b500 100644 --- a/drivers/video/fbdev/Makefile +++ b/drivers/video/fbdev/Makefile @@ -136,11 +136,6 @@ obj-$(CONFIG_FB_VESA) += vesafb.o obj-$(CONFIG_FB_EFI) += efifb.o obj-$(CONFIG_FB_VGA16) += vga16fb.o obj-$(CONFIG_FB_OF) += offb.o -obj-$(CONFIG_FB_BF537_LQ035) += bf537-lq035.o -obj-$(CONFIG_FB_BF54X_LQ043) += bf54x-lq043fb.o -obj-$(CONFIG_FB_BFIN_LQ035Q1) += bfin-lq035q1-fb.o -obj-$(CONFIG_FB_BFIN_T350MCQB) += bfin-t350mcqb-fb.o -obj-$(CONFIG_FB_BFIN_7393) += bfin_adv7393fb.o obj-$(CONFIG_FB_MX3) += mx3fb.o obj-$(CONFIG_FB_DA8XX) += da8xx-fb.o obj-$(CONFIG_FB_MXS) += mxsfb.o diff --git a/drivers/video/fbdev/bf537-lq035.c b/drivers/video/fbdev/bf537-lq035.c deleted file mode 100644 index ef29fb425122..000000000000 --- a/drivers/video/fbdev/bf537-lq035.c +++ /dev/null @@ -1,891 +0,0 @@ -/* - * Analog Devices Blackfin(BF537 STAMP) + SHARP TFT LCD. - * http://docs.blackfin.uclinux.org/doku.php?id=hw:cards:tft-lcd - * - * Copyright 2006-2010 Analog Devices Inc. - * Licensed under the GPL-2. - */ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/errno.h> -#include <linux/string.h> -#include <linux/mm.h> -#include <linux/delay.h> -#include <linux/fb.h> -#include <linux/ioport.h> -#include <linux/init.h> -#include <linux/types.h> -#include <linux/gpio.h> -#include <linux/interrupt.h> -#include <linux/sched.h> -#include <linux/timer.h> -#include <linux/device.h> -#include <linux/backlight.h> -#include <linux/lcd.h> -#include <linux/i2c.h> -#include <linux/spinlock.h> -#include <linux/dma-mapping.h> -#include <linux/slab.h> -#include <linux/platform_device.h> - -#include <asm/blackfin.h> -#include <asm/irq.h> -#include <asm/dpmc.h> -#include <asm/dma.h> -#include <asm/portmux.h> - -#define NO_BL 1 - -#define MAX_BRIGHENESS 95 -#define MIN_BRIGHENESS 5 -#define NBR_PALETTE 256 - -static const unsigned short ppi_pins[] = { - P_PPI0_CLK, P_PPI0_D0, P_PPI0_D1, P_PPI0_D2, P_PPI0_D3, - P_PPI0_D4, P_PPI0_D5, P_PPI0_D6, P_PPI0_D7, - P_PPI0_D8, P_PPI0_D9, P_PPI0_D10, P_PPI0_D11, - P_PPI0_D12, P_PPI0_D13, P_PPI0_D14, P_PPI0_D15, 0 -}; - -static unsigned char *fb_buffer; /* RGB Buffer */ -static unsigned long *dma_desc_table; -static int t_conf_done, lq035_open_cnt; -static DEFINE_SPINLOCK(bfin_lq035_lock); - -static int landscape; -module_param(landscape, int, 0); -MODULE_PARM_DESC(landscape, - "LANDSCAPE use 320x240 instead of Native 240x320 Resolution"); - -static int bgr; -module_param(bgr, int, 0); -MODULE_PARM_DESC(bgr, - "BGR use 16-bit BGR-565 instead of RGB-565"); - -static int nocursor = 1; -module_param(nocursor, int, 0644); -MODULE_PARM_DESC(nocursor, "cursor enable/disable"); - -static unsigned long current_brightness; /* backlight */ - -/* AD5280 vcomm */ -static unsigned char vcomm_value = 150; -static struct i2c_client *ad5280_client; - -static void set_vcomm(void) -{ - int nr; - - if (!ad5280_client) - return; - - nr = i2c_smbus_write_byte_data(ad5280_client, 0x00, vcomm_value); - if (nr) - pr_err("i2c_smbus_write_byte_data fail: %d\n", nr); -} - -static int ad5280_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int ret; - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE_DATA)) { - dev_err(&client->dev, "SMBUS Byte Data not Supported\n"); - return -EIO; - } - - ret = i2c_smbus_write_byte_data(client, 0x00, vcomm_value); - if (ret) { - dev_err(&client->dev, "write fail: %d\n", ret); - return ret; - } - - ad5280_client = client; - - return 0; -} - -static int ad5280_remove(struct i2c_client *client) -{ - ad5280_client = NULL; - return 0; -} - -static const struct i2c_device_id ad5280_id[] = { - {"bf537-lq035-ad5280", 0}, - {} -}; - -MODULE_DEVICE_TABLE(i2c, ad5280_id); - -static struct i2c_driver ad5280_driver = { - .driver = { - .name = "bf537-lq035-ad5280", - }, - .probe = ad5280_probe, - .remove = ad5280_remove, - .id_table = ad5280_id, -}; - -#ifdef CONFIG_PNAV10 -#define MOD GPIO_PH13 - -#define bfin_write_TIMER_LP_CONFIG bfin_write_TIMER0_CONFIG -#define bfin_write_TIMER_LP_WIDTH bfin_write_TIMER0_WIDTH -#define bfin_write_TIMER_LP_PERIOD bfin_write_TIMER0_PERIOD -#define bfin_read_TIMER_LP_COUNTER bfin_read_TIMER0_COUNTER -#define TIMDIS_LP TIMDIS0 -#define TIMEN_LP TIMEN0 - -#define bfin_write_TIMER_SPS_CONFIG bfin_write_TIMER1_CONFIG -#define bfin_write_TIMER_SPS_WIDTH bfin_write_TIMER1_WIDTH -#define bfin_write_TIMER_SPS_PERIOD bfin_write_TIMER1_PERIOD -#define TIMDIS_SPS TIMDIS1 -#define TIMEN_SPS TIMEN1 - -#define bfin_write_TIMER_SP_CONFIG bfin_write_TIMER5_CONFIG -#define bfin_write_TIMER_SP_WIDTH bfin_write_TIMER5_WIDTH -#define bfin_write_TIMER_SP_PERIOD bfin_write_TIMER5_PERIOD -#define TIMDIS_SP TIMDIS5 -#define TIMEN_SP TIMEN5 - -#define bfin_write_TIMER_PS_CLS_CONFIG bfin_write_TIMER2_CONFIG -#define bfin_write_TIMER_PS_CLS_WIDTH bfin_write_TIMER2_WIDTH -#define bfin_write_TIMER_PS_CLS_PERIOD bfin_write_TIMER2_PERIOD -#define TIMDIS_PS_CLS TIMDIS2 -#define TIMEN_PS_CLS TIMEN2 - -#define bfin_write_TIMER_REV_CONFIG bfin_write_TIMER3_CONFIG -#define bfin_write_TIMER_REV_WIDTH bfin_write_TIMER3_WIDTH -#define bfin_write_TIMER_REV_PERIOD bfin_write_TIMER3_PERIOD -#define TIMDIS_REV TIMDIS3 -#define TIMEN_REV TIMEN3 -#define bfin_read_TIMER_REV_COUNTER bfin_read_TIMER3_COUNTER - -#define FREQ_PPI_CLK (5*1024*1024) /* PPI_CLK 5MHz */ - -#define TIMERS {P_TMR0, P_TMR1, P_TMR2, P_TMR3, P_TMR5, 0} - -#else - -#define UD GPIO_PF13 /* Up / Down */ -#define MOD GPIO_PF10 -#define LBR GPIO_PF14 /* Left Right */ - -#define bfin_write_TIMER_LP_CONFIG bfin_write_TIMER6_CONFIG -#define bfin_write_TIMER_LP_WIDTH bfin_write_TIMER6_WIDTH -#define bfin_write_TIMER_LP_PERIOD bfin_write_TIMER6_PERIOD -#define bfin_read_TIMER_LP_COUNTER bfin_read_TIMER6_COUNTER -#define TIMDIS_LP TIMDIS6 -#define TIMEN_LP TIMEN6 - -#define bfin_write_TIMER_SPS_CONFIG bfin_write_TIMER1_CONFIG -#define bfin_write_TIMER_SPS_WIDTH bfin_write_TIMER1_WIDTH -#define bfin_write_TIMER_SPS_PERIOD bfin_write_TIMER1_PERIOD -#define TIMDIS_SPS TIMDIS1 -#define TIMEN_SPS TIMEN1 - -#define bfin_write_TIMER_SP_CONFIG bfin_write_TIMER0_CONFIG -#define bfin_write_TIMER_SP_WIDTH bfin_write_TIMER0_WIDTH -#define bfin_write_TIMER_SP_PERIOD bfin_write_TIMER0_PERIOD -#define TIMDIS_SP TIMDIS0 -#define TIMEN_SP TIMEN0 - -#define bfin_write_TIMER_PS_CLS_CONFIG bfin_write_TIMER7_CONFIG -#define bfin_write_TIMER_PS_CLS_WIDTH bfin_write_TIMER7_WIDTH -#define bfin_write_TIMER_PS_CLS_PERIOD bfin_write_TIMER7_PERIOD -#define TIMDIS_PS_CLS TIMDIS7 -#define TIMEN_PS_CLS TIMEN7 - -#define bfin_write_TIMER_REV_CONFIG bfin_write_TIMER5_CONFIG -#define bfin_write_TIMER_REV_WIDTH bfin_write_TIMER5_WIDTH -#define bfin_write_TIMER_REV_PERIOD bfin_write_TIMER5_PERIOD -#define TIMDIS_REV TIMDIS5 -#define TIMEN_REV TIMEN5 -#define bfin_read_TIMER_REV_COUNTER bfin_read_TIMER5_COUNTER - -#define FREQ_PPI_CLK (6*1000*1000) /* PPI_CLK 6MHz */ -#define TIMERS {P_TMR0, P_TMR1, P_TMR5, P_TMR6, P_TMR7, 0} - -#endif - -#define LCD_X_RES 240 /* Horizontal Resolution */ -#define LCD_Y_RES 320 /* Vertical Resolution */ - -#define LCD_BBP 16 /* Bit Per Pixel */ - -/* the LCD and the DMA start counting differently; - * since one starts at 0 and the other starts at 1, - * we have a difference of 1 between START_LINES - * and U_LINES. - */ -#define START_LINES 8 /* lines for field flyback or field blanking signal */ -#define U_LINES 9 /* number of undisplayed blanking lines */ - -#define FRAMES_PER_SEC (60) - -#define DCLKS_PER_FRAME (FREQ_PPI_CLK/FRAMES_PER_SEC) -#define DCLKS_PER_LINE (DCLKS_PER_FRAME/(LCD_Y_RES+U_LINES)) - -#define PPI_CONFIG_VALUE (PORT_DIR|XFR_TYPE|DLEN_16|POLS) -#define PPI_DELAY_VALUE (0) -#define TIMER_CONFIG (PWM_OUT|PERIOD_CNT|TIN_SEL|CLK_SEL) - -#define ACTIVE_VIDEO_MEM_OFFSET (LCD_X_RES*START_LINES*(LCD_BBP/8)) -#define ACTIVE_VIDEO_MEM_SIZE (LCD_Y_RES*LCD_X_RES*(LCD_BBP/8)) -#define TOTAL_VIDEO_MEM_SIZE ((LCD_Y_RES+U_LINES)*LCD_X_RES*(LCD_BBP/8)) -#define TOTAL_DMA_DESC_SIZE (2 * sizeof(u32) * (LCD_Y_RES + U_LINES)) - -static void start_timers(void) /* CHECK with HW */ -{ - unsigned long flags; - - local_irq_save(flags); - - bfin_write_TIMER_ENABLE(TIMEN_REV); - SSYNC(); - - while (bfin_read_TIMER_REV_COUNTER() <= 11) - continue; - bfin_write_TIMER_ENABLE(TIMEN_LP); - SSYNC(); - - while (bfin_read_TIMER_LP_COUNTER() < 3) - continue; - bfin_write_TIMER_ENABLE(TIMEN_SP|TIMEN_SPS|TIMEN_PS_CLS); - SSYNC(); - t_conf_done = 1; - local_irq_restore(flags); -} - -static void config_timers(void) -{ - /* Stop timers */ - bfin_write_TIMER_DISABLE(TIMDIS_SP|TIMDIS_SPS|TIMDIS_REV| - TIMDIS_LP|TIMDIS_PS_CLS); - SSYNC(); - - /* LP, timer 6 */ - bfin_write_TIMER_LP_CONFIG(TIMER_CONFIG|PULSE_HI); - bfin_write_TIMER_LP_WIDTH(1); - - bfin_write_TIMER_LP_PERIOD(DCLKS_PER_LINE); - SSYNC(); - - /* SPS, timer 1 */ - bfin_write_TIMER_SPS_CONFIG(TIMER_CONFIG|PULSE_HI); - bfin_write_TIMER_SPS_WIDTH(DCLKS_PER_LINE*2); - bfin_write_TIMER_SPS_PERIOD((DCLKS_PER_LINE * (LCD_Y_RES+U_LINES))); - SSYNC(); - - /* SP, timer 0 */ - bfin_write_TIMER_SP_CONFIG(TIMER_CONFIG|PULSE_HI); - bfin_write_TIMER_SP_WIDTH(1); - bfin_write_TIMER_SP_PERIOD(DCLKS_PER_LINE); - SSYNC(); - - /* PS & CLS, timer 7 */ - bfin_write_TIMER_PS_CLS_CONFIG(TIMER_CONFIG); - bfin_write_TIMER_PS_CLS_WIDTH(LCD_X_RES + START_LINES); - bfin_write_TIMER_PS_CLS_PERIOD(DCLKS_PER_LINE); - - SSYNC(); - -#ifdef NO_BL - /* REV, timer 5 */ - bfin_write_TIMER_REV_CONFIG(TIMER_CONFIG|PULSE_HI); - - bfin_write_TIMER_REV_WIDTH(DCLKS_PER_LINE); - bfin_write_TIMER_REV_PERIOD(DCLKS_PER_LINE*2); - - SSYNC(); -#endif -} - -static void config_ppi(void) -{ - bfin_write_PPI_DELAY(PPI_DELAY_VALUE); - bfin_write_PPI_COUNT(LCD_X_RES-1); - /* 0x10 -> PORT_CFG -> 2 or 3 frame syncs */ - bfin_write_PPI_CONTROL((PPI_CONFIG_VALUE|0x10) & (~POLS)); -} - -static int config_dma(void) -{ - u32 i; - - if (landscape) { - - for (i = 0; i < U_LINES; ++i) { - /* blanking lines point to first line of fb_buffer */ - dma_desc_table[2*i] = (unsigned long)&dma_desc_table[2*i+2]; - dma_desc_table[2*i+1] = (unsigned long)fb_buffer; - } - - for (i = U_LINES; i < U_LINES + LCD_Y_RES; ++i) { - /* visible lines */ - dma_desc_table[2*i] = (unsigned long)&dma_desc_table[2*i+2]; - dma_desc_table[2*i+1] = (unsigned long)fb_buffer + - (LCD_Y_RES+U_LINES-1-i)*2; - } - - /* last descriptor points to first */ - dma_desc_table[2*(LCD_Y_RES+U_LINES-1)] = (unsigned long)&dma_desc_table[0]; - - set_dma_x_count(CH_PPI, LCD_X_RES); - set_dma_x_modify(CH_PPI, LCD_Y_RES * (LCD_BBP / 8)); - set_dma_y_count(CH_PPI, 0); - set_dma_y_modify(CH_PPI, 0); - set_dma_next_desc_addr(CH_PPI, (void *)dma_desc_table[0]); - set_dma_config(CH_PPI, DMAFLOW_LARGE | NDSIZE_4 | WDSIZE_16); - - } else { - - set_dma_config(CH_PPI, set_bfin_dma_config(DIR_READ, - DMA_FLOW_AUTO, - INTR_DISABLE, - DIMENSION_2D, - DATA_SIZE_16, - DMA_NOSYNC_KEEP_DMA_BUF)); - set_dma_x_count(CH_PPI, LCD_X_RES); - set_dma_x_modify(CH_PPI, LCD_BBP / 8); - set_dma_y_count(CH_PPI, LCD_Y_RES+U_LINES); - set_dma_y_modify(CH_PPI, LCD_BBP / 8); - set_dma_start_addr(CH_PPI, (unsigned long) fb_buffer); - } - - return 0; -} - -static int request_ports(void) -{ - u16 tmr_req[] = TIMERS; - - /* - UD: PF13 - MOD: PF10 - LBR: PF14 - PPI_CLK: PF15 - */ - - if (peripheral_request_list(ppi_pins, KBUILD_MODNAME)) { - pr_err("requesting PPI peripheral failed\n"); - return -EBUSY; - } - - if (peripheral_request_list(tmr_req, KBUILD_MODNAME)) { - peripheral_free_list(ppi_pins); - pr_err("requesting timer peripheral failed\n"); - return -EBUSY; - } - -#if (defined(UD) && defined(LBR)) - if (gpio_request_one(UD, GPIOF_OUT_INIT_LOW, KBUILD_MODNAME)) { - pr_err("requesting GPIO %d failed\n", UD); - return -EBUSY; - } - - if (gpio_request_one(LBR, GPIOF_OUT_INIT_HIGH, KBUILD_MODNAME)) { - pr_err("requesting GPIO %d failed\n", LBR); - gpio_free(UD); - return -EBUSY; - } -#endif - - if (gpio_request_one(MOD, GPIOF_OUT_INIT_HIGH, KBUILD_MODNAME)) { - pr_err("requesting GPIO %d failed\n", MOD); -#if (defined(UD) && defined(LBR)) - gpio_free(LBR); - gpio_free(UD); -#endif - return -EBUSY; - } - - SSYNC(); - return 0; -} - -static void free_ports(void) -{ - u16 tmr_req[] = TIMERS; - - peripheral_free_list(ppi_pins); - peripheral_free_list(tmr_req); - -#if defined(UD) && defined(LBR) - gpio_free(LBR); - gpio_free(UD); -#endif - gpio_free(MOD); -} - -static struct fb_info bfin_lq035_fb; - -static struct fb_var_screeninfo bfin_lq035_fb_defined = { - .bits_per_pixel = LCD_BBP, - .activate = FB_ACTIVATE_TEST, - .xres = LCD_X_RES, /*default portrait mode RGB*/ - .yres = LCD_Y_RES, - .xres_virtual = LCD_X_RES, - .yres_virtual = LCD_Y_RES, - .height = -1, - .width = -1, - .left_margin = 0, - .right_margin = 0, - .upper_margin = 0, - .lower_margin = 0, - .red = {11, 5, 0}, - .green = {5, 6, 0}, - .blue = {0, 5, 0}, - .transp = {0, 0, 0}, -}; - -static struct fb_fix_screeninfo bfin_lq035_fb_fix = { - .id = KBUILD_MODNAME, - .smem_len = ACTIVE_VIDEO_MEM_SIZE, - .type = FB_TYPE_PACKED_PIXELS, - .visual = FB_VISUAL_TRUECOLOR, - .xpanstep = 0, - .ypanstep = 0, - .line_length = LCD_X_RES*(LCD_BBP/8), - .accel = FB_ACCEL_NONE, -}; - - -static int bfin_lq035_fb_open(struct fb_info *info, int user) -{ - unsigned long flags; - - spin_lock_irqsave(&bfin_lq035_lock, flags); - lq035_open_cnt++; - spin_unlock_irqrestore(&bfin_lq035_lock, flags); - - if (lq035_open_cnt <= 1) { - bfin_write_PPI_CONTROL(0); - SSYNC(); - - set_vcomm(); - config_dma(); - config_ppi(); - - /* start dma */ - enable_dma(CH_PPI); - SSYNC(); - bfin_write_PPI_CONTROL(bfin_read_PPI_CONTROL() | PORT_EN); - SSYNC(); - - if (!t_conf_done) { - config_timers(); - start_timers(); - } - /* gpio_set_value(MOD,1); */ - } - - return 0; -} - -static int bfin_lq035_fb_release(struct fb_info *info, int user) -{ - unsigned long flags; - - spin_lock_irqsave(&bfin_lq035_lock, flags); - lq035_open_cnt--; - spin_unlock_irqrestore(&bfin_lq035_lock, flags); - - - if (lq035_open_cnt <= 0) { - - bfin_write_PPI_CONTROL(0); - SSYNC(); - - disable_dma(CH_PPI); - } - - return 0; -} - - -static int bfin_lq035_fb_check_var(struct fb_var_screeninfo *var, |