OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [hotplug/] [acpiphp.h] - Blame information for rev 1275

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * ACPI PCI Hot Plug Controller Driver
3
 *
4
 * Copyright (C) 1995,2001 Compaq Computer Corporation
5
 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
6
 * Copyright (C) 2001 IBM Corp.
7
 * Copyright (C) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com)
8
 * Copyright (C) 2002,2003 Takayoshi Kochi (t-kochi@bq.jp.nec.com)
9
 * Copyright (C) 2002,2003 NEC Corporation
10
 *
11
 * All rights reserved.
12
 *
13
 * This program is free software; you can redistribute it and/or modify
14
 * it under the terms of the GNU General Public License as published by
15
 * the Free Software Foundation; either version 2 of the License, or (at
16
 * your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful, but
19
 * WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
21
 * NON INFRINGEMENT.  See the GNU General Public License for more
22
 * details.
23
 *
24
 * You should have received a copy of the GNU General Public License
25
 * along with this program; if not, write to the Free Software
26
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27
 *
28
 * Send feedback to <gregkh@us.ibm.com>,
29
 *                  <t-kochi@bq.jp.nec.com>
30
 *
31
 */
32
 
33
#ifndef _ACPIPHP_H
34
#define _ACPIPHP_H
35
 
36
#include <linux/acpi.h>
37
#include "pci_hotplug.h"
38
 
39
#if ACPI_CA_VERSION < 0x20020201
40
/* until we get a new version of the ACPI driver for both ia32 and ia64 ... */
41
#define acpi_util_eval_error(h,p,s)
42
 
43
static acpi_status
44
acpi_evaluate_integer (
45
        acpi_handle             handle,
46
        acpi_string             pathname,
47
        acpi_object_list        *arguments,
48
        unsigned long           *data)
49
{
50
        acpi_status             status = AE_OK;
51
        acpi_object             element;
52
        acpi_buffer             buffer = {sizeof(acpi_object), &element};
53
 
54
        if (!data)
55
                return AE_BAD_PARAMETER;
56
 
57
        status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
58
        if (ACPI_FAILURE(status)) {
59
                acpi_util_eval_error(handle, pathname, status);
60
                return status;
61
        }
62
 
63
        if (element.type != ACPI_TYPE_INTEGER) {
64
                acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
65
                return AE_BAD_DATA;
66
        }
67
 
68
        *data = element.integer.value;
69
 
70
        return AE_OK;
71
}
72
#else  /* ACPI_CA_VERSION < 0x20020201 */
73
#include <acpi/acpi_bus.h>
74
#endif
75
 
76
/* compatibility stuff for ACPI CA */
77
#ifndef ACPI_MEMORY_RANGE
78
#define ACPI_MEMORY_RANGE MEMORY_RANGE
79
#endif
80
 
81
#ifndef ACPI_IO_RANGE
82
#define ACPI_IO_RANGE IO_RANGE
83
#endif
84
 
85
#ifndef ACPI_BUS_NUMBER_RANGE
86
#define ACPI_BUS_NUMBER_RANGE BUS_NUMBER_RANGE
87
#endif
88
 
89
#ifndef ACPI_PREFETCHABLE_MEMORY
90
#define ACPI_PREFETCHABLE_MEMORY PREFETCHABLE_MEMORY
91
#endif
92
 
93
#ifndef ACPI_PRODUCER
94
#define ACPI_PRODUCER PRODUCER
95
#endif
96
 
97
#define dbg(format, arg...)                                     \
98
        do {                                                    \
99
                if (acpiphp_debug)                              \
100
                        printk(KERN_DEBUG "%s: " format,        \
101
                                MY_NAME , ## arg);              \
102
        } while (0)
103
#define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME , ## arg)
104
#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
105
#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
106
 
107
#define SLOT_MAGIC      0x67267322
108
/* name size which is used for entries in pcihpfs */
109
#define SLOT_NAME_SIZE  16              /* {_SUN} */
110
 
111
struct acpiphp_bridge;
112
struct acpiphp_slot;
113
struct pci_resource;
114
 
115
/*
116
 * struct slot - slot information for each *physical* slot
117
 */
118
struct slot {
119
        u32 magic;
120
        u8 number;
121
        struct hotplug_slot     *hotplug_slot;
122
        struct list_head        slot_list;
123
 
124
        struct acpiphp_slot     *acpi_slot;
125
};
126
 
127
/*
128
 * struct pci_resource - describes pci resource (mem, pfmem, io, bus)
129
 */
130
struct pci_resource {
131
        struct pci_resource * next;
132
        u64 base;
133
        u32 length;
134
};
135
 
136
/**
137
 * struct hpp_param - ACPI 2.0 _HPP Hot Plug Parameters
138
 * @cache_line_size in DWORD
139
 * @latency_timer in PCI clock
140
 * @enable_SERR 0 or 1
141
 * @enable_PERR 0 or 1
142
 */
143
struct hpp_param {
144
        u8 cache_line_size;
145
        u8 latency_timer;
146
        u8 enable_SERR;
147
        u8 enable_PERR;
148
};
149
 
150
 
151
/**
152
 * struct acpiphp_bridge - PCI bridge information
153
 *
154
 * for each bridge device in ACPI namespace
155
 */
156
struct acpiphp_bridge {
157
        struct list_head list;
158
        acpi_handle handle;
159
        struct acpiphp_slot *slots;
160
        int type;
161
        int nr_slots;
162
 
163
        u8 seg;
164
        u8 bus;
165
        u8 sub;
166
 
167
        u32 flags;
168
 
169
        /* This bus (host bridge) or Secondary bus (PCI-to-PCI bridge) */
170
        struct pci_bus *pci_bus;
171
 
172
        /* PCI-to-PCI bridge device */
173
        struct pci_dev *pci_dev;
174
 
175
        /* ACPI 2.0 _HPP parameters */
176
        struct hpp_param hpp;
177
 
178
        spinlock_t res_lock;
179
 
180
        /* available resources on this bus */
181
        struct pci_resource *mem_head;
182
        struct pci_resource *p_mem_head;
183
        struct pci_resource *io_head;
184
        struct pci_resource *bus_head;
185
};
186
 
187
 
188
/**
189
 * struct acpiphp_slot - PCI slot information
190
 *
191
 * PCI slot information for each *physical* PCI slot
192
 */
193
struct acpiphp_slot {
194
        struct acpiphp_slot *next;
195
        struct acpiphp_bridge *bridge;  /* parent */
196
        struct list_head funcs;         /* one slot may have different
197
                                           objects (i.e. for each function) */
198
        struct semaphore crit_sect;
199
 
200
        u32             id;             /* slot id (serial #) for hotplug core */
201
        u8              device;         /* pci device# */
202
 
203
        u32             sun;            /* ACPI _SUN (slot unique number) */
204
        u32             slotno;         /* slot number relative to bridge */
205
        u32             flags;          /* see below */
206
};
207
 
208
 
209
/**
210
 * struct acpiphp_func - PCI function information
211
 *
212
 * PCI function information for each object in ACPI namespace
213
 * typically 8 objects per slot (i.e. for each PCI function)
214
 */
215
struct acpiphp_func {
216
        struct acpiphp_slot *slot;      /* parent */
217
 
218
        struct list_head sibling;
219
        struct pci_dev *pci_dev;
220
 
221
        acpi_handle     handle;
222
 
223
        u8              function;       /* pci function# */
224
        u32             flags;          /* see below */
225
 
226
        /* resources used for this function */
227
        struct pci_resource *mem_head;
228
        struct pci_resource *p_mem_head;
229
        struct pci_resource *io_head;
230
        struct pci_resource *bus_head;
231
};
232
 
233
 
234
/* PCI bus bridge HID */
235
#define ACPI_PCI_HOST_HID               "PNP0A03"
236
 
237
/* PCI BRIDGE type */
238
#define BRIDGE_TYPE_HOST                0
239
#define BRIDGE_TYPE_P2P                 1
240
 
241
/* ACPI _STA method value (ignore bit 4; battery present) */
242
#define ACPI_STA_PRESENT                (0x00000001)
243
#define ACPI_STA_ENABLED                (0x00000002)
244
#define ACPI_STA_SHOW_IN_UI             (0x00000004)
245
#define ACPI_STA_FUNCTIONING            (0x00000008)
246
#define ACPI_STA_ALL                    (0x0000000f)
247
 
248
/* bridge flags */
249
#define BRIDGE_HAS_STA          (0x00000001)
250
#define BRIDGE_HAS_EJ0          (0x00000002)
251
#define BRIDGE_HAS_HPP          (0x00000004)
252
#define BRIDGE_HAS_PS0          (0x00000010)
253
#define BRIDGE_HAS_PS1          (0x00000020)
254
#define BRIDGE_HAS_PS2          (0x00000040)
255
#define BRIDGE_HAS_PS3          (0x00000080)
256
 
257
/* slot flags */
258
 
259
#define SLOT_POWEREDON          (0x00000001)
260
#define SLOT_ENABLED            (0x00000002)
261
#define SLOT_MULTIFUNCTION      (x000000004)
262
 
263
/* function flags */
264
 
265
#define FUNC_HAS_STA            (0x00000001)
266
#define FUNC_HAS_EJ0            (0x00000002)
267
#define FUNC_HAS_PS0            (0x00000010)
268
#define FUNC_HAS_PS1            (0x00000020)
269
#define FUNC_HAS_PS2            (0x00000040)
270
#define FUNC_HAS_PS3            (0x00000080)
271
 
272
#define FUNC_EXISTS             (0x10000000) /* to make sure we call _EJ0 only for existing funcs */
273
 
274
/* function prototypes */
275
 
276
/* acpiphp_glue.c */
277
extern int acpiphp_glue_init (void);
278
extern void acpiphp_glue_exit (void);
279
extern int acpiphp_get_num_slots (void);
280
extern struct acpiphp_slot *get_slot_from_id (int id);
281
typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
282
extern int acpiphp_for_each_slot (acpiphp_callback fn, void *data);
283
 
284
extern int acpiphp_check_bridge (struct acpiphp_bridge *bridge);
285
extern int acpiphp_enable_slot (struct acpiphp_slot *slot);
286
extern int acpiphp_disable_slot (struct acpiphp_slot *slot);
287
extern u8 acpiphp_get_power_status (struct acpiphp_slot *slot);
288
extern u8 acpiphp_get_attention_status (struct acpiphp_slot *slot);
289
extern u8 acpiphp_get_latch_status (struct acpiphp_slot *slot);
290
extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot);
291
 
292
/* acpiphp_pci.c */
293
extern struct pci_dev *acpiphp_allocate_pcidev (struct pci_bus *pbus, int dev, int fn);
294
extern int acpiphp_configure_slot (struct acpiphp_slot *slot);
295
extern int acpiphp_configure_function (struct acpiphp_func *func);
296
extern int acpiphp_unconfigure_function (struct acpiphp_func *func);
297
extern int acpiphp_detect_pci_resource (struct acpiphp_bridge *bridge);
298
extern int acpiphp_init_func_resource (struct acpiphp_func *func);
299
 
300
/* acpiphp_res.c */
301
extern struct pci_resource *acpiphp_get_io_resource (struct pci_resource **head, u32 size);
302
extern struct pci_resource *acpiphp_get_max_resource (struct pci_resource **head, u32 size);
303
extern struct pci_resource *acpiphp_get_resource (struct pci_resource **head, u32 size);
304
extern struct pci_resource *acpiphp_get_resource_with_base (struct pci_resource **head, u64 base, u32 size);
305
extern int acpiphp_resource_sort_and_combine (struct pci_resource **head);
306
extern struct pci_resource *acpiphp_make_resource (u64 base, u32 length);
307
extern void acpiphp_move_resource (struct pci_resource **from, struct pci_resource **to);
308
extern void acpiphp_free_resource (struct pci_resource **res);
309
extern void acpiphp_dump_resource (struct acpiphp_bridge *bridge); /* debug */
310
extern void acpiphp_dump_func_resource (struct acpiphp_func *func); /* debug */
311
 
312
/* variables */
313
extern int acpiphp_debug;
314
 
315
#endif /* _ACPIPHP_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.