rpaphp_pci.c (c1f3ee120bb61045b1c0a3ead620d1d65af47130) rpaphp_pci.c (66bef8c059015ba2b36bb5759080336feb01e680)
1/*
2 * PCI Hot Plug Controller Driver for RPA-compliant PPC64 platform.
3 * Copyright (C) 2003 Linda Xie <lxie@us.ibm.com>
4 *
5 * All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by

--- 28 unchanged lines hidden (view full) ---

37 int rc;
38 int setlevel;
39
40 rc = rtas_get_sensor(DR_ENTITY_SENSE, slot->index, state);
41
42 if (rc < 0) {
43 if (rc == -EFAULT || rc == -EEXIST) {
44 dbg("%s: slot must be power up to get sensor-state\n",
1/*
2 * PCI Hot Plug Controller Driver for RPA-compliant PPC64 platform.
3 * Copyright (C) 2003 Linda Xie <lxie@us.ibm.com>
4 *
5 * All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by

--- 28 unchanged lines hidden (view full) ---

37 int rc;
38 int setlevel;
39
40 rc = rtas_get_sensor(DR_ENTITY_SENSE, slot->index, state);
41
42 if (rc < 0) {
43 if (rc == -EFAULT || rc == -EEXIST) {
44 dbg("%s: slot must be power up to get sensor-state\n",
45 __FUNCTION__);
45 __func__);
46
47 /* some slots have to be powered up
48 * before get-sensor will succeed.
49 */
50 rc = rtas_set_power_level(slot->power_domain, POWER_ON,
51 &setlevel);
52 if (rc < 0) {
53 dbg("%s: power on slot[%s] failed rc=%d.\n",
46
47 /* some slots have to be powered up
48 * before get-sensor will succeed.
49 */
50 rc = rtas_set_power_level(slot->power_domain, POWER_ON,
51 &setlevel);
52 if (rc < 0) {
53 dbg("%s: power on slot[%s] failed rc=%d.\n",
54 __FUNCTION__, slot->name, rc);
54 __func__, slot->name, rc);
55 } else {
56 rc = rtas_get_sensor(DR_ENTITY_SENSE,
57 slot->index, state);
58 }
59 } else if (rc == -ENODEV)
55 } else {
56 rc = rtas_get_sensor(DR_ENTITY_SENSE,
57 slot->index, state);
58 }
59 } else if (rc == -ENODEV)
60 info("%s: slot is unusable\n", __FUNCTION__);
60 info("%s: slot is unusable\n", __func__);
61 else
61 else
62 err("%s failed to get sensor state\n", __FUNCTION__);
62 err("%s failed to get sensor state\n", __func__);
63 }
64 return rc;
65}
66
67/**
68 * rpaphp_enable_slot - record slot state, config pci device
69 * @slot: target &slot
70 *

--- 19 unchanged lines hidden (view full) ---

90
91 /* Figure out if there is an adapter in the slot */
92 rc = rpaphp_get_sensor_state(slot, &state);
93 if (rc)
94 return rc;
95
96 bus = pcibios_find_pci_bus(slot->dn);
97 if (!bus) {
63 }
64 return rc;
65}
66
67/**
68 * rpaphp_enable_slot - record slot state, config pci device
69 * @slot: target &slot
70 *

--- 19 unchanged lines hidden (view full) ---

90
91 /* Figure out if there is an adapter in the slot */
92 rc = rpaphp_get_sensor_state(slot, &state);
93 if (rc)
94 return rc;
95
96 bus = pcibios_find_pci_bus(slot->dn);
97 if (!bus) {
98 err("%s: no pci_bus for dn %s\n", __FUNCTION__, slot->dn->full_name);
98 err("%s: no pci_bus for dn %s\n", __func__, slot->dn->full_name);
99 return -EINVAL;
100 }
101
102 info->adapter_status = EMPTY;
103 slot->bus = bus;
104 slot->pci_devs = &bus->devices;
105
106 /* if there's an adapter in the slot, go add the pci devices */
107 if (state == PRESENT) {
108 info->adapter_status = NOT_CONFIGURED;
109 slot->state = NOT_CONFIGURED;
110
111 /* non-empty slot has to have child */
112 if (!slot->dn->child) {
113 err("%s: slot[%s]'s device_node doesn't have child for adapter\n",
99 return -EINVAL;
100 }
101
102 info->adapter_status = EMPTY;
103 slot->bus = bus;
104 slot->pci_devs = &bus->devices;
105
106 /* if there's an adapter in the slot, go add the pci devices */
107 if (state == PRESENT) {
108 info->adapter_status = NOT_CONFIGURED;
109 slot->state = NOT_CONFIGURED;
110
111 /* non-empty slot has to have child */
112 if (!slot->dn->child) {
113 err("%s: slot[%s]'s device_node doesn't have child for adapter\n",
114 __FUNCTION__, slot->name);
114 __func__, slot->name);
115 return -EINVAL;
116 }
117
118 if (list_empty(&bus->devices))
119 pcibios_add_pci_devices(bus);
120
121 if (!list_empty(&bus->devices)) {
122 info->adapter_status = CONFIGURED;
123 slot->state = CONFIGURED;
124 }
125
126 if (debug) {
127 struct pci_dev *dev;
115 return -EINVAL;
116 }
117
118 if (list_empty(&bus->devices))
119 pcibios_add_pci_devices(bus);
120
121 if (!list_empty(&bus->devices)) {
122 info->adapter_status = CONFIGURED;
123 slot->state = CONFIGURED;
124 }
125
126 if (debug) {
127 struct pci_dev *dev;
128 dbg("%s: pci_devs of slot[%s]\n", __FUNCTION__, slot->dn->full_name);
128 dbg("%s: pci_devs of slot[%s]\n", __func__, slot->dn->full_name);
129 list_for_each_entry (dev, &bus->devices, bus_list)
130 dbg("\t%s\n", pci_name(dev));
131 }
132 }
133
134 return 0;
135}
136
129 list_for_each_entry (dev, &bus->devices, bus_list)
130 dbg("\t%s\n", pci_name(dev));
131 }
132 }
133
134 return 0;
135}
136