25 #include <linux/kernel.h>
26 #include <linux/module.h>
28 #include <linux/pci.h>
35 #include <asm/pci-bridge.h>
43 #define DRIVER_VERSION "0.1"
45 #define DRIVER_DESC "RPA HOT Plug PCI Controller Driver"
47 #define MAX_LOC_CODE 128
67 struct slot *
slot = (
struct slot *)hotplug_slot->private;
81 hotplug_slot->info->attention_status =
value;
91 static int get_power_status(
struct hotplug_slot *hotplug_slot,
u8 * value)
94 struct slot *slot = (
struct slot *)hotplug_slot->private;
107 static int get_attention_status(
struct hotplug_slot *hotplug_slot,
u8 * value)
109 struct slot *slot = (
struct slot *)hotplug_slot->private;
114 static int get_adapter_status(
struct hotplug_slot *hotplug_slot,
u8 * value)
116 struct slot *slot = (
struct slot *)hotplug_slot->private;
128 *value = slot->
state;
133 static enum pci_bus_speed get_max_bus_speed(
struct slot *slot)
136 switch (slot->
type) {
169 static int get_children_props(
struct device_node *
dn,
const int **drc_indexes,
170 const int **drc_names,
const int **drc_types,
171 const int **drc_power_domains)
173 const int *indexes, *names, *types, *domains;
180 if (!indexes || !names || !types || !domains) {
185 *drc_indexes = indexes;
192 if (drc_power_domains)
193 *drc_power_domains = domains;
203 char **
drc_name,
char **drc_type,
int *drc_power_domain)
205 const int *indexes, *names;
206 const int *types, *domains;
207 const unsigned int *my_index;
208 char *name_tmp, *type_tmp;
217 rc = get_children_props(dn->
parent, &indexes, &names, &types, &domains);
222 name_tmp = (
char *) &names[1];
223 type_tmp = (
char *) &types[1];
226 for (i = 0; i < indexes[0]; i++) {
227 if ((
unsigned int) indexes[i + 1] == *my_index) {
229 *drc_name = name_tmp;
231 *drc_type = type_tmp;
233 *drc_index = *my_index;
234 if (drc_power_domain)
235 *drc_power_domain = domains[i+1];
238 name_tmp += (
strlen(name_tmp) + 1);
239 type_tmp += (
strlen(type_tmp) + 1);
245 static int is_php_type(
char *drc_type)
252 if (endptr == drc_type)
271 static int is_php_dn(
struct device_node *dn,
const int **indexes,
272 const int **names,
const int **types,
const int **power_domains)
274 const int *drc_types;
277 rc = get_children_props(dn, indexes, names, &drc_types, power_domains);
281 if (!is_php_type((
char *) &drc_types[1]))
309 const int *indexes, *names, *types, *power_domains;
316 if (!is_php_dn(dn, &indexes, &names, &types, &power_domains))
319 dbg(
"Entry %s: dn->full_name=%s\n", __func__, dn->
full_name);
322 name = (
char *) &names[1];
323 type = (
char *) &types[1];
324 for (i = 0; i < indexes[0]; i++) {
332 dbg(
"Found drc-index:0x%x drc-name:%s drc-type:%s\n",
333 indexes[i + 1], name, type);
345 dbg(
"%s - Exit: rc[%d]\n", __func__, retval);
351 static void __exit cleanup_slots(
void)
370 static int __init rpaphp_init(
void)
382 static void __exit rpaphp_exit(
void)
387 static int enable_slot(
struct hotplug_slot *hotplug_slot)
389 struct slot *slot = (
struct slot *)hotplug_slot->private;
406 err(
"%s: slot[%s] is in invalid state\n", __func__, slot->
name);
411 slot->
bus->max_bus_speed = get_max_bus_speed(slot);
415 static int disable_slot(
struct hotplug_slot *hotplug_slot)
417 struct slot *slot = (
struct slot *)hotplug_slot->private;