Subversion Repositories Kolibri OS

Rev

Rev 1970 | Rev 2967 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1970 Rev 2161
Line 17... Line 17...
17
#ifndef LINUX_PCI_H
17
#ifndef LINUX_PCI_H
18
#define LINUX_PCI_H
18
#define LINUX_PCI_H
Line 19... Line 19...
19
 
19
 
20
#include 
20
#include 
-
 
21
#include 
-
 
22
#include 	/* The pci register defines */
Line -... Line 23...
-
 
23
#include 
-
 
24
 
-
 
25
 
Line 21... Line 26...
21
#include 
26
#define PCI_CFG_SPACE_SIZE      256
Line 22... Line 27...
22
 
27
#define PCI_CFG_SPACE_EXP_SIZE  4096
Line 149... Line 154...
149
#define PCI_CLASS_SP_OTHER              0x1180
154
#define PCI_CLASS_SP_OTHER              0x1180
Line 150... Line 155...
150
 
155
 
Line 151... Line -...
151
#define PCI_CLASS_OTHERS                0xff
-
 
152
 
-
 
153
 
-
 
154
/*
-
 
155
 * Under PCI, each device has 256 bytes of configuration address space,
-
 
156
 * of which the first 64 bytes are standardized as follows:
-
 
157
 */
-
 
158
#define PCI_VENDOR_ID                   0x000    /* 16 bits */
-
 
159
#define PCI_DEVICE_ID                   0x002    /* 16 bits */
-
 
160
#define PCI_COMMAND                     0x004    /* 16 bits */
-
 
161
#define  PCI_COMMAND_IO                 0x001    /* Enable response in I/O space */
-
 
162
#define  PCI_COMMAND_MEMORY             0x002    /* Enable response in Memory space */
-
 
163
#define  PCI_COMMAND_MASTER             0x004    /* Enable bus mastering */
-
 
164
#define  PCI_COMMAND_SPECIAL            0x008    /* Enable response to special cycles */
-
 
165
#define  PCI_COMMAND_INVALIDATE         0x010    /* Use memory write and invalidate */
-
 
166
#define  PCI_COMMAND_VGA_PALETTE        0x020    /* Enable palette snooping */
-
 
167
#define  PCI_COMMAND_PARITY             0x040    /* Enable parity checking */
-
 
168
#define  PCI_COMMAND_WAIT               0x080    /* Enable address/data stepping */
-
 
169
#define  PCI_COMMAND_SERR               0x100    /* Enable SERR */
-
 
170
#define  PCI_COMMAND_FAST_BACK          0x200    /* Enable back-to-back writes */
-
 
171
#define  PCI_COMMAND_INTX_DISABLE       0x400    /* INTx Emulation Disable */
-
 
172
 
-
 
173
#define PCI_STATUS                      0x006    /* 16 bits */
-
 
174
#define  PCI_STATUS_CAP_LIST            0x010    /* Support Capability List */
-
 
175
#define  PCI_STATUS_66MHZ               0x020    /* Support 66 Mhz PCI 2.1 bus */
-
 
176
#define  PCI_STATUS_UDF                 0x040    /* Support User Definable Features [obsolete] */
-
 
177
#define  PCI_STATUS_FAST_BACK           0x080    /* Accept fast-back to back */
-
 
178
#define  PCI_STATUS_PARITY              0x100    /* Detected parity error */
-
 
179
#define  PCI_STATUS_DEVSEL_MASK         0x600    /* DEVSEL timing */
-
 
180
#define  PCI_STATUS_DEVSEL_FAST         0x000
-
 
181
#define  PCI_STATUS_DEVSEL_MEDIUM       0x200
-
 
182
#define  PCI_STATUS_DEVSEL_SLOW         0x400
-
 
183
#define  PCI_STATUS_SIG_TARGET_ABORT    0x800    /* Set on target abort */
-
 
184
#define  PCI_STATUS_REC_TARGET_ABORT    0x1000   /* Master ack of " */
-
 
185
#define  PCI_STATUS_REC_MASTER_ABORT    0x2000   /* Set on master abort */
-
 
186
#define  PCI_STATUS_SIG_SYSTEM_ERROR    0x4000   /* Set when we drive SERR */
-
 
187
#define  PCI_STATUS_DETECTED_PARITY     0x8000   /* Set on parity error */
-
 
188
 
-
 
189
#define PCI_CLASS_REVISION               0x08    /* High 24 bits are class, low 8 revision */
-
 
190
#define PCI_REVISION_ID                  0x08    /* Revision ID */
-
 
191
#define PCI_CLASS_PROG                   0x09    /* Reg. Level Programming Interface */
-
 
192
#define PCI_CLASS_DEVICE                 0x0a    /* Device class */
-
 
193
 
-
 
194
#define PCI_CACHE_LINE_SIZE              0x0c    /* 8 bits */
-
 
195
#define PCI_LATENCY_TIMER                0x0d    /* 8 bits */
-
 
196
#define PCI_HEADER_TYPE                  0x0e    /* 8 bits */
-
 
197
#define  PCI_HEADER_TYPE_NORMAL             0
-
 
198
#define  PCI_HEADER_TYPE_BRIDGE             1
-
 
199
#define  PCI_HEADER_TYPE_CARDBUS            2
-
 
200
 
-
 
201
#define PCI_BIST                         0x0f    /* 8 bits */
-
 
202
#define  PCI_BIST_CODE_MASK              0x0f    /* Return result */
-
 
203
#define  PCI_BIST_START                  0x40    /* 1 to start BIST, 2 secs or less */
-
 
