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;
27 res = find_resource(dev, 0x10);
31 #define NvRegPhyInterface 0xC0
32 #define PHY_RGMII 0x10000000
34 writel(PHY_RGMII, base + NvRegPhyInterface);
36 old = dword = pci_read_config32(dev, 0x30);
40 pci_write_config32(dev, 0x30 , dword);
43 conf = dev->chip_info;
45 if(conf->mac_eeprom_smbus != 0) {
46 // read MAC address from EEPROM at first
47 struct device *dev_eeprom;
48 dev_eeprom = dev_find_slot_on_smbus(conf->mac_eeprom_smbus, conf->mac_eeprom_addr);
51 // if that is valid we will use that
56 status = smbus_read_byte(dev_eeprom, i);
58 dat[i] = status & 0xff;
66 if(mac_l != 0xffffffff) {
78 // if that is invalid we will read that from romstrap
80 unsigned long mac_pos;
81 mac_pos = 0xffffffd0; // refer to romstrap.inc and romstrap.lds
82 mac_l = readl(mac_pos) + nic_index;
83 mac_h = readl(mac_pos + 4);
86 // set that into NIC MMIO
87 #define NvRegMacAddrA 0xA8
88 #define NvRegMacAddrB 0xAC
89 writel(mac_l, base + NvRegMacAddrA);
90 writel(mac_h, base + NvRegMacAddrB);
93 pci_write_config32(dev, 0xa8, mac_l);
94 pci_write_config32(dev, 0xac, mac_h);
99 #if CONFIG_PCI_ROM_RUN == 1
100 pci_dev_init(dev);// it will init option rom
105 static void lpci_set_subsystem(device_t dev, unsigned vendor, unsigned device)
107 pci_write_config32(dev, 0x40,
108 ((device & 0xffff) << 16) | (vendor & 0xffff));
111 static struct pci_operations lops_pci = {
112 .set_subsystem = lpci_set_subsystem,
115 static struct device_operations nic_ops = {
116 .read_resources = pci_dev_read_resources,
117 .set_resources = pci_dev_set_resources,
118 .enable_resources = pci_dev_enable_resources,
121 // .enable = ck804_enable,
122 .ops_pci = &lops_pci,
124 static struct pci_driver nic_driver __pci_driver = {
126 .vendor = PCI_VENDOR_ID_NVIDIA,
127 .device = PCI_DEVICE_ID_NVIDIA_CK804_NIC,
129 static struct pci_driver nic_bridge_driver __pci_driver = {
131 .vendor = PCI_VENDOR_ID_NVIDIA,
132 .device = PCI_DEVICE_ID_NVIDIA_CK804_NIC_BRIDGE,