pci_ixp.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. /*
  2. * IXP PCI Init
  3. * (C) Copyright 2004 eslab.whut.edu.cn
  4. * Yue Hu(huyue_whut@yahoo.com.cn), Ligong Xue(lgxue@hotmail.com)
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <common.h>
  25. #include <asm/processor.h>
  26. #include <asm/io.h>
  27. #include <pci.h>
  28. #include <asm/arch/ixp425.h>
  29. #include <asm/arch/ixp425pci.h>
  30. static void non_prefetch_read (unsigned int addr, unsigned int cmd,
  31. unsigned int *data);
  32. static void non_prefetch_write (unsigned int addr, unsigned int cmd,
  33. unsigned int data);
  34. static void configure_pins (void);
  35. static void sys_pci_gpio_clock_config (void);
  36. static void pci_bus_scan (void);
  37. static int pci_device_exists (unsigned int deviceNo);
  38. static void sys_pci_bar_info_get (unsigned int devnum, unsigned int bus,
  39. unsigned int dev, unsigned int func);
  40. static void sys_pci_device_bars_write (void);
  41. static void calc_bars (PciBar * Bars[], unsigned int nBars,
  42. unsigned int startAddr);
  43. #define PCI_MEMORY_BUS 0x00000000
  44. #define PCI_MEMORY_PHY 0x48000000
  45. #define PCI_MEMORY_SIZE 0x04000000
  46. #define PCI_MEM_BUS 0x40000000
  47. #define PCI_MEM_PHY 0x00000000
  48. #define PCI_MEM_SIZE 0x04000000
  49. #define PCI_IO_BUS 0x40000000
  50. #define PCI_IO_PHY 0x50000000
  51. #define PCI_IO_SIZE 0x10000000
  52. struct pci_controller hose;
  53. unsigned int nDevices;
  54. unsigned int nMBars;
  55. unsigned int nIOBars;
  56. PciBar *memBars[IXP425_PCI_MAX_BAR];
  57. PciBar *ioBars[IXP425_PCI_MAX_BAR];
  58. PciDevice devices[IXP425_PCI_MAX_FUNC_ON_BUS];
  59. int pci_read_config_dword (pci_dev_t dev, int where, unsigned int *val)
  60. {
  61. unsigned int retval;
  62. unsigned int addr;
  63. /*address bits 31:28 specify the device 10:8 specify the function */
  64. /*Set the address to be read */
  65. addr = BIT ((31 - dev)) | (where & ~3);
  66. non_prefetch_read (addr, NP_CMD_CONFIGREAD, &retval);
  67. *val = retval;
  68. return (OK);
  69. }
  70. int pci_read_config_word (pci_dev_t dev, int where, unsigned short *val)
  71. {
  72. unsigned int n;
  73. unsigned int retval;
  74. unsigned int addr;
  75. unsigned int byteEnables;
  76. n = where % 4;
  77. /*byte enables are 4 bits active low, the position of each
  78. bit maps to the byte that it enables */
  79. byteEnables =
  80. (~(BIT (n) | BIT ((n + 1)))) &
  81. IXP425_PCI_BOTTOM_NIBBLE_OF_LONG_MASK;
  82. byteEnables = byteEnables << PCI_NP_CBE_BESL;
  83. /*address bits 31:28 specify the device 10:8 specify the function */
  84. /*Set the address to be read */
  85. addr = BIT ((31 - dev)) | (where & ~3);
  86. non_prefetch_read (addr, byteEnables | NP_CMD_CONFIGREAD, &retval);
  87. /*Pick out the word we are interested in */
  88. *val = (retval >> (8 * n));
  89. return (OK);
  90. }
  91. int pci_read_config_byte (pci_dev_t dev, int where, unsigned char *val)
  92. {
  93. unsigned int retval;
  94. unsigned int n;
  95. unsigned int byteEnables;
  96. unsigned int addr;
  97. n = where % 4;
  98. /*byte enables are 4 bits, active low, the position of each
  99. bit maps to the byte that it enables */
  100. byteEnables = (~BIT (n)) & IXP425_PCI_BOTTOM_NIBBLE_OF_LONG_MASK;
  101. byteEnables = byteEnables << PCI_NP_CBE_BESL;
  102. /*address bits 31:28 specify the device, 10:8 specify the function */
  103. /*Set the address to be read */
  104. addr = BIT ((31 - dev)) | (where & ~3);
  105. non_prefetch_read (addr, byteEnables | NP_CMD_CONFIGREAD, &retval);
  106. /*Pick out the byte we are interested in */
  107. *val = (retval >> (8 * n));
  108. return (OK);
  109. }
  110. int pci_write_config_byte (pci_dev_t dev, int where, unsigned char val)
  111. {
  112. unsigned int addr;
  113. unsigned int byteEnables;
  114. unsigned int n;
  115. unsigned int ldata;
  116. n = where % 4;
  117. /*byte enables are 4 bits active low, the position of each
  118. bit maps to the byte that it enables */
  119. byteEnables = (~BIT (n)) & IXP425_PCI_BOTTOM_NIBBLE_OF_LONG_MASK;
  120. byteEnables = byteEnables << PCI_NP_CBE_BESL;
  121. ldata = val << (8 * n);
  122. /*address bits 31:28 specify the device 10:8 specify the function */
  123. /*Set the address to be written */
  124. addr = BIT ((31 - dev)) | (where & ~3);
  125. non_prefetch_write (addr, byteEnables | NP_CMD_CONFIGWRITE, ldata);
  126. return (OK);
  127. }
  128. int pci_write_config_word (pci_dev_t dev, int where, unsigned short val)
  129. {
  130. unsigned int addr;
  131. unsigned int byteEnables;
  132. unsigned int n;
  133. unsigned int ldata;
  134. n = where % 4;
  135. /*byte enables are 4 bits active low, the position of each
  136. bit maps to the byte that it enables */
  137. byteEnables =
  138. (~(BIT (n) | BIT ((n + 1)))) &
  139. IXP425_PCI_BOTTOM_NIBBLE_OF_LONG_MASK;
  140. byteEnables = byteEnables << PCI_NP_CBE_BESL;
  141. ldata = val << (8 * n);
  142. /*address bits 31:28 specify the device 10:8 specify the function */
  143. /*Set the address to be written */
  144. addr = BIT (31 - dev) | (where & ~3);
  145. non_prefetch_write (addr, byteEnables | NP_CMD_CONFIGWRITE, ldata);
  146. return (OK);
  147. }
  148. int pci_write_config_dword (pci_dev_t dev, int where, unsigned int val)
  149. {
  150. unsigned int addr;
  151. /*address bits 31:28 specify the device 10:8 specify the function */
  152. /*Set the address to be written */
  153. addr = BIT (31 - dev) | (where & ~3);
  154. non_prefetch_write (addr, NP_CMD_CONFIGWRITE, val);
  155. return (OK);
  156. }
  157. void non_prefetch_read (unsigned int addr,
  158. unsigned int cmd, unsigned int *data)
  159. {
  160. REG_WRITE (PCI_CSR_BASE, PCI_NP_AD_OFFSET, addr);
  161. /*set up and execute the read */
  162. REG_WRITE (PCI_CSR_BASE, PCI_NP_CBE_OFFSET, cmd);
  163. /*The result of the read is now in np_rdata */
  164. REG_READ (PCI_CSR_BASE, PCI_NP_RDATA_OFFSET, *data);
  165. return;
  166. }
  167. void non_prefetch_write (unsigned int addr,
  168. unsigned int cmd, unsigned int data)
  169. {
  170. REG_WRITE (PCI_CSR_BASE, PCI_NP_AD_OFFSET, addr);
  171. /*set up the write */
  172. REG_WRITE (PCI_CSR_BASE, PCI_NP_CBE_OFFSET, cmd);
  173. /*Execute the write by writing to NP_WDATA */
  174. REG_WRITE (PCI_CSR_BASE, PCI_NP_WDATA_OFFSET, data);
  175. return;
  176. }
  177. /*
  178. * PCI controller config registers are accessed through these functions
  179. * i.e. these allow us to set up our own BARs etc.
  180. */
  181. void crp_read (unsigned int offset, unsigned int *data)
  182. {
  183. REG_WRITE (PCI_CSR_BASE, PCI_CRP_AD_CBE_OFFSET, offset);
  184. REG_READ (PCI_CSR_BASE, PCI_CRP_RDATA_OFFSET, *data);
  185. }
  186. void crp_write (unsigned int offset, unsigned int data)
  187. {
  188. /*The CRP address register bit 16 indicates that we want to do a write */
  189. REG_WRITE (PCI_CSR_BASE, PCI_CRP_AD_CBE_OFFSET,
  190. PCI_CRP_WRITE | offset);
  191. REG_WRITE (PCI_CSR_BASE, PCI_CRP_WDATA_OFFSET, data);
  192. }
  193. /*struct pci_controller *hose*/
  194. void pci_ixp_init (struct pci_controller *hose)
  195. {
  196. unsigned int regval;
  197. hose->first_busno = 0;
  198. hose->last_busno = 0x00;
  199. /* System memory space */
  200. pci_set_region (hose->regions + 0,
  201. PCI_MEMORY_BUS,
  202. PCI_MEMORY_PHY, PCI_MEMORY_SIZE, PCI_REGION_SYS_MEMORY);
  203. /* PCI memory space */
  204. pci_set_region (hose->regions + 1,
  205. PCI_MEM_BUS,
  206. PCI_MEM_PHY, PCI_MEM_SIZE, PCI_REGION_MEM);
  207. /* PCI I/O space */
  208. pci_set_region (hose->regions + 2,
  209. PCI_IO_BUS, PCI_IO_PHY, PCI_IO_SIZE, PCI_REGION_IO);
  210. hose->region_count = 3;
  211. pci_register_hose (hose);
  212. /*
  213. ==========================================================
  214. Init IXP PCI
  215. ==========================================================
  216. */
  217. REG_READ (PCI_CSR_BASE, PCI_CSR_OFFSET, regval);
  218. regval |= 1 << 2;
  219. REG_WRITE (PCI_CSR_BASE, PCI_CSR_OFFSET, regval);
  220. configure_pins ();
  221. READ_GPIO_REG (IXP425_GPIO_GPOUTR, regval);
  222. WRITE_GPIO_REG (IXP425_GPIO_GPOUTR, regval & (~(1 << 13)));
  223. udelay (533);
  224. sys_pci_gpio_clock_config ();
  225. REG_WRITE (PCI_CSR_BASE, PCI_INTEN_OFFSET, 0);
  226. udelay (100);
  227. READ_GPIO_REG (IXP425_GPIO_GPOUTR, regval);
  228. WRITE_GPIO_REG (IXP425_GPIO_GPOUTR, regval | (1 << 13));
  229. udelay (533);
  230. crp_write (PCI_CFG_BASE_ADDRESS_0, IXP425_PCI_BAR_0_DEFAULT);
  231. crp_write (PCI_CFG_BASE_ADDRESS_1, IXP425_PCI_BAR_1_DEFAULT);
  232. crp_write (PCI_CFG_BASE_ADDRESS_2, IXP425_PCI_BAR_2_DEFAULT);
  233. crp_write (PCI_CFG_BASE_ADDRESS_3, IXP425_PCI_BAR_3_DEFAULT);
  234. crp_write (PCI_CFG_BASE_ADDRESS_4, IXP425_PCI_BAR_4_DEFAULT);
  235. crp_write (PCI_CFG_BASE_ADDRESS_5, IXP425_PCI_BAR_5_DEFAULT);
  236. /*Setup PCI-AHB and AHB-PCI address mappings */
  237. REG_WRITE (PCI_CSR_BASE, PCI_AHBMEMBASE_OFFSET,
  238. IXP425_PCI_AHBMEMBASE_DEFAULT);
  239. REG_WRITE (PCI_CSR_BASE, PCI_AHBIOBASE_OFFSET,
  240. IXP425_PCI_AHBIOBASE_DEFAULT);
  241. REG_WRITE (PCI_CSR_BASE, PCI_PCIMEMBASE_OFFSET,
  242. IXP425_PCI_PCIMEMBASE_DEFAULT);
  243. crp_write (PCI_CFG_SUB_VENDOR_ID, IXP425_PCI_SUB_VENDOR_SYSTEM);
  244. REG_READ (PCI_CSR_BASE, PCI_CSR_OFFSET, regval);
  245. regval |= PCI_CSR_IC | PCI_CSR_ABE | PCI_CSR_PDS;
  246. REG_WRITE (PCI_CSR_BASE, PCI_CSR_OFFSET, regval);
  247. crp_write (PCI_CFG_COMMAND, PCI_CFG_CMD_MAE | PCI_CFG_CMD_BME);
  248. udelay (1000);
  249. pci_write_config_word (0, PCI_CFG_COMMAND, INITIAL_PCI_CMD);
  250. REG_WRITE (PCI_CSR_BASE, PCI_ISR_OFFSET, PCI_ISR_PSE
  251. | PCI_ISR_PFE | PCI_ISR_PPE | PCI_ISR_AHBE);
  252. #ifdef CONFIG_PCI_SCAN_SHOW
  253. printf ("Device bus dev func deviceID vendorID \n");
  254. #endif
  255. pci_bus_scan ();
  256. }
  257. void configure_pins (void)
  258. {
  259. unsigned int regval;
  260. /* Disable clock on GPIO PIN 14 */
  261. READ_GPIO_REG (IXP425_GPIO_GPCLKR, regval);
  262. WRITE_GPIO_REG (IXP425_GPIO_GPCLKR, regval & (~(1 << 8)));
  263. READ_GPIO_REG (IXP425_GPIO_GPCLKR, regval);
  264. READ_GPIO_REG (IXP425_GPIO_GPOER, regval);
  265. WRITE_GPIO_REG (IXP425_GPIO_GPOER,
  266. (((~(3 << 13)) & regval) | (0xf << 8)));
  267. READ_GPIO_REG (IXP425_GPIO_GPOER, regval);
  268. READ_GPIO_REG (IXP425_GPIO_GPIT2R, regval);
  269. WRITE_GPIO_REG (IXP425_GPIO_GPIT2R,
  270. (regval &
  271. ((0x1 << 9) | (0x1 << 6) | (0x1 << 3) | 0x1)));
  272. READ_GPIO_REG (IXP425_GPIO_GPIT2R, regval);
  273. READ_GPIO_REG (IXP425_GPIO_GPISR, regval);
  274. WRITE_GPIO_REG (IXP425_GPIO_GPISR, (regval | (0xf << 8)));
  275. READ_GPIO_REG (IXP425_GPIO_GPISR, regval);
  276. }
  277. void sys_pci_gpio_clock_config (void)
  278. {
  279. unsigned int regval;
  280. READ_GPIO_REG (IXP425_GPIO_GPCLKR, regval);
  281. regval |= 0x1 << 4;
  282. WRITE_GPIO_REG (IXP425_GPIO_GPCLKR, regval);
  283. READ_GPIO_REG (IXP425_GPIO_GPCLKR, regval);
  284. regval |= 0x1 << 8;
  285. WRITE_GPIO_REG (IXP425_GPIO_GPCLKR, regval);
  286. }
  287. void pci_bus_scan (void)
  288. {
  289. unsigned int bus = 0, dev, func = 0;
  290. unsigned short data16;
  291. unsigned int data32;
  292. unsigned char intPin;
  293. /* Assign first device to ourselves */
  294. devices[0].bus = 0;
  295. devices[0].device = 0;
  296. devices[0].func = 0;
  297. crp_read (PCI_CFG_VENDOR_ID, &data32);
  298. devices[0].vendor_id = data32 & IXP425_PCI_BOTTOM_WORD_OF_LONG_MASK;
  299. devices[0].device_id = data32 >> 16;
  300. devices[0].error = FALSE;
  301. devices[0].bar[NO_BAR].size = 0; /*dummy - required */
  302. nDevices = 1;
  303. nMBars = 0;
  304. nIOBars = 0;
  305. for (dev = 0; dev < IXP425_PCI_MAX_DEV; dev++) {
  306. /*Check whether a device is present */
  307. if (pci_device_exists (dev) != TRUE) {
  308. /*Clear error bits in ISR, write 1 to clear */
  309. REG_WRITE (PCI_CSR_BASE, PCI_ISR_OFFSET, PCI_ISR_PSE
  310. | PCI_ISR_PFE | PCI_ISR_PPE |
  311. PCI_ISR_AHBE);
  312. continue;
  313. }
  314. /*A device is present, add an entry to the array */
  315. devices[nDevices].bus = bus;
  316. devices[nDevices].device = dev;
  317. devices[nDevices].func = func;
  318. pci_read_config_word (dev, PCI_CFG_VENDOR_ID, &data16);
  319. devices[nDevices].vendor_id = data16;
  320. pci_read_config_word (dev, PCI_CFG_DEVICE_ID, &data16);
  321. devices[nDevices].device_id = data16;
  322. /*The device is functioning correctly, set error to FALSE */
  323. devices[nDevices].error = FALSE;
  324. /*Figure out what BARs are on this device */
  325. sys_pci_bar_info_get (nDevices, bus, dev, func);
  326. /*Figure out what INTX# line the card uses */
  327. pci_read_config_byte (dev, PCI_CFG_DEV_INT_PIN, &intPin);
  328. /*assign the appropriate irq line */
  329. if (intPin > PCI_IRQ_LINES) {
  330. devices[nDevices].error = TRUE;
  331. } else if (intPin != 0) {
  332. /*This device uses an interrupt line */
  333. /*devices[nDevices].irq = ixp425PciIntTranslate[dev][intPin-1]; */
  334. devices[nDevices].irq = intPin;
  335. }
  336. #ifdef CONFIG_PCI_SCAN_SHOW
  337. printf ("%06d %03d %03d %04d %08d %08x\n", nDevices,
  338. devices[nDevices].vendor_id);
  339. #endif
  340. nDevices++;
  341. }
  342. calc_bars (memBars, nMBars, IXP425_PCI_BAR_MEM_BASE);
  343. sys_pci_device_bars_write ();
  344. REG_WRITE (PCI_CSR_BASE, PCI_ISR_OFFSET, PCI_ISR_PSE
  345. | PCI_ISR_PFE | PCI_ISR_PPE | PCI_ISR_AHBE);
  346. }
  347. void sys_pci_bar_info_get (unsigned int devnum,
  348. unsigned int bus,
  349. unsigned int dev, unsigned int func)
  350. {
  351. unsigned int data32;
  352. unsigned int tmp;
  353. unsigned int size;
  354. pci_write_config_dword (devnum,
  355. PCI_CFG_BASE_ADDRESS_0, IXP425_PCI_BAR_QUERY);
  356. pci_read_config_dword (devnum, PCI_CFG_BASE_ADDRESS_0, &data32);
  357. devices[devnum].bar[0].address = (data32 & 1);
  358. if (data32 & 1) {
  359. /* IO space */
  360. tmp = data32 & ~0x3;
  361. size = ~(tmp - 1);
  362. devices[devnum].bar[0].size = size;
  363. if (nIOBars < IXP425_PCI_MAX_BAR) {
  364. ioBars[nIOBars++] = &devices[devnum].bar[0];
  365. }
  366. } else {
  367. /* Mem space */
  368. tmp = data32 & ~IXP425_PCI_BOTTOM_NIBBLE_OF_LONG_MASK;
  369. size = ~(tmp - 1);
  370. devices[devnum].bar[0].size = size;
  371. if (nMBars < IXP425_PCI_MAX_BAR) {
  372. memBars[nMBars++] = &devices[devnum].bar[0];
  373. } else {
  374. devices[devnum].error = TRUE;
  375. }
  376. }
  377. devices[devnum].bar[1].size = 0;
  378. }
  379. void sortBars (PciBar * Bars[], unsigned int nBars)
  380. {
  381. unsigned int i, j;
  382. PciBar *tmp;
  383. if (nBars == 0) {
  384. return;
  385. }
  386. /* Sort biggest to smallest */
  387. for (i = 0; i < nBars - 1; i++) {
  388. for (j = i + 1; j < nBars; j++) {
  389. if (Bars[j]->size > Bars[i]->size) {
  390. /* swap them */
  391. tmp = Bars[i];
  392. Bars[i] = Bars[j];
  393. Bars[j] = tmp;
  394. }
  395. }
  396. }
  397. }
  398. void calc_bars (PciBar * Bars[], unsigned int nBars, unsigned int startAddr)
  399. {
  400. unsigned int i;
  401. if (nBars == 0) {
  402. return;
  403. }
  404. for (i = 0; i < nBars; i++) {
  405. Bars[i]->address |= startAddr;
  406. startAddr += Bars[i]->size;
  407. }
  408. }
  409. void sys_pci_device_bars_write (void)
  410. {
  411. unsigned int i;
  412. int addr;
  413. for (i = 1; i < nDevices; i++) {
  414. if (devices[i].error) {
  415. continue;
  416. }
  417. pci_write_config_dword (devices[i].device,
  418. PCI_CFG_BASE_ADDRESS_0,
  419. devices[i].bar[0].address);
  420. addr = BIT (31 - devices[i].device) |
  421. (0 << PCI_NP_AD_FUNCSL) |
  422. (PCI_CFG_BASE_ADDRESS_0 & ~3);
  423. pci_write_config_dword (devices[i].device,
  424. PCI_CFG_DEV_INT_LINE, devices[i].irq);
  425. pci_write_config_word (devices[i].device,
  426. PCI_CFG_COMMAND, INITIAL_PCI_CMD);
  427. }
  428. }
  429. int pci_device_exists (unsigned int deviceNo)
  430. {
  431. unsigned int vendorId;
  432. unsigned int regval;
  433. pci_read_config_dword (deviceNo, PCI_CFG_VENDOR_ID, &vendorId);
  434. /* There are two ways to find out an empty device.
  435. * 1. check Master Abort bit after the access.
  436. * 2. check whether the vendor id read back is 0x0.
  437. */
  438. REG_READ (PCI_CSR_BASE, PCI_ISR_OFFSET, regval);
  439. if ((vendorId != 0x0) && ((regval & PCI_ISR_PFE) == 0)) {
  440. return TRUE;
  441. }
  442. /*no device present, make sure that the master abort bit is reset */
  443. REG_WRITE (PCI_CSR_BASE, PCI_ISR_OFFSET, PCI_ISR_PFE);
  444. return FALSE;
  445. }
  446. pci_dev_t pci_find_devices (struct pci_device_id * ids, int devNo)
  447. {
  448. unsigned int i;
  449. unsigned int devdidvid;
  450. unsigned int didvid;
  451. unsigned int vendorId, deviceId;
  452. vendorId = ids->vendor;
  453. deviceId = ids->device;
  454. didvid = ((deviceId << 16) & IXP425_PCI_TOP_WORD_OF_LONG_MASK) |
  455. (vendorId & IXP425_PCI_BOTTOM_WORD_OF_LONG_MASK);
  456. for (i = devNo + 1; i < nDevices; i++) {
  457. pci_read_config_dword (devices[i].device, PCI_CFG_VENDOR_ID,
  458. &devdidvid);
  459. if (devdidvid == didvid) {
  460. return devices[i].device;
  461. }
  462. }
  463. return -1;
  464. }