204
#define  PCI_BIST_CAPABLE                0x80    /* 1 if BIST capable */
-
 
205
 
-
 
206
/*
-
 
207
 * Base addresses specify locations in memory or I/O space.
-
 
208
 * Decoded size can be determined by writing a value of
-
 
209
 * 0xffffffff to the register, and reading it back.  Only
-
 
210
 * 1 bits are decoded.
-
 
211
 */
-
 
212
#define  PCI_BASE_ADDRESS_0             0x10    /* 32 bits */
-
 
213
#define  PCI_BASE_ADDRESS_1             0x14    /* 32 bits [htype 0,1 only] */
-
 
214
#define  PCI_BASE_ADDRESS_2             0x18    /* 32 bits [htype 0 only] */
-
 
215
#define  PCI_BASE_ADDRESS_3             0x1c    /* 32 bits */
-
 
216
#define  PCI_BASE_ADDRESS_4             0x20    /* 32 bits */
-
 
217
#define  PCI_BASE_ADDRESS_5             0x24    /* 32 bits */
-
 
218
#define  PCI_BASE_ADDRESS_SPACE         0x01    /* 0 = memory, 1 = I/O */
-
 
219
#define  PCI_BASE_ADDRESS_SPACE_IO      0x01
-
 
220
#define  PCI_BASE_ADDRESS_SPACE_MEMORY  0x00
-
 
221
#define  PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06
-
 
222
#define  PCI_BASE_ADDRESS_MEM_TYPE_32   0x00    /* 32 bit address */
-
 
223
#define  PCI_BASE_ADDRESS_MEM_TYPE_1M   0x02    /* Below 1M [obsolete] */
-
 
224
#define  PCI_BASE_ADDRESS_MEM_TYPE_64   0x04    /* 64 bit address */
-
 
225
#define  PCI_BASE_ADDRESS_MEM_PREFETCH  0x08    /* prefetchable? */
-
 
226
#define  PCI_BASE_ADDRESS_MEM_MASK      (~0x0fUL)
-
 
227
#define  PCI_BASE_ADDRESS_IO_MASK       (~0x03UL)
-
 
228
/* bit 1 is reserved if address_space = 1 */
-
 
229
 
-
 
230
#define PCI_ROM_ADDRESS1                0x38    /* Same as PCI_ROM_ADDRESS, but for htype 1 */
-
 
231
 
-
 
232
/* Header type 0 (normal devices) */
-
 
233
#define PCI_CARDBUS_CIS                  0x28
-
 
234
#define PCI_SUBSYSTEM_VENDOR_ID          0x2c
-
 
235
#define PCI_SUBSYSTEM_ID                 0x2e
-
 
236
#define PCI_ROM_ADDRESS                  0x30    /* Bits 31..11 are address, 10..1 reserved */
-
 
237
#define  PCI_ROM_ADDRESS_ENABLE          0x01
-
 
238
#define PCI_ROM_ADDRESS_MASK             (~0x7ffUL)
-
 
239
 
-
 
240
#define PCI_INTERRUPT_LINE               0x3c    /* 8 bits */
-
 
241
#define PCI_INTERRUPT_PIN                0x3d    /* 8 bits */
-
 
242
 
-
 
243
 
-
 
244
#define PCI_CB_SUBSYSTEM_VENDOR_ID       0x40
-
 
245
#define PCI_CB_SUBSYSTEM_ID              0x42
-
 
246
 
-
 
247
#define PCI_CAPABILITY_LIST              0x34    /* Offset of first capability list entry */
-
 
248
#define PCI_CB_CAPABILITY_LIST           0x14
-
 
249
/* Capability lists */
-
 
250
 
-
 
251
#define PCI_CAP_LIST_ID                  0       /* Capability ID */
-
 
252
#define  PCI_CAP_ID_PM                   0x01    /* Power Management */
-
 
253
#define  PCI_CAP_ID_AGP                  0x02    /* Accelerated Graphics Port */
-
 
254
#define  PCI_CAP_ID_VPD                  0x03    /* Vital Product Data */
-
 
255
#define  PCI_CAP_ID_SLOTID               0x04    /* Slot Identification */
-
 
256
#define  PCI_CAP_ID_MSI                  0x05    /* Message Signalled Interrupts */
-
 
257
#define  PCI_CAP_ID_CHSWP                0x06    /* CompactPCI HotSwap */
-
 
258
#define  PCI_CAP_ID_PCIX                 0x07    /* PCI-X */
-
 
259
#define  PCI_CAP_ID_HT                   0x08    /* HyperTransport */
-
 
260
#define  PCI_CAP_ID_VNDR                 0x09    /* Vendor specific capability */
-
 
261
#define  PCI_CAP_ID_SHPC                 0x0C    /* PCI Standard Hot-Plug Controller */
-
 
262
#define  PCI_CAP_ID_EXP                  0x10    /* PCI Express */
-
 
263
#define  PCI_CAP_ID_MSIX                 0x11    /* MSI-X */
-
 
264
#define PCI_CAP_LIST_NEXT                1       /* Next capability in the list */
-
 
265
#define PCI_CAP_FLAGS                    2       /* Capability defined flags (16 bits) */
-
 
266
#define PCI_CAP_SIZEOF                   4
-
 
267
 
-
 
268
 
-
 
269
/* AGP registers */
-
 
270
 
-
 
271
#define PCI_AGP_VERSION                     2   /* BCD version number */
-
 
272
#define PCI_AGP_RFU                         3   /* Rest of capability flags */
-
 
273
#define PCI_AGP_STATUS                      4   /* Status register */
-
 
