Esempio n. 1
0
int
nvmem_write_cell_by_name(phandle_t node, const char *name, void *cell, size_t buflen)
{
	int rv, idx;

	rv = ofw_bus_find_string_index(node, "nvmem-cell-names", name, &idx);
	if (rv != 0)
		return (rv);

	return (nvmem_write_cell_by_idx(node, idx, cell, buflen));
}
Esempio n. 2
0
int
gpio_pin_get_by_ofw_name(device_t consumer, phandle_t node,
    char *name, gpio_pin_t *pin)
{
	int rv, idx;

	KASSERT(consumer != NULL && node > 0,
	    ("both consumer and node required"));

	rv = ofw_bus_find_string_index(node, "gpio-names", name, &idx);
	if (rv != 0)
		return (rv);
	return (gpio_pin_get_by_ofw_idx(consumer, node, idx, pin));
}
Esempio n. 3
0
int
hwreset_get_by_ofw_name(device_t consumer_dev, char *name, hwreset_t *rst)
{
	int rv, idx;
	phandle_t cnode;

	cnode = ofw_bus_get_node(consumer_dev);
	if (cnode <= 0) {
		device_printf(consumer_dev,
		    "%s called on not ofw based device\n",  __func__);
		return (ENXIO);
	}
	rv = ofw_bus_find_string_index(cnode, "reset-names", name, &idx);
	if (rv != 0)
		return (rv);
	return (hwreset_get_by_ofw_idx(consumer_dev, idx, rst));
}
Esempio n. 4
0
int
phy_get_by_ofw_name(device_t consumer_dev, phandle_t cnode, char *name,
                    phy_t *phy)
{
    int rv, idx;

    if (cnode <= 0)
        cnode = ofw_bus_get_node(consumer_dev);
    if (cnode <= 0) {
        device_printf(consumer_dev,
                      "%s called on not ofw based device\n",  __func__);
        return (ENXIO);
    }
    rv = ofw_bus_find_string_index(cnode, "phy-names", name, &idx);
    if (rv != 0)
        return (rv);
    return (phy_get_by_ofw_idx(consumer_dev, cnode, idx, phy));
}
Esempio n. 5
0
int
nvmem_get_cell_len(phandle_t node, const char *name)
{
	phandle_t cell_node;
	uint32_t reg[2];
	int rv, idx;

	rv = ofw_bus_find_string_index(node, "nvmem-cell-names", name, &idx);
	if (rv != 0)
		return (rv);

	rv = nvmem_get_cell_node(node, idx, &cell_node);
	if (rv != 0)
		return (rv);

	if (OF_getencprop(cell_node, "reg", reg, sizeof(reg)) != sizeof(reg)) {
		if (bootverbose)
			printf("nvmem_get_cell_len: Cannot parse reg property of cell %s\n",
			    name);
		return (ENOENT);
	}

	return (reg[1]);
}