static int __init via_pmu_led_init(void) { struct device_node *dt; const char *model; /* only do this on keylargo based models */ if (pmu_get_model() != PMU_KEYLARGO_BASED) return -ENODEV; dt = of_find_node_by_path("/"); if (dt == NULL) return -ENODEV; model = (const char *)get_property(dt, "model", NULL); if (model == NULL) return -ENODEV; if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 && strncmp(model, "iBook", strlen("iBook")) != 0) { of_node_put(dt); /* ignore */ return -ENODEV; } of_node_put(dt); spin_lock_init(&pmu_blink_lock); /* no outstanding req */ pmu_blink_req.complete = 1; pmu_blink_req.done = pmu_req_done; #ifdef CONFIG_PM pmu_register_sleep_notifier(&via_pmu_led_sleep_notif); #endif return led_classdev_register(NULL, &pmu_led); }
static int __devinit chipsfb_pci_init(struct pci_dev *dp, const struct pci_device_id *ent) { struct fb_info *p = &chipsfb_info; unsigned long addr, size; unsigned short cmd; if ((dp->resource[0].flags & IORESOURCE_MEM) == 0) return -ENODEV; addr = pci_resource_start(dp, 0); size = pci_resource_len(dp, 0); if (addr == 0) return -ENODEV; if (p->screen_base != 0) return -EBUSY; if (!request_mem_region(addr, size, "chipsfb")) return -EBUSY; #ifdef __BIG_ENDIAN addr += 0x800000; // Use big-endian aperture #endif /* we should use pci_enable_device here, but, the device doesn't declare its I/O ports in its BARs so pci_enable_device won't turn on I/O responses */ pci_read_config_word(dp, PCI_COMMAND, &cmd); cmd |= 3; /* enable memory and IO space */ pci_write_config_word(dp, PCI_COMMAND, cmd); #ifdef CONFIG_PMAC_BACKLIGHT /* turn on the backlight */ set_backlight_enable(1); #endif /* CONFIG_PMAC_BACKLIGHT */ p->screen_base = __ioremap(addr, 0x200000, _PAGE_NO_CACHE); if (p->screen_base == NULL) { release_mem_region(addr, size); return -ENOMEM; } p->device = &dp->dev; init_chips(p, addr); #ifdef CONFIG_PMAC_PBOOK pmu_register_sleep_notifier(&chips_sleep_notifier); #endif /* CONFIG_PMAC_PBOOK */ /* Clear the entire framebuffer */ memset(p->screen_base, 0, 0x100000); pci_set_drvdata(dp, p); return 0; }
int __init adb_init(void) { struct adb_driver *driver; int i; #ifdef CONFIG_PPC32 if ( (_machine != _MACH_chrp) && (_machine != _MACH_Pmac) ) return 0; #endif #ifdef CONFIG_MAC if (!MACH_IS_MAC) return 0; #endif /* xmon may do early-init */ if (adb_inited) return 0; adb_inited = 1; adb_controller = NULL; i = 0; while ((driver = adb_driver_list[i++]) != NULL) { if (!driver->probe()) { adb_controller = driver; break; } } if ((adb_controller == NULL) || adb_controller->init()) { printk(KERN_WARNING "Warning: no ADB interface detected\n"); adb_controller = NULL; } else { #ifdef CONFIG_PM pmu_register_sleep_notifier(&adb_sleep_notifier); #endif /* CONFIG_PM */ #ifdef CONFIG_PPC if (machine_is_compatible("AAPL,PowerBook1998") || machine_is_compatible("PowerBook1,1")) sleepy_trackpad = 1; #endif /* CONFIG_PPC */ init_completion(&adb_probe_task_comp); adbdev_init(); adb_reset_bus(); } return 0; }
static int __init apm_emu_init(void) { struct proc_dir_entry *apm_proc; if (sys_ctrler != SYS_CTRLER_PMU) { printk(KERN_INFO "apm_emu: Requires a machine with a PMU.\n"); return -ENODEV; } apm_proc = create_proc_info_entry("apm", 0, NULL, apm_emu_get_info); if (apm_proc) SET_MODULE_OWNER(apm_proc); misc_register(&apm_device); pmu_register_sleep_notifier(&apm_sleep_notifier); printk(KERN_INFO "apm_emu: APM Emulation %s initialized.\n", driver_version); return 0; }
void adb_init(void) { if ( (_machine != _MACH_chrp) && (_machine != _MACH_Pmac) ) return; via_cuda_init(); via_pmu_init(); macio_adb_init(); if (adb_controller == NULL) printk(KERN_WARNING "Warning: no ADB interface detected\n"); else { adb_hardware = adb_controller->kind; #ifdef CONFIG_PMAC_PBOOK pmu_register_sleep_notifier(&adb_sleep_notifier); #endif /* CONFIG_PMAC_PBOOK */ adb_reset_bus(); } }
static dldwd_priv_t* airport_attach(struct device_node* of_node) { dldwd_priv_t *priv; struct net_device *ndev; dldwd_card_t* card; hermes_t *hw; TRACE_ENTER("dldwd"); if (of_node->n_addrs < 1 || of_node->n_intrs < 1) { printk(KERN_ERR "airport: wrong interrupt/addresses in OF tree\n"); return NULL; } /* Allocate space for private device-specific data */ card = kmalloc(sizeof(*card), GFP_KERNEL); if (!card) { printk(KERN_ERR "airport: can't allocate device datas\n"); return NULL; } memset(card, 0, sizeof(*card)); priv = &(card->priv); priv->card = card; ndev = &priv->ndev; hw = &priv->hw; card->node = of_node; /* Setup the common part */ if (dldwd_setup(priv) < 0) { kfree(card); return NULL; } /* Overrides */ ndev->init = airport_init; ndev->open = airport_open; ndev->stop = airport_stop; /* Setup interrupts & base address */ ndev->irq = of_node->intrs[0].line; ndev->base_addr = (unsigned long)ioremap(of_node->addrs[0].address, 0x1000) - _IO_BASE; hermes_struct_init(hw, ndev->base_addr); /* Power up card */ feature_set_airport_power(card->node, 1); current->state = TASK_UNINTERRUPTIBLE; schedule_timeout(HZ); /* Reset it before we get the interrupt */ hermes_reset(hw); if (request_irq(ndev->irq, dldwd_interrupt, 0, "Airport", (void *)priv)) { printk(KERN_ERR "airport: Couldn't get IRQ %d\n", ndev->irq); goto failed; } card->irq_requested = 1; /* register_netdev will give us an ethX name */ ndev->name[0] = '\0'; /* Tell the stack we exist */ if (register_netdev(ndev) != 0) { printk(KERN_ERR "airport: register_netdev() failed\n"); goto failed; } printk(KERN_DEBUG "airport: card registered for interface %s\n", ndev->name); card->ndev_registered = 1; SET_MODULE_OWNER(ndev); /* And give us the proc nodes for debugging */ if (dldwd_proc_dev_init(priv) != 0) printk(KERN_ERR "airport: Failed to create /proc node for %s\n", ndev->name); #ifdef CONFIG_PMAC_PBOOK pmu_register_sleep_notifier(&airport_sleep_notifier); #endif return priv; failed: airport_detach(priv); return NULL; } /* airport_attach */
void __init pmac_ide_probe(void) { struct device_node *np; int i; struct device_node *atas; struct device_node *p, **pp, *removables, **rp; unsigned long base; int irq, big_delay; ide_hwif_t *hwif; if (_machine != _MACH_Pmac) return; pp = &atas; rp = &removables; p = find_devices("ATA"); if (p == NULL) p = find_devices("IDE"); if (p == NULL) p = find_type_devices("ide"); if (p == NULL) p = find_type_devices("ata"); /* Move removable devices such as the media-bay CDROM on the PB3400 to the end of the list. */ for (; p != NULL; p = p->next) { if (p->parent && p->parent->type && strcasecmp(p->parent->type, "media-bay") == 0) { *rp = p; rp = &p->next; } else { *pp = p; pp = &p->next; } } *rp = NULL; *pp = removables; big_delay = 0; for (i = 0, np = atas; i < MAX_HWIFS && np != NULL; np = np->next) { struct device_node *tp; int *bidp; int in_bay = 0; /* * If this node is not under a mac-io or dbdma node, * leave it to the generic PCI driver. */ for (tp = np->parent; tp != 0; tp = tp->parent) if (tp->type && (strcmp(tp->type, "mac-io") == 0 || strcmp(tp->type, "dbdma") == 0)) break; if (tp == 0) continue; if (np->n_addrs == 0) { printk(KERN_WARNING "ide: no address for device %s\n", np->full_name); continue; } /* * If this slot is taken (e.g. by ide-pci.c) try the next one. */ while (i < MAX_HWIFS && ide_hwifs[i].io_ports[IDE_DATA_OFFSET] != 0) ++i; if (i >= MAX_HWIFS) break; base = (unsigned long) ioremap(np->addrs[0].address, 0x200) - _IO_BASE; /* XXX This is bogus. Should be fixed in the registry by checking the kind of host interrupt controller, a bit like gatwick fixes in irq.c */ if (np->n_intrs == 0) { printk(KERN_WARNING "ide: no intrs for device %s, using 13\n", np->full_name); irq = 13; } else { irq = np->intrs[0].line; } pmac_ide[i].regbase = base; pmac_ide[i].irq = irq; pmac_ide[i].node = np; if (device_is_compatible(np, "keylargo-ata")) { if (strcmp(np->name, "ata-4") == 0) pmac_ide[i].kind = controller_kl_ata4; else pmac_ide[i].kind = controller_kl_ata3; } else if (device_is_compatible(np, "heathrow-ata")) pmac_ide[i].kind = controller_heathrow; else pmac_ide[i].kind = controller_ohare; bidp = (int *)get_property(np, "AAPL,bus-id", NULL); pmac_ide[i].aapl_bus_id = bidp ? *bidp : 0; if (np->parent && np->parent->name && strcasecmp(np->parent->name, "media-bay") == 0) { #ifdef CONFIG_PMAC_PBOOK media_bay_set_ide_infos(np->parent,base,irq,i); #endif /* CONFIG_PMAC_PBOOK */ in_bay = 1; } else if (pmac_ide[i].kind == controller_ohare) { /* The code below is having trouble on some ohare machines * (timing related ?). Until I can put my hand on one of these * units, I keep the old way */ feature_set(np, FEATURE_IDE0_enable); } else { /* This is necessary to enable IDE when net-booting */ printk(KERN_INFO "pmac_ide: enabling IDE bus ID %d\n", pmac_ide[i].aapl_bus_id); switch(pmac_ide[i].aapl_bus_id) { case 0: feature_set(np, FEATURE_IDE0_reset); mdelay(10); feature_set(np, FEATURE_IDE0_enable); mdelay(10); feature_clear(np, FEATURE_IDE0_reset); break; case 1: feature_set(np, FEATURE_IDE1_reset); mdelay(10); feature_set(np, FEATURE_IDE1_enable); mdelay(10); feature_clear(np, FEATURE_IDE1_reset); break; case 2: /* This one exists only for KL, I don't know about any enable bit */ feature_set(np, FEATURE_IDE2_reset); mdelay(10); feature_clear(np, FEATURE_IDE2_reset); break; } big_delay = 1; } hwif = &ide_hwifs[i]; pmac_ide_init_hwif_ports(&hwif->hw, base, 0, &hwif->irq); memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports)); hwif->chipset = ide_pmac; hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET] || in_bay; #ifdef CONFIG_PMAC_PBOOK if (in_bay && check_media_bay_by_base(base, MB_CD) == 0) hwif->noprobe = 0; #endif /* CONFIG_PMAC_PBOOK */ #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC if (np->n_addrs >= 2) { /* has a DBDMA controller channel */ pmac_ide_setup_dma(np, i); } #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ ++i; } pmac_ide_count = i; if (big_delay) mdelay(IDE_WAKEUP_DELAY_MS); #ifdef CONFIG_PMAC_PBOOK pmu_register_sleep_notifier(&idepmac_sleep_notifier); #endif /* CONFIG_PMAC_PBOOK */ }
static struct net_device * airport_attach(struct device_node *of_node) { struct orinoco_private *priv; struct net_device *dev; struct airport *card; unsigned long phys_addr; hermes_t *hw; if (of_node->n_addrs < 1 || of_node->n_intrs < 1) { printk(KERN_ERR "airport: wrong interrupt/addresses in OF tree\n"); return NULL; } /* Allocate space for private device-specific data */ dev = alloc_orinocodev(sizeof(*card), airport_hard_reset); if (! dev) { printk(KERN_ERR "airport: can't allocate device datas\n"); return NULL; } priv = dev->priv; card = priv->card; hw = &priv->hw; card->node = of_node; if (! request_OF_resource(of_node, 0, " (airport)")) { printk(KERN_ERR "airport: can't request IO resource !\n"); kfree(dev); return NULL; } dev->name[0] = '\0'; /* register_netdev will give us an ethX name */ SET_MODULE_OWNER(dev); /* Setup interrupts & base address */ dev->irq = of_node->intrs[0].line; phys_addr = of_node->addrs[0].address; /* Physical address */ printk(KERN_DEBUG "Airport at physical address %lx\n", phys_addr); dev->base_addr = phys_addr; card->vaddr = ioremap(phys_addr, AIRPORT_IO_LEN); if (! card->vaddr) { printk("airport: ioremap() failed\n"); goto failed; } hermes_struct_init(hw, (ulong)card->vaddr, HERMES_MEM, HERMES_16BIT_REGSPACING); /* Power up card */ pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 1); current->state = TASK_UNINTERRUPTIBLE; schedule_timeout(HZ); /* Reset it before we get the interrupt */ hermes_init(hw); if (request_irq(dev->irq, orinoco_interrupt, 0, "Airport", (void *)priv)) { printk(KERN_ERR "airport: Couldn't get IRQ %d\n", dev->irq); goto failed; } card->irq_requested = 1; /* Tell the stack we exist */ if (register_netdev(dev) != 0) { printk(KERN_ERR "airport: register_netdev() failed\n"); goto failed; } printk(KERN_DEBUG "airport: card registered for interface %s\n", dev->name); card->ndev_registered = 1; #ifdef CONFIG_PMAC_PBOOK pmu_register_sleep_notifier(&airport_sleep_notifier); #endif return dev; failed: airport_detach(dev); return NULL; } /* airport_attach */