274
#define  PCI_AGP_STATUS_RQ_MASK        0xff000000  /* Maximum number of requests - 1 */
-
 
275
#define  PCI_AGP_STATUS_SBA            0x0200   /* Sideband addressing supported */
-
 
276
#define  PCI_AGP_STATUS_64BIT          0x0020   /* 64-bit addressing supported */
-
 
277
#define  PCI_AGP_STATUS_FW             0x0010   /* FW transfers supported */
-
 
278
#define  PCI_AGP_STATUS_RATE4          0x0004   /* 4x transfer rate supported */
-
 
279
#define  PCI_AGP_STATUS_RATE2          0x0002   /* 2x transfer rate supported */
-
 
280
#define  PCI_AGP_STATUS_RATE1          0x0001   /* 1x transfer rate supported */
-
 
281
#define PCI_AGP_COMMAND                     8   /* Control register */
-
 
282
#define  PCI_AGP_COMMAND_RQ_MASK    0xff000000  /* Master: Maximum number of requests */
-
 
283
#define  PCI_AGP_COMMAND_SBA           0x0200   /* Sideband addressing enabled */
-
 
284
#define  PCI_AGP_COMMAND_AGP           0x0100   /* Allow processing of AGP transactions */
-
 
285
#define  PCI_AGP_COMMAND_64BIT         0x0020   /* Allow processing of 64-bit addresses */
-
 
286
#define  PCI_AGP_COMMAND_FW            0x0010   /* Force FW transfers */
-
 
287
#define  PCI_AGP_COMMAND_RATE4         0x0004   /* Use 4x rate */
-
 
288
#define  PCI_AGP_COMMAND_RATE2         0x0002   /* Use 2x rate */
-
 
289
#define  PCI_AGP_COMMAND_RATE1         0x0001   /* Use 1x rate */
-
 
290
#define PCI_AGP_SIZEOF                     12
-
 
291
 
-
 
292
 
-
 
293
#define PCI_MAP_REG_START                   0x10
-
 
294
#define PCI_MAP_REG_END                     0x28
-
 
295
#define PCI_MAP_ROM_REG                     0x30
-
 
296
 
-
 
297
#define PCI_MAP_MEMORY                0x00000000
-
 
298
#define PCI_MAP_IO                    0x00000001
-
 
299
 
-
 
300
#define PCI_MAP_MEMORY_TYPE           0x00000007
-
 
301
#define PCI_MAP_IO_TYPE               0x00000003
-
 
302
 
-
 
303
#define PCI_MAP_MEMORY_TYPE_32BIT     0x00000000
-
 
304
#define PCI_MAP_MEMORY_TYPE_32BIT_1M  0x00000002
-
 
305
#define PCI_MAP_MEMORY_TYPE_64BIT     0x00000004
-
 
306
#define PCI_MAP_MEMORY_TYPE_MASK      0x00000006
-
 
307
#define PCI_MAP_MEMORY_CACHABLE       0x00000008
-
 
308
#define PCI_MAP_MEMORY_ATTR_MASK      0x0000000e
-
 
Line 309... Line 156...
309
#define PCI_MAP_MEMORY_ADDRESS_MASK   0xfffffff0
156
#define PCI_CLASS_OTHERS                0xff
310
 
157
 
Line 345... Line 192...
345
#define PCI_BUS_FROM_TAG(tag)  (((tag) >> 16) & (PCI_DOMBUS_MASK))
192
#define PCI_BUS_FROM_TAG(tag)  (((tag) >> 16) & (PCI_DOMBUS_MASK))
346
#define PCI_DEV_FROM_TAG(tag)  (((tag) & 0x0000f800u) >> 11)
193
#define PCI_DEV_FROM_TAG(tag)  (((tag) & 0x0000f800u) >> 11)
347
#define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8)
194
#define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8)
348
#define PCI_DFN_FROM_TAG(tag)  (((tag) & 0x0000ff00u) >> 8)
195
#define PCI_DFN_FROM_TAG(tag)  (((tag) & 0x0000ff00u) >> 8)
Line -... Line 196...
-
 
196
 
-
 
197
/*
-
 
198
 * The PCI interface treats multi-function devices as independent
-
 
199
 * devices.  The slot/function address of each device is encoded
-
 
200
 * in a single byte as follows:
-
 
201
 *
-
 
202
 *	7:3 = slot
-
 
203
 *	2:0 = function
349
 
204
 */
350
#define PCI_DEVFN(slot, func)  ((((slot) & 0x1f) << 3) | ((func) & 0x07))
205
#define PCI_DEVFN(slot, func)  ((((slot) & 0x1f) << 3) | ((func) & 0x07))
351
#define PCI_SLOT(devfn)        (((devfn) >> 3) & 0x1f)
206
#define PCI_SLOT(devfn)        (((devfn) >> 3) & 0x1f)
Line 359... Line 214...
359
pciTag(int busnum, int devnum, int funcnum)
214
pciTag(int busnum, int devnum, int funcnum)
360
{
215
{
361
    return(PCI_MAKE_TAG(busnum,devnum,funcnum));
216
    return(PCI_MAKE_TAG(busnum,devnum,funcnum));
362
}
217
}
Line -... Line 218...
-
 
218
 
-
 
219
/* pci_slot represents a physical slot */
-
 
