2 * RPA Hot Plug Virtual I/O device functions
3 * Copyright (C) 2004 Linda Xie <lxie@us.ibm.com>
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
9 * the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
15 * NON INFRINGEMENT. See the GNU General Public License for more
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 * Send feedback to <lxie@us.ibm.com>
29 * get_vio_adapter_status - get the status of a slot
33 * 1-- adapter is configured
34 * 2-- adapter is not configured
37 inline int rpaphp_get_vio_adapter_status(struct slot *slot, int is_init, u8 *value)
43 int rpaphp_unconfig_vio_adapter(struct slot *slot)
47 dbg("Entry %s: slot[%s]\n", __FUNCTION__, slot->name);
48 if (!slot->dev.vio_dev) {
49 info("%s: no VIOA in slot[%s]\n", __FUNCTION__, slot->name);
53 /* remove the device from the vio core */
54 vio_unregister_device(slot->dev.vio_dev);
55 slot->state = NOT_CONFIGURED;
56 info("%s: adapter in slot[%s] unconfigured.\n", __FUNCTION__, slot->name);
58 dbg("Exit %s, rc=0x%x\n", __FUNCTION__, retval);
62 static int setup_vio_hotplug_slot_info(struct slot *slot)
64 slot->hotplug_slot->info->power_status = 1;
65 rpaphp_get_vio_adapter_status(slot, 1,
66 &slot->hotplug_slot->info->adapter_status);
70 int register_vio_slot(struct device_node *dn)
75 struct slot *slot = NULL;
77 index = (u32 *) get_property(dn, "ibm,my-drc-index", NULL);
80 name = get_property(dn, "ibm,loc-code", NULL);
83 if (!(slot = alloc_slot_struct(dn, *index, name, 0))) {
87 slot->dev_type = VIO_DEV;
88 slot->dev.vio_dev = vio_find_node(dn);
89 if (!slot->dev.vio_dev)
90 slot->dev.vio_dev = vio_register_device(dn);
91 if (slot->dev.vio_dev)
92 slot->state = CONFIGURED;
94 slot->state = NOT_CONFIGURED;
95 if (setup_vio_hotplug_slot_info(slot))
97 strcpy(slot->name, slot->dev.vio_dev->dev.bus_id);
98 info("%s: registered VIO device[name=%s vio_dev=%p]\n",
99 __FUNCTION__, slot->name, slot->dev.vio_dev);
100 rc = register_slot(slot);
103 dealloc_slot_struct(slot);
107 int rpaphp_enable_vio_slot(struct slot *slot)
111 if ((slot->dev.vio_dev = vio_register_device(slot->dn))) {
112 info("%s: VIO adapter %s in slot[%s] has been configured\n",
113 __FUNCTION__, slot->dn->name, slot->name);
114 slot->state = CONFIGURED;
116 info("%s: no vio_dev struct for adapter in slot[%s]\n",
117 __FUNCTION__, slot->name);
118 slot->state = NOT_CONFIGURED;