via-core.h revision 94dd1a856b23bd51dfebf68e6dd63cfd4d4fd5ae
1f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet/*
2f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet * Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved.
3f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet * Copyright 2009 Jonathan Corbet <corbet@lwn.net>
5f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet *
6f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet * This program is free software; you can redistribute it and/or
7f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet * modify it under the terms of the GNU General Public
8f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet * License as published by the Free Software Foundation;
9f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet * either version 2, or (at your option) any later version.
10f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet *
11f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet * This program is distributed in the hope that it will be useful,
12f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
13f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet * the implied warranty of MERCHANTABILITY or FITNESS FOR
14f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet * A PARTICULAR PURPOSE.See the GNU General Public License
15f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet * for more details.
16f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet *
17f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet * You should have received a copy of the GNU General Public License
18f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet * along with this program; if not, write to the Free Software
19f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet * Foundation, Inc.,
20f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet */
22f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet
23f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet#ifndef __VIA_CORE_H__
24f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet#define __VIA_CORE_H__
2524b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet#include <linux/spinlock.h>
2624b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet#include <linux/pci.h>
2724b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet
28f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet/*
29f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet * A description of each known serial I2C/GPIO port.
30f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet */
31f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbetenum via_port_type {
32f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet	VIA_PORT_NONE = 0,
33f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet	VIA_PORT_I2C,
34f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet	VIA_PORT_GPIO,
35f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet};
36f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet
37f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbetenum via_port_mode {
38f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet	VIA_MODE_OFF = 0,
39f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet	VIA_MODE_I2C,		/* Used as I2C port */
40f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet	VIA_MODE_GPIO,	/* Two GPIO ports */
41f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet};
42f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet
43f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbetenum viafb_i2c_adap {
44f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet	VIA_PORT_26 = 0,
45f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet	VIA_PORT_31,
46f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet	VIA_PORT_25,
47f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet	VIA_PORT_2C,
48f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet	VIA_PORT_3D,
49f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet};
50f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet#define VIAFB_NUM_PORTS 5
51f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet
52f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbetstruct via_port_cfg {
53f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet	enum via_port_type	type;
54f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet	enum via_port_mode	mode;
5524b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	u16			io_port;
5624b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	u8			ioport_index;
57f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet};
5824b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet
5924b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet/*
6024b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet * This is the global viafb "device" containing stuff needed by
6124b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet * all subdevs.
6224b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet */
6324b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbetstruct viafb_dev {
6424b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	struct pci_dev *pdev;
6524b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	int chip_type;
667582eb9be85f35271fd2569681a88a5b243e9380Jonathan Corbet	struct via_port_cfg *port_cfg;
6724b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	/*
6824b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	 * Spinlock for access to device registers.  Not yet
6924b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	 * globally used.
7024b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	 */
7124b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	spinlock_t reg_lock;
7224b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	/*
7324b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	 * The framebuffer MMIO region.  Little, if anything, touches
7424b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	 * this memory directly, and certainly nothing outside of the
7524b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	 * framebuffer device itself.  We *do* have to be able to allocate
7624b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	 * chunks of this memory for other devices, though.
7724b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	 */
7824b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	unsigned long fbmem_start;
7924b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	long fbmem_len;
8024b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	void __iomem *fbmem;
8124b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	/*
8224b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	 * The MMIO region for device registers.
8324b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	 */
8424b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	unsigned long engine_start;
8524b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	unsigned long engine_len;
8624b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet	void __iomem *engine_mmio;
8724b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet
8824b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet};
8924b4d82e4715841848a499534ed5cb7db3d6bca3Jonathan Corbet
9094dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet/*
9194dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet * Interrupt management.
9294dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet */
9394dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet
9494dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbetvoid viafb_irq_enable(u32 mask);
9594dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbetvoid viafb_irq_disable(u32 mask);
9694dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet
9794dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet/*
9894dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet * The global interrupt control register and its bits.
9994dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet */
10094dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define VDE_INTERRUPT	0x200	/* Video interrupt flags/masks */
10194dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_DVISENSE  0x00000001  /* DVI sense int status */
10294dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_VBLANK    0x00000002  /* Vertical blank status */
10394dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_MCCFI	  0x00000004  /* MCE compl. frame int status */
10494dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_VSYNC	  0x00000008  /* VGA VSYNC int status */
10594dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_DMA0DDONE 0x00000010  /* DMA 0 descr done */
10694dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_DMA0TDONE 0x00000020  /* DMA 0 transfer done */
10794dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_DMA1DDONE 0x00000040  /* DMA 1 descr done */
10894dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_DMA1TDONE 0x00000080  /* DMA 1 transfer done */
10994dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_C1AV      0x00000100  /* Cap Eng 1 act vid end */
11094dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_HQV0	  0x00000200  /* First HQV engine */
11194dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_HQV1      0x00000400  /* Second HQV engine */
11294dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_HQV1EN	  0x00000800  /* Second HQV engine enable */
11394dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_C0AV      0x00001000  /* Cap Eng 0 act vid end */
11494dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_C0VBI     0x00002000  /* Cap Eng 0 VBI end */
11594dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_C1VBI     0x00004000  /* Cap Eng 1 VBI end */
11694dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_VSYNC2    0x00008000  /* Sec. Disp. VSYNC */
11794dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_DVISNSEN  0x00010000  /* DVI sense enable */
11894dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_VSYNC2EN  0x00020000  /* Sec Disp VSYNC enable */
11994dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_MCCFIEN	  0x00040000  /* MC comp frame int mask enable */
12094dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_VSYNCEN   0x00080000  /* VSYNC enable */
12194dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_DMA0DDEN  0x00100000  /* DMA 0 descr done enable */
12294dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_DMA0TDEN  0x00200000  /* DMA 0 trans done enable */
12394dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_DMA1DDEN  0x00400000  /* DMA 1 descr done enable */
12494dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_DMA1TDEN  0x00800000  /* DMA 1 trans done enable */
12594dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_C1AVEN    0x01000000  /* cap 1 act vid end enable */
12694dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_HQV0EN	  0x02000000  /* First hqv engine enable */
12794dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_C1VBIEN	  0x04000000  /* Cap 1 VBI end enable */
12894dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_LVDSSI    0x08000000  /* LVDS sense interrupt */
12994dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_C0AVEN    0x10000000  /* Cap 0 act vid end enable */
13094dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_C0VBIEN   0x20000000  /* Cap 0 VBI end enable */
13194dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_LVDSSIEN  0x40000000  /* LVDS Sense enable */
13294dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet#define   VDE_I_ENABLE	  0x80000000  /* Global interrupt enable */
13394dd1a856b23bd51dfebf68e6dd63cfd4d4fd5aeJonathan Corbet
134f045f77bc0bf238a871b10bea9e425329a8e4abcJonathan Corbet#endif /* __VIA_CORE_H__ */
135