220
struct pci_slot {
-
 
221
	struct pci_bus *bus;		/* The bus this slot is on */
-
 
222
	struct list_head list;		/* node in list of slots on this bus */
-
 
223
	struct hotplug_slot *hotplug;	/* Hotplug info (migrate over time) */
-
 
224
	unsigned char number;		/* PCI_SLOT(pci_dev->devfn) */
Line 363... Line -...
363
 
-
 
364
 
-
 
365
struct resource
225
};
366
{
226
 
367
         resource_size_t start;
227
/* File state for mmap()s on /proc/bus/pci/X/Y */
368
         resource_size_t end;
228
enum pci_mmap_state {
369
//         const char *name;
-
 
370
         unsigned long flags;
229
	pci_mmap_io,
Line -... Line 230...
-
 
230
	pci_mmap_mem
-
 
231
};
-
 
232
 
-
 
233
/* This defines the direction arg to the DMA mapping routines. */
-
 
234
#define PCI_DMA_BIDIRECTIONAL	0
-
 
235
#define PCI_DMA_TODEVICE	1
371
//         struct resource *parent, *sibling, *child;
236
#define PCI_DMA_FROMDEVICE	2
372
};
237
#define PCI_DMA_NONE		3
373
 
238
 
-
 
239
/*
-
 
240
 *  For PCI devices, the region numbers are assigned this way:
-
 
241
 */
-
 
242
enum {
-
 
243
    /* #0-5: standard PCI resources */
-
 
244
    PCI_STD_RESOURCES,
-
 
245
    PCI_STD_RESOURCE_END = 5,
-
 
246
 
-
 
247
    /* #6: expansion ROM resource */
-
 
248
    PCI_ROM_RESOURCE,
-
 
249
 
374
/*
250
    /* device specific resources */
-
 
251
#ifdef CONFIG_PCI_IOV
Line 375... Line -...
375
 * IO resources have these defined flags.
-
 
376
 */
-
 
377
#define IORESOURCE_BITS         0x000000ff      /* Bus-specific bits */
-
 
378
 
-
 
379
#define IORESOURCE_IO           0x00000100      /* Resource type */
-
 
380
#define IORESOURCE_MEM          0x00000200
-
 
381
#define IORESOURCE_IRQ          0x00000400
-
 
382
#define IORESOURCE_DMA          0x00000800
-
 
383
 
-
 
384
#define IORESOURCE_PREFETCH     0x00001000      /* No side effects */
-
 
385
#define IORESOURCE_READONLY     0x00002000
-
 
386
#define IORESOURCE_CACHEABLE    0x00004000
-
 
387
#define IORESOURCE_RANGELENGTH  0x00008000
-
 
388
#define IORESOURCE_SHADOWABLE   0x00010000
-
 
389
#define IORESOURCE_BUS_HAS_VGA  0x00080000
-
 
390
 
-
 
391
#define IORESOURCE_DISABLED     0x10000000
-
 
392
#define IORESOURCE_UNSET        0x20000000
-
 
393
#define IORESOURCE_AUTO         0x40000000
-
 
394
#define IORESOURCE_BUSY         0x80000000      /* Driver has marked this resource busy */
-
 
395
 
-
 
396
/* ISA PnP IRQ specific bits (IORESOURCE_BITS) */
-
 
397
#define IORESOURCE_IRQ_HIGHEDGE         (1<<0)
-
 
398
#define IORESOURCE_IRQ_LOWEDGE          (1<<1)
-
 
399
#define IORESOURCE_IRQ_HIGHLEVEL        (1<<2)
-
 
400
#define IORESOURCE_IRQ_LOWLEVEL         (1<<3)
-
 
401
#define IORESOURCE_IRQ_SHAREABLE        (1<<4)
-
 
402
 
-
 
403
/* ISA PnP DMA specific bits (IORESOURCE_BITS) */
-
 
404
#define IORESOURCE_DMA_TYPE_MASK        (3<<0)
-
 
405
#define IORESOURCE_DMA_8BIT             (0<<0)
-
 
406
#define IORESOURCE_DMA_8AND16BIT        (1<<0)
-
 
407
#define IORESOURCE_DMA_16BIT            (2<<0)
-
 
408
 
-
 
409
#define IORESOURCE_DMA_MASTER           (1<<2)
-
 
410
#define IORESOURCE_DMA_BYTE             (1<<3)
-
 
411
#define IORESOURCE_DMA_WORD             (1<<4)
-
 
412
 
-
 
413
#define IORESOURCE_DMA_SPEED_MASK       (3<<6)
-
 
414
#define IORESOURCE_DMA_COMPATIBLE       (0<<6)
-
 
415
#define IORESOURCE_DMA_TYPEA            (1<<6)
252
    PCI_IOV_RESOURCES,
416
#define IORESOURCE_DMA_TYPEB            (2<<6)
-
 
417
#define IORESOURCE_DMA_TYPEF            (3<<6)
-
 
418
 
-
 
419
/* ISA PnP memory I/O specific bits (IORESOURCE_BITS) */
-
 
420
#define IORESOURCE_MEM_WRITEABLE        (1<<0)  /* dup: IORESOURCE_READONLY */
-
 
421
#define IORESOURCE_MEM_CACHEABLE        (1<<1)  /* dup: IORESOURCE_CACHEABLE */
-
 
422
#define IORESOURCE_MEM_RANGELENGTH      (1<<2)  /* dup: IORESOURCE_RANGELENGTH */
-
 
423
#define IORESOURCE_MEM_TYPE_MASK        (3<<3)
-
 
424
#define IORESOURCE_MEM_8BIT             (0<<3)
-
 
425
#define IORESOURCE_MEM_16BIT            (1<<3)
253
    PCI_IOV_RESOURCE_END = PCI_IOV_RESOURCES + PCI_SRIOV_NUM_BARS - 1,
426
#define IORESOURCE_MEM_8AND16BIT        (2<<3)
-
 
427
#define IORESOURCE_MEM_32BIT            (3<<3)
-
 
428
#define IORESOURCE_MEM_SHADOWABLE       (1<<5)  /* dup: IORESOURCE_SHADOWABLE */
-
 
429
#define IORESOURCE_MEM_EXPANSIONROM     (1<<6)
-
 
430
 
-
 
431
/* PCI ROM control bits (IORESOURCE_BITS) */
-
 
Line -... Line 254...
-
 
254
#endif
432
#define IORESOURCE_ROM_ENABLE           (1<<0)  /* ROM is enabled, same as PCI_ROM_ADDRESS_ENABLE */
255
 
433
#define IORESOURCE_ROM_SHADOW           (1<<1)  /* ROM is copy at C000:0 */
256
    /* resources assigned to buses behind the bridge */
Line -... Line 257...
-
 
257
#define PCI_BRIDGE_RESOURCE_NUM 4
-
 
258
 
Line -... Line 259...
-
 
259
    PCI_BRIDGE_RESOURCES,
-
 
260
    PCI_BRIDGE_RESOURCE_END = PCI_BRIDGE_RESOURCES +
434
#define IORESOURCE_ROM_COPY             (1<<2)  /* ROM is alloc'd copy, resource field overlaid */
261
                  PCI_BRIDGE_RESOURCE_NUM - 1,
-
 
262
 
435
#define IORESOURCE_ROM_BIOS_COPY        (1<<3)  /* ROM is BIOS copy, resource field overlaid */
263
    /* total resources associated with a PCI device */
436
 
264
    PCI_NUM_RESOURCES,
-
 
265
 
437
/* PCI control bits.  Shares IORESOURCE_BITS with above PCI ROM.  */
266
    /* preserve this for compatibility */
438
#define IORESOURCE_PCI_FIXED            (1<<4)  /* Do not move resource */
267
    DEVICE_COUNT_RESOURCE
-
 
268
};
-
 
