/* Function called on init for each RaspberryPi Pico ADC device. It setups all channels to return constant 0 mV and create acquisition thread.  */
static int adc_rpi_init(const struct device *dev)
/* Function called on init for each RaspberryPi Pico ADC device. It setups all channels to return constant 0 mV and create acquisition thread.  */
static int adc_rpi_init(const struct device *dev)
{
	const struct adc_rpi_config *config = dev->config;
	struct adc_rpi_data *data = dev->data;
	int ret;
	ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
	if (ret < 0) {
		return ret;
	}
	ret = clock_control_on(config->clk_dev, config->clk_id);
	if (ret < 0) {
		return ret;
	}
	ret = reset_line_toggle_dt(&config->reset);
	if (ret < 0) {
		return ret;
	}
	config->irq_configure();
	adc_fifo_setup(true, false, 1, true, true);
	adc_set_clkdiv(0.f);
	adc_enable();
	adc_irq_set_enabled(true);
	adc_context_unlock_unconditionally(&data->ctx);
	return 0;
}