[LinuxBIOS] r374 - in LinuxBIOSv3: device include/device
svn at openbios.org
svn at openbios.org
Wed Jun 27 21:47:27 CEST 2007
Author: rminnich
Date: 2007-06-27 21:47:27 +0200 (Wed, 27 Jun 2007)
New Revision: 374
Added:
LinuxBIOSv3/device/pnp_raw.c
Modified:
LinuxBIOSv3/device/Makefile
LinuxBIOSv3/include/device/pnp.h
Log:
Add pnp code and remove pnp inlines.
Signed-off-by: Ronald G. Minnich <rminnich at gmail.com>
Acked-by: Stefan Reinauer <stepan at coresystems.de>
Modified: LinuxBIOSv3/device/Makefile
===================================================================
--- LinuxBIOSv3/device/Makefile 2007-06-27 19:24:22 UTC (rev 373)
+++ LinuxBIOSv3/device/Makefile 2007-06-27 19:47:27 UTC (rev 374)
@@ -25,5 +25,5 @@
$(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
Added: LinuxBIOSv3/device/pnp_raw.c
===================================================================
--- LinuxBIOSv3/device/pnp_raw.c (rev 0)
+++ LinuxBIOSv3/device/pnp_raw.c 2007-06-27 19:47:27 UTC (rev 374)
@@ -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 <types.h>
+#include <device/pnp_def.h>
+#include <io.h>
+
+/* 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);
+}
+
Modified: LinuxBIOSv3/include/device/pnp.h
===================================================================
--- LinuxBIOSv3/include/device/pnp.h 2007-06-27 19:24:22 UTC (rev 373)
+++ LinuxBIOSv3/include/device/pnp.h 2007-06-27 19:47:27 UTC (rev 374)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) FIXME
+ * Copyright (C) 2007 Ronald G. Minnich <rminnich at gmail.com>
* Copyright (C) 2007 coresystems GmbH
*
* This program is free software; you can redistribute it and/or modify
@@ -24,6 +24,14 @@
#include <device/device.h>
#include <device/pnp_def.h>
+/* 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);
More information about the coreboot
mailing list