pnp: Add some default functions to enter/exit config state
Implement some common default functions to enter and exit the
configuration state. Also provide default pnp_mode_ops for common
enter()/exit() function pairs.
The following cocci ensures their use:
@ mode_match @
identifier enter, exit, ops;
@@
struct pnp_mode_ops ops = {
.enter_conf_mode = enter,
.exit_conf_mode = exit,
};
@ enter_match_8787 @
identifier mode_match.enter, dev;
@@
enter(...)
{
outb(0x87, dev->path.pnp.port);
outb(0x87, dev->path.pnp.port);
}
@ depends on enter_match_8787 @
identifier mode_match.enter, mode_match.ops;
@@
struct pnp_mode_ops ops = {
- .enter_conf_mode = enter,
+ .enter_conf_mode = pnp_enter_conf_mode_8787,
};
@ enter_match_55 @
identifier mode_match.enter, dev;
@@
enter(...)
{
outb(0x55, dev->path.pnp.port);
}
@ depends on enter_match_55 @
identifier mode_match.enter, mode_match.ops;
@@
struct pnp_mode_ops ops = {
- .enter_conf_mode = enter,
+ .enter_conf_mode = pnp_enter_conf_mode_55,
};
@ depends on enter_match_8787 || enter_match_55 @
identifier mode_match.enter;
@@
-enter(...) {...}
@ exit_match_aa @
identifier mode_match.exit, dev;
@@
exit(...)
{
outb(0xaa, dev->path.pnp.port);
}
@ depends on exit_match_aa @
identifier mode_match.exit, mode_match.ops;
@@
struct pnp_mode_ops ops = {
- .exit_conf_mode = exit,
+ .exit_conf_mode = pnp_exit_conf_mode_aa,
};
@ depends on exit_match_aa @
identifier mode_match.exit;
@@
-exit(...) {...}
@ depends on enter_match_8787 || enter_match_55 || exit_match_aa @
@@
#include <device/pnp.h>
+#include <superio/conf_mode.h>
@ mode_match_55_aa @
identifier ops;
@@
struct pnp_mode_ops ops = {
.enter_conf_mode = pnp_enter_conf_mode_55,
.exit_conf_mode = pnp_exit_conf_mode_aa,
};
@@
identifier mode_match_55_aa.ops;
@@
-struct pnp_mode_ops ops = {...};
@@
identifier mode_match_55_aa.ops, devops;
@@
struct device_operations devops = {
- .ops_pnp_mode = &ops,
+ .ops_pnp_mode = &pnp_conf_mode_55_aa,
};
@ mode_match_8787_aa @
identifier ops;
@@
struct pnp_mode_ops ops = {
.enter_conf_mode = pnp_enter_conf_mode_8787,
.exit_conf_mode = pnp_exit_conf_mode_aa,
};
@@
identifier mode_match_8787_aa.ops;
@@
-struct pnp_mode_ops ops = {...};
@@
identifier mode_match_8787_aa.ops, devops;
@@
struct device_operations devops = {
- .ops_pnp_mode = &ops,
+ .ops_pnp_mode = &pnp_conf_mode_8787_aa,
};
Change-Id: I1480336b54523cc95210d99cf31c1a0b3a14b464
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: http://review.coreboot.org/3484
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include <arch/io.h>
|
||||
#include <device/device.h>
|
||||
#include <device/pnp.h>
|
||||
#include <superio/conf_mode.h>
|
||||
#include <console/console.h>
|
||||
#include <device/smbus.h>
|
||||
#include <string.h>
|
||||
@@ -35,26 +36,18 @@
|
||||
static void enable_dev(device_t dev);
|
||||
static void kbc1100_init(device_t dev);
|
||||
|
||||
static void pnp_enter_conf_state(device_t dev);
|
||||
static void pnp_exit_conf_state(device_t dev);
|
||||
|
||||
struct chip_operations superio_smsc_kbc1100_ops = {
|
||||
CHIP_NAME("SMSC KBC1100 Super I/O")
|
||||
.enable_dev = enable_dev
|
||||
};
|
||||
|
||||
static const struct pnp_mode_ops pnp_conf_mode_ops = {
|
||||
.enter_conf_mode = pnp_enter_conf_state,
|
||||
.exit_conf_mode = pnp_exit_conf_state,
|
||||
};
|
||||
|
||||
static struct device_operations ops = {
|
||||
.read_resources = pnp_read_resources,
|
||||
.set_resources = pnp_set_resources,
|
||||
.enable_resources = pnp_enable_resources,
|
||||
.enable = pnp_alt_enable,
|
||||
.init = kbc1100_init,
|
||||
.ops_pnp_mode = &pnp_conf_mode_ops,
|
||||
.ops_pnp_mode = &pnp_conf_mode_55_aa,
|
||||
};
|
||||
|
||||
static struct pnp_info pnp_dev_info[] = {
|
||||
@@ -86,13 +79,3 @@ static void kbc1100_init(device_t dev)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void pnp_enter_conf_state(device_t dev)
|
||||
{
|
||||
outb(0x55, dev->path.pnp.port);
|
||||
}
|
||||
|
||||
static void pnp_exit_conf_state(device_t dev)
|
||||
{
|
||||
outb(0xaa, dev->path.pnp.port);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <arch/io.h>
|
||||
#include <device/device.h>
|
||||
#include <device/pnp.h>
|
||||
#include <superio/conf_mode.h>
|
||||
#include <console/console.h>
|
||||
#include <device/smbus.h>
|
||||
#include <string.h>
|
||||
@@ -38,9 +39,6 @@
|
||||
/* Forward declarations */
|
||||
static void enable_dev(device_t dev);
|
||||
static void lpc47b272_init(device_t dev);
|
||||
|
||||
static void pnp_enter_conf_state(device_t dev);
|
||||
static void pnp_exit_conf_state(device_t dev);
|
||||
// static void dump_pnp_device(device_t dev);
|
||||
|
||||
struct chip_operations superio_smsc_lpc47b272_ops = {
|
||||
@@ -48,18 +46,13 @@ struct chip_operations superio_smsc_lpc47b272_ops = {
|
||||
.enable_dev = enable_dev
|
||||
};
|
||||
|
||||
static const struct pnp_mode_ops pnp_conf_mode_ops = {
|
||||
.enter_conf_mode = pnp_enter_conf_state,
|
||||
.exit_conf_mode = pnp_exit_conf_state,
|
||||
};
|
||||
|
||||
static struct device_operations ops = {
|
||||
.read_resources = pnp_read_resources,
|
||||
.set_resources = pnp_set_resources,
|
||||
.enable_resources = pnp_enable_resources,
|
||||
.enable = pnp_alt_enable,
|
||||
.init = lpc47b272_init,
|
||||
.ops_pnp_mode = &pnp_conf_mode_ops,
|
||||
.ops_pnp_mode = &pnp_conf_mode_55_aa,
|
||||
};
|
||||
|
||||
static struct pnp_info pnp_dev_info[] = {
|
||||
@@ -105,16 +98,6 @@ static void lpc47b272_init(device_t dev)
|
||||
}
|
||||
}
|
||||
|
||||
static void pnp_enter_conf_state(device_t dev)
|
||||
{
|
||||
outb(0x55, dev->path.pnp.port);
|
||||
}
|
||||
|
||||
static void pnp_exit_conf_state(device_t dev)
|
||||
{
|
||||
outb(0xaa, dev->path.pnp.port);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* Print the values of all of the LPC47B272's configuration registers.
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <arch/io.h>
|
||||
#include <device/device.h>
|
||||
#include <device/pnp.h>
|
||||
#include <superio/conf_mode.h>
|
||||
#include <console/console.h>
|
||||
#include <device/smbus.h>
|
||||
#include <string.h>
|
||||
@@ -32,16 +33,6 @@
|
||||
#include "chip.h"
|
||||
#include "lpc47b397.h"
|
||||
|
||||
static void pnp_enter_conf_state(device_t dev)
|
||||
{
|
||||
outb(0x55, dev->path.pnp.port);
|
||||
}
|
||||
|
||||
static void pnp_exit_conf_state(device_t dev)
|
||||
{
|
||||
outb(0xaa, dev->path.pnp.port);
|
||||
}
|
||||
|
||||
static void pnp_write_index(u16 port, u8 reg, u8 value)
|
||||
{
|
||||
outb(reg, port);
|
||||
@@ -94,18 +85,13 @@ static void lpc47b397_pnp_enable_resources(device_t dev)
|
||||
pnp_exit_conf_mode(dev);
|
||||
}
|
||||
|
||||
static const struct pnp_mode_ops pnp_conf_mode_ops = {
|
||||
.enter_conf_mode = pnp_enter_conf_state,
|
||||
.exit_conf_mode = pnp_exit_conf_state,
|
||||
};
|
||||
|
||||
static struct device_operations ops = {
|
||||
.read_resources = pnp_read_resources,
|
||||
.set_resources = pnp_set_resources,
|
||||
.enable_resources = lpc47b397_pnp_enable_resources,
|
||||
.enable = pnp_alt_enable,
|
||||
.init = lpc47b397_init,
|
||||
.ops_pnp_mode = &pnp_conf_mode_ops,
|
||||
.ops_pnp_mode = &pnp_conf_mode_55_aa,
|
||||
};
|
||||
|
||||
#define HWM_INDEX 0
|
||||
@@ -165,7 +151,7 @@ static struct device_operations ops_hwm = {
|
||||
.init = lpc47b397_init,
|
||||
.scan_bus = scan_static_bus,
|
||||
.ops_smbus_bus = &lops_smbus_bus,
|
||||
.ops_pnp_mode = &pnp_conf_mode_ops,
|
||||
.ops_pnp_mode = &pnp_conf_mode_55_aa,
|
||||
};
|
||||
|
||||
static struct pnp_info pnp_dev_info[] = {
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <arch/io.h>
|
||||
#include <device/device.h>
|
||||
#include <device/pnp.h>
|
||||
#include <superio/conf_mode.h>
|
||||
#include <console/console.h>
|
||||
#include <device/smbus.h>
|
||||
#include <string.h>
|
||||
@@ -37,9 +38,6 @@
|
||||
/* Forward declarations */
|
||||
static void enable_dev(device_t dev);
|
||||
static void lpc47m10x_init(device_t dev);
|
||||
|
||||
static void pnp_enter_conf_state(device_t dev);
|
||||
static void pnp_exit_conf_state(device_t dev);
|
||||
// static void dump_pnp_device(device_t dev);
|
||||
|
||||
struct chip_operations superio_smsc_lpc47m10x_ops = {
|
||||
@@ -47,18 +45,13 @@ struct chip_operations superio_smsc_lpc47m10x_ops = {
|
||||
.enable_dev = enable_dev
|
||||
};
|
||||
|
||||
static const struct pnp_mode_ops pnp_conf_mode_ops = {
|
||||
.enter_conf_mode = pnp_enter_conf_state,
|
||||
.exit_conf_mode = pnp_exit_conf_state,
|
||||
};
|
||||
|
||||
static struct device_operations ops = {
|
||||
.read_resources = pnp_read_resources,
|
||||
.set_resources = pnp_set_resources,
|
||||
.enable_resources = pnp_enable_resources,
|
||||
.enable = pnp_alt_enable,
|
||||
.init = lpc47m10x_init,
|
||||
.ops_pnp_mode = &pnp_conf_mode_ops,
|
||||
.ops_pnp_mode = &pnp_conf_mode_55_aa,
|
||||
};
|
||||
|
||||
static struct pnp_info pnp_dev_info[] = {
|
||||
@@ -104,16 +97,6 @@ static void lpc47m10x_init(device_t dev)
|
||||
}
|
||||
}
|
||||
|
||||
static void pnp_enter_conf_state(device_t dev)
|
||||
{
|
||||
outb(0x55, dev->path.pnp.port);
|
||||
}
|
||||
|
||||
static void pnp_exit_conf_state(device_t dev)
|
||||
{
|
||||
outb(0xaa, dev->path.pnp.port);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* Print the values of all of the LPC47M10X2's configuration registers.
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <arch/io.h>
|
||||
#include <device/device.h>
|
||||
#include <device/pnp.h>
|
||||
#include <superio/conf_mode.h>
|
||||
#include <console/console.h>
|
||||
#include <device/smbus.h>
|
||||
#include <string.h>
|
||||
@@ -35,26 +36,18 @@
|
||||
static void enable_dev(device_t dev);
|
||||
static void lpc47m15x_init(device_t dev);
|
||||
|
||||
static void pnp_enter_conf_state(device_t dev);
|
||||
static void pnp_exit_conf_state(device_t dev);
|
||||
|
||||
struct chip_operations superio_smsc_lpc47m15x_ops = {
|
||||
CHIP_NAME("SMSC LPC47M15x/192/997 Super I/O")
|
||||
.enable_dev = enable_dev
|
||||
};
|
||||
|
||||
static const struct pnp_mode_ops pnp_conf_mode_ops = {
|
||||
.enter_conf_mode = pnp_enter_conf_state,
|
||||
.exit_conf_mode = pnp_exit_conf_state,
|
||||
};
|
||||
|
||||
static struct device_operations ops = {
|
||||
.read_resources = pnp_read_resources,
|
||||
.set_resources = pnp_set_resources,
|
||||
.enable_resources = pnp_enable_resources,
|
||||
.enable = pnp_alt_enable,
|
||||
.init = lpc47m15x_init,
|
||||
.ops_pnp_mode = &pnp_conf_mode_ops,
|
||||
.ops_pnp_mode = &pnp_conf_mode_55_aa,
|
||||
};
|
||||
|
||||
static struct pnp_info pnp_dev_info[] = {
|
||||
@@ -84,13 +77,3 @@ static void lpc47m15x_init(device_t dev)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void pnp_enter_conf_state(device_t dev)
|
||||
{
|
||||
outb(0x55, dev->path.pnp.port);
|
||||
}
|
||||
|
||||
static void pnp_exit_conf_state(device_t dev)
|
||||
{
|
||||
outb(0xaa, dev->path.pnp.port);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <arch/io.h>
|
||||
#include <device/device.h>
|
||||
#include <device/pnp.h>
|
||||
#include <superio/conf_mode.h>
|
||||
#include <console/console.h>
|
||||
#include <device/smbus.h>
|
||||
#include <string.h>
|
||||
@@ -33,16 +34,6 @@
|
||||
#include <arch/acpi.h>
|
||||
#endif
|
||||
|
||||
static void pnp_enter_conf_state(device_t dev)
|
||||
{
|
||||
outb(0x55, dev->path.pnp.port);
|
||||
}
|
||||
|
||||
static void pnp_exit_conf_state(device_t dev)
|
||||
{
|
||||
outb(0xaa, dev->path.pnp.port);
|
||||
}
|
||||
|
||||
static void mec1308_init(device_t dev)
|
||||
{
|
||||
struct superio_smsc_mec1308_config *conf = dev->chip_info;
|
||||
@@ -61,18 +52,13 @@ static void mec1308_init(device_t dev)
|
||||
}
|
||||
}
|
||||
|
||||
static const struct pnp_mode_ops pnp_conf_mode_ops = {
|
||||
.enter_conf_mode = pnp_enter_conf_state,
|
||||
.exit_conf_mode = pnp_exit_conf_state,
|
||||
};
|
||||
|
||||
static struct device_operations ops = {
|
||||
.read_resources = pnp_read_resources,
|
||||
.set_resources = pnp_set_resources,
|
||||
.enable_resources = pnp_enable_resources,
|
||||
.enable = pnp_alt_enable,
|
||||
.init = mec1308_init,
|
||||
.ops_pnp_mode = &pnp_conf_mode_ops,
|
||||
.ops_pnp_mode = &pnp_conf_mode_55_aa,
|
||||
};
|
||||
|
||||
static struct pnp_info pnp_dev_info[] = {
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <arch/io.h>
|
||||
#include <device/device.h>
|
||||
#include <device/pnp.h>
|
||||
#include <superio/conf_mode.h>
|
||||
#include <console/console.h>
|
||||
#include <device/smbus.h>
|
||||
#include <string.h>
|
||||
@@ -35,26 +36,18 @@
|
||||
static void enable_dev(device_t dev);
|
||||
static void sch4037_init(device_t dev);
|
||||
|
||||
static void pnp_enter_conf_state(device_t dev);
|
||||
static void pnp_exit_conf_state(device_t dev);
|
||||
|
||||
struct chip_operations superio_smsc_sch4037_ops = {
|
||||
CHIP_NAME("SMSC SCH4037 Super I/O")
|
||||
.enable_dev = enable_dev,
|
||||
};
|
||||
|
||||
static const struct pnp_mode_ops pnp_conf_mode_ops = {
|
||||
.enter_conf_mode = pnp_enter_conf_state,
|
||||
.exit_conf_mode = pnp_exit_conf_state,
|
||||
};
|
||||
|
||||
static struct device_operations ops = {
|
||||
.read_resources = pnp_read_resources,
|
||||
.set_resources = pnp_set_resources,
|
||||
.enable_resources = pnp_enable_resources,
|
||||
.enable = pnp_alt_enable,
|
||||
.init = sch4037_init,
|
||||
.ops_pnp_mode = &pnp_conf_mode_ops,
|
||||
.ops_pnp_mode = &pnp_conf_mode_55_aa,
|
||||
};
|
||||
|
||||
static struct pnp_info pnp_dev_info[] = {
|
||||
@@ -85,13 +78,3 @@ static void sch4037_init(device_t dev)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void pnp_enter_conf_state(device_t dev)
|
||||
{
|
||||
outb(0x55, dev->path.pnp.port);
|
||||
}
|
||||
|
||||
static void pnp_exit_conf_state(device_t dev)
|
||||
{
|
||||
outb(0xaa, dev->path.pnp.port);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <arch/io.h>
|
||||
#include <device/device.h>
|
||||
#include <device/pnp.h>
|
||||
#include <superio/conf_mode.h>
|
||||
#include <console/console.h>
|
||||
#include <device/smbus.h>
|
||||
#include <string.h>
|
||||
@@ -35,26 +36,18 @@
|
||||
static void enable_dev(device_t dev);
|
||||
static void sio1036_init(device_t dev);
|
||||
|
||||
static void pnp_enter_conf_state(device_t dev);
|
||||
static void pnp_exit_conf_state(device_t dev);
|
||||
|
||||
struct chip_operations superio_smsc_sio1036_ops = {
|
||||
CHIP_NAME("SMSC SIO1036 Super I/O")
|
||||
.enable_dev = enable_dev
|
||||
};
|
||||
|
||||
static const struct pnp_mode_ops pnp_conf_mode_ops = {
|
||||
.enter_conf_mode = pnp_enter_conf_state,
|
||||
.exit_conf_mode = pnp_exit_conf_state,
|
||||
};
|
||||
|
||||
static struct device_operations ops = {
|
||||
.read_resources = pnp_read_resources,
|
||||
.set_resources = pnp_set_resources,
|
||||
.enable_resources = pnp_enable_resources,
|
||||
.enable = pnp_alt_enable,
|
||||
.init = sio1036_init,
|
||||
.ops_pnp_mode = &pnp_conf_mode_ops,
|
||||
.ops_pnp_mode = &pnp_conf_mode_55_aa,
|
||||
};
|
||||
|
||||
static struct pnp_info pnp_dev_info[] = {
|
||||
@@ -84,13 +77,3 @@ static void sio1036_init(device_t dev)
|
||||
}
|
||||
}
|
||||
|
||||
static void pnp_enter_conf_state(device_t dev)
|
||||
{
|
||||
outb(0x55, dev->path.pnp.port);
|
||||
}
|
||||
|
||||
static void pnp_exit_conf_state(device_t dev)
|
||||
{
|
||||
outb(0xaa, dev->path.pnp.port);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <arch/io.h>
|
||||
#include <device/device.h>
|
||||
#include <device/pnp.h>
|
||||
#include <superio/conf_mode.h>
|
||||
#include <console/console.h>
|
||||
#include <uart8250.h>
|
||||
#include <pc80/keyboard.h>
|
||||
@@ -143,32 +144,6 @@ static const struct logical_devices {
|
||||
{SCH4304, {0, 3, 4, 5, -1, 7, -1, 11, -1, -1, -1, -1, 10, -1, -1}},
|
||||
};
|
||||
|
||||
/**
|
||||
* Enter the configuration state by writing 0x55 to the config port.
|
||||
*
|
||||
* The Super I/O configuration registers can only be modified when the chip
|
||||
* is in the configuration state. Thus, to program the registers you have
|
||||
* to a) enter config mode, b) program the registers, c) exit config mode.
|
||||
*
|
||||
* @param dev The device to use.
|
||||
*/
|
||||
static void smsc_pnp_enter_conf_state(device_t dev)
|
||||
{
|
||||
outb(0x55, dev->path.pnp.port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exit the configuration state by writing 0xaa to the config port.
|
||||
*
|
||||
* This puts the chip into the 'run' state again.
|
||||
*
|
||||
* @param dev The device to use.
|
||||
*/
|
||||
static void smsc_pnp_exit_conf_state(device_t dev)
|
||||
{
|
||||
outb(0xaa, dev->path.pnp.port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize those logical devices which need a special init.
|
||||
*
|
||||
@@ -199,11 +174,6 @@ static void smsc_init(device_t dev)
|
||||
}
|
||||
}
|
||||
|
||||
static const struct pnp_mode_ops pnp_conf_mode_ops = {
|
||||
.enter_conf_mode = smsc_pnp_enter_conf_state,
|
||||
.exit_conf_mode = smsc_pnp_exit_conf_state,
|
||||
};
|
||||
|
||||
/** Standard device operations. */
|
||||
static struct device_operations ops = {
|
||||
.read_resources = pnp_read_resources,
|
||||
@@ -211,7 +181,7 @@ static struct device_operations ops = {
|
||||
.enable_resources = pnp_enable_resources,
|
||||
.enable = pnp_alt_enable,
|
||||
.init = smsc_init,
|
||||
.ops_pnp_mode = &pnp_conf_mode_ops,
|
||||
.ops_pnp_mode = &pnp_conf_mode_55_aa,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user