3 * by yinghai.lu@amd.com
6 #include <console/console.h>
7 #include <device/device.h>
9 #include <device/pci.h>
10 #include <device/pci_ids.h>
11 #include <device/pci_ops.h>
16 static void sata_init(struct device *dev)
24 unsigned int mmio_base;
25 volatile unsigned int *mmio_reg;
28 if(!(dev->path.pci.devfn & 7)) { // only set it in Func0
29 byte = pci_read_config8(dev, 0x78);
31 pci_write_config8(dev, 0x78, byte);
33 res = find_resource(dev, 0x24);
37 mmio_base &= 0xfffffffc;
38 mmio_reg = (unsigned int *)( mmio_base + 0x10f0 );
39 * mmio_reg = 0x40000001;
40 mmio_reg = ( unsigned int *)( mmio_base + 0x8c );
41 * mmio_reg = 0x00ff2007;
43 * mmio_reg = 0x78592009;
45 * mmio_reg = 0x00082004;
47 * mmio_reg = 0x00002004;
52 printk(BIOS_DEBUG, "init PHY...\n");
54 mmio = base + 0x100 * i;
55 byte = read8(mmio + 0x40);
56 printk(BIOS_DEBUG, "port %d PHY status = %02x\n", i, byte);
57 if(byte & 0x4) {// bit 2 is set
58 byte = read8(mmio+0x48);
59 write8(mmio + 0x48, byte | 1);
60 write8(mmio + 0x48, byte & (~1));
61 byte = read8(mmio + 0x40);
62 printk(BIOS_DEBUG, "after reset port %d PHY status = %02x\n", i, byte);
71 static void lpci_set_subsystem(device_t dev, unsigned vendor, unsigned device)
73 pci_write_config32(dev, 0x40,
74 ((device & 0xffff) << 16) | (vendor & 0xffff));
76 static struct pci_operations lops_pci = {
77 .set_subsystem = lpci_set_subsystem,
80 static struct device_operations sata_ops = {
81 .read_resources = pci_dev_read_resources,
82 .set_resources = pci_dev_set_resources,
83 .enable_resources = pci_dev_enable_resources,
84 // .enable = bcm5785_enable,
90 static const struct pci_driver sata0_driver __pci_driver = {
92 .vendor = PCI_VENDOR_ID_SERVERWORKS,
93 .device = PCI_DEVICE_ID_SERVERWORKS_BCM5785_SATA,