From b175ce06ac90ebd676f3f7b30d51e2a4bb257fe5 Mon Sep 17 00:00:00 2001 From: "Ronald G. Minnich" Date: Wed, 27 Jun 2007 19:47:27 +0000 Subject: [PATCH] Add pnp code and remove pnp inlines. Signed-off-by: Ronald G. Minnich Acked-by: Stefan Reinauer git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@374 f3766cd6-281f-0410-b1cd-43a5c92072e9 --- device/Makefile | 2 +- device/pnp_raw.c | 98 ++++++++++++++++++++++++++++++++++++++++++++ include/device/pnp.h | 10 ++++- 3 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 device/pnp_raw.c diff --git a/device/Makefile b/device/Makefile index 3000375d9b..2c7a75016d 100644 --- a/device/Makefile +++ b/device/Makefile @@ -25,5 +25,5 @@ $(obj)/device/%.o: $(src)/device/%.c $(Q)$(CC) $(INITCFLAGS) -c $< -o $@ STAGE2_DEVICE_OBJ = device.o device_util.o root_device.o \ - pci_device.o pci_ops.o pci_rom.o pnp_device.o + pci_device.o pci_ops.o pci_rom.o pnp_device.o rawpnp.o diff --git a/device/pnp_raw.c b/device/pnp_raw.c new file mode 100644 index 0000000000..67d42da7fd --- /dev/null +++ b/device/pnp_raw.c @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2007 Ronald G. Minnich + * Copyright (C) 2007 coresystems GmbH + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include + +/* very low level pnp manipulation intended for stage 0 or 1 */ +/** + * rawpnp_enter_ext_funct -- Enter the PNP extended functions, + * i.e. configuration mode + * @param dev The device IO port. + */ +void rawpnp_enter_ext_func_mode(u16 dev) +{ + outb(0x87, dev); + outb(0x87, dev); +} + +/** + * Exit the PNP extended functions, i.e. configuration mode + * @param dev The device IO port. + */ +void rawpnp_exit_ext_func_mode(u16 dev) +{ + outb(0xaa, dev); +} + +/** + * Write a pnp configuration register. This is done by writing + * the register number to the port, and the value to the + * port+1 + * @param dev The device IO port. + * @param reg The register number + * @param value The new value. + */ +void rawpnp_write_config(u16 dev, u8 reg, u8 value) +{ + outb(reg, dev); + outb(value,dev + 1); +} + +/** + * Select a logical device. PNP has up to 16 logical devices. + * They are selected by writing the device # to register 7. + * @param dev The device IO port. + * @param which Which device + */ +void rawpnp_set_logical_device(u16 dev, u8 which) +{ + rawpnp_write_config(dev, 0x07, which); +} + +/** + * Set the enable for the device. The enable is at register 30. + * Setting the low bit enables the device. + * Code must have selected the proper device using + * rawpnp_set_logical_device. If enable is non-zero, device + * is enabled. If enable is zero, device is disabled. + * @param dev The device IO port. + * @param enable non-zero enables the device + */ +void rawpnp_set_enable(u16 dev, int enable) +{ + rawpnp_write_config(dev, 0x30, enable ? 0x1 : 0x0); +} + +/** + * Set the iobase for the device. The iobase is at registers 'index' + * and 'index + 1', since these are 8 bit registers and iobase is 16 bits. + * Code must have selected the proper device using + * rawpnp_set_logical_device. + * @param dev The device IO port. + * @param iobase The 16 bit iobase + */ +void rawpnp_set_iobase(u16 dev, u8 index, u16 iobase) +{ + /* Index == 0x60 or 0x62 */ + rawpnp_write_config(dev, index + 0, (iobase >> 8) & 0xff); + rawpnp_write_config(dev, index + 1, iobase & 0xff); +} + diff --git a/include/device/pnp.h b/include/device/pnp.h index 75f1a989a9..f0e2e62220 100644 --- a/include/device/pnp.h +++ b/include/device/pnp.h @@ -1,5 +1,5 @@ /* - * Copyright (C) FIXME + * Copyright (C) 2007 Ronald G. Minnich * Copyright (C) 2007 coresystems GmbH * * This program is free software; you can redistribute it and/or modify @@ -24,6 +24,14 @@ #include #include +/* very low level pnp manipulation intended for stage 0 or 1 */ +void rawpnp_enter_ext_func_mode(u16 dev); +void rawpnp_exit_ext_func_mode(u16 dev); +void rawpnp_write_config(u16 dev, u8 reg, u8 value); +void rawpnp_set_logical_device(u16 dev, u8 which); +void rawpnp_set_enable(u16 dev, int enable); +void rawpnp_set_iobase(u16 dev, u8 index, u16 iobase); + /* Primitive pnp resource manipulation */ void pnp_write_config(struct device * dev, u8 reg, u8 value); u8 pnp_read_config(struct device * dev, u8 reg);