1736759efSBjorn Helgaas /* SPDX-License-Identifier: GPL-2.0+ */
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds * PCI Hot Plug Controller Driver for RPA-compliant PPC64 platform.
41da177e4SLinus Torvalds *
51da177e4SLinus Torvalds * Copyright (C) 2003 Linda Xie <lxie@us.ibm.com>
61da177e4SLinus Torvalds *
71da177e4SLinus Torvalds * All rights reserved.
81da177e4SLinus Torvalds *
91da177e4SLinus Torvalds * Send feedback to <lxie@us.ibm.com>,
101da177e4SLinus Torvalds *
111da177e4SLinus Torvalds */
121da177e4SLinus Torvalds
131da177e4SLinus Torvalds #ifndef _PPC64PHP_H
141da177e4SLinus Torvalds #define _PPC64PHP_H
151da177e4SLinus Torvalds
161da177e4SLinus Torvalds #include <linux/pci.h>
17e17e31e3SOlaf Hering #include <linux/pci_hotplug.h>
181da177e4SLinus Torvalds
191da177e4SLinus Torvalds #define DR_INDICATOR 9002
201da177e4SLinus Torvalds #define DR_ENTITY_SENSE 9003
211da177e4SLinus Torvalds
221da177e4SLinus Torvalds #define POWER_ON 100
231da177e4SLinus Torvalds #define POWER_OFF 0
241da177e4SLinus Torvalds
251da177e4SLinus Torvalds #define LED_OFF 0
261da177e4SLinus Torvalds #define LED_ON 1 /* continuous on */
271da177e4SLinus Torvalds #define LED_ID 2 /* slow blinking */
281da177e4SLinus Torvalds #define LED_ACTION 3 /* fast blinking */
291da177e4SLinus Torvalds
301da177e4SLinus Torvalds /* Sensor values from rtas_get-sensor */
311da177e4SLinus Torvalds #define EMPTY 0 /* No card in slot */
321da177e4SLinus Torvalds #define PRESENT 1 /* Card in slot */
331da177e4SLinus Torvalds
341da177e4SLinus Torvalds #define MY_NAME "rpaphp"
3590ab5ee9SRusty Russell extern bool rpaphp_debug;
361da177e4SLinus Torvalds #define dbg(format, arg...) \
371da177e4SLinus Torvalds do { \
385d9bc1faSKristen Carlson Accardi if (rpaphp_debug) \
391da177e4SLinus Torvalds printk(KERN_DEBUG "%s: " format, \
401da177e4SLinus Torvalds MY_NAME, ## arg); \
411da177e4SLinus Torvalds } while (0)
421da177e4SLinus Torvalds #define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME, ## arg)
431da177e4SLinus Torvalds #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME, ## arg)
441da177e4SLinus Torvalds #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME, ## arg)
451da177e4SLinus Torvalds
461da177e4SLinus Torvalds /* slot states */
471da177e4SLinus Torvalds
481da177e4SLinus Torvalds #define NOT_VALID 3
491da177e4SLinus Torvalds #define NOT_CONFIGURED 2
501da177e4SLinus Torvalds #define CONFIGURED 1
511da177e4SLinus Torvalds #define EMPTY 0
521da177e4SLinus Torvalds
532fcf3ae5SMichael Bringmann /* DRC constants */
542fcf3ae5SMichael Bringmann
552fcf3ae5SMichael Bringmann #define MAX_DRC_NAME_LEN 64
562fcf3ae5SMichael Bringmann
571da177e4SLinus Torvalds /*
581da177e4SLinus Torvalds * struct slot - slot information for each *physical* slot
591da177e4SLinus Torvalds */
601da177e4SLinus Torvalds struct slot {
611da177e4SLinus Torvalds struct list_head rpaphp_slot_list;
621da177e4SLinus Torvalds int state;
631da177e4SLinus Torvalds u32 index;
641da177e4SLinus Torvalds u32 type;
651da177e4SLinus Torvalds u32 power_domain;
66a7da2161SLukas Wunner u8 attention_status;
671da177e4SLinus Torvalds char *name;
689c209c91SJohn Rose struct device_node *dn;
699c209c91SJohn Rose struct pci_bus *bus;
709c209c91SJohn Rose struct list_head *pci_devs;
71*125450f8SLukas Wunner struct hotplug_slot hotplug_slot;
721da177e4SLinus Torvalds };
731da177e4SLinus Torvalds
7481c4b5bfSLukas Wunner extern const struct hotplug_slot_ops rpaphp_hotplug_slot_ops;
751da177e4SLinus Torvalds extern struct list_head rpaphp_slot_head;
761da177e4SLinus Torvalds
to_slot(struct hotplug_slot * hotplug_slot)77*125450f8SLukas Wunner static inline struct slot *to_slot(struct hotplug_slot *hotplug_slot)
78*125450f8SLukas Wunner {
79*125450f8SLukas Wunner return container_of(hotplug_slot, struct slot, hotplug_slot);
80*125450f8SLukas Wunner }
81*125450f8SLukas Wunner
821da177e4SLinus Torvalds /* function prototypes */
831da177e4SLinus Torvalds
841da177e4SLinus Torvalds /* rpaphp_pci.c */
85f39d5b72SBjorn Helgaas int rpaphp_enable_slot(struct slot *slot);
86f39d5b72SBjorn Helgaas int rpaphp_get_sensor_state(struct slot *slot, int *state);
87934199e9Slinas
881da177e4SLinus Torvalds /* rpaphp_core.c */
89f39d5b72SBjorn Helgaas int rpaphp_add_slot(struct device_node *dn);
902fcf3ae5SMichael Bringmann int rpaphp_check_drc_props(struct device_node *dn, char *drc_name,
912fcf3ae5SMichael Bringmann char *drc_type);
921da177e4SLinus Torvalds
931da177e4SLinus Torvalds /* rpaphp_slot.c */
94f39d5b72SBjorn Helgaas void dealloc_slot_struct(struct slot *slot);
95f39d5b72SBjorn Helgaas struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_name, int power_domain);
96f39d5b72SBjorn Helgaas int rpaphp_register_slot(struct slot *slot);
97f39d5b72SBjorn Helgaas int rpaphp_deregister_slot(struct slot *slot);
981da177e4SLinus Torvalds
991da177e4SLinus Torvalds #endif /* _PPC64PHP_H */
100