Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 1 | /* |
Uwe Hermann | c6a1062 | 2010-10-17 19:30:58 +0000 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2005 AMD |
| 5 | * Written by Yinghai Lu <yinghai.lu@amd.com> for AMD. |
| 6 | * |
| 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. |
| 10 | * |
| 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. |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 15 | */ |
Uwe Hermann | c6a1062 | 2010-10-17 19:30:58 +0000 | [diff] [blame] | 16 | |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 17 | #include <console/console.h> |
| 18 | #include <device/device.h> |
| 19 | #include <device/pci.h> |
| 20 | #include <device/pci_ids.h> |
| 21 | #include "bcm5785.h" |
| 22 | |
| 23 | void bcm5785_enable(device_t dev) |
| 24 | { |
| 25 | device_t sb_pci_main_dev; |
| 26 | device_t bus_dev; |
Stefan Reinauer | c51dc44 | 2010-04-07 01:44:04 +0000 | [diff] [blame] | 27 | // unsigned index; |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 28 | |
| 29 | /* See if we are on the behind the pcix bridge */ |
| 30 | bus_dev = dev->bus->dev; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 31 | if ((bus_dev->vendor == PCI_VENDOR_ID_SERVERWORKS) && |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 32 | (bus_dev->device == 0x0036 )) // device under PCI-X Bridge |
| 33 | { |
| 34 | unsigned devfn; |
Stefan Reinauer | 2b34db8 | 2009-02-28 20:10:20 +0000 | [diff] [blame] | 35 | devfn = bus_dev->path.pci.devfn + (1 << 3); |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 36 | sb_pci_main_dev = dev_find_slot(bus_dev->bus->secondary, devfn); |
Stefan Reinauer | c51dc44 | 2010-04-07 01:44:04 +0000 | [diff] [blame] | 37 | // index = ((dev->path.pci.devfn & ~7) >> 3) + 8; |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 38 | } else if ((bus_dev->vendor == PCI_VENDOR_ID_SERVERWORKS) && |
| 39 | (bus_dev->device == 0x0104)) // device under PCI Bridge( under PCI-X ) |
| 40 | { |
| 41 | unsigned devfn; |
Stefan Reinauer | 2b34db8 | 2009-02-28 20:10:20 +0000 | [diff] [blame] | 42 | devfn = bus_dev->bus->dev->path.pci.devfn + (1 << 3); |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 43 | sb_pci_main_dev = dev_find_slot(bus_dev->bus->dev->bus->secondary, devfn); |
Stefan Reinauer | c51dc44 | 2010-04-07 01:44:04 +0000 | [diff] [blame] | 44 | // index = ((dev->path.pci.devfn & ~7) >> 3) + 8; |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 45 | } |
| 46 | else { // same bus |
| 47 | unsigned devfn; |
Stefan Reinauer | 2b34db8 | 2009-02-28 20:10:20 +0000 | [diff] [blame] | 48 | devfn = (dev->path.pci.devfn) & ~7; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 49 | if( dev->vendor == PCI_VENDOR_ID_SERVERWORKS ) { |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 50 | if(dev->device == 0x0036) //PCI-X Bridge |
| 51 | { devfn += (1<<3); } |
| 52 | else if(dev->device == 0x0223) // USB |
| 53 | { devfn -= (1<<3); } |
| 54 | } |
| 55 | sb_pci_main_dev = dev_find_slot(dev->bus->secondary, devfn); |
Stefan Reinauer | c51dc44 | 2010-04-07 01:44:04 +0000 | [diff] [blame] | 56 | // index = dev->path.pci.devfn & 7; |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 57 | } |
| 58 | if (!sb_pci_main_dev) { |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | // get index now |
| 63 | #if 0 |
Stefan Reinauer | c51dc44 | 2010-04-07 01:44:04 +0000 | [diff] [blame] | 64 | unsigned reg_old, reg; |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 65 | if (index < 16) { |
| 66 | reg = reg_old = pci_read_config16(sb_pci_main_dev, 0x48); |
| 67 | reg &= ~(1 << index); |
| 68 | if (dev->enabled) { |
| 69 | reg |= (1 << index); |
| 70 | } |
| 71 | if (reg != reg_old) { |
| 72 | pci_write_config16(sb_pci_main_dev, 0x48, reg); |
| 73 | } |
| 74 | } |
| 75 | else if (index == 16) { |
| 76 | reg = reg_old = pci_read_config8(sb_pci_main_dev, 0x47); |
| 77 | reg &= ~(1 << 7); |
| 78 | if (!dev->enabled) { |
| 79 | reg |= (1 << 7); |
| 80 | } |
| 81 | if (reg != reg_old) { |
| 82 | pci_write_config8(sb_pci_main_dev, 0x47, reg); |
| 83 | } |
| 84 | } |
| 85 | #endif |
| 86 | } |
| 87 | |
| 88 | struct chip_operations southbridge_broadcom_bcm5785_ops = { |
Uwe Hermann | a7aa29b | 2006-11-05 18:50:49 +0000 | [diff] [blame] | 89 | CHIP_NAME("Serverworks BCM5785 Southbridge") |
Yinghai Lu | afd34e6 | 2006-02-16 17:22:19 +0000 | [diff] [blame] | 90 | .enable_dev = bcm5785_enable, |
| 91 | }; |