make INT[EFGH]# of vt8237 configurable as gpio via devicetree
[coreboot.git] / src / southbridge / via / vt8237r / lpc.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007, 2008 Rudolf Marek <r.marek@assembler.cz>
5  * Copyright (C) 2009 Jon Harrison <bothlyn@blueyonder.co.uk>
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.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19  */
20
21 /* Inspiration from other VIA SB code. */
22
23 #include <arch/io.h>
24 #include <console/console.h>
25 #include <device/device.h>
26 #include <device/pci.h>
27 #include <device/pci_ids.h>
28 #include <pc80/mc146818rtc.h>
29 #include <arch/ioapic.h>
30 #include <cpu/x86/lapic.h>
31 #include <cpu/cpu.h>
32 #include <pc80/keyboard.h>
33 #include <pc80/i8259.h>
34 #include <stdlib.h>
35 #include <arch/acpi.h>
36 #include "vt8237r.h"
37 #include "chip.h"
38
39 static void southbridge_init_common(struct device *dev);
40
41 #if CONFIG_EPIA_VT8237R_INIT
42                    /* Interrupts for  INT# A   B   C   D */
43 static const unsigned char pciIrqs[4]  = { 10, 11, 12, 0};
44
45             /* Interrupt Assignments for Pins   1   2   3   4  */
46 static const unsigned char sataPins[4] =     { 'A','B','C','D'};
47 static const unsigned char vgaPins[4] =      { 'A','B','C','D'};
48 static const unsigned char usbPins[4] =      { 'A','B','C','D'};
49 static const unsigned char enetPins[4] =     { 'A','B','C','D'};
50 static const unsigned char vt8237Pins[4] =   { 'A','B','C','D'};
51 static const unsigned char slotPins[4] =     { 'C','D','A','B'};
52 static const unsigned char riserPins[4] =    { 'D','C','B','A'};
53
54 static unsigned char *pin_to_irq(const unsigned char *pin)
55 {
56         static unsigned char Irqs[4];
57         int i;
58         for (i = 0 ; i < 4 ; i++)
59                 Irqs[i] = pciIrqs[ pin[i] - 'A' ];
60
61         return Irqs;
62 }
63 #endif
64
65 /** Set up PCI IRQ routing, route everything through APIC. */
66 static void pci_routing_fixup(struct device *dev)
67 {
68 #if CONFIG_EPIA_VT8237R_INIT
69         device_t pdev;
70 #endif
71
72         /* PCI PNP Interrupt Routing INTE/F - disable */
73         pci_write_config8(dev, 0x44, 0x00);
74
75         /* PCI PNP Interrupt Routing INTG/H - disable */
76         pci_write_config8(dev, 0x45, 0x00);
77
78         /* Gate Interrupts until RAM Writes are flushed */
79         pci_write_config8(dev, 0x49, 0x20);
80
81 #if CONFIG_EPIA_VT8237R_INIT
82
83         /* Share INTE-INTH with INTA-INTD as per stock BIOS. */
84         pci_write_config8(dev, 0x46, 0x00);
85
86         /* setup PCI IRQ routing (For PCI Slot)*/
87         pci_write_config8(dev, 0x55, pciIrqs[0] << 4);
88         pci_write_config8(dev, 0x56, pciIrqs[1] | (pciIrqs[2] << 4) );
89         pci_write_config8(dev, 0x57, pciIrqs[3] << 4);
90
91         /* PCI Routing Fixup */
92
93         //Setup MiniPCI Slot
94         pci_assign_irqs(0, 0x14, pin_to_irq(slotPins));
95
96         // Via 2 slot riser card 2nd slot
97         pci_assign_irqs(0, 0x13, pin_to_irq(riserPins));
98
99         //Setup USB
100         pci_assign_irqs(0, 0x10, pin_to_irq(usbPins));
101
102         //Setup VT8237R Sound
103         pci_assign_irqs(0, 0x11, pin_to_irq(vt8237Pins));
104
105         //Setup Ethernet
106         pci_assign_irqs(0, 0x12, pin_to_irq(enetPins));
107
108         //Setup VGA
109         pci_assign_irqs(1, 0x00, pin_to_irq(vgaPins));
110
111         /* APIC Routing Fixup */
112
113         // Setup SATA
114         pdev = dev_find_device(PCI_VENDOR_ID_VIA,
115                                 PCI_DEVICE_ID_VIA_VT6420_SATA, 0);
116         pci_write_config8(pdev, PCI_INTERRUPT_PIN, 0x02);
117         pci_assign_irqs(0, 0x0f, pin_to_irq(sataPins));
118
119
120         // Setup PATA Override
121         pdev = dev_find_device(PCI_VENDOR_ID_VIA,
122                                 PCI_DEVICE_ID_VIA_82C586_1, 0);
123         pci_write_config8(pdev, PCI_INTERRUPT_PIN, 0x01);
124         pci_write_config8(pdev, PCI_INTERRUPT_LINE, 0xFF);
125
126 #else
127         /* Route INTE-INTH through registers above, no map to INTA-INTD. */
128         pci_write_config8(dev, 0x46, 0x10);
129
130         /* PCI Interrupt Polarity */
131         pci_write_config8(dev, 0x54, 0x00);
132
133         /* PCI INTA# Routing */
134         pci_write_config8(dev, 0x55, 0x00);
135
136         /* PCI INTB#/C# Routing */
137         pci_write_config8(dev, 0x56, 0x00);
138
139         /* PCI INTD# Routing */
140         pci_write_config8(dev, 0x57, 0x00);
141 #endif
142 }
143
144
145
146 /**
147  * Set up the power management capabilities directly into ACPI mode.
148  * This avoids having to handle any System Management Interrupts (SMIs).
149  */
150
151 static void setup_pm(device_t dev)
152 {
153         u16 tmp;
154         /* Debounce LID and PWRBTN# Inputs for 16ms. */
155         pci_write_config8(dev, 0x80, 0x20);
156
157         /* Set ACPI base address to I/O VT8237R_ACPI_IO_BASE. */
158         pci_write_config16(dev, 0x88, VT8237R_ACPI_IO_BASE | 0x1);
159
160         /* Set ACPI to 9, must set IRQ 9 override to level! Set PSON gating. */
161         pci_write_config8(dev, 0x82, 0x40 | VT8237R_ACPI_IRQ);
162
163 #if CONFIG_EPIA_VT8237R_INIT
164         /* Primary interupt channel, define wake events 0=IRQ0 15=IRQ15 1=en. */
165         pci_write_config16(dev, 0x84, 0x3052);
166 #else
167         /* Primary interupt channel, define wake events 0=IRQ0 15=IRQ15 1=en. */
168         pci_write_config16(dev, 0x84, 0x30b2);
169
170 #endif
171         /* SMI output level to low, 7.5us throttle clock */
172         pci_write_config8(dev, 0x8d, 0x18);
173
174         /* GP Timer Control 1s */
175         pci_write_config8(dev, 0x93, 0x88);
176
177         /*
178          * 7 = SMBus clock from RTC 32.768KHz
179          * 5 = Internal PLL reset from susp disabled
180          * 2 = GPO2 is SUSA#
181          */
182         pci_write_config8(dev, 0x94, 0xa0);
183
184         /*
185          * 7 = stp to sust delay 1msec
186          * 6 = SUSST# Deasserted Before PWRGD for STD
187          * 5 = Keyboard/Mouse Swap
188          * 4 = PWRGOOD reset on VT8237A/S
189          * 3 = GPO26/GPO27 is GPO
190          * 2 = Disable Alert on Lan
191          * 1 = SUSCLK/GPO4
192          * 0 = USB Wakeup
193          */
194
195 #if CONFIG_EPIA_VT8237R_INIT
196         pci_write_config8(dev, 0x95, 0xc2);
197 #else
198         pci_write_config8(dev, 0x95, 0xcc);
199 #endif
200
201         /* Disable GP3 timer. */
202         pci_write_config8(dev, 0x98, 0);
203
204         /* Enable ACPI accessm RTC signal gated with PSON. */
205         pci_write_config8(dev, 0x81, 0x84);
206
207         /* Clear status events. */
208         outw(0xffff, VT8237R_ACPI_IO_BASE + 0x00);
209         outw(0xffff, VT8237R_ACPI_IO_BASE + 0x20);
210         outw(0xffff, VT8237R_ACPI_IO_BASE + 0x28);
211         outl(0xffffffff, VT8237R_ACPI_IO_BASE + 0x30);
212
213         /* Disable SCI on GPIO. */
214         outw(0x0, VT8237R_ACPI_IO_BASE + 0x22);
215
216         /* Disable SMI on GPIO. */
217         outw(0x0, VT8237R_ACPI_IO_BASE + 0x24);
218
219         /* Disable all global enable SMIs, except SW SMI */
220         outw(0x40, VT8237R_ACPI_IO_BASE + 0x2a);
221
222         /* Primary activity SMI disable. */
223         outl(0x0, VT8237R_ACPI_IO_BASE + 0x34);
224
225         /* GP timer reload on none. */
226         outl(0x0, VT8237R_ACPI_IO_BASE + 0x38);
227
228         /* Disable extended IO traps. */
229         outb(0x0, VT8237R_ACPI_IO_BASE + 0x42);
230
231         /* SCI is generated for RTC/pwrBtn/slpBtn. */
232         tmp = inw(VT8237R_ACPI_IO_BASE + 0x04);
233 #if CONFIG_HAVE_ACPI_RESUME == 1
234         acpi_slp_type = ((tmp & (7 << 10)) >> 10) == 1 ? 3 : 0 ;
235         printk(BIOS_DEBUG, "SLP_TYP type was %x %x\n", tmp, acpi_slp_type);
236 #endif
237
238         /* All SMI on, both IDE buses ON, PSON rising edge. */
239         outw(0x1, VT8237R_ACPI_IO_BASE + 0x2c);
240
241         /* clear sleep */
242         tmp &= ~(7 << 10);
243         tmp |= 1;
244         outw(tmp, VT8237R_ACPI_IO_BASE + 0x04);
245 }
246
247 static void vt8237r_init(struct device *dev)
248 {
249         u8 enables;
250
251 #if CONFIG_EPIA_VT8237R_INIT
252         printk(BIOS_SPEW, "Entering vt8237r_init, for EPIA.\n");
253         /*
254          * TODO: Looks like stock BIOS can do this but causes a hang
255          * Enable SATA LED, disable special CPU Frequency Change -
256          * GPIO28 GPIO22 GPIO29 GPIO23 are GPIOs.
257          * Setup to match EPIA default
258          * PCS0# on Pin U1
259          */
260         enables = pci_read_config8(dev, 0xe5);
261         enables |= 0x23;
262         pci_write_config8(dev, 0xe5, enables);
263
264         /*
265          * Enable Flash Write Access.
266          * Note EPIA-N Does not use REQ5 or PCISTP#(Hang)
267          */
268         enables = pci_read_config8(dev, 0xe4);
269         enables |= 0x2B;
270         pci_write_config8(dev, 0xe4, enables);
271
272         /* Enables Extra RTC Ports */
273         enables = pci_read_config8(dev, 0x4E);
274         enables |= 0x80;
275         pci_write_config8(dev, 0x4E, enables);
276
277 #else
278         printk(BIOS_SPEW, "Entering vt8237r_init.\n");
279         /*
280          * Enable SATA LED, disable special CPU Frequency Change -
281          * GPIO28 GPIO22 GPIO29 GPIO23 are GPIOs.
282          */
283         pci_write_config8(dev, 0xe5, 0x09);
284
285         /* REQ5 as PCI request input - should be together with INTE-INTH. */
286         pci_write_config8(dev, 0xe4, 0x4);
287 #endif
288
289         /* Set bit 3 of 0x4f (use INIT# as CPU reset). */
290         enables = pci_read_config8(dev, 0x4f);
291         enables |= 0x08;
292         pci_write_config8(dev, 0x4f, enables);
293
294 #if CONFIG_EPIA_VT8237R_INIT
295         /*
296          * Set Read Pass Write Control Enable
297          */
298         pci_write_config8(dev, 0x48, 0x0c);
299 #else
300
301   #if CONFIG_SOUTHBRIDGE_VIA_K8T800 || CONFIG_SOUTHBRIDGE_VIA_K8T800_OLD
302         /* It seems that when we pair with the K8T800, we need to disable
303          * the A2 mask
304          */
305         pci_write_config8(dev, 0x48, 0x0c);
306   #else
307         /*
308          * Set Read Pass Write Control Enable
309          * (force A2 from APIC FSB to low).
310          */
311         pci_write_config8(dev, 0x48, 0x8c);
312   #endif
313
314 #endif
315
316         southbridge_init_common(dev);
317
318 #if !CONFIG_EPIA_VT8237R_INIT
319         /* FIXME: Intel needs more bit set for C2/C3. */
320
321         /*
322          * Allow SLP# signal to assert LDTSTOP_L.
323          * Will work for C3 and for FID/VID change.
324          */
325         outb(0x1, VT8237R_ACPI_IO_BASE + 0x11);
326 #endif
327
328         printk(BIOS_SPEW, "Leaving %s.\n", __func__);
329         printk(BIOS_SPEW, "And taking a dump:\n");
330         dump_south(dev);
331 }
332
333 static void vt8237a_init(struct device *dev)
334 {
335         /*
336          * FIXME: This is based on vt8237s_init() and the values the AMI
337          *        BIOS on my M2V wrote to these registers (by loking
338          *        at lspci -nxxx output).
339          *        Works for me.
340          */
341         u32 tmp;
342
343         /* Set bit 3 of 0x4f (use INIT# as CPU reset). */
344         tmp = pci_read_config8(dev, 0x4f);
345         tmp |= 0x08;
346         pci_write_config8(dev, 0x4f, tmp);
347
348         /*
349          * bit2: REQ5 as PCI request input - should be together with INTE-INTH.
350          * bit5: usb power control lines as gpio
351          */
352         pci_write_config8(dev, 0xe4, 0x24);
353         /*
354          * Enable APIC wakeup from INTH
355          * Enable SATA LED, disable special CPU Frequency Change -
356          * GPIO28 GPIO22 GPIO29 GPIO23 are GPIOs.
357          */
358         pci_write_config8(dev, 0xe5, 0x69);
359
360         /* Reduce further the STPCLK/LDTSTP signal to 5us. */
361         pci_write_config8(dev, 0xec, 0x4);
362
363         /* Host Bus Power Management Control, maybe not needed */
364         pci_write_config8(dev, 0x8c, 0x5);
365
366         /* Enable HPET at VT8237R_HPET_ADDR. */
367         pci_write_config32(dev, 0x68, (VT8237R_HPET_ADDR | 0x80));
368
369         southbridge_init_common(dev);
370
371         /* Share INTE-INTH with INTA-INTD for simplicity */
372         pci_write_config8(dev, 0x46, 0x00);
373
374         /* FIXME: Intel needs more bit set for C2/C3. */
375
376         /*
377          * Allow SLP# signal to assert LDTSTOP_L.
378          * Will work for C3 and for FID/VID change.
379          */
380         outb(0x1, VT8237R_ACPI_IO_BASE + 0x11);
381
382         dump_south(dev);
383 }
384
385 static void vt8237s_init(struct device *dev)
386 {
387         u32 tmp;
388
389         /* Put SPI base VT8237S_SPI_MEM_BASE. */
390         tmp = pci_read_config32(dev, 0xbc);
391         pci_write_config32(dev, 0xbc,
392                            (VT8237S_SPI_MEM_BASE >> 8) | (tmp & 0xFF000000));
393
394         /*
395          * REQ5 as PCI request input - should be together with INTE-INTH.
396          */
397         pci_write_config8(dev, 0xe4, 0x04);
398
399         /* Reduce further the STPCLK/LDTSTP signal to 5us. */
400         pci_write_config8(dev, 0xec, 0x4);
401
402         /* Host Bus Power Management Control, maybe not needed */
403         pci_write_config8(dev, 0x8c, 0x5);
404
405         /* Enable HPET at VT8237R_HPET_ADDR., does not work correctly on R. */
406         pci_write_config32(dev, 0x68, (VT8237R_HPET_ADDR | 0x80));
407
408         southbridge_init_common(dev);
409
410         /* FIXME: Intel needs more bit set for C2/C3. */
411
412         /*
413          * Allow SLP# signal to assert LDTSTOP_L.
414          * Will work for C3 and for FID/VID change. FIXME FIXME, pre rev A2.
415          */
416         outb(0xff, VT8237R_ACPI_IO_BASE + 0x50);
417
418         dump_south(dev);
419 }
420
421 static void vt8237_common_init(struct device *dev)
422 {
423         u8 enables, byte;
424         struct southbridge_via_vt8237r_config *cfg;
425 #if !CONFIG_EPIA_VT8237R_INIT
426         unsigned char pwr_on;
427 #endif
428
429         cfg = dev->chip_info;
430
431         /* Enable addr/data stepping. */
432         byte = pci_read_config8(dev, PCI_COMMAND);
433         byte |= PCI_COMMAND_WAIT;
434         pci_write_config8(dev, PCI_COMMAND, byte);
435
436 /* EPIA-N(L) Uses CN400 for BIOS Access */
437 #if !CONFIG_EPIA_VT8237R_INIT
438         /* Enable the internal I/O decode. */
439         enables = pci_read_config8(dev, 0x6C);
440         enables |= 0x80;
441         pci_write_config8(dev, 0x6C, enables);
442
443         /*
444          * ROM decode
445          * bit range
446          *   7 000E0000h-000EFFFFh
447          *   6 FFF00000h-FFF7FFFFh
448          *   5 FFE80000h-FFEFFFFFh
449          *   4 FFE00000h-FFE7FFFFh
450          *   3 FFD80000h-FFDFFFFFh
451          *   2 FFD00000h-FFD7FFFFh
452          *   1 FFC80000h-FFCFFFFFh
453          *   0 FFC00000h-FFC7FFFFh
454          * So 0x7f here sets ROM decode to FFC00000-FFFFFFFF or 4Mbyte.
455          */
456         pci_write_config8(dev, 0x41, 0x7f);
457 #endif
458
459         /*
460          * Set bit 6 of 0x40 (I/O recovery time).
461          * IMPORTANT FIX - EISA = ECLR reg at 0x4d0! Decoding must be on so
462          * that PCI interrupts can be properly marked as level triggered.
463          */
464         enables = pci_read_config8(dev, 0x40);
465         enables |= 0x44;
466         pci_write_config8(dev, 0x40, enables);
467
468         /* Line buffer control */
469         enables = pci_read_config8(dev, 0x42);
470         enables |= 0xf8;
471         pci_write_config8(dev, 0x42, enables);
472
473         /* Delay transaction control */
474         pci_write_config8(dev, 0x43, 0xb);
475
476 #if CONFIG_EPIA_VT8237R_INIT
477         /* I/O recovery time, default IDE routing */
478         pci_write_config8(dev, 0x4c, 0x04);
479
480         /* ROM memory cycles go to LPC. */
481         pci_write_config8(dev, 0x59, 0x80);
482
483         /*
484          * Bit | Meaning
485          * -------------
486          *   3 | Bypass APIC De-Assert Message (1=Enable)
487          *   2 | APIC HyperTransport Mode (1=Enable)
488          *   1 | possibly "INTE#, INTF#, INTG#, INTH# as PCI"
489          *     | bit 1=1 works for Aaron at VIA, bit 1=0 works for jakllsch
490          *   0 | Dynamic Clock Gating Main Switch (1=Enable)
491          */
492         pci_write_config8(dev, 0x5b, 0x9);
493
494         /* Set 0x58 to 0x42 APIC On and RTC Write Protect.*/
495         pci_write_config8(dev, 0x58, 0x42);
496
497         /* Enable serial IRQ, 6PCI clocks. */
498         pci_write_config8(dev, 0x52, 0x9);
499 #else
500         /* I/O recovery time, default IDE routing */
501         pci_write_config8(dev, 0x4c, 0x44);
502
503         /* ROM memory cycles go to LPC. */
504         pci_write_config8(dev, 0x59, 0x80);
505
506         /*
507          * Bit | Meaning
508          * -------------
509          *   3 | Bypass APIC De-Assert Message (1=Enable)
510          *   2 | APIC HyperTransport Mode (1=Enable)
511          *   1 | possibly "INTE#, INTF#, INTG#, INTH# as PCI"
512          *     | bit 1=1 works for Aaron at VIA, bit 1=0 works for jakllsch
513          *   0 | Dynamic Clock Gating Main Switch (1=Enable)
514          */
515         if (cfg && cfg->int_efgh_as_gpio) {
516                 pci_write_config8(dev, 0x5b, 0x9);
517         } else {
518                 pci_write_config8(dev, 0x5b, 0xb);
519         }
520
521         /* configure power state of the board after loss of power */
522         if (get_option(&pwr_on, "power_on_after_fail") < 0)
523                 pwr_on = 1;
524         enables = pci_read_config8(dev, 0x58);
525         pci_write_config8(dev, 0x58, enables & ~0x02);
526         outb(0x0d, 0x70);
527         outb(pwr_on ? 0x00 : 0x80, 0x71);
528         pci_write_config8(dev, 0x58, enables);
529
530         /* Set 0x58 to 0x43 APIC and RTC. */
531         pci_write_config8(dev, 0x58, 0x43);
532
533         /* Enable serial IRQ, 6PCI clocks. */
534         pci_write_config8(dev, 0x52, 0x9);
535 #endif
536 #if CONFIG_HAVE_SMI_HANDLER
537         smm_lock();
538 #endif
539
540         /* Power management setup */
541         setup_pm(dev);
542
543         /* Start the RTC. */
544         rtc_init(0);
545 }
546
547 static void vt8237r_read_resources(device_t dev)
548 {
549         struct resource *res;
550
551         pci_dev_read_resources(dev);
552
553         /* Fixed ACPI Base IO Base*/
554         res = new_resource(dev, 0x88);
555         res->base = VT8237R_ACPI_IO_BASE;
556         res->size = 128;
557         res->limit = 0xffffUL;
558         res->flags = IORESOURCE_IO | IORESOURCE_FIXED | IORESOURCE_RESERVE |
559                      IORESOURCE_STORED | IORESOURCE_ASSIGNED;
560
561         /* Fixed EISA ECLR I/O Regs     */
562         res = new_resource(dev, 3);
563         res->base = 0x4d0;
564         res->size = 2;
565         res->limit = 0xffffUL;
566         res->flags = IORESOURCE_IO | IORESOURCE_FIXED | IORESOURCE_RESERVE |
567                      IORESOURCE_STORED | IORESOURCE_ASSIGNED;
568
569         /* Fixed System Management Bus I/O Resource */
570         res = new_resource(dev, 0xD0);
571         res->base = VT8237R_SMBUS_IO_BASE;
572         res->size = 16;
573         res->limit = 0xffffUL;
574         res->flags = IORESOURCE_IO | IORESOURCE_FIXED | IORESOURCE_RESERVE |
575                      IORESOURCE_STORED | IORESOURCE_ASSIGNED;
576
577         /* Fixed APIC resource */
578         res = new_resource(dev, 0x44);
579         res->base = IO_APIC_ADDR;
580         res->size = 256;
581         res->limit = 0xffffffffUL;
582         res->align = 8;
583         res->gran = 8;
584         res->flags = IORESOURCE_MEM | IORESOURCE_FIXED | IORESOURCE_RESERVE |
585                      IORESOURCE_STORED | IORESOURCE_ASSIGNED;
586
587         /* Fixed flashrom resource */
588         res = new_resource(dev, 4);
589         res->base = 0xff000000UL;
590         res->size = 0x01000000UL; /* 16MB */
591         res->limit = 0xffffffffUL;
592         res->flags = IORESOURCE_MEM | IORESOURCE_FIXED | IORESOURCE_RESERVE |
593                      IORESOURCE_STORED | IORESOURCE_ASSIGNED;
594
595         res = new_resource(dev, 1);
596         res->base = 0x0UL;
597         res->size = 0x1000UL;
598         res->limit = 0xffffUL;
599         res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
600 }
601
602 static void init_keyboard(struct device *dev)
603 {
604         u8 regval = pci_read_config8(dev, 0x51);
605         if (regval & 0x1)
606                 pc_keyboard_init(0);
607 }
608
609 static void southbridge_init_common(struct device *dev)
610 {
611         vt8237_common_init(dev);
612         pci_routing_fixup(dev);
613         setup_ioapic(IO_APIC_ADDR, VT8237R_APIC_ID);
614         setup_i8259();
615         init_keyboard(dev);
616 }
617
618 static const struct device_operations vt8237r_lpc_ops_s = {
619         .read_resources         = vt8237r_read_resources,
620         .set_resources          = pci_dev_set_resources,
621         .enable_resources       = pci_dev_enable_resources,
622         .init                   = vt8237s_init,
623         .scan_bus               = scan_static_bus,
624 };
625
626 static const struct device_operations vt8237r_lpc_ops_r = {
627         .read_resources         = vt8237r_read_resources,
628         .set_resources          = pci_dev_set_resources,
629         .enable_resources       = pci_dev_enable_resources,
630         .init                   = vt8237r_init,
631         .scan_bus               = scan_static_bus,
632 };
633
634 static const struct device_operations vt8237r_lpc_ops_a = {
635         .read_resources         = vt8237r_read_resources,
636         .set_resources          = pci_dev_set_resources,
637         .enable_resources       = pci_dev_enable_resources,
638         .init                   = vt8237a_init,
639         .scan_bus               = scan_static_bus,
640 };
641
642 static const struct pci_driver lpc_driver_r __pci_driver = {
643         .ops    = &vt8237r_lpc_ops_r,
644         .vendor = PCI_VENDOR_ID_VIA,
645         .device = PCI_DEVICE_ID_VIA_VT8237R_LPC,
646 };
647
648 static const struct pci_driver lpc_driver_a __pci_driver = {
649         .ops    = &vt8237r_lpc_ops_a,
650         .vendor = PCI_VENDOR_ID_VIA,
651         .device = PCI_DEVICE_ID_VIA_VT8237A_LPC,
652 };
653
654 static const struct pci_driver lpc_driver_s __pci_driver = {
655         .ops    = &vt8237r_lpc_ops_s,
656         .vendor = PCI_VENDOR_ID_VIA,
657         .device = PCI_DEVICE_ID_VIA_VT8237S_LPC,
658 };