Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 205631
b: refs/heads/master
c: 3fd66da
h: refs/heads/master
i:
  205629: 5e4e8be
  205627: 3ea535b
  205623: 842e087
  205615: ab072b9
  205599: e62da30
  205567: 032564f
v: v3
  • Loading branch information
Barry Song authored and Greg Kroah-Hartman committed Jun 18, 2010
1 parent cf79533 commit ac8b4be
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 71 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ee9a691e08360a22a8eaefb1289bc2e9cfd493a0
refs/heads/master: 3fd66da1d529c65488a84f54d8da7bed972fd14f
6 changes: 0 additions & 6 deletions trunk/drivers/staging/iio/imu/adis16400.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,8 @@ struct adis16400_state {
struct mutex buf_lock;
};

int adis16400_spi_read_burst(struct device *dev, u8 *rx);

int adis16400_set_irq(struct device *dev, bool enable);

int adis16400_reset(struct device *dev);

int adis16400_check_status(struct device *dev);

#ifdef CONFIG_IIO_RING_BUFFER
/* At the moment triggers are only used for ring buffer
* filling. This may change!
Expand Down
84 changes: 20 additions & 64 deletions trunk/drivers/staging/iio/imu/adis16400_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

#define DRIVER_NAME "adis16400"

static int adis16400_check_status(struct device *dev);

/* At the moment the spi framework doesn't allow global setting of cs_change.
* It's in the likely to be added comment at the top of spi.h.
* This means that use cannot be made of spi_write etc.
Expand Down Expand Up @@ -161,54 +163,6 @@ static int adis16400_spi_read_reg_16(struct device *dev,
return ret;
}

/**
* adis16400_spi_read_burst() - read all data registers
* @dev: device associated with child of actual device (iio_dev or iio_trig)
* @rx: somewhere to pass back the value read (min size is 24 bytes)
**/
int adis16400_spi_read_burst(struct device *dev, u8 *rx)
{
struct spi_message msg;
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct adis16400_state *st = iio_dev_get_devdata(indio_dev);
u32 old_speed_hz = st->us->max_speed_hz;
int ret;

struct spi_transfer xfers[] = {
{
.tx_buf = st->tx,
.bits_per_word = 8,
.len = 2,
.cs_change = 0,
}, {
.rx_buf = rx,
.bits_per_word = 8,
.len = 24,
.cs_change = 1,
},
};

mutex_lock(&st->buf_lock);
st->tx[0] = ADIS16400_READ_REG(ADIS16400_GLOB_CMD);
st->tx[1] = 0;

spi_message_init(&msg);
spi_message_add_tail(&xfers[0], &msg);
spi_message_add_tail(&xfers[1], &msg);

st->us->max_speed_hz = min(ADIS16400_SPI_BURST, old_speed_hz);
spi_setup(st->us);

ret = spi_sync(st->us, &msg);
if (ret)
dev_err(&st->us->dev, "problem when burst reading");

st->us->max_speed_hz = old_speed_hz;
spi_setup(st->us);
mutex_unlock(&st->buf_lock);
return ret;
}

static ssize_t adis16400_spi_read_signed(struct device *dev,
struct device_attribute *attr,
char *buf,
Expand Down Expand Up @@ -277,7 +231,6 @@ static ssize_t adis16400_read_12bit_signed(struct device *dev,
return ret;
}


static ssize_t adis16400_write_16bit(struct device *dev,
struct device_attribute *attr,
const char *buf,
Expand Down Expand Up @@ -349,6 +302,18 @@ static ssize_t adis16400_write_frequency(struct device *dev,
return ret ? ret : len;
}

static int adis16400_reset(struct device *dev)
{
int ret;
ret = adis16400_spi_write_reg_8(dev,
ADIS16400_GLOB_CMD,
ADIS16400_GLOB_CMD_SW_RESET);
if (ret)
dev_err(dev, "problem resetting device");

return ret;
}

static ssize_t adis16400_write_reset(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
Expand All @@ -364,8 +329,6 @@ static ssize_t adis16400_write_reset(struct device *dev,
return -1;
}



int adis16400_set_irq(struct device *dev, bool enable)
{
int ret;
Expand All @@ -388,18 +351,6 @@ int adis16400_set_irq(struct device *dev, bool enable)
return ret;
}

int adis16400_reset(struct device *dev)
{
int ret;
ret = adis16400_spi_write_reg_8(dev,
ADIS16400_GLOB_CMD,
ADIS16400_GLOB_CMD_SW_RESET);
if (ret)
dev_err(dev, "problem resetting device");

return ret;
}

/* Power down the device */
static int adis16400_stop_device(struct device *dev)
{
Expand Down Expand Up @@ -430,7 +381,7 @@ static int adis16400_self_test(struct device *dev)
return ret;
}

int adis16400_check_status(struct device *dev)
static int adis16400_check_status(struct device *dev)
{
u16 status;
int ret;
Expand Down Expand Up @@ -496,6 +447,11 @@ static int adis16400_initial_setup(struct adis16400_state *st)
}

/* Do self test */
ret = adis16400_self_test(dev);
if (ret) {
dev_err(dev, "self test failure");
goto err_ret;
}

/* Read status register to check the result */
ret = adis16400_check_status(dev);
Expand Down
48 changes: 48 additions & 0 deletions trunk/drivers/staging/iio/imu/adis16400_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,54 @@ static void adis16400_poll_func_th(struct iio_dev *indio_dev)
*/
}

/**
* adis16400_spi_read_burst() - read all data registers
* @dev: device associated with child of actual device (iio_dev or iio_trig)
* @rx: somewhere to pass back the value read (min size is 24 bytes)
**/
static int adis16400_spi_read_burst(struct device *dev, u8 *rx)
{
struct spi_message msg;
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct adis16400_state *st = iio_dev_get_devdata(indio_dev);
u32 old_speed_hz = st->us->max_speed_hz;
int ret;

struct spi_transfer xfers[] = {
{
.tx_buf = st->tx,
.bits_per_word = 8,
.len = 2,
.cs_change = 0,
}, {
.rx_buf = rx,
.bits_per_word = 8,
.len = 24,
.cs_change = 1,
},
};

mutex_lock(&st->buf_lock);
st->tx[0] = ADIS16400_READ_REG(ADIS16400_GLOB_CMD);
st->tx[1] = 0;

spi_message_init(&msg);
spi_message_add_tail(&xfers[0], &msg);
spi_message_add_tail(&xfers[1], &msg);

st->us->max_speed_hz = min(ADIS16400_SPI_BURST, old_speed_hz);
spi_setup(st->us);

ret = spi_sync(st->us, &msg);
if (ret)
dev_err(&st->us->dev, "problem when burst reading");

st->us->max_speed_hz = old_speed_hz;
spi_setup(st->us);
mutex_unlock(&st->buf_lock);
return ret;
}

/* Whilst this makes a lot of calls to iio_sw_ring functions - it is to device
* specific to be rolled into the core.
*/
Expand Down

0 comments on commit ac8b4be

Please sign in to comment.