Lines Matching refs:offset
27 static u8 *get_gpio_flags(struct udevice *dev, unsigned offset) in get_gpio_flags() argument
32 if (offset >= uc_priv->gpio_count) { in get_gpio_flags()
34 printf("sandbox_gpio: error: invalid gpio %u\n", offset); in get_gpio_flags()
38 return &state[offset].flags; in get_gpio_flags()
41 static int get_gpio_flag(struct udevice *dev, unsigned offset, int flag) in get_gpio_flag() argument
43 return (*get_gpio_flags(dev, offset) & flag) != 0; in get_gpio_flag()
46 static int set_gpio_flag(struct udevice *dev, unsigned offset, int flag, in set_gpio_flag() argument
49 u8 *gpio = get_gpio_flags(dev, offset); in set_gpio_flag()
63 int sandbox_gpio_get_value(struct udevice *dev, unsigned offset) in sandbox_gpio_get_value() argument
65 if (get_gpio_flag(dev, offset, GPIOF_OUTPUT)) in sandbox_gpio_get_value()
66 debug("sandbox_gpio: get_value on output gpio %u\n", offset); in sandbox_gpio_get_value()
67 return get_gpio_flag(dev, offset, GPIOF_HIGH); in sandbox_gpio_get_value()
70 int sandbox_gpio_set_value(struct udevice *dev, unsigned offset, int value) in sandbox_gpio_set_value() argument
72 return set_gpio_flag(dev, offset, GPIOF_HIGH, value); in sandbox_gpio_set_value()
75 int sandbox_gpio_get_open_drain(struct udevice *dev, unsigned offset) in sandbox_gpio_get_open_drain() argument
77 return get_gpio_flag(dev, offset, GPIOF_ODR); in sandbox_gpio_get_open_drain()
80 int sandbox_gpio_set_open_drain(struct udevice *dev, unsigned offset, int value) in sandbox_gpio_set_open_drain() argument
82 return set_gpio_flag(dev, offset, GPIOF_ODR, value); in sandbox_gpio_set_open_drain()
85 int sandbox_gpio_get_direction(struct udevice *dev, unsigned offset) in sandbox_gpio_get_direction() argument
87 return get_gpio_flag(dev, offset, GPIOF_OUTPUT); in sandbox_gpio_get_direction()
90 int sandbox_gpio_set_direction(struct udevice *dev, unsigned offset, int output) in sandbox_gpio_set_direction() argument
92 return set_gpio_flag(dev, offset, GPIOF_OUTPUT, output); in sandbox_gpio_set_direction()
100 static int sb_gpio_direction_input(struct udevice *dev, unsigned offset) in sb_gpio_direction_input() argument
102 debug("%s: offset:%u\n", __func__, offset); in sb_gpio_direction_input()
104 return sandbox_gpio_set_direction(dev, offset, 0); in sb_gpio_direction_input()
108 static int sb_gpio_direction_output(struct udevice *dev, unsigned offset, in sb_gpio_direction_output() argument
111 debug("%s: offset:%u, value = %d\n", __func__, offset, value); in sb_gpio_direction_output()
113 return sandbox_gpio_set_direction(dev, offset, 1) | in sb_gpio_direction_output()
114 sandbox_gpio_set_value(dev, offset, value); in sb_gpio_direction_output()
118 static int sb_gpio_get_value(struct udevice *dev, unsigned offset) in sb_gpio_get_value() argument
120 debug("%s: offset:%u\n", __func__, offset); in sb_gpio_get_value()
122 return sandbox_gpio_get_value(dev, offset); in sb_gpio_get_value()
126 static int sb_gpio_set_value(struct udevice *dev, unsigned offset, int value) in sb_gpio_set_value() argument
128 debug("%s: offset:%u, value = %d\n", __func__, offset, value); in sb_gpio_set_value()
130 if (!sandbox_gpio_get_direction(dev, offset)) { in sb_gpio_set_value()
132 offset); in sb_gpio_set_value()
136 return sandbox_gpio_set_value(dev, offset, value); in sb_gpio_set_value()
140 static int sb_gpio_get_open_drain(struct udevice *dev, unsigned offset) in sb_gpio_get_open_drain() argument
142 debug("%s: offset:%u\n", __func__, offset); in sb_gpio_get_open_drain()
144 return sandbox_gpio_get_open_drain(dev, offset); in sb_gpio_get_open_drain()
148 static int sb_gpio_set_open_drain(struct udevice *dev, unsigned offset, int value) in sb_gpio_set_open_drain() argument
150 debug("%s: offset:%u, value = %d\n", __func__, offset, value); in sb_gpio_set_open_drain()
152 if (!sandbox_gpio_get_direction(dev, offset)) { in sb_gpio_set_open_drain()
154 offset); in sb_gpio_set_open_drain()
158 return sandbox_gpio_set_open_drain(dev, offset, value); in sb_gpio_set_open_drain()
161 static int sb_gpio_get_function(struct udevice *dev, unsigned offset) in sb_gpio_get_function() argument
163 if (get_gpio_flag(dev, offset, GPIOF_OUTPUT)) in sb_gpio_get_function()
171 desc->offset = args->args[0]; in sb_gpio_xlate()