Lines Matching +full:gpio_config +full:-

3  * SPDX-License-Identifier: Apache-2.0
20 #define GPIO_CONFIG 0x80U macro
118 const struct mfd_npm2100_config *config = data->dev->config; in gpio_callback()
120 if (config->host_int_flags & GPIO_INT_LEVEL_ACTIVE) { in gpio_callback()
122 gpio_pin_interrupt_configure_dt(&config->host_int_gpios, GPIO_INT_DISABLE); in gpio_callback()
125 k_work_submit(&data->work); in gpio_callback()
131 const struct mfd_npm2100_config *config = data->dev->config; in work_callback()
136 ret = i2c_write_read_dt(&config->i2c, &buf[0], 1U, &buf[1], EVENTS_SIZE); in work_callback()
138 k_work_submit(&data->work); in work_callback()
144 gpio_fire_callbacks(&data->callbacks, data->dev, BIT(i)); in work_callback()
150 ret = i2c_write_dt(&config->i2c, buf, EVENTS_SIZE + 1U); in work_callback()
152 k_work_submit(&data->work); in work_callback()
157 if (gpio_pin_get_dt(&config->host_int_gpios) != 0) { in work_callback()
158 k_work_submit(&data->work); in work_callback()
163 if (config->host_int_flags & GPIO_INT_LEVEL_ACTIVE) { in work_callback()
164 /* Re-enable irq */ in work_callback()
165 gpio_pin_interrupt_configure_dt(&config->host_int_gpios, config->host_int_flags); in work_callback()
171 const struct mfd_npm2100_config *config = dev->config; in config_pmic_int()
174 if (config->pmic_int_flags & GPIO_ACTIVE_LOW) { in config_pmic_int()
179 int ret = i2c_reg_write_byte_dt(&config->i2c, GPIO_USAGE + config->pmic_int_pin, usage); in config_pmic_int()
186 return i2c_reg_write_byte_dt(&config->i2c, GPIO_CONFIG + config->pmic_int_pin, in config_pmic_int()
192 const struct mfd_npm2100_config *config = dev->config; in config_shphold()
196 if (config->shiphold_longpress != SHPHLD_LONGPRESS_SHIP) { in config_shphold()
197 ret = i2c_reg_write_byte_dt(&config->i2c, RESET_WRITESTICKY, RESET_STICKY_PWRBUT); in config_shphold()
202 ret = i2c_reg_write_byte_dt(&config->i2c, RESET_STROBESTICKY, 1U); in config_shphold()
207 if (config->shiphold_longpress == SHPHLD_LONGPRESS_RESET) { in config_shphold()
208 ret = i2c_reg_write_byte_dt(&config->i2c, RESET_BUTTON, 0U); in config_shphold()
213 ret = i2c_reg_write_byte_dt(&config->i2c, RESET_PIN, 1U); in config_shphold()
220 reg = config->shiphold_hibernate_wakeup ? WAKEUP_HIBERNATE_PIN : WAKEUP_HIBERNATE_NOPIN; in config_shphold()
221 if ((config->shiphold_flags & GPIO_ACTIVE_HIGH) != 0U) { in config_shphold()
225 ret = i2c_reg_write_byte_dt(&config->i2c, SHPHLD_WAKEUP, reg); in config_shphold()
230 if ((config->shiphold_flags & GPIO_PULL_UP) != 0U) { in config_shphold()
232 } else if ((config->shiphold_flags & GPIO_PULL_DOWN) != 0U) { in config_shphold()
237 if (config->shiphold_current != 0U) { in config_shphold()
238 reg |= FIELD_PREP(SHPHLD_CURR_MASK, (config->shiphold_current - 1U)); in config_shphold()
242 return i2c_reg_write_byte_dt(&config->i2c, SHPHLD_SHPHLD, reg); in config_shphold()
247 const struct mfd_npm2100_config *config = dev->config; in mfd_npm2100_init()
248 struct mfd_npm2100_data *mfd_data = dev->data; in mfd_npm2100_init()
251 if (!i2c_is_ready_dt(&config->i2c)) { in mfd_npm2100_init()
252 return -ENODEV; in mfd_npm2100_init()
255 mfd_data->dev = dev; in mfd_npm2100_init()
262 if (config->host_int_gpios.port == NULL) { in mfd_npm2100_init()
272 if (!gpio_is_ready_dt(&config->host_int_gpios)) { in mfd_npm2100_init()
273 return -ENODEV; in mfd_npm2100_init()
276 ret = gpio_pin_configure_dt(&config->host_int_gpios, GPIO_INPUT); in mfd_npm2100_init()
281 gpio_init_callback(&mfd_data->gpio_cb, gpio_callback, BIT(config->host_int_gpios.pin)); in mfd_npm2100_init()
283 ret = gpio_add_callback_dt(&config->host_int_gpios, &mfd_data->gpio_cb); in mfd_npm2100_init()
288 mfd_data->work.handler = work_callback; in mfd_npm2100_init()
290 return gpio_pin_interrupt_configure_dt(&config->host_int_gpios, config->host_int_flags); in mfd_npm2100_init()
296 const struct mfd_npm2100_config *config = dev->config; in mfd_npm2100_set_timer()
304 return -EINVAL; in mfd_npm2100_set_timer()
307 ret = i2c_reg_read_byte_dt(&config->i2c, TIMER_STATUS, &timer_status); in mfd_npm2100_set_timer()
313 return -EBUSY; in mfd_npm2100_set_timer()
318 ret = i2c_write_dt(&config->i2c, buff, sizeof(buff)); in mfd_npm2100_set_timer()
323 return i2c_reg_write_byte_dt(&config->i2c, TIMER_CONFIG, mode); in mfd_npm2100_set_timer()
328 const struct mfd_npm2100_config *config = dev->config; in mfd_npm2100_start_timer()
330 return i2c_reg_write_byte_dt(&config->i2c, TIMER_TASKS_START, 1U); in mfd_npm2100_start_timer()
335 const struct mfd_npm2100_config *config = dev->config; in mfd_npm2100_reset()
337 return i2c_reg_write_byte_dt(&config->i2c, RESET_TASKS_RESET, 1U); in mfd_npm2100_reset()
342 const struct mfd_npm2100_config *config = dev->config; in mfd_npm2100_hibernate()
358 ret = i2c_reg_write_byte_dt(&config->i2c, RESET_WRITESTICKY, 0); in mfd_npm2100_hibernate()
363 ret = i2c_reg_write_byte_dt(&config->i2c, RESET_STROBESTICKY, 1U); in mfd_npm2100_hibernate()
368 return i2c_reg_write_byte_dt(&config->i2c, HIBERNATE_TASKS_HIBER, 1U); in mfd_npm2100_hibernate()
373 const struct mfd_npm2100_config *config = dev->config; in mfd_npm2100_add_callback()
374 struct mfd_npm2100_data *data = dev->data; in mfd_npm2100_add_callback()
378 if ((callback->pin_mask & BIT(i)) != 0U) { in mfd_npm2100_add_callback()
381 &config->i2c, event_reg[i].offset + EVENTS_CLR, event_reg[i].mask); in mfd_npm2100_add_callback()
387 ret = i2c_reg_write_byte_dt(&config->i2c, event_reg[i].offset + INTEN_SET, in mfd_npm2100_add_callback()
395 return gpio_manage_callback(&data->callbacks, callback, true); in mfd_npm2100_add_callback()
400 struct mfd_npm2100_data *data = dev->data; in mfd_npm2100_remove_callback()
402 return gpio_manage_callback(&data->callbacks, callback, false); in mfd_npm2100_remove_callback()