bool IntelBacklightHandler::start(IOService *provider) { if (!super::start(provider)) return false; IOPCIDevice* pci = OSDynamicCast(IOPCIDevice, provider); if (!pci) { IOLog("IntelBacklightHandler is not an IOPCIDevice... aborting\n"); return false; } // setup for direct access IOService* service = waitForMatchingService(serviceMatching("ACPIBacklightPanel"), 2000UL*1000UL*1000UL); if (!service) { IOLog("ACPIBacklightPanel not found... aborting\n"); return false; } ACPIBacklightPanel* panel = OSDynamicCast(ACPIBacklightPanel, service); if (!panel) { IOLog("Backlight service was not ACPIBacklightPanel\n"); return false; } // setup BAR1 address... _baseMap = pci->mapDeviceMemoryWithRegister(kIOPCIConfigBaseAddress0); if (!_baseMap) { IOLog("unable to map BAR1... aborting\n"); return false; } _baseAddr = reinterpret_cast<volatile void *>(_baseMap->getVirtualAddress()); if (!_baseAddr) { IOLog("unable to get virtual address for BAR1... aborting\n"); return false; } OSNumber* num = OSDynamicCast(OSNumber, getProperty("kFrameBufferType")); if (num == NULL) { IOLog("unable to get framebuffer type\n"); return false; } _fbtype = num->unsigned32BitValue(); // now register with ACPIBacklight if (!panel->setBacklightHandler(this, &_params)) { // setBacklightHandler will return false for old PNLF patches _baseMap->release(); return false; } _panel = panel; panel->retain(); // register service so ACPIBacklightPanel can proceed... registerService(); return true; }
/** * at_probe - Device Initialization Routine * @pdev: PCI device information struct * @ent: entry in at_pci_tbl * * Returns 0 on success, negative on failure * * at_probe initializes an adapter identified by a pci_dev structure. * The OS initialization, configuring of the adapter private structure, * and a hardware reset occur. **/ bool AtherosL1Ethernet::atProbe() { u16 vendorId, deviceId; at_adapter *adapter=&adapter_; IOPCIDevice *pdev = adapter_.pdev; pdev->setBusMasterEnable(true); pdev->setMemoryEnable(true); pdev->setIOEnable(true); vendorId = pdev->configRead16(kIOPCIConfigVendorID); deviceId = pdev->configRead16(kIOPCIConfigDeviceID); DbgPrint("Vendor ID %x, device ID %x\n", vendorId, deviceId); DbgPrint("MMR0 address %x\n", (u32)pdev->configRead32(kIOPCIConfigBaseAddress0)); pdev->enablePCIPowerManagement(); hw_addr_ = pdev->mapDeviceMemoryWithRegister(kIOPCIConfigBaseAddress0); if (hw_addr_ == NULL) { ErrPrint("Couldn't map io regs\n"); return false; } DbgPrint("Memory mapped at bus address %x, virtual address %x, length %d\n", (u32)hw_addr_->getPhysicalAddress(), (u32)hw_addr_->getVirtualAddress(), (u32)hw_addr_->getLength()); hw_addr_->retain(); adapter->hw.mmr_base = reinterpret_cast<char *>(hw_addr_->getVirtualAddress()); DbgPrint("REG_VPD_CAP = %x\n", OSReadLittleInt32(adapter->hw.mmr_base, REG_VPD_CAP)); DbgPrint("REG_PCIE_CAP_LIST = %x\n", OSReadLittleInt32(adapter->hw.mmr_base, REG_PCIE_CAP_LIST)); DbgPrint("REG_MASTER_CTRL = %x\n", OSReadLittleInt32(adapter->hw.mmr_base, REG_MASTER_CTRL)); at_setup_pcicmd(pdev); /* get user settings */ at_check_options(adapter); /* setup the private structure */ if(at_sw_init(adapter)) { ErrPrint("Couldn't init software\n"); return false; } /* Init GPHY as early as possible due to power saving issue */ at_phy_init(&adapter->hw); /* reset the controller to * put the device in a known good starting state */ if (at_reset_hw(&adapter->hw)) { ErrPrint("Couldn't reset hardware\n"); return false; //TO-DO: Uncomment } /* copy the MAC address out of the EEPROM */ at_read_mac_addr(&adapter->hw); return true; }