Lines Matching +full:pin +full:- +full:mask

5  * SPDX-License-Identifier: Apache-2.0
37 static int bd8lb600fs_gpio_pin_configure(const struct device *dev, gpio_pin_t pin, in bd8lb600fs_gpio_pin_configure() argument
40 const struct bd8lb600fs_gpio_config *config = dev->config; in bd8lb600fs_gpio_pin_configure()
41 struct bd8lb600fs_gpio_data *data = dev->data; in bd8lb600fs_gpio_pin_configure()
45 return -EWOULDBLOCK; in bd8lb600fs_gpio_pin_configure()
48 if (pin >= config->gpios_count) { in bd8lb600fs_gpio_pin_configure()
49 LOG_ERR("invalid pin number %i", pin); in bd8lb600fs_gpio_pin_configure()
50 return -EINVAL; in bd8lb600fs_gpio_pin_configure()
54 LOG_ERR("cannot configure pin as input"); in bd8lb600fs_gpio_pin_configure()
55 return -ENOTSUP; in bd8lb600fs_gpio_pin_configure()
59 LOG_ERR("pin must be configured as an output"); in bd8lb600fs_gpio_pin_configure()
60 return -ENOTSUP; in bd8lb600fs_gpio_pin_configure()
64 LOG_ERR("pin must be configured as single ended"); in bd8lb600fs_gpio_pin_configure()
65 return -ENOTSUP; in bd8lb600fs_gpio_pin_configure()
69 LOG_ERR("pin must be configured as open drain"); in bd8lb600fs_gpio_pin_configure()
70 return -ENOTSUP; in bd8lb600fs_gpio_pin_configure()
74 LOG_ERR("pin cannot have a pull up configured"); in bd8lb600fs_gpio_pin_configure()
75 return -ENOTSUP; in bd8lb600fs_gpio_pin_configure()
79 LOG_ERR("pin cannot have a pull down configured"); in bd8lb600fs_gpio_pin_configure()
80 return -ENOTSUP; in bd8lb600fs_gpio_pin_configure()
83 k_mutex_lock(&data->lock, K_FOREVER); in bd8lb600fs_gpio_pin_configure()
86 WRITE_BIT(data->state, pin, 0); in bd8lb600fs_gpio_pin_configure()
88 WRITE_BIT(data->state, pin, 1); in bd8lb600fs_gpio_pin_configure()
91 WRITE_BIT(data->configured, pin, 1); in bd8lb600fs_gpio_pin_configure()
93 int result = mfd_bd8lb600fs_set_outputs(config->parent_dev, data->state); in bd8lb600fs_gpio_pin_configure()
95 k_mutex_unlock(&data->lock); in bd8lb600fs_gpio_pin_configure()
103 return -ENOTSUP; in bd8lb600fs_gpio_port_get_raw()
106 static int bd8lb600fs_gpio_port_set_masked_raw(const struct device *dev, uint32_t mask, in bd8lb600fs_gpio_port_set_masked_raw() argument
109 const struct bd8lb600fs_gpio_config *config = dev->config; in bd8lb600fs_gpio_port_set_masked_raw()
110 struct bd8lb600fs_gpio_data *data = dev->data; in bd8lb600fs_gpio_port_set_masked_raw()
114 return -EWOULDBLOCK; in bd8lb600fs_gpio_port_set_masked_raw()
117 k_mutex_lock(&data->lock, K_FOREVER); in bd8lb600fs_gpio_port_set_masked_raw()
118 data->state = (data->state & ~mask) | (mask & value); in bd8lb600fs_gpio_port_set_masked_raw()
120 int result = mfd_bd8lb600fs_set_outputs(config->parent_dev, data->state); in bd8lb600fs_gpio_port_set_masked_raw()
122 k_mutex_unlock(&data->lock); in bd8lb600fs_gpio_port_set_masked_raw()
127 static int bd8lb600fs_gpio_port_set_bits_raw(const struct device *dev, uint32_t mask) in bd8lb600fs_gpio_port_set_bits_raw() argument
129 return bd8lb600fs_gpio_port_set_masked_raw(dev, mask, mask); in bd8lb600fs_gpio_port_set_bits_raw()
132 static int bd8lb600fs_gpio_port_clear_bits_raw(const struct device *dev, uint32_t mask) in bd8lb600fs_gpio_port_clear_bits_raw() argument
134 return bd8lb600fs_gpio_port_set_masked_raw(dev, mask, 0); in bd8lb600fs_gpio_port_clear_bits_raw()
137 static int bd8lb600fs_gpio_port_toggle_bits(const struct device *dev, uint32_t mask) in bd8lb600fs_gpio_port_toggle_bits() argument
139 const struct bd8lb600fs_gpio_config *config = dev->config; in bd8lb600fs_gpio_port_toggle_bits()
140 struct bd8lb600fs_gpio_data *data = dev->data; in bd8lb600fs_gpio_port_toggle_bits()
144 return -EWOULDBLOCK; in bd8lb600fs_gpio_port_toggle_bits()
147 k_mutex_lock(&data->lock, K_FOREVER); in bd8lb600fs_gpio_port_toggle_bits()
148 data->state ^= mask; in bd8lb600fs_gpio_port_toggle_bits()
150 int result = mfd_bd8lb600fs_set_outputs(config->parent_dev, data->state); in bd8lb600fs_gpio_port_toggle_bits()
152 k_mutex_unlock(&data->lock); in bd8lb600fs_gpio_port_toggle_bits()
168 const struct bd8lb600fs_gpio_config *config = dev->config; in bd8lb600fs_gpio_init()
169 struct bd8lb600fs_gpio_data *data = dev->data; in bd8lb600fs_gpio_init()
171 if (!device_is_ready(config->parent_dev)) { in bd8lb600fs_gpio_init()
173 return -ENODEV; in bd8lb600fs_gpio_init()
176 int result = k_mutex_init(&data->lock); in bd8lb600fs_gpio_init()