• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6/drivers/media/video/saa7164/
1/*
2 *  Driver for the NXP SAA7164 PCIe bridge
3 *
4 *  Copyright (c) 2009 Steven Toth <stoth@kernellabs.com>
5 *
6 *  This program is free software; you can redistribute it and/or modify
7 *  it under the terms of the GNU General Public License as published by
8 *  the Free Software Foundation; either version 2 of the License, or
9 *  (at your option) any later version.
10 *
11 *  This program is distributed in the hope that it will be useful,
12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 *
15 *  GNU General Public License for more details.
16 *
17 *  You should have received a copy of the GNU General Public License
18 *  along with this program; if not, write to the Free Software
19 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22/* TODO: Retest the driver with errors expressed as negatives */
23
24/* Result codes */
25#define SAA_OK				0
26#define SAA_ERR_BAD_PARAMETER		0x09
27#define SAA_ERR_NO_RESOURCES		0x0c
28#define SAA_ERR_NOT_SUPPORTED		0x13
29#define SAA_ERR_BUSY			0x15
30#define SAA_ERR_READ			0x17
31#define SAA_ERR_TIMEOUT			0x1f
32#define SAA_ERR_OVERFLOW		0x20
33#define SAA_ERR_EMPTY			0x22
34#define SAA_ERR_NOT_STARTED		0x23
35#define SAA_ERR_ALREADY_STARTED		0x24
36#define SAA_ERR_NOT_STOPPED		0x25
37#define SAA_ERR_ALREADY_STOPPED		0x26
38#define SAA_ERR_INVALID_COMMAND		0x3e
39#define SAA_ERR_NULL_PACKET		0x59
40
41/* Errors and flags from the silicon */
42#define PVC_ERRORCODE_UNKNOWN		0x00
43#define PVC_ERRORCODE_INVALID_COMMAND	0x01
44#define PVC_ERRORCODE_INVALID_CONTROL	0x02
45#define PVC_ERRORCODE_INVALID_DATA	0x03
46#define PVC_ERRORCODE_TIMEOUT		0x04
47#define PVC_ERRORCODE_NAK		0x05
48#define PVC_RESPONSEFLAG_ERROR		0x01
49#define PVC_RESPONSEFLAG_OVERFLOW	0x02
50#define PVC_RESPONSEFLAG_RESET		0x04
51#define PVC_RESPONSEFLAG_INTERFACE	0x08
52#define PVC_RESPONSEFLAG_CONTINUED	0x10
53#define PVC_CMDFLAG_INTERRUPT		0x02
54#define PVC_CMDFLAG_INTERFACE		0x04
55#define PVC_CMDFLAG_SERIALIZE		0x08
56#define PVC_CMDFLAG_CONTINUE		0x10
57
58/* Silicon Commands */
59#define GET_DESCRIPTORS_CONTROL		0x01
60#define GET_STRING_CONTROL		0x03
61#define GET_LANGUAGE_CONTROL		0x05
62#define SET_POWER_CONTROL		0x07
63#define GET_FW_VERSION_CONTROL		0x09
64#define SET_DEBUG_LEVEL_CONTROL		0x0B
65#define GET_DEBUG_DATA_CONTROL		0x0C
66#define GET_PRODUCTION_INFO_CONTROL	0x0D
67
68/* cmd defines */
69#define SAA_CMDFLAG_CONTINUE		0x10
70#define SAA_CMD_MAX_MSG_UNITS		256
71
72/* Some defines */
73#define SAA_BUS_TIMEOUT			50
74#define SAA_DEVICE_TIMEOUT		5000
75#define SAA_DEVICE_MAXREQUESTSIZE	256
76
77/* Register addresses */
78#define SAA_DEVICE_VERSION		0x30
79#define SAA_DOWNLOAD_FLAGS		0x34
80#define SAA_DOWNLOAD_FLAG		0x34
81#define SAA_DOWNLOAD_FLAG_ACK		0x38
82#define SAA_DATAREADY_FLAG		0x3C
83#define SAA_DATAREADY_FLAG_ACK		0x40
84
85/* Boot loader register and bit definitions */
86#define SAA_BOOTLOADERERROR_FLAGS	0x44
87#define SAA_DEVICE_IMAGE_SEARCHING	0x01
88#define SAA_DEVICE_IMAGE_LOADING	0x02
89#define SAA_DEVICE_IMAGE_BOOTING	0x03
90#define SAA_DEVICE_IMAGE_CORRUPT	0x04
91#define SAA_DEVICE_MEMORY_CORRUPT	0x08
92#define SAA_DEVICE_NO_IMAGE		0x10
93
94/* Register addresses */
95#define SAA_DEVICE_2ND_VERSION			0x50
96#define SAA_DEVICE_2ND_DOWNLOADFLAG_OFFSET	0x54
97
98/* Register addresses */
99#define SAA_SECONDSTAGEERROR_FLAGS		0x64
100
101/* Bootloader regs and flags */
102#define SAA_DEVICE_DEADLOCK_DETECTED_OFFSET	0x6C
103#define SAA_DEVICE_DEADLOCK_DETECTED		0xDEADDEAD
104
105/* Basic firmware status registers */
106#define SAA_DEVICE_SYSINIT_STATUS_OFFSET	0x70
107#define SAA_DEVICE_SYSINIT_STATUS		0x70
108#define SAA_DEVICE_SYSINIT_MODE			0x74
109#define SAA_DEVICE_SYSINIT_SPEC			0x78
110#define SAA_DEVICE_SYSINIT_INST			0x7C
111#define SAA_DEVICE_SYSINIT_CPULOAD		0x80
112#define SAA_DEVICE_SYSINIT_REMAINHEAP		0x84
113
114#define SAA_DEVICE_DOWNLOAD_OFFSET		0x1000
115#define SAA_DEVICE_BUFFERBLOCKSIZE		0x1000
116
117#define SAA_DEVICE_2ND_BUFFERBLOCKSIZE		0x100000
118#define SAA_DEVICE_2ND_DOWNLOAD_OFFSET		0x200000
119
120/* Descriptors */
121#define CS_INTERFACE	0x24
122
123/* Descriptor subtypes */
124#define VC_INPUT_TERMINAL		0x02
125#define VC_OUTPUT_TERMINAL		0x03
126#define VC_SELECTOR_UNIT		0x04
127#define VC_PROCESSING_UNIT		0x05
128#define FEATURE_UNIT			0x06
129#define TUNER_UNIT			0x09
130#define ENCODER_UNIT			0x0A
131#define EXTENSION_UNIT			0x0B
132#define VC_TUNER_PATH			0xF0
133#define PVC_HARDWARE_DESCRIPTOR		0xF1
134#define PVC_INTERFACE_DESCRIPTOR	0xF2
135#define PVC_INFRARED_UNIT		0xF3
136#define DRM_UNIT			0xF4
137#define GENERAL_REQUEST			0xF5
138
139/* Format Types */
140#define VS_FORMAT_TYPE         0x02
141#define VS_FORMAT_TYPE_I       0x01
142#define VS_FORMAT_UNCOMPRESSED 0x04
143#define VS_FRAME_UNCOMPRESSED  0x05
144#define VS_FORMAT_MPEG2PS      0x09
145#define VS_FORMAT_MPEG2TS      0x0A
146#define VS_FORMAT_MPEG4SL      0x0B
147#define VS_FORMAT_WM9          0x0C
148#define VS_FORMAT_DIVX         0x0D
149#define VS_FORMAT_VBI          0x0E
150#define VS_FORMAT_RDS          0x0F
151
152/* Device extension commands */
153#define EXU_REGISTER_ACCESS_CONTROL	0x00
154#define EXU_GPIO_CONTROL		0x01
155#define EXU_GPIO_GROUP_CONTROL		0x02
156#define EXU_INTERRUPT_CONTROL		0x03
157
158/* State Transition and args */
159#define SAA_STATE_CONTROL	0x03
160#define SAA_DMASTATE_STOP	0x00
161#define SAA_DMASTATE_ACQUIRE	0x01
162#define SAA_DMASTATE_PAUSE	0x02
163#define SAA_DMASTATE_RUN	0x03
164
165/* Hardware registers */
166