2 * (C) 2003 Linux Networx, SuSE Linux AG
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>
13 unsigned int value_low, value_high;
16 static struct ioapicreg ioapicregvalues[] = {
17 #define ALL (0xff << 24)
19 #define DISABLED (1 << 16)
20 #define ENABLED (0 << 16)
21 #define TRIGGER_EDGE (0 << 15)
22 #define TRIGGER_LEVEL (1 << 15)
23 #define POLARITY_HIGH (0 << 13)
24 #define POLARITY_LOW (1 << 13)
25 #define PHYSICAL_DEST (0 << 11)
26 #define LOGICAL_DEST (1 << 11)
27 #define ExtINT (7 << 8)
31 /* IO-APIC virtual wire mode configuration */
32 /* mask, trigger, polarity, destination, delivery, vector */
33 { 0, ENABLED | TRIGGER_EDGE | POLARITY_HIGH | PHYSICAL_DEST | ExtINT, NONE},
43 { 10, DISABLED, NONE},
44 { 11, DISABLED, NONE},
45 { 12, DISABLED, NONE},
46 { 13, DISABLED, NONE},
47 { 14, DISABLED, NONE},
48 { 15, DISABLED, NONE},
49 { 16, DISABLED, NONE},
50 { 17, DISABLED, NONE},
51 { 18, DISABLED, NONE},
52 { 19, DISABLED, NONE},
53 { 20, DISABLED, NONE},
54 { 21, DISABLED, NONE},
55 { 22, DISABLED, NONE},
56 { 23, DISABLED, NONE},
57 /* Be careful and don't write past the end... */
60 static void setup_ioapic(void)
63 unsigned long value_low, value_high;
64 unsigned long ioapic_base = 0xfec00000;
65 volatile unsigned long *l;
66 struct ioapicreg *a = ioapicregvalues;
68 l = (unsigned long *) ioapic_base;
70 for (i = 0; i < sizeof(ioapicregvalues) / sizeof(ioapicregvalues[0]);
72 l[0] = (a->reg * 2) + 0x10;
75 l[0] = (a->reg *2) + 0x11;
78 if ((i==0) && (value_low == 0xffffffff)) {
79 printk_warning("IO APIC not responding.\n");
82 printk_spew("for IRQ, reg 0x%08x value 0x%08x 0x%08x\n",
83 a->reg, a->value_low, a->value_high);
87 static void lpc_init(struct device *dev)
93 printk_debug("lpc_init\n");
95 /* IO APIC initialization */
96 byte = pci_read_config8(dev, 0x4B);
98 pci_write_config8(dev, 0x4B, byte);
101 /* posted memory write enable */
102 byte = pci_read_config8(dev, 0x46);
103 pci_write_config8(dev, 0x46, byte | (1<<0));
106 /* Disable AC97 and Ethernet */
107 word = pci_read_config16(dev, 0x48);
108 pci_write_config16(dev, 0x48, word & ~((1<<5)|(1<<6)|(1<<9)));
112 /* power after power fail */
113 byte = pci_read_config8(dev, 0x43);
119 pci_write_config8(dev, 0x43, byte);
124 static void amd8111_lpc_read_resources(device_t dev)
128 /* Get the normal pci resources of this device */
129 pci_dev_read_resources(dev);
131 /* Find my place in the resource list */
132 reg = dev->resources;
134 /* Add an extra subtractive resource for both memory and I/O */
135 dev->resource[reg].base = 0;
136 dev->resource[reg].size = 0;
137 dev->resource[reg].align = 0;
138 dev->resource[reg].gran = 0;
139 dev->resource[reg].limit = 0;
140 dev->resource[reg].flags = IORESOURCE_IO | IORESOURCE_SUBTRACTIVE | IORESOURCE_SET;
141 dev->resource[reg].index = 0;
144 dev->resource[reg].base = 0;
145 dev->resource[reg].size = 0;
146 dev->resource[reg].align = 0;
147 dev->resource[reg].gran = 0;
148 dev->resource[reg].limit = 0;
149 dev->resource[reg].flags = IORESOURCE_MEM | IORESOURCE_SUBTRACTIVE | IORESOURCE_SET;
150 dev->resource[reg].index = 0;
153 dev->resources = reg;
156 static struct device_operations lpc_ops = {
157 .read_resources = amd8111_lpc_read_resources,
158 .set_resources = pci_dev_set_resources,
159 .enable_resources = pci_dev_enable_resources,
161 .scan_bus = walk_static_devices,
164 static struct pci_driver lpc_driver __pci_driver = {
166 .vendor = PCI_VENDOR_ID_AMD,
167 .device = PCI_DEVICE_ID_AMD_8111_ISA,