2018-01-27 04:22:04 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* PCI Hot Plug Controller Driver for RPA-compliant PPC64 platform.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 Linda Xie <lxie@us.ibm.com>
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Send feedback to <lxie@us.ibm.com>,
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _PPC64PHP_H
|
|
|
|
#define _PPC64PHP_H
|
|
|
|
|
|
|
|
#include <linux/pci.h>
|
2006-10-20 15:23:05 +08:00
|
|
|
#include <linux/pci_hotplug.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define DR_INDICATOR 9002
|
|
|
|
#define DR_ENTITY_SENSE 9003
|
|
|
|
|
|
|
|
#define POWER_ON 100
|
|
|
|
#define POWER_OFF 0
|
|
|
|
|
|
|
|
#define LED_OFF 0
|
|
|
|
#define LED_ON 1 /* continuous on */
|
|
|
|
#define LED_ID 2 /* slow blinking */
|
|
|
|
#define LED_ACTION 3 /* fast blinking */
|
|
|
|
|
|
|
|
/* Sensor values from rtas_get-sensor */
|
|
|
|
#define EMPTY 0 /* No card in slot */
|
|
|
|
#define PRESENT 1 /* Card in slot */
|
|
|
|
|
|
|
|
#define MY_NAME "rpaphp"
|
2012-01-13 07:02:20 +08:00
|
|
|
extern bool rpaphp_debug;
|
2005-04-17 06:20:36 +08:00
|
|
|
#define dbg(format, arg...) \
|
|
|
|
do { \
|
2013-11-15 02:28:18 +08:00
|
|
|
if (rpaphp_debug) \
|
2005-04-17 06:20:36 +08:00
|
|
|
printk(KERN_DEBUG "%s: " format, \
|
2015-12-28 05:21:11 +08:00
|
|
|
MY_NAME, ## arg); \
|
2005-04-17 06:20:36 +08:00
|
|
|
} while (0)
|
2015-12-28 05:21:11 +08:00
|
|
|
#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)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* slot states */
|
|
|
|
|
|
|
|
#define NOT_VALID 3
|
|
|
|
#define NOT_CONFIGURED 2
|
|
|
|
#define CONFIGURED 1
|
|
|
|
#define EMPTY 0
|
|
|
|
|
hotplug/drc-info: Add code to search ibm,drc-info property
rpadlpar_core.c: Provide parallel routines to search the older device-
tree properties ("ibm,drc-indexes", "ibm,drc-names", "ibm,drc-types"
and "ibm,drc-power-domains"), or the new property "ibm,drc-info".
The interface to examine the DRC information is changed from a "get"
function that returns values for local verification elsewhere, to a
"check" function that validates the 'name' and/or 'type' of a device
node. This update hides the format of the underlying device-tree
properties, and concentrates the value checks into a single function
without requiring the user to verify whether a search was successful.
Signed-off-by: Michael Bringmann <mwb@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2017-12-02 07:19:48 +08:00
|
|
|
/* DRC constants */
|
|
|
|
|
|
|
|
#define MAX_DRC_NAME_LEN 64
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* struct slot - slot information for each *physical* slot
|
|
|
|
*/
|
|
|
|
struct slot {
|
|
|
|
struct list_head rpaphp_slot_list;
|
|
|
|
int state;
|
|
|
|
u32 index;
|
|
|
|
u32 type;
|
|
|
|
u32 power_domain;
|
PCI: hotplug: Drop hotplug_slot_info
Ever since the PCI hotplug core was introduced in 2002, drivers had to
allocate and register a struct hotplug_slot_info for every slot:
https://git.kernel.org/tglx/history/c/a8a2069f432c
Apparently the idea was that drivers furnish the hotplug core with an
up-to-date card presence status, power status, latch status and
attention indicator status as well as notify the hotplug core of changes
thereof. However only 4 out of 12 hotplug drivers bother to notify the
hotplug core with pci_hp_change_slot_info() and the hotplug core never
made any use of the information: There is just a single macro in
pci_hotplug_core.c, GET_STATUS(), which uses the hotplug_slot_info if
the driver lacks the corresponding callback in hotplug_slot_ops. The
macro is called when the user reads the attribute via sysfs.
Now, if the callback isn't defined, the attribute isn't exposed in sysfs
in the first place (see e.g. has_power_file()). There are only two
situations when the hotplug_slot_info would actually be accessed:
* If the driver defines ->enable_slot or ->disable_slot but not
->get_power_status.
* If the driver defines ->set_attention_status but not
->get_attention_status.
There is no driver doing the former and just a single driver doing the
latter, namely pnv_php.c. Amend it with a ->get_attention_status
callback. With that, the hotplug_slot_info becomes completely unused by
the PCI hotplug core. But a few drivers use it internally as a cache:
cpcihp uses it to cache the latch_status and adapter_status.
cpqhp uses it to cache the adapter_status.
pnv_php and rpaphp use it to cache the attention_status.
shpchp uses it to cache all four values.
Amend these drivers to cache the information in their private slot
struct. shpchp's slot struct already contains members to cache the
power_status and adapter_status, so additional members are only needed
for the other two values. In the case of cpqphp, the cached value is
only accessed in a single place, so instead of caching it, read the
current value from the hardware.
Caution: acpiphp, cpci, cpqhp, shpchp, asus-wmi and eeepc-laptop
populate the hotplug_slot_info with initial values on probe. That code
is herewith removed. There is a theoretical chance that the code has
side effects without which the driver fails to function, e.g. if the
ACPI method to read the adapter status needs to be executed at least
once on probe. That seems unlikely to me, still maintainers should
review the changes carefully for this possibility.
Rafael adds: "I'm not aware of any case in which it will break anything,
[...] but if that happens, it may be necessary to add the execution of
the control methods in question directly to the initialization part."
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com> # drivers/pci/hotplug/rpa*
Acked-by: Sebastian Ott <sebott@linux.ibm.com> # drivers/pci/hotplug/s390*
Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com> # drivers/platform/x86
Cc: Len Brown <lenb@kernel.org>
Cc: Scott Murray <scott@spiteful.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Oliver OHalloran <oliveroh@au1.ibm.com>
Cc: Gavin Shan <gwshan@linux.vnet.ibm.com>
Cc: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Cc: Corentin Chary <corentin.chary@gmail.com>
Cc: Darren Hart <dvhart@infradead.org>
2018-09-08 15:59:01 +08:00
|
|
|
u8 attention_status;
|
2005-04-17 06:20:36 +08:00
|
|
|
char *name;
|
2005-07-26 00:13:38 +08:00
|
|
|
struct device_node *dn;
|
|
|
|
struct pci_bus *bus;
|
|
|
|
struct list_head *pci_devs;
|
2018-09-08 15:59:01 +08:00
|
|
|
struct hotplug_slot hotplug_slot;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2018-09-08 15:59:01 +08:00
|
|
|
extern const struct hotplug_slot_ops rpaphp_hotplug_slot_ops;
|
2005-04-17 06:20:36 +08:00
|
|
|
extern struct list_head rpaphp_slot_head;
|
|
|
|
|
2018-09-08 15:59:01 +08:00
|
|
|
static inline struct slot *to_slot(struct hotplug_slot *hotplug_slot)
|
|
|
|
{
|
|
|
|
return container_of(hotplug_slot, struct slot, hotplug_slot);
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* function prototypes */
|
|
|
|
|
|
|
|
/* rpaphp_pci.c */
|
2013-04-13 02:02:59 +08:00
|
|
|
int rpaphp_enable_slot(struct slot *slot);
|
|
|
|
int rpaphp_get_sensor_state(struct slot *slot, int *state);
|
2005-09-29 08:33:38 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* rpaphp_core.c */
|
2013-04-13 02:02:59 +08:00
|
|
|
int rpaphp_add_slot(struct device_node *dn);
|
hotplug/drc-info: Add code to search ibm,drc-info property
rpadlpar_core.c: Provide parallel routines to search the older device-
tree properties ("ibm,drc-indexes", "ibm,drc-names", "ibm,drc-types"
and "ibm,drc-power-domains"), or the new property "ibm,drc-info".
The interface to examine the DRC information is changed from a "get"
function that returns values for local verification elsewhere, to a
"check" function that validates the 'name' and/or 'type' of a device
node. This update hides the format of the underlying device-tree
properties, and concentrates the value checks into a single function
without requiring the user to verify whether a search was successful.
Signed-off-by: Michael Bringmann <mwb@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2017-12-02 07:19:48 +08:00
|
|
|
int rpaphp_check_drc_props(struct device_node *dn, char *drc_name,
|
|
|
|
char *drc_type);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* rpaphp_slot.c */
|
2013-04-13 02:02:59 +08:00
|
|
|
void dealloc_slot_struct(struct slot *slot);
|
|
|
|
struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_name, int power_domain);
|
|
|
|
int rpaphp_register_slot(struct slot *slot);
|
|
|
|
int rpaphp_deregister_slot(struct slot *slot);
|
2013-11-15 02:28:18 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* _PPC64PHP_H */
|