blob: 05ca871d89c12e6dcebb2034b653788d7672840c [file] [log] [blame]
Eric Biederman83b991a2003-10-11 06:20:25 +00001/*
2 * (C) 2003 Linux Networx
3 */
4#include <console/console.h>
5#include <device/device.h>
6#include <device/pci.h>
7#include <device/pci_ids.h>
8#include <device/pci_ops.h>
arch import user (historical)bc5be472005-07-06 16:48:04 +00009#include <arch/io.h>
Myles Watson43bb9cd2008-12-18 18:24:11 +000010#include <delay.h>
Eric Biederman83b991a2003-10-11 06:20:25 +000011#include "amd8111.h"
12
13
Kevin Paul Herbert4104e6c2015-02-25 00:36:51 -080014#define CMD3 0x54
arch import user (historical)bc5be472005-07-06 16:48:04 +000015
16typedef enum {
17 VAL3 = (1 << 31), /* VAL bit for byte 3 */
18 VAL2 = (1 << 23), /* VAL bit for byte 2 */
19 VAL1 = (1 << 15), /* VAL bit for byte 1 */
20 VAL0 = (1 << 7), /* VAL bit for byte 0 */
21}VAL_BITS;
22
23typedef enum {
24 /* VAL3 */
25 ASF_INIT_DONE_ALIAS = (1 << 29),
26 /* VAL2 */
27 JUMBO = (1 << 21),
Stefan Reinauer14e22772010-04-27 06:56:47 +000028 VSIZE = (1 << 20),
arch import user (historical)bc5be472005-07-06 16:48:04 +000029 VLONLY = (1 << 19),
Stefan Reinauer14e22772010-04-27 06:56:47 +000030 VL_TAG_DEL = (1 << 18),
arch import user (historical)bc5be472005-07-06 16:48:04 +000031 /* VAL1 */
Stefan Reinauer14e22772010-04-27 06:56:47 +000032 EN_PMGR = (1 << 14),
arch import user (historical)bc5be472005-07-06 16:48:04 +000033 INTLEVEL = (1 << 13),
Stefan Reinauer14e22772010-04-27 06:56:47 +000034 FORCE_FULL_DUPLEX = (1 << 12),
35 FORCE_LINK_STATUS = (1 << 11),
36 APEP = (1 << 10),
37 MPPLBA = (1 << 9),
arch import user (historical)bc5be472005-07-06 16:48:04 +000038 /* VAL0 */
Stefan Reinauer14e22772010-04-27 06:56:47 +000039 RESET_PHY_PULSE = (1 << 2),
40 RESET_PHY = (1 << 1),
41 PHY_RST_POL = (1 << 0),
arch import user (historical)bc5be472005-07-06 16:48:04 +000042}CMD3_BITS;
43
44static void nic_init(struct device *dev)
45{
46 struct southbridge_amd_amd8111_config *conf;
47 struct resource *resource;
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080048 u8 *mmio;
arch import user (historical)bc5be472005-07-06 16:48:04 +000049
50 conf = dev->chip_info;
51 resource = find_resource(dev, PCI_BASE_ADDRESS_0);
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080052 mmio = res2mmio(resource, 0, 0);
arch import user (historical)bc5be472005-07-06 16:48:04 +000053
54 /* Hard Reset PHY */
Paul Menzel4159a802013-07-14 00:24:31 +020055 printk(BIOS_DEBUG, "Resetting PHY... ");
arch import user (historical)bc5be472005-07-06 16:48:04 +000056 if (conf->phy_lowreset) {
Stefan Reinauer50776fa2010-03-17 04:40:15 +000057 write32((mmio + CMD3), VAL0 | PHY_RST_POL | RESET_PHY);
arch import user (historical)bc5be472005-07-06 16:48:04 +000058 } else {
Stefan Reinauer50776fa2010-03-17 04:40:15 +000059 write32((mmio + CMD3), VAL0 | RESET_PHY);
arch import user (historical)bc5be472005-07-06 16:48:04 +000060 }
61 mdelay(15);
Stefan Reinauer50776fa2010-03-17 04:40:15 +000062 write32((mmio + CMD3), RESET_PHY);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000063 printk(BIOS_DEBUG, "Done\n");
arch import user (historical)bc5be472005-07-06 16:48:04 +000064}
65
66static void lpci_set_subsystem(device_t dev, unsigned vendor, unsigned device)
67{
68 pci_write_config32(dev, 0xc8,
69 ((device & 0xffff) << 16) | (vendor & 0xffff));
70}
71
72static struct pci_operations lops_pci = {
73 .set_subsystem = lpci_set_subsystem,
74};
Stefan Reinauer14e22772010-04-27 06:56:47 +000075
Eric Biederman83b991a2003-10-11 06:20:25 +000076static struct device_operations nic_ops = {
77 .read_resources = pci_dev_read_resources,
78 .set_resources = pci_dev_set_resources,
79 .enable_resources = pci_dev_enable_resources,
arch import user (historical)bc5be472005-07-06 16:48:04 +000080 .init = nic_init,
Eric Biederman83b991a2003-10-11 06:20:25 +000081 .scan_bus = 0,
arch import user (historical)bc5be472005-07-06 16:48:04 +000082 .enable = amd8111_enable,
83 .ops_pci = &lops_pci,
Eric Biederman83b991a2003-10-11 06:20:25 +000084};
85
Stefan Reinauerf1cf1f72007-10-24 09:08:58 +000086static const struct pci_driver nic_driver __pci_driver = {
Eric Biederman83b991a2003-10-11 06:20:25 +000087 .ops = &nic_ops,
88 .vendor = PCI_VENDOR_ID_AMD,
arch import user (historical)bc5be472005-07-06 16:48:04 +000089 .device = PCI_DEVICE_ID_AMD_8111_NIC,
Eric Biederman83b991a2003-10-11 06:20:25 +000090};