/** * mdss_dsi_find_panel_of_node(): find device node of dsi panel * @pdev: platform_device of the dsi ctrl node * @panel_cfg: string containing intf specific config data * * Function finds the panel device node using the interface * specific configuration data. This configuration data is * could be derived from the result of bootloader's GCDB * panel detection mechanism. If such config data doesn't * exist then this panel returns the default panel configured * in the device tree. * * returns pointer to panel node on success, NULL on error. */ static struct device_node *mdss_dsi_find_panel_of_node( struct platform_device *pdev, char *panel_cfg) { int l; int ctrl_id = -1; char *panel_name; struct device_node *dsi_pan_node = NULL, *mdss_node = NULL; l = strlen(panel_cfg); if (!l) { /* no panel cfg chg, parse dt */ pr_debug("%s:%d: no cmd line cfg present\n", __func__, __LINE__); dsi_pan_node = mdss_dsi_pref_prim_panel(pdev); } else { if (panel_cfg[0] == '0') { pr_debug("%s:%d: DSI ctrl 1\n", __func__, __LINE__); ctrl_id = 0; } else if (panel_cfg[0] == '1') { pr_debug("%s:%d: DSI ctrl 2\n", __func__, __LINE__); ctrl_id = 1; } if ((pdev->id - 1) != ctrl_id) { pr_err("%s:%d:pdev_ID=[%d]\n", __func__, __LINE__, pdev->id); return NULL; } /* * skip first two chars '<dsi_ctrl_id>' and * ':' to get to the panel name */ panel_name = panel_cfg + 2; pr_debug("%s:%d:%s:%s\n", __func__, __LINE__, panel_cfg, panel_name); mdss_node = of_parse_phandle(pdev->dev.of_node, "qcom,mdss-mdp", 0); if (!mdss_node) { pr_err("%s: %d: mdss_node null\n", __func__, __LINE__); return NULL; } dsi_pan_node = of_find_node_by_name(mdss_node, panel_name); if (!dsi_pan_node) { pr_err("%s: invalid pan node, selecting prim panel\n", __func__); dsi_pan_node = mdss_dsi_pref_prim_panel(pdev); } } return dsi_pan_node; }
static int __init smp_core99_probe(void) { struct device_node *cpus; struct device_node *cc; int ncpus = 0; /* Maybe use systemconfiguration here ? */ if (ppc_md.progress) ppc_md.progress("smp_core99_probe", 0x345); /* Count CPUs in the device-tree */ for (cpus = NULL; (cpus = of_find_node_by_type(cpus, "cpu")) != NULL;) ++ncpus; printk(KERN_INFO "PowerMac SMP probe found %d cpus\n", ncpus); /* Nothing more to do if less than 2 of them */ if (ncpus <= 1) return 1; /* Look for the clock chip */ for (cc = NULL; (cc = of_find_node_by_name(cc, "i2c-hwclock")) != NULL;) { struct device_node *p = of_get_parent(cc); u32 *reg; int ok; ok = p && device_is_compatible(p, "uni-n-i2c"); if (!ok) goto next; reg = (u32 *)get_property(cc, "reg", NULL); if (reg == NULL) goto next; switch (*reg) { case 0xd2: pmac_tb_freeze = smp_core99_cypress_tb_freeze; printk(KERN_INFO "Timebase clock is Cypress chip\n"); break; case 0xd4: pmac_tb_freeze = smp_core99_pulsar_tb_freeze; printk(KERN_INFO "Timebase clock is Pulsar chip\n"); break; } if (pmac_tb_freeze != NULL) { pmac_tb_clock_chip_host = p; smp_ops->give_timebase = smp_core99_give_timebase; smp_ops->take_timebase = smp_core99_take_timebase; break; } next: of_node_put(p); } mpic_request_ipis(); return ncpus; }
static int msm_vidc_load_bus_vectors(struct msm_vidc_platform_resources *res) { struct platform_device *pdev = res->pdev; struct device_node *child_node, *bus_node; struct bus_set *buses = &res->bus_set; int rc = 0, c = 0; u32 num_buses = 0; bus_node = of_find_node_by_name(pdev->dev.of_node, "qcom,msm-bus-clients"); if (!bus_node) { /* Not a required property */ dprintk(VIDC_DBG, "qcom,msm-bus-clients not found\n"); rc = 0; goto err_bad_node; } for_each_child_of_node(bus_node, child_node) ++num_buses; buses->bus_tbl = devm_kzalloc(&pdev->dev, sizeof(*buses->bus_tbl) * num_buses, GFP_KERNEL); if (!buses->bus_tbl) { dprintk(VIDC_ERR, "%s: Failed to allocate memory\n", __func__); rc = -ENOMEM; goto err_bad_node; } buses->count = num_buses; c = 0; for_each_child_of_node(bus_node, child_node) { bool passive = false; u32 configs = 0; struct bus_info *bus = &buses->bus_tbl[c]; passive = of_property_read_bool(child_node, "qcom,bus-passive"); rc = of_property_read_u32(child_node, "qcom,bus-configs", &configs); if (rc) { dprintk(VIDC_ERR, "Failed to read qcom,bus-configs in %s: %d\n", child_node->name, rc); break; } bus->passive = passive; bus->sessions_supported = configs; bus->pdata = msm_bus_pdata_from_node(pdev, child_node); if (IS_ERR_OR_NULL(bus->pdata)) { rc = PTR_ERR(bus->pdata) ?: -EBADHANDLE; dprintk(VIDC_ERR, "Failed to get bus pdata: %d\n", rc); break; }
/* ************************************************************************ * * Setup the architecture * */ static void __init mpc832x_sys_setup_arch(void) { struct device_node *np; u8 __iomem *bcsr_regs = NULL; if (ppc_md.progress) ppc_md.progress("mpc832x_sys_setup_arch()", 0); /* Map BCSR area */ np = of_find_node_by_name(NULL, "bcsr"); if (np) { struct resource res; of_address_to_resource(np, 0, &res); bcsr_regs = ioremap(res.start, resource_size(&res)); of_node_put(np); } mpc83xx_setup_pci(); #ifdef CONFIG_QUICC_ENGINE 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 PHYs */ #define BCSR8_FETH_RST 0x50 clrbits8(&bcsr_regs[8], BCSR8_FETH_RST); udelay(1000); setbits8(&bcsr_regs[8], BCSR8_FETH_RST); iounmap(bcsr_regs); of_node_put(np); } #endif /* CONFIG_QUICC_ENGINE */ }
void __init device_tree_init(void) { struct device_node *np; unflatten_and_copy_device_tree(); /* Disable SMP boot unless both CPUs are listed in DT and !disabled */ np = of_find_node_by_name(NULL, "cpus"); if (np && of_get_available_child_count(np) <= 1) bmips_smp_enabled = 0; of_node_put(np); }
static int SM5701_parse_dt(struct SM5701_platform_data *pdata) { int ret = 0; struct device_node *np = of_find_node_by_name(NULL, "chargermfd"); struct device_node *np2 = of_find_node_by_name(np, "charger"); if (np == NULL) { pr_err("%s np NULL\n", __func__); } else { pdata->irq = of_get_named_gpio(np, "chgirq-gpio", 0); pdata->chgen = of_get_named_gpio(np2, "chgen-gpio", 0); pr_info("%s: SM5701_parse_dt irq: %d\n", __func__, pdata->irq); pr_info("%s: SM5701_parse_dt chgen: %d\n", __func__, pdata->chgen); if (pdata->irq < 0) { pr_err("%s: of_get_named_gpio failed: %d\n", __func__, pdata->irq); return pdata->irq; } } return ret; }
void __init at91_add_device_hdmac(void) { #if defined(CONFIG_OF) struct device_node *of_node = of_find_node_by_name(NULL, "dma-controller"); if (of_node) of_node_put(of_node); else #endif platform_device_register(&at_hdmac_device); }
static void __init cell_find_and_init_phbs(void) { struct device_node *axon, *plb5, *plb4, *np; int index = 0; /* Old blades, use generic code */ axon = of_find_node_by_name(NULL, "axon"); if (axon == NULL) { find_and_init_phbs(); return; } /* New blades, manually instanciate bridges for now as * RHEL5 doesn't have the infrastructure to do it from * of_platform */ for (; axon; axon = of_find_node_by_name(axon, "axon")) { for (plb5 = NULL; !!(plb5 = of_get_next_child(axon, plb5));) if (strcmp(plb5->name, "plb5") == 0) break; if (plb5 == NULL) continue; for (np = NULL; !!(np = of_get_next_child(plb5, np));) if ((strcmp(np->name, "pcie") == 0) || (strcmp(np->name, "pciex") == 0)) cell_add_phb(np, index++); for (plb4 = NULL; !!(plb4 = of_get_next_child(plb5, plb4));) if (strcmp(plb4->name, "plb4") == 0) break; of_node_put(plb5); if (plb4 == NULL) continue; for (np = NULL; !!(np = of_get_next_child(plb4, np));) if (strcmp(np->name, "pcix") == 0) cell_add_phb(np, index++); of_node_put(plb4); } pci_devs_phb_init(); }
static int probe_bcl_periph_prop(struct bcl_context *bcl) { int ret = 0; struct device_node *ibat_node = NULL, *dev_node = bcl->dev->of_node; char *key = NULL; key = "qcom,ibat-monitor"; ibat_node = of_find_node_by_name(dev_node, key); if (!ibat_node) { ret = -ENODEV; goto ibat_probe_exit; } BCL_FETCH_DT_U32(ibat_node, key, "qcom,low-threshold-uamp", ret, bcl->ibat_low_thresh.trip_value, ibat_probe_exit); BCL_FETCH_DT_U32(ibat_node, key, "qcom,high-threshold-uamp", ret, bcl->ibat_high_thresh.trip_value, ibat_probe_exit); BCL_FETCH_DT_U32(ibat_node, key, "qcom,mitigation-freq-khz", ret, bcl->bcl_p_freq_max, ibat_probe_exit); BCL_FETCH_DT_U32(ibat_node, key, "qcom,vph-high-threshold-uv", ret, bcl->vbat_high_thresh.trip_value, ibat_probe_exit); BCL_FETCH_DT_U32(ibat_node, key, "qcom,vph-low-threshold-uv", ret, bcl->vbat_low_thresh.trip_value, ibat_probe_exit); BCL_FETCH_DT_U32(ibat_node, key, "qcom,soc-low-threshold", ret, soc_low_threshold, ibat_probe_exit); bcl->vbat_high_thresh.trip_notify = bcl->vbat_low_thresh.trip_notify = bcl_periph_vbat_notify; bcl->vbat_high_thresh.trip_data = bcl->vbat_low_thresh.trip_data = (void *) bcl; bcl->ibat_high_thresh.trip_notify = bcl->ibat_low_thresh.trip_notify = bcl_periph_ibat_notify; bcl->ibat_high_thresh.trip_data = bcl->ibat_low_thresh.trip_data = (void *) bcl; get_vdd_rstr_freq(bcl, ibat_node); bcl->bcl_p_freq_max = max(bcl->bcl_p_freq_max, bcl->thermal_freq_limit); bcl->btm_mode = BCL_MONITOR_DISABLED; bcl->bcl_monitor_type = BCL_IBAT_PERIPH_MONITOR_TYPE; snprintf(bcl->bcl_type, BCL_NAME_LENGTH, "%s", bcl_type[BCL_IBAT_PERIPH_MONITOR_TYPE]); ret = cpufreq_register_notifier(&bcl_cpufreq_notifier, CPUFREQ_POLICY_NOTIFIER); if (ret) pr_err("Error with cpufreq register. err:%d\n", ret); ibat_probe_exit: if (ret && ret != -EPROBE_DEFER) dev_info(bcl->dev, "%s:%s Error reading key:%s. ret = %d\n", KBUILD_MODNAME, __func__, key, ret); return ret; }
/** * thermal_zone_of_sensor_register - registers a sensor to a DT thermal zone * @dev: a valid struct device pointer of a sensor device. Must contain * a valid .of_node, for the sensor node. * @sensor_id: a sensor identifier, in case the sensor IP has more * than one sensors * @data: a private pointer (owned by the caller) that will be passed * back, when a temperature reading is needed. * @get_temp: a pointer to a function that reads the sensor temperature. * @get_trend: a pointer to a function that reads the sensor temperature trend. * * This function will search the list of thermal zones described in device * tree and look for the zone that refer to the sensor device pointed by * @dev->of_node as temperature providers. For the zone pointing to the * sensor node, the sensor will be added to the DT thermal zone device. * * The thermal zone temperature is provided by the @get_temp function * pointer. When called, it will have the private pointer @data back. * * The thermal zone temperature trend is provided by the @get_trend function * pointer. When called, it will have the private pointer @data back. * * TODO: * 01 - This function must enqueue the new sensor instead of using * it as the only source of temperature values. * * 02 - There must be a way to match the sensor with all thermal zones * that refer to it. * * Return: On success returns a valid struct thermal_zone_device, * otherwise, it returns a corresponding ERR_PTR(). Caller must * check the return value with help of IS_ERR() helper. */ struct thermal_zone_device * thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data, int (*get_temp)(void *, long *), int (*get_trend)(void *, long *)) { struct device_node *np, *child, *sensor_np; np = of_find_node_by_name(NULL, "thermal-zones"); if (!np) return ERR_PTR(-ENODEV); if (!dev || !dev->of_node) return ERR_PTR(-EINVAL); sensor_np = dev->of_node; for_each_child_of_node(np, child) { struct of_phandle_args sensor_specs; int ret, id; /* Check whether child is enabled or not */ if (!of_device_is_available(child)) continue; /* For now, thermal framework supports only 1 sensor per zone */ ret = of_parse_phandle_with_args(child, "thermal-sensors", "#thermal-sensor-cells", 0, &sensor_specs); if (ret) continue; if (sensor_specs.args_count >= 1) { id = sensor_specs.args[0]; WARN(sensor_specs.args_count > 1, "%s: too many cells in sensor specifier %d\n", sensor_specs.np->name, sensor_specs.args_count); } else { id = 0; } if (sensor_specs.np == sensor_np && id == sensor_id) { of_node_put(np); return thermal_zone_of_add_sensor(child, sensor_np, data, get_temp, get_trend); } } of_node_put(np); return ERR_PTR(-ENODEV); }
int __init cpm_muram_init(void) { struct device_node *np; struct resource r; u32 zero[OF_MAX_ADDR_CELLS] = {}; resource_size_t max = 0; int i = 0; int ret = 0; spin_lock_init(&cpm_muram_lock); /* initialize the info header */ rh_init(&cpm_muram_info, 1, sizeof(cpm_boot_muram_rh_block) / sizeof(cpm_boot_muram_rh_block[0]), cpm_boot_muram_rh_block); np = of_find_compatible_node(NULL, NULL, "fsl,cpm-muram-data"); if (!np) { /* try legacy bindings */ np = of_find_node_by_name(NULL, "data-only"); if (!np) { printk(KERN_ERR "Cannot find CPM muram data node"); ret = -ENODEV; goto out; } } muram_pbase = of_translate_address(np, zero); if (muram_pbase == (phys_addr_t)OF_BAD_ADDR) { printk(KERN_ERR "Cannot translate zero through CPM muram node"); ret = -ENODEV; goto out; } while (of_address_to_resource(np, i++, &r) == 0) { if (r.end > max) max = r.end; rh_attach_region(&cpm_muram_info, r.start - muram_pbase, r.end - r.start + 1); } muram_vbase = ioremap(muram_pbase, max - muram_pbase + 1); if (!muram_vbase) { printk(KERN_ERR "Cannot map CPM muram"); ret = -ENOMEM; } out: of_node_put(np); return ret; }
int __init hydra_init(void) { struct device_node *np; struct resource r; np = of_find_node_by_name(NULL, "mac-io"); if (np == NULL || of_address_to_resource(np, 0, &r)) { of_node_put(np); return 0; } of_node_put(np); <<<<<<< HEAD
static void exynos_lpm_dt_init(void) { struct device_node *np = of_find_node_by_name(NULL, "power-mode"); parsing_dt_reg_check_list(np, "lpm-reg", "lpm-val", check_reg_lpm); parsing_dt_reg_check_list(np, "lpc-reg", "lpc-val", check_reg_lpc); if (of_property_read_u32(np, "cpd_residency", &cpd_residency)) pr_warn("No matching property: cpd_residency\n"); if (of_property_read_u32(np, "lpc_residency", &lpc_residency)) pr_warn("No matching property: lpc_residency\n"); }
static bool twl6040_has_vibra(struct twl6040_platform_data *pdata, struct device_node *node) { if (pdata && pdata->vibra) return true; #ifdef CONFIG_OF if (of_find_node_by_name(node, "vibra")) return true; #endif return false; }
static bool twl4030_vibra_check_coexist(struct twl4030_vibra_data *pdata, struct device_node *node) { if (pdata && pdata->coexist) return true; if (of_find_node_by_name(node, "codec")) { of_node_put(node); return true; } return false; }
static void of_override_clk(u32 *enable) { struct device_node *chosen_node = NULL; chosen_node = of_find_node_by_name(NULL, "chosen"); if (!chosen_node) { pr_err("%s: get chosen node failed\n", __func__); return; } of_property_read_u32(chosen_node, "mmi,clock_override", enable); of_node_put(chosen_node); }
int read_log(struct tpm_bios_log *log) { struct device_node *np; const u32 *sizep; const __be64 *basep; if (log->bios_event_log != NULL) { pr_err("%s: ERROR - Eventlog already initialized\n", __func__); return -EFAULT; } np = of_find_node_by_name(NULL, "ibm,vtpm"); if (!np) { pr_err("%s: ERROR - IBMVTPM not supported\n", __func__); return -ENODEV; } sizep = of_get_property(np, "linux,sml-size", NULL); if (sizep == NULL) { pr_err("%s: ERROR - SML size not found\n", __func__); goto cleanup_eio; } if (*sizep == 0) { pr_err("%s: ERROR - event log area empty\n", __func__); goto cleanup_eio; } basep = of_get_property(np, "linux,sml-base", NULL); if (basep == NULL) { pr_err("%s: ERROR - SML not found\n", __func__); goto cleanup_eio; } of_node_put(np); log->bios_event_log = kmalloc(*sizep, GFP_KERNEL); if (!log->bios_event_log) { pr_err("%s: ERROR - Not enough memory for BIOS measurements\n", __func__); return -ENOMEM; } log->bios_event_log_end = log->bios_event_log + *sizep; memcpy(log->bios_event_log, __va(be64_to_cpup(basep)), *sizep); return 0; cleanup_eio: of_node_put(np); return -EIO; }
int __init ams_init(void) { struct device_node *np; spin_lock_init(&ams_info.irq_lock); mutex_init(&ams_info.lock); INIT_WORK(&ams_info.worker, ams_worker); #ifdef CONFIG_SENSORS_AMS_I2C np = of_find_node_by_name(NULL, "accelerometer"); if (np && of_device_is_compatible(np, "AAPL,accelerometer_1")) /* Found I2C motion sensor */ return ams_i2c_init(np); #endif #ifdef CONFIG_SENSORS_AMS_PMU np = of_find_node_by_name(NULL, "sms"); if (np && of_device_is_compatible(np, "sms")) /* Found PMU motion sensor */ return ams_pmu_init(np); #endif return -ENODEV; }
static struct max77828_haptic_platform_data *of_max77828_haptic_dt(struct device *dev) { struct device_node *np_root = dev->parent->of_node; struct device_node *np_haptic; struct max77828_haptic_platform_data *pdata; u32 temp; const char *temp_str; pdata = kzalloc(sizeof(struct max77828_haptic_platform_data), GFP_KERNEL); if (!pdata) { pr_err("%s: failed to allocate driver data\n", __func__); return NULL; } printk("%s : start dt parsing\n", __func__); np_haptic = of_find_node_by_name(np_root, "haptic"); if (np_haptic == NULL) { pr_err("[VIB] %s : error to get dt node\n", __func__); kfree(pdata); return NULL; } of_property_read_u32(np_haptic, "haptic,max_timeout", &temp); pdata->max_timeout = (u16)temp; of_property_read_u32(np_haptic, "haptic,duty", &temp); pdata->duty = (u16)temp; of_property_read_u32(np_haptic, "haptic,period", &temp); pdata->period = (u16)temp; of_property_read_u32(np_haptic, "haptic,pwm_id", &temp); pdata->pwm_id = (u16)temp; of_property_read_string(np_haptic, "haptic,regulator_name", &temp_str); pdata->regulator_name = (char *)temp_str; /* debugging */ printk("%s : max_timeout = %d\n", __func__, pdata->max_timeout); printk("%s : duty = %d\n", __func__, pdata->duty); printk("%s : period = %d\n", __func__, pdata->period); printk("%s : pwm_id = %d\n", __func__, pdata->pwm_id); printk("%s : regulator_name = %s\n", __func__, pdata->regulator_name); pdata->init_hw = NULL; pdata->motor_en = NULL; return pdata; }
/* Marvell Discovery II based Pegasos 2 */ static void __init setup_peg2(struct pci_controller *hose, struct device_node *dev) { struct device_node *root = find_path_device("/"); struct device_node *rtas; rtas = of_find_node_by_name (root, "rtas"); if (rtas) { hose->ops = &rtas_pci_ops; } else { printk ("RTAS supporting Pegasos OF not found, please upgrade" " your firmware\n"); } pci_assign_all_buses = 1; }
static int ulpi_of_register(struct ulpi *ulpi) { struct device_node *np = NULL, *child; struct device *parent; /* Find a ulpi bus underneath the parent or the grandparent */ parent = ulpi->dev.parent; if (parent->of_node) np = of_find_node_by_name(parent->of_node, "ulpi"); else if (parent->parent && parent->parent->of_node) np = of_find_node_by_name(parent->parent->of_node, "ulpi"); if (!np) return 0; child = of_get_next_available_child(np, NULL); of_node_put(np); if (!child) return -EINVAL; ulpi->dev.of_node = child; return 0; }
void __init sun4m_init_IRQ(void) { struct device_node *dp = of_find_node_by_name(NULL, "interrupt"); int len, i, mid, num_cpu_iregs; const u32 *addr; if (!dp) { printk(KERN_ERR "sun4m_init_IRQ: No 'interrupt' node.\n"); return; } addr = of_get_property(dp, "address", &len); of_node_put(dp); if (!addr) { printk(KERN_ERR "sun4m_init_IRQ: No 'address' prop.\n"); return; } num_cpu_iregs = (len / sizeof(u32)) - 1; for (i = 0; i < num_cpu_iregs; i++) { sun4m_irq_percpu[i] = (void __iomem *) (unsigned long) addr[i]; } sun4m_irq_global = (void __iomem *) (unsigned long) addr[num_cpu_iregs]; local_irq_disable(); sbus_writel(~SUN4M_INT_MASKALL, &sun4m_irq_global->mask_set); for (i = 0; !cpu_find_by_instance(i, NULL, &mid); i++) sbus_writel(~0x17fff, &sun4m_irq_percpu[mid]->clear); if (num_cpu_iregs == 4) sbus_writel(0, &sun4m_irq_global->interrupt_target); BTFIXUPSET_CALL(enable_irq, sun4m_enable_irq, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(disable_irq, sun4m_disable_irq, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(enable_pil_irq, sun4m_enable_pil_irq, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(disable_pil_irq, sun4m_disable_pil_irq, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(clear_clock_irq, sun4m_clear_clock_irq, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(load_profile_irq, sun4m_load_profile_irq, BTFIXUPCALL_NORM); sparc_init_timers = sun4m_init_timers; #ifdef CONFIG_SMP BTFIXUPSET_CALL(set_cpu_int, sun4m_send_ipi, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(clear_cpu_int, sun4m_clear_ipi, BTFIXUPCALL_NORM); BTFIXUPSET_CALL(set_irq_udt, sun4m_set_udt, BTFIXUPCALL_NORM); #endif /* Cannot enable interrupts until OBP ticker is disabled. */ }
/* If there are footprints written before smp_init, do init on driver detection are too late. */ int __init mnemosyne_early_init(void) { struct device_node *np; pr_info("%s: init from early init.\n", MNEMOSYNE_MODULE_NAME); np = of_find_node_by_name(NULL, MNEMOSYNE_DT_NAME); if (!np) { pr_warn("%s: cannot find mnemosyne device node named %s.\n", MNEMOSYNE_MODULE_NAME, MNEMOSYNE_DT_NAME); return -ENODEV; } return mnemosyne_parse_dt(np); }
void __init plat_time_init(void) { struct device_node *np; u32 freq; np = of_find_node_by_name(NULL, "cpus"); if (!np) panic("missing 'cpus' DT node"); if (of_property_read_u32(np, "mips-hpt-frequency", &freq) < 0) panic("missing 'mips-hpt-frequency' property"); of_node_put(np); mips_hpt_frequency = freq; }
void udbg_init_scc(struct device_node *np) { u32 *reg; unsigned long addr; int i, x; if (np == NULL) np = of_find_node_by_name(NULL, "escc"); if (np == NULL || np->parent == NULL) return; udbg_printf("found SCC...\n"); /* Get address within mac-io ASIC */ reg = (u32 *)get_property(np, "reg", NULL); if (reg == NULL) return; addr = reg[0]; udbg_printf("local addr: %lx\n", addr); /* Get address of mac-io PCI itself */ reg = (u32 *)get_property(np->parent, "assigned-addresses", NULL); if (reg == NULL) return; addr += reg[2]; udbg_printf("final addr: %lx\n", addr); /* Setup for 57600 8N1 */ addr += 0x20; sccc = (volatile u8 *) ioremap(addr & PAGE_MASK, PAGE_SIZE) ; sccc += addr & ~PAGE_MASK; sccd = sccc + 0x10; udbg_printf("ioremap result sccc: %p\n", sccc); mb(); for (i = 20000; i != 0; --i) x = *sccc; eieio(); *sccc = 9; eieio(); /* reset A or B side */ *sccc = 0xc0; eieio(); for (i = 0; i < sizeof(scc_inittab); ++i) { *sccc = scc_inittab[i]; eieio(); } ppc_md.udbg_putc = udbg_putc; ppc_md.udbg_getc = udbg_getc; ppc_md.udbg_getc_poll = udbg_getc_poll; udbg_puts("Hello World !\n"); }
int __devinit mc13xxx_get_num_regulators_dt(struct platform_device *pdev) { struct device_node *parent, *child; int num = 0; of_node_get(pdev->dev.parent->of_node); parent = of_find_node_by_name(pdev->dev.parent->of_node, "regulators"); if (!parent) return -ENODEV; for_each_child_of_node(parent, child) num++; return num; }
int __init owl_pmu_detect(void) { int ret; struct device_node *np; ret = sysfs_create_file(power_kobj, &dev_attr_pmu_id.attr); if (ret) pr_err("sysfs_create_file failed: %d\n", ret); np = of_find_node_by_name(NULL, "dcdc0"); if (np) { pmu_id = 1; return 0; } np = of_find_node_by_name(NULL, "dcdc1"); if (np) { pmu_id = 0; return 0; } pr_err("DTS without PMU node!\n"); return -EINVAL; }
static int find_bridge(const char *name, struct bridge_init *bridge) { bridge->valid = false; bridge->client = NULL; bridge->node = of_find_node_by_name(NULL, name); if (!bridge->node) return 0; bridge->client = of_find_i2c_device_by_node(bridge->node); if (!bridge->client) return -ENODEV; bridge->valid = true; return 0; }
static struct da9063_regulators_pdata *da9063_parse_regulators_dt( struct platform_device *pdev, struct of_regulator_match **da9063_reg_matches) { struct da9063_regulators_pdata *pdata; struct da9063_regulator_data *rdata; struct device_node *node; int i, n, num; node = of_find_node_by_name(pdev->dev.parent->of_node, "regulators"); if (!node) { dev_err(&pdev->dev, "Regulators device node not found\n"); return ERR_PTR(-ENODEV); } num = of_regulator_match(&pdev->dev, node, da9063_matches, ARRAY_SIZE(da9063_matches)); if (num < 0) { dev_err(&pdev->dev, "Failed to match regulators\n"); return ERR_PTR(-EINVAL); } pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return ERR_PTR(-ENOMEM); pdata->regulator_data = devm_kzalloc(&pdev->dev, num * sizeof(*pdata->regulator_data), GFP_KERNEL); if (!pdata->regulator_data) return ERR_PTR(-ENOMEM); pdata->n_regulators = num; n = 0; for (i = 0; i < ARRAY_SIZE(da9063_matches); i++) { if (!da9063_matches[i].init_data) continue; rdata = &pdata->regulator_data[n]; rdata->id = i; rdata->initdata = da9063_matches[i].init_data; n++; }; *da9063_reg_matches = da9063_matches; return pdata; }
int pmac_has_backlight_type(const char *type) { struct device_node* bk_node = of_find_node_by_name(NULL, "backlight"); if (bk_node) { const char *prop = of_get_property(bk_node, "backlight-control", NULL); if (prop && strncmp(prop, type, strlen(type)) == 0) { of_node_put(bk_node); return 1; } of_node_put(bk_node); } return 0; }