1736759efSBjorn Helgaas /* SPDX-License-Identifier: GPL-2.0+ */
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds * Compaq Hot Plug Controller Driver
41da177e4SLinus Torvalds *
51da177e4SLinus Torvalds * Copyright (C) 1995,2001 Compaq Computer Corporation
61da177e4SLinus Torvalds * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
71da177e4SLinus Torvalds * Copyright (C) 2001 IBM
81da177e4SLinus Torvalds *
91da177e4SLinus Torvalds * All rights reserved.
101da177e4SLinus Torvalds *
111da177e4SLinus Torvalds * Send feedback to <greg@kroah.com>
121da177e4SLinus Torvalds *
131da177e4SLinus Torvalds */
141da177e4SLinus Torvalds #ifndef _CPQPHP_H
151da177e4SLinus Torvalds #define _CPQPHP_H
161da177e4SLinus Torvalds
171da177e4SLinus Torvalds #include <linux/interrupt.h>
18*31dedb8eSKrzysztof Wilczyński #include <linux/io.h> /* for read? and write? functions */
191da177e4SLinus Torvalds #include <linux/delay.h> /* for delays */
206aa4cdd0SIngo Molnar #include <linux/mutex.h>
21174cd4b1SIngo Molnar #include <linux/sched/signal.h> /* for signal_pending() */
221da177e4SLinus Torvalds
231da177e4SLinus Torvalds #define MY_NAME "cpqphp"
241da177e4SLinus Torvalds
251da177e4SLinus Torvalds #define dbg(fmt, arg...) do { if (cpqhp_debug) printk(KERN_DEBUG "%s: " fmt, MY_NAME, ## arg); } while (0)
261da177e4SLinus Torvalds #define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME, ## arg)
271da177e4SLinus Torvalds #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME, ## arg)
281da177e4SLinus Torvalds #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME, ## arg)
291da177e4SLinus Torvalds
301da177e4SLinus Torvalds
311da177e4SLinus Torvalds
321da177e4SLinus Torvalds struct smbios_system_slot {
331da177e4SLinus Torvalds u8 type;
341da177e4SLinus Torvalds u8 length;
351da177e4SLinus Torvalds u16 handle;
361da177e4SLinus Torvalds u8 name_string_num;
371da177e4SLinus Torvalds u8 slot_type;
381da177e4SLinus Torvalds u8 slot_width;
391da177e4SLinus Torvalds u8 slot_current_usage;
401da177e4SLinus Torvalds u8 slot_length;
411da177e4SLinus Torvalds u16 slot_number;
421da177e4SLinus Torvalds u8 properties1;
431da177e4SLinus Torvalds u8 properties2;
441da177e4SLinus Torvalds } __attribute__ ((packed));
451da177e4SLinus Torvalds
461da177e4SLinus Torvalds /* offsets to the smbios generic type based on the above structure layout */
471da177e4SLinus Torvalds enum smbios_system_slot_offsets {
481da177e4SLinus Torvalds SMBIOS_SLOT_GENERIC_TYPE = offsetof(struct smbios_system_slot, type),
491da177e4SLinus Torvalds SMBIOS_SLOT_GENERIC_LENGTH = offsetof(struct smbios_system_slot, length),
501da177e4SLinus Torvalds SMBIOS_SLOT_GENERIC_HANDLE = offsetof(struct smbios_system_slot, handle),
511da177e4SLinus Torvalds SMBIOS_SLOT_NAME_STRING_NUM = offsetof(struct smbios_system_slot, name_string_num),
521da177e4SLinus Torvalds SMBIOS_SLOT_TYPE = offsetof(struct smbios_system_slot, slot_type),
531da177e4SLinus Torvalds SMBIOS_SLOT_WIDTH = offsetof(struct smbios_system_slot, slot_width),
541da177e4SLinus Torvalds SMBIOS_SLOT_CURRENT_USAGE = offsetof(struct smbios_system_slot, slot_current_usage),
551da177e4SLinus Torvalds SMBIOS_SLOT_LENGTH = offsetof(struct smbios_system_slot, slot_length),
561da177e4SLinus Torvalds SMBIOS_SLOT_NUMBER = offsetof(struct smbios_system_slot, slot_number),
571da177e4SLinus Torvalds SMBIOS_SLOT_PROPERTIES1 = offsetof(struct smbios_system_slot, properties1),
581da177e4SLinus Torvalds SMBIOS_SLOT_PROPERTIES2 = offsetof(struct smbios_system_slot, properties2),
591da177e4SLinus Torvalds };
601da177e4SLinus Torvalds
611da177e4SLinus Torvalds struct smbios_generic {
621da177e4SLinus Torvalds u8 type;
631da177e4SLinus Torvalds u8 length;
641da177e4SLinus Torvalds u16 handle;
651da177e4SLinus Torvalds } __attribute__ ((packed));
661da177e4SLinus Torvalds
671da177e4SLinus Torvalds /* offsets to the smbios generic type based on the above structure layout */
681da177e4SLinus Torvalds enum smbios_generic_offsets {
691da177e4SLinus Torvalds SMBIOS_GENERIC_TYPE = offsetof(struct smbios_generic, type),
701da177e4SLinus Torvalds SMBIOS_GENERIC_LENGTH = offsetof(struct smbios_generic, length),
711da177e4SLinus Torvalds SMBIOS_GENERIC_HANDLE = offsetof(struct smbios_generic, handle),
721da177e4SLinus Torvalds };
731da177e4SLinus Torvalds
741da177e4SLinus Torvalds struct smbios_entry_point {
751da177e4SLinus Torvalds char anchor[4];
761da177e4SLinus Torvalds u8 ep_checksum;
771da177e4SLinus Torvalds u8 ep_length;
781da177e4SLinus Torvalds u8 major_version;
791da177e4SLinus Torvalds u8 minor_version;
801da177e4SLinus Torvalds u16 max_size_entry;
811da177e4SLinus Torvalds u8 ep_rev;
821da177e4SLinus Torvalds u8 reserved[5];
831da177e4SLinus Torvalds char int_anchor[5];
841da177e4SLinus Torvalds u8 int_checksum;
851da177e4SLinus Torvalds u16 st_length;
861da177e4SLinus Torvalds u32 st_address;
871da177e4SLinus Torvalds u16 number_of_entrys;
881da177e4SLinus Torvalds u8 bcd_rev;
891da177e4SLinus Torvalds } __attribute__ ((packed));
901da177e4SLinus Torvalds
911da177e4SLinus Torvalds /* offsets to the smbios entry point based on the above structure layout */
921da177e4SLinus Torvalds enum smbios_entry_point_offsets {
931da177e4SLinus Torvalds ANCHOR = offsetof(struct smbios_entry_point, anchor[0]),
941da177e4SLinus Torvalds EP_CHECKSUM = offsetof(struct smbios_entry_point, ep_checksum),
951da177e4SLinus Torvalds EP_LENGTH = offsetof(struct smbios_entry_point, ep_length),
961da177e4SLinus Torvalds MAJOR_VERSION = offsetof(struct smbios_entry_point, major_version),
971da177e4SLinus Torvalds MINOR_VERSION = offsetof(struct smbios_entry_point, minor_version),
981da177e4SLinus Torvalds MAX_SIZE_ENTRY = offsetof(struct smbios_entry_point, max_size_entry),
991da177e4SLinus Torvalds EP_REV = offsetof(struct smbios_entry_point, ep_rev),
1001da177e4SLinus Torvalds INT_ANCHOR = offsetof(struct smbios_entry_point, int_anchor[0]),
1011da177e4SLinus Torvalds INT_CHECKSUM = offsetof(struct smbios_entry_point, int_checksum),
1021da177e4SLinus Torvalds ST_LENGTH = offsetof(struct smbios_entry_point, st_length),
1031da177e4SLinus Torvalds ST_ADDRESS = offsetof(struct smbios_entry_point, st_address),
1041da177e4SLinus Torvalds NUMBER_OF_ENTRYS = offsetof(struct smbios_entry_point, number_of_entrys),
1051da177e4SLinus Torvalds BCD_REV = offsetof(struct smbios_entry_point, bcd_rev),
1061da177e4SLinus Torvalds };
1071da177e4SLinus Torvalds
1081da177e4SLinus Torvalds struct ctrl_reg { /* offset */
1091da177e4SLinus Torvalds u8 slot_RST; /* 0x00 */
1101da177e4SLinus Torvalds u8 slot_enable; /* 0x01 */
1111da177e4SLinus Torvalds u16 misc; /* 0x02 */
1121da177e4SLinus Torvalds u32 led_control; /* 0x04 */
1131da177e4SLinus Torvalds u32 int_input_clear; /* 0x08 */
1141da177e4SLinus Torvalds u32 int_mask; /* 0x0a */
1151da177e4SLinus Torvalds u8 reserved0; /* 0x10 */
1161da177e4SLinus Torvalds u8 reserved1; /* 0x11 */
1171da177e4SLinus Torvalds u8 reserved2; /* 0x12 */
1181da177e4SLinus Torvalds u8 gen_output_AB; /* 0x13 */
1191da177e4SLinus Torvalds u32 non_int_input; /* 0x14 */
1201da177e4SLinus Torvalds u32 reserved3; /* 0x18 */
1211da177e4SLinus Torvalds u32 reserved4; /* 0x1a */
1221da177e4SLinus Torvalds u32 reserved5; /* 0x20 */
1231da177e4SLinus Torvalds u8 reserved6; /* 0x24 */
1241da177e4SLinus Torvalds u8 reserved7; /* 0x25 */
1251da177e4SLinus Torvalds u16 reserved8; /* 0x26 */
1261da177e4SLinus Torvalds u8 slot_mask; /* 0x28 */
1271da177e4SLinus Torvalds u8 reserved9; /* 0x29 */
1281da177e4SLinus Torvalds u8 reserved10; /* 0x2a */
1291da177e4SLinus Torvalds u8 reserved11; /* 0x2b */
1301da177e4SLinus Torvalds u8 slot_SERR; /* 0x2c */
1311da177e4SLinus Torvalds u8 slot_power; /* 0x2d */
1321da177e4SLinus Torvalds u8 reserved12; /* 0x2e */
1331da177e4SLinus Torvalds u8 reserved13; /* 0x2f */
1341da177e4SLinus Torvalds u8 next_curr_freq; /* 0x30 */
1351da177e4SLinus Torvalds u8 reset_freq_mode; /* 0x31 */
1361da177e4SLinus Torvalds } __attribute__ ((packed));
1371da177e4SLinus Torvalds
1381da177e4SLinus Torvalds /* offsets to the controller registers based on the above structure layout */
1391da177e4SLinus Torvalds enum ctrl_offsets {
1401da177e4SLinus Torvalds SLOT_RST = offsetof(struct ctrl_reg, slot_RST),
1411da177e4SLinus Torvalds SLOT_ENABLE = offsetof(struct ctrl_reg, slot_enable),
1421da177e4SLinus Torvalds MISC = offsetof(struct ctrl_reg, misc),
1431da177e4SLinus Torvalds LED_CONTROL = offsetof(struct ctrl_reg, led_control),
1441da177e4SLinus Torvalds INT_INPUT_CLEAR = offsetof(struct ctrl_reg, int_input_clear),
1451da177e4SLinus Torvalds INT_MASK = offsetof(struct ctrl_reg, int_mask),
1461da177e4SLinus Torvalds CTRL_RESERVED0 = offsetof(struct ctrl_reg, reserved0),
1471da177e4SLinus Torvalds CTRL_RESERVED1 = offsetof(struct ctrl_reg, reserved1),
1481da177e4SLinus Torvalds CTRL_RESERVED2 = offsetof(struct ctrl_reg, reserved1),
1491da177e4SLinus Torvalds GEN_OUTPUT_AB = offsetof(struct ctrl_reg, gen_output_AB),
1501da177e4SLinus Torvalds NON_INT_INPUT = offsetof(struct ctrl_reg, non_int_input),
1511da177e4SLinus Torvalds CTRL_RESERVED3 = offsetof(struct ctrl_reg, reserved3),
1521da177e4SLinus Torvalds CTRL_RESERVED4 = offsetof(struct ctrl_reg, reserved4),
1531da177e4SLinus Torvalds CTRL_RESERVED5 = offsetof(struct ctrl_reg, reserved5),
1541da177e4SLinus Torvalds CTRL_RESERVED6 = offsetof(struct ctrl_reg, reserved6),
1551da177e4SLinus Torvalds CTRL_RESERVED7 = offsetof(struct ctrl_reg, reserved7),
1561da177e4SLinus Torvalds CTRL_RESERVED8 = offsetof(struct ctrl_reg, reserved8),
1571da177e4SLinus Torvalds SLOT_MASK = offsetof(struct ctrl_reg, slot_mask),
1581da177e4SLinus Torvalds CTRL_RESERVED9 = offsetof(struct ctrl_reg, reserved9),
1591da177e4SLinus Torvalds CTRL_RESERVED10 = offsetof(struct ctrl_reg, reserved10),
1601da177e4SLinus Torvalds CTRL_RESERVED11 = offsetof(struct ctrl_reg, reserved11),
1611da177e4SLinus Torvalds SLOT_SERR = offsetof(struct ctrl_reg, slot_SERR),
1621da177e4SLinus Torvalds SLOT_POWER = offsetof(struct ctrl_reg, slot_power),
1631da177e4SLinus Torvalds NEXT_CURR_FREQ = offsetof(struct ctrl_reg, next_curr_freq),
1641da177e4SLinus Torvalds RESET_FREQ_MODE = offsetof(struct ctrl_reg, reset_freq_mode),
1651da177e4SLinus Torvalds };
1661da177e4SLinus Torvalds
1671da177e4SLinus Torvalds struct hrt {
1681da177e4SLinus Torvalds char sig0;
1691da177e4SLinus Torvalds char sig1;
1701da177e4SLinus Torvalds char sig2;
1711da177e4SLinus Torvalds char sig3;
1721da177e4SLinus Torvalds u16 unused_IRQ;
1731da177e4SLinus Torvalds u16 PCIIRQ;
1741da177e4SLinus Torvalds u8 number_of_entries;
1751da177e4SLinus Torvalds u8 revision;
1761da177e4SLinus Torvalds u16 reserved1;
1771da177e4SLinus Torvalds u32 reserved2;
1781da177e4SLinus Torvalds } __attribute__ ((packed));
1791da177e4SLinus Torvalds
180427438c6SAlex Chiang /* offsets to the hotplug resource table registers based on the above
181427438c6SAlex Chiang * structure layout
182427438c6SAlex Chiang */
1831da177e4SLinus Torvalds enum hrt_offsets {
1841da177e4SLinus Torvalds SIG0 = offsetof(struct hrt, sig0),
1851da177e4SLinus Torvalds SIG1 = offsetof(struct hrt, sig1),
1861da177e4SLinus Torvalds SIG2 = offsetof(struct hrt, sig2),
1871da177e4SLinus Torvalds SIG3 = offsetof(struct hrt, sig3),
1881da177e4SLinus Torvalds UNUSED_IRQ = offsetof(struct hrt, unused_IRQ),
1891da177e4SLinus Torvalds PCIIRQ = offsetof(struct hrt, PCIIRQ),
1901da177e4SLinus Torvalds NUMBER_OF_ENTRIES = offsetof(struct hrt, number_of_entries),
1911da177e4SLinus Torvalds REVISION = offsetof(struct hrt, revision),
1921da177e4SLinus Torvalds HRT_RESERVED1 = offsetof(struct hrt, reserved1),
1931da177e4SLinus Torvalds HRT_RESERVED2 = offsetof(struct hrt, reserved2),
1941da177e4SLinus Torvalds };
1951da177e4SLinus Torvalds
1961da177e4SLinus Torvalds struct slot_rt {
1971da177e4SLinus Torvalds u8 dev_func;
1981da177e4SLinus Torvalds u8 primary_bus;
1991da177e4SLinus Torvalds u8 secondary_bus;
2001da177e4SLinus Torvalds u8 max_bus;
2011da177e4SLinus Torvalds u16 io_base;
2021da177e4SLinus Torvalds u16 io_length;
2031da177e4SLinus Torvalds u16 mem_base;
2041da177e4SLinus Torvalds u16 mem_length;
2051da177e4SLinus Torvalds u16 pre_mem_base;
2061da177e4SLinus Torvalds u16 pre_mem_length;
2071da177e4SLinus Torvalds } __attribute__ ((packed));
2081da177e4SLinus Torvalds
209427438c6SAlex Chiang /* offsets to the hotplug slot resource table registers based on the above
210427438c6SAlex Chiang * structure layout
211427438c6SAlex Chiang */
2121da177e4SLinus Torvalds enum slot_rt_offsets {
2131da177e4SLinus Torvalds DEV_FUNC = offsetof(struct slot_rt, dev_func),
2141da177e4SLinus Torvalds PRIMARY_BUS = offsetof(struct slot_rt, primary_bus),
2151da177e4SLinus Torvalds SECONDARY_BUS = offsetof(struct slot_rt, secondary_bus),
2161da177e4SLinus Torvalds MAX_BUS = offsetof(struct slot_rt, max_bus),
2171da177e4SLinus Torvalds IO_BASE = offsetof(struct slot_rt, io_base),
2181da177e4SLinus Torvalds IO_LENGTH = offsetof(struct slot_rt, io_length),
2191da177e4SLinus Torvalds MEM_BASE = offsetof(struct slot_rt, mem_base),
2201da177e4SLinus Torvalds MEM_LENGTH = offsetof(struct slot_rt, mem_length),
2211da177e4SLinus Torvalds PRE_MEM_BASE = offsetof(struct slot_rt, pre_mem_base),
2221da177e4SLinus Torvalds PRE_MEM_LENGTH = offsetof(struct slot_rt, pre_mem_length),
2231da177e4SLinus Torvalds };
2241da177e4SLinus Torvalds
2251da177e4SLinus Torvalds struct pci_func {
2261da177e4SLinus Torvalds struct pci_func *next;
2271da177e4SLinus Torvalds u8 bus;
2281da177e4SLinus Torvalds u8 device;
2291da177e4SLinus Torvalds u8 function;
2301da177e4SLinus Torvalds u8 is_a_board;
2311da177e4SLinus Torvalds u16 status;
2321da177e4SLinus Torvalds u8 configured;
2331da177e4SLinus Torvalds u8 switch_save;
2341da177e4SLinus Torvalds u8 presence_save;
2351da177e4SLinus Torvalds u32 base_length[0x06];
2361da177e4SLinus Torvalds u8 base_type[0x06];
2371da177e4SLinus Torvalds u16 reserved2;
2381da177e4SLinus Torvalds u32 config_space[0x20];
2391da177e4SLinus Torvalds struct pci_resource *mem_head;
2401da177e4SLinus Torvalds struct pci_resource *p_mem_head;
2411da177e4SLinus Torvalds struct pci_resource *io_head;
2421da177e4SLinus Torvalds struct pci_resource *bus_head;
2431da177e4SLinus Torvalds struct timer_list *p_task_event;
2441da177e4SLinus Torvalds struct pci_dev *pci_dev;
2451da177e4SLinus Torvalds };
2461da177e4SLinus Torvalds
2471da177e4SLinus Torvalds struct slot {
2481da177e4SLinus Torvalds struct slot *next;
2491da177e4SLinus Torvalds u8 bus;
2501da177e4SLinus Torvalds u8 device;
2511da177e4SLinus Torvalds u8 number;
2521da177e4SLinus Torvalds u8 is_a_board;
2531da177e4SLinus Torvalds u8 configured;
2541da177e4SLinus Torvalds u8 state;
2551da177e4SLinus Torvalds u8 switch_save;
2561da177e4SLinus Torvalds u8 presence_save;
2571da177e4SLinus Torvalds u32 capabilities;
2581da177e4SLinus Torvalds u16 reserved2;
2591da177e4SLinus Torvalds struct timer_list task_event;
2601da177e4SLinus Torvalds u8 hp_slot;
2611da177e4SLinus Torvalds struct controller *ctrl;
2621da177e4SLinus Torvalds void __iomem *p_sm_slot;
263125450f8SLukas Wunner struct hotplug_slot hotplug_slot;
2641da177e4SLinus Torvalds };
2651da177e4SLinus Torvalds
2661da177e4SLinus Torvalds struct pci_resource {
2671da177e4SLinus Torvalds struct pci_resource *next;
2681da177e4SLinus Torvalds u32 base;
2691da177e4SLinus Torvalds u32 length;
2701da177e4SLinus Torvalds };
2711da177e4SLinus Torvalds
2721da177e4SLinus Torvalds struct event_info {
2731da177e4SLinus Torvalds u32 event_type;
2741da177e4SLinus Torvalds u8 hp_slot;
2751da177e4SLinus Torvalds };
2761da177e4SLinus Torvalds
2771da177e4SLinus Torvalds struct controller {
2781da177e4SLinus Torvalds struct controller *next;
2791da177e4SLinus Torvalds u32 ctrl_int_comp;
2806aa4cdd0SIngo Molnar struct mutex crit_sect; /* critical section mutex */
2811da177e4SLinus Torvalds void __iomem *hpc_reg; /* cookie for our pci controller location */
2821da177e4SLinus Torvalds struct pci_resource *mem_head;
2831da177e4SLinus Torvalds struct pci_resource *p_mem_head;
2841da177e4SLinus Torvalds struct pci_resource *io_head;
2851da177e4SLinus Torvalds struct pci_resource *bus_head;
2861da177e4SLinus Torvalds struct pci_dev *pci_dev;
2871da177e4SLinus Torvalds struct pci_bus *pci_bus;
2881da177e4SLinus Torvalds struct event_info event_queue[10];
2891da177e4SLinus Torvalds struct slot *slot;
2901da177e4SLinus Torvalds u8 next_event;
2911da177e4SLinus Torvalds u8 interrupt;
2921da177e4SLinus Torvalds u8 cfgspc_irq;
2931da177e4SLinus Torvalds u8 bus; /* bus number for the pci hotplug controller */
2941da177e4SLinus Torvalds u8 rev;
2951da177e4SLinus Torvalds u8 slot_device_offset;
2961da177e4SLinus Torvalds u8 first_slot;
2971da177e4SLinus Torvalds u8 add_support;
2981da177e4SLinus Torvalds u8 push_flag;
2991da177e4SLinus Torvalds u8 push_button; /* 0 = no pushbutton, 1 = pushbutton present */
3001da177e4SLinus Torvalds u8 slot_switch_type; /* 0 = no switch, 1 = switch present */
3011da177e4SLinus Torvalds u8 defeature_PHP; /* 0 = PHP not supported, 1 = PHP supported */
3021da177e4SLinus Torvalds u8 alternate_base_address; /* 0 = not supported, 1 = supported */
3031da177e4SLinus Torvalds u8 pci_config_space; /* Index/data access to working registers 0 = not supported, 1 = supported */
3041da177e4SLinus Torvalds u8 pcix_speed_capability; /* PCI-X */
3051da177e4SLinus Torvalds u8 pcix_support; /* PCI-X */
3061da177e4SLinus Torvalds u16 vendor_id;
3071da177e4SLinus Torvalds struct work_struct int_task_event;
3081da177e4SLinus Torvalds wait_queue_head_t queue; /* sleep & wake process */
3099f3f4681SGreg Kroah-Hartman struct dentry *dentry; /* debugfs dentry */
3101da177e4SLinus Torvalds };
3111da177e4SLinus Torvalds
3121da177e4SLinus Torvalds struct irq_mapping {
3131da177e4SLinus Torvalds u8 barber_pole;
3141da177e4SLinus Torvalds u8 valid_INT;
3151da177e4SLinus Torvalds u8 interrupt[4];
3161da177e4SLinus Torvalds };
3171da177e4SLinus Torvalds
3181da177e4SLinus Torvalds struct resource_lists {
3191da177e4SLinus Torvalds struct pci_resource *mem_head;
3201da177e4SLinus Torvalds struct pci_resource *p_mem_head;
3211da177e4SLinus Torvalds struct pci_resource *io_head;
3221da177e4SLinus Torvalds struct pci_resource *bus_head;
3231da177e4SLinus Torvalds struct irq_mapping *irqs;
3241da177e4SLinus Torvalds };
3251da177e4SLinus Torvalds
3261da177e4SLinus Torvalds #define ROM_PHY_ADDR 0x0F0000
3271da177e4SLinus Torvalds #define ROM_PHY_LEN 0x00ffff
3281da177e4SLinus Torvalds
3291da177e4SLinus Torvalds #define PCI_HPC_ID 0xA0F7
3301da177e4SLinus Torvalds #define PCI_SUB_HPC_ID 0xA2F7
3311da177e4SLinus Torvalds #define PCI_SUB_HPC_ID2 0xA2F8
3321da177e4SLinus Torvalds #define PCI_SUB_HPC_ID3 0xA2F9
3331da177e4SLinus Torvalds #define PCI_SUB_HPC_ID_INTC 0xA2FA
3341da177e4SLinus Torvalds #define PCI_SUB_HPC_ID4 0xA2FD
3351da177e4SLinus Torvalds
3361da177e4SLinus Torvalds #define INT_BUTTON_IGNORE 0
3371da177e4SLinus Torvalds #define INT_PRESENCE_ON 1
3381da177e4SLinus Torvalds #define INT_PRESENCE_OFF 2
3391da177e4SLinus Torvalds #define INT_SWITCH_CLOSE 3
3401da177e4SLinus Torvalds #define INT_SWITCH_OPEN 4
3411da177e4SLinus Torvalds #define INT_POWER_FAULT 5
3421da177e4SLinus Torvalds #define INT_POWER_FAULT_CLEAR 6
3431da177e4SLinus Torvalds #define INT_BUTTON_PRESS 7
3441da177e4SLinus Torvalds #define INT_BUTTON_RELEASE 8
3451da177e4SLinus Torvalds #define INT_BUTTON_CANCEL 9
3461da177e4SLinus Torvalds
3471da177e4SLinus Torvalds #define STATIC_STATE 0
3481da177e4SLinus Torvalds #define BLINKINGON_STATE 1
3491da177e4SLinus Torvalds #define BLINKINGOFF_STATE 2
3501da177e4SLinus Torvalds #define POWERON_STATE 3
3511da177e4SLinus Torvalds #define POWEROFF_STATE 4
3521da177e4SLinus Torvalds
3531da177e4SLinus Torvalds #define PCISLOT_INTERLOCK_CLOSED 0x00000001
3541da177e4SLinus Torvalds #define PCISLOT_ADAPTER_PRESENT 0x00000002
3551da177e4SLinus Torvalds #define PCISLOT_POWERED 0x00000004
3561da177e4SLinus Torvalds #define PCISLOT_66_MHZ_OPERATION 0x00000008
3571da177e4SLinus Torvalds #define PCISLOT_64_BIT_OPERATION 0x00000010
3581da177e4SLinus Torvalds #define PCISLOT_REPLACE_SUPPORTED 0x00000020
3591da177e4SLinus Torvalds #define PCISLOT_ADD_SUPPORTED 0x00000040
3601da177e4SLinus Torvalds #define PCISLOT_INTERLOCK_SUPPORTED 0x00000080
3611da177e4SLinus Torvalds #define PCISLOT_66_MHZ_SUPPORTED 0x00000100
3621da177e4SLinus Torvalds #define PCISLOT_64_BIT_SUPPORTED 0x00000200
3631da177e4SLinus Torvalds
3641da177e4SLinus Torvalds #define PCI_TO_PCI_BRIDGE_CLASS 0x00060400
3651da177e4SLinus Torvalds
3661da177e4SLinus Torvalds #define INTERLOCK_OPEN 0x00000002
3671da177e4SLinus Torvalds #define ADD_NOT_SUPPORTED 0x00000003
3681da177e4SLinus Torvalds #define CARD_FUNCTIONING 0x00000005
3691da177e4SLinus Torvalds #define ADAPTER_NOT_SAME 0x00000006
3701da177e4SLinus Torvalds #define NO_ADAPTER_PRESENT 0x00000009
3711da177e4SLinus Torvalds #define NOT_ENOUGH_RESOURCES 0x0000000B
3721da177e4SLinus Torvalds #define DEVICE_TYPE_NOT_SUPPORTED 0x0000000C
3731da177e4SLinus Torvalds #define POWER_FAILURE 0x0000000E
3741da177e4SLinus Torvalds
3751da177e4SLinus Torvalds #define REMOVE_NOT_SUPPORTED 0x00000003
3761da177e4SLinus Torvalds
3771da177e4SLinus Torvalds
3781da177e4SLinus Torvalds /*
3791da177e4SLinus Torvalds * error Messages
3801da177e4SLinus Torvalds */
3811da177e4SLinus Torvalds #define msg_initialization_err "Initialization failure, error=%d\n"
3821da177e4SLinus Torvalds #define msg_HPC_rev_error "Unsupported revision of the PCI hot plug controller found.\n"
3831da177e4SLinus Torvalds #define msg_HPC_non_compaq_or_intel "The PCI hot plug controller is not supported by this driver.\n"
3841da177e4SLinus Torvalds #define msg_HPC_not_supported "this system is not supported by this version of cpqphpd. Upgrade to a newer version of cpqphpd\n"
3851da177e4SLinus Torvalds #define msg_unable_to_save "unable to store PCI hot plug add resource information. This system must be rebooted before adding any PCI devices.\n"
3861da177e4SLinus Torvalds #define msg_button_on "PCI slot #%d - powering on due to button press.\n"
3871da177e4SLinus Torvalds #define msg_button_off "PCI slot #%d - powering off due to button press.\n"
3881da177e4SLinus Torvalds #define msg_button_cancel "PCI slot #%d - action canceled due to button press.\n"
3891da177e4SLinus Torvalds #define msg_button_ignore "PCI slot #%d - button press ignored. (action in progress...)\n"
3901da177e4SLinus Torvalds
3911da177e4SLinus Torvalds
3929f3f4681SGreg Kroah-Hartman /* debugfs functions for the hotplug controller info */
393f39d5b72SBjorn Helgaas void cpqhp_initialize_debugfs(void);
394f39d5b72SBjorn Helgaas void cpqhp_shutdown_debugfs(void);
395f39d5b72SBjorn Helgaas void cpqhp_create_debugfs_files(struct controller *ctrl);
396f39d5b72SBjorn Helgaas void cpqhp_remove_debugfs_files(struct controller *ctrl);
3971da177e4SLinus Torvalds
3981da177e4SLinus Torvalds /* controller functions */
39934d773f6SKees Cook void cpqhp_pushbutton_thread(struct timer_list *t);
400f39d5b72SBjorn Helgaas irqreturn_t cpqhp_ctrl_intr(int IRQ, void *data);
401f39d5b72SBjorn Helgaas int cpqhp_find_available_resources(struct controller *ctrl,
40286a58023SAlex Chiang void __iomem *rom_start);
403f39d5b72SBjorn Helgaas int cpqhp_event_start_thread(void);
404f39d5b72SBjorn Helgaas void cpqhp_event_stop_thread(void);
405f39d5b72SBjorn Helgaas struct pci_func *cpqhp_slot_create(unsigned char busnumber);
406f39d5b72SBjorn Helgaas struct pci_func *cpqhp_slot_find(unsigned char bus, unsigned char device,
40786a58023SAlex Chiang unsigned char index);
408f39d5b72SBjorn Helgaas int cpqhp_process_SI(struct controller *ctrl, struct pci_func *func);
409f39d5b72SBjorn Helgaas int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func);
410f39d5b72SBjorn Helgaas int cpqhp_hardware_test(struct controller *ctrl, int test_num);
4111da177e4SLinus Torvalds
4121da177e4SLinus Torvalds /* resource functions */
413f39d5b72SBjorn Helgaas int cpqhp_resource_sort_and_combine(struct pci_resource **head);
4141da177e4SLinus Torvalds
4151da177e4SLinus Torvalds /* pci functions */
416f39d5b72SBjorn Helgaas int cpqhp_set_irq(u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num);
417f39d5b72SBjorn Helgaas int cpqhp_get_bus_dev(struct controller *ctrl, u8 *bus_num, u8 *dev_num,
41886a58023SAlex Chiang u8 slot);
419f39d5b72SBjorn Helgaas int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug);
420f39d5b72SBjorn Helgaas int cpqhp_save_base_addr_length(struct controller *ctrl, struct pci_func *func);
421f39d5b72SBjorn Helgaas int cpqhp_save_used_resources(struct controller *ctrl, struct pci_func *func);
422f39d5b72SBjorn Helgaas int cpqhp_configure_board(struct controller *ctrl, struct pci_func *func);
423f39d5b72SBjorn Helgaas int cpqhp_save_slot_config(struct controller *ctrl, struct pci_func *new_slot);
424f39d5b72SBjorn Helgaas int cpqhp_valid_replace(struct controller *ctrl, struct pci_func *func);
425f39d5b72SBjorn Helgaas void cpqhp_destroy_board_resources(struct pci_func *func);
426f39d5b72SBjorn Helgaas int cpqhp_return_board_resources(struct pci_func *func,
42786a58023SAlex Chiang struct resource_lists *resources);
428f39d5b72SBjorn Helgaas void cpqhp_destroy_resource_list(struct resource_lists *resources);
429f39d5b72SBjorn Helgaas int cpqhp_configure_device(struct controller *ctrl, struct pci_func *func);
430f39d5b72SBjorn Helgaas int cpqhp_unconfigure_device(struct pci_func *func);
4311da177e4SLinus Torvalds
4321da177e4SLinus Torvalds /* Global variables */
4331da177e4SLinus Torvalds extern int cpqhp_debug;
4341da177e4SLinus Torvalds extern int cpqhp_legacy_mode;
4351da177e4SLinus Torvalds extern struct controller *cpqhp_ctrl_list;
4361da177e4SLinus Torvalds extern struct pci_func *cpqhp_slot_list[256];
437b019ee67SAlex Chiang extern struct irq_routing_table *cpqhp_routing_table;
4381da177e4SLinus Torvalds
4391da177e4SLinus Torvalds /* these can be gotten rid of, but for debugging they are purty */
4401da177e4SLinus Torvalds extern u8 cpqhp_nic_irq;
4411da177e4SLinus Torvalds extern u8 cpqhp_disk_irq;
4421da177e4SLinus Torvalds
4431da177e4SLinus Torvalds
4441da177e4SLinus Torvalds /* inline functions */
4451da177e4SLinus Torvalds
slot_name(struct slot * slot)4466d1e87daSAlex Chiang static inline const char *slot_name(struct slot *slot)
44730ac7acdSAlex Chiang {
448125450f8SLukas Wunner return hotplug_slot_name(&slot->hotplug_slot);
449125450f8SLukas Wunner }
450125450f8SLukas Wunner
to_slot(struct hotplug_slot * hotplug_slot)451125450f8SLukas Wunner static inline struct slot *to_slot(struct hotplug_slot *hotplug_slot)
452125450f8SLukas Wunner {
453125450f8SLukas Wunner return container_of(hotplug_slot, struct slot, hotplug_slot);
45430ac7acdSAlex Chiang }
45530ac7acdSAlex Chiang
4561da177e4SLinus Torvalds /*
4571da177e4SLinus Torvalds * return_resource
4581da177e4SLinus Torvalds *
4591da177e4SLinus Torvalds * Puts node back in the resource list pointed to by head
4601da177e4SLinus Torvalds */
return_resource(struct pci_resource ** head,struct pci_resource * node)46186a58023SAlex Chiang static inline void return_resource(struct pci_resource **head,
46286a58023SAlex Chiang struct pci_resource *node)
4631da177e4SLinus Torvalds {
4641da177e4SLinus Torvalds if (!node || !head)
4651da177e4SLinus Torvalds return;
4661da177e4SLinus Torvalds node->next = *head;
4671da177e4SLinus Torvalds *head = node;
4681da177e4SLinus Torvalds }
4691da177e4SLinus Torvalds
set_SOGO(struct controller * ctrl)4701da177e4SLinus Torvalds static inline void set_SOGO(struct controller *ctrl)
4711da177e4SLinus Torvalds {
4721da177e4SLinus Torvalds u16 misc;
4731da177e4SLinus Torvalds
4741da177e4SLinus Torvalds misc = readw(ctrl->hpc_reg + MISC);
4751da177e4SLinus Torvalds misc = (misc | 0x0001) & 0xFFFB;
4761da177e4SLinus Torvalds writew(misc, ctrl->hpc_reg + MISC);
4771da177e4SLinus Torvalds }
4781da177e4SLinus Torvalds
4791da177e4SLinus Torvalds
amber_LED_on(struct controller * ctrl,u8 slot)4801da177e4SLinus Torvalds static inline void amber_LED_on(struct controller *ctrl, u8 slot)
4811da177e4SLinus Torvalds {
4821da177e4SLinus Torvalds u32 led_control;
4831da177e4SLinus Torvalds
4841da177e4SLinus Torvalds led_control = readl(ctrl->hpc_reg + LED_CONTROL);
4851da177e4SLinus Torvalds led_control |= (0x01010000L << slot);
4861da177e4SLinus Torvalds writel(led_control, ctrl->hpc_reg + LED_CONTROL);
4871da177e4SLinus Torvalds }
4881da177e4SLinus Torvalds
4891da177e4SLinus Torvalds
amber_LED_off(struct controller * ctrl,u8 slot)4901da177e4SLinus Torvalds static inline void amber_LED_off(struct controller *ctrl, u8 slot)
4911da177e4SLinus Torvalds {
4921da177e4SLinus Torvalds u32 led_control;
4931da177e4SLinus Torvalds
4941da177e4SLinus Torvalds led_control = readl(ctrl->hpc_reg + LED_CONTROL);
4951da177e4SLinus Torvalds led_control &= ~(0x01010000L << slot);
4961da177e4SLinus Torvalds writel(led_control, ctrl->hpc_reg + LED_CONTROL);
4971da177e4SLinus Torvalds }
4981da177e4SLinus Torvalds
4991da177e4SLinus Torvalds
read_amber_LED(struct controller * ctrl,u8 slot)5001da177e4SLinus Torvalds static inline int read_amber_LED(struct controller *ctrl, u8 slot)
5011da177e4SLinus Torvalds {
5021da177e4SLinus Torvalds u32 led_control;
5031da177e4SLinus Torvalds
5041da177e4SLinus Torvalds led_control = readl(ctrl->hpc_reg + LED_CONTROL);
5051da177e4SLinus Torvalds led_control &= (0x01010000L << slot);
5061da177e4SLinus Torvalds
5071da177e4SLinus Torvalds return led_control ? 1 : 0;
5081da177e4SLinus Torvalds }
5091da177e4SLinus Torvalds
5101da177e4SLinus Torvalds
green_LED_on(struct controller * ctrl,u8 slot)5111da177e4SLinus Torvalds static inline void green_LED_on(struct controller *ctrl, u8 slot)
5121da177e4SLinus Torvalds {
5131da177e4SLinus Torvalds u32 led_control;
5141da177e4SLinus Torvalds
5151da177e4SLinus Torvalds led_control = readl(ctrl->hpc_reg + LED_CONTROL);
5161da177e4SLinus Torvalds led_control |= 0x0101L << slot;
5171da177e4SLinus Torvalds writel(led_control, ctrl->hpc_reg + LED_CONTROL);
5181da177e4SLinus Torvalds }
5191da177e4SLinus Torvalds
green_LED_off(struct controller * ctrl,u8 slot)5201da177e4SLinus Torvalds static inline void green_LED_off(struct controller *ctrl, u8 slot)
5211da177e4SLinus Torvalds {
5221da177e4SLinus Torvalds u32 led_control;
5231da177e4SLinus Torvalds
5241da177e4SLinus Torvalds led_control = readl(ctrl->hpc_reg + LED_CONTROL);
5251da177e4SLinus Torvalds led_control &= ~(0x0101L << slot);
5261da177e4SLinus Torvalds writel(led_control, ctrl->hpc_reg + LED_CONTROL);
5271da177e4SLinus Torvalds }
5281da177e4SLinus Torvalds
5291da177e4SLinus Torvalds
green_LED_blink(struct controller * ctrl,u8 slot)5301da177e4SLinus Torvalds static inline void green_LED_blink(struct controller *ctrl, u8 slot)
5311da177e4SLinus Torvalds {
5321da177e4SLinus Torvalds u32 led_control;
5331da177e4SLinus Torvalds
5341da177e4SLinus Torvalds led_control = readl(ctrl->hpc_reg + LED_CONTROL);
5351da177e4SLinus Torvalds led_control &= ~(0x0101L << slot);
5361da177e4SLinus Torvalds led_control |= (0x0001L << slot);
5371da177e4SLinus Torvalds writel(led_control, ctrl->hpc_reg + LED_CONTROL);
5381da177e4SLinus Torvalds }
5391da177e4SLinus Torvalds
5401da177e4SLinus Torvalds
slot_disable(struct controller * ctrl,u8 slot)5411da177e4SLinus Torvalds static inline void slot_disable(struct controller *ctrl, u8 slot)
5421da177e4SLinus Torvalds {
5431da177e4SLinus Torvalds u8 slot_enable;
5441da177e4SLinus Torvalds
5451da177e4SLinus Torvalds slot_enable = readb(ctrl->hpc_reg + SLOT_ENABLE);
5461da177e4SLinus Torvalds slot_enable &= ~(0x01 << slot);
5471da177e4SLinus Torvalds writeb(slot_enable, ctrl->hpc_reg + SLOT_ENABLE);
5481da177e4SLinus Torvalds }
5491da177e4SLinus Torvalds
5501da177e4SLinus Torvalds
slot_enable(struct controller * ctrl,u8 slot)5511da177e4SLinus Torvalds static inline void slot_enable(struct controller *ctrl, u8 slot)
5521da177e4SLinus Torvalds {
5531da177e4SLinus Torvalds u8 slot_enable;
5541da177e4SLinus Torvalds
5551da177e4SLinus Torvalds slot_enable = readb(ctrl->hpc_reg + SLOT_ENABLE);
5561da177e4SLinus Torvalds slot_enable |= (0x01 << slot);
5571da177e4SLinus Torvalds writeb(slot_enable, ctrl->hpc_reg + SLOT_ENABLE);
5581da177e4SLinus Torvalds }
5591da177e4SLinus Torvalds
5601da177e4SLinus Torvalds
is_slot_enabled(struct controller * ctrl,u8 slot)5611da177e4SLinus Torvalds static inline u8 is_slot_enabled(struct controller *ctrl, u8 slot)
5621da177e4SLinus Torvalds {
5631da177e4SLinus Torvalds u8 slot_enable;
5641da177e4SLinus Torvalds
5651da177e4SLinus Torvalds slot_enable = readb(ctrl->hpc_reg + SLOT_ENABLE);
5661da177e4SLinus Torvalds slot_enable &= (0x01 << slot);
5671da177e4SLinus Torvalds return slot_enable ? 1 : 0;
5681da177e4SLinus Torvalds }
5691da177e4SLinus Torvalds
5701da177e4SLinus Torvalds
read_slot_enable(struct controller * ctrl)5711da177e4SLinus Torvalds static inline u8 read_slot_enable(struct controller *ctrl)
5721da177e4SLinus Torvalds {
5731da177e4SLinus Torvalds return readb(ctrl->hpc_reg + SLOT_ENABLE);
5741da177e4SLinus Torvalds }
5751da177e4SLinus Torvalds
5761da177e4SLinus Torvalds
577427438c6SAlex Chiang /**
5781da177e4SLinus Torvalds * get_controller_speed - find the current frequency/mode of controller.
5791da177e4SLinus Torvalds *
5801da177e4SLinus Torvalds * @ctrl: controller to get frequency/mode for.
5811da177e4SLinus Torvalds *
5821da177e4SLinus Torvalds * Returns controller speed.
5831da177e4SLinus Torvalds */
get_controller_speed(struct controller * ctrl)5841da177e4SLinus Torvalds static inline u8 get_controller_speed(struct controller *ctrl)
5851da177e4SLinus Torvalds {
5861da177e4SLinus Torvalds u8 curr_freq;
5871da177e4SLinus Torvalds u16 misc;
5881da177e4SLinus Torvalds
5891da177e4SLinus Torvalds if (ctrl->pcix_support) {
5901da177e4SLinus Torvalds curr_freq = readb(ctrl->hpc_reg + NEXT_CURR_FREQ);
5911da177e4SLinus Torvalds if ((curr_freq & 0xB0) == 0xB0)
5921da177e4SLinus Torvalds return PCI_SPEED_133MHz_PCIX;
5931da177e4SLinus Torvalds if ((curr_freq & 0xA0) == 0xA0)
5941da177e4SLinus Torvalds return PCI_SPEED_100MHz_PCIX;
5951da177e4SLinus Torvalds if ((curr_freq & 0x90) == 0x90)
5961da177e4SLinus Torvalds return PCI_SPEED_66MHz_PCIX;
5971da177e4SLinus Torvalds if (curr_freq & 0x10)
5981da177e4SLinus Torvalds return PCI_SPEED_66MHz;
5991da177e4SLinus Torvalds
6001da177e4SLinus Torvalds return PCI_SPEED_33MHz;
6011da177e4SLinus Torvalds }
6021da177e4SLinus Torvalds
6031da177e4SLinus Torvalds misc = readw(ctrl->hpc_reg + MISC);
6041da177e4SLinus Torvalds return (misc & 0x0800) ? PCI_SPEED_66MHz : PCI_SPEED_33MHz;
6051da177e4SLinus Torvalds }
6061da177e4SLinus Torvalds
6071da177e4SLinus Torvalds
608427438c6SAlex Chiang /**
6091da177e4SLinus Torvalds * get_adapter_speed - find the max supported frequency/mode of adapter.
6101da177e4SLinus Torvalds *
6111da177e4SLinus Torvalds * @ctrl: hotplug controller.
6121da177e4SLinus Torvalds * @hp_slot: hotplug slot where adapter is installed.
6131da177e4SLinus Torvalds *
6141da177e4SLinus Torvalds * Returns adapter speed.
6151da177e4SLinus Torvalds */
get_adapter_speed(struct controller * ctrl,u8 hp_slot)6161da177e4SLinus Torvalds static inline u8 get_adapter_speed(struct controller *ctrl, u8 hp_slot)
6171da177e4SLinus Torvalds {
6181da177e4SLinus Torvalds u32 temp_dword = readl(ctrl->hpc_reg + NON_INT_INPUT);
6191da177e4SLinus Torvalds dbg("slot: %d, PCIXCAP: %8x\n", hp_slot, temp_dword);
6201da177e4SLinus Torvalds if (ctrl->pcix_support) {
6211da177e4SLinus Torvalds if (temp_dword & (0x10000 << hp_slot))
6221da177e4SLinus Torvalds return PCI_SPEED_133MHz_PCIX;
6231da177e4SLinus Torvalds if (temp_dword & (0x100 << hp_slot))
6241da177e4SLinus Torvalds return PCI_SPEED_66MHz_PCIX;
6251da177e4SLinus Torvalds }
6261da177e4SLinus Torvalds
6271da177e4SLinus Torvalds if (temp_dword & (0x01 << hp_slot))
6281da177e4SLinus Torvalds return PCI_SPEED_66MHz;
6291da177e4SLinus Torvalds
6301da177e4SLinus Torvalds return PCI_SPEED_33MHz;
6311da177e4SLinus Torvalds }
6321da177e4SLinus Torvalds
enable_slot_power(struct controller * ctrl,u8 slot)6331da177e4SLinus Torvalds static inline void enable_slot_power(struct controller *ctrl, u8 slot)
6341da177e4SLinus Torvalds {
6351da177e4SLinus Torvalds u8 slot_power;
6361da177e4SLinus Torvalds
6371da177e4SLinus Torvalds slot_power = readb(ctrl->hpc_reg + SLOT_POWER);
6381da177e4SLinus Torvalds slot_power |= (0x01 << slot);
6391da177e4SLinus Torvalds writeb(slot_power, ctrl->hpc_reg + SLOT_POWER);
6401da177e4SLinus Torvalds }
6411da177e4SLinus Torvalds
disable_slot_power(struct controller * ctrl,u8 slot)6421da177e4SLinus Torvalds static inline void disable_slot_power(struct controller *ctrl, u8 slot)
6431da177e4SLinus Torvalds {
6441da177e4SLinus Torvalds u8 slot_power;
6451da177e4SLinus Torvalds
6461da177e4SLinus Torvalds slot_power = readb(ctrl->hpc_reg + SLOT_POWER);
6471da177e4SLinus Torvalds slot_power &= ~(0x01 << slot);
6481da177e4SLinus Torvalds writeb(slot_power, ctrl->hpc_reg + SLOT_POWER);
6491da177e4SLinus Torvalds }
6501da177e4SLinus Torvalds
6511da177e4SLinus Torvalds
cpq_get_attention_status(struct controller * ctrl,struct slot * slot)6521da177e4SLinus Torvalds static inline int cpq_get_attention_status(struct controller *ctrl, struct slot *slot)
6531da177e4SLinus Torvalds {
6541da177e4SLinus Torvalds u8 hp_slot;
6551da177e4SLinus Torvalds
6561da177e4SLinus Torvalds hp_slot = slot->device - ctrl->slot_device_offset;
6571da177e4SLinus Torvalds
6581da177e4SLinus Torvalds return read_amber_LED(ctrl, hp_slot);
6591da177e4SLinus Torvalds }
6601da177e4SLinus Torvalds
6611da177e4SLinus Torvalds
get_slot_enabled(struct controller * ctrl,struct slot * slot)6621da177e4SLinus Torvalds static inline int get_slot_enabled(struct controller *ctrl, struct slot *slot)
6631da177e4SLinus Torvalds {
6641da177e4SLinus Torvalds u8 hp_slot;
6651da177e4SLinus Torvalds
6661da177e4SLinus Torvalds hp_slot = slot->device - ctrl->slot_device_offset;
6671da177e4SLinus Torvalds
6681da177e4SLinus Torvalds return is_slot_enabled(ctrl, hp_slot);
6691da177e4SLinus Torvalds }
6701da177e4SLinus Torvalds
6711da177e4SLinus Torvalds
cpq_get_latch_status(struct controller * ctrl,struct slot * slot)67286a58023SAlex Chiang static inline int cpq_get_latch_status(struct controller *ctrl,
67386a58023SAlex Chiang struct slot *slot)
6741da177e4SLinus Torvalds {
6751da177e4SLinus Torvalds u32 status;
6761da177e4SLinus Torvalds u8 hp_slot;
6771da177e4SLinus Torvalds
6781da177e4SLinus Torvalds hp_slot = slot->device - ctrl->slot_device_offset;
6791da177e4SLinus Torvalds dbg("%s: slot->device = %d, ctrl->slot_device_offset = %d\n",
68066bef8c0SHarvey Harrison __func__, slot->device, ctrl->slot_device_offset);
6811da177e4SLinus Torvalds
6821da177e4SLinus Torvalds status = (readl(ctrl->hpc_reg + INT_INPUT_CLEAR) & (0x01L << hp_slot));
6831da177e4SLinus Torvalds
6841da177e4SLinus Torvalds return (status == 0) ? 1 : 0;
6851da177e4SLinus Torvalds }
6861da177e4SLinus Torvalds
6871da177e4SLinus Torvalds
get_presence_status(struct controller * ctrl,struct slot * slot)68886a58023SAlex Chiang static inline int get_presence_status(struct controller *ctrl,
68986a58023SAlex Chiang struct slot *slot)
6901da177e4SLinus Torvalds {
6911da177e4SLinus Torvalds int presence_save = 0;
6921da177e4SLinus Torvalds u8 hp_slot;
6931da177e4SLinus Torvalds u32 tempdword;
6941da177e4SLinus Torvalds
6951da177e4SLinus Torvalds hp_slot = slot->device - ctrl->slot_device_offset;
6961da177e4SLinus Torvalds
6971da177e4SLinus Torvalds tempdword = readl(ctrl->hpc_reg + INT_INPUT_CLEAR);
69886a58023SAlex Chiang presence_save = (int) ((((~tempdword) >> 23) | ((~tempdword) >> 15))
69986a58023SAlex Chiang >> hp_slot) & 0x02;
7001da177e4SLinus Torvalds
7011da177e4SLinus Torvalds return presence_save;
7021da177e4SLinus Torvalds }
7031da177e4SLinus Torvalds
wait_for_ctrl_irq(struct controller * ctrl)7041da177e4SLinus Torvalds static inline int wait_for_ctrl_irq(struct controller *ctrl)
7051da177e4SLinus Torvalds {
7061da177e4SLinus Torvalds DECLARE_WAITQUEUE(wait, current);
7071da177e4SLinus Torvalds int retval = 0;
7081da177e4SLinus Torvalds
70966bef8c0SHarvey Harrison dbg("%s - start\n", __func__);
7101da177e4SLinus Torvalds add_wait_queue(&ctrl->queue, &wait);
7111da177e4SLinus Torvalds /* Sleep for up to 1 second to wait for the LED to change. */
7121da177e4SLinus Torvalds msleep_interruptible(1000);
7131da177e4SLinus Torvalds remove_wait_queue(&ctrl->queue, &wait);
7141da177e4SLinus Torvalds if (signal_pending(current))
7151da177e4SLinus Torvalds retval = -EINTR;
7161da177e4SLinus Torvalds
71766bef8c0SHarvey Harrison dbg("%s - end\n", __func__);
7181da177e4SLinus Torvalds return retval;
7191da177e4SLinus Torvalds }
7201da177e4SLinus Torvalds
721b019ee67SAlex Chiang #include <asm/pci_x86.h>
cpqhp_routing_table_length(void)722b019ee67SAlex Chiang static inline int cpqhp_routing_table_length(void)
723b019ee67SAlex Chiang {
724b019ee67SAlex Chiang BUG_ON(cpqhp_routing_table == NULL);
725b019ee67SAlex Chiang return ((cpqhp_routing_table->size - sizeof(struct irq_routing_table)) /
726b019ee67SAlex Chiang sizeof(struct irq_info));
727b019ee67SAlex Chiang }
728b019ee67SAlex Chiang
7291da177e4SLinus Torvalds #endif
730