static int sb_gpio_free(struct udevice *dev, unsigned offset) { struct gpio_state *state = dev_get_priv(dev); debug("%s: offset:%u\n", __func__, offset); if (check_reserved(dev, offset, __func__)) return -1; state[offset].label = NULL; return set_gpio_flag(dev, offset, GPIOF_RESERVED, 0); }
static int sb_gpio_request(struct udevice *dev, unsigned offset, const char *label) { struct gpio_dev_priv *uc_priv = dev->uclass_priv; struct gpio_state *state = dev_get_priv(dev); debug("%s: offset:%u, label:%s\n", __func__, offset, label); if (offset >= uc_priv->gpio_count) { printf("sandbox_gpio: error: invalid gpio %u\n", offset); return -1; } if (get_gpio_flag(dev, offset, GPIOF_RESERVED)) { printf("sandbox_gpio: error: gpio %u already reserved\n", offset); return -1; } state[offset].label = label; return set_gpio_flag(dev, offset, GPIOF_RESERVED, 1); }
int sandbox_gpio_set_direction(struct udevice *dev, unsigned offset, int output) { return set_gpio_flag(dev, offset, GPIOF_OUTPUT, output); }
int sandbox_gpio_set_value(struct udevice *dev, unsigned offset, int value) { return set_gpio_flag(dev, offset, GPIOF_HIGH, value); }