Ed Swierk | 62eee3f | 2008-03-16 23:31:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2008 Arastra, Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 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. |
Ed Swierk | 62eee3f | 2008-03-16 23:31:04 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <stdlib.h> |
| 18 | #include <device/device.h> |
| 19 | #include <device/pnp.h> |
Ed Swierk | 62eee3f | 2008-03-16 23:31:04 +0000 | [diff] [blame] | 20 | #include "i3100.h" |
| 21 | #include <arch/io.h> |
| 22 | |
Edward O'Callaghan | f21bdc3 | 2014-10-21 07:43:41 +1100 | [diff] [blame] | 23 | static void pnp_enter_ext_func_mode(struct device *dev) |
Ed Swierk | 62eee3f | 2008-03-16 23:31:04 +0000 | [diff] [blame] | 24 | { |
Stefan Reinauer | 2b34db8 | 2009-02-28 20:10:20 +0000 | [diff] [blame] | 25 | outb(0x80, dev->path.pnp.port); |
| 26 | outb(0x86, dev->path.pnp.port); |
Ed Swierk | 62eee3f | 2008-03-16 23:31:04 +0000 | [diff] [blame] | 27 | } |
| 28 | |
Edward O'Callaghan | f21bdc3 | 2014-10-21 07:43:41 +1100 | [diff] [blame] | 29 | static void pnp_exit_ext_func_mode(struct device *dev) |
Ed Swierk | 62eee3f | 2008-03-16 23:31:04 +0000 | [diff] [blame] | 30 | { |
Stefan Reinauer | 2b34db8 | 2009-02-28 20:10:20 +0000 | [diff] [blame] | 31 | outb(0x68, dev->path.pnp.port); |
| 32 | outb(0x08, dev->path.pnp.port); |
Ed Swierk | 62eee3f | 2008-03-16 23:31:04 +0000 | [diff] [blame] | 33 | } |
| 34 | |
Edward O'Callaghan | f21bdc3 | 2014-10-21 07:43:41 +1100 | [diff] [blame] | 35 | static void i3100_init(struct device *dev) |
Ed Swierk | 62eee3f | 2008-03-16 23:31:04 +0000 | [diff] [blame] | 36 | { |
Uwe Hermann | 7d34188 | 2010-11-05 00:07:13 +0000 | [diff] [blame] | 37 | if (!dev->enabled) |
Ed Swierk | 62eee3f | 2008-03-16 23:31:04 +0000 | [diff] [blame] | 38 | return; |
Ed Swierk | 62eee3f | 2008-03-16 23:31:04 +0000 | [diff] [blame] | 39 | } |
| 40 | |
Nico Huber | 13dc976 | 2013-06-15 19:33:15 +0200 | [diff] [blame] | 41 | static const struct pnp_mode_ops pnp_conf_mode_ops = { |
| 42 | .enter_conf_mode = pnp_enter_ext_func_mode, |
| 43 | .exit_conf_mode = pnp_exit_ext_func_mode, |
| 44 | }; |
| 45 | |
Ed Swierk | 62eee3f | 2008-03-16 23:31:04 +0000 | [diff] [blame] | 46 | static struct device_operations ops = { |
| 47 | .read_resources = pnp_read_resources, |
Nico Huber | 0b2ee93 | 2013-06-15 19:58:35 +0200 | [diff] [blame] | 48 | .set_resources = pnp_set_resources, |
| 49 | .enable_resources = pnp_enable_resources, |
| 50 | .enable = pnp_alt_enable, |
Ed Swierk | 62eee3f | 2008-03-16 23:31:04 +0000 | [diff] [blame] | 51 | .init = i3100_init, |
Nico Huber | 13dc976 | 2013-06-15 19:33:15 +0200 | [diff] [blame] | 52 | .ops_pnp_mode = &pnp_conf_mode_ops, |
Ed Swierk | 62eee3f | 2008-03-16 23:31:04 +0000 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | static struct pnp_info pnp_dev_info[] = { |
Uwe Hermann | a69d978 | 2010-11-15 19:35:14 +0000 | [diff] [blame] | 56 | { &ops, I3100_SP1, PNP_IO0 | PNP_IRQ0, {0x07f8, 0}, }, |
| 57 | { &ops, I3100_SP2, PNP_IO0 | PNP_IRQ0, {0x07f8, 0}, }, |
Ed Swierk | 62eee3f | 2008-03-16 23:31:04 +0000 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | static void enable_dev(struct device *dev) |
| 61 | { |
| 62 | pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info); |
| 63 | } |
| 64 | |
| 65 | struct chip_operations superio_intel_i3100_ops = { |
| 66 | CHIP_NAME("Intel 3100 Super I/O") |
| 67 | .enable_dev = enable_dev, |
| 68 | }; |