Joerg Fischer | 52a1549 | 2010-05-21 22:28:19 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the flashrom project. |
| 3 | * |
| 4 | * Copyright (C) 2009 Joerg Fischer <turboj@gmx.de> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
Carl-Daniel Hailfinger | cceafa2 | 2010-05-26 01:45:41 +0000 | [diff] [blame^] | 21 | #if defined(__i386__) || defined(__x86_64__) |
| 22 | |
Joerg Fischer | 52a1549 | 2010-05-21 22:28:19 +0000 | [diff] [blame] | 23 | #include <stdlib.h> |
| 24 | #include <string.h> |
| 25 | #include <sys/types.h> |
| 26 | #include "flash.h" |
| 27 | |
| 28 | #define PCI_VENDOR_ID_REALTEK 0x10ec |
| 29 | #define PCI_VENDOR_ID_SMC1211 0x1113 |
| 30 | |
| 31 | #define BIOS_ROM_ADDR 0xD4 |
| 32 | #define BIOS_ROM_DATA 0xD7 |
| 33 | |
| 34 | struct pcidev_status nics_realtek[] = { |
Uwe Hermann | 829ed84 | 2010-05-24 17:39:14 +0000 | [diff] [blame] | 35 | {0x10ec, 0x8139, OK, "Realtek", "RTL8139/8139C/8139C+"}, |
Joerg Fischer | 52a1549 | 2010-05-21 22:28:19 +0000 | [diff] [blame] | 36 | {}, |
| 37 | }; |
| 38 | |
| 39 | struct pcidev_status nics_realteksmc1211[] = { |
Uwe Hermann | 829ed84 | 2010-05-24 17:39:14 +0000 | [diff] [blame] | 40 | {0x1113, 0x1211, OK, "SMC2", "1211TX"}, /* RTL8139 clone */ |
| 41 | {}, |
Joerg Fischer | 52a1549 | 2010-05-21 22:28:19 +0000 | [diff] [blame] | 42 | }; |
| 43 | |
Joerg Fischer | 52a1549 | 2010-05-21 22:28:19 +0000 | [diff] [blame] | 44 | int nicrealtek_init(void) |
| 45 | { |
| 46 | get_io_perms(); |
Uwe Hermann | 829ed84 | 2010-05-24 17:39:14 +0000 | [diff] [blame] | 47 | |
Joerg Fischer | 52a1549 | 2010-05-21 22:28:19 +0000 | [diff] [blame] | 48 | io_base_addr = pcidev_init(PCI_VENDOR_ID_REALTEK, PCI_BASE_ADDRESS_0, |
Uwe Hermann | 829ed84 | 2010-05-24 17:39:14 +0000 | [diff] [blame] | 49 | nics_realtek, programmer_param); |
| 50 | |
Joerg Fischer | 52a1549 | 2010-05-21 22:28:19 +0000 | [diff] [blame] | 51 | buses_supported = CHIP_BUSTYPE_PARALLEL; |
| 52 | |
| 53 | return 0; |
| 54 | } |
| 55 | |
Joerg Fischer | 52a1549 | 2010-05-21 22:28:19 +0000 | [diff] [blame] | 56 | int nicsmc1211_init(void) |
| 57 | { |
| 58 | get_io_perms(); |
Uwe Hermann | 829ed84 | 2010-05-24 17:39:14 +0000 | [diff] [blame] | 59 | |
Joerg Fischer | 52a1549 | 2010-05-21 22:28:19 +0000 | [diff] [blame] | 60 | io_base_addr = pcidev_init(PCI_VENDOR_ID_SMC1211, PCI_BASE_ADDRESS_0, |
Uwe Hermann | 829ed84 | 2010-05-24 17:39:14 +0000 | [diff] [blame] | 61 | nics_realteksmc1211, programmer_param); |
| 62 | |
Joerg Fischer | 52a1549 | 2010-05-21 22:28:19 +0000 | [diff] [blame] | 63 | buses_supported = CHIP_BUSTYPE_PARALLEL; |
| 64 | |
| 65 | return 0; |
| 66 | } |
| 67 | |
| 68 | int nicrealtek_shutdown(void) |
| 69 | { |
| 70 | free(programmer_param); |
| 71 | pci_cleanup(pacc); |
| 72 | release_io_perms(); |
| 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | void nicrealtek_chip_writeb(uint8_t val, chipaddr addr) |
| 77 | { |
Uwe Hermann | 829ed84 | 2010-05-24 17:39:14 +0000 | [diff] [blame] | 78 | OUTL(((uint32_t)addr & 0x01FFFF) | 0x0A0000 | (val << 24), |
| 79 | io_base_addr + BIOS_ROM_ADDR); |
| 80 | OUTL(((uint32_t)addr & 0x01FFFF) | 0x1E0000 | (val << 24), |
| 81 | io_base_addr + BIOS_ROM_ADDR); |
Joerg Fischer | 52a1549 | 2010-05-21 22:28:19 +0000 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | uint8_t nicrealtek_chip_readb(const chipaddr addr) |
Joerg Fischer | 52a1549 | 2010-05-21 22:28:19 +0000 | [diff] [blame] | 85 | { |
Uwe Hermann | 829ed84 | 2010-05-24 17:39:14 +0000 | [diff] [blame] | 86 | uint8_t val; |
Joerg Fischer | 52a1549 | 2010-05-21 22:28:19 +0000 | [diff] [blame] | 87 | |
Uwe Hermann | 829ed84 | 2010-05-24 17:39:14 +0000 | [diff] [blame] | 88 | val = INB(io_base_addr + BIOS_ROM_DATA); |
| 89 | OUTL(((uint32_t)addr & 0x01FFFF) | 0x060000 | (val << 24), |
| 90 | io_base_addr + BIOS_ROM_ADDR); |
| 91 | |
| 92 | val = INB(io_base_addr + BIOS_ROM_DATA); |
| 93 | OUTL(((uint32_t)addr & 0x01FFFF) | 0x1E0000 | (val << 24), |
| 94 | io_base_addr + BIOS_ROM_ADDR); |
| 95 | |
| 96 | return val; |
Joerg Fischer | 52a1549 | 2010-05-21 22:28:19 +0000 | [diff] [blame] | 97 | } |
Carl-Daniel Hailfinger | cceafa2 | 2010-05-26 01:45:41 +0000 | [diff] [blame^] | 98 | |
| 99 | #else |
| 100 | #error PCI port I/O access is not supported on this architecture yet. |
| 101 | #endif |