unsigned int get_brg_clk(void) { struct device_node *qe; if (brg_clk) return brg_clk; qe = of_find_node_by_type(NULL, "qe"); if (qe) { unsigned int size; const u32 *prop = of_get_property(qe, "brg-frequency", &size); brg_clk = *prop; of_node_put(qe); }; return brg_clk; }
static void __init mpc830x_rdb_init_IRQ(void) { struct device_node *np; np = of_find_node_by_type(NULL, "ipic"); if (!np) return; ipic_init(np, 0); /* Initialize the default interrupt mapping priorities, * in case the boot rom changed something on us. */ ipic_set_default_priority(); }
static int pSeries_check_legacy_ioport(unsigned int baseport) { struct device_node *np; #define I8042_DATA_REG 0x60 #define FDC_BASE 0x3f0 switch(baseport) { case I8042_DATA_REG: np = of_find_node_by_type(NULL, "8042"); if (np == NULL) return -ENODEV; of_node_put(np); break; case FDC_BASE: np = of_find_node_by_type(NULL, "fdc"); if (np == NULL) return -ENODEV; of_node_put(np); break; } return 0; }
void riscv_fill_hwcap(void) { struct device_node *node; const char *isa; size_t i; static unsigned long isa2hwcap[256] = {0}; isa2hwcap['i'] = isa2hwcap['I'] = COMPAT_HWCAP_ISA_I; isa2hwcap['m'] = isa2hwcap['M'] = COMPAT_HWCAP_ISA_M; isa2hwcap['a'] = isa2hwcap['A'] = COMPAT_HWCAP_ISA_A; isa2hwcap['f'] = isa2hwcap['F'] = COMPAT_HWCAP_ISA_F; isa2hwcap['d'] = isa2hwcap['D'] = COMPAT_HWCAP_ISA_D; isa2hwcap['c'] = isa2hwcap['C'] = COMPAT_HWCAP_ISA_C; elf_hwcap = 0; /* * We don't support running Linux on hertergenous ISA systems. For * now, we just check the ISA of the first processor. */ node = of_find_node_by_type(NULL, "cpu"); if (!node) { pr_warning("Unable to find \"cpu\" devicetree entry"); return; } if (of_property_read_string(node, "riscv,isa", &isa)) { pr_warning("Unable to find \"riscv,isa\" devicetree entry"); return; } for (i = 0; i < strlen(isa); ++i) elf_hwcap |= isa2hwcap[(unsigned char)(isa[i])]; /* We don't support systems with F but without D, so mask those out * here. */ if ((elf_hwcap & COMPAT_HWCAP_ISA_F) && !(elf_hwcap & COMPAT_HWCAP_ISA_D)) { pr_info("This kernel does not support systems with F but not D"); elf_hwcap &= ~COMPAT_HWCAP_ISA_F; } pr_info("elf_hwcap is 0x%lx", elf_hwcap); #ifdef CONFIG_FPU if (elf_hwcap & (COMPAT_HWCAP_ISA_F | COMPAT_HWCAP_ISA_D)) has_fpu = true; #endif }
/* ************************************************************************ * * Setup the architecture * */ static void __init mpc834x_itx_setup_arch(void) { #ifdef CONFIG_PCI struct device_node *np; #endif if (ppc_md.progress) ppc_md.progress("mpc834x_itx_setup_arch()", 0); #ifdef CONFIG_PCI for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) add_bridge(np); ppc_md.pci_exclude_device = mpc83xx_exclude_device; #endif }
phys_addr_t get_csrbase(void) { struct device_node *tsi; if (tsi108_csr_base != -1) return tsi108_csr_base; tsi = of_find_node_by_type(NULL, "tsi-bridge"); if (tsi) { unsigned int size; const void *prop = of_get_property(tsi, "reg", &size); tsi108_csr_base = of_translate_address(tsi, prop); of_node_put(tsi); }; return tsi108_csr_base; }
int __init mmio_nvram_init(void) { struct device_node *nvram_node; unsigned long nvram_addr; struct resource r; int ret; nvram_node = of_find_node_by_type(NULL, "nvram"); if (!nvram_node) { printk(KERN_WARNING "nvram: no node found in device-tree\n"); return -ENODEV; } ret = of_address_to_resource(nvram_node, 0, &r); if (ret) { printk(KERN_WARNING "nvram: failed to get address (err %d)\n", ret); goto out; } nvram_addr = r.start; mmio_nvram_len = r.end - r.start + 1; if ( (!mmio_nvram_len) || (!nvram_addr) ) { printk(KERN_WARNING "nvram: address or length is 0\n"); ret = -EIO; goto out; } mmio_nvram_start = ioremap(nvram_addr, mmio_nvram_len); if (!mmio_nvram_start) { printk(KERN_WARNING "nvram: failed to ioremap\n"); ret = -ENOMEM; goto out; } printk(KERN_INFO "mmio NVRAM, %luk at 0x%lx mapped to %p\n", mmio_nvram_len >> 10, nvram_addr, mmio_nvram_start); ppc_md.nvram_read_val = mmio_nvram_read_val; ppc_md.nvram_write_val = mmio_nvram_write_val; ppc_md.nvram_read = mmio_nvram_read; ppc_md.nvram_write = mmio_nvram_write; ppc_md.nvram_size = mmio_nvram_get_size; out: of_node_put(nvram_node); return ret; }
static void __init ksi8560_pic_init(void) { struct mpic *mpic; struct resource r; struct device_node *np; #ifdef CONFIG_CPM2 int irq; #endif np = of_find_node_by_type(NULL, "open-pic"); if (np == NULL) { printk(KERN_ERR "Could not find open-pic node\n"); return; } if (of_address_to_resource(np, 0, &r)) { printk(KERN_ERR "Could not map mpic register space\n"); of_node_put(np); return; } mpic = mpic_alloc(np, r.start, MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN, 0, 256, " OpenPIC "); BUG_ON(mpic == NULL); of_node_put(np); mpic_init(mpic); #ifdef CONFIG_CPM2 /* Setup CPM2 PIC */ np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic"); if (np == NULL) { printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n"); return; } irq = irq_of_parse_and_map(np, 0); cpm2_pic_init(np); of_node_put(np); set_irq_chained_handler(irq, cpm2_cascade); setup_irq(0, NULL); #endif }
/* ************************************************************************ * * Setup the architecture * */ static void __init mpc836x_mds_setup_arch(void) { struct device_node *np; if (ppc_md.progress) ppc_md.progress("mpc836x_mds_setup_arch()", 0); /* Map BCSR area */ np = of_find_node_by_name(NULL, "bcsr"); if (np != 0) { struct resource res; of_address_to_resource(np, 0, &res); bcsr_regs = ioremap(res.start, res.end - res.start +1); of_node_put(np); } #ifdef CONFIG_PCI for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) add_bridge(np); ppc_md.pci_exclude_device = mpc83xx_exclude_device; #endif #ifdef CONFIG_QUICC_ENGINE qe_reset(); if ((np = of_find_node_by_name(NULL, "par_io")) != NULL) { par_io_init(np); of_node_put(np); for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;) par_io_of_config(np); } if ((np = of_find_compatible_node(NULL, "network", "ucc_geth")) != NULL) { /* Reset the Ethernet PHY */ bcsr_regs[9] &= ~0x20; udelay(1000); bcsr_regs[9] |= 0x20; iounmap(bcsr_regs); of_node_put(np); } #endif /* CONFIG_QUICC_ENGINE */ }
phys_addr_t get_immrbase(void) { struct device_node *soc; if (immrbase != -1) return immrbase; soc = of_find_node_by_type(NULL, "soc"); if (soc != 0) { unsigned int size; void *prop = get_property(soc, "reg", &size); immrbase = of_translate_address(soc, prop); of_node_put(soc); }; return immrbase; }
phys_addr_t get_qe_base(void) { struct device_node *qe; if (qebase != -1) return qebase; qe = of_find_node_by_type(NULL, "qe"); if (qe) { unsigned int size; const void *prop = of_get_property(qe, "reg", &size); qebase = of_translate_address(qe, prop); of_node_put(qe); }; return qebase; }
static int __init cbe_find_pmd_mmio(int cpu, struct cbe_pervasive *p) { struct device_node *node; unsigned int *int_servers; char *addr; unsigned long real_address; unsigned int size; struct pmd_regs __iomem *pmd_mmio_area; int hardid, thread; int proplen; pmd_mmio_area = NULL; hardid = get_hard_smp_processor_id(cpu); for (node = NULL; (node = of_find_node_by_type(node, "cpu"));) { int_servers = (void *) get_property(node, "ibm,ppc-interrupt-server#s", &proplen); if (!int_servers) { printk(KERN_WARNING "%s misses " "ibm,ppc-interrupt-server#s property", node->full_name); continue; } for (thread = 0; thread < proplen / sizeof (int); thread++) { if (hardid == int_servers[thread]) { addr = get_property(node, "pervasive", NULL); goto found; } } } printk(KERN_WARNING "%s: CPU %d not found\n", __FUNCTION__, cpu); return -EINVAL; found: real_address = *(unsigned long*) addr; addr += sizeof (unsigned long); size = *(unsigned int*) addr; pr_debug("pervasive area for CPU %d at %lx, size %x\n", cpu, real_address, size); p->regs = ioremap(real_address, size); p->thread = thread; return 0; }
void __init mpc85xx_smp_init(void) { struct device_node *np; np = of_find_node_by_type(NULL, "open-pic"); if (np) { smp_85xx_ops.probe = smp_mpic_probe; smp_85xx_ops.setup_cpu = smp_85xx_setup_cpu; smp_85xx_ops.message_pass = smp_mpic_message_pass; } if (cpu_has_feature(CPU_FTR_DBELL)) smp_85xx_ops.message_pass = smp_dbell_message_pass; BUG_ON(!smp_85xx_ops.message_pass); smp_ops = &smp_85xx_ops; }
void __init mpc85xx_smp_init(void) { struct device_node *np; smp_85xx_ops.setup_cpu = smp_85xx_setup_cpu; np = of_find_node_by_type(NULL, "open-pic"); if (np) { smp_85xx_ops.probe = smp_mpic_probe; smp_85xx_ops.message_pass = smp_mpic_message_pass; } if (cpu_has_feature(CPU_FTR_DBELL)) { /* * If left NULL, .message_pass defaults to * smp_muxed_ipi_message_pass */ smp_85xx_ops.message_pass = NULL; smp_85xx_ops.cause_ipi = doorbell_cause_ipi; } np = of_find_matching_node(NULL, mpc85xx_smp_guts_ids); if (np) { guts = of_iomap(np, 0); of_node_put(np); if (!guts) { pr_err("%s: Could not map guts node address\n", __func__); return; } smp_85xx_ops.give_timebase = mpc85xx_give_timebase; smp_85xx_ops.take_timebase = mpc85xx_take_timebase; #ifdef CONFIG_HOTPLUG_CPU ppc_md.cpu_die = smp_85xx_mach_cpu_die; #endif } smp_ops = &smp_85xx_ops; #ifdef CONFIG_KEXEC ppc_md.kexec_cpu_down = mpc85xx_smp_kexec_cpu_down; ppc_md.machine_kexec = mpc85xx_smp_machine_kexec; #endif }
u32 get_baudrate(void) { struct device_node *node; if (fs_baudrate != -1) return fs_baudrate; node = of_find_node_by_type(NULL, "serial"); if (node) { int size; const unsigned int *prop = of_get_property(node, "current-speed", &size); if (prop) fs_baudrate = *prop; of_node_put(node); } return fs_baudrate; }
u32 get_brgfreq(void) { struct device_node *node; if (brgfreq != -1) return brgfreq; node = of_find_node_by_type(NULL, "cpm"); if (node) { unsigned int size; const unsigned int *prop = of_get_property(node, "brg-frequency", &size); if (prop) brgfreq = *prop; of_node_put(node); }; return brgfreq; }
/* Search all cpu device nodes for an offline logical cpu. If a * device node has a "ibm,my-drc-index" property (meaning this is an * LPAR), paranoid-check whether we own the cpu. For each "thread" * of a cpu, if it is offline and has the same hw index as before, * grab that in preference. */ static unsigned int find_physical_cpu_to_start(unsigned int old_hwindex) { struct device_node *np = NULL; unsigned int best = -1U; while ((np = of_find_node_by_type(np, "cpu"))) { int nr_threads, len; u32 *index = (u32 *)get_property(np, "ibm,my-drc-index", NULL); u32 *tid = (u32 *) get_property(np, "ibm,ppc-interrupt-server#s", &len); if (!tid) tid = (u32 *)get_property(np, "reg", &len); if (!tid) continue; /* If there is a drc-index, make sure that we own * the cpu. */ if (index) { int state; int rc = rtas_get_sensor(9003, *index, &state); if (rc != 0 || state != 1) continue; } nr_threads = len / sizeof(u32); while (nr_threads--) { if (0 == query_cpu_stopped(tid[nr_threads])) { best = tid[nr_threads]; if (best == old_hwindex) goto out; } } } out: of_node_put(np); return best; }
static int __init get_freq(char *name, unsigned long *val) { struct device_node *cpu; const unsigned int *fp; int found = 0; /* The cpu node should have timebase and clock frequency properties */ cpu = of_find_node_by_type(NULL, "cpu"); if (cpu) { fp = of_get_property(cpu, name, NULL); if (fp) { found = 1; *val = *fp; } of_node_put(cpu); } return found; }
/* * Enumerate the possible CPU set from the device tree. */ void __init smp_init_cpus(void) { const char *enable_method; struct device_node *dn = NULL; int cpu = 0; while ((dn = of_find_node_by_type(dn, "cpu"))) { if (cpu >= NR_CPUS) goto next; /* * We currently support only the "spin-table" enable-method. */ enable_method = of_get_property(dn, "enable-method", NULL); if (!enable_method) { pr_err("CPU %d: missing enable-method property\n", cpu); goto next; } smp_enable_ops[cpu] = smp_get_enable_ops(enable_method); if (!smp_enable_ops[cpu]) { pr_err("CPU %d: invalid enable-method property: %s\n", cpu, enable_method); goto next; } if (smp_enable_ops[cpu]->init_cpu(dn, cpu)) goto next; set_cpu_possible(cpu, true); next: cpu++; } /* sanity check */ if (cpu > NR_CPUS) pr_warning("no. of cores (%d) greater than configured maximum of %d - clipping\n", cpu, NR_CPUS); }
void holly_restart(char *cmd) { __be32 __iomem *ocn_bar1 = NULL; unsigned long bar; struct device_node *bridge = NULL; const void *prop; int size; phys_addr_t addr = 0xc0000000; local_irq_disable(); bridge = of_find_node_by_type(NULL, "tsi-bridge"); if (bridge) { prop = of_get_property(bridge, "reg", &size); addr = of_translate_address(bridge, prop); } addr += (TSI108_PB_OFFSET + 0x414); ocn_bar1 = ioremap(addr, 0x4); /* Turn on the BOOT bit so the addresses are correctly * routed to the HLP interface */ bar = ioread32be(ocn_bar1); bar |= 2; iowrite32be(bar, ocn_bar1); iosync(); /* Set SRR0 to the reset vector and turn on MSR_IP */ mtspr(SPRN_SRR0, 0xfff00100); mtspr(SPRN_SRR1, MSR_IP); /* Do an rfi to jump back to firmware. Somewhat evil, * but it works */ __asm__ __volatile__("rfi" : : : "memory"); /* Spin until reset happens. Shouldn't really get here */ for (;;) ; }
static void __init holly_setup_arch(void) { struct device_node *np; if (ppc_md.progress) ppc_md.progress("holly_setup_arch():set_bridge", 0); tsi108_csr_vir_base = get_vir_csrbase(); /* setup PCI host bridge */ holly_remap_bridge(); np = of_find_node_by_type(NULL, "pci"); if (np) tsi108_setup_pci(np, HOLLY_PCI_CFG_PHYS, 1); ppc_md.pci_exclude_device = holly_exclude_device; if (ppc_md.progress) ppc_md.progress("tsi108: resources set", 0x100); printk(KERN_INFO "PPC750GX/CL Platform\n"); }
static int __init wf_rm31_init(void) { struct device_node *cpu; int i; if (!of_machine_is_compatible("RackMac3,1")) return -ENODEV; /* Count the number of CPU cores */ nr_chips = 0; for (cpu = NULL; (cpu = of_find_node_by_type(cpu, "cpu")) != NULL; ) ++nr_chips; if (nr_chips > NR_CHIPS) nr_chips = NR_CHIPS; pr_info("windfarm: Initializing for desktop G5 with %d chips\n", nr_chips); /* Get MPU data for each CPU */ for (i = 0; i < nr_chips; i++) { cpu_mpu_data[i] = wf_get_mpu(i); if (!cpu_mpu_data[i]) { pr_err("wf_rm31: Failed to find MPU data for CPU %d\n", i); return -ENXIO; } } #ifdef MODULE request_module("windfarm_fcu_controls"); request_module("windfarm_lm75_sensor"); request_module("windfarm_lm87_sensor"); request_module("windfarm_ad7417_sensor"); request_module("windfarm_max6690_sensor"); request_module("windfarm_cpufreq_clamp"); #endif /* MODULE */ platform_driver_register(&wf_rm31_driver); return 0; }
static void __init mpc885ads_setup_arch(void) { struct device_node *cpu; cpu = of_find_node_by_type(NULL, "cpu"); if (cpu != 0) { const unsigned int *fp; fp = of_get_property(cpu, "clock-frequency", NULL); if (fp != 0) loops_per_jiffy = *fp / HZ; else loops_per_jiffy = 50000000 / HZ; of_node_put(cpu); } cpm_reset(); mpc885ads_board_setup(); ROOT_DEV = Root_NFS; }
static void __init sbc8641_init_irq(void) { struct mpic *mpic1; struct device_node *np; struct resource res; /* Determine PIC address. */ np = of_find_node_by_type(NULL, "open-pic"); if (np == NULL) return; of_address_to_resource(np, 0, &res); /* Alloc mpic structure and per isu has 16 INT entries. */ mpic1 = mpic_alloc(np, res.start, MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN, 0, 256, " MPIC "); of_node_put(np); BUG_ON(mpic1 == NULL); mpic_init(mpic1); }
static void sh_of_smp_probe(void) { struct device_node *np = 0; const char *method = 0; const struct of_cpu_method *m = __cpu_method_of_table; pr_info("SH generic board support: scanning for cpus\n"); init_cpu_possible(cpumask_of(0)); while ((np = of_find_node_by_type(np, "cpu"))) { const __be32 *cell = of_get_property(np, "reg", NULL); u64 id = -1; if (cell) id = of_read_number(cell, of_n_addr_cells(np)); if (id < NR_CPUS) { if (!method) of_property_read_string(np, "enable-method", &method); set_cpu_possible(id, true); set_cpu_present(id, true); __cpu_number_map[id] = id; __cpu_logical_map[id] = id; } } if (!method) { np = of_find_node_by_name(NULL, "cpus"); of_property_read_string(np, "enable-method", &method); } pr_info("CPU enable method: %s\n", method); if (method) for (; m->method; m++) if (!strcmp(m->method, method)) { register_smp_ops(m->ops); return; } register_smp_ops(&dummy_smp_ops); }
phys_addr_t get_qe_base(void) { struct device_node *qe; int size; const u32 *prop; if (qebase != -1) return qebase; qe = of_find_compatible_node(NULL, NULL, "fsl,qe"); if (!qe) { qe = of_find_node_by_type(NULL, "qe"); if (!qe) return qebase; } prop = of_get_property(qe, "reg", &size); if (prop && size >= sizeof(*prop)) qebase = of_translate_address(qe, prop); of_node_put(qe); return qebase; }
void __init mpc85xx_smp_init(void) { struct device_node *np; np = of_find_node_by_type(NULL, "open-pic"); if (np) { smp_85xx_ops.probe = smp_mpic_probe; smp_85xx_ops.setup_cpu = smp_85xx_setup_cpu; smp_85xx_ops.message_pass = smp_mpic_message_pass; } if (cpu_has_feature(CPU_FTR_DBELL)) smp_85xx_ops.message_pass = doorbell_message_pass; BUG_ON(!smp_85xx_ops.message_pass); smp_ops = &smp_85xx_ops; #ifdef CONFIG_KEXEC ppc_md.kexec_cpu_down = mpc85xx_smp_kexec_cpu_down; ppc_md.machine_kexec = mpc85xx_smp_machine_kexec; #endif }
u32 fsl_get_sys_freq(void) { struct device_node *soc; const u32 *prop; int size; if (sysfreq != -1) return sysfreq; soc = of_find_node_by_type(NULL, "soc"); if (!soc) return -1; prop = of_get_property(soc, "clock-frequency", &size); if (!prop || size != sizeof(*prop) || *prop == 0) prop = of_get_property(soc, "bus-frequency", &size); if (prop && size == sizeof(*prop)) sysfreq = *prop; of_node_put(soc); return sysfreq; }
static void __init mpc85xx_mds_qeic_init(void) { struct device_node *np; np = of_find_compatible_node(NULL, NULL, "fsl,qe"); if (!of_device_is_available(np)) { of_node_put(np); return; } np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic"); if (!np) { np = of_find_node_by_type(NULL, "qeic"); if (!np) return; } if (machine_is(p1021_mds)) qe_ic_init(np, 0, qe_ic_cascade_low_mpic, qe_ic_cascade_high_mpic); else qe_ic_init(np, 0, qe_ic_cascade_muxed_mpic, NULL); of_node_put(np); }
unsigned int qe_get_brg_clk(void) { struct device_node *qe; int size; const u32 *prop; if (brg_clk) return brg_clk; qe = of_find_compatible_node(NULL, NULL, "fsl,qe"); if (!qe) { qe = of_find_node_by_type(NULL, "qe"); if (!qe) return brg_clk; } prop = of_get_property(qe, "brg-frequency", &size); if (prop && size == sizeof(*prop)) brg_clk = *prop; of_node_put(qe); return brg_clk; }