2003-07-19 06:28:22 +02:00
|
|
|
#ifndef DEVICE_PNP_H
|
|
|
|
#define DEVICE_PNP_H
|
|
|
|
|
2004-03-11 16:01:31 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <device/device.h>
|
|
|
|
#include <device/pnp_def.h>
|
|
|
|
|
2013-03-21 19:51:41 +01:00
|
|
|
#if !defined(__PRE_RAM__) && !defined(__SMM__)
|
2010-10-18 02:00:57 +02:00
|
|
|
/* Primitive PNP resource manipulation */
|
|
|
|
void pnp_write_config(device_t dev, u8 reg, u8 value);
|
|
|
|
u8 pnp_read_config(device_t dev, u8 reg);
|
|
|
|
void pnp_set_logical_device(device_t dev);
|
|
|
|
void pnp_set_enable(device_t dev, int enable);
|
|
|
|
int pnp_read_enable(device_t dev);
|
|
|
|
void pnp_set_iobase(device_t dev, u8 index, u16 iobase);
|
|
|
|
void pnp_set_irq(device_t dev, u8 index, u8 irq);
|
|
|
|
void pnp_set_drq(device_t dev, u8 index, u8 drq);
|
2004-03-11 16:01:31 +01:00
|
|
|
|
|
|
|
/* PNP device operations */
|
|
|
|
void pnp_read_resources(device_t dev);
|
|
|
|
void pnp_set_resources(device_t dev);
|
|
|
|
void pnp_enable_resources(device_t dev);
|
|
|
|
void pnp_enable(device_t dev);
|
pnp: Provide alternative pnp_enable() implementation
The current default implementation of pnp_enable() only disables devices
- if set so in the devicetree - but does not enable them. Enablement takes
place in pnp_enable_resources(). Yet, many PnP chips implement their own
version of pnp_enable() which also enables devices if set in the devicetree.
It's arguable, if enabling those devices makes sense, before they get
resources assigned. Maybe we can't write the resource registers if not,
who knows? The least we can do is providing a common implementation for
this behavior, and get rid of some code duplication.
Used the following cocci:
@@
expression e;
@@
+pnp_alt_enable(e);
-pnp_set_logical_device(e);
(
-pnp_set_enable(e, !!e->enabled);
|
-(e->enabled) ? pnp_set_enable(e, 1) : pnp_set_enable(e, 0);
|
-if (e->enabled) { pnp_set_enable(e, 1); }
-else { pnp_set_enable(e, 0); }
)
Change-Id: I8d695e8fcd3cf8b847b1aa99326b51a554700bc4
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: http://review.coreboot.org/3480
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2013-06-10 22:57:12 +02:00
|
|
|
void pnp_alt_enable(device_t dev);
|
2004-03-11 16:01:31 +01:00
|
|
|
|
2009-03-13 16:42:27 +01:00
|
|
|
extern struct device_operations pnp_ops;
|
2004-03-11 16:01:31 +01:00
|
|
|
|
|
|
|
/* PNP helper operations */
|
|
|
|
|
|
|
|
struct io_info {
|
|
|
|
unsigned mask, set;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct pnp_info {
|
|
|
|
struct device_operations *ops;
|
2010-12-05 23:36:14 +01:00
|
|
|
unsigned int function; /* Must be at least 16 bits (virtual LDNs)! */
|
2010-10-18 02:00:57 +02:00
|
|
|
unsigned int flags;
|
2010-02-22 07:09:43 +01:00
|
|
|
#define PNP_IO0 0x001
|
|
|
|
#define PNP_IO1 0x002
|
|
|
|
#define PNP_IO2 0x004
|
|
|
|
#define PNP_IO3 0x008
|
|
|
|
#define PNP_IRQ0 0x010
|
|
|
|
#define PNP_IRQ1 0x020
|
|
|
|
#define PNP_DRQ0 0x040
|
|
|
|
#define PNP_DRQ1 0x080
|
|
|
|
#define PNP_EN 0x100
|
|
|
|
#define PNP_MSC0 0x200
|
|
|
|
#define PNP_MSC1 0x400
|
2004-10-14 22:54:17 +02:00
|
|
|
struct io_info io0, io1, io2, io3;
|
2004-03-11 16:01:31 +01:00
|
|
|
};
|
|
|
|
struct resource *pnp_get_resource(device_t dev, unsigned index);
|
2004-10-16 08:20:29 +02:00
|
|
|
void pnp_enable_devices(struct device *dev, struct device_operations *ops,
|
2010-10-18 02:00:57 +02:00
|
|
|
unsigned int functions, struct pnp_info *info);
|
2003-07-19 06:28:22 +02:00
|
|
|
|
2013-03-21 19:51:41 +01:00
|
|
|
#endif
|
2003-07-19 06:28:22 +02:00
|
|
|
#endif /* DEVICE_PNP_H */
|