#include "../common/ms_sensors/ms_sensors_i2c.h"
 
+struct ms_tp_data {
+       const char *name;
+       const struct ms_tp_hw_data *hw;
+};
+
 static const int ms5637_samp_freq[6] = { 960, 480, 240, 120, 60, 30 };
 /* String copy of the above const for readability purpose */
 static const char ms5637_show_samp_freq[] = "960 480 240 120 60 30";
 static int ms5637_probe(struct i2c_client *client,
                        const struct i2c_device_id *id)
 {
+       const struct ms_tp_data *data;
        struct ms_tp_dev *dev_data;
        struct iio_dev *indio_dev;
        int ret;
                return -EOPNOTSUPP;
        }
 
+       if (id)
+               data = (const struct ms_tp_data *)id->driver_data;
+       else
+               data = device_get_match_data(&client->dev);
+       if (!data)
+               return -EINVAL;
+
        indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*dev_data));
        if (!indio_dev)
                return -ENOMEM;
 
        dev_data = iio_priv(indio_dev);
        dev_data->client = client;
-       dev_data->res_index = 5;
+       dev_data->res_index = data->hw->max_res_index;
+       dev_data->hw = data->hw;
        mutex_init(&dev_data->lock);
 
        indio_dev->info = &ms5637_info;
-       indio_dev->name = id->name;
+       indio_dev->name = data->name;
        indio_dev->modes = INDIO_DIRECT_MODE;
        indio_dev->channels = ms5637_channels;
        indio_dev->num_channels = ARRAY_SIZE(ms5637_channels);
        return devm_iio_device_register(&client->dev, indio_dev);
 }
 
+static const struct ms_tp_hw_data ms5637_hw_data  = {
+       .prom_len = 7,
+       .max_res_index = 5
+};
+
+static const struct ms_tp_data ms5637_data = { .name = "ms5637", .hw = &ms5637_hw_data };
+
+static const struct ms_tp_data ms5805_data = { .name = "ms5805", .hw = &ms5637_hw_data };
+
+static const struct ms_tp_data ms5837_data = { .name = "ms5837", .hw = &ms5637_hw_data };
+
+static const struct ms_tp_data ms8607_data = {
+       .name = "ms8607-temppressure",
+       .hw = &ms5637_hw_data,
+};
+
 static const struct i2c_device_id ms5637_id[] = {
-       {"ms5637", 0},
-       {"ms5805", 0},
-       {"ms5837", 0},
-       {"ms8607-temppressure", 0},
+       {"ms5637", (kernel_ulong_t)&ms5637_data },
+       {"ms5805", (kernel_ulong_t)&ms5805_data },
+       {"ms5837", (kernel_ulong_t)&ms5837_data },
+       {"ms8607-temppressure", (kernel_ulong_t)&ms8607_data },
        {}
 };
 MODULE_DEVICE_TABLE(i2c, ms5637_id);
 
 static const struct of_device_id ms5637_of_match[] = {
-       { .compatible = "meas,ms5637", },
-       { .compatible = "meas,ms5805", },
-       { .compatible = "meas,ms5837", },
-       { .compatible = "meas,ms8607-temppressure", },
+       { .compatible = "meas,ms5637", .data = &ms5637_data },
+       { .compatible = "meas,ms5805", .data = &ms5805_data },
+       { .compatible = "meas,ms5837", .data = &ms5837_data },
+       { .compatible = "meas,ms8607-temppressure", .data = &ms8607_data },
        { },
 };
 MODULE_DEVICE_TABLE(of, ms5637_of_match);