2 * This file is part of the coreboot project.
4 * Copyright (C) 2009-2010 iWave Systems
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; version 2 of the License.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <arch/romcc_io.h>
23 #include <device/pci_def.h>
24 #include <device/pnp_def.h>
25 #include <cpu/x86/lapic.h>
29 * Restricted Access Regions:
31 * MCR - Message Control Register
33 * ----------------------------------------------------------------------------
34 * | | | Target | Write | |
35 * | Opcode | Port | register | byte | Reserved |
36 * | | | Address | Enables | |
37 * ----------------------------------------------------------------------------
39 * MDR - Message Data Register
41 * ----------------------------------------------------------------------------
45 * ----------------------------------------------------------------------------
48 #define MSG_OPCODE_READ 0xD0000000
49 #define MSG_OPCODE_WRITE 0xE0000000
54 int sch_port_access_read(int port, int reg, int bytes)
56 pci_write_config32(PCI_DEV(0, 0, 0), MCR,
57 (MSG_OPCODE_READ | (port << 16) | (reg << 8)));
58 return pci_read_config32(PCI_DEV(0, 0, 0), MDR);
61 void sch_port_access_write(int port, int reg, int bytes, long data)
63 pci_write_config32(PCI_DEV(0, 0, 0), MDR, data);
64 pci_write_config32(PCI_DEV(0, 0, 0), MCR,
65 (MSG_OPCODE_WRITE | (port << 16) | (reg << 8)));
66 pci_read_config32(PCI_DEV(0, 0, 0), MDR);
69 void sch_port_access_write_ram_cmd(int cmd, int port, int reg, int data)
71 pci_write_config32(PCI_DEV(0, 0, 0), MDR, data);
72 pci_write_config32(PCI_DEV(0, 0, 0), MCR,
73 ((cmd << 24) | (port << 16) | (reg << 8)));
74 pci_read_config32(PCI_DEV(0, 0, 0), MDR);