| 1 |
|
| 2 |
|
| 3 |
#ifndef DEVICE_PNP_H |
| 4 |
#define DEVICE_PNP_H |
| 5 |
|
| 6 |
#include <stdint.h> |
| 7 |
#include <device/device.h> |
| 8 |
|
| 9 |
#include <device/pnp_def.h> |
| 10 |
#include <device/pnp_type.h> |
| 11 |
#include <arch/io.h> |
| 12 |
|
| 13 |
#if !ENV_PNP_SIMPLE_DEVICE |
| 14 |
|
| 15 |
|
| 16 |
void pnp_write_config(struct device *dev, u8 reg, u8 value); |
| 17 |
u8 pnp_read_config(struct device *dev, u8 reg); |
| 18 |
void pnp_unset_and_set_config(struct device *dev, u8 reg, u8 unset, u8 set); |
| 19 |
void pnp_set_logical_device(struct device *dev); |
| 20 |
void pnp_set_enable(struct device *dev, int enable); |
| 21 |
int pnp_read_enable(struct device *dev); |
| 22 |
void pnp_set_iobase(struct device *dev, u8 index, u16 iobase); |
| 23 |
void pnp_set_irq(struct device *dev, u8 index, u8 irq); |
| 24 |
void pnp_set_drq(struct device *dev, u8 index, u8 drq); |
| 25 |
|
| 26 |
#endif |
| 27 |
|
| 28 |
|
| 29 |
void pnp_read_resources(struct device *dev); |
| 30 |
void pnp_set_resources(struct device *dev); |
| 31 |
void pnp_enable_resources(struct device *dev); |
| 32 |
void pnp_enable(struct device *dev); |
| 33 |
void pnp_alt_enable(struct device *dev); |
| 34 |
|
| 35 |
extern struct device_operations pnp_ops; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
struct pnp_info { |
| 40 |
struct device_operations *ops; |
| 41 |
#define PNP_SKIP_FUNCTION 0xffff |
| 42 |
u16 function; |
| 43 |
unsigned int flags; |
| 44 |
#define PNP_IO0 0x0000001 |
| 45 |
#define PNP_IO1 0x0000002 |
| 46 |
#define PNP_IO2 0x0000004 |
| 47 |
#define PNP_IO3 0x0000008 |
| 48 |
#define PNP_IO4 0x0000010 |
| 49 |
#define PNP_IRQ0 0x0000020 |
| 50 |
#define PNP_IRQ1 0x0000040 |
| 51 |
#define PNP_DRQ0 0x0000080 |
| 52 |
#define PNP_DRQ1 0x0000100 |
| 53 |
#define PNP_EN 0x0000200 |
| 54 |
#define PNP_MSC0 0x0000400 |
| 55 |
#define PNP_MSC1 0x0000800 |
| 56 |
#define PNP_MSC2 0x0001000 |
| 57 |
#define PNP_MSC3 0x0002000 |
| 58 |
#define PNP_MSC4 0x0004000 |
| 59 |
#define PNP_MSC5 0x0008000 |
| 60 |
#define PNP_MSC6 0x0010000 |
| 61 |
#define PNP_MSC7 0x0020000 |
| 62 |
#define PNP_MSC8 0x0040000 |
| 63 |
#define PNP_MSC9 0x0080000 |
| 64 |
#define PNP_MSCA 0x0100000 |
| 65 |
#define PNP_MSCB 0x0200000 |
| 66 |
#define PNP_MSCC 0x0400000 |
| 67 |
#define PNP_MSCD 0x0800000 |
| 68 |
#define PNP_MSCE 0x1000000 |
| 69 |
u16 io0, io1, io2, io3, io4; |
| 70 |
}; |
| 71 |
struct resource *pnp_get_resource(struct device *dev, unsigned int index); |
| 72 |
void pnp_enable_devices(struct device *dev, struct device_operations *ops, |
| 73 |
unsigned int functions, struct pnp_info *info); |
| 74 |
|
| 75 |
struct pnp_mode_ops { |
| 76 |
void (*enter_conf_mode)(struct device *dev); |
| 77 |
void (*exit_conf_mode)(struct device *dev); |
| 78 |
#if CONFIG(HAVE_ACPI_TABLES) |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
void (*ssdt_enter_conf_mode)(struct device *dev, const char *idx, const char *data); |
| 86 |
void (*ssdt_exit_conf_mode)(struct device *dev, const char *idx, const char *data); |
| 87 |
#endif |
| 88 |
}; |
| 89 |
void pnp_enter_conf_mode(struct device *dev); |
| 90 |
void pnp_exit_conf_mode(struct device *dev); |
| 91 |
#if CONFIG(HAVE_ACPI_TABLES) |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
void pnp_ssdt_enter_conf_mode(struct device *dev, const char *idx, const char *data); |
| 100 |
void pnp_ssdt_exit_conf_mode(struct device *dev, const char *idx, const char *data); |
| 101 |
#endif |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
static inline u8 pnp_read_index(u16 port, u8 reg) |
| 117 |
{ |
| 118 |
outb(reg, port); |
| 119 |
return inb(port + 1); |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
static inline void pnp_write_index(u16 port, u8 reg, u8 value) |
| 135 |
{ |
| 136 |
outb(reg, port); |
| 137 |
outb(value, port + 1); |
| 138 |
} |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
static inline void pnp_unset_and_set_index(u16 port, u8 reg, u8 unset, u8 set) |
| 164 |
{ |
| 165 |
outb(reg, port); |
| 166 |
|
| 167 |
u8 value = inb(port + 1); |
| 168 |
value &= (u8)~unset; |
| 169 |
value |= set; |
| 170 |
outb(value, port + 1); |
| 171 |
} |
| 172 |
|
| 173 |
#endif |