#include <linux/hwmon.h>
 #include <linux/module.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/scpi_protocol.h>
 #include <linux/slab.h>
 #include <linux/thermal.h>
 
 struct sensor_data {
+       unsigned int scale;
        struct scpi_sensor_info info;
        struct device_attribute dev_attr_input;
        struct device_attribute dev_attr_label;
        const struct attribute_group *groups[2];
 };
 
+static const u32 gxbb_scpi_scale[] = {
+       [TEMPERATURE]   = 1,            /* (celsius)            */
+       [VOLTAGE]       = 1000,         /* (millivolts)         */
+       [CURRENT]       = 1000,         /* (milliamperes)       */
+       [POWER]         = 1000000,      /* (microwatts)         */
+       [ENERGY]        = 1000000,      /* (microjoules)        */
+};
+
+static const u32 scpi_scale[] = {
+       [TEMPERATURE]   = 1000,         /* (millicelsius)       */
+       [VOLTAGE]       = 1000,         /* (millivolts)         */
+       [CURRENT]       = 1000,         /* (milliamperes)       */
+       [POWER]         = 1000000,      /* (microwatts)         */
+       [ENERGY]        = 1000000,      /* (microjoules)        */
+};
+
+static void scpi_scale_reading(u64 *value, struct sensor_data *sensor)
+{
+       if (scpi_scale[sensor->info.class] != sensor->scale) {
+               *value *= scpi_scale[sensor->info.class];
+               do_div(*value, sensor->scale);
+       }
+}
+
 static int scpi_read_temp(void *dev, int *temp)
 {
        struct scpi_thermal_zone *zone = dev;
        if (ret)
                return ret;
 
+       scpi_scale_reading(&value, sensor);
+
        *temp = value;
        return 0;
 }
        if (ret)
                return ret;
 
+       scpi_scale_reading(&value, sensor);
+
        return sprintf(buf, "%llu\n", value);
 }
 
        .get_temp = scpi_read_temp,
 };
 
+static const struct of_device_id scpi_of_match[] = {
+       {.compatible = "arm,scpi-sensors", .data = &scpi_scale},
+       {.compatible = "amlogic,meson-gxbb-scpi-sensors", .data = &gxbb_scpi_scale},
+       {},
+};
+MODULE_DEVICE_TABLE(of, scpi_of_match);
+
 static int scpi_hwmon_probe(struct platform_device *pdev)
 {
        u16 nr_sensors, i;
+       const u32 *scale;
        int num_temp = 0, num_volt = 0, num_current = 0, num_power = 0;
        int num_energy = 0;
        struct scpi_ops *scpi_ops;
        struct device *hwdev, *dev = &pdev->dev;
        struct scpi_sensors *scpi_sensors;
+       const struct of_device_id *of_id;
        int idx, ret;
 
        scpi_ops = get_scpi_ops();
 
        scpi_sensors->scpi_ops = scpi_ops;
 
+       of_id = of_match_device(scpi_of_match, &pdev->dev);
+       if (!of_id) {
+               dev_err(&pdev->dev, "Unable to initialize scpi-hwmon data\n");
+               return -ENODEV;
+       }
+       scale = of_id->data;
+
        for (i = 0, idx = 0; i < nr_sensors; i++) {
                struct sensor_data *sensor = &scpi_sensors->data[idx];
 
                        continue;
                }
 
+               sensor->scale = scale[sensor->info.class];
+
                sensor->dev_attr_input.attr.mode = S_IRUGO;
                sensor->dev_attr_input.show = scpi_show_sensor;
                sensor->dev_attr_input.attr.name = sensor->input;
        return 0;
 }
 
-static const struct of_device_id scpi_of_match[] = {
-       {.compatible = "arm,scpi-sensors"},
-       {},
-};
-MODULE_DEVICE_TABLE(of, scpi_of_match);
-
 static struct platform_driver scpi_hwmon_platdrv = {
        .driver = {
                .name   = "scpi-hwmon",