X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=drivers%2Fiio%2Flight%2Ftsl2563.c;h=0c6e459c86b1de6450e8de0fa05b3a3f8df57a3b;hb=8175bff5b47eae171a393f5bd67673de50630973;hp=ebb962c5c323a025f9c9e1ef8cfb27f40f2ba8d5;hpb=098e7f1665f1a3503524bdd537499e45ad30e67d;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c index ebb962c..0c6e459 100644 --- a/drivers/iio/light/tsl2563.c +++ b/drivers/iio/light/tsl2563.c @@ -526,6 +526,20 @@ error_ret: return ret; } +static const struct iio_event_spec tsl2563_events[] = { + { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_RISING, + .mask_separate = BIT(IIO_EV_INFO_VALUE) | + BIT(IIO_EV_INFO_ENABLE), + }, { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_FALLING, + .mask_separate = BIT(IIO_EV_INFO_VALUE) | + BIT(IIO_EV_INFO_ENABLE), + }, +}; + static const struct iio_chan_spec tsl2563_channels[] = { { .type = IIO_LIGHT, @@ -538,10 +552,8 @@ static const struct iio_chan_spec tsl2563_channels[] = { .channel2 = IIO_MOD_LIGHT_BOTH, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_CALIBSCALE), - .event_mask = (IIO_EV_BIT(IIO_EV_TYPE_THRESH, - IIO_EV_DIR_RISING) | - IIO_EV_BIT(IIO_EV_TYPE_THRESH, - IIO_EV_DIR_FALLING)), + .event_spec = tsl2563_events, + .num_event_specs = ARRAY_SIZE(tsl2563_events), }, { .type = IIO_INTENSITY, .modified = 1, @@ -552,12 +564,13 @@ static const struct iio_chan_spec tsl2563_channels[] = { }; static int tsl2563_read_thresh(struct iio_dev *indio_dev, - u64 event_code, - int *val) + const struct iio_chan_spec *chan, enum iio_event_type type, + enum iio_event_direction dir, enum iio_event_info info, int *val, + int *val2) { struct tsl2563_chip *chip = iio_priv(indio_dev); - switch (IIO_EVENT_CODE_EXTRACT_DIR(event_code)) { + switch (dir) { case IIO_EV_DIR_RISING: *val = chip->high_thres; break; @@ -568,18 +581,19 @@ static int tsl2563_read_thresh(struct iio_dev *indio_dev, return -EINVAL; } - return 0; + return IIO_VAL_INT; } static int tsl2563_write_thresh(struct iio_dev *indio_dev, - u64 event_code, - int val) + const struct iio_chan_spec *chan, enum iio_event_type type, + enum iio_event_direction dir, enum iio_event_info info, int val, + int val2) { struct tsl2563_chip *chip = iio_priv(indio_dev); int ret; u8 address; - if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_RISING) + if (dir == IIO_EV_DIR_RISING) address = TSL2563_REG_HIGHLOW; else address = TSL2563_REG_LOWLOW; @@ -591,7 +605,7 @@ static int tsl2563_write_thresh(struct iio_dev *indio_dev, ret = i2c_smbus_write_byte_data(chip->client, TSL2563_CMD | (address + 1), (val >> 8) & 0xFF); - if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_RISING) + if (dir == IIO_EV_DIR_RISING) chip->high_thres = val; else chip->low_thres = val; @@ -620,8 +634,8 @@ static irqreturn_t tsl2563_event_handler(int irq, void *private) } static int tsl2563_write_interrupt_config(struct iio_dev *indio_dev, - u64 event_code, - int state) + const struct iio_chan_spec *chan, enum iio_event_type type, + enum iio_event_direction dir, int state) { struct tsl2563_chip *chip = iio_priv(indio_dev); int ret = 0; @@ -662,7 +676,8 @@ out: } static int tsl2563_read_interrupt_config(struct iio_dev *indio_dev, - u64 event_code) + const struct iio_chan_spec *chan, enum iio_event_type type, + enum iio_event_direction dir) { struct tsl2563_chip *chip = iio_priv(indio_dev); int ret; @@ -687,10 +702,10 @@ static const struct iio_info tsl2563_info = { .driver_module = THIS_MODULE, .read_raw = &tsl2563_read_raw, .write_raw = &tsl2563_write_raw, - .read_event_value = &tsl2563_read_thresh, - .write_event_value = &tsl2563_write_thresh, - .read_event_config = &tsl2563_read_interrupt_config, - .write_event_config = &tsl2563_write_interrupt_config, + .read_event_value_new = &tsl2563_read_thresh, + .write_event_value_new = &tsl2563_write_thresh, + .read_event_config_new = &tsl2563_read_interrupt_config, + .write_event_config_new = &tsl2563_write_interrupt_config, }; static int tsl2563_probe(struct i2c_client *client, @@ -699,6 +714,7 @@ static int tsl2563_probe(struct i2c_client *client, struct iio_dev *indio_dev; struct tsl2563_chip *chip; struct tsl2563_platform_data *pdata = client->dev.platform_data; + struct device_node *np = client->dev.of_node; int err = 0; u8 id = 0; @@ -735,6 +751,9 @@ static int tsl2563_probe(struct i2c_client *client, if (pdata) chip->cover_comp_gain = pdata->cover_comp_gain; + else if (np) + of_property_read_u32(np, "amstaos,cover-comp-gain", + &chip->cover_comp_gain); else chip->cover_comp_gain = 1;