Lines Matching +full:pin +full:- +full:mask
4 * SPDX-License-Identifier: Apache-2.0
39 static int tle9104_gpio_pin_configure(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) in tle9104_gpio_pin_configure() argument
41 const struct tle9104_gpio_config *config = dev->config; in tle9104_gpio_pin_configure()
42 struct tle9104_gpio_data *data = dev->data; in tle9104_gpio_pin_configure()
47 return -EWOULDBLOCK; in tle9104_gpio_pin_configure()
50 if (pin >= TLE9104_GPIO_COUNT) { in tle9104_gpio_pin_configure()
51 LOG_ERR("invalid pin number %i", pin); in tle9104_gpio_pin_configure()
52 return -EINVAL; in tle9104_gpio_pin_configure()
56 LOG_ERR("cannot configure pin as input"); in tle9104_gpio_pin_configure()
57 return -ENOTSUP; in tle9104_gpio_pin_configure()
61 LOG_ERR("pin must be configured as an output"); in tle9104_gpio_pin_configure()
62 return -ENOTSUP; in tle9104_gpio_pin_configure()
66 LOG_ERR("pin must be configured as single ended"); in tle9104_gpio_pin_configure()
67 return -ENOTSUP; in tle9104_gpio_pin_configure()
71 LOG_ERR("pin must be configured as open drain"); in tle9104_gpio_pin_configure()
72 return -ENOTSUP; in tle9104_gpio_pin_configure()
76 LOG_ERR("pin cannot have a pull up configured"); in tle9104_gpio_pin_configure()
77 return -ENOTSUP; in tle9104_gpio_pin_configure()
81 LOG_ERR("pin cannot have a pull down configured"); in tle9104_gpio_pin_configure()
82 return -ENOTSUP; in tle9104_gpio_pin_configure()
85 if (config->parallel_mode_out12 && pin == 1) { in tle9104_gpio_pin_configure()
87 return -EINVAL; in tle9104_gpio_pin_configure()
90 if (config->parallel_mode_out34 && pin == 3) { in tle9104_gpio_pin_configure()
92 return -EINVAL; in tle9104_gpio_pin_configure()
95 k_mutex_lock(&data->lock, K_FOREVER); in tle9104_gpio_pin_configure()
98 WRITE_BIT(data->state, pin, 0); in tle9104_gpio_pin_configure()
100 WRITE_BIT(data->state, pin, 1); in tle9104_gpio_pin_configure()
103 WRITE_BIT(data->configured, pin, 1); in tle9104_gpio_pin_configure()
104 result = tle9104_write_state(config->parent, data->state); in tle9104_gpio_pin_configure()
105 k_mutex_unlock(&data->lock); in tle9104_gpio_pin_configure()
116 return -ENOTSUP; in tle9104_gpio_port_get_raw()
119 static int tle9104_gpio_port_set_masked_raw(const struct device *dev, uint32_t mask, uint32_t value) in tle9104_gpio_port_set_masked_raw() argument
121 const struct tle9104_gpio_config *config = dev->config; in tle9104_gpio_port_set_masked_raw()
122 struct tle9104_gpio_data *data = dev->data; in tle9104_gpio_port_set_masked_raw()
125 if (config->parallel_mode_out12 && (BIT(1) & mask) != 0) { in tle9104_gpio_port_set_masked_raw()
127 return -EINVAL; in tle9104_gpio_port_set_masked_raw()
130 if (config->parallel_mode_out34 && (BIT(3) & mask) != 0) { in tle9104_gpio_port_set_masked_raw()
132 return -EINVAL; in tle9104_gpio_port_set_masked_raw()
137 return -EWOULDBLOCK; in tle9104_gpio_port_set_masked_raw()
140 k_mutex_lock(&data->lock, K_FOREVER); in tle9104_gpio_port_set_masked_raw()
141 data->state = (data->state & ~mask) | (mask & value); in tle9104_gpio_port_set_masked_raw()
142 result = tle9104_write_state(config->parent, data->state); in tle9104_gpio_port_set_masked_raw()
143 k_mutex_unlock(&data->lock); in tle9104_gpio_port_set_masked_raw()
148 static int tle9104_gpio_port_set_bits_raw(const struct device *dev, uint32_t mask) in tle9104_gpio_port_set_bits_raw() argument
150 return tle9104_gpio_port_set_masked_raw(dev, mask, mask); in tle9104_gpio_port_set_bits_raw()
153 static int tle9104_gpio_port_clear_bits_raw(const struct device *dev, uint32_t mask) in tle9104_gpio_port_clear_bits_raw() argument
155 return tle9104_gpio_port_set_masked_raw(dev, mask, 0); in tle9104_gpio_port_clear_bits_raw()
158 static int tle9104_gpio_port_toggle_bits(const struct device *dev, uint32_t mask) in tle9104_gpio_port_toggle_bits() argument
160 const struct tle9104_gpio_config *config = dev->config; in tle9104_gpio_port_toggle_bits()
161 struct tle9104_gpio_data *data = dev->data; in tle9104_gpio_port_toggle_bits()
164 if (config->parallel_mode_out12 && (BIT(1) & mask) != 0) { in tle9104_gpio_port_toggle_bits()
166 return -EINVAL; in tle9104_gpio_port_toggle_bits()
169 if (config->parallel_mode_out34 && (BIT(3) & mask) != 0) { in tle9104_gpio_port_toggle_bits()
171 return -EINVAL; in tle9104_gpio_port_toggle_bits()
176 return -EWOULDBLOCK; in tle9104_gpio_port_toggle_bits()
179 k_mutex_lock(&data->lock, K_FOREVER); in tle9104_gpio_port_toggle_bits()
180 data->state ^= mask; in tle9104_gpio_port_toggle_bits()
181 result = tle9104_write_state(config->parent, data->state); in tle9104_gpio_port_toggle_bits()
182 k_mutex_unlock(&data->lock); in tle9104_gpio_port_toggle_bits()
187 static int tle9104_gpio_pin_interrupt_configure(const struct device *dev, gpio_pin_t pin, in tle9104_gpio_pin_interrupt_configure() argument
191 ARG_UNUSED(pin); in tle9104_gpio_pin_interrupt_configure()
194 return -ENOTSUP; in tle9104_gpio_pin_interrupt_configure()
209 const struct tle9104_gpio_config *config = dev->config; in tle9104_gpio_init()
210 struct tle9104_gpio_data *data = dev->data; in tle9104_gpio_init()
213 LOG_DBG("initialize TLE9104 GPIO instance %s", dev->name); in tle9104_gpio_init()
215 if (!device_is_ready(config->parent)) { in tle9104_gpio_init()
216 LOG_ERR("%s: parent MFD is not ready", dev->name); in tle9104_gpio_init()
217 return -EINVAL; in tle9104_gpio_init()
220 result = k_mutex_init(&data->lock); in tle9104_gpio_init()