Lines Matching refs:offset

28 static struct gpio_state *get_gpio_state(struct udevice *dev, uint offset)  in get_gpio_state()  argument
33 if (offset >= uc_priv->gpio_count) { in get_gpio_state()
34 printf("sandbox_gpio: error: invalid gpio %u\n", offset); in get_gpio_state()
38 return &state[offset]; in get_gpio_state()
42 static ulong *get_gpio_flags(struct udevice *dev, unsigned int offset) in get_gpio_flags() argument
44 struct gpio_state *state = get_gpio_state(dev, offset); in get_gpio_flags()
53 static int get_gpio_flag(struct udevice *dev, unsigned int offset, ulong flag) in get_gpio_flag() argument
55 return (*get_gpio_flags(dev, offset) & flag) != 0; in get_gpio_flag()
58 static int set_gpio_flag(struct udevice *dev, unsigned int offset, ulong flag, in set_gpio_flag() argument
61 struct gpio_state *state = get_gpio_state(dev, offset); in set_gpio_flag()
75 int sandbox_gpio_get_value(struct udevice *dev, unsigned offset) in sandbox_gpio_get_value() argument
77 struct gpio_state *state = get_gpio_state(dev, offset); in sandbox_gpio_get_value()
80 if (get_gpio_flag(dev, offset, GPIOD_IS_OUT)) in sandbox_gpio_get_value()
81 debug("sandbox_gpio: get_value on output gpio %u\n", offset); in sandbox_gpio_get_value()
97 int sandbox_gpio_set_value(struct udevice *dev, unsigned offset, int value) in sandbox_gpio_set_value() argument
99 set_gpio_flag(dev, offset, GPIOD_EXT_DRIVEN | GPIOD_EXT_HIGH, value); in sandbox_gpio_set_value()
104 int sandbox_gpio_get_direction(struct udevice *dev, unsigned offset) in sandbox_gpio_get_direction() argument
106 return get_gpio_flag(dev, offset, GPIOD_IS_OUT); in sandbox_gpio_get_direction()
109 int sandbox_gpio_set_direction(struct udevice *dev, unsigned offset, int output) in sandbox_gpio_set_direction() argument
111 set_gpio_flag(dev, offset, GPIOD_IS_OUT, output); in sandbox_gpio_set_direction()
112 set_gpio_flag(dev, offset, GPIOD_IS_IN, !output); in sandbox_gpio_set_direction()
117 ulong sandbox_gpio_get_flags(struct udevice *dev, uint offset) in sandbox_gpio_get_flags() argument
119 ulong flags = *get_gpio_flags(dev, offset); in sandbox_gpio_get_flags()
124 int sandbox_gpio_set_flags(struct udevice *dev, uint offset, ulong flags) in sandbox_gpio_set_flags() argument
126 struct gpio_state *state = get_gpio_state(dev, offset); in sandbox_gpio_set_flags()
138 static int sb_gpio_direction_input(struct udevice *dev, unsigned offset) in sb_gpio_direction_input() argument
140 debug("%s: offset:%u\n", __func__, offset); in sb_gpio_direction_input()
142 return sandbox_gpio_set_direction(dev, offset, 0); in sb_gpio_direction_input()
146 static int sb_gpio_direction_output(struct udevice *dev, unsigned offset, in sb_gpio_direction_output() argument
151 debug("%s: offset:%u, value = %d\n", __func__, offset, value); in sb_gpio_direction_output()
153 ret = sandbox_gpio_set_direction(dev, offset, 1); in sb_gpio_direction_output()
156 ret = set_gpio_flag(dev, offset, GPIOD_IS_OUT_ACTIVE | in sb_gpio_direction_output()
165 static int sb_gpio_get_value(struct udevice *dev, unsigned offset) in sb_gpio_get_value() argument
167 debug("%s: offset:%u\n", __func__, offset); in sb_gpio_get_value()
169 return sandbox_gpio_get_value(dev, offset); in sb_gpio_get_value()
173 static int sb_gpio_set_value(struct udevice *dev, unsigned offset, int value) in sb_gpio_set_value() argument
177 debug("%s: offset:%u, value = %d\n", __func__, offset, value); in sb_gpio_set_value()
179 if (!sandbox_gpio_get_direction(dev, offset)) { in sb_gpio_set_value()
181 offset); in sb_gpio_set_value()
185 ret = set_gpio_flag(dev, offset, GPIOD_IS_OUT_ACTIVE | in sb_gpio_set_value()
193 static int sb_gpio_get_function(struct udevice *dev, unsigned offset) in sb_gpio_get_function() argument
195 if (get_gpio_flag(dev, offset, GPIOD_IS_OUT)) in sb_gpio_get_function()
197 if (get_gpio_flag(dev, offset, GPIOD_IS_IN)) in sb_gpio_get_function()
206 desc->offset = args->args[0]; in sb_gpio_xlate()
225 static int sb_gpio_set_flags(struct udevice *dev, unsigned int offset, in sb_gpio_set_flags() argument
228 debug("%s: offset:%u, flags = %lx\n", __func__, offset, flags); in sb_gpio_set_flags()
229 struct gpio_state *state = get_gpio_state(dev, offset); in sb_gpio_set_flags()
245 static int sb_gpio_get_flags(struct udevice *dev, uint offset, ulong *flagsp) in sb_gpio_get_flags() argument
247 debug("%s: offset:%u\n", __func__, offset); in sb_gpio_get_flags()
248 *flagsp = *get_gpio_flags(dev, offset) & ~GPIOD_SANDBOX_MASK; in sb_gpio_get_flags()
261 gpio->pins[0] = desc->offset; in sb_gpio_get_acpi()
269 gpio->pin0_addr = 0x80012 + desc->offset; in sb_gpio_get_acpi()
275 gpio->irq.pin = desc->offset; in sb_gpio_get_acpi()
283 gpio->pin0_addr = 0xc00dc + desc->offset; in sb_gpio_get_acpi()