summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2008-04-30 13:59:05 -0400
committerLen Brown <len.brown@intel.com>2008-04-30 13:59:05 -0400
commit008238b54ac2350babf195084ecedbcf7851a202 (patch)
treea7cc18ea0403f4478883a3e36a6f0d2bf67eef3e /include
parent96916090f488986a4ebb8e9ffa6a3b50881d5ccd (diff)
parentdfd2e1b4e6eb46ff59c7e1c1111c967b8b5981c1 (diff)
downloadlinux-3.10-008238b54ac2350babf195084ecedbcf7851a202.tar.gz
linux-3.10-008238b54ac2350babf195084ecedbcf7851a202.tar.bz2
linux-3.10-008238b54ac2350babf195084ecedbcf7851a202.zip
Merge branch 'pnp' into release
Diffstat (limited to 'include')
-rw-r--r--include/linux/isapnp.h10
-rw-r--r--include/linux/pnp.h208
-rw-r--r--include/linux/pnpbios.h151
3 files changed, 110 insertions, 259 deletions
diff --git a/include/linux/isapnp.h b/include/linux/isapnp.h
index 1e8728a9ee8..cd5a269fdb5 100644
--- a/include/linux/isapnp.h
+++ b/include/linux/isapnp.h
@@ -26,16 +26,6 @@
#include <linux/pnp.h>
/*
- * Configuration registers (TODO: change by specification)
- */
-
-#define ISAPNP_CFG_ACTIVATE 0x30 /* byte */
-#define ISAPNP_CFG_MEM 0x40 /* 4 * dword */
-#define ISAPNP_CFG_PORT 0x60 /* 8 * word */
-#define ISAPNP_CFG_IRQ 0x70 /* 2 * word */
-#define ISAPNP_CFG_DMA 0x74 /* 2 * byte */
-
-/*
*
*/
diff --git a/include/linux/pnp.h b/include/linux/pnp.h
index b2f05c230f4..e3b2c0068de 100644
--- a/include/linux/pnp.h
+++ b/include/linux/pnp.h
@@ -13,59 +13,122 @@
#include <linux/errno.h>
#include <linux/mod_devicetable.h>
-#define PNP_MAX_PORT 40
-#define PNP_MAX_MEM 24
-#define PNP_MAX_IRQ 2
-#define PNP_MAX_DMA 2
#define PNP_NAME_LEN 50
struct pnp_protocol;
struct pnp_dev;
+struct pnp_resource_table;
/*
* Resource Management
*/
+struct resource *pnp_get_resource(struct pnp_dev *, unsigned int, unsigned int);
+
+static inline int pnp_resource_valid(struct resource *res)
+{
+ if (res && !(res->flags & IORESOURCE_UNSET))
+ return 1;
+ return 0;
+}
+
+static inline resource_size_t pnp_resource_len(struct resource *res)
+{
+ if (res->start == 0 && res->end == 0)
+ return 0;
+ return res->end - res->start + 1;
+}
+
+
+static inline resource_size_t pnp_port_start(struct pnp_dev *dev,
+ unsigned int bar)
+{
+ return pnp_get_resource(dev, IORESOURCE_IO, bar)->start;
+}
+
+static inline resource_size_t pnp_port_end(struct pnp_dev *dev,
+ unsigned int bar)
+{
+ return pnp_get_resource(dev, IORESOURCE_IO, bar)->end;
+}
+
+static inline unsigned long pnp_port_flags(struct pnp_dev *dev,
+ unsigned int bar)
+{
+ return pnp_get_resource(dev, IORESOURCE_IO, bar)->flags;
+}
+
+static inline int pnp_port_valid(struct pnp_dev *dev, unsigned int bar)
+{
+ return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_IO, bar));
+}
+
+static inline resource_size_t pnp_port_len(struct pnp_dev *dev,
+ unsigned int bar)
+{
+ return pnp_resource_len(pnp_get_resource(dev, IORESOURCE_IO, bar));
+}
+
+
+static inline resource_size_t pnp_mem_start(struct pnp_dev *dev,
+ unsigned int bar)
+{
+ return pnp_get_resource(dev, IORESOURCE_MEM, bar)->start;
+}
+
+static inline resource_size_t pnp_mem_end(struct pnp_dev *dev,
+ unsigned int bar)
+{
+ return pnp_get_resource(dev, IORESOURCE_MEM, bar)->end;
+}
+
+static inline unsigned long pnp_mem_flags(struct pnp_dev *dev, unsigned int bar)
+{
+ return pnp_get_resource(dev, IORESOURCE_MEM, bar)->flags;
+}
+
+static inline int pnp_mem_valid(struct pnp_dev *dev, unsigned int bar)
+{
+ return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_MEM, bar));
+}
+
+static inline resource_size_t pnp_mem_len(struct pnp_dev *dev,
+ unsigned int bar)
+{
+ return pnp_resource_len(pnp_get_resource(dev, IORESOURCE_MEM, bar));
+}
+
+
+static inline resource_size_t pnp_irq(struct pnp_dev *dev, unsigned int bar)
+{
+ return pnp_get_resource(dev, IORESOURCE_IRQ, bar)->start;
+}
+
+static inline unsigned long pnp_irq_flags(struct pnp_dev *dev, unsigned int bar)
+{
+ return pnp_get_resource(dev, IORESOURCE_IRQ, bar)->flags;
+}
+
+static inline int pnp_irq_valid(struct pnp_dev *dev, unsigned int bar)
+{
+ return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_IRQ, bar));
+}
+
+
+static inline resource_size_t pnp_dma(struct pnp_dev *dev, unsigned int bar)
+{
+ return pnp_get_resource(dev, IORESOURCE_DMA, bar)->start;
+}
+
+static inline unsigned long pnp_dma_flags(struct pnp_dev *dev, unsigned int bar)
+{
+ return pnp_get_resource(dev, IORESOURCE_DMA, bar)->flags;
+}
+
+static inline int pnp_dma_valid(struct pnp_dev *dev, unsigned int bar)
+{
+ return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_DMA, bar));
+}
-/* Use these instead of directly reading pnp_dev to get resource information */
-#define pnp_port_start(dev,bar) ((dev)->res.port_resource[(bar)].start)
-#define pnp_port_end(dev,bar) ((dev)->res.port_resource[(bar)].end)
-#define pnp_port_flags(dev,bar) ((dev)->res.port_resource[(bar)].flags)
-#define pnp_port_valid(dev,bar) \
- ((pnp_port_flags((dev),(bar)) & (IORESOURCE_IO | IORESOURCE_UNSET)) \
- == IORESOURCE_IO)
-#define pnp_port_len(dev,bar) \
- ((pnp_port_start((dev),(bar)) == 0 && \
- pnp_port_end((dev),(bar)) == \
- pnp_port_start((dev),(bar))) ? 0 : \
- \
- (pnp_port_end((dev),(bar)) - \
- pnp_port_start((dev),(bar)) + 1))
-
-#define pnp_mem_start(dev,bar) ((dev)->res.mem_resource[(bar)].start)
-#define pnp_mem_end(dev,bar) ((dev)->res.mem_resource[(bar)].end)
-#define pnp_mem_flags(dev,bar) ((dev)->res.mem_resource[(bar)].flags)
-#define pnp_mem_valid(dev,bar) \
- ((pnp_mem_flags((dev),(bar)) & (IORESOURCE_MEM | IORESOURCE_UNSET)) \
- == IORESOURCE_MEM)
-#define pnp_mem_len(dev,bar) \
- ((pnp_mem_start((dev),(bar)) == 0 && \
- pnp_mem_end((dev),(bar)) == \
- pnp_mem_start((dev),(bar))) ? 0 : \
- \
- (pnp_mem_end((dev),(bar)) - \
- pnp_mem_start((dev),(bar)) + 1))
-
-#define pnp_irq(dev,bar) ((dev)->res.irq_resource[(bar)].start)
-#define pnp_irq_flags(dev,bar) ((dev)->res.irq_resource[(bar)].flags)
-#define pnp_irq_valid(dev,bar) \
- ((pnp_irq_flags((dev),(bar)) & (IORESOURCE_IRQ | IORESOURCE_UNSET)) \
- == IORESOURCE_IRQ)
-
-#define pnp_dma(dev,bar) ((dev)->res.dma_resource[(bar)].start)
-#define pnp_dma_flags(dev,bar) ((dev)->res.dma_resource[(bar)].flags)
-#define pnp_dma_valid(dev,bar) \
- ((pnp_dma_flags((dev),(bar)) & (IORESOURCE_DMA | IORESOURCE_UNSET)) \
- == IORESOURCE_DMA)
#define PNP_PORT_FLAG_16BITADDR (1<<0)
#define PNP_PORT_FLAG_FIXED (1<<1)
@@ -118,13 +181,6 @@ struct pnp_option {
struct pnp_option *next; /* used to chain dependent resources */
};
-struct pnp_resource_table {
- struct resource port_resource[PNP_MAX_PORT];
- struct resource mem_resource[PNP_MAX_MEM];
- struct resource dma_resource[PNP_MAX_DMA];
- struct resource irq_resource[PNP_MAX_IRQ];
-};
-
/*
* Device Management
*/
@@ -194,10 +250,9 @@ struct pnp_dev {
int capabilities;
struct pnp_option *independent;
struct pnp_option *dependent;
- struct pnp_resource_table res;
+ struct pnp_resource_table *res;
char name[PNP_NAME_LEN]; /* contains a human-readable name */
- unsigned short regs; /* ISAPnP: supported registers */
int flags; /* used by protocols */
struct proc_dir_entry *procent; /* device entry in /proc/bus/isapnp */
void *data;
@@ -328,8 +383,8 @@ struct pnp_protocol {
char *name;
/* resource control functions */
- int (*get) (struct pnp_dev *dev, struct pnp_resource_table *res);
- int (*set) (struct pnp_dev *dev, struct pnp_resource_table *res);
+ int (*get) (struct pnp_dev *dev);
+ int (*set) (struct pnp_dev *dev);
int (*disable) (struct pnp_dev *dev);
/* protocol specific suspend/resume */
@@ -358,20 +413,12 @@ extern struct bus_type pnp_bus_type;
#if defined(CONFIG_PNP)
/* device management */
-int pnp_register_protocol(struct pnp_protocol *protocol);
-void pnp_unregister_protocol(struct pnp_protocol *protocol);
-int pnp_add_device(struct pnp_dev *dev);
int pnp_device_attach(struct pnp_dev *pnp_dev);
void pnp_device_detach(struct pnp_dev *pnp_dev);
extern struct list_head pnp_global;
extern int pnp_platform_devices;
/* multidevice card support */
-int pnp_add_card(struct pnp_card *card);
-void pnp_remove_card(struct pnp_card *card);
-int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev);
-void pnp_remove_card_device(struct pnp_dev *dev);
-int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card);
struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink,
const char *id, struct pnp_dev *from);
void pnp_release_card_device(struct pnp_dev *dev);
@@ -380,77 +427,42 @@ void pnp_unregister_card_driver(struct pnp_card_driver *drv);
extern struct list_head pnp_cards;
/* resource management */
-struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev);
-struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev,
- int priority);
-int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data);
-int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data);
-int pnp_register_port_resource(struct pnp_option *option,
- struct pnp_port *data);
-int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data);
-void pnp_init_resource_table(struct pnp_resource_table *table);
-int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res,
- int mode);
int pnp_auto_config_dev(struct pnp_dev *dev);
-int pnp_validate_config(struct pnp_dev *dev);
int pnp_start_dev(struct pnp_dev *dev);
int pnp_stop_dev(struct pnp_dev *dev);
int pnp_activate_dev(struct pnp_dev *dev);
int pnp_disable_dev(struct pnp_dev *dev);
-void pnp_resource_change(struct resource *resource, resource_size_t start,
- resource_size_t size);
/* protocol helpers */
int pnp_is_active(struct pnp_dev *dev);
int compare_pnp_id(struct pnp_id *pos, const char *id);
-int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev);
int pnp_register_driver(struct pnp_driver *drv);
void pnp_unregister_driver(struct pnp_driver *drv);
#else
/* device management */
-static inline int pnp_register_protocol(struct pnp_protocol *protocol) { return -ENODEV; }
-static inline void pnp_unregister_protocol(struct pnp_protocol *protocol) { }
-static inline int pnp_init_device(struct pnp_dev *dev) { return -ENODEV; }
-static inline int pnp_add_device(struct pnp_dev *dev) { return -ENODEV; }
static inline int pnp_device_attach(struct pnp_dev *pnp_dev) { return -ENODEV; }
static inline void pnp_device_detach(struct pnp_dev *pnp_dev) { }
#define pnp_platform_devices 0
/* multidevice card support */
-static inline int pnp_add_card(struct pnp_card *card) { return -ENODEV; }
-static inline void pnp_remove_card(struct pnp_card *card) { }
-static inline int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev) { return -ENODEV; }
-static inline void pnp_remove_card_device(struct pnp_dev *dev) { }
-static inline int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card) { return -ENODEV; }
static inline struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink, const char *id, struct pnp_dev *from) { return NULL; }
static inline void pnp_release_card_device(struct pnp_dev *dev) { }
static inline int pnp_register_card_driver(struct pnp_card_driver *drv) { return -ENODEV; }
static inline void pnp_unregister_card_driver(struct pnp_card_driver *drv) { }
/* resource management */
-static inline struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev) { return NULL; }
-static inline struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev, int priority) { return NULL; }
-static inline int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data) { return -ENODEV; }
-static inline int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data) { return -ENODEV; }
-static inline int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data) { return -ENODEV; }
-static inline int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data) { return -ENODEV; }
-static inline void pnp_init_resource_table(struct pnp_resource_table *table) { }
-static inline int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res, int mode) { return -ENODEV; }
static inline int pnp_auto_config_dev(struct pnp_dev *dev) { return -ENODEV; }
-static inline int pnp_validate_config(struct pnp_dev *dev) { return -ENODEV; }
static inline int pnp_start_dev(struct pnp_dev *dev) { return -ENODEV; }
static inline int pnp_stop_dev(struct pnp_dev *dev) { return -ENODEV; }
static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; }
static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; }
-static inline void pnp_resource_change(struct resource *resource, resource_size_t start, resource_size_t size) { }
/* protocol helpers */
static inline int pnp_is_active(struct pnp_dev *dev) { return 0; }
static inline int compare_pnp_id(struct pnp_id *pos, const char *id) { return -ENODEV; }
-static inline int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev) { return -ENODEV; }
static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; }
static inline void pnp_unregister_driver(struct pnp_driver *drv) { }
diff --git a/include/linux/pnpbios.h b/include/linux/pnpbios.h
deleted file mode 100644
index 329192adc9d..00000000000
--- a/include/linux/pnpbios.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Include file for the interface to a PnP BIOS
- *
- * Original BIOS code (C) 1998 Christian Schmidt (chr.schmidt@tu-bs.de)
- * PnP handler parts (c) 1998 Tom Lees <tom@lpsg.demon.co.uk>
- * Minor reorganizations by David Hinds <dahinds@users.sourceforge.net>
- *
- * 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, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _LINUX_PNPBIOS_H
-#define _LINUX_PNPBIOS_H
-
-#ifdef __KERNEL__
-
-#include <linux/types.h>
-#include <linux/pnp.h>
-
-/*
- * Return codes
- */
-#define PNP_SUCCESS 0x00
-#define PNP_NOT_SET_STATICALLY 0x7f
-#define PNP_UNKNOWN_FUNCTION 0x81
-#define PNP_FUNCTION_NOT_SUPPORTED 0x82
-#define PNP_INVALID_HANDLE 0x83
-#define PNP_BAD_PARAMETER 0x84
-#define PNP_SET_FAILED 0x85
-#define PNP_EVENTS_NOT_PENDING 0x86
-#define PNP_SYSTEM_NOT_DOCKED 0x87
-#define PNP_NO_ISA_PNP_CARDS 0x88
-#define PNP_UNABLE_TO_DETERMINE_DOCK_CAPABILITIES 0x89
-#define PNP_CONFIG_CHANGE_FAILED_NO_BATTERY 0x8a
-#define PNP_CONFIG_CHANGE_FAILED_RESOURCE_CONFLICT 0x8b
-#define PNP_BUFFER_TOO_SMALL 0x8c
-#define PNP_USE_ESCD_SUPPORT 0x8d
-#define PNP_MESSAGE_NOT_SUPPORTED 0x8e
-#define PNP_HARDWARE_ERROR 0x8f
-
-#define ESCD_SUCCESS 0x00
-#define ESCD_IO_ERROR_READING 0x55
-#define ESCD_INVALID 0x56
-#define ESCD_BUFFER_TOO_SMALL 0x59
-#define ESCD_NVRAM_TOO_SMALL 0x5a
-#define ESCD_FUNCTION_NOT_SUPPORTED 0x81
-
-/*
- * Events that can be received by "get event"
- */
-#define PNPEV_ABOUT_TO_CHANGE_CONFIG 0x0001
-#define PNPEV_DOCK_CHANGED 0x0002
-#define PNPEV_SYSTEM_DEVICE_CHANGED 0x0003
-#define PNPEV_CONFIG_CHANGED_FAILED 0x0004
-#define PNPEV_UNKNOWN_SYSTEM_EVENT 0xffff
-/* 0x8000 through 0xfffe are OEM defined */
-
-/*
- * Messages that should be sent through "send message"
- */
-#define PNPMSG_OK 0x00
-#define PNPMSG_ABORT 0x01
-#define PNPMSG_UNDOCK_DEFAULT_ACTION 0x40
-#define PNPMSG_POWER_OFF 0x41
-#define PNPMSG_PNP_OS_ACTIVE 0x42
-#define PNPMSG_PNP_OS_INACTIVE 0x43
-
-/*
- * Plug and Play BIOS flags
- */
-#define PNPBIOS_NO_DISABLE 0x0001
-#define PNPBIOS_NO_CONFIG 0x0002
-#define PNPBIOS_OUTPUT 0x0004
-#define PNPBIOS_INPUT 0x0008
-#define PNPBIOS_BOOTABLE 0x0010
-#define PNPBIOS_DOCK 0x0020
-#define PNPBIOS_REMOVABLE 0x0040
-#define pnpbios_is_static(x) (((x)->flags & 0x0100) == 0x0000)
-#define pnpbios_is_dynamic(x) ((x)->flags & 0x0080)
-
-/*
- * Function Parameters
- */
-#define PNPMODE_STATIC 1
-#define PNPMODE_DYNAMIC 0
-
-/* 0x8000 through 0xffff are OEM defined */
-
-#pragma pack(1)
-struct pnp_dev_node_info {
- __u16 no_nodes;
- __u16 max_node_size;
-};
-struct pnp_docking_station_info {
- __u32 location_id;
- __u32 serial;
- __u16 capabilities;
-};
-struct pnp_isa_config_struc {
- __u8 revision;
- __u8 no_csns;
- __u16 isa_rd_data_port;
- __u16 reserved;
-};
-struct escd_info_struc {
- __u16 min_escd_write_size;
- __u16 escd_size;
- __u32 nv_storage_base;
-};
-struct pnp_bios_node {
- __u16 size;
- __u8 handle;
- __u32 eisa_id;
- __u8 type_code[3];
- __u16 flags;
- __u8 data[0];
-};
-#pragma pack()
-
-#ifdef CONFIG_PNPBIOS
-
-/* non-exported */
-extern struct pnp_dev_node_info node_info;
-
-extern int pnp_bios_dev_node_info(struct pnp_dev_node_info *data);
-extern int pnp_bios_get_dev_node(u8 *nodenum, char config,
- struct pnp_bios_node *data);
-extern int pnp_bios_set_dev_node(u8 nodenum, char config,
- struct pnp_bios_node *data);
-extern int pnp_bios_get_stat_res(char *info);
-extern int pnp_bios_isapnp_config(struct pnp_isa_config_struc *data);
-extern int pnp_bios_escd_info(struct escd_info_struc *data);
-extern int pnp_bios_read_escd(char *data, u32 nvram_base);
-extern int pnp_bios_dock_station_info(struct pnp_docking_station_info *data);
-
-#endif /* CONFIG_PNPBIOS */
-
-#endif /* __KERNEL__ */
-
-#endif /* _LINUX_PNPBIOS_H */