Rename src/superio/NSC to src/superio/nsc.
[coreboot.git] / src / superio / nsc / pc97317 / 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 <device/device.h>
7 #include <device/pnp.h>
8 #include "chip.h"
9 #include "pc97317.h"
10
11 static void init(device_t dev)
12 {
13         struct superio_nsc_pc97317_config *conf;
14         struct resource *res0, *res1;
15
16         if (!dev->enabled) {
17                 return;
18         }
19         conf = dev->chip_info;
20         switch(dev->path.u.pnp.device) {
21         case PC97317_SP1:
22                 res0 = find_resource(dev, PNP_IDX_IO0);
23                 init_uart8250(res0->base, &conf->com1);
24                 break;
25
26         case PC97317_SP2:
27                 res0 = find_resource(dev, PNP_IDX_IO0);
28                 init_uart8250(res0->base, &conf->com2);
29                 break;
30
31         case PC97317_KBCK:
32                 /* Enable keyboard */
33                 pnp_set_logical_device(dev);
34                 pnp_set_enable(dev, 0); /* Disable keyboard */
35                 pnp_write_config(dev, 0xf0, 0x40); /* Set KBC clock to 8 Mhz */
36                 pnp_set_enable(dev, 1); /* Enable keyboard */
37
38                 res0 = find_resource(dev, PNP_IDX_IO0);
39                 res1 = find_resource(dev, PNP_IDX_IO1);
40                 init_pc_keyboard(res0->base, res1->base, &conf->keyboard);
41                 break;
42
43 #if 0
44         case PC97317_FDC:
45         {
46                 unsigned reg;
47                 /* Set up floppy in PS/2 mode */
48                 outb(0x09, SIO_CONFIG_RA);
49                 reg = inb(SIO_CONFIG_RD);
50                 reg = (reg & 0x3F) | 0x40;
51                 outb(reg, SIO_CONFIG_RD);
52                 outb(reg, SIO_CONFIG_RD);       /* Have to write twice to change! */
53                 break;
54         }
55 #endif
56         default:
57                 break;
58         }
59 }
60
61 static struct device_operations ops = {
62         .read_resources   = pnp_read_resources,
63         .set_resources    = pnp_set_resources,
64         .enable_resources = pnp_enable_resources,
65         .enable           = pnp_enable,
66         .init             = init,
67 };
68
69 static struct pnp_info pnp_dev_info[] = {
70  { &ops, PC97317_KBCK, PNP_IO0 | PNP_IO1 | PNP_IRQ0, { 0xffb, 0 }, { 0xffb, 0x4}, },
71  { &ops, PC97317_KBCM, PNP_IRQ0 },
72  { &ops, PC97317_RTC,  PNP_IO0 | PNP_IRQ0, { 0xfffe, 0}, },
73  { &ops, PC97317_FDC,  PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, { 0xfffa, 0}, },
74  { &ops, PC97317_PP,   PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, { 0x03fc, 0}, },
75  { &ops, PC97317_SP2,  PNP_IO0 | PNP_IRQ0 | PNP_DRQ0 | PNP_DRQ1, { 0xfff8, 0 }, },
76  { &ops, PC97317_SP1,  PNP_IO0 | PNP_IRQ0, { 0xfff8, 0 }, },
77  { &ops, PC97317_GPIO, PNP_IO0, { 0xfff8, 0 } },
78  { &ops, PC97317_PM,   PNP_IO0, { 0xfffe, 0 } },
79 };
80
81 static void enable_dev(struct device *dev)
82 {
83         pnp_enable_devices(dev, &ops,
84                 sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
85 }
86
87 struct chip_operations superio_nsc_pc97317_ops = {
88         CHIP_NAME("NSC 97317")
89         .enable_dev = enable_dev,
90 };