269
 
-
 
270
typedef int __bitwise pci_power_t;
-
 
271
 
-
 
272
#define PCI_D0		((pci_power_t __force) 0)
439
 
273
#define PCI_D1		((pci_power_t __force) 1)
-
 
274
#define PCI_D2		((pci_power_t __force) 2)
440
 
275
#define PCI_D3hot	((pci_power_t __force) 3)
-
 
276
#define PCI_D3cold	((pci_power_t __force) 4)
Line 441... Line 277...
441
/*
277
#define PCI_UNKNOWN	((pci_power_t __force) 5)
442
 *  For PCI devices, the region numbers are assigned this way:
278
#define PCI_POWER_ERROR	((pci_power_t __force) -1)
443
 *
279
/** The pci_channel state describes connectivity between the CPU and
Line 444... Line 280...
444
 *      0-5     standard PCI regions
280
 *  the pci device.  If some PCI bus between here and the pci device
445
 *      6       expansion ROM
281
 *  has crashed or locked up, this info is reflected here.
446
 *      7-10    bridges: address space assigned to buses behind the bridge
-
 
Line -... Line 282...
-
 
282
 */
-
 
283
typedef unsigned int __bitwise pci_channel_state_t;
-
 
284
 
-
 
285
enum pci_channel_state {
-
 
286
	/* I/O channel is in normal state */
-
 
287
	pci_channel_io_normal = (__force pci_channel_state_t) 1,
-
 
288
 
-
 
289
	/* I/O to channel is blocked */
-
 
290
	pci_channel_io_frozen = (__force pci_channel_state_t) 2,
-
 
291
 
-
 
292
	/* PCI card is dead */
-
 
293
	pci_channel_io_perm_failure = (__force pci_channel_state_t) 3,
-
 
294
};
-
 
295
typedef unsigned short __bitwise pci_bus_flags_t;
-
 
296
enum pci_bus_flags {
-
 
297
    PCI_BUS_FLAGS_NO_MSI   = (__force pci_bus_flags_t) 1,
-
 
298
    PCI_BUS_FLAGS_NO_MMRBC = (__force pci_bus_flags_t) 2,
-
 
299
};
-
 
300
 
-
 
301
/* Based on the PCI Hotplug Spec, but some values are made up by us */
-
 
302
enum pci_bus_speed {
-
 
303
	PCI_SPEED_33MHz			= 0x00,
-
 
304
	PCI_SPEED_66MHz			= 0x01,
-
 
305
	PCI_SPEED_66MHz_PCIX		= 0x02,
-
 
306
	PCI_SPEED_100MHz_PCIX		= 0x03,
-
 
307
	PCI_SPEED_133MHz_PCIX		= 0x04,
-
 
308
	PCI_SPEED_66MHz_PCIX_ECC	= 0x05,
-
 
309
	PCI_SPEED_100MHz_PCIX_ECC	= 0x06,
447
 */
310
	PCI_SPEED_133MHz_PCIX_ECC	= 0x07,
-
 
311
	PCI_SPEED_66MHz_PCIX_266	= 0x09,
-
 
312
	PCI_SPEED_100MHz_PCIX_266	= 0x0a,
-
 
313
	PCI_SPEED_133MHz_PCIX_266	= 0x0b,
-
 
314
	AGP_UNKNOWN			= 0x0c,
-
 
315
	AGP_1X				= 0x0d,
-
 
316
	AGP_2X				= 0x0e,
Line 448... Line 317...
448
 
317
	AGP_4X				= 0x0f,
449
#define PCI_ROM_RESOURCE        6
318
	AGP_8X				= 0x10,
450
#define PCI_BRIDGE_RESOURCES    7
319
	PCI_SPEED_66MHz_PCIX_533	= 0x11,
451
#define PCI_NUM_RESOURCES       11
320
	PCI_SPEED_100MHz_PCIX_533	= 0x12,
452
 
321
	PCI_SPEED_133MHz_PCIX_533	= 0x13,
453
#ifndef PCI_BUS_NUM_RESOURCES
322
	PCIE_SPEED_2_5GT		= 0x14,
454
#define PCI_BUS_NUM_RESOURCES   8
323
	PCIE_SPEED_5_0GT		= 0x15,
Line 455... Line 324...
455
#endif
324
	PCIE_SPEED_8_0GT		= 0x16,
456
 
325
	PCI_SPEED_UNKNOWN		= 0xff,
457
#define DEVICE_COUNT_RESOURCE   12
326
};
458
 
