iio: make st_sensors drivers use regmap

This patch is meant to replace the i2c/spi transfer functions with
regmap. SPI framework requires DMA safe buffers so let's add GFP_DMA
flag for memory allocation used by bulk_read functions.

Signed-off-by: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
Denis Ciocca
2019-07-18 15:53:53 -07:00
committed by Jonathan Cameron
parent 1ecd245e0e
commit 062809ef77
19 changed files with 105 additions and 213 deletions
+3 -37
View File
@@ -16,6 +16,7 @@
#include <linux/iio/trigger.h>
#include <linux/bitops.h>
#include <linux/regulator/consumer.h>
#include <linux/regmap.h>
#include <linux/platform_data/st_sensors_pdata.h>
@@ -169,36 +170,6 @@ struct st_sensor_data_ready_irq {
} ig1;
};
/**
* struct st_sensor_transfer_buffer - ST sensor device I/O buffer
* @buf_lock: Mutex to protect rx and tx buffers.
* @tx_buf: Buffer used by SPI transfer function to send data to the sensors.
* This buffer is used to avoid DMA not-aligned issue.
* @rx_buf: Buffer used by SPI transfer to receive data from sensors.
* This buffer is used to avoid DMA not-aligned issue.
*/
struct st_sensor_transfer_buffer {
struct mutex buf_lock;
u8 rx_buf[ST_SENSORS_RX_MAX_LENGTH];
u8 tx_buf[ST_SENSORS_TX_MAX_LENGTH] ____cacheline_aligned;
};
/**
* struct st_sensor_transfer_function - ST sensor device I/O function
* @read_byte: Function used to read one byte.
* @write_byte: Function used to write one byte.
* @read_multiple_byte: Function used to read multiple byte.
*/
struct st_sensor_transfer_function {
int (*read_byte) (struct st_sensor_transfer_buffer *tb,
struct device *dev, u8 reg_addr, u8 *res_byte);
int (*write_byte) (struct st_sensor_transfer_buffer *tb,
struct device *dev, u8 reg_addr, u8 data);
int (*read_multiple_byte) (struct st_sensor_transfer_buffer *tb,
struct device *dev, u8 reg_addr, int len, u8 *data,
bool multiread_bit);
};
/**
* struct st_sensor_settings - ST specific sensor settings
* @wai: Contents of WhoAmI register.
@@ -242,16 +213,14 @@ struct st_sensor_settings {
* @current_fullscale: Maximum range of measure by the sensor.
* @vdd: Pointer to sensor's Vdd power supply
* @vdd_io: Pointer to sensor's Vdd-IO power supply
* @regmap: Pointer to specific sensor regmap configuration.
* @enabled: Status of the sensor (false->off, true->on).
* @multiread_bit: Use or not particular bit for [I2C/SPI] multiread.
* @buffer_data: Data used by buffer part.
* @odr: Output data rate of the sensor [Hz].
* num_data_channels: Number of data channels used in buffer.
* @drdy_int_pin: Redirect DRDY on pin 1 (1) or pin 2 (2).
* @int_pin_open_drain: Set the interrupt/DRDY to open drain.
* @get_irq_data_ready: Function to get the IRQ used for data ready signal.
* @tf: Transfer function structure used by I/O operations.
* @tb: Transfer buffers and mutex used by I/O operations.
* @edge_irq: the IRQ triggers on edges and need special handling.
* @hw_irq_trigger: if we're using the hardware interrupt on the sensor.
* @hw_timestamp: Latest timestamp from the interrupt handler, when in use.
@@ -264,9 +233,9 @@ struct st_sensor_data {
struct st_sensor_fullscale_avl *current_fullscale;
struct regulator *vdd;
struct regulator *vdd_io;
struct regmap *regmap;
bool enabled;
bool multiread_bit;
char *buffer_data;
@@ -278,9 +247,6 @@ struct st_sensor_data {
unsigned int (*get_irq_data_ready) (struct iio_dev *indio_dev);
const struct st_sensor_transfer_function *tf;
struct st_sensor_transfer_buffer tb;
bool edge_irq;
bool hw_irq_trigger;
s64 hw_timestamp;
+2 -2
View File
@@ -14,8 +14,8 @@
#include <linux/iio/common/st_sensors.h>
#include <linux/of.h>
void st_sensors_i2c_configure(struct iio_dev *indio_dev,
struct i2c_client *client, struct st_sensor_data *sdata);
int st_sensors_i2c_configure(struct iio_dev *indio_dev,
struct i2c_client *client);
#ifdef CONFIG_ACPI
int st_sensors_match_acpi_device(struct device *dev);