Lines Matching full:offset
25 static u8 *get_gpio_flags(struct udevice *dev, unsigned offset) in get_gpio_flags() argument
30 if (offset >= uc_priv->gpio_count) { in get_gpio_flags()
32 printf("sandbox_gpio: error: invalid gpio %u\n", offset); in get_gpio_flags()
36 return &state[offset].flags; in get_gpio_flags()
39 static int get_gpio_flag(struct udevice *dev, unsigned offset, int flag) in get_gpio_flag() argument
41 return (*get_gpio_flags(dev, offset) & flag) != 0; in get_gpio_flag()
44 static int set_gpio_flag(struct udevice *dev, unsigned offset, int flag, in set_gpio_flag() argument
47 u8 *gpio = get_gpio_flags(dev, offset); in set_gpio_flag()
61 int sandbox_gpio_get_value(struct udevice *dev, unsigned offset) in sandbox_gpio_get_value() argument
63 if (get_gpio_flag(dev, offset, GPIOF_OUTPUT)) in sandbox_gpio_get_value()
64 debug("sandbox_gpio: get_value on output gpio %u\n", offset); in sandbox_gpio_get_value()
65 return get_gpio_flag(dev, offset, GPIOF_HIGH); in sandbox_gpio_get_value()
68 int sandbox_gpio_set_value(struct udevice *dev, unsigned offset, int value) in sandbox_gpio_set_value() argument
70 return set_gpio_flag(dev, offset, GPIOF_HIGH, value); in sandbox_gpio_set_value()
73 int sandbox_gpio_get_open_drain(struct udevice *dev, unsigned offset) in sandbox_gpio_get_open_drain() argument
75 return get_gpio_flag(dev, offset, GPIOF_ODR); in sandbox_gpio_get_open_drain()
78 int sandbox_gpio_set_open_drain(struct udevice *dev, unsigned offset, int value) in sandbox_gpio_set_open_drain() argument
80 return set_gpio_flag(dev, offset, GPIOF_ODR, value); in sandbox_gpio_set_open_drain()
83 int sandbox_gpio_get_direction(struct udevice *dev, unsigned offset) in sandbox_gpio_get_direction() argument
85 return get_gpio_flag(dev, offset, GPIOF_OUTPUT); in sandbox_gpio_get_direction()
88 int sandbox_gpio_set_direction(struct udevice *dev, unsigned offset, int output) in sandbox_gpio_set_direction() argument
90 return set_gpio_flag(dev, offset, GPIOF_OUTPUT, output); in sandbox_gpio_set_direction()
97 /* set GPIO port 'offset' as an input */
98 static int sb_gpio_direction_input(struct udevice *dev, unsigned offset) in sb_gpio_direction_input() argument
100 debug("%s: offset:%u\n", __func__, offset); in sb_gpio_direction_input()
102 return sandbox_gpio_set_direction(dev, offset, 0); in sb_gpio_direction_input()
105 /* set GPIO port 'offset' as an output, with polarity 'value' */
106 static int sb_gpio_direction_output(struct udevice *dev, unsigned offset, in sb_gpio_direction_output() argument
109 debug("%s: offset:%u, value = %d\n", __func__, offset, value); in sb_gpio_direction_output()
111 return sandbox_gpio_set_direction(dev, offset, 1) | in sb_gpio_direction_output()
112 sandbox_gpio_set_value(dev, offset, value); in sb_gpio_direction_output()
115 /* read GPIO IN value of port 'offset' */
116 static int sb_gpio_get_value(struct udevice *dev, unsigned offset) in sb_gpio_get_value() argument
118 debug("%s: offset:%u\n", __func__, offset); in sb_gpio_get_value()
120 return sandbox_gpio_get_value(dev, offset); in sb_gpio_get_value()
123 /* write GPIO OUT value to port 'offset' */
124 static int sb_gpio_set_value(struct udevice *dev, unsigned offset, int value) in sb_gpio_set_value() argument
126 debug("%s: offset:%u, value = %d\n", __func__, offset, value); in sb_gpio_set_value()
128 if (!sandbox_gpio_get_direction(dev, offset)) { in sb_gpio_set_value()
130 offset); in sb_gpio_set_value()
134 return sandbox_gpio_set_value(dev, offset, value); in sb_gpio_set_value()
137 /* read GPIO ODR value of port 'offset' */
138 static int sb_gpio_get_open_drain(struct udevice *dev, unsigned offset) in sb_gpio_get_open_drain() argument
140 debug("%s: offset:%u\n", __func__, offset); in sb_gpio_get_open_drain()
142 return sandbox_gpio_get_open_drain(dev, offset); in sb_gpio_get_open_drain()
145 /* write GPIO ODR value to port 'offset' */
146 static int sb_gpio_set_open_drain(struct udevice *dev, unsigned offset, int value) in sb_gpio_set_open_drain() argument
148 debug("%s: offset:%u, value = %d\n", __func__, offset, value); in sb_gpio_set_open_drain()
150 if (!sandbox_gpio_get_direction(dev, offset)) { in sb_gpio_set_open_drain()
152 offset); in sb_gpio_set_open_drain()
156 return sandbox_gpio_set_open_drain(dev, offset, value); in sb_gpio_set_open_drain()
159 static int sb_gpio_get_function(struct udevice *dev, unsigned offset) in sb_gpio_get_function() argument
161 if (get_gpio_flag(dev, offset, GPIOF_OUTPUT)) in sb_gpio_get_function()
169 desc->offset = args->args[0]; in sb_gpio_xlate()