327
 
459
/*
328
/*
460
 * The pci_dev structure is used to describe PCI devices.
329
 * The pci_dev structure is used to describe PCI devices.
461
 */
330
 */
462
struct pci_dev {
331
struct pci_dev {
463
//    struct list_head bus_list;  /* node in per-bus list */
332
    struct list_head bus_list;  /* node in per-bus list */
464
//    struct pci_bus  *bus;       /* bus this device is on */
333
    struct pci_bus  *bus;       /* bus this device is on */
465
//    struct pci_bus  *subordinate;   /* bus this device bridges to */
334
    struct pci_bus  *subordinate;   /* bus this device bridges to */
466
 
335
 
-
 
336
	void		*sysdata;	/* hook for sys-specific extension */
467
//    void        *sysdata;       /* hook for sys-specific extension */
337
//    struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */
468
//    struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */
338
	struct pci_slot	*slot;		/* Physical slot this device is in */
469
//    struct pci_slot *slot;      /* Physical slot this device is in */
339
    u32_t           busnr;
Line 470... Line 340...
470
    u32_t        bus;
340
	unsigned int	devfn;		/* encoded device & function index */
471
    u32_t        devfn;          /* encoded device & function index */
341
	unsigned short	vendor;
472
    u16_t        vendor;
342
	unsigned short	device;
473
    u16_t        device;
343
	unsigned short	subsystem_vendor;
474
    u16_t        subsystem_vendor;
344
	unsigned short	subsystem_device;
475
    u16_t        subsystem_device;
345
	unsigned int	class;		/* 3 bytes: (base,sub,prog-if) */
Line 476... Line 346...
476
    u32_t        class;         /* 3 bytes: (base,sub,prog-if) */
346
	u8		revision;	/* PCI revision, low byte of class word */
Line 477... Line 347...
477
    uint8_t      revision;      /* PCI revision, low byte of class word */
347
	u8		hdr_type;	/* PCI header type (`multi' flag masked out) */
478
    uint8_t      hdr_type;      /* PCI header type (`multi' flag masked out) */
348
	u8		pcie_cap;	/* PCI-E capability offset */
479
    uint8_t      pcie_type;     /* PCI-E device/port type */
349
	u8		pcie_type;	/* PCI-E device/port type */
480
    uint8_t      rom_base_reg;   /* which config register controls the ROM */
350
	u8		rom_base_reg;	/* which config register controls the ROM */
481
    uint8_t      pin;           /* which interrupt pin this device uses */
351
	u8		pin;  		/* which interrupt pin this device uses */
482
 
352
 
483
 //   struct pci_driver *driver;  /* which driver has allocated this device */
353
 //   struct pci_driver *driver;  /* which driver has allocated this device */
-
 
354
    uint64_t     dma_mask;   /* Mask of the bits of bus address this
484
    uint64_t     dma_mask;   /* Mask of the bits of bus address this
355
                       device implements.  Normally this is
485
                       device implements.  Normally this is
356
                       0xffffffff.  You only need to change
486
                       0xffffffff.  You only need to change
357
                       this if your device has broken DMA
-
 
358
                       or supports 64-bit transfers.  */
-
 
359
 
-
 
360
 //   struct device_dma_parameters dma_parms;
-
 
361
 
Line 487... Line -...
487
                       this if your device has broken DMA
-
 
488
                       or supports 64-bit transfers.  */
-
 
Line -... Line 362...
-
 
362
	pci_power_t     current_state;  /* Current operating state. In ACPI-speak,
-
 
363
					   this is D0-D3, D0 being fully functional,
-
 
364
					   and D3 being off. */
489
 
365
	int		pm_cap;		/* PM capability offset in the
Line 490... Line 366...
490
 //   struct device_dma_parameters dma_parms;
366
					   configuration space */
491
 
367
    unsigned int    pme_support:5;  /* Bitmask of states from which PME#
492
//    pci_power_t     current_state;  /* Current operating state. In ACPI-speak,
368
                       can be generated */
493
 //                      this is D0-D3, D0 being fully functional,
369
	unsigned int	pme_interrupt:1;
494
//                       and D3 being off. */
370
    unsigned int    d1_support:1;   /* Low power state D1 is supported */
495
//    int     pm_cap;     /* PM capability offset in the
371
    unsigned int    d2_support:1;   /* Low power state D2 is supported */
-
 
372
    unsigned int    no_d1d2:1;  /* Only allow D0 and D3 */
Line 496... Line 373...
496
//                       configuration space */
373
	unsigned int	mmio_always_on:1;	/* disallow turning off io/mem
497
    unsigned int    pme_support:5;  /* Bitmask of states from which PME#
374
						   decoding during bar sizing */
498
                       can be generated */
375
	unsigned int	wakeup_prepared:1;
499
    unsigned int    d1_support:1;   /* Low power state D1 is supported */
376
	unsigned int	d3_delay;	/* D3->D0 transition time in ms */
Line 524... Line 401...
524
    unsigned int    irq_reroute_variant:2;  /* device needs IRQ rerouting variant */
401
    unsigned int    irq_reroute_variant:2;  /* device needs IRQ rerouting variant */
525
    unsigned int    msi_enabled:1;
402
    unsigned int    msi_enabled:1;
526
    unsigned int    msix_enabled:1;
403
    unsigned int    msix_enabled:1;
527
    unsigned int    ari_enabled:1;  /* ARI forwarding */
404
	unsigned int	ari_enabled:1;	/* ARI forwarding */
528
    unsigned int    is_managed:1;
405
    unsigned int    is_managed:1;
-
 
406
	unsigned int	is_pcie:1;	/* Obsolete. Will be removed.
529
    unsigned int    is_pcie:1;
407
					   Use pci_is_pcie() instead */
-
 
408
	unsigned int    needs_freset:1; /* Dev requires fundamental reset */
530
    unsigned int    state_saved:1;
409
    unsigned int    state_saved:1;
531
    unsigned int    is_physfn:1;
410
    unsigned int    is_physfn:1;
532
    unsigned int    is_virtfn:1;
411
    unsigned int    is_virtfn:1;
-
 
412
	unsigned int	reset_fn:1;
-
 
413
	unsigned int    is_hotplug_bridge:1;
533
//    pci_dev_flags_t dev_flags;
414
//    pci_dev_flags_t dev_flags;
534
//    atomic_t    enable_cnt;   /* pci_enable_device has been called */
415
//    atomic_t    enable_cnt;   /* pci_enable_device has been called */
Line 535... Line 416...
535
 
416
 
536
//    u32     saved_config_space[16]; /* config space saved at suspend time */
417
//    u32     saved_config_space[16]; /* config space saved at suspend time */
Line 551... Line 432...
551
                                                        \
432
                                                        \
552
         (pci_resource_end((dev), (bar)) -              \
433
         (pci_resource_end((dev), (bar)) -              \
553
          pci_resource_start((dev), (bar)) + 1))
434
          pci_resource_start((dev), (bar)) + 1))
