[2/2] iio: chemical: atlas-sensor: add RTD-SM module support
diff mbox series

Message ID 20200419055907.23411-3-matt.ranostay@konsulko.com
State New
Headers show
Series
  • iio: chemical: atlas-sensor: add RTD-SM module support
Related show

Commit Message

Matt Ranostay April 19, 2020, 5:59 a.m. UTC
Atlas Scientific RTD-SM OEM sensor reads temperate using
resistance temperature detector technology.

Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
---
 drivers/iio/chemical/atlas-sensor.c | 32 +++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

Comments

Matt Ranostay April 19, 2020, 6:01 a.m. UTC | #1
*sigh* wrong patch submitted.. ignore this for now.. v2 coming up..

- Matt

On Sat, Apr 18, 2020 at 10:59 PM Matt Ranostay
<matt.ranostay@konsulko.com> wrote:
>
> Atlas Scientific RTD-SM OEM sensor reads temperate using
> resistance temperature detector technology.
>
> Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
> ---
>  drivers/iio/chemical/atlas-sensor.c | 32 +++++++++++++++++++++++++++--
>  1 file changed, 30 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c
> index 82d470561ad3..b58ef9759c08 100644
> --- a/drivers/iio/chemical/atlas-sensor.c
> +++ b/drivers/iio/chemical/atlas-sensor.c
> @@ -68,16 +68,20 @@
>  #define ATLAS_REG_DO_TEMP_DATA         0x12
>  #define ATLAS_REG_DO_DATA              0x22
>
> +#define ATLAS_REG_RTD_DATA             0x0e
> +
>  #define ATLAS_PH_INT_TIME_IN_MS                450
>  #define ATLAS_EC_INT_TIME_IN_MS                650
>  #define ATLAS_ORP_INT_TIME_IN_MS       450
>  #define ATLAS_DO_INT_TIME_IN_MS                450
> +#define ATLAS_RTD_INT_TIME_IN_MS       450
>
>  enum {
>         ATLAS_PH_SM,
>         ATLAS_EC_SM,
>         ATLAS_ORP_SM,
>         ATLAS_DO_SM,
> +       ATLAS_RTD_SM,
>  };
>
>  struct atlas_data {
> @@ -199,13 +203,29 @@ static const struct iio_chan_spec atlas_do_channels[] = {
>         {
>                 .type = IIO_TEMP,
>                 .address = ATLAS_REG_DO_TEMP_DATA,
> -               .info_mask_separate =
> -                       BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> +               .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
>                 .output = 1,
>                 .scan_index = -1
>         },
>  };
>
> +static const struct iio_chan_spec atlas_rtd_channels[] = {
> +       {
> +               .type = IIO_TEMP,
> +               .address = ATLAS_REG_RTD_DATA,
> +               .info_mask_separate =
> +                       BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> +               .scan_index = 0,
> +               .scan_type = {
> +                       .sign = 'u',
> +                       .realbits = 32,
> +                       .storagebits = 32,
> +                       .endianness = IIO_BE,
> +               },
> +       },
> +       IIO_CHAN_SOFT_TIMESTAMP(1),
> +};
> +
>  static int atlas_check_ph_calibration(struct atlas_data *data)
>  {
>         struct device *dev = &data->client->dev;
> @@ -350,6 +370,12 @@ static struct atlas_device atlas_devices[] = {
>                                 .calibration = &atlas_check_do_calibration,
>                                 .delay = ATLAS_DO_INT_TIME_IN_MS,
>         },
> +       [ATLAS_RTD_SM] = {
> +                               .channels = atlas_rtd_channels,
> +                               .num_channels = 2,
> +                               .data_reg = ATLAS_REG_RTD_DATA,
> +                               .delay = ATLAS_RTD_INT_TIME_IN_MS,
> +       },
>  };
>
>  static int atlas_set_powermode(struct atlas_data *data, int on)
> @@ -566,6 +592,7 @@ static const struct i2c_device_id atlas_id[] = {
>         { "atlas-ec-sm", ATLAS_EC_SM},
>         { "atlas-orp-sm", ATLAS_ORP_SM},
>         { "atlas-do-sm", ATLAS_DO_SM},
> +       { "atlas-rtd-sm", ATLAS_RTD_SM},
>         {}
>  };
>  MODULE_DEVICE_TABLE(i2c, atlas_id);
> @@ -575,6 +602,7 @@ static const struct of_device_id atlas_dt_ids[] = {
>         { .compatible = "atlas,ec-sm", .data = (void *)ATLAS_EC_SM, },
>         { .compatible = "atlas,orp-sm", .data = (void *)ATLAS_ORP_SM, },
>         { .compatible = "atlas,do-sm", .data = (void *)ATLAS_DO_SM, },
> +       { .compatible = "atlas,rtd-sm", .data = (void *)ATLAS_RTD_SM, },
>         { }
>  };
>  MODULE_DEVICE_TABLE(of, atlas_dt_ids);
> --
> 2.20.1
>

Patch
diff mbox series

diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c
index 82d470561ad3..b58ef9759c08 100644
--- a/drivers/iio/chemical/atlas-sensor.c
+++ b/drivers/iio/chemical/atlas-sensor.c
@@ -68,16 +68,20 @@ 
 #define ATLAS_REG_DO_TEMP_DATA		0x12
 #define ATLAS_REG_DO_DATA		0x22
 
+#define ATLAS_REG_RTD_DATA		0x0e
+
 #define ATLAS_PH_INT_TIME_IN_MS		450
 #define ATLAS_EC_INT_TIME_IN_MS		650
 #define ATLAS_ORP_INT_TIME_IN_MS	450
 #define ATLAS_DO_INT_TIME_IN_MS		450
+#define ATLAS_RTD_INT_TIME_IN_MS	450
 
 enum {
 	ATLAS_PH_SM,
 	ATLAS_EC_SM,
 	ATLAS_ORP_SM,
 	ATLAS_DO_SM,
+	ATLAS_RTD_SM,
 };
 
 struct atlas_data {
@@ -199,13 +203,29 @@  static const struct iio_chan_spec atlas_do_channels[] = {
 	{
 		.type = IIO_TEMP,
 		.address = ATLAS_REG_DO_TEMP_DATA,
-		.info_mask_separate =
-			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
+		.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
 		.output = 1,
 		.scan_index = -1
 	},
 };
 
+static const struct iio_chan_spec atlas_rtd_channels[] = {
+	{
+		.type = IIO_TEMP,
+		.address = ATLAS_REG_RTD_DATA,
+		.info_mask_separate =
+			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
+		.scan_index = 0,
+		.scan_type = {
+			.sign = 'u',
+			.realbits = 32,
+			.storagebits = 32,
+			.endianness = IIO_BE,
+		},
+	},
+	IIO_CHAN_SOFT_TIMESTAMP(1),
+};
+
 static int atlas_check_ph_calibration(struct atlas_data *data)
 {
 	struct device *dev = &data->client->dev;
@@ -350,6 +370,12 @@  static struct atlas_device atlas_devices[] = {
 				.calibration = &atlas_check_do_calibration,
 				.delay = ATLAS_DO_INT_TIME_IN_MS,
 	},
+	[ATLAS_RTD_SM] = {
+				.channels = atlas_rtd_channels,
+				.num_channels = 2,
+				.data_reg = ATLAS_REG_RTD_DATA,
+				.delay = ATLAS_RTD_INT_TIME_IN_MS,
+	},
 };
 
 static int atlas_set_powermode(struct atlas_data *data, int on)
@@ -566,6 +592,7 @@  static const struct i2c_device_id atlas_id[] = {
 	{ "atlas-ec-sm", ATLAS_EC_SM},
 	{ "atlas-orp-sm", ATLAS_ORP_SM},
 	{ "atlas-do-sm", ATLAS_DO_SM},
+	{ "atlas-rtd-sm", ATLAS_RTD_SM},
 	{}
 };
 MODULE_DEVICE_TABLE(i2c, atlas_id);
@@ -575,6 +602,7 @@  static const struct of_device_id atlas_dt_ids[] = {
 	{ .compatible = "atlas,ec-sm", .data = (void *)ATLAS_EC_SM, },
 	{ .compatible = "atlas,orp-sm", .data = (void *)ATLAS_ORP_SM, },
 	{ .compatible = "atlas,do-sm", .data = (void *)ATLAS_DO_SM, },
+	{ .compatible = "atlas,rtd-sm", .data = (void *)ATLAS_RTD_SM, },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, atlas_dt_ids);