Ejemplo n.º 1
0
/* write GPIO OUT value to port 'offset' */
static int sb_gpio_set_value(struct udevice *dev, unsigned offset, int value)
{
	debug("%s: offset:%u, value = %d\n", __func__, offset, value);

	if (!sandbox_gpio_get_direction(dev, offset)) {
		printf("sandbox_gpio: error: set_value on input gpio %u\n",
		       offset);
		return -1;
	}

	return sandbox_gpio_set_value(dev, offset, value);
}
Ejemplo n.º 2
0
static int sb_gpio_get_state(struct udevice *dev, unsigned int offset,
			     char *buf, int bufsize)
{
	struct gpio_dev_priv *uc_priv = dev->uclass_priv;
	struct gpio_state *state = dev_get_priv(dev);
	const char *label;

	label = state[offset].label;
	snprintf(buf, bufsize, "%s%d: %s: %d [%c]%s%s",
		 uc_priv->bank_name ? uc_priv->bank_name : "", offset,
		 sandbox_gpio_get_direction(dev, offset) ? "out" : " in",
		 sandbox_gpio_get_value(dev, offset),
		 get_gpio_flag(dev, offset, GPIOF_RESERVED) ? 'x' : ' ',
		 label ? " " : "",
		 label ? label : "");

	return 0;
}