root/arch/ppc/kernel/pci.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. pcibios_init
  2. pcibios_fixup
  3. _LE_to_BE_long
  4. _LE_to_BE_short
  5. pcibios_present
  6. pcibios_read_config_dword
  7. pcibios_read_config_word
  8. pcibios_read_config_byte
  9. pcibios_write_config_dword
  10. pcibios_write_config_word
  11. pcibios_write_config_byte
  12. pcibios_find_device
  13. pcibios_find_class
  14. pcibios_strerror

   1 /*
   2  * PCI support
   3  */
   4 
   5 #include <linux/config.h>
   6 #include <linux/types.h>
   7 #include <linux/bios32.h>
   8 #include <linux/pci.h>
   9 
  10 /* #define PCI_DEBUG */
  11 
  12 int PCI_conversions[2];
  13 
  14 unsigned long pcibios_init(unsigned long mem_start,
     /* [previous][next][first][last][top][bottom][index][help] */
  15                            unsigned long mem_end)
  16 {
  17         printk("PPC init stub -- cort\n");
  18 
  19         return mem_start;
  20 }
  21 
  22 unsigned long pcibios_fixup(unsigned long mem_start, unsigned long mem_end)
     /* [previous][next][first][last][top][bottom][index][help] */
  23 {
  24   return mem_start;
  25 }
  26 
  27 unsigned long
  28 _LE_to_BE_long(unsigned long val)
     /* [previous][next][first][last][top][bottom][index][help] */
  29 {
  30         unsigned char *p = (unsigned char *)&val;
  31         PCI_conversions[0]++;
  32         return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | (p[0] << 0));
  33 }
  34 
  35 unsigned short
  36 _LE_to_BE_short(unsigned long val)
     /* [previous][next][first][last][top][bottom][index][help] */
  37 {
  38         unsigned char *p = (unsigned char *)&val;
  39         PCI_conversions[1]++;
  40         return ((p[3] << 8) | (p[2] << 0));
  41 }
  42 
  43 int
  44 pcibios_present (void)
     /* [previous][next][first][last][top][bottom][index][help] */
  45 {
  46 #ifdef PCI_DEBUG        
  47         _printk("PCI [BIOS] present?\n");
  48 #endif  
  49         return (1);
  50 }
  51 
  52 int
  53 pcibios_read_config_dword (unsigned char bus,
     /* [previous][next][first][last][top][bottom][index][help] */
  54     unsigned char dev, unsigned char offset, unsigned int *val)
  55 {
  56         unsigned long _val;
  57         unsigned long *ptr;
  58         dev >>= 3;
  59 #ifdef PCI_DEBUG        
  60         _printk("PCI Read config dword[%d.%d.%x] = ", bus, dev, offset);
  61 #endif  
  62         if ((bus != 0) || (dev < 11) || (dev > 16))
  63         {
  64                 *val = 0xFFFFFFFF;
  65                 return PCIBIOS_DEVICE_NOT_FOUND;
  66         } else
  67         {
  68                 ptr = (unsigned long *)(0x80800000 | (1<<dev) | offset);
  69 #ifdef PCI_DEBUG        
  70                 _printk("[%x] ", ptr);
  71 #endif          
  72                 _val = _LE_to_BE_long(*ptr);
  73         }
  74 #ifdef PCI_DEBUG        
  75         _printk("%x\n", _val);
  76 #endif  
  77         *val = _val;
  78         return PCIBIOS_SUCCESSFUL;
  79 }
  80 
  81 int
  82 pcibios_read_config_word (unsigned char bus,
     /* [previous][next][first][last][top][bottom][index][help] */
  83     unsigned char dev, unsigned char offset, unsigned short *val)
  84 {
  85         unsigned short _val;
  86         unsigned short *ptr;
  87         dev >>= 3;
  88 #ifdef PCI_DEBUG        
  89         _printk("PCI Read config word[%d.%d.%x] = ", bus, dev, offset);
  90 #endif  
  91         if ((bus != 0) || (dev < 11) || (dev > 16))
  92         {
  93                 *val =(unsigned short) 0xFFFFFFFF;
  94                 return PCIBIOS_DEVICE_NOT_FOUND;
  95         } else
  96         {
  97                 ptr = (unsigned short *)(0x80800000 | (1<<dev) | offset);
  98 #ifdef PCI_DEBUG        
  99                 _printk("[%x] ", ptr);
 100 #endif          
 101                 _val = _LE_to_BE_short(*ptr);
 102         }
 103 #ifdef PCI_DEBUG        
 104         _printk("%x\n", _val);
 105 #endif          
 106         *val = _val;
 107         return PCIBIOS_SUCCESSFUL;
 108 }
 109 
 110 int
 111 pcibios_read_config_byte (unsigned char bus,
     /* [previous][next][first][last][top][bottom][index][help] */
 112     unsigned char dev, unsigned char offset, unsigned char *val)
 113 {
 114         unsigned char _val;
 115         unsigned char *ptr;
 116         dev >>= 3;
 117 #ifdef PCI_DEBUG        
 118         _printk("PCI Read config byte[%d.%d.%x] = ", bus, dev, offset);
 119 #endif          
 120         if ((bus != 0) || (dev < 11) || (dev > 16))
 121         {
 122                 *val = (unsigned char) 0xFFFFFFFF;
 123                 return PCIBIOS_DEVICE_NOT_FOUND;
 124         } else
 125         {
 126                 ptr = (unsigned char *)(0x80800000 | (1<<dev) | offset ^ 1);
 127 #ifdef PCI_DEBUG        
 128                 _printk("[%x] ", ptr);
 129 #endif          
 130                 _val = *ptr;
 131         }
 132 #ifdef PCI_DEBUG        
 133         _printk("%x\n", _val);
 134 #endif          
 135         *val = _val;
 136         return PCIBIOS_SUCCESSFUL;
 137 }
 138 
 139 int
 140 pcibios_write_config_dword (unsigned char bus,
     /* [previous][next][first][last][top][bottom][index][help] */
 141     unsigned char dev, unsigned char offset, unsigned int val)
 142 {
 143         unsigned long _val;
 144         unsigned long *ptr;
 145         dev >>= 3;
 146         _val = _LE_to_BE_long(val);
 147 #ifdef PCI_DEBUG        
 148         _printk("PCI Write config dword[%d.%d.%x] = %x\n", bus, dev, offset, _val);
 149 #endif          
 150         if ((bus != 0) || (dev < 11) || (dev > 16))
 151         {
 152                 return PCIBIOS_DEVICE_NOT_FOUND;
 153         } else
 154         {
 155                 ptr = (unsigned long *)(0x80800000 | (1<<dev) | offset);
 156                 *ptr = _val;
 157         }
 158         return PCIBIOS_SUCCESSFUL;
 159 }
 160 
 161 int
 162 pcibios_write_config_word (unsigned char bus,
     /* [previous][next][first][last][top][bottom][index][help] */
 163     unsigned char dev, unsigned char offset, unsigned short val)
 164 {
 165         unsigned short _val;
 166         unsigned short *ptr;
 167         dev >>= 3;
 168         _val = _LE_to_BE_short(val);
 169 #ifdef PCI_DEBUG        
 170         _printk("PCI Write config word[%d.%d.%x] = %x\n", bus, dev, offset, _val);
 171 #endif          
 172         if ((bus != 0) || (dev < 11) || (dev > 16))
 173         {
 174                 return PCIBIOS_DEVICE_NOT_FOUND;
 175         } else
 176         {
 177                 ptr = (unsigned short *)(0x80800000 | (1<<dev) | offset);
 178                 *ptr = _val;
 179         }
 180         return PCIBIOS_SUCCESSFUL;
 181 }
 182 
 183 int
 184 pcibios_write_config_byte (unsigned char bus,
     /* [previous][next][first][last][top][bottom][index][help] */
 185     unsigned char dev, unsigned char offset, unsigned char val)
 186 {
 187         unsigned char _val;
 188         unsigned char *ptr;
 189         dev >>= 3;
 190         _val = val;
 191 #ifdef PCI_DEBUG        
 192         _printk("PCI Write config byte[%d.%d.%x] = %x\n", bus, dev, offset, _val);
 193 #endif          
 194         if ((bus != 0) || (dev < 11) || (dev > 16))
 195         {
 196                 return PCIBIOS_DEVICE_NOT_FOUND;
 197         } else
 198         {
 199                 ptr = (unsigned char *)(0x80800000 | (1<<dev) | offset ^ 1);
 200                 *ptr = _val;
 201         }
 202         return PCIBIOS_SUCCESSFUL;
 203 }
 204 
 205 int
 206 pcibios_find_device (unsigned short vendor, unsigned short device_id,
     /* [previous][next][first][last][top][bottom][index][help] */
 207                      unsigned short index, unsigned char *bus,
 208                      unsigned char *dev)
 209 {
 210         unsigned int w, desired = (device_id << 16) | vendor;
 211         int devnr;
 212 
 213         if (vendor == 0xffff) {
 214                 return PCIBIOS_BAD_VENDOR_ID;
 215         }
 216 
 217         for (devnr = 11;  devnr < 16;  devnr++)
 218         {
 219                 pcibios_read_config_dword(0, devnr<<3, PCI_VENDOR_ID, &w);
 220                 if (w == desired) {
 221                         if (index == 0) {
 222                                 *bus = 0;
 223                                 *dev = devnr<<3;
 224                                 return PCIBIOS_SUCCESSFUL;
 225                         }
 226                         --index;
 227                 }
 228         }
 229         return PCIBIOS_DEVICE_NOT_FOUND;
 230 }
 231 
 232 int
 233 pcibios_find_class (unsigned int class_code, unsigned short index, 
     /* [previous][next][first][last][top][bottom][index][help] */
 234     unsigned char *bus, unsigned char *dev)
 235 {
 236         printk("pcibios_find_class\n");
 237         return PCIBIOS_FUNC_NOT_SUPPORTED;
 238 }    
 239 
 240 const char *pcibios_strerror(int error) { _panic("pcibios_strerror"); } 
     /* [previous][next][first][last][top][bottom][index][help] */
 241 /*int get_pci_list(char *buf) { _panic("get_pci_list"); } */

/* [previous][next][first][last][top][bottom][index][help] */