#define BMA180_DRV_NAME "bma180"
#define BMA180_IRQ_NAME "bma180_event"
+enum {
+ BMA180,
+};
+
+struct bma180_part_info {
+ const struct iio_chan_spec *channels;
+ unsigned num_channels;
+ const int *scale_table;
+ unsigned num_scales;
+ const int *bw_table;
+ unsigned num_bw;
+};
+
/* Register set */
#define BMA180_CHIP_ID 0x00 /* Need to distinguish BMA180 from other */
#define BMA180_ACC_X_LSB 0x02 /* First of 6 registers of accel data */
struct bma180_data {
struct i2c_client *client;
struct iio_trigger *trig;
+ const struct bma180_part_info *part_info;
struct mutex mutex;
bool sleep_state;
int scale;
if (data->sleep_state)
return -EBUSY;
- for (i = 0; i < ARRAY_SIZE(bma180_bw_table); ++i) {
- if (bma180_bw_table[i] == val) {
+ for (i = 0; i < data->part_info->num_bw; ++i) {
+ if (data->part_info->bw_table[i] == val) {
ret = bma180_set_bits(data,
BMA180_BW_TCS, BMA180_BW, i);
if (ret) {
if (data->sleep_state)
return -EBUSY;
- for (i = 0; i < ARRAY_SIZE(bma180_scale_table); ++i)
- if (bma180_scale_table[i] == val) {
+ for (i = 0; i < data->part_info->num_scales; ++i)
+ if (data->part_info->scale_table[i] == val) {
ret = bma180_set_bits(data,
BMA180_OFFSET_LSB1, BMA180_RANGE, i);
if (ret) {
IIO_CHAN_SOFT_TIMESTAMP(4),
};
+static const struct bma180_part_info bma180_part_info[] = {
+ [BMA180] = {
+ bma180_channels, ARRAY_SIZE(bma180_channels),
+ bma180_scale_table, ARRAY_SIZE(bma180_scale_table),
+ bma180_bw_table, ARRAY_SIZE(bma180_bw_table),
+ },
+};
+
static irqreturn_t bma180_trigger_handler(int irq, void *p)
{
struct iio_poll_func *pf = p;
data = iio_priv(indio_dev);
i2c_set_clientdata(client, indio_dev);
data->client = client;
+ data->part_info = &bma180_part_info[id->driver_data];
ret = bma180_chip_init(data);
if (ret < 0)
mutex_init(&data->mutex);
indio_dev->dev.parent = &client->dev;
- indio_dev->channels = bma180_channels;
- indio_dev->num_channels = ARRAY_SIZE(bma180_channels);
+ indio_dev->channels = data->part_info->channels;
+ indio_dev->num_channels = data->part_info->num_channels;
indio_dev->name = BMA180_DRV_NAME;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &bma180_info;
#define BMA180_PM_OPS NULL
#endif
-static struct i2c_device_id bma180_id[] = {
- { BMA180_DRV_NAME, 0 },
+static struct i2c_device_id bma180_ids[] = {
+ { BMA180_DRV_NAME, BMA180 },
{ }
};
-MODULE_DEVICE_TABLE(i2c, bma180_id);
+MODULE_DEVICE_TABLE(i2c, bma180_ids);
static struct i2c_driver bma180_driver = {
.driver = {
},
.probe = bma180_probe,
.remove = bma180_remove,
- .id_table = bma180_id,
+ .id_table = bma180_ids,
};
module_i2c_driver(bma180_driver);