static int rk818_parse_dt(const void* blob) { int node, nd; struct fdt_gpio_state gpios[2]; u32 bus, addr; int ret, i; node = fdt_node_offset_by_compatible(blob, 0, COMPAT_ROCKCHIP_RK818); if (node < 0) { printf("can't find dts node for rk818\n"); return -ENODEV; } if (!fdt_device_is_available(blob,node)) { printf("device rk818 is disabled\n"); return -1; } ret = fdt_get_i2c_info(blob, node, &bus, &addr); if (ret < 0) { printf("pmic rk818 get fdt i2c failed\n"); return ret; } ret = rk818_i2c_probe(bus, addr); if (ret < 0) { printf("pmic rk818 i2c probe failed\n"); return ret; } nd = fdt_get_regulator_node(blob, node); if (nd < 0) printf("%s: Cannot find regulators\n", __func__); else fdt_regulator_match(blob, nd, rk818_reg_matches, RK818_NUM_REGULATORS); for (i = 0; i < RK818_NUM_REGULATORS; i++) { if (rk818_reg_matches[i].boot_on && (rk818_reg_matches[i].min_uV == rk818_reg_matches[i].max_uV)) ret = rk818_set_regulator_init(&rk818_reg_matches[i], i); } fdtdec_decode_gpios(blob, node, "gpios", gpios, 2); support_dc_chg = fdtdec_get_int(blob, node, "rk818,support_dc_chg",0); rk818.pmic = pmic_alloc(); rk818.node = node; rk818.pmic->hw.i2c.addr = addr; rk818.pmic->bus = bus; debug("rk818 i2c_bus:%d addr:0x%02x\n", rk818.pmic->bus, rk818.pmic->hw.i2c.addr); return 0; }
static int rk808_parse_dt(const void* blob) { int node, parent, nd; u32 i2c_bus_addr, bus; int ret; fdt_addr_t addr; struct fdt_gpio_state gpios[2]; node = fdt_node_offset_by_compatible(blob, 0, COMPAT_ROCKCHIP_RK808); if (node < 0) { printf("can't find dts node for rk808\n"); return -ENODEV; } if (!fdt_device_is_available(blob,node)) { debug("device rk808 is disabled\n"); return -1; } addr = fdtdec_get_addr(blob, node, "reg"); fdtdec_decode_gpios(blob, node, "gpios", gpios, 2); parent = fdt_parent_offset(blob, node); if (parent < 0) { debug("%s: Cannot find node parent\n", __func__); return -1; } i2c_bus_addr = fdtdec_get_addr(blob, parent, "reg"); bus = i2c_get_bus_num_fdt(i2c_bus_addr); ret = rk808_i2c_probe(bus, addr); if (ret < 0) { debug("pmic rk808 i2c probe failed\n"); return ret; } nd = fdt_get_regulator_node(blob, node); if (nd < 0) printf("%s: Cannot find regulators\n", __func__); else fdt_regulator_match(blob, nd, rk808_reg_matches, RK808_NUM_REGULATORS); rk808.pmic = pmic_alloc(); rk808.node = node; rk808.pmic->hw.i2c.addr = addr; rk808.pmic->bus = bus; rk808.pwr_hold.gpio = rk_gpio_base_to_bank(gpios[1].gpio & RK_GPIO_BANK_MASK) | (gpios[1].gpio & RK_GPIO_PIN_MASK); rk808.pwr_hold.flags = !(gpios[1].flags & OF_GPIO_ACTIVE_LOW); debug("rk808 i2c_bus:%d addr:0x%02x\n", rk808.pmic->bus, rk808.pmic->hw.i2c.addr); return 0; }
int ricoh619_parse_dt(const void* blob) { int node, parent, nd; u32 i2c_bus_addr, bus; int ret; fdt_addr_t addr; node = fdt_node_offset_by_compatible(blob, 0, COMPAT_RICOH_RICOH619); if (node < 0) { printf("can't find dts node for ricoh619\n"); return -ENODEV; } if (!fdt_device_is_available(blob,node)) { debug("device ricoh619 is disabled\n"); return -1; } addr = fdtdec_get_addr(blob, node, "reg"); parent = fdt_parent_offset(blob, node); if (parent < 0) { debug("%s: Cannot find node parent\n", __func__); return -1; } i2c_bus_addr = fdtdec_get_addr(blob, parent, "reg"); bus = i2c_get_bus_num_fdt(i2c_bus_addr); ret = ricoh619_i2c_probe(bus, addr); if (ret < 0) { debug("pmic ricoh619 i2c probe failed\n"); return ret; } nd = fdt_get_regulator_node(blob, node); if (nd < 0) printf("%s: Cannot find regulators\n", __func__); else fdt_regulator_match(blob, nd, ricoh619_regulator_matches, RICOH619_NUM_REGULATORS); ricoh619.pmic = pmic_alloc(); ricoh619.node = node; ricoh619.pmic->hw.i2c.addr = addr; ricoh619.pmic->bus = bus; debug("ricoh619 i2c_bus:%d addr:0x%02x\n", ricoh619.pmic->bus, ricoh619.pmic->hw.i2c.addr); return 0; }