Line -... Line 435...
-
 
435
 
-
 
436
 
-
 
437
struct pci_bus {
-
 
438
    struct list_head node;      /* node in list of buses */
-
 
439
    struct pci_bus  *parent;    /* parent bus this bridge is on */
-
 
440
    struct list_head children;  /* list of child buses */
-
 
441
    struct list_head devices;   /* list of devices on this bus */
-
 
442
    struct pci_dev  *self;      /* bridge device as seen by parent */
-
 
443
    struct list_head slots;     /* list of slots on this bus */
-
 
444
    struct resource *resource[PCI_BRIDGE_RESOURCE_NUM];
-
 
445
    struct list_head resources; /* address space routed to this bus */
-
 
446
 
-
 
447
    struct pci_ops  *ops;       /* configuration access functions */
-
 
448
    void        *sysdata;   /* hook for sys-specific extension */
-
 
449
    struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */
-
 
450
 
-
 
451
    unsigned char   number;     /* bus number */
-
 
452
    unsigned char   primary;    /* number of primary bridge */
-
 
453
    unsigned char   secondary;  /* number of secondary bridge */
-
 
454
    unsigned char   subordinate;    /* max number of subordinate buses */
-
 
455
    unsigned char   max_bus_speed;  /* enum pci_bus_speed */
-
 
456
    unsigned char   cur_bus_speed;  /* enum pci_bus_speed */
-
 
457
 
-
 
458
    char        name[48];
-
 
459
 
-
 
460
    unsigned short  bridge_ctl; /* manage NO_ISA/FBB/et al behaviors */
-
 
461
    pci_bus_flags_t bus_flags;  /* Inherited by child busses */
-
 
462
    struct device       *bridge;
-
 
463
    struct device       dev;
-
 
464
    struct bin_attribute    *legacy_io; /* legacy I/O for this bus */
-
 
465
    struct bin_attribute    *legacy_mem; /* legacy mem */
-
 
466
    unsigned int        is_added:1;
-
 
467
};
-
 
468
 
-
 
469
 
-
 
470
#define pci_bus_b(n)    list_entry(n, struct pci_bus, node)
-
 
471
#define to_pci_bus(n)   container_of(n, struct pci_bus, dev)
-
 
472
#define pci_dev_b(n)    list_entry(n, struct pci_dev, bus_list)
-
 
473
#define to_pci_dev(n) container_of(n, struct pci_dev, dev)
-
 
474
#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL)
-
 
475
 
-
 
476
 
-
 
477
/* Low-level architecture-dependent routines */
-
 
478
 
-
 
479
struct pci_sysdata {
-
 
480
        int             domain;         /* PCI domain */
-
 
481
        int             node;           /* NUMA node */
-
 
482
};
-
 
483
 
-
 
484
 
-
 
485
#define pci_bus_b(n)    list_entry(n, struct pci_bus, node)
-
 
486
#define to_pci_bus(n)   container_of(n, struct pci_bus, dev)
-
 
487
 
-
 
488
/*
-
 
489
 * Returns true if the pci bus is root (behind host-pci bridge),
-
 
490
 * false otherwise
-
 
491
 */
-
 
492
static inline bool pci_is_root_bus(struct pci_bus *pbus)
-
 
493
{
-
 
494
    return !(pbus->parent);
-
 
495
}
-
 
