/** * detect_SMBIOS_pointer - find the System Management BIOS Table in mem region. * @begin: begin pointer for region to be scanned. * @end: end pointer for region to be scanned. * * Returns pointer to the head of the SMBIOS tables (or %NULL).
*/ staticvoid __iomem *detect_SMBIOS_pointer(void __iomem *begin, void __iomem *end)
{ void __iomem *fp; void __iomem *endp;
u8 temp1, temp2, temp3, temp4; int status = 0;
/** * get_subsequent_smbios_entry: get the next entry from bios table. * @smbios_start: where to start in the SMBIOS table * @smbios_table: location of the SMBIOS table * @curr: %NULL or pointer to previously returned structure * * Gets the first entry if previous == NULL; * otherwise, returns the next entry. * Uses global SMBIOS Table pointer. * * Returns a pointer to an SMBIOS structure or NULL if none found.
*/ staticvoid __iomem *get_subsequent_smbios_entry(void __iomem *smbios_start, void __iomem *smbios_table, void __iomem *curr)
{
u8 bail = 0;
u8 previous_byte = 1; void __iomem *p_temp; void __iomem *p_max;
if (!smbios_table || !curr) return NULL;
/* set p_max to the end of the table */
p_max = smbios_start + readw(smbios_table + ST_LENGTH);
while ((p_temp < p_max) && !bail) { /* Look for the double NULL terminator * The first condition is the previous byte * and the second is the curr
*/ if (!previous_byte && !(readb(p_temp)))
bail = 1;
previous_byte = readb(p_temp);
p_temp++;
}
if (p_temp < p_max) return p_temp; else return NULL;
}
/** * get_SMBIOS_entry - return the requested SMBIOS entry or %NULL * @smbios_start: where to start in the SMBIOS table * @smbios_table: location of the SMBIOS table * @type: SMBIOS structure type to be returned * @previous: %NULL or pointer to previously returned structure * * Gets the first entry of the specified type if previous == %NULL; * Otherwise, returns the next entry of the given type. * Uses global SMBIOS Table pointer. * Uses get_subsequent_smbios_entry. * * Returns a pointer to an SMBIOS structure or %NULL if none found.
*/ staticvoid __iomem *get_SMBIOS_entry(void __iomem *smbios_start, void __iomem *smbios_table,
u8 type, void __iomem *previous)
{ if (!smbios_table) return NULL;
/* Free IRQ associated with hot plug device */
free_irq(ctrl->interrupt, ctrl); /* Unmap the memory */
iounmap(ctrl->hpc_reg); /* Finally reclaim PCI mem */
release_mem_region(pci_resource_start(ctrl->pci_dev, 0),
pci_resource_len(ctrl->pci_dev, 0));
return 0;
}
/** * get_slot_mapping - determine logical slot mapping for PCI device * * Won't work for more than one PCI-PCI bridge in a slot. * * @bus: pointer to the PCI bus structure * @bus_num: bus number of PCI device * @dev_num: device number of PCI device * @slot: Pointer to u8 where slot number will be returned * * Output: SUCCESS or FAILURE
*/ staticint
get_slot_mapping(struct pci_bus *bus, u8 bus_num, u8 dev_num, u8 *slot)
{
u32 work; long len; long loop;
if ((tbus == bus_num) && (tdevice == dev_num)) {
*slot = tslot; return 0;
} else { /* Did not get a match on the target PCI device. Check * if the current IRQ table entry is a PCI-to-PCI * bridge device. If so, and its secondary bus * matches the bus number for the target device, I need * to save the bridge's slot number. If I can not find * an entry for the target device, I will have to * assume it's on the other side of the bridge, and * assign it the bridge's slot.
*/
bus->number = tbus;
pci_bus_read_config_dword(bus, PCI_DEVFN(tdevice, 0),
PCI_CLASS_REVISION, &work);
if ((work >> 8) == PCI_TO_PCI_BRIDGE_CLASS) {
pci_bus_read_config_dword(bus,
PCI_DEVFN(tdevice, 0),
PCI_PRIMARY_BUS, &work); // See if bridge's secondary bus matches target bus. if (((work >> 8) & 0x000000FF) == (long) bus_num)
bridgeSlot = tslot;
}
}
}
/* If we got here, we didn't find an entry in the IRQ mapping table for * the target PCI device. If we did determine that the target device * is on the other side of a PCI-to-PCI bridge, return the slot number * for the bridge.
*/ if (bridgeSlot != 0xFF) {
*slot = bridgeSlot; return 0;
} /* Couldn't find an entry in the routing table for this PCI device */ return -1;
}
/** * cpqhp_set_attention_status - Turns the Amber LED for a slot on or off * @ctrl: struct controller to use * @func: PCI device/function info * @status: LED control flag: 1 = LED on, 0 = LED off
*/ staticint
cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func,
u32 status)
{
u8 hp_slot;
/* Wait for SOBS to be unset */
wait_for_ctrl_irq(ctrl);
/* Done with exclusive hardware access */
mutex_unlock(&ctrl->crit_sect);
return 0;
}
/** * set_attention_status - Turns the Amber LED for a slot on or off * @hotplug_slot: slot to change LED on * @status: LED control flag
*/ staticint set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
{ struct pci_func *slot_func; struct slot *slot = to_slot(hotplug_slot); struct controller *ctrl = slot->ctrl;
u8 bus;
u8 devfn;
u8 device;
u8 function;
/*FIXME: these capabilities aren't used but if they are * they need to be correctly implemented
*/
slot->capabilities |= PCISLOT_REPLACE_SUPPORTED;
slot->capabilities |= PCISLOT_INTERLOCK_SUPPORTED;
if (is_slot64bit(slot))
slot->capabilities |= PCISLOT_64_BIT_SUPPORTED; if (is_slot66mhz(slot))
slot->capabilities |= PCISLOT_66_MHZ_SUPPORTED; if (bus->cur_bus_speed == PCI_SPEED_66MHz)
slot->capabilities |= PCISLOT_66_MHZ_OPERATION;
/* FIXME: We also need to hook the NMI handler eventually. * this also needs to be worked with Christoph * register_NMI_handler();
*/ /* Map rom address */
cpqhp_rom_start = ioremap(ROM_PHY_ADDR, ROM_PHY_LEN); if (!cpqhp_rom_start) {
err("Could not ioremap memory region for ROM\n");
retval = -EIO; goto error;
}
/* Now, map the int15 entry point if we are on compaq specific * hardware
*/
compaq_nvram_init(cpqhp_rom_start);
/* Map smbios table entry point structure */
smbios_table = detect_SMBIOS_pointer(cpqhp_rom_start,
cpqhp_rom_start + ROM_PHY_LEN); if (!smbios_table) {
err("Could not find the SMBIOS pointer in memory\n");
retval = -EIO; goto error_rom_start;
}
smbios_start = ioremap(readl(smbios_table + ST_ADDRESS),
readw(smbios_table + ST_LENGTH)); if (!smbios_start) {
err("Could not ioremap memory region taken from SMBIOS values\n");
retval = -EIO; goto error_smbios_start;
}
bus = pdev->subordinate; if (!bus) {
pci_notice(pdev, "the device is not a bridge, skipping\n");
rc = -ENODEV; goto err_disable_device;
}
/* Need to read VID early b/c it's used to differentiate CPQ and INTC * discovery
*/
vendor_id = pdev->vendor; if ((vendor_id != PCI_VENDOR_ID_COMPAQ) &&
(vendor_id != PCI_VENDOR_ID_INTEL)) {
err(msg_HPC_non_compaq_or_intel);
rc = -ENODEV; goto err_disable_device;
}
dbg("Vendor ID: %x\n", vendor_id);
/* Check for the proper subsystem IDs * Intel uses a different SSID programming model than Compaq. * For Intel, each SSID bit identifies a PHP capability. * Also Intel HPCs may have RID=0.
*/ if ((pdev->revision <= 2) && (vendor_id != PCI_VENDOR_ID_INTEL)) {
err(msg_HPC_not_supported);
rc = -ENODEV; goto err_disable_device;
}
/* TODO: This code can be made to support non-Compaq or Intel * subsystem IDs
*/
subsystem_vid = pdev->subsystem_vendor;
dbg("Subsystem Vendor ID: %x\n", subsystem_vid); if ((subsystem_vid != PCI_VENDOR_ID_COMPAQ) && (subsystem_vid != PCI_VENDOR_ID_INTEL)) {
err(msg_HPC_non_compaq_or_intel);
rc = -ENODEV; goto err_disable_device;
}
/* PCI Config Space Index (0=not supported, 1=supported) */ if (subsystem_deviceid & 0x0020)
ctrl->pci_config_space = 1; else
ctrl->pci_config_space = 0;
/* PCI-X support */ if (subsystem_deviceid & 0x0080) {
ctrl->pcix_support = 1; if (subsystem_deviceid & 0x0040) /* 133MHz PCI-X if bit 7 is 1 */
ctrl->pcix_speed_capability = 1; else /* 100MHz PCI-X if bit 7 is 1 and bit 0 is 0, */ /* 66MHz PCI-X if bit 7 is 1 and bit 0 is 1 */
ctrl->pcix_speed_capability = 0;
} else { /* Conventional PCI */
ctrl->pcix_support = 0;
ctrl->pcix_speed_capability = 0;
} break;
/* make our own copy of the pci bus structure,
* as we like tweaking it a lot */
ctrl->pci_bus = kmemdup(pdev->bus, sizeof(*ctrl->pci_bus), GFP_KERNEL); if (!ctrl->pci_bus) {
err("out of memory\n");
rc = -ENOMEM; goto err_free_ctrl;
}
/* Check for 66Mhz operation */
bus->cur_bus_speed = get_controller_speed(ctrl);
/******************************************************** * * Save configuration headers for this and * subordinate PCI buses *
********************************************************/
/* find the physical slot number of the first hot plug slot */
/* Get slot won't work for devices behind bridges, but * in this case it will always be called for the "base" * bus/dev/func of a slot. * CS: this is leveraging the PCIIRQ routing code from the kernel
* (pci-pc.c: get_irq_routing_table) */
rc = get_slot_mapping(ctrl->pci_bus, pdev->bus->number,
(readb(ctrl->hpc_reg + SLOT_MASK) >> 4),
&(ctrl->first_slot));
dbg("get_slot_mapping: first_slot = %d, returned = %d\n",
ctrl->first_slot, rc); if (rc) {
err(msg_initialization_err, rc); goto err_iounmap;
}
/* Store PCI Config Space for all devices on this bus */
rc = cpqhp_save_config(ctrl, ctrl->bus, readb(ctrl->hpc_reg + SLOT_MASK)); if (rc) {
err("%s: unable to save PCI configuration data, error %d\n",
__func__, rc); goto err_iounmap;
}
/* * Get IO, memory, and IRQ resources for new devices
*/ /* The next line is required for cpqhp_find_available_resources */
ctrl->interrupt = pdev->irq; if (ctrl->interrupt < 0x10) {
cpqhp_legacy_mode = 1;
dbg("System seems to be configured for Full Table Mapped MPS mode\n");
}
rc = cpqhp_find_available_resources(ctrl, cpqhp_rom_start);
ctrl->add_support = !rc; if (rc) {
dbg("cpqhp_find_available_resources = 0x%x\n", rc);
err("unable to locate PCI configuration resources for hot plug add.\n"); goto err_iounmap;
}
/* * Finish setting up the hot plug ctrl device
*/
ctrl->slot_device_offset = readb(ctrl->hpc_reg + SLOT_MASK) >> 4;
dbg("NumSlots %d\n", ctrl->slot_device_offset);
ctrl->next_event = 0;
/* Setup the slot information structures */
rc = ctrl_slot_setup(ctrl, smbios_start, smbios_table); if (rc) {
err(msg_initialization_err, 6);
err("%s: unable to save PCI configuration data, error %d\n",
__func__, rc); goto err_iounmap;
}
/* Mask all general input interrupts */
writel(0xFFFFFFFFL, ctrl->hpc_reg + INT_MASK);
/* set up the interrupt */
dbg("HPC interrupt = %d\n", ctrl->interrupt); if (request_irq(ctrl->interrupt, cpqhp_ctrl_intr,
IRQF_SHARED, MY_NAME, ctrl)) {
err("Can't get irq %d for the hotplug pci controller\n",
ctrl->interrupt);
rc = -ENODEV; goto err_iounmap;
}
/* Enable Shift Out interrupt and clear it, also enable SERR on power * fault
*/
temp_word = readw(ctrl->hpc_reg + MISC);
temp_word |= 0x4006;
writew(temp_word, ctrl->hpc_reg + MISC);
/* Changed 05/05/97 to clear all interrupts at start */
writel(0xFFFFFFFFL, ctrl->hpc_reg + INT_INPUT_CLEAR);
/* We have to save the presence info for these slots */
temp_word = ctrl->ctrl_int_comp >> 16;
func->presence_save = (temp_word >> hp_slot) & 0x01;
func->presence_save |= (temp_word >> (hp_slot + 7)) & 0x02;
res = ctrl->io_head; while (res) {
tres = res;
res = res->next;
kfree(tres);
}
res = ctrl->mem_head; while (res) {
tres = res;
res = res->next;
kfree(tres);
}
res = ctrl->p_mem_head; while (res) {
tres = res;
res = res->next;
kfree(tres);
}
res = ctrl->bus_head; while (res) {
tres = res;
res = res->next;
kfree(tres);
}
kfree(ctrl->pci_bus);
tctrl = ctrl;
ctrl = ctrl->next;
kfree(tctrl);
}
for (loop = 0; loop < 256; loop++) {
next = cpqhp_slot_list[loop]; while (next != NULL) {
res = next->io_head; while (res) {
tres = res;
res = res->next;
kfree(tres);
}
res = next->mem_head; while (res) {
tres = res;
res = res->next;
kfree(tres);
}
res = next->p_mem_head; while (res) {
tres = res;
res = res->next;
kfree(tres);
}
res = next->bus_head; while (res) {
tres = res;
res = res->next;
kfree(tres);
}
TempSlot = next;
next = next->next;
kfree(TempSlot);
}
}
/* Stop the notification mechanism */ if (initialized)
cpqhp_event_stop_thread();
/* unmap the rom address */ if (cpqhp_rom_start)
iounmap(cpqhp_rom_start); if (smbios_start)
iounmap(smbios_start);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.