Lines Matching +full:lock +full:- +full:mode
4 * SPDX-License-Identifier: Apache-2.0
34 /* lock GPIO registers access */
35 struct k_sem lock; member
41 const struct gpio_rt1718s_port_config *const config = dev->config; in gpio_rt1718s_pin_config()
42 struct gpio_rt1718s_port_data *const data = dev->data; in gpio_rt1718s_pin_config()
46 /* Don't support simultaneous in/out mode */ in gpio_rt1718s_pin_config()
48 return -ENOTSUP; in gpio_rt1718s_pin_config()
51 /* Don't support "open source" mode */ in gpio_rt1718s_pin_config()
53 return -ENOTSUP; in gpio_rt1718s_pin_config()
58 return -EINVAL; in gpio_rt1718s_pin_config()
64 /* Set pull-high/low input */ in gpio_rt1718s_pin_config()
75 /* Set push-pull or open-drain */ in gpio_rt1718s_pin_config()
86 k_sem_take(&data->lock, K_FOREVER); in gpio_rt1718s_pin_config()
87 ret = rt1718s_reg_write_byte(config->rt1718s_dev, RT1718S_REG_GPIO_CTRL(pin), new_reg); in gpio_rt1718s_pin_config()
88 k_sem_give(&data->lock); in gpio_rt1718s_pin_config()
95 const struct gpio_rt1718s_port_config *const config = dev->config; in gpio_rt1718s_port_get_raw()
99 ret = rt1718s_reg_read_byte(config->rt1718s_dev, RT1718S_REG_RT_ST8, ®); in gpio_rt1718s_port_get_raw()
109 const struct gpio_rt1718s_port_config *const config = dev->config; in gpio_rt1718s_port_set_masked_raw()
110 struct gpio_rt1718s_port_data *const data = dev->data; in gpio_rt1718s_port_set_masked_raw()
114 k_sem_take(&data->lock, K_FOREVER); in gpio_rt1718s_port_set_masked_raw()
118 ret = rt1718s_reg_read_byte(config->rt1718s_dev, RT1718S_REG_GPIO_CTRL(pin), in gpio_rt1718s_port_set_masked_raw()
129 ret = rt1718s_reg_update(config->rt1718s_dev, RT1718S_REG_GPIO_CTRL(pin), in gpio_rt1718s_port_set_masked_raw()
134 k_sem_give(&data->lock); in gpio_rt1718s_port_set_masked_raw()
141 const struct gpio_rt1718s_port_config *const config = dev->config; in gpio_rt1718s_port_set_bits_raw()
142 struct gpio_rt1718s_port_data *const data = dev->data; in gpio_rt1718s_port_set_bits_raw()
146 k_sem_take(&data->lock, K_FOREVER); in gpio_rt1718s_port_set_bits_raw()
150 ret = rt1718s_reg_read_byte(config->rt1718s_dev, RT1718S_REG_GPIO_CTRL(pin), in gpio_rt1718s_port_set_bits_raw()
156 ret = rt1718s_reg_update(config->rt1718s_dev, RT1718S_REG_GPIO_CTRL(pin), in gpio_rt1718s_port_set_bits_raw()
161 k_sem_give(&data->lock); in gpio_rt1718s_port_set_bits_raw()
168 const struct gpio_rt1718s_port_config *const config = dev->config; in gpio_rt1718s_port_clear_bits_raw()
169 struct gpio_rt1718s_port_data *const data = dev->data; in gpio_rt1718s_port_clear_bits_raw()
173 k_sem_take(&data->lock, K_FOREVER); in gpio_rt1718s_port_clear_bits_raw()
177 ret = rt1718s_reg_read_byte(config->rt1718s_dev, RT1718S_REG_GPIO_CTRL(pin), in gpio_rt1718s_port_clear_bits_raw()
183 ret = rt1718s_reg_update(config->rt1718s_dev, RT1718S_REG_GPIO_CTRL(pin), in gpio_rt1718s_port_clear_bits_raw()
188 k_sem_give(&data->lock); in gpio_rt1718s_port_clear_bits_raw()
195 const struct gpio_rt1718s_port_config *const config = dev->config; in gpio_rt1718s_port_toggle_bits()
196 struct gpio_rt1718s_port_data *const data = dev->data; in gpio_rt1718s_port_toggle_bits()
200 k_sem_take(&data->lock, K_FOREVER); in gpio_rt1718s_port_toggle_bits()
204 ret = rt1718s_reg_read_byte(config->rt1718s_dev, RT1718S_REG_GPIO_CTRL(pin), in gpio_rt1718s_port_toggle_bits()
210 ret = rt1718s_reg_update(config->rt1718s_dev, RT1718S_REG_GPIO_CTRL(pin), in gpio_rt1718s_port_toggle_bits()
215 k_sem_give(&data->lock); in gpio_rt1718s_port_toggle_bits()
221 enum gpio_int_mode mode, enum gpio_int_trig trig) in gpio_rt1718s_pin_interrupt_configure() argument
223 const struct gpio_rt1718s_port_config *const config = dev->config; in gpio_rt1718s_pin_interrupt_configure()
224 struct gpio_rt1718s_port_data *const data = dev->data; in gpio_rt1718s_pin_interrupt_configure()
225 struct rt1718s_data *const data_rt1718s = config->rt1718s_dev->data; in gpio_rt1718s_pin_interrupt_configure()
232 if (mode == GPIO_INT_MODE_LEVEL || pin >= RT1718S_GPIO_NUM) { in gpio_rt1718s_pin_interrupt_configure()
233 return -ENOTSUP; in gpio_rt1718s_pin_interrupt_configure()
236 k_sem_take(&data->lock, K_FOREVER); in gpio_rt1718s_pin_interrupt_configure()
237 k_sem_take(&data_rt1718s->lock_tcpci, K_FOREVER); in gpio_rt1718s_pin_interrupt_configure()
239 ret = rt1718s_reg_read_byte(config->rt1718s_dev, RT1718S_REG_RT_MASK8, ®_mask8); in gpio_rt1718s_pin_interrupt_configure()
245 if (mode == GPIO_INT_MODE_DISABLED) { in gpio_rt1718s_pin_interrupt_configure()
247 } else if (mode == GPIO_INT_MODE_EDGE) { in gpio_rt1718s_pin_interrupt_configure()
259 ret = -EINVAL; in gpio_rt1718s_pin_interrupt_configure()
263 ret = rt1718s_reg_burst_read(config->rt1718s_dev, RT1718S_REG_ALERT_MASK, in gpio_rt1718s_pin_interrupt_configure()
272 ret = rt1718s_reg_burst_write(config->rt1718s_dev, RT1718S_REG_ALERT_MASK, in gpio_rt1718s_pin_interrupt_configure()
284 rt1718s_reg_write_byte(config->rt1718s_dev, RT1718S_REG_RT_INT8, reg_int8); in gpio_rt1718s_pin_interrupt_configure()
288 ret = rt1718s_reg_update(config->rt1718s_dev, RT1718S_REG_RT_MASK8, reg_mask8, in gpio_rt1718s_pin_interrupt_configure()
292 k_sem_give(&data_rt1718s->lock_tcpci); in gpio_rt1718s_pin_interrupt_configure()
293 k_sem_give(&data->lock); in gpio_rt1718s_pin_interrupt_configure()
301 struct gpio_rt1718s_port_data *const data = dev->data; in gpio_rt1718s_manage_callback()
303 return gpio_manage_callback(&data->cb_list_gpio, callback, set); in gpio_rt1718s_manage_callback()
308 const struct rt1718s_config *const config = dev->config; in rt1718s_gpio_alert_handler()
309 struct gpio_rt1718s_port_data *const data_port = config->gpio_port_dev->data; in rt1718s_gpio_alert_handler()
312 k_sem_take(&data_port->lock, K_FOREVER); in rt1718s_gpio_alert_handler()
317 k_sem_give(&data_port->lock); in rt1718s_gpio_alert_handler()
326 k_sem_give(&data_port->lock); in rt1718s_gpio_alert_handler()
332 k_sem_give(&data_port->lock); in rt1718s_gpio_alert_handler()
336 gpio_fire_callbacks(&data_port->cb_list_gpio, config->gpio_port_dev, in rt1718s_gpio_alert_handler()
354 const struct gpio_rt1718s_port_config *const config = dev->config; in gpio_rt1718s_port_init()
355 struct gpio_rt1718s_port_data *const data = dev->data; in gpio_rt1718s_port_init()
357 if (!device_is_ready(config->rt1718s_dev)) { in gpio_rt1718s_port_init()
358 LOG_ERR("%s is not ready", config->rt1718s_dev->name); in gpio_rt1718s_port_init()
359 return -ENODEV; in gpio_rt1718s_port_init()
362 k_sem_init(&data->lock, 1, 1); in gpio_rt1718s_port_init()