496
 
-
 
497
struct pci_bus *
-
 
498
pci_find_next_bus(const struct pci_bus *from);
-
 
499
 
-
 
500
 
-
 
501
  /*
-
 
502
 * Error values that may be returned by PCI functions.
-
 
503
 */
-
 
504
#define PCIBIOS_SUCCESSFUL      0x00
-
 
505
#define PCIBIOS_FUNC_NOT_SUPPORTED  0x81
-
 
506
#define PCIBIOS_BAD_VENDOR_ID       0x83
-
 
507
#define PCIBIOS_DEVICE_NOT_FOUND    0x86
-
 
508
#define PCIBIOS_BAD_REGISTER_NUMBER 0x87
-
 
509
#define PCIBIOS_SET_FAILED      0x88
-
 
510
#define PCIBIOS_BUFFER_TOO_SMALL    0x89
-
 
511
 
-
 
512
/* Low-level architecture-dependent routines */
-
 
513
 
-
 
514
struct pci_ops {
-
 
515
    int (*read)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val);
-
 
516
    int (*write)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val);
-
 
517
};
-
 
518
 
-
 
519
 
-
 
520
enum pci_bar_type {
-
 
521
    pci_bar_unknown,    /* Standard PCI BAR probe */
-
 
522
    pci_bar_io,     /* An io port BAR */
-
 
523
    pci_bar_mem32,      /* A 32-bit memory BAR */
-
 
524
    pci_bar_mem64,      /* A 64-bit memory BAR */
-
 
525
};
-
 
526
 
-
 
527
/*
-
 
528
 * PCI domain support.  Sometimes called PCI segment (eg by ACPI),
-
 
529
 * a PCI domain is defined to be a set of PCI busses which share
-
 
530
 * configuration space.
-
 
531
 */
-
 
532
#ifdef CONFIG_PCI_DOMAINS
-
 
533
extern int pci_domains_supported;
-
 
534
#else
-
 
535
enum { pci_domains_supported = 0 };
-
 
536
static inline int pci_domain_nr(struct pci_bus *bus)
-
 
537
{
-
 
538
    return 0;
-
 
539
}
-
 
540
 
-
 
541
static inline int pci_proc_domain(struct pci_bus *bus)
-
 
542
{
-
 
543
    return 0;
-
 
544
}
-
 
545
#endif /* CONFIG_PCI_DOMAINS */
-
 
546
 
-
 
547
/**
-
 
548
 * pci_pcie_cap - get the saved PCIe capability offset
-
 
549
 * @dev: PCI device
-
 
550
 *
-
 
551
 * PCIe capability offset is calculated at PCI device initialization
-
 
552
 * time and saved in the data structure. This function returns saved
-
 
553
 * PCIe capability offset. Using this instead of pci_find_capability()
-
 
554
 * reduces unnecessary search in the PCI configuration space. If you
-
 
555
 * need to calculate PCIe capability offset from raw device for some
-
 
556
 * reasons, please use pci_find_capability() instead.
-
 
557
 */
-
 
558
static inline int pci_pcie_cap(struct pci_dev *dev)
-
 
559
{
-
 
560
    return dev->pcie_cap;
-
 
561
}
-
 
562
 
-
 
563
/**
-
 
564
 * pci_is_pcie - check if the PCI device is PCI Express capable
-
 
565
 * @dev: PCI device
-
 
566
 *
-
 
567
 * Retrun true if the PCI device is PCI Express capable, false otherwise.
-
 
568
 */
-
 
569
static inline bool pci_is_pcie(struct pci_dev *dev)
-
 
570
{
-
 
571
    return !!pci_pcie_cap(dev);
-
 
572
}
-
 
573
 
-
 
574
static inline int pci_iov_init(struct pci_dev *dev)
-
 
575
{
-
 
576
    return -ENODEV;
-
 
577
}
-
 
578
static inline void pci_iov_release(struct pci_dev *dev)
-
 
579
 
-
 
580
{}
-
 
581
 
-
 
582
static inline int pci_iov_resource_bar(struct pci_dev *dev, int resno,
-
 
583
                       enum pci_bar_type *type)
-
 
584
{
-
 
585
    return 0;
-
 
586
}
-
 
587
static inline void pci_restore_iov_state(struct pci_dev *dev)
-
 
588
{
-
 
589
}
-
 
590
static inline int pci_iov_bus_range(struct pci_bus *bus)
-
 
591
{
-
 
592
    return 0;
-
 
593
}
-
 
594
 
-
 
595
static inline int pci_enable_ats(struct pci_dev *dev, int ps)
-
 
596
{
-
 
597
    return -ENODEV;
-
 
598
}
-
 
599
static inline void pci_disable_ats(struct pci_dev *dev)
-
 
600
{
-
 
601
}
-
 
602
static inline int pci_ats_queue_depth(struct pci_dev *dev)
-
 
603
{
-
 
604
    return -ENODEV;
-
 
605
}
-
 
606
static inline int pci_ats_enabled(struct pci_dev *dev)
-
 
607
{
-
 
608
    return 0;
-
 
609
}
-
 
610
 
-
 
611
int pci_setup_device(struct pci_dev *dev);
-
 
612
int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
-
 
613
         struct resource *res, unsigned int reg);
-
 
614
int pci_resource_bar(struct pci_dev *dev, int resno,
-
 
615
         enum pci_bar_type *type);
Line 554... Line 616...
554
 
616
int pci_bus_add_child(struct pci_bus *bus);
555
 
617
unsigned int pci_scan_child_bus(struct pci_bus *bus);
556
 
618