2 * This file is part of the coreboot project.
4 * Copyright (C) 2004 Tyan Computer
5 * Written by Yinghai Lu <yhlu@tyan.com> for Tyan Computer.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
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.
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
21 #include <console/console.h>
22 #include <device/device.h>
23 #include <device/smbus.h>
24 #include <device/pci.h>
25 #include <device/pci_ids.h>
26 #include <device/pci_ops.h>
30 static void nic_init(struct device *dev)
32 u32 dword, old, mac_h, mac_l;
34 struct southbridge_nvidia_ck804_config *conf;
35 static u32 nic_index = 0;
39 res = find_resource(dev, 0x10);
40 base = (unsigned long)res->base;
42 #define NvRegPhyInterface 0xC0
43 #define PHY_RGMII 0x10000000
45 write32(base + NvRegPhyInterface, PHY_RGMII);
47 old = dword = pci_read_config32(dev, 0x30);
51 pci_write_config32(dev, 0x30, dword);
53 conf = dev->chip_info;
55 if (conf->mac_eeprom_smbus != 0) {
56 /* Read MAC address from EEPROM at first. */
57 struct device *dev_eeprom;
58 dev_eeprom = dev_find_slot_on_smbus(conf->mac_eeprom_smbus,
59 conf->mac_eeprom_addr);
62 /* If that is valid we will use that. */
65 for (i = 0; i < 6; i++) {
66 status = smbus_read_byte(dev_eeprom, i);
69 dat[i] = status & 0xff;
73 for (i = 3; i >= 0; i--) {
77 if (mac_l != 0xffffffff) {
80 for (i = 5; i >= 4; i--) {
90 /* If that is invalid we will read that from romstrap. */
92 unsigned long mac_pos;
93 mac_pos = 0xffffffd0; /* See romstrap.inc and romstrap.lds. */
94 mac_l = read32(mac_pos) + nic_index;
95 mac_h = read32(mac_pos + 4);
98 /* Set that into NIC MMIO. */
99 #define NvRegMacAddrA 0xA8
100 #define NvRegMacAddrB 0xAC
101 write32(base + NvRegMacAddrA, mac_l);
102 write32(base + NvRegMacAddrB, mac_h);
104 /* Set that into NIC. */
105 pci_write_config32(dev, 0xa8, mac_l);
106 pci_write_config32(dev, 0xac, mac_h);
111 #if CONFIG_PCI_ROM_RUN == 1
112 pci_dev_init(dev); /* It will init Option ROM. */
116 static struct device_operations nic_ops = {
117 .read_resources = pci_dev_read_resources,
118 .set_resources = pci_dev_set_resources,
119 .enable_resources = pci_dev_enable_resources,
122 // .enable = ck804_enable,
123 .ops_pci = &ck804_pci_ops,
126 static const struct pci_driver nic_driver __pci_driver = {
128 .vendor = PCI_VENDOR_ID_NVIDIA,
129 .device = PCI_DEVICE_ID_NVIDIA_CK804_NIC,
132 static const struct pci_driver nic_bridge_driver __pci_driver = {
134 .vendor = PCI_VENDOR_ID_NVIDIA,
135 .device = PCI_DEVICE_ID_NVIDIA_CK804_NIC_BRIDGE,