2 * Copyright 2004 Tyan Computer
5 #include <console/console.h>
6 #include <device/device.h>
7 #include <device/smbus.h>
8 #include <device/pci.h>
9 #include <device/pci_ids.h>
10 #include <device/pci_ops.h>
15 static void nic_init(struct device *dev)
18 uint32_t mac_h, mac_l;
20 struct southbridge_nvidia_ck804_config *conf;
22 static uint32_t nic_index = 0;
25 old = dword = pci_read_config32(dev, 0x30);
29 pci_write_config32(dev, 0x30 , dword);
32 conf = dev->chip_info;
34 if(conf->mac_eeprom_smbus != 0) {
35 // read MAC address from EEPROM at first
36 struct device *dev_eeprom;
37 dev_eeprom = dev_find_slot_on_smbus(conf->mac_eeprom_smbus, conf->mac_eeprom_addr);
40 // if that is valid we will use that
45 status = smbus_read_byte(dev_eeprom, i);
47 dat[i] = status & 0xff;
55 if(mac_l != 0xffffffff) {
67 // if that is invalid we will read that from romstrap
69 unsigned long mac_pos;
70 mac_pos = 0xffffffd0; // refer to romstrap.inc and romstrap.lds
71 mac_l = readl(mac_pos) + nic_index;
72 mac_h = readl(mac_pos + 4);
76 pci_write_config32(dev, 0xa8, mac_l);
77 pci_write_config32(dev, 0xac, mac_h);
81 #if CONFIG_PCI_ROM_RUN == 1
82 pci_dev_init(dev);// it will init option rom
87 static void lpci_set_subsystem(device_t dev, unsigned vendor, unsigned device)
89 pci_write_config32(dev, 0x40,
90 ((device & 0xffff) << 16) | (vendor & 0xffff));
93 static struct pci_operations lops_pci = {
94 .set_subsystem = lpci_set_subsystem,
97 static struct device_operations nic_ops = {
98 .read_resources = pci_dev_read_resources,
99 .set_resources = pci_dev_set_resources,
100 .enable_resources = pci_dev_enable_resources,
103 // .enable = ck804_enable,
104 .ops_pci = &lops_pci,
106 static struct pci_driver nic_driver __pci_driver = {
108 .vendor = PCI_VENDOR_ID_NVIDIA,
109 .device = PCI_DEVICE_ID_NVIDIA_CK804_NIC,
111 static struct pci_driver nic_bridge_driver __pci_driver = {
113 .vendor = PCI_VENDOR_ID_NVIDIA,
114 .device = PCI_DEVICE_ID_NVIDIA_CK804_NIC_BRIDGE,