📄 io_common.c
字号:
/* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 2006 Silicon Graphics, Inc. All rights reserved. */#include <linux/bootmem.h>#include <asm/sn/types.h>#include <asm/sn/addrs.h>#include <asm/sn/sn_feature_sets.h>#include <asm/sn/geo.h>#include <asm/sn/io.h>#include <asm/sn/l1.h>#include <asm/sn/module.h>#include <asm/sn/pcibr_provider.h>#include <asm/sn/pcibus_provider_defs.h>#include <asm/sn/pcidev.h>#include <asm/sn/simulator.h>#include <asm/sn/sn_sal.h>#include <asm/sn/tioca_provider.h>#include <asm/sn/tioce_provider.h>#include "xtalk/hubdev.h"#include "xtalk/xwidgetdev.h"#include <linux/acpi.h>#include <asm/sn/sn2/sn_hwperf.h>#include <asm/sn/acpi.h>#include "acpi/acglobal.h"extern void sn_init_cpei_timer(void);extern void register_sn_procfs(void);extern void sn_io_acpi_init(void);extern void sn_io_init(void);static struct list_head sn_sysdata_list;/* sysdata list struct */struct sysdata_el { struct list_head entry; void *sysdata;};int sn_ioif_inited; /* SN I/O infrastructure initialized? */int sn_acpi_rev; /* SN ACPI revision */EXPORT_SYMBOL_GPL(sn_acpi_rev);struct sn_pcibus_provider *sn_pci_provider[PCIIO_ASIC_MAX_TYPES]; /* indexed by asic type *//* * Hooks and struct for unsupported pci providers */static dma_addr_tsn_default_pci_map(struct pci_dev *pdev, unsigned long paddr, size_t size, int type){ return 0;}static voidsn_default_pci_unmap(struct pci_dev *pdev, dma_addr_t addr, int direction){ return;}static void *sn_default_pci_bus_fixup(struct pcibus_bussoft *soft, struct pci_controller *controller){ return NULL;}static struct sn_pcibus_provider sn_pci_default_provider = { .dma_map = sn_default_pci_map, .dma_map_consistent = sn_default_pci_map, .dma_unmap = sn_default_pci_unmap, .bus_fixup = sn_default_pci_bus_fixup,};/* * Retrieve the DMA Flush List given nasid, widget, and device. * This list is needed to implement the WAR - Flush DMA data on PIO Reads. */static inline u64sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num, u64 address){ struct ia64_sal_retval ret_stuff; ret_stuff.status = 0; ret_stuff.v0 = 0; SAL_CALL_NOLOCK(ret_stuff, (u64) SN_SAL_IOIF_GET_DEVICE_DMAFLUSH_LIST, (u64) nasid, (u64) widget_num, (u64) device_num, (u64) address, 0, 0, 0); return ret_stuff.status;}/* * sn_pcidev_info_get() - Retrieve the pcidev_info struct for the specified * device. */inline struct pcidev_info *sn_pcidev_info_get(struct pci_dev *dev){ struct pcidev_info *pcidev; list_for_each_entry(pcidev, &(SN_PLATFORM_DATA(dev)->pcidev_info), pdi_list) { if (pcidev->pdi_linux_pcidev == dev) return pcidev; } return NULL;}/* Older PROM flush WAR * * 01/16/06 -- This war will be in place until a new official PROM is released. * Additionally note that the struct sn_flush_device_war also has to be * removed from arch/ia64/sn/include/xtalk/hubdev.h */static u8 war_implemented = 0;static s64 sn_device_fixup_war(u64 nasid, u64 widget, int device, struct sn_flush_device_common *common){ struct sn_flush_device_war *war_list; struct sn_flush_device_war *dev_entry; struct ia64_sal_retval isrv = {0,0,0,0}; if (!war_implemented) { printk(KERN_WARNING "PROM version < 4.50 -- implementing old " "PROM flush WAR\n"); war_implemented = 1; } war_list = kzalloc(DEV_PER_WIDGET * sizeof(*war_list), GFP_KERNEL); if (!war_list) BUG(); SAL_CALL_NOLOCK(isrv, SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST, nasid, widget, __pa(war_list), 0, 0, 0 ,0); if (isrv.status) panic("sn_device_fixup_war failed: %s\n", ia64_sal_strerror(isrv.status)); dev_entry = war_list + device; memcpy(common,dev_entry, sizeof(*common)); kfree(war_list); return isrv.status;}/* * sn_common_hubdev_init() - This routine is called to initialize the HUB data * structure for each node in the system. */void __initsn_common_hubdev_init(struct hubdev_info *hubdev){ struct sn_flush_device_kernel *sn_flush_device_kernel; struct sn_flush_device_kernel *dev_entry; s64 status; int widget, device, size; /* Attach the error interrupt handlers */ if (hubdev->hdi_nasid & 1) /* If TIO */ ice_error_init(hubdev); else hub_error_init(hubdev); for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) hubdev->hdi_xwidget_info[widget].xwi_hubinfo = hubdev; if (!hubdev->hdi_flush_nasid_list.widget_p) return; size = (HUB_WIDGET_ID_MAX + 1) * sizeof(struct sn_flush_device_kernel *); hubdev->hdi_flush_nasid_list.widget_p = kzalloc(size, GFP_KERNEL); if (!hubdev->hdi_flush_nasid_list.widget_p) BUG(); for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) { size = DEV_PER_WIDGET * sizeof(struct sn_flush_device_kernel); sn_flush_device_kernel = kzalloc(size, GFP_KERNEL); if (!sn_flush_device_kernel) BUG(); dev_entry = sn_flush_device_kernel; for (device = 0; device < DEV_PER_WIDGET; device++, dev_entry++) { size = sizeof(struct sn_flush_device_common); dev_entry->common = kzalloc(size, GFP_KERNEL); if (!dev_entry->common) BUG(); if (sn_prom_feature_available(PRF_DEVICE_FLUSH_LIST)) status = sal_get_device_dmaflush_list( hubdev->hdi_nasid, widget, device, (u64)(dev_entry->common)); else status = sn_device_fixup_war(hubdev->hdi_nasid, widget, device, dev_entry->common); if (status != SALRET_OK) panic("SAL call failed: %s\n", ia64_sal_strerror(status)); spin_lock_init(&dev_entry->sfdl_flush_lock); } if (sn_flush_device_kernel) hubdev->hdi_flush_nasid_list.widget_p[widget] = sn_flush_device_kernel; }}void sn_pci_unfixup_slot(struct pci_dev *dev){ struct pci_dev *host_pci_dev = SN_PCIDEV_INFO(dev)->host_pci_dev; sn_irq_unfixup(dev); pci_dev_put(host_pci_dev); pci_dev_put(dev);}/* * sn_pci_fixup_slot() */void sn_pci_fixup_slot(struct pci_dev *dev, struct pcidev_info *pcidev_info, struct sn_irq_info *sn_irq_info){ int segment = pci_domain_nr(dev->bus); struct pcibus_bussoft *bs; struct pci_bus *host_pci_bus; struct pci_dev *host_pci_dev; unsigned int bus_no, devfn; pci_dev_get(dev); /* for the sysdata pointer */ /* Add pcidev_info to list in pci_controller.platform_data */ list_add_tail(&pcidev_info->pdi_list, &(SN_PLATFORM_DATA(dev->bus)->pcidev_info)); /* * Using the PROMs values for the PCI host bus, get the Linux * PCI host_pci_dev struct and set up host bus linkages */ bus_no = (pcidev_info->pdi_slot_host_handle >> 32) & 0xff; devfn = pcidev_info->pdi_slot_host_handle & 0xffffffff; host_pci_bus = pci_find_bus(segment, bus_no); host_pci_dev = pci_get_slot(host_pci_bus, devfn); pcidev_info->host_pci_dev = host_pci_dev; pcidev_info->pdi_linux_pcidev = dev; pcidev_info->pdi_host_pcidev_info = SN_PCIDEV_INFO(host_pci_dev); bs = SN_PCIBUS_BUSSOFT(dev->bus); pcidev_info->pdi_pcibus_info = bs; if (bs && bs->bs_asic_type < PCIIO_ASIC_MAX_TYPES) { SN_PCIDEV_BUSPROVIDER(dev) = sn_pci_provider[bs->bs_asic_type]; } else { SN_PCIDEV_BUSPROVIDER(dev) = &sn_pci_default_provider; } /* Only set up IRQ stuff if this device has a host bus context */ if (bs && sn_irq_info->irq_irq) { pcidev_info->pdi_sn_irq_info = sn_irq_info; dev->irq = pcidev_info->pdi_sn_irq_info->irq_irq; sn_irq_fixup(dev, sn_irq_info); } else { pcidev_info->pdi_sn_irq_info = NULL; kfree(sn_irq_info); }}/* * sn_common_bus_fixup - Perform platform specific bus fixup. * Execute the ASIC specific fixup routine * for this bus. */voidsn_common_bus_fixup(struct pci_bus *bus, struct pcibus_bussoft *prom_bussoft_ptr)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -