linux-old/drivers/hotplug/acpiphp.h
<<
>>
Prefs
   1/*
   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#include <acpi/acpi_bus.h>
  40
  41#define dbg(format, arg...)                                     \
  42        do {                                                    \
  43                if (acpiphp_debug)                              \
  44                        printk(KERN_DEBUG "%s: " format,        \
  45                                MY_NAME , ## arg);              \
  46        } while (0)
  47#define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME , ## arg)
  48#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
  49#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
  50
  51#define SLOT_MAGIC      0x67267322
  52/* name size which is used for entries in pcihpfs */
  53#define SLOT_NAME_SIZE  16              /* {_SUN} */
  54
  55struct acpiphp_bridge;
  56struct acpiphp_slot;
  57struct pci_resource;
  58
  59/*
  60 * struct slot - slot information for each *physical* slot
  61 */
  62struct slot {
  63        u32 magic;
  64        u8 number;
  65        struct hotplug_slot     *hotplug_slot;
  66        struct list_head        slot_list;
  67
  68        struct acpiphp_slot     *acpi_slot;
  69};
  70
  71/*
  72 * struct pci_resource - describes pci resource (mem, pfmem, io, bus)
  73 */
  74struct pci_resource {
  75        struct pci_resource * next;
  76        u64 base;
  77        u32 length;
  78};
  79
  80/**
  81 * struct hpp_param - ACPI 2.0 _HPP Hot Plug Parameters
  82 * @cache_line_size in DWORD
  83 * @latency_timer in PCI clock
  84 * @enable_SERR 0 or 1
  85 * @enable_PERR 0 or 1
  86 */
  87struct hpp_param {
  88        u8 cache_line_size;
  89        u8 latency_timer;
  90        u8 enable_SERR;
  91        u8 enable_PERR;
  92};
  93
  94
  95/**
  96 * struct acpiphp_bridge - PCI bridge information
  97 *
  98 * for each bridge device in ACPI namespace
  99 */
 100struct acpiphp_bridge {
 101        struct list_head list;
 102        acpi_handle handle;
 103        struct acpiphp_slot *slots;
 104        int type;
 105        int nr_slots;
 106
 107        u8 seg;
 108        u8 bus;
 109        u8 sub;
 110
 111        u32 flags;
 112
 113        /* This bus (host bridge) or Secondary bus (PCI-to-PCI bridge) */
 114        struct pci_bus *pci_bus;
 115
 116        /* PCI-to-PCI bridge device */
 117        struct pci_dev *pci_dev;
 118
 119        /* ACPI 2.0 _HPP parameters */
 120        struct hpp_param hpp;
 121
 122        spinlock_t res_lock;
 123
 124        /* available resources on this bus */
 125        struct pci_resource *mem_head;
 126        struct pci_resource *p_mem_head;
 127        struct pci_resource *io_head;
 128        struct pci_resource *bus_head;
 129};
 130
 131
 132/**
 133 * struct acpiphp_slot - PCI slot information
 134 *
 135 * PCI slot information for each *physical* PCI slot
 136 */
 137struct acpiphp_slot {
 138        struct acpiphp_slot *next;
 139        struct acpiphp_bridge *bridge;  /* parent */
 140        struct list_head funcs;         /* one slot may have different
 141                                           objects (i.e. for each function) */
 142        struct semaphore crit_sect;
 143
 144        u32             id;             /* slot id (serial #) for hotplug core */
 145        u8              device;         /* pci device# */
 146
 147        u32             sun;            /* ACPI _SUN (slot unique number) */
 148        u32             slotno;         /* slot number relative to bridge */
 149        u32             flags;          /* see below */
 150};
 151
 152
 153/**
 154 * struct acpiphp_func - PCI function information
 155 *
 156 * PCI function information for each object in ACPI namespace
 157 * typically 8 objects per slot (i.e. for each PCI function)
 158 */
 159struct acpiphp_func {
 160        struct acpiphp_slot *slot;      /* parent */
 161
 162        struct list_head sibling;
 163        struct pci_dev *pci_dev;
 164
 165        acpi_handle     handle;
 166
 167        u8              function;       /* pci function# */
 168        u32             flags;          /* see below */
 169
 170        /* resources used for this function */
 171        struct pci_resource *mem_head;
 172        struct pci_resource *p_mem_head;
 173        struct pci_resource *io_head;
 174        struct pci_resource *bus_head;
 175};
 176
 177
 178/* PCI bus bridge HID */
 179#define ACPI_PCI_HOST_HID               "PNP0A03"
 180
 181/* PCI BRIDGE type */
 182#define BRIDGE_TYPE_HOST                0
 183#define BRIDGE_TYPE_P2P                 1
 184
 185/* ACPI _STA method value (ignore bit 4; battery present) */
 186#define ACPI_STA_PRESENT                (0x00000001)
 187#define ACPI_STA_ENABLED                (0x00000002)
 188#define ACPI_STA_SHOW_IN_UI             (0x00000004)
 189#define ACPI_STA_FUNCTIONING            (0x00000008)
 190#define ACPI_STA_ALL                    (0x0000000f)
 191
 192/* bridge flags */
 193#define BRIDGE_HAS_STA          (0x00000001)
 194#define BRIDGE_HAS_EJ0          (0x00000002)
 195#define BRIDGE_HAS_HPP          (0x00000004)
 196#define BRIDGE_HAS_PS0          (0x00000010)
 197#define BRIDGE_HAS_PS1          (0x00000020)
 198#define BRIDGE_HAS_PS2          (0x00000040)
 199#define BRIDGE_HAS_PS3          (0x00000080)
 200
 201/* slot flags */
 202
 203#define SLOT_POWEREDON          (0x00000001)
 204#define SLOT_ENABLED            (0x00000002)
 205#define SLOT_MULTIFUNCTION      (0x00000004)
 206
 207/* function flags */
 208
 209#define FUNC_HAS_STA            (0x00000001)
 210#define FUNC_HAS_EJ0            (0x00000002)
 211#define FUNC_HAS_PS0            (0x00000010)
 212#define FUNC_HAS_PS1            (0x00000020)
 213#define FUNC_HAS_PS2            (0x00000040)
 214#define FUNC_HAS_PS3            (0x00000080)
 215
 216/* function prototypes */
 217
 218/* acpiphp_glue.c */
 219extern int acpiphp_glue_init (void);
 220extern void acpiphp_glue_exit (void);
 221extern int acpiphp_get_num_slots (void);
 222extern struct acpiphp_slot *get_slot_from_id (int id);
 223typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
 224extern int acpiphp_for_each_slot (acpiphp_callback fn, void *data);
 225
 226extern int acpiphp_check_bridge (struct acpiphp_bridge *bridge);
 227extern int acpiphp_enable_slot (struct acpiphp_slot *slot);
 228extern int acpiphp_disable_slot (struct acpiphp_slot *slot);
 229extern u8 acpiphp_get_power_status (struct acpiphp_slot *slot);
 230extern u8 acpiphp_get_attention_status (struct acpiphp_slot *slot);
 231extern u8 acpiphp_get_latch_status (struct acpiphp_slot *slot);
 232extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot);
 233extern u32 acpiphp_get_address (struct acpiphp_slot *slot);
 234
 235/* acpiphp_pci.c */
 236extern struct pci_dev *acpiphp_allocate_pcidev (struct pci_bus *pbus, int dev, int fn);
 237extern int acpiphp_configure_slot (struct acpiphp_slot *slot);
 238extern int acpiphp_configure_function (struct acpiphp_func *func);
 239extern int acpiphp_unconfigure_function (struct acpiphp_func *func);
 240extern int acpiphp_detect_pci_resource (struct acpiphp_bridge *bridge);
 241extern int acpiphp_init_func_resource (struct acpiphp_func *func);
 242
 243/* acpiphp_res.c */
 244extern struct pci_resource *acpiphp_get_io_resource (struct pci_resource **head, u32 size);
 245extern struct pci_resource *acpiphp_get_max_resource (struct pci_resource **head, u32 size);
 246extern struct pci_resource *acpiphp_get_resource (struct pci_resource **head, u32 size);
 247extern struct pci_resource *acpiphp_get_resource_with_base (struct pci_resource **head, u64 base, u32 size);
 248extern int acpiphp_resource_sort_and_combine (struct pci_resource **head);
 249extern struct pci_resource *acpiphp_make_resource (u64 base, u32 length);
 250extern void acpiphp_move_resource (struct pci_resource **from, struct pci_resource **to);
 251extern void acpiphp_free_resource (struct pci_resource **res);
 252extern void acpiphp_dump_resource (struct acpiphp_bridge *bridge); /* debug */
 253extern void acpiphp_dump_func_resource (struct acpiphp_func *func); /* debug */
 254
 255/* variables */
 256extern int acpiphp_debug;
 257
 258#endif /* _ACPIPHP_H */
 259