From 100e74a150d3a31d4c12658c926429ceb880d2f7 Mon Sep 17 00:00:00 2001 From: Florian Tobias Schandinat Date: Sat, 17 Apr 2010 19:44:53 +0000 Subject: viafb: move some modesetting functions to a seperate file viafb: move some modesetting functions to a seperate file This patch moves the modesetting functions which are already cleaned up to a seperate file. Just the beginning to bring some structure in this mess. Signed-off-by: Florian Tobias Schandinat --- drivers/video/via/via_modesetting.c | 126 ++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 drivers/video/via/via_modesetting.c (limited to 'drivers/video/via/via_modesetting.c') diff --git a/drivers/video/via/via_modesetting.c b/drivers/video/via/via_modesetting.c new file mode 100644 index 00000000000..69ff2857500 --- /dev/null +++ b/drivers/video/via/via_modesetting.c @@ -0,0 +1,126 @@ +/* + * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. + * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. + * Copyright 2010 Florian Tobias Schandinat + * + * 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, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; 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. + */ +/* + * basic modesetting functions + */ + +#include +#include "via_modesetting.h" +#include "via_io.h" +#include "share.h" +#include "debug.h" + +void via_set_primary_address(u32 addr) +{ + DEBUG_MSG(KERN_DEBUG "via_set_primary_address(0x%08X)\n", addr); + via_write_reg(VIACR, 0x0D, addr & 0xFF); + via_write_reg(VIACR, 0x0C, (addr >> 8) & 0xFF); + via_write_reg(VIACR, 0x34, (addr >> 16) & 0xFF); + via_write_reg_mask(VIACR, 0x48, (addr >> 24) & 0x1F, 0x1F); +} + +void via_set_secondary_address(u32 addr) +{ + DEBUG_MSG(KERN_DEBUG "via_set_secondary_address(0x%08X)\n", addr); + /* secondary display supports only quadword aligned memory */ + via_write_reg_mask(VIACR, 0x62, (addr >> 2) & 0xFE, 0xFE); + via_write_reg(VIACR, 0x63, (addr >> 10) & 0xFF); + via_write_reg(VIACR, 0x64, (addr >> 18) & 0xFF); + via_write_reg_mask(VIACR, 0xA3, (addr >> 26) & 0x07, 0x07); +} + +void via_set_primary_pitch(u32 pitch) +{ + DEBUG_MSG(KERN_DEBUG "via_set_primary_pitch(0x%08X)\n", pitch); + /* spec does not say that first adapter skips 3 bits but old + * code did it and seems to be reasonable in analogy to 2nd adapter + */ + pitch = pitch >> 3; + via_write_reg(VIACR, 0x13, pitch & 0xFF); + via_write_reg_mask(VIACR, 0x35, (pitch >> (8 - 5)) & 0xE0, 0xE0); +} + +void via_set_secondary_pitch(u32 pitch) +{ + DEBUG_MSG(KERN_DEBUG "via_set_secondary_pitch(0x%08X)\n", pitch); + pitch = pitch >> 3; + via_write_reg(VIACR, 0x66, pitch & 0xFF); + via_write_reg_mask(VIACR, 0x67, (pitch >> 8) & 0x03, 0x03); + via_write_reg_mask(VIACR, 0x71, (pitch >> (10 - 7)) & 0x80, 0x80); +} + +void via_set_primary_color_depth(u8 depth) +{ + u8 value; + + DEBUG_MSG(KERN_DEBUG "via_set_primary_color_depth(%d)\n", depth); + switch (depth) { + case 8: + value = 0x00; + break; + case 15: + value = 0x04; + break; + case 16: + value = 0x14; + break; + case 24: + value = 0x0C; + break; + case 30: + value = 0x08; + break; + default: + printk(KERN_WARNING "via_set_primary_color_depth: " + "Unsupported depth: %d\n", depth); + return; + } + + via_write_reg_mask(VIASR, 0x15, value, 0x1C); +} + +void via_set_secondary_color_depth(u8 depth) +{ + u8 value; + + DEBUG_MSG(KERN_DEBUG "via_set_secondary_color_depth(%d)\n", depth); + switch (depth) { + case 8: + value = 0x00; + break; + case 16: + value = 0x40; + break; + case 24: + value = 0xC0; + break; + case 30: + value = 0x80; + break; + default: + printk(KERN_WARNING "via_set_secondary_color_depth: " + "Unsupported depth: %d\n", depth); + return; + } + + via_write_reg_mask(VIACR, 0x67, value, 0xC0); +} -- cgit v1.2.3-70-g09d2 From 64a6bd6a570c53f1955eaedf3952dcbe9b62da1d Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Wed, 5 May 2010 13:42:49 -0600 Subject: viafb: fold via_io.h into via-core.h Preparatory move toward the ultimate goal of moving pan-subdevice stuff into include/linux. Cc: ScottFang@viatech.com.cn Cc: JosephChan@via.com.tw Cc: Harald Welte Acked-by: Florian Tobias Schandinat Signed-off-by: Jonathan Corbet --- drivers/video/via/hw.h | 1 - drivers/video/via/share.h | 11 ++---- drivers/video/via/via-core.h | 48 +++++++++++++++++++++++++- drivers/video/via/via_io.h | 67 ------------------------------------- drivers/video/via/via_modesetting.c | 2 +- drivers/video/via/via_utility.c | 1 + drivers/video/via/viamode.c | 1 + 7 files changed, 53 insertions(+), 78 deletions(-) delete mode 100644 drivers/video/via/via_io.h (limited to 'drivers/video/via/via_modesetting.c') diff --git a/drivers/video/via/hw.h b/drivers/video/via/hw.h index a58701f3bf7..a109de37981 100644 --- a/drivers/video/via/hw.h +++ b/drivers/video/via/hw.h @@ -24,7 +24,6 @@ #include "viamode.h" #include "global.h" -#include "via_io.h" #include "via_modesetting.h" #define viafb_read_reg(p, i) via_read_reg(p, i) diff --git a/drivers/video/via/share.h b/drivers/video/via/share.h index 861b4142efa..7f0de7f006a 100644 --- a/drivers/video/via/share.h +++ b/drivers/video/via/share.h @@ -43,14 +43,9 @@ /* Video Memory Size */ #define VIDEO_MEMORY_SIZE_16M 0x1000000 -/* standard VGA IO port -*/ -#define VIAStatus 0x3DA -#define VIACR 0x3D4 -#define VIASR 0x3C4 -#define VIAGR 0x3CE -#define VIAAR 0x3C0 - +/* + * Lengths of the VPIT structure arrays. + */ #define StdCR 0x19 #define StdSR 0x04 #define StdGR 0x09 diff --git a/drivers/video/via/via-core.h b/drivers/video/via/via-core.h index 087c562abae..7ffb521e1a7 100644 --- a/drivers/video/via/via-core.h +++ b/drivers/video/via/via-core.h @@ -1,7 +1,8 @@ /* * Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved. * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. - * Copyright 2009 Jonathan Corbet + * Copyright 2009-2010 Jonathan Corbet + * Copyright 2010 Florian Tobias Schandinat * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -22,6 +23,8 @@ #ifndef __VIA_CORE_H__ #define __VIA_CORE_H__ +#include +#include #include #include @@ -170,4 +173,47 @@ int viafb_dma_copy_out_sg(unsigned int offset, struct scatterlist *sg, int nsg); #define VGA_WIDTH 640 #define VGA_HEIGHT 480 +/* + * Indexed port operations. Note that these are all multi-op + * functions; every invocation will be racy if you're not holding + * reg_lock. + */ + +#define VIAStatus 0x3DA /* Non-indexed port */ +#define VIACR 0x3D4 +#define VIASR 0x3C4 +#define VIAGR 0x3CE +#define VIAAR 0x3C0 + +static inline u8 via_read_reg(u16 port, u8 index) +{ + outb(index, port); + return inb(port + 1); +} + +static inline void via_write_reg(u16 port, u8 index, u8 data) +{ + outb(index, port); + outb(data, port + 1); +} + +static inline void via_write_reg_mask(u16 port, u8 index, u8 data, u8 mask) +{ + u8 old; + + outb(index, port); + old = inb(port + 1); + outb((data & mask) | (old & ~mask), port + 1); +} + +#define VIA_MISC_REG_READ 0x03CC +#define VIA_MISC_REG_WRITE 0x03C2 + +static inline void via_write_misc_reg_mask(u8 data, u8 mask) +{ + u8 old = inb(VIA_MISC_REG_READ); + outb((data & mask) | (old & ~mask), VIA_MISC_REG_WRITE); +} + + #endif /* __VIA_CORE_H__ */ diff --git a/drivers/video/via/via_io.h b/drivers/video/via/via_io.h deleted file mode 100644 index a3d2aca6554..00000000000 --- a/drivers/video/via/via_io.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. - * Copyright 2010 Florian Tobias Schandinat - * - * 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, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; 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. - */ -/* - * basic io functions - */ - -#ifndef __VIA_IO_H__ -#define __VIA_IO_H__ - -#include -#include - -#define VIA_MISC_REG_READ 0x03CC -#define VIA_MISC_REG_WRITE 0x03C2 - -/* - * Indexed port operations. Note that these are all multi-op - * functions; every invocation will be racy if you're not holding - * reg_lock. - */ -static inline u8 via_read_reg(u16 port, u8 index) -{ - outb(index, port); - return inb(port + 1); -} - -static inline void via_write_reg(u16 port, u8 index, u8 data) -{ - outb(index, port); - outb(data, port + 1); -} - -static inline void via_write_reg_mask(u16 port, u8 index, u8 data, u8 mask) -{ - u8 old; - - outb(index, port); - old = inb(port + 1); - outb((data & mask) | (old & ~mask), port + 1); -} - -static inline void via_write_misc_reg_mask(u8 data, u8 mask) -{ - u8 old = inb(VIA_MISC_REG_READ); - outb((data & mask) | (old & ~mask), VIA_MISC_REG_WRITE); -} - -#endif /* __VIA_IO_H__ */ diff --git a/drivers/video/via/via_modesetting.c b/drivers/video/via/via_modesetting.c index 69ff2857500..b4e735cc350 100644 --- a/drivers/video/via/via_modesetting.c +++ b/drivers/video/via/via_modesetting.c @@ -25,7 +25,7 @@ #include #include "via_modesetting.h" -#include "via_io.h" +#include "via-core.h" #include "share.h" #include "debug.h" diff --git a/drivers/video/via/via_utility.c b/drivers/video/via/via_utility.c index aefdeeec89b..57570314186 100644 --- a/drivers/video/via/via_utility.c +++ b/drivers/video/via/via_utility.c @@ -19,6 +19,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "via-core.h" #include "global.h" void viafb_get_device_support_state(u32 *support_state) diff --git a/drivers/video/via/viamode.c b/drivers/video/via/viamode.c index 6f3bcda8cb4..2fdb9e6724a 100644 --- a/drivers/video/via/viamode.c +++ b/drivers/video/via/viamode.c @@ -19,6 +19,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "via-core.h" #include "global.h" struct res_map_refresh res_map_refresh_tbl[] = { /*hres, vres, vclock, vmode_refresh*/ -- cgit v1.2.3-70-g09d2 From ec66841e495b9ab4f92bdf91efe8cf56e1471fbd Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Wed, 5 May 2010 14:44:55 -0600 Subject: viafb: move some include files to include/linux These are the files which should be available to subdevices compiled outside of drivers/video/via. Cc: ScottFang@viatech.com.cn Cc: JosephChan@via.com.tw Cc: Harald Welte Acked-by: Florian Tobias Schandinat Signed-off-by: Jonathan Corbet --- drivers/video/via/accel.c | 2 +- drivers/video/via/dvi.c | 4 +- drivers/video/via/hw.c | 3 +- drivers/video/via/lcd.c | 4 +- drivers/video/via/via-core.c | 6 +- drivers/video/via/via-core.h | 219 ------------------------------------ drivers/video/via/via-gpio.c | 4 +- drivers/video/via/via-gpio.h | 14 --- drivers/video/via/via_i2c.c | 4 +- drivers/video/via/via_i2c.h | 42 ------- drivers/video/via/via_modesetting.c | 2 +- drivers/video/via/via_utility.c | 2 +- drivers/video/via/viafbdev.c | 4 +- drivers/video/via/viamode.c | 2 +- drivers/video/via/vt1636.c | 4 +- include/linux/via-core.h | 219 ++++++++++++++++++++++++++++++++++++ include/linux/via-gpio.h | 14 +++ include/linux/via_i2c.h | 42 +++++++ 18 files changed, 296 insertions(+), 295 deletions(-) delete mode 100644 drivers/video/via/via-core.h delete mode 100644 drivers/video/via/via-gpio.h delete mode 100644 drivers/video/via/via_i2c.h create mode 100644 include/linux/via-core.h create mode 100644 include/linux/via-gpio.h create mode 100644 include/linux/via_i2c.h (limited to 'drivers/video/via/via_modesetting.c') diff --git a/drivers/video/via/accel.c b/drivers/video/via/accel.c index 189aba41f9b..e44893ea590 100644 --- a/drivers/video/via/accel.c +++ b/drivers/video/via/accel.c @@ -18,7 +18,7 @@ * Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "via-core.h" +#include #include "global.h" /* diff --git a/drivers/video/via/dvi.c b/drivers/video/via/dvi.c index 6271b769632..39b040bb381 100644 --- a/drivers/video/via/dvi.c +++ b/drivers/video/via/dvi.c @@ -18,8 +18,8 @@ * Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "via-core.h" -#include "via_i2c.h" +#include +#include #include "global.h" static void tmds_register_write(int index, u8 data); diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c index e356fe8d8a9..b996803ae2c 100644 --- a/drivers/video/via/hw.c +++ b/drivers/video/via/hw.c @@ -18,7 +18,8 @@ * Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "via-core.h" + +#include #include "global.h" static struct pll_map pll_value[] = { diff --git a/drivers/video/via/lcd.c b/drivers/video/via/lcd.c index 04eec31aa9a..2ab0f156439 100644 --- a/drivers/video/via/lcd.c +++ b/drivers/video/via/lcd.c @@ -18,8 +18,8 @@ * Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "via-core.h" -#include "via_i2c.h" +#include +#include #include "global.h" #include "lcdtbl.h" diff --git a/drivers/video/via/via-core.c b/drivers/video/via/via-core.c index 188c0022dcb..e8cfe839211 100644 --- a/drivers/video/via/via-core.c +++ b/drivers/video/via/via-core.c @@ -7,9 +7,9 @@ /* * Core code for the Via multifunction framebuffer device. */ -#include "via-core.h" -#include "via_i2c.h" -#include "via-gpio.h" +#include +#include +#include #include "global.h" #include diff --git a/drivers/video/via/via-core.h b/drivers/video/via/via-core.h deleted file mode 100644 index 7ffb521e1a7..00000000000 --- a/drivers/video/via/via-core.h +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. - * Copyright 2009-2010 Jonathan Corbet - * Copyright 2010 Florian Tobias Schandinat - * - * 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, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; 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 __VIA_CORE_H__ -#define __VIA_CORE_H__ -#include -#include -#include -#include - -/* - * A description of each known serial I2C/GPIO port. - */ -enum via_port_type { - VIA_PORT_NONE = 0, - VIA_PORT_I2C, - VIA_PORT_GPIO, -}; - -enum via_port_mode { - VIA_MODE_OFF = 0, - VIA_MODE_I2C, /* Used as I2C port */ - VIA_MODE_GPIO, /* Two GPIO ports */ -}; - -enum viafb_i2c_adap { - VIA_PORT_26 = 0, - VIA_PORT_31, - VIA_PORT_25, - VIA_PORT_2C, - VIA_PORT_3D, -}; -#define VIAFB_NUM_PORTS 5 - -struct via_port_cfg { - enum via_port_type type; - enum via_port_mode mode; - u16 io_port; - u8 ioport_index; -}; - -/* - * This is the global viafb "device" containing stuff needed by - * all subdevs. - */ -struct viafb_dev { - struct pci_dev *pdev; - int chip_type; - struct via_port_cfg *port_cfg; - /* - * Spinlock for access to device registers. Not yet - * globally used. - */ - spinlock_t reg_lock; - /* - * The framebuffer MMIO region. Little, if anything, touches - * this memory directly, and certainly nothing outside of the - * framebuffer device itself. We *do* have to be able to allocate - * chunks of this memory for other devices, though. - */ - unsigned long fbmem_start; - long fbmem_len; - void __iomem *fbmem; -#if defined(CONFIG_FB_VIA_CAMERA) || defined(CONFIG_FB_VIA_CAMERA_MODULE) - long camera_fbmem_offset; - long camera_fbmem_size; -#endif - /* - * The MMIO region for device registers. - */ - unsigned long engine_start; - unsigned long engine_len; - void __iomem *engine_mmio; - -}; - -/* - * Interrupt management. - */ - -void viafb_irq_enable(u32 mask); -void viafb_irq_disable(u32 mask); - -/* - * The global interrupt control register and its bits. - */ -#define VDE_INTERRUPT 0x200 /* Video interrupt flags/masks */ -#define VDE_I_DVISENSE 0x00000001 /* DVI sense int status */ -#define VDE_I_VBLANK 0x00000002 /* Vertical blank status */ -#define VDE_I_MCCFI 0x00000004 /* MCE compl. frame int status */ -#define VDE_I_VSYNC 0x00000008 /* VGA VSYNC int status */ -#define VDE_I_DMA0DDONE 0x00000010 /* DMA 0 descr done */ -#define VDE_I_DMA0TDONE 0x00000020 /* DMA 0 transfer done */ -#define VDE_I_DMA1DDONE 0x00000040 /* DMA 1 descr done */ -#define VDE_I_DMA1TDONE 0x00000080 /* DMA 1 transfer done */ -#define VDE_I_C1AV 0x00000100 /* Cap Eng 1 act vid end */ -#define VDE_I_HQV0 0x00000200 /* First HQV engine */ -#define VDE_I_HQV1 0x00000400 /* Second HQV engine */ -#define VDE_I_HQV1EN 0x00000800 /* Second HQV engine enable */ -#define VDE_I_C0AV 0x00001000 /* Cap Eng 0 act vid end */ -#define VDE_I_C0VBI 0x00002000 /* Cap Eng 0 VBI end */ -#define VDE_I_C1VBI 0x00004000 /* Cap Eng 1 VBI end */ -#define VDE_I_VSYNC2 0x00008000 /* Sec. Disp. VSYNC */ -#define VDE_I_DVISNSEN 0x00010000 /* DVI sense enable */ -#define VDE_I_VSYNC2EN 0x00020000 /* Sec Disp VSYNC enable */ -#define VDE_I_MCCFIEN 0x00040000 /* MC comp frame int mask enable */ -#define VDE_I_VSYNCEN 0x00080000 /* VSYNC enable */ -#define VDE_I_DMA0DDEN 0x00100000 /* DMA 0 descr done enable */ -#define VDE_I_DMA0TDEN 0x00200000 /* DMA 0 trans done enable */ -#define VDE_I_DMA1DDEN 0x00400000 /* DMA 1 descr done enable */ -#define VDE_I_DMA1TDEN 0x00800000 /* DMA 1 trans done enable */ -#define VDE_I_C1AVEN 0x01000000 /* cap 1 act vid end enable */ -#define VDE_I_HQV0EN 0x02000000 /* First hqv engine enable */ -#define VDE_I_C1VBIEN 0x04000000 /* Cap 1 VBI end enable */ -#define VDE_I_LVDSSI 0x08000000 /* LVDS sense interrupt */ -#define VDE_I_C0AVEN 0x10000000 /* Cap 0 act vid end enable */ -#define VDE_I_C0VBIEN 0x20000000 /* Cap 0 VBI end enable */ -#define VDE_I_LVDSSIEN 0x40000000 /* LVDS Sense enable */ -#define VDE_I_ENABLE 0x80000000 /* Global interrupt enable */ - -/* - * DMA management. - */ -int viafb_request_dma(void); -void viafb_release_dma(void); -/* void viafb_dma_copy_out(unsigned int offset, dma_addr_t paddr, int len); */ -int viafb_dma_copy_out_sg(unsigned int offset, struct scatterlist *sg, int nsg); - -/* - * DMA Controller registers. - */ -#define VDMA_MR0 0xe00 /* Mod reg 0 */ -#define VDMA_MR_CHAIN 0x01 /* Chaining mode */ -#define VDMA_MR_TDIE 0x02 /* Transfer done int enable */ -#define VDMA_CSR0 0xe04 /* Control/status */ -#define VDMA_C_ENABLE 0x01 /* DMA Enable */ -#define VDMA_C_START 0x02 /* Start a transfer */ -#define VDMA_C_ABORT 0x04 /* Abort a transfer */ -#define VDMA_C_DONE 0x08 /* Transfer is done */ -#define VDMA_MARL0 0xe20 /* Mem addr low */ -#define VDMA_MARH0 0xe24 /* Mem addr high */ -#define VDMA_DAR0 0xe28 /* Device address */ -#define VDMA_DQWCR0 0xe2c /* Count (16-byte) */ -#define VDMA_TMR0 0xe30 /* Tile mode reg */ -#define VDMA_DPRL0 0xe34 /* Not sure */ -#define VDMA_DPR_IN 0x08 /* Inbound transfer to FB */ -#define VDMA_DPRH0 0xe38 -#define VDMA_PMR0 (0xe00 + 0x134) /* Pitch mode */ - -/* - * Useful stuff that probably belongs somewhere global. - */ -#define VGA_WIDTH 640 -#define VGA_HEIGHT 480 - -/* - * Indexed port operations. Note that these are all multi-op - * functions; every invocation will be racy if you're not holding - * reg_lock. - */ - -#define VIAStatus 0x3DA /* Non-indexed port */ -#define VIACR 0x3D4 -#define VIASR 0x3C4 -#define VIAGR 0x3CE -#define VIAAR 0x3C0 - -static inline u8 via_read_reg(u16 port, u8 index) -{ - outb(index, port); - return inb(port + 1); -} - -static inline void via_write_reg(u16 port, u8 index, u8 data) -{ - outb(index, port); - outb(data, port + 1); -} - -static inline void via_write_reg_mask(u16 port, u8 index, u8 data, u8 mask) -{ - u8 old; - - outb(index, port); - old = inb(port + 1); - outb((data & mask) | (old & ~mask), port + 1); -} - -#define VIA_MISC_REG_READ 0x03CC -#define VIA_MISC_REG_WRITE 0x03C2 - -static inline void via_write_misc_reg_mask(u8 data, u8 mask) -{ - u8 old = inb(VIA_MISC_REG_READ); - outb((data & mask) | (old & ~mask), VIA_MISC_REG_WRITE); -} - - -#endif /* __VIA_CORE_H__ */ diff --git a/drivers/video/via/via-gpio.c b/drivers/video/via/via-gpio.c index 67d699cbfd2..595516aea69 100644 --- a/drivers/video/via/via-gpio.c +++ b/drivers/video/via/via-gpio.c @@ -8,8 +8,8 @@ #include #include #include -#include "via-core.h" -#include "via-gpio.h" +#include +#include /* * The ports we know about. Note that the port-25 gpios are not diff --git a/drivers/video/via/via-gpio.h b/drivers/video/via/via-gpio.h deleted file mode 100644 index 8281aea3dd6..00000000000 --- a/drivers/video/via/via-gpio.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Support for viafb GPIO ports. - * - * Copyright 2009 Jonathan Corbet - * Distributable under version 2 of the GNU General Public License. - */ - -#ifndef __VIA_GPIO_H__ -#define __VIA_GPIO_H__ - -extern int viafb_gpio_lookup(const char *name); -extern int viafb_gpio_init(void); -extern void viafb_gpio_exit(void); -#endif diff --git a/drivers/video/via/via_i2c.c b/drivers/video/via/via_i2c.c index 2291765f2f8..da9e4ca94b1 100644 --- a/drivers/video/via/via_i2c.c +++ b/drivers/video/via/via_i2c.c @@ -23,8 +23,8 @@ #include #include #include -#include "via-core.h" -#include "via_i2c.h" +#include +#include /* * There can only be one set of these, so there's no point in having diff --git a/drivers/video/via/via_i2c.h b/drivers/video/via/via_i2c.h deleted file mode 100644 index 44532e468c0..00000000000 --- a/drivers/video/via/via_i2c.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. - - * 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, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; 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 __VIA_I2C_H__ -#define __VIA_I2C_H__ - -#include -#include - -struct via_i2c_stuff { - u16 i2c_port; /* GPIO or I2C port */ - u16 is_active; /* Being used as I2C? */ - struct i2c_adapter adapter; - struct i2c_algo_bit_data algo; -}; - - -int viafb_i2c_readbyte(u8 adap, u8 slave_addr, u8 index, u8 *pdata); -int viafb_i2c_writebyte(u8 adap, u8 slave_addr, u8 index, u8 data); -int viafb_i2c_readbytes(u8 adap, u8 slave_addr, u8 index, u8 *buff, int buff_len); -struct i2c_adapter *viafb_find_i2c_adapter(enum viafb_i2c_adap which); - -extern int viafb_i2c_init(void); -extern void viafb_i2c_exit(void); -#endif /* __VIA_I2C_H__ */ diff --git a/drivers/video/via/via_modesetting.c b/drivers/video/via/via_modesetting.c index b4e735cc350..3cddcff88ab 100644 --- a/drivers/video/via/via_modesetting.c +++ b/drivers/video/via/via_modesetting.c @@ -24,8 +24,8 @@ */ #include +#include #include "via_modesetting.h" -#include "via-core.h" #include "share.h" #include "debug.h" diff --git a/drivers/video/via/via_utility.c b/drivers/video/via/via_utility.c index 57570314186..d05ccb62b55 100644 --- a/drivers/video/via/via_utility.c +++ b/drivers/video/via/via_utility.c @@ -19,7 +19,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "via-core.h" +#include #include "global.h" void viafb_get_device_support_state(u32 *support_state) diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c index 3d033186a82..d3dd2eb9558 100644 --- a/drivers/video/via/viafbdev.c +++ b/drivers/video/via/viafbdev.c @@ -22,9 +22,9 @@ #include #include #include -#define _MASTER_FILE +#include -#include "via-core.h" +#define _MASTER_FILE #include "global.h" static char *viafb_name = "Via"; diff --git a/drivers/video/via/viamode.c b/drivers/video/via/viamode.c index 2fdb9e6724a..2dbad3c0f67 100644 --- a/drivers/video/via/viamode.c +++ b/drivers/video/via/viamode.c @@ -19,7 +19,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "via-core.h" +#include #include "global.h" struct res_map_refresh res_map_refresh_tbl[] = { /*hres, vres, vclock, vmode_refresh*/ diff --git a/drivers/video/via/vt1636.c b/drivers/video/via/vt1636.c index e5f80247288..d65bf1aee87 100644 --- a/drivers/video/via/vt1636.c +++ b/drivers/video/via/vt1636.c @@ -19,8 +19,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "via-core.h" -#include "via_i2c.h" +#include +#include #include "global.h" u8 viafb_gpio_i2c_read_lvds(struct lvds_setting_information diff --git a/include/linux/via-core.h b/include/linux/via-core.h new file mode 100644 index 00000000000..7ffb521e1a7 --- /dev/null +++ b/include/linux/via-core.h @@ -0,0 +1,219 @@ +/* + * Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved. + * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. + * Copyright 2009-2010 Jonathan Corbet + * Copyright 2010 Florian Tobias Schandinat + * + * 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, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; 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 __VIA_CORE_H__ +#define __VIA_CORE_H__ +#include +#include +#include +#include + +/* + * A description of each known serial I2C/GPIO port. + */ +enum via_port_type { + VIA_PORT_NONE = 0, + VIA_PORT_I2C, + VIA_PORT_GPIO, +}; + +enum via_port_mode { + VIA_MODE_OFF = 0, + VIA_MODE_I2C, /* Used as I2C port */ + VIA_MODE_GPIO, /* Two GPIO ports */ +}; + +enum viafb_i2c_adap { + VIA_PORT_26 = 0, + VIA_PORT_31, + VIA_PORT_25, + VIA_PORT_2C, + VIA_PORT_3D, +}; +#define VIAFB_NUM_PORTS 5 + +struct via_port_cfg { + enum via_port_type type; + enum via_port_mode mode; + u16 io_port; + u8 ioport_index; +}; + +/* + * This is the global viafb "device" containing stuff needed by + * all subdevs. + */ +struct viafb_dev { + struct pci_dev *pdev; + int chip_type; + struct via_port_cfg *port_cfg; + /* + * Spinlock for access to device registers. Not yet + * globally used. + */ + spinlock_t reg_lock; + /* + * The framebuffer MMIO region. Little, if anything, touches + * this memory directly, and certainly nothing outside of the + * framebuffer device itself. We *do* have to be able to allocate + * chunks of this memory for other devices, though. + */ + unsigned long fbmem_start; + long fbmem_len; + void __iomem *fbmem; +#if defined(CONFIG_FB_VIA_CAMERA) || defined(CONFIG_FB_VIA_CAMERA_MODULE) + long camera_fbmem_offset; + long camera_fbmem_size; +#endif + /* + * The MMIO region for device registers. + */ + unsigned long engine_start; + unsigned long engine_len; + void __iomem *engine_mmio; + +}; + +/* + * Interrupt management. + */ + +void viafb_irq_enable(u32 mask); +void viafb_irq_disable(u32 mask); + +/* + * The global interrupt control register and its bits. + */ +#define VDE_INTERRUPT 0x200 /* Video interrupt flags/masks */ +#define VDE_I_DVISENSE 0x00000001 /* DVI sense int status */ +#define VDE_I_VBLANK 0x00000002 /* Vertical blank status */ +#define VDE_I_MCCFI 0x00000004 /* MCE compl. frame int status */ +#define VDE_I_VSYNC 0x00000008 /* VGA VSYNC int status */ +#define VDE_I_DMA0DDONE 0x00000010 /* DMA 0 descr done */ +#define VDE_I_DMA0TDONE 0x00000020 /* DMA 0 transfer done */ +#define VDE_I_DMA1DDONE 0x00000040 /* DMA 1 descr done */ +#define VDE_I_DMA1TDONE 0x00000080 /* DMA 1 transfer done */ +#define VDE_I_C1AV 0x00000100 /* Cap Eng 1 act vid end */ +#define VDE_I_HQV0 0x00000200 /* First HQV engine */ +#define VDE_I_HQV1 0x00000400 /* Second HQV engine */ +#define VDE_I_HQV1EN 0x00000800 /* Second HQV engine enable */ +#define VDE_I_C0AV 0x00001000 /* Cap Eng 0 act vid end */ +#define VDE_I_C0VBI 0x00002000 /* Cap Eng 0 VBI end */ +#define VDE_I_C1VBI 0x00004000 /* Cap Eng 1 VBI end */ +#define VDE_I_VSYNC2 0x00008000 /* Sec. Disp. VSYNC */ +#define VDE_I_DVISNSEN 0x00010000 /* DVI sense enable */ +#define VDE_I_VSYNC2EN 0x00020000 /* Sec Disp VSYNC enable */ +#define VDE_I_MCCFIEN 0x00040000 /* MC comp frame int mask enable */ +#define VDE_I_VSYNCEN 0x00080000 /* VSYNC enable */ +#define VDE_I_DMA0DDEN 0x00100000 /* DMA 0 descr done enable */ +#define VDE_I_DMA0TDEN 0x00200000 /* DMA 0 trans done enable */ +#define VDE_I_DMA1DDEN 0x00400000 /* DMA 1 descr done enable */ +#define VDE_I_DMA1TDEN 0x00800000 /* DMA 1 trans done enable */ +#define VDE_I_C1AVEN 0x01000000 /* cap 1 act vid end enable */ +#define VDE_I_HQV0EN 0x02000000 /* First hqv engine enable */ +#define VDE_I_C1VBIEN 0x04000000 /* Cap 1 VBI end enable */ +#define VDE_I_LVDSSI 0x08000000 /* LVDS sense interrupt */ +#define VDE_I_C0AVEN 0x10000000 /* Cap 0 act vid end enable */ +#define VDE_I_C0VBIEN 0x20000000 /* Cap 0 VBI end enable */ +#define VDE_I_LVDSSIEN 0x40000000 /* LVDS Sense enable */ +#define VDE_I_ENABLE 0x80000000 /* Global interrupt enable */ + +/* + * DMA management. + */ +int viafb_request_dma(void); +void viafb_release_dma(void); +/* void viafb_dma_copy_out(unsigned int offset, dma_addr_t paddr, int len); */ +int viafb_dma_copy_out_sg(unsigned int offset, struct scatterlist *sg, int nsg); + +/* + * DMA Controller registers. + */ +#define VDMA_MR0 0xe00 /* Mod reg 0 */ +#define VDMA_MR_CHAIN 0x01 /* Chaining mode */ +#define VDMA_MR_TDIE 0x02 /* Transfer done int enable */ +#define VDMA_CSR0 0xe04 /* Control/status */ +#define VDMA_C_ENABLE 0x01 /* DMA Enable */ +#define VDMA_C_START 0x02 /* Start a transfer */ +#define VDMA_C_ABORT 0x04 /* Abort a transfer */ +#define VDMA_C_DONE 0x08 /* Transfer is done */ +#define VDMA_MARL0 0xe20 /* Mem addr low */ +#define VDMA_MARH0 0xe24 /* Mem addr high */ +#define VDMA_DAR0 0xe28 /* Device address */ +#define VDMA_DQWCR0 0xe2c /* Count (16-byte) */ +#define VDMA_TMR0 0xe30 /* Tile mode reg */ +#define VDMA_DPRL0 0xe34 /* Not sure */ +#define VDMA_DPR_IN 0x08 /* Inbound transfer to FB */ +#define VDMA_DPRH0 0xe38 +#define VDMA_PMR0 (0xe00 + 0x134) /* Pitch mode */ + +/* + * Useful stuff that probably belongs somewhere global. + */ +#define VGA_WIDTH 640 +#define VGA_HEIGHT 480 + +/* + * Indexed port operations. Note that these are all multi-op + * functions; every invocation will be racy if you're not holding + * reg_lock. + */ + +#define VIAStatus 0x3DA /* Non-indexed port */ +#define VIACR 0x3D4 +#define VIASR 0x3C4 +#define VIAGR 0x3CE +#define VIAAR 0x3C0 + +static inline u8 via_read_reg(u16 port, u8 index) +{ + outb(index, port); + return inb(port + 1); +} + +static inline void via_write_reg(u16 port, u8 index, u8 data) +{ + outb(index, port); + outb(data, port + 1); +} + +static inline void via_write_reg_mask(u16 port, u8 index, u8 data, u8 mask) +{ + u8 old; + + outb(index, port); + old = inb(port + 1); + outb((data & mask) | (old & ~mask), port + 1); +} + +#define VIA_MISC_REG_READ 0x03CC +#define VIA_MISC_REG_WRITE 0x03C2 + +static inline void via_write_misc_reg_mask(u8 data, u8 mask) +{ + u8 old = inb(VIA_MISC_REG_READ); + outb((data & mask) | (old & ~mask), VIA_MISC_REG_WRITE); +} + + +#endif /* __VIA_CORE_H__ */ diff --git a/include/linux/via-gpio.h b/include/linux/via-gpio.h new file mode 100644 index 00000000000..8281aea3dd6 --- /dev/null +++ b/include/linux/via-gpio.h @@ -0,0 +1,14 @@ +/* + * Support for viafb GPIO ports. + * + * Copyright 2009 Jonathan Corbet + * Distributable under version 2 of the GNU General Public License. + */ + +#ifndef __VIA_GPIO_H__ +#define __VIA_GPIO_H__ + +extern int viafb_gpio_lookup(const char *name); +extern int viafb_gpio_init(void); +extern void viafb_gpio_exit(void); +#endif diff --git a/include/linux/via_i2c.h b/include/linux/via_i2c.h new file mode 100644 index 00000000000..44532e468c0 --- /dev/null +++ b/include/linux/via_i2c.h @@ -0,0 +1,42 @@ +/* + * Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved. + * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. + + * 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, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; 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 __VIA_I2C_H__ +#define __VIA_I2C_H__ + +#include +#include + +struct via_i2c_stuff { + u16 i2c_port; /* GPIO or I2C port */ + u16 is_active; /* Being used as I2C? */ + struct i2c_adapter adapter; + struct i2c_algo_bit_data algo; +}; + + +int viafb_i2c_readbyte(u8 adap, u8 slave_addr, u8 index, u8 *pdata); +int viafb_i2c_writebyte(u8 adap, u8 slave_addr, u8 index, u8 data); +int viafb_i2c_readbytes(u8 adap, u8 slave_addr, u8 index, u8 *buff, int buff_len); +struct i2c_adapter *viafb_find_i2c_adapter(enum viafb_i2c_adap which); + +extern int viafb_i2c_init(void); +extern void viafb_i2c_exit(void); +#endif /* __VIA_I2C_H__ */ -- cgit v1.2.3-70-g09d2