/* * Copyright 2012 Red Hat Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. *
*/ /* * Authors: Dave Airlie <airlied@redhat.com>
*/
/* * Run this function as part of the HW device cleanup; not * when the DRM device gets released.
*/ staticvoid ast_enable_mmio_release(void *data)
{ void __iomem *ioregs = (void __force __iomem *)data;
/* * Find configuration mode and read SCU revision
*/
/* Check if we have device-tree properties */ if (np && !of_property_read_u32(np, "aspeed,scu-revision-id", &data)) { /* We do, disable P2A access */
config_mode = ast_use_dt;
scu_rev = data;
} elseif (pdev->device == PCI_CHIP_AST2000) { // Not all families have a P2A bridge /* * The BMC will set SCU 0x40 D[12] to 1 if the P2 bridge * is disabled. We force using P2A if VGA only mode bit * is set D[7]
*/
vgacrd0 = __ast_read8_i(ioregs, AST_IO_VGACRI, 0xd0);
vgacrd1 = __ast_read8_i(ioregs, AST_IO_VGACRI, 0xd1); if (!(vgacrd0 & 0x80) || !(vgacrd1 & 0x10)) {
/* * We have a P2A bridge and it is enabled.
*/
/* Patch AST2500/AST2510 */ if ((pdev->revision & 0xf0) == 0x40) { if (!(vgacrd0 & AST_IO_VGACRD0_VRAM_INIT_STATUS_MASK))
ast_2500_patch_ahb(regs);
}
/* Double check that it's actually working */
data = __ast_read32(regs, 0xf004); if ((data != 0xffffffff) && (data != 0x00)) {
config_mode = ast_use_p2a;
ret = aperture_remove_conflicting_pci_devices(pdev, ast_driver.name); if (ret) return ret;
ret = pcim_enable_device(pdev); if (ret) return ret;
regs = pcim_iomap_region(pdev, 1, "ast"); if (IS_ERR(regs)) return PTR_ERR(regs);
if (pdev->revision >= 0x40) { /* * On AST2500 and later models, MMIO is enabled by * default. Adopt it to be compatible with ARM.
*/
resource_size_t len = pci_resource_len(pdev, 1);
if (len < AST_IO_MM_OFFSET) return -EIO; if ((len - AST_IO_MM_OFFSET) < AST_IO_MM_LENGTH) return -EIO;
ioregs = regs + AST_IO_MM_OFFSET;
} elseif (pci_resource_flags(pdev, 2) & IORESOURCE_IO) { /* * Map I/O registers if we have a PCI BAR for I/O.
*/
resource_size_t len = pci_resource_len(pdev, 2);
if (len < AST_IO_MM_LENGTH) return -EIO;
ioregs = pcim_iomap_region(pdev, 2, "ast"); if (IS_ERR(ioregs)) return PTR_ERR(ioregs);
} else { /* * Anything else is best effort.
*/
resource_size_t len = pci_resource_len(pdev, 1);
if (len < AST_IO_MM_OFFSET) return -EIO; if ((len - AST_IO_MM_OFFSET) < AST_IO_MM_LENGTH) return -EIO;
ioregs = regs + AST_IO_MM_OFFSET;
dev_info(dev, "Platform has no I/O space, using MMIO\n");
}
if (!ast_is_vga_enabled(ioregs)) {
dev_info(dev, "VGA not enabled on entry, requesting chip POST\n");
need_post = true;
}
/* * If VGA isn't enabled, we need to enable now or subsequent * access to the scratch registers will fail.
*/ if (need_post)
ast_enable_vga(ioregs); /* Enable extended register access */
ast_open_key(ioregs);
ret = ast_enable_mmio(dev, ioregs); if (ret) return ret;
ret = ast_detect_chip(pdev, regs, ioregs, &chip, &config_mode); if (ret) return ret;
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.