mpspec.h: Tweak the write_smp_table macro so that it is safe if passed a complex...
[coreboot.git] / src / superio / NSC / pc97307 / superio.c
1 /* Copyright 2000  AG Electronics Ltd. */
2 /* This code is distributed without warranty under the GPL v2 (see COPYING) */
3
4 #include <arch/io.h>
5 #include <console/console.h>
6 #include "chip.h"
7 #include "pc97307.h"
8
9 static void init(device_t dev)
10 {
11         struct superio_NSC_pc97307_config *conf;
12         struct resource *res0, *res1;
13
14         if (!dev->enabled) {
15                 return;
16         }
17         conf = dev->chip;
18         switch(dev->path.u.pnp.device) {
19         case PC97307_SP1:
20                 res0 = find_resource(dev, PNP_IDX_IO0);
21                 init_uart8250(res0->base, &conf->com1);
22                 break;
23
24         case PC97307_SP2:
25                 res0 = find_resource(dev, PNP_IDX_IO0);
26                 init_uart8250(res0->base, &conf->com2);
27                 break;
28
29         case PC97307_KBCK:
30                 /* Enable keyboard */
31                 pnp_set_logical_device(dev);
32                 pnp_set_enable(dev, 0); /* Disable keyboard */
33                 pnp_write_config(dev, 0xf0, 0x40); /* Set KBC clock to 8 Mhz */
34                 pnp_set_enable(dev, 1); /* Enable keyboard */
35
36                 res0 = find_resource(dev, PNP_IDX_IO0);
37                 res1 = find_resource(dev, PNP_IDX_IO1);
38                 init_pc_keyboard(res0->base, res1->base, &conf->keyboard);
39                 break;
40
41         case PC97307_FDC:
42                 /* Set up floppy in PS/2 mode */
43                 outb(0x09, SIO_CONFIG_RA);
44                 reg = inb(SIO_CONFIG_RD);
45                 reg = (reg & 0x3F) | 0x40;
46                 outb(reg, SIO_CONFIG_RD);
47                 outb(reg, SIO_CONFIG_RD);       /* Have to write twice to change! */
48                 break;
49
50         }
51 }
52
53 static struct device_operations ops = {
54         .read_resources   = pnp_read_resources,
55         .set_resources    = pnp_set_resources,
56         .enable_resources = pnp_enable_resources,
57         .enable           = pnp_enable,
58         .init             = init,
59 };
60
61 static struct pnp_info pnp_dev_info[] = {
62  { &ops, PC97307_KBCK, PNP_IO0 | PNP_IO1 | PNP_IRQ0, { 0xffb, 0 }, { 0xffb, 0x4}, },
63  { &ops, PC97307_KBCM, PNP_IRQ0 },
64  { &ops, PC97307_RTC,  PNP_IO0 | PNP_IRQ0, { 0xfffe, 0}, },
65  { &ops, PC97307_FDC,  PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, { 0xfffa, 0}, },
66  { &ops, PC97307_PP,   PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, { 0x03fc, 0}, },
67  { &ops, PC97307_SP2,  PNP_IO0 | PNP_IRQ0 | PNP_DRQ0 | PNP_DRQ1, { 0xfff8, 0 }, },
68  { &ops, PC97307_SP1,  PNP_IO0 | PNP_IRQ0, { 0xfff8, 0 }, },
69  { &ops, PC97307_GPIO, PNP_IO0, { 0xfff8, 0 } },
70  { &ops, PC97307_PM,   PNP_IO0, { 0xfffe, 0 } },
71 };
72
73 static void enable_dev(struct device *dev)
74 {
75         pnp_enable_devices(dev, &ops,
76                 sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
77 }
78
79 struct chip_operations superio_NSC_pc97307_control = {
80         CHIP_NAME("NSC 97307")
81         .enable_dev = enable_dev,
82 };