acpiphp.h 5.3 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9
/*
 * ACPI PCI Hot Plug Controller Driver
 *
 * Copyright (C) 1995,2001 Compaq Computer Corporation
 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
 * Copyright (C) 2001 IBM Corp.
 * Copyright (C) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com)
 * Copyright (C) 2002,2003 Takayoshi Kochi (t-kochi@bq.jp.nec.com)
 * Copyright (C) 2002,2003 NEC Corporation
10 11
 * Copyright (C) 2003-2005 Matthew Wilcox (matthew.wilcox@hp.com)
 * Copyright (C) 2003-2005 Hewlett Packard
L
Linus Torvalds 已提交
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
 *
 * All rights reserved.
 *
 * 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, GOOD TITLE or
 * NON INFRINGEMENT.  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., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * Send feedback to <gregkh@us.ibm.com>,
 *		    <t-kochi@bq.jp.nec.com>
 *
 */

#ifndef _ACPIPHP_H
#define _ACPIPHP_H

#include <linux/acpi.h>
39
#include <linux/mutex.h>
40
#include <linux/pci_hotplug.h>
L
Linus Torvalds 已提交
41 42 43 44 45

#define dbg(format, arg...)					\
	do {							\
		if (acpiphp_debug)				\
			printk(KERN_DEBUG "%s: " format,	\
46
				MY_NAME , ## arg);		\
L
Linus Torvalds 已提交
47 48 49 50 51
	} while (0)
#define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME , ## arg)
#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)

52
struct acpiphp_context;
L
Linus Torvalds 已提交
53 54 55 56 57 58 59 60 61
struct acpiphp_bridge;
struct acpiphp_slot;

/*
 * struct slot - slot information for each *physical* slot
 */
struct slot {
	struct hotplug_slot	*hotplug_slot;
	struct acpiphp_slot	*acpi_slot;
62
	struct hotplug_slot_info info;
63
	unsigned int sun;	/* ACPI _SUN (Slot User Number) value */
L
Linus Torvalds 已提交
64 65
};

66 67 68 69 70
static inline const char *slot_name(struct slot *slot)
{
	return hotplug_slot_name(slot->hotplug_slot);
}

R
Randy Dunlap 已提交
71
/*
L
Linus Torvalds 已提交
72 73 74 75 76 77
 * struct acpiphp_bridge - PCI bridge information
 *
 * for each bridge device in ACPI namespace
 */
struct acpiphp_bridge {
	struct list_head list;
78
	struct list_head slots;
79
	struct kref ref;
80

81
	struct acpiphp_context *context;
82

L
Linus Torvalds 已提交
83 84 85 86 87 88 89 90 91 92
	int nr_slots;

	/* This bus (host bridge) or Secondary bus (PCI-to-PCI bridge) */
	struct pci_bus *pci_bus;

	/* PCI-to-PCI bridge device */
	struct pci_dev *pci_dev;
};


R
Randy Dunlap 已提交
93
/*
L
Linus Torvalds 已提交
94 95 96 97 98
 * struct acpiphp_slot - PCI slot information
 *
 * PCI slot information for each *physical* PCI slot
 */
struct acpiphp_slot {
99
	struct list_head node;
100
	struct pci_bus *bus;
L
Linus Torvalds 已提交
101 102
	struct list_head funcs;		/* one slot may have different
					   objects (i.e. for each function) */
103
	struct slot *slot;
104
	struct mutex crit_sect;
L
Linus Torvalds 已提交
105 106 107 108 109 110

	u8		device;		/* pci device# */
	u32		flags;		/* see below */
};


R
Randy Dunlap 已提交
111
/*
L
Linus Torvalds 已提交
112 113 114 115 116 117
 * struct acpiphp_func - PCI function information
 *
 * PCI function information for each object in ACPI namespace
 * typically 8 objects per slot (i.e. for each PCI function)
 */
struct acpiphp_func {
118 119
	struct acpiphp_bridge *parent;
	struct acpiphp_slot *slot;
L
Linus Torvalds 已提交
120 121 122 123 124 125 126

	struct list_head sibling;

	u8		function;	/* pci function# */
	u32		flags;		/* see below */
};

127 128
struct acpiphp_context {
	acpi_handle handle;
129
	struct acpiphp_func func;
130 131 132 133
	struct acpiphp_bridge *bridge;
	unsigned int refcount;
};

134 135 136 137 138
static inline struct acpiphp_context *func_to_context(struct acpiphp_func *func)
{
	return container_of(func, struct acpiphp_context, func);
}

139 140 141 142 143
static inline acpi_handle func_to_handle(struct acpiphp_func *func)
{
	return func_to_context(func)->handle;
}

R
Randy Dunlap 已提交
144
/*
L
Linus Torvalds 已提交
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
 * struct acpiphp_attention_info - device specific attention registration
 *
 * ACPI has no generic method of setting/getting attention status
 * this allows for device specific driver registration
 */
struct acpiphp_attention_info
{
	int (*set_attn)(struct hotplug_slot *slot, u8 status);
	int (*get_attn)(struct hotplug_slot *slot, u8 *status);
	struct module *owner;
};

/* PCI bus bridge HID */
#define ACPI_PCI_HOST_HID		"PNP0A03"

/* ACPI _STA method value (ignore bit 4; battery present) */
#define ACPI_STA_ALL			(0x0000000f)

/* slot flags */

#define SLOT_ENABLED		(0x00000002)
#define SLOT_MULTIFUNCTION	(0x00000004)

/* function flags */

#define FUNC_HAS_STA		(0x00000001)
#define FUNC_HAS_EJ0		(0x00000002)
172
#define FUNC_HAS_DCK            (0x00000004)
L
Linus Torvalds 已提交
173 174 175 176

/* function prototypes */

/* acpiphp_core.c */
177 178
int acpiphp_register_attention(struct acpiphp_attention_info*info);
int acpiphp_unregister_attention(struct acpiphp_attention_info *info);
179
int acpiphp_register_hotplug_slot(struct acpiphp_slot *slot, unsigned int sun);
180
void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot);
L
Linus Torvalds 已提交
181 182 183 184

/* acpiphp_glue.c */
typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);

185
int acpiphp_enable_slot(struct acpiphp_slot *slot);
186
int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot);
187 188 189 190
u8 acpiphp_get_power_status(struct acpiphp_slot *slot);
u8 acpiphp_get_attention_status(struct acpiphp_slot *slot);
u8 acpiphp_get_latch_status(struct acpiphp_slot *slot);
u8 acpiphp_get_adapter_status(struct acpiphp_slot *slot);
L
Linus Torvalds 已提交
191 192

/* variables */
193
extern bool acpiphp_debug;
194
extern bool acpiphp_disabled;
L
Linus Torvalds 已提交
195 196

#endif /* _ACPIPHP_H */