diff --git a/drivers/adc/CMakeLists.txt b/drivers/adc/CMakeLists.txt index 5353de86f01..9ecca0b0afe 100644 --- a/drivers/adc/CMakeLists.txt +++ b/drivers/adc/CMakeLists.txt @@ -3,7 +3,6 @@ zephyr_library() zephyr_library_sources_ifdef(CONFIG_ADC_DW adc_dw.c) zephyr_library_sources_ifdef(CONFIG_ADC_MCUX_ADC16 adc_mcux_adc16.c) zephyr_library_sources_ifdef(CONFIG_ADC_SAM_AFEC adc_sam_afec.c) -zephyr_library_sources_ifdef(CONFIG_ADC_TI_ADC108S102 adc_ti_adc108s102.c) zephyr_library_sources_ifdef(CONFIG_ADC_NRFX_ADC adc_nrfx_adc.c) zephyr_library_sources_ifdef(CONFIG_ADC_NRFX_SAADC adc_nrfx_saadc.c) zephyr_library_sources_ifdef(CONFIG_ADC_INTEL_QUARK_D2000 adc_intel_quark_d2000.c) diff --git a/drivers/adc/Kconfig b/drivers/adc/Kconfig index 98de617a19a..0122427cd38 100644 --- a/drivers/adc/Kconfig +++ b/drivers/adc/Kconfig @@ -75,8 +75,6 @@ source "drivers/adc/Kconfig.nrfx" source "drivers/adc/Kconfig.sam_afec" -source "drivers/adc/Kconfig.ti_adc108s102" - source "drivers/adc/Kconfig.intel_quark" endif # ADC diff --git a/drivers/adc/Kconfig.ti_adc108s102 b/drivers/adc/Kconfig.ti_adc108s102 deleted file mode 100644 index d6738096339..00000000000 --- a/drivers/adc/Kconfig.ti_adc108s102 +++ /dev/null @@ -1,36 +0,0 @@ -# Kconfig - ADC configuration options - -# -# Copyright (c) 2015 Intel Corporation -# -# SPDX-License-Identifier: Apache-2.0 -# - -menuconfig ADC_TI_ADC108S102 - bool "TI adc108s102 chip driver" - select SPI - select ADC_0 - help - Enable support for TI's ADC chip adc108s102 driver. - -if ADC_TI_ADC108S102 - -config ADC_TI_ADC108S102_SPI_PORT_NAME - string "Master SPI port name" - default "" - help - Master SPI port name through which adc108s102 chip is accessed. - -config ADC_TI_ADC108S102_SPI_FREQ - int "Master SPI port max frequency" - default 0 - help - Master SPI port frequency used to access adc108s102 chip. - -config ADC_TI_ADC108S102_SPI_SLAVE - int "SPI slave slot" - default 0 - help - adc108s102 chip's SPI slave number on master SPI port. - -endif # ADC_TI_ADC108S102 diff --git a/drivers/adc/adc_ti_adc108s102.c b/drivers/adc/adc_ti_adc108s102.c deleted file mode 100644 index 6d1ad2f44f6..00000000000 --- a/drivers/adc/adc_ti_adc108s102.c +++ /dev/null @@ -1,241 +0,0 @@ -/* adc-ti-adc108s102.c - TI's ADC 108s102 driver implementation */ - -/* - * Copyright (c) 2015 Intel Corporation - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include - -#include -#include -#include -#include - -#include "adc_ti_adc108s102.h" -#define LOG_LEVEL CONFIG_ADC_LOG_LEVEL -#include -LOG_MODULE_REGISTER(adc_ti_adc108s102); - -static inline int _ti_adc108s102_sampling(struct device *dev) -{ - struct ti_adc108s102_data *adc = dev->driver_data; - const struct spi_buf tx_buf = { - .buf = adc->cmd_buffer, - .len = ADC108S102_CMD_BUFFER_SIZE - }; - const struct spi_buf_set tx = { - .buffers = &tx_buf, - .count = 1 - }; - const struct spi_buf rx_buf = { - .buf = adc->sampling_buffer, - .len = ADC108S102_SAMPLING_BUFFER_SIZE - }; - const struct spi_buf_set rx = { - .buffers = &rx_buf, - .count = 1 - }; - - LOG_DBG("Sampling!"); - - return spi_transceive(adc->spi, &adc->spi_cfg, &tx, &rx); -} - -static inline void _ti_adc108s102_handle_result(struct device *dev) -{ - struct ti_adc108s102_data *adc = dev->driver_data; - struct adc_seq_table *seq_table = adc->seq_table; - struct ti_adc108s102_chan *chan; - struct adc_seq_entry *entry; - u32_t s_i, i; - - LOG_DBG("_ti_adc108s102_handle_result()"); - - for (i = 0, s_i = 1; i < seq_table->num_entries; i++, s_i++) { - entry = &seq_table->entries[i]; - chan = &adc->chans[entry->channel_id]; - - if (entry->buffer_length - chan->buf_idx == 0) { - continue; - } - - *((u16_t *)(entry->buffer+chan->buf_idx)) = - ADC108S102_RESULT(adc->sampling_buffer[s_i]); - - chan->buf_idx += 2; - } -} - -static inline s32_t _ti_adc108s102_prepare(struct device *dev) -{ - struct ti_adc108s102_data *adc = dev->driver_data; - struct adc_seq_table *seq_table = adc->seq_table; - struct ti_adc108s102_chan *chan; - s32_t sampling_delay = 0; - u32_t i; - - adc->cmd_buf_len = 0; - adc->sampling_buf_len = 1; /* Counting the dummy byte */ - - for (i = 0; i < seq_table->num_entries; i++) { - struct adc_seq_entry *entry = &seq_table->entries[i]; - - /* No more space in the buffer? */ - chan = &adc->chans[entry->channel_id]; - if (entry->buffer_length - chan->buf_idx == 0) { - continue; - } - - LOG_DBG("Requesting channel %d", entry->channel_id); - adc->cmd_buffer[adc->cmd_buf_len] = - ADC108S102_CHANNEL_CMD(entry->channel_id); - - adc->cmd_buf_len++; - adc->sampling_buf_len++; - - sampling_delay = entry->sampling_delay; - } - - if (adc->cmd_buf_len == 0) { - return ADC108S102_DONE; - } - - /* dummy cmd byte */ - adc->cmd_buffer[adc->cmd_buf_len] = 0; - adc->cmd_buf_len++; - - LOG_DBG("ADC108S102 is prepared..."); - - return sampling_delay; -} - -static void ti_adc108s102_enable(struct device *dev) -{ - ARG_UNUSED(dev); - - /* - * There is nothing to be done. If there is no sampling going on, - * the chip will put itself on power-saving mode (that is because - * SPI will release CS) - */ -} - -static void ti_adc108s102_disable(struct device *dev) -{ - ARG_UNUSED(dev); - - /* Same issue as with ti_adc108s102_enable() */ -} - -static inline int _verify_entries(struct adc_seq_table *seq_table) -{ - struct adc_seq_entry *entry; - u32_t chans_set = 0; - int i; - - if (seq_table->num_entries >= ADC108S102_CMD_BUFFER_SIZE) { - return 0; - } - - for (i = 0; i < seq_table->num_entries; i++) { - entry = &seq_table->entries[i]; - - if (entry->sampling_delay <= 0 || - entry->channel_id >= ADC108S102_CHANNELS) { - return 0; - } - - if (!entry->buffer_length) { - continue; - } - - if (entry->buffer_length & 0x1) { - return 0; - } - - chans_set++; - } - - return chans_set; -} - -static int ti_adc108s102_read(struct device *dev, - struct adc_seq_table *seq_table) -{ - struct ti_adc108s102_data *adc = dev->driver_data; - int ret = 0; - s32_t delay; - - /* Resetting all internal channel data */ - (void)memset(adc->chans, 0, ADC108S102_CHANNELS_SIZE); - - if (_verify_entries(seq_table) == 0) { - return -EINVAL; - } - - adc->seq_table = seq_table; - - /* Sampling */ - while (1) { - delay = _ti_adc108s102_prepare(dev); - if (delay == ADC108S102_DONE) { - break; - } - - /* convert to milliseconds */ - delay = (s32_t)((MSEC_PER_SEC * (u64_t)delay) / - CONFIG_SYS_CLOCK_TICKS_PER_SEC); - - k_sleep(delay); - - ret = _ti_adc108s102_sampling(dev); - if (ret != 0) { - break; - } - - _ti_adc108s102_handle_result(dev); - } - - return ret; -} - -static const struct adc_driver_api ti_adc108s102_api = { - .enable = ti_adc108s102_enable, - .disable = ti_adc108s102_disable, - .read = ti_adc108s102_read, -}; - -static int ti_adc108s102_init(struct device *dev) -{ - struct ti_adc108s102_data *adc = dev->driver_data; - - adc->spi = device_get_binding( - CONFIG_ADC_TI_ADC108S102_SPI_PORT_NAME); - if (!adc->spi) { - return -EINVAL; - } - - adc->spi_cfg.operation = SPI_WORD_SET(16); - adc->spi_cfg.frequency = CONFIG_ADC_TI_ADC108S102_SPI_FREQ; - adc->spi_cfg.slave = CONFIG_ADC_TI_ADC108S102_SPI_SLAVE; - - - LOG_DBG("ADC108s102 initialized"); - - dev->driver_api = &ti_adc108s102_api; - - return 0; -} - -#ifdef CONFIG_ADC_TI_ADC108S102 - -static struct ti_adc108s102_data adc108s102_data; - -DEVICE_INIT(adc108s102, CONFIG_ADC_0_NAME, - ti_adc108s102_init, - &adc108s102_data, NULL, - POST_KERNEL, CONFIG_ADC_INIT_PRIORITY); - -#endif /* CONFIG_ADC_TI_ADC108S102 */