Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

rt_pci.h

Go to the documentation of this file.
00001 /*********************************************************************************/
00002 /* This file has been written by Sergio Perez Alcañiz <serpeal@disca.upv.es>     */
00003 /*            Departamento de Informática de Sistemas y Computadores             */
00004 /*            Universidad Politécnica de Valencia                                */
00005 /*            Valencia (Spain)                                                   */
00006 /*                                                                               */
00007 /* The RTL-lwIP project has been supported by the Spanish Government Research    */
00008 /* Office (CICYT) under grant TIC2002-04123-C03-03                               */
00009 /*                                                                               */
00010 /* Copyright (c) March, 2003 SISTEMAS DE TIEMPO REAL EMPOTRADOS, FIABLES Y       */
00011 /* DISTRIBUIDOS BASADOS EN COMPONENTES                                           */
00012 /*                                                                               */
00013 /*  This program is free software; you can redistribute it and/or modify         */
00014 /*  it under the terms of the GNU General Public License as published by         */
00015 /*  the Free Software Foundation; either version 2 of the License, or            */
00016 /*  (at your option) any later version.                                          */
00017 /*                                                                               */
00018 /*  This program is distributed in the hope that it will be useful,              */
00019 /*  but WITHOUT ANY WARRANTY; without even the implied warranty of               */
00020 /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                */
00021 /*  GNU General Public License for more details.                                 */
00022 /*                                                                               */
00023 /*  You should have received a copy of the GNU General Public License            */
00024 /*  along with this program; if not, write to the Free Software                  */
00025 /*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA    */
00026 /*                                                                               */
00027 /*  Linking RTL-lwIP statically or dynamically with other modules is making a    */
00028 /*  combined work based on RTL-lwIP.  Thus, the terms and conditions of the GNU  */
00029 /*  General Public License cover the whole combination.                          */
00030 /*                                                                               */
00031 /*  As a special exception, the copyright holders of RTL-lwIP give you           */
00032 /*  permission to link RTL-lwIP with independent modules that communicate with   */
00033 /*  RTL-lwIP solely through the interfaces, regardless of the license terms of   */
00034 /*  these independent modules, and to copy and distribute the resulting combined */
00035 /*  work under terms of your choice, provided that every copy of the combined    */
00036 /*  work is accompanied by a complete copy of the source code of RTL-lwIP (the   */
00037 /*  version of RTL-lwIP used to produce the combined work), being distributed    */
00038 /*  under the terms of the GNU General Public License plus this exception.  An   */
00039 /*  independent module is a module which is not derived from or based on         */
00040 /*  RTL-lwIP.                                                                    */
00041 /*                                                                               */
00042 /*  Note that people who make modified versions of RTL-lwIP are not obligated to */
00043 /*  grant this special exception for their modified versions; it is their choice */
00044 /*  whether to do so.  The GNU General Public License gives permission to        */
00045 /*  release a modified version without this exception; this exception also makes */
00046 /*  it possible to release a modified version which carries forward this         */
00047 /*  exception.                                                                   */
00048 /*                                                                               */
00049 /*  CONTRIBUTORS: -Miguel Masmano Tello <mmasmano@disca.upv.es>                  */
00050 /*                -COMEDI                                                        */
00051 /*                 The Linux Control and Measurement Device Interface            */
00052 /*                 David Schleef <ds@schleef.org>                                */
00053 /*********************************************************************************/
00054 
00055 #include <linux/pci.h>
00056 #include <linux/config.h>
00057 #include <asm/io.h>
00058 #ifndef PCI_H
00059 #define PCI_H
00060 
00061 #define PCI_COMMAND_IO                  0x1     /* Enable response in I/O space */
00062 #define PCI_COMMAND_MEM                 0x2     /* Enable response in mem space */
00063 #define PCI_COMMAND_MASTER              0x4     /* Enable bus mastering */
00064 #define PCI_LATENCY_TIMER               0x0d    /* 8 bits */
00065 
00066 #define PCIBIOS_PCI_FUNCTION_ID         0xb1XX
00067 #define PCIBIOS_PCI_BIOS_PRESENT        0xb101
00068 #define PCIBIOS_FIND_PCI_DEVICE         0xb102
00069 #define PCIBIOS_FIND_PCI_CLASS_CODE     0xb103
00070 #define PCIBIOS_GENERATE_SPECIAL_CYCLE  0xb106
00071 #define PCIBIOS_READ_CONFIG_BYTE        0xb108
00072 #define PCIBIOS_READ_CONFIG_WORD        0xb109
00073 #define PCIBIOS_READ_CONFIG_DWORD       0xb10a
00074 #define PCIBIOS_WRITE_CONFIG_BYTE       0xb10b
00075 #define PCIBIOS_WRITE_CONFIG_WORD       0xb10c
00076 #define PCIBIOS_WRITE_CONFIG_DWORD      0xb10d
00077 #define PCIBIOS_SET_PCI_HW_INT          0xb10f
00078 
00079 #define PCI_VENDOR_ID           0x00    /* 16 bits */
00080 #define PCI_DEVICE_ID           0x02    /* 16 bits */
00081 #define PCI_COMMAND             0x04    /* 16 bits */
00082 
00083 #define PCI_REVISION            0x08    /* 8 bits  */
00084 #define PCI_CLASS_CODE          0x0b    /* 8 bits */
00085 #define PCI_SUBCLASS_CODE       0x0a    /* 8 bits */
00086 #define PCI_HEADER_TYPE         0x0e    /* 8 bits */
00087 
00088 #define PCI_BASE_ADDRESS_0      0x10    /* 32 bits */
00089 #define PCI_BASE_ADDRESS_1      0x14    /* 32 bits */
00090 #define PCI_BASE_ADDRESS_2      0x18    /* 32 bits */
00091 #define PCI_BASE_ADDRESS_3      0x1c    /* 32 bits */
00092 #define PCI_BASE_ADDRESS_4      0x20    /* 32 bits */
00093 #define PCI_BASE_ADDRESS_5      0x24    /* 32 bits */
00094 
00095 #define PCI_INTERRUPT_LINE      0x3c    /* 8 bits */
00096 #define PCI_INTERRUPT_PIN       0x3d    /* 8 bits */
00097 
00098 #ifndef PCI_BASE_ADDRESS_IO_MASK
00099 #define PCI_BASE_ADDRESS_IO_MASK       (~0x03)
00100 #endif
00101 #define PCI_BASE_ADDRESS_SPACE_IO       0x01
00102 #define PCI_ROM_ADDRESS         0x30    /* 32 bits */
00103 #define PCI_ROM_ADDRESS_ENABLE  0x01    /* Write 1 to enable ROM,
00104                                            bits 31..11 are address,
00105                                            10..2 are reserved */
00106 
00107 #define PCI_FUNC(devfn)           ((devfn) & 0x07)
00108 
00109 #define bus_number(pci_dev) ((((int)(pci_dev))>>8) & 0xff)
00110 #define devfn_number(pci_dev) (((int)(pci_dev)) & 0xff)
00111 
00112 
00113 #define BIOS32_SIGNATURE        (('_' << 0) + ('3' << 8) + ('2' << 16) + ('_' << 24))
00114 
00115 /* PCI signature: "PCI " */
00116 #define PCI_SIGNATURE           (('P' << 0) + ('C' << 8) + ('I' << 16) + (' ' << 24))
00117 
00118 /* PCI service signature: "$PCI" */
00119 #define PCI_SERVICE             (('$' << 0) + ('P' << 8) + ('C' << 16) + ('I' << 24))
00120 
00121 union bios32 {
00122   struct {
00123     unsigned long signature;    /* _32_ */
00124     unsigned long entry;        /* Direccion fisica de 32 bit */
00125     unsigned char revision;             /* Nivel de revision */
00126     unsigned char length;               /* La longitud deberia ser 01 */
00127     unsigned char checksum;             /* Todos los bytes deberian ser cero */
00128     unsigned char reserved[5];  /* Debe ser cero */
00129   } fields;
00130   char chars[16];
00131 };
00132 
00133 #define KERN_CODE_SEG   0x10    /* Esto coincide con oskit/base_gdt.h KERNEL_CS */
00134 
00135 
00136 extern int rt_pcibios_read_config_byte(unsigned int bus, unsigned int device_fn, 
00137                                     unsigned int where, unsigned char *value);
00138 
00139 extern int rt_rtpcibios_write_config_byte (unsigned int bus, unsigned int device_fn,
00140                                       unsigned int where, unsigned char value);
00141 
00142 extern int rt_pcibios_read_config_word(unsigned int bus, unsigned int device_fn, 
00143                                     unsigned int where, unsigned short *value);
00144 
00145 extern int rt_pcibios_write_config_word (unsigned int bus, unsigned int device_fn,
00146                                       unsigned int where, unsigned short value);
00147 
00148 extern int rt_pcibios_read_config_dword(unsigned int bus, unsigned int device_fn, 
00149                                      unsigned int where, unsigned int *value);
00150 
00151 extern int rt_pcibios_write_config_dword(unsigned int bus, unsigned int device_fn,
00152                                       unsigned int where, unsigned int value);
00153 
00154 extern int rt_pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
00155 
00156 #define rt_pci_read_config_byte(pdev, where, valp)\
00157         rt_pcibios_read_config_byte(bus_number(pdev), devfn_number(pdev), where, valp)
00158 #define rt_pci_read_config_word(pdev, where, valp)\
00159         rt_pcibios_read_config_word(bus_number(pdev), devfn_number(pdev), where, valp)
00160 #define rt_pci_read_config_dword(pdev, where, valp)\
00161         rt_pcibios_read_config_dword(bus_number(pdev), devfn_number(pdev), where, valp)
00162 #define rt_pci_write_config_byte(pdev, where, val)\
00163         rt_pcibios_write_config_byte(bus_number(pdev), devfn_number(pdev), where, val)
00164 #define rt_pci_write_config_word(pdev, where, val)\
00165         rt_pcibios_write_config_word(bus_number(pdev), devfn_number(pdev), where, val)
00166 #define rt_pci_write_config_dword(pdev, where, val)\
00167         rt_pcibios_write_config_dword(bus_number(pdev), devfn_number(pdev), where, val)
00168 
00169 #define rt_pci_resource_start(dev,bar)   ((dev)->resource[(bar)].start)
00170 #define rt_pci_resource_end(dev,bar)     ((dev)->resource[(bar)].end)
00171 #define rt_pci_resource_flags(dev,bar)   ((dev)->resource[(bar)].flags)
00172 #define rt_pci_resource_len(dev,bar) \
00173         ((rt_pci_resource_start((dev),(bar)) == 0 &&    \
00174           rt_pci_resource_end((dev),(bar)) ==           \
00175           rt_pci_resource_start((dev),(bar))) ? 0 :     \
00176                                                         \
00177          (rt_pci_resource_end((dev),(bar)) -            \
00178           rt_pci_resource_start((dev),(bar)) + 1))
00179 
00180 
00181 
00182 
00183 int rt_pci_set_power_state(struct pci_dev *dev, int state);
00184 int rt_pci_find_capability(struct pci_dev *dev, int cap);
00185 struct pci_dev * rt_pci_find_device(unsigned int vendor, unsigned int device, const struct pci_dev *from);
00186 int rt_pci_enable_device(struct pci_dev *dev);
00187 int rt_pci_restore_state(struct pci_dev *dev, u32 *buffer);
00188 int rt_pci_enable_wake(struct pci_dev *dev, u32 state, int enable);
00189 int rt_pci_save_state(struct pci_dev *dev, u32 *buffer);
00190 #endif  /* PCI_H */

Generated on Wed Jan 14 12:58:56 2004 for RTL-lwIP-0.4 by doxygen 1.3.4