Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 9 | f9daq | 1 | //**************************************************************************** |
| 2 | // Copyright (C) 2000-2004 ARW Elektronik Germany |
||
| 3 | // |
||
| 4 | // |
||
| 5 | // This program is free software; you can redistribute it and/or modify |
||
| 6 | // it under the terms of the GNU General Public License as published by |
||
| 7 | // the Free Software Foundation; either version 2 of the License, or |
||
| 8 | // (at your option) any later version. |
||
| 9 | // |
||
| 10 | // This program is distributed in the hope that it will be useful, |
||
| 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 13 | // GNU General Public License for more details. |
||
| 14 | // |
||
| 15 | // You should have received a copy of the GNU General Public License |
||
| 16 | // along with this program; if not, write to the Free Software |
||
| 17 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||
| 18 | // |
||
| 19 | // This product is not authorized for use as critical component in |
||
| 20 | // life support systems without the express written approval of |
||
| 21 | // ARW Elektronik Germany. |
||
| 22 | // |
||
| 23 | // Please announce changes and hints to ARW Elektronik |
||
| 24 | // |
||
| 25 | // Maintainer(s): Klaus Hitschler (klaus.hitschler@gmx.de) |
||
| 26 | // |
||
| 27 | //**************************************************************************** |
||
| 28 | |||
| 29 | //**************************************************************************** |
||
| 30 | // |
||
| 31 | // plxbug.c -- plx 9050 bug fix code the PCIVME PCI to VME Interface |
||
| 32 | // |
||
| 33 | // $Log: plxbug.c,v $ |
||
| 34 | // Revision 1.6 2004/08/13 19:23:26 klaus |
||
| 35 | // conversion to kernel-version 2.6, released version 3.0 |
||
| 36 | // |
||
| 37 | // Revision 1.5 2002/10/18 21:56:28 klaus |
||
| 38 | // completed functional features, untested |
||
| 39 | // |
||
| 40 | // Revision 1.4 2002/10/18 21:56:28 klaus |
||
| 41 | // completed functional features, untested |
||
| 42 | // |
||
| 43 | // Revision 1.3 2002/10/10 18:57:46 klaus |
||
| 44 | // source beautyfied |
||
| 45 | // |
||
| 46 | //**************************************************************************** |
||
| 47 | |||
| 48 | #include "common.h" /* must be the first include */ |
||
| 49 | |||
| 50 | #include <asm/types.h> |
||
| 51 | #include "plxbug.h" |
||
| 52 | #include "main.h" |
||
| 53 | |||
| 54 | /*------------------------------------------------------------------------- |
||
| 55 | // DEFINES |
||
| 56 | */ |
||
| 57 | #define PCR_MEMORY_BUG 0x00 // 1st PCR index of potential bug |
||
| 58 | #define PCR_IO_BUG 0x01 // 2nd PCR index of potential bug |
||
| 59 | #define PCR_MEMORY_OK 0x04 // 1st PCR index of no bug |
||
| 60 | #define PCR_IO_OK 0x05 // 2nd PCR index of no bug |
||
| 61 | |||
| 62 | //------------------------------------------------------------------------- |
||
| 63 | // EXTERNALS |
||
| 64 | |||
| 65 | //------------------------------------------------------------------------- |
||
| 66 | // function to call for bug fix |
||
| 67 | |||
| 68 | |||
| 69 | // fixes address of LCR through change in address windows - updates PCIConfigHeader |
||
| 70 | int PLX9050BugFix(PCIConfig *pHeader) |
||
| 71 | { |
||
| 72 | u32 dwDataBug; |
||
| 73 | u32 dwDataOK; |
||
| 74 | int result = 0; |
||
| 75 | |||
| 76 | if (pHeader->pciDev->resource[PCR_MEMORY_BUG].start & 0x80) |
||
| 77 | { |
||
| 78 | result = pci_read_config_dword(pHeader->pciDev, PCI_BASE_ADDRESS_0, &dwDataBug); |
||
| 79 | if (result) |
||
| 80 | goto fail; |
||
| 81 | |||
| 82 | result = pci_read_config_dword(pHeader->pciDev, PCI_BASE_ADDRESS_4, &dwDataOK); |
||
| 83 | if (result) |
||
| 84 | goto fail; |
||
| 85 | |||
| 86 | result = pci_write_config_dword(pHeader->pciDev, PCI_BASE_ADDRESS_0, dwDataOK); |
||
| 87 | if (result) |
||
| 88 | goto fail; |
||
| 89 | |||
| 90 | result = pci_write_config_dword(pHeader->pciDev, PCI_BASE_ADDRESS_4, dwDataBug); |
||
| 91 | if (result) |
||
| 92 | goto fail; |
||
| 93 | |||
| 94 | // put changes in structures, too |
||
| 95 | dwDataBug = pHeader->pciDev->resource[PCR_MEMORY_BUG].start; |
||
| 96 | dwDataOK = pHeader->pciDev->resource[PCR_MEMORY_OK].start; |
||
| 97 | |||
| 98 | pHeader->pciDev->resource[PCR_MEMORY_BUG].start = dwDataOK; |
||
| 99 | pHeader->pciDev->resource[PCR_MEMORY_OK].start = dwDataBug; |
||
| 100 | |||
| 101 | PRINTK(KERN_DEBUG "%s : bugfix memory done.\n", DEVICE_NAME); |
||
| 102 | } |
||
| 103 | |||
| 104 | if (pHeader->pciDev->resource[PCR_IO_BUG].start & 0x80) |
||
| 105 | { |
||
| 106 | result = pci_read_config_dword(pHeader->pciDev, PCI_BASE_ADDRESS_1, &dwDataBug); |
||
| 107 | if (result) |
||
| 108 | goto fail; |
||
| 109 | |||
| 110 | result = pci_read_config_dword(pHeader->pciDev, PCI_BASE_ADDRESS_5, &dwDataOK); |
||
| 111 | if (result) |
||
| 112 | goto fail; |
||
| 113 | |||
| 114 | result = pci_write_config_dword(pHeader->pciDev, PCI_BASE_ADDRESS_1, dwDataOK); |
||
| 115 | if (result) |
||
| 116 | goto fail; |
||
| 117 | |||
| 118 | result = pci_write_config_dword(pHeader->pciDev, PCI_BASE_ADDRESS_5, dwDataBug); |
||
| 119 | if (result) |
||
| 120 | goto fail; |
||
| 121 | |||
| 122 | // put changes in structures, too |
||
| 123 | dwDataBug = pHeader->pciDev->resource[PCR_IO_BUG].start; |
||
| 124 | dwDataOK = pHeader->pciDev->resource[PCR_IO_OK].start; |
||
| 125 | |||
| 126 | pHeader->pciDev->resource[PCR_IO_BUG].start = dwDataOK; |
||
| 127 | pHeader->pciDev->resource[PCR_IO_OK].start = dwDataBug; |
||
| 128 | |||
| 129 | PRINTK(KERN_DEBUG "%s : bugfix io done.\n", DEVICE_NAME); |
||
| 130 | } |
||
| 131 | |||
| 132 | fail: |
||
| 133 | if (result) |
||
| 134 | printk(KERN_ERR "%s : PCI-error %d!\n", DEVICE_NAME, result); |
||
| 135 | |||
| 136 | return result; |
||
| 137 | } |
||
| 138 |