From 8b2114489661ece66a13c0cc0cf6e5919014eb8d Mon Sep 17 00:00:00 2001 From: Miroslav Ondra Date: Wed, 5 Sep 2018 11:17:29 +0200 Subject: [PATCH] move io definitions from unipi_spi.h to iio.h and iio.c --- modules/unipi/src/unipi_common.h | 12 ----- modules/unipi/src/unipi_iio.c | 29 +++++++++++ modules/unipi/src/unipi_iio.h | 83 ++++++++++++++++++++++++++++++++ modules/unipi/src/unipi_spi.h | 3 +- 4 files changed, 114 insertions(+), 13 deletions(-) diff --git a/modules/unipi/src/unipi_common.h b/modules/unipi/src/unipi_common.h index be2902f..a63b0d1 100644 --- a/modules/unipi/src/unipi_common.h +++ b/modules/unipi/src/unipi_common.h @@ -263,18 +263,6 @@ struct neuronspi_led_driver spinlock_t lock; }; -/* -struct neuronspi_file_data -{ - struct spi_device** spi_device; - struct mutex lock; - struct neuronspi_op_buffer send_buf; - struct neuronspi_op_buffer recv_buf; - u32 message_len; - u8 device_index; - u8 has_first_message; -}; -*/ struct neuronspi_direct_acc { diff --git a/modules/unipi/src/unipi_iio.c b/modules/unipi/src/unipi_iio.c index 2ff053f..033e44a 100644 --- a/modules/unipi/src/unipi_iio.c +++ b/modules/unipi/src/unipi_iio.c @@ -393,6 +393,35 @@ int neuronspi_iio_sec_ao_write_raw(struct iio_dev *indio_dev, struct iio_chan_sp } } +/***************************************************************** + * Probe data and functions + * + *****************************************************************/ +static const struct iio_info neuronspi_stm_ai_info = { + .read_raw = neuronspi_iio_stm_ai_read_raw, + .driver_module = THIS_MODULE, + .attrs = &neuron_stm_ai_group, +}; + +static const struct iio_info neuronspi_stm_ao_info = { + .read_raw = neuronspi_iio_stm_ao_read_raw, + .write_raw = neuronspi_iio_stm_ao_write_raw, + .driver_module = THIS_MODULE, + .attrs = &neuron_stm_ao_group, +}; + +static const struct iio_info neuronspi_sec_ai_info = { + .read_raw = neuronspi_iio_sec_ai_read_raw, + .driver_module = THIS_MODULE, + .attrs = &neuron_sec_ai_group, +}; + +static const struct iio_info neuronspi_sec_ao_info = { + .write_raw = neuronspi_iio_sec_ao_write_raw, + .driver_module = THIS_MODULE, + //.attrs = &neuron_sec_ao_group, +}; + struct iio_dev* neuronspi_stm_ai_probe(int io_count, int neuron_index, struct platform_device *board_device) { diff --git a/modules/unipi/src/unipi_iio.h b/modules/unipi/src/unipi_iio.h index 86c77ae..2b0eb9e 100644 --- a/modules/unipi/src/unipi_iio.h +++ b/modules/unipi/src/unipi_iio.h @@ -21,6 +21,87 @@ #include "unipi_common.h" + +/******************** + * Data Definitions * + ********************/ + +static const struct iio_chan_spec neuronspi_stm_ai_chan_spec[] = { + { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 0, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .output = 0 + }, + { + .type = IIO_CURRENT, + .indexed = 1, + .channel = 1, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .output = 0 + } +}; + +static const struct iio_chan_spec neuronspi_stm_ao_chan_spec[] = { + { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 0, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .output = 1 + }, + { + .type = IIO_CURRENT, + .indexed = 1, + .channel = 1, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .output = 1 + }, + { + .type = IIO_RESISTANCE, + .indexed = 1, + .channel = 2, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .output = 0 + } +}; + +static const struct iio_chan_spec neuronspi_sec_ai_chan_spec[] = { + { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 0, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .output = 0 + }, + { + .type = IIO_CURRENT, + .indexed = 1, + .channel = 1, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .output = 0 + }, + { + .type = IIO_RESISTANCE, + .indexed = 1, + .channel = 2, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .output = 0 + } +}; + +static const struct iio_chan_spec neuronspi_sec_ao_chan_spec[] = { + { + .type = IIO_VOLTAGE, + .indexed = 1, + .channel = 0, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .output = 1 + } +}; + + /************************* * Function Declarations * *************************/ @@ -36,4 +117,6 @@ struct iio_dev* neuronspi_stm_ao_probe(int io_count, int neuron_index, struct pl struct iio_dev** neuronspi_sec_ai_probe(int io_count, int neuron_index, struct platform_device *board_device); struct iio_dev** neuronspi_sec_ao_probe(int io_count, int neuron_index, struct platform_device *board_device); + + #endif /* MODULES_NEURON_SPI_SRC_UNIPI_IIO_H_ */ diff --git a/modules/unipi/src/unipi_spi.h b/modules/unipi/src/unipi_spi.h index 2ed625d..b3f24d2 100644 --- a/modules/unipi/src/unipi_spi.h +++ b/modules/unipi/src/unipi_spi.h @@ -165,6 +165,7 @@ static const struct regmap_config neuronspi_regmap_config_default = .can_multi_write = 1, }; +/* static const struct iio_chan_spec neuronspi_stm_ai_chan_spec[] = { { .type = IIO_VOLTAGE, @@ -264,7 +265,7 @@ static const struct iio_info neuronspi_sec_ao_info = { .driver_module = THIS_MODULE, //.attrs = &neuron_sec_ao_group, }; - +*/ // These defines need to be at the end #define to_neuronspi_uart_data(p,e) ((container_of((p), struct neuronspi_uart_data, e))) #define to_neuronspi_port(p,e) ((container_of((p), struct neuronspi_port, e))) -- 2.34.1