int board_get_revision(void) { struct fdt_gpio_state gpios[CONFIG_BOARD_REV_GPIO_COUNT]; unsigned gpio_list[CONFIG_BOARD_REV_GPIO_COUNT]; int board_rev = -1; int count = 0; int node; node = fdtdec_next_compatible(gd->fdt_blob, 0, COMPAT_GOOGLE_BOARD_REV); if (node >= 0) { count = fdtdec_decode_gpios(gd->fdt_blob, node, "google,board-rev-gpios", gpios, CONFIG_BOARD_REV_GPIO_COUNT); } if (count > 0) { int i; for (i = 0; i < count; i++) gpio_list[i] = gpios[i].gpio; board_rev = gpio_decode_number(gpio_list, count); } else { debug("%s: No board revision information in fdt\n", __func__); } return board_rev; }
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; }
int fdtdec_decode_gpio(const void *blob, int node, const char *prop_name, struct fdt_gpio_state *gpio) { int err; debug("%s: %s\n", __func__, prop_name); gpio->gpio = FDT_GPIO_NONE; gpio->name = NULL; err = fdtdec_decode_gpios(blob, node, prop_name, gpio, 1); return err == 1 ? 0 : err; }
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; }