Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 1 | /* |
| 2 | * IBM PowerNV platform sensors for temperature/fan/voltage/power |
| 3 | * Copyright (C) 2014 IBM |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. |
| 17 | */ |
| 18 | |
| 19 | #define DRVNAME "ibmpowernv" |
| 20 | #define pr_fmt(fmt) DRVNAME ": " fmt |
| 21 | |
| 22 | #include <linux/init.h> |
| 23 | #include <linux/module.h> |
| 24 | #include <linux/kernel.h> |
| 25 | #include <linux/hwmon.h> |
| 26 | #include <linux/hwmon-sysfs.h> |
| 27 | #include <linux/of.h> |
| 28 | #include <linux/slab.h> |
| 29 | |
| 30 | #include <linux/platform_device.h> |
| 31 | #include <asm/opal.h> |
| 32 | #include <linux/err.h> |
Cédric Le Goater | 3df2f59 | 2015-04-08 19:19:50 +0200 | [diff] [blame] | 33 | #include <asm/cputhreads.h> |
Guenter Roeck | 8416915 | 2015-04-08 21:02:47 -0700 | [diff] [blame] | 34 | #include <asm/smp.h> |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 35 | |
| 36 | #define MAX_ATTR_LEN 32 |
Cédric Le Goater | 2bcd378 | 2015-04-08 19:19:49 +0200 | [diff] [blame] | 37 | #define MAX_LABEL_LEN 64 |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 38 | |
| 39 | /* Sensor suffix name from DT */ |
| 40 | #define DT_FAULT_ATTR_SUFFIX "faulted" |
| 41 | #define DT_DATA_ATTR_SUFFIX "data" |
| 42 | #define DT_THRESHOLD_ATTR_SUFFIX "thrs" |
| 43 | |
| 44 | /* |
| 45 | * Enumerates all the types of sensors in the POWERNV platform and does index |
| 46 | * into 'struct sensor_group' |
| 47 | */ |
| 48 | enum sensors { |
| 49 | FAN, |
Cédric Le Goater | 9612461 | 2015-03-19 18:44:41 +0100 | [diff] [blame] | 50 | TEMP, |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 51 | POWER_SUPPLY, |
| 52 | POWER_INPUT, |
Shilpasri G Bhat | 3a2b3d3 | 2017-06-20 10:38:13 +0530 | [diff] [blame] | 53 | CURRENT, |
Shilpasri G Bhat | 43d2974 | 2018-05-07 15:55:38 +0530 | [diff] [blame] | 54 | ENERGY, |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 55 | MAX_SENSOR_TYPE, |
| 56 | }; |
| 57 | |
Cédric Le Goater | 1468163 | 2015-04-08 19:19:48 +0200 | [diff] [blame] | 58 | #define INVALID_INDEX (-1U) |
| 59 | |
Cédric Le Goater | 3ab5216 | 2017-06-20 10:38:12 +0530 | [diff] [blame] | 60 | /* |
| 61 | * 'compatible' string properties for sensor types as defined in old |
| 62 | * PowerNV firmware (skiboot). These are ordered as 'enum sensors'. |
| 63 | */ |
| 64 | static const char * const legacy_compatibles[] = { |
| 65 | "ibm,opal-sensor-cooling-fan", |
| 66 | "ibm,opal-sensor-amb-temp", |
| 67 | "ibm,opal-sensor-power-supply", |
| 68 | "ibm,opal-sensor-power" |
| 69 | }; |
| 70 | |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 71 | static struct sensor_group { |
Cédric Le Goater | 3ab5216 | 2017-06-20 10:38:12 +0530 | [diff] [blame] | 72 | const char *name; /* matches property 'sensor-type' */ |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 73 | struct attribute_group group; |
| 74 | u32 attr_count; |
Cédric Le Goater | fcaf57b | 2015-03-19 18:44:45 +0100 | [diff] [blame] | 75 | u32 hwmon_index; |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 76 | } sensor_groups[] = { |
Cédric Le Goater | 3ab5216 | 2017-06-20 10:38:12 +0530 | [diff] [blame] | 77 | { "fan" }, |
| 78 | { "temp" }, |
| 79 | { "in" }, |
Shilpasri G Bhat | 3a2b3d3 | 2017-06-20 10:38:13 +0530 | [diff] [blame] | 80 | { "power" }, |
| 81 | { "curr" }, |
Shilpasri G Bhat | 43d2974 | 2018-05-07 15:55:38 +0530 | [diff] [blame] | 82 | { "energy" }, |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | struct sensor_data { |
| 86 | u32 id; /* An opaque id of the firmware for each sensor */ |
Cédric Le Goater | fcaf57b | 2015-03-19 18:44:45 +0100 | [diff] [blame] | 87 | u32 hwmon_index; |
| 88 | u32 opal_index; |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 89 | enum sensors type; |
Cédric Le Goater | 2bcd378 | 2015-04-08 19:19:49 +0200 | [diff] [blame] | 90 | char label[MAX_LABEL_LEN]; |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 91 | char name[MAX_ATTR_LEN]; |
| 92 | struct device_attribute dev_attr; |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 93 | struct sensor_group_data *sgrp_data; |
| 94 | }; |
| 95 | |
| 96 | struct sensor_group_data { |
| 97 | struct mutex mutex; |
| 98 | u32 gid; |
| 99 | bool enable; |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | struct platform_data { |
| 103 | const struct attribute_group *attr_groups[MAX_SENSOR_TYPE + 1]; |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 104 | struct sensor_group_data *sgrp_data; |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 105 | u32 sensors_count; /* Total count of sensors from each group */ |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 106 | u32 nr_sensor_groups; /* Total number of sensor groups */ |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 107 | }; |
| 108 | |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 109 | static ssize_t show_sensor(struct device *dev, struct device_attribute *devattr, |
| 110 | char *buf) |
| 111 | { |
| 112 | struct sensor_data *sdata = container_of(devattr, struct sensor_data, |
| 113 | dev_attr); |
| 114 | ssize_t ret; |
Shilpasri G Bhat | 3c8c049 | 2018-05-07 15:55:37 +0530 | [diff] [blame] | 115 | u64 x; |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 116 | |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 117 | if (sdata->sgrp_data && !sdata->sgrp_data->enable) |
| 118 | return -ENODATA; |
| 119 | |
Shilpasri G Bhat | 3c8c049 | 2018-05-07 15:55:37 +0530 | [diff] [blame] | 120 | ret = opal_get_sensor_data_u64(sdata->id, &x); |
| 121 | |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 122 | if (ret) |
| 123 | return ret; |
| 124 | |
| 125 | /* Convert temperature to milli-degrees */ |
Cédric Le Goater | 9612461 | 2015-03-19 18:44:41 +0100 | [diff] [blame] | 126 | if (sdata->type == TEMP) |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 127 | x *= 1000; |
| 128 | /* Convert power to micro-watts */ |
| 129 | else if (sdata->type == POWER_INPUT) |
| 130 | x *= 1000000; |
| 131 | |
Shilpasri G Bhat | 3c8c049 | 2018-05-07 15:55:37 +0530 | [diff] [blame] | 132 | return sprintf(buf, "%llu\n", x); |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 133 | } |
| 134 | |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 135 | static ssize_t show_enable(struct device *dev, |
| 136 | struct device_attribute *devattr, char *buf) |
| 137 | { |
| 138 | struct sensor_data *sdata = container_of(devattr, struct sensor_data, |
| 139 | dev_attr); |
| 140 | |
| 141 | return sprintf(buf, "%u\n", sdata->sgrp_data->enable); |
| 142 | } |
| 143 | |
| 144 | static ssize_t store_enable(struct device *dev, |
| 145 | struct device_attribute *devattr, |
| 146 | const char *buf, size_t count) |
| 147 | { |
| 148 | struct sensor_data *sdata = container_of(devattr, struct sensor_data, |
| 149 | dev_attr); |
| 150 | struct sensor_group_data *sgrp_data = sdata->sgrp_data; |
| 151 | int ret; |
| 152 | bool data; |
| 153 | |
| 154 | ret = kstrtobool(buf, &data); |
| 155 | if (ret) |
| 156 | return ret; |
| 157 | |
| 158 | ret = mutex_lock_interruptible(&sgrp_data->mutex); |
| 159 | if (ret) |
| 160 | return ret; |
| 161 | |
| 162 | if (data != sgrp_data->enable) { |
| 163 | ret = sensor_group_enable(sgrp_data->gid, data); |
| 164 | if (!ret) |
| 165 | sgrp_data->enable = data; |
| 166 | } |
| 167 | |
| 168 | if (!ret) |
| 169 | ret = count; |
| 170 | |
| 171 | mutex_unlock(&sgrp_data->mutex); |
| 172 | return ret; |
| 173 | } |
| 174 | |
Cédric Le Goater | 2bcd378 | 2015-04-08 19:19:49 +0200 | [diff] [blame] | 175 | static ssize_t show_label(struct device *dev, struct device_attribute *devattr, |
| 176 | char *buf) |
| 177 | { |
| 178 | struct sensor_data *sdata = container_of(devattr, struct sensor_data, |
| 179 | dev_attr); |
| 180 | |
| 181 | return sprintf(buf, "%s\n", sdata->label); |
| 182 | } |
| 183 | |
Geert Uytterhoeven | e3e61f0 | 2018-10-28 18:16:51 +0100 | [diff] [blame] | 184 | static int get_logical_cpu(int hwcpu) |
Cédric Le Goater | 3df2f59 | 2015-04-08 19:19:50 +0200 | [diff] [blame] | 185 | { |
| 186 | int cpu; |
| 187 | |
| 188 | for_each_possible_cpu(cpu) |
| 189 | if (get_hard_smp_processor_id(cpu) == hwcpu) |
| 190 | return cpu; |
| 191 | |
| 192 | return -ENOENT; |
| 193 | } |
| 194 | |
Geert Uytterhoeven | e3e61f0 | 2018-10-28 18:16:51 +0100 | [diff] [blame] | 195 | static void make_sensor_label(struct device_node *np, |
| 196 | struct sensor_data *sdata, const char *label) |
Cédric Le Goater | 2bcd378 | 2015-04-08 19:19:49 +0200 | [diff] [blame] | 197 | { |
Cédric Le Goater | 3df2f59 | 2015-04-08 19:19:50 +0200 | [diff] [blame] | 198 | u32 id; |
Cédric Le Goater | 2bcd378 | 2015-04-08 19:19:49 +0200 | [diff] [blame] | 199 | size_t n; |
| 200 | |
| 201 | n = snprintf(sdata->label, sizeof(sdata->label), "%s", label); |
Cédric Le Goater | 3df2f59 | 2015-04-08 19:19:50 +0200 | [diff] [blame] | 202 | |
| 203 | /* |
| 204 | * Core temp pretty print |
| 205 | */ |
| 206 | if (!of_property_read_u32(np, "ibm,pir", &id)) { |
| 207 | int cpuid = get_logical_cpu(id); |
| 208 | |
| 209 | if (cpuid >= 0) |
| 210 | /* |
| 211 | * The digital thermal sensors are associated |
Michael Neuling | acf3296 | 2016-09-13 15:47:41 +1000 | [diff] [blame] | 212 | * with a core. |
Cédric Le Goater | 3df2f59 | 2015-04-08 19:19:50 +0200 | [diff] [blame] | 213 | */ |
| 214 | n += snprintf(sdata->label + n, |
Michael Neuling | acf3296 | 2016-09-13 15:47:41 +1000 | [diff] [blame] | 215 | sizeof(sdata->label) - n, " %d", |
| 216 | cpuid); |
Cédric Le Goater | 3df2f59 | 2015-04-08 19:19:50 +0200 | [diff] [blame] | 217 | else |
| 218 | n += snprintf(sdata->label + n, |
| 219 | sizeof(sdata->label) - n, " phy%d", id); |
| 220 | } |
| 221 | |
| 222 | /* |
| 223 | * Membuffer pretty print |
| 224 | */ |
| 225 | if (!of_property_read_u32(np, "ibm,chip-id", &id)) |
| 226 | n += snprintf(sdata->label + n, sizeof(sdata->label) - n, |
| 227 | " %d", id & 0xffff); |
Cédric Le Goater | 2bcd378 | 2015-04-08 19:19:49 +0200 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | static int get_sensor_index_attr(const char *name, u32 *index, char *attr) |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 231 | { |
| 232 | char *hash_pos = strchr(name, '#'); |
| 233 | char buf[8] = { 0 }; |
| 234 | char *dash_pos; |
| 235 | u32 copy_len; |
| 236 | int err; |
| 237 | |
| 238 | if (!hash_pos) |
| 239 | return -EINVAL; |
| 240 | |
| 241 | dash_pos = strchr(hash_pos, '-'); |
| 242 | if (!dash_pos) |
| 243 | return -EINVAL; |
| 244 | |
| 245 | copy_len = dash_pos - hash_pos - 1; |
| 246 | if (copy_len >= sizeof(buf)) |
| 247 | return -EINVAL; |
| 248 | |
| 249 | strncpy(buf, hash_pos + 1, copy_len); |
| 250 | |
| 251 | err = kstrtou32(buf, 10, index); |
| 252 | if (err) |
| 253 | return err; |
| 254 | |
| 255 | strncpy(attr, dash_pos + 1, MAX_ATTR_LEN); |
| 256 | |
| 257 | return 0; |
| 258 | } |
| 259 | |
Cédric Le Goater | ccc9ac6 | 2015-03-19 18:44:43 +0100 | [diff] [blame] | 260 | static const char *convert_opal_attr_name(enum sensors type, |
| 261 | const char *opal_attr) |
| 262 | { |
| 263 | const char *attr_name = NULL; |
| 264 | |
| 265 | if (!strcmp(opal_attr, DT_FAULT_ATTR_SUFFIX)) { |
| 266 | attr_name = "fault"; |
| 267 | } else if (!strcmp(opal_attr, DT_DATA_ATTR_SUFFIX)) { |
| 268 | attr_name = "input"; |
| 269 | } else if (!strcmp(opal_attr, DT_THRESHOLD_ATTR_SUFFIX)) { |
| 270 | if (type == TEMP) |
| 271 | attr_name = "max"; |
| 272 | else if (type == FAN) |
| 273 | attr_name = "min"; |
| 274 | } |
| 275 | |
| 276 | return attr_name; |
| 277 | } |
| 278 | |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 279 | /* |
| 280 | * This function translates the DT node name into the 'hwmon' attribute name. |
| 281 | * IBMPOWERNV device node appear like cooling-fan#2-data, amb-temp#1-thrs etc. |
| 282 | * which need to be mapped as fan2_input, temp1_max respectively before |
| 283 | * populating them inside hwmon device class. |
| 284 | */ |
Cédric Le Goater | f9f54f1 | 2015-03-19 18:44:44 +0100 | [diff] [blame] | 285 | static const char *parse_opal_node_name(const char *node_name, |
| 286 | enum sensors type, u32 *index) |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 287 | { |
| 288 | char attr_suffix[MAX_ATTR_LEN]; |
Cédric Le Goater | ccc9ac6 | 2015-03-19 18:44:43 +0100 | [diff] [blame] | 289 | const char *attr_name; |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 290 | int err; |
| 291 | |
Cédric Le Goater | f9f54f1 | 2015-03-19 18:44:44 +0100 | [diff] [blame] | 292 | err = get_sensor_index_attr(node_name, index, attr_suffix); |
| 293 | if (err) |
| 294 | return ERR_PTR(err); |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 295 | |
Cédric Le Goater | ccc9ac6 | 2015-03-19 18:44:43 +0100 | [diff] [blame] | 296 | attr_name = convert_opal_attr_name(type, attr_suffix); |
| 297 | if (!attr_name) |
Cédric Le Goater | f9f54f1 | 2015-03-19 18:44:44 +0100 | [diff] [blame] | 298 | return ERR_PTR(-ENOENT); |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 299 | |
Cédric Le Goater | f9f54f1 | 2015-03-19 18:44:44 +0100 | [diff] [blame] | 300 | return attr_name; |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 301 | } |
| 302 | |
Cédric Le Goater | c4ad472 | 2015-03-19 18:44:42 +0100 | [diff] [blame] | 303 | static int get_sensor_type(struct device_node *np) |
| 304 | { |
| 305 | enum sensors type; |
Cédric Le Goater | 1468163 | 2015-04-08 19:19:48 +0200 | [diff] [blame] | 306 | const char *str; |
Cédric Le Goater | c4ad472 | 2015-03-19 18:44:42 +0100 | [diff] [blame] | 307 | |
Cédric Le Goater | 3ab5216 | 2017-06-20 10:38:12 +0530 | [diff] [blame] | 308 | for (type = 0; type < ARRAY_SIZE(legacy_compatibles); type++) { |
| 309 | if (of_device_is_compatible(np, legacy_compatibles[type])) |
Cédric Le Goater | c4ad472 | 2015-03-19 18:44:42 +0100 | [diff] [blame] | 310 | return type; |
| 311 | } |
Cédric Le Goater | 1468163 | 2015-04-08 19:19:48 +0200 | [diff] [blame] | 312 | |
| 313 | /* |
| 314 | * Let's check if we have a newer device tree |
| 315 | */ |
| 316 | if (!of_device_is_compatible(np, "ibm,opal-sensor")) |
| 317 | return MAX_SENSOR_TYPE; |
| 318 | |
| 319 | if (of_property_read_string(np, "sensor-type", &str)) |
| 320 | return MAX_SENSOR_TYPE; |
| 321 | |
| 322 | for (type = 0; type < MAX_SENSOR_TYPE; type++) |
| 323 | if (!strcmp(str, sensor_groups[type].name)) |
| 324 | return type; |
| 325 | |
Cédric Le Goater | c4ad472 | 2015-03-19 18:44:42 +0100 | [diff] [blame] | 326 | return MAX_SENSOR_TYPE; |
| 327 | } |
| 328 | |
Cédric Le Goater | fcaf57b | 2015-03-19 18:44:45 +0100 | [diff] [blame] | 329 | static u32 get_sensor_hwmon_index(struct sensor_data *sdata, |
| 330 | struct sensor_data *sdata_table, int count) |
| 331 | { |
| 332 | int i; |
| 333 | |
Cédric Le Goater | 1468163 | 2015-04-08 19:19:48 +0200 | [diff] [blame] | 334 | /* |
| 335 | * We don't use the OPAL index on newer device trees |
| 336 | */ |
| 337 | if (sdata->opal_index != INVALID_INDEX) { |
| 338 | for (i = 0; i < count; i++) |
| 339 | if (sdata_table[i].opal_index == sdata->opal_index && |
| 340 | sdata_table[i].type == sdata->type) |
| 341 | return sdata_table[i].hwmon_index; |
| 342 | } |
Cédric Le Goater | fcaf57b | 2015-03-19 18:44:45 +0100 | [diff] [blame] | 343 | return ++sensor_groups[sdata->type].hwmon_index; |
| 344 | } |
| 345 | |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 346 | static int init_sensor_group_data(struct platform_device *pdev, |
| 347 | struct platform_data *pdata) |
| 348 | { |
| 349 | struct sensor_group_data *sgrp_data; |
| 350 | struct device_node *groups, *sgrp; |
| 351 | int count = 0, ret = 0; |
| 352 | enum sensors type; |
| 353 | |
| 354 | groups = of_find_compatible_node(NULL, NULL, "ibm,opal-sensor-group"); |
| 355 | if (!groups) |
| 356 | return ret; |
| 357 | |
| 358 | for_each_child_of_node(groups, sgrp) { |
| 359 | type = get_sensor_type(sgrp); |
| 360 | if (type != MAX_SENSOR_TYPE) |
| 361 | pdata->nr_sensor_groups++; |
| 362 | } |
| 363 | |
| 364 | if (!pdata->nr_sensor_groups) |
| 365 | goto out; |
| 366 | |
| 367 | sgrp_data = devm_kcalloc(&pdev->dev, pdata->nr_sensor_groups, |
| 368 | sizeof(*sgrp_data), GFP_KERNEL); |
| 369 | if (!sgrp_data) { |
| 370 | ret = -ENOMEM; |
| 371 | goto out; |
| 372 | } |
| 373 | |
| 374 | for_each_child_of_node(groups, sgrp) { |
| 375 | u32 gid; |
| 376 | |
| 377 | type = get_sensor_type(sgrp); |
| 378 | if (type == MAX_SENSOR_TYPE) |
| 379 | continue; |
| 380 | |
| 381 | if (of_property_read_u32(sgrp, "sensor-group-id", &gid)) |
| 382 | continue; |
| 383 | |
| 384 | if (of_count_phandle_with_args(sgrp, "sensors", NULL) <= 0) |
| 385 | continue; |
| 386 | |
| 387 | sensor_groups[type].attr_count++; |
| 388 | sgrp_data[count].gid = gid; |
| 389 | mutex_init(&sgrp_data[count].mutex); |
| 390 | sgrp_data[count++].enable = false; |
| 391 | } |
| 392 | |
| 393 | pdata->sgrp_data = sgrp_data; |
| 394 | out: |
| 395 | of_node_put(groups); |
| 396 | return ret; |
| 397 | } |
| 398 | |
| 399 | static struct sensor_group_data *get_sensor_group(struct platform_data *pdata, |
| 400 | struct device_node *node, |
| 401 | enum sensors gtype) |
| 402 | { |
| 403 | struct sensor_group_data *sgrp_data = pdata->sgrp_data; |
| 404 | struct device_node *groups, *sgrp; |
| 405 | |
| 406 | groups = of_find_compatible_node(NULL, NULL, "ibm,opal-sensor-group"); |
| 407 | if (!groups) |
| 408 | return NULL; |
| 409 | |
| 410 | for_each_child_of_node(groups, sgrp) { |
| 411 | struct of_phandle_iterator it; |
| 412 | u32 gid; |
| 413 | int rc, i; |
| 414 | enum sensors type; |
| 415 | |
| 416 | type = get_sensor_type(sgrp); |
| 417 | if (type != gtype) |
| 418 | continue; |
| 419 | |
| 420 | if (of_property_read_u32(sgrp, "sensor-group-id", &gid)) |
| 421 | continue; |
| 422 | |
| 423 | of_for_each_phandle(&it, rc, sgrp, "sensors", NULL, 0) |
| 424 | if (it.phandle == node->phandle) { |
| 425 | of_node_put(it.node); |
| 426 | break; |
| 427 | } |
| 428 | |
| 429 | if (rc) |
| 430 | continue; |
| 431 | |
| 432 | for (i = 0; i < pdata->nr_sensor_groups; i++) |
| 433 | if (gid == sgrp_data[i].gid) { |
| 434 | of_node_put(sgrp); |
| 435 | of_node_put(groups); |
| 436 | return &sgrp_data[i]; |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | of_node_put(groups); |
| 441 | return NULL; |
| 442 | } |
| 443 | |
Neelesh Gupta | 8de303ba | 2014-11-05 16:45:14 +0530 | [diff] [blame] | 444 | static int populate_attr_groups(struct platform_device *pdev) |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 445 | { |
| 446 | struct platform_data *pdata = platform_get_drvdata(pdev); |
| 447 | const struct attribute_group **pgroups = pdata->attr_groups; |
| 448 | struct device_node *opal, *np; |
| 449 | enum sensors type; |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 450 | int ret; |
| 451 | |
| 452 | ret = init_sensor_group_data(pdev, pdata); |
| 453 | if (ret) |
| 454 | return ret; |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 455 | |
| 456 | opal = of_find_node_by_path("/ibm,opal/sensors"); |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 457 | for_each_child_of_node(opal, np) { |
Cédric Le Goater | 2bcd378 | 2015-04-08 19:19:49 +0200 | [diff] [blame] | 458 | const char *label; |
| 459 | |
Cédric Le Goater | c4ad472 | 2015-03-19 18:44:42 +0100 | [diff] [blame] | 460 | type = get_sensor_type(np); |
Cédric Le Goater | 2bcd378 | 2015-04-08 19:19:49 +0200 | [diff] [blame] | 461 | if (type == MAX_SENSOR_TYPE) |
| 462 | continue; |
| 463 | |
| 464 | sensor_groups[type].attr_count++; |
| 465 | |
| 466 | /* |
Shilpasri G Bhat | 996cf5a | 2017-05-29 10:16:01 +0530 | [diff] [blame] | 467 | * add attributes for labels, min and max |
Cédric Le Goater | 2bcd378 | 2015-04-08 19:19:49 +0200 | [diff] [blame] | 468 | */ |
| 469 | if (!of_property_read_string(np, "label", &label)) |
Cédric Le Goater | c4ad472 | 2015-03-19 18:44:42 +0100 | [diff] [blame] | 470 | sensor_groups[type].attr_count++; |
Shilpasri G Bhat | 996cf5a | 2017-05-29 10:16:01 +0530 | [diff] [blame] | 471 | if (of_find_property(np, "sensor-data-min", NULL)) |
| 472 | sensor_groups[type].attr_count++; |
| 473 | if (of_find_property(np, "sensor-data-max", NULL)) |
| 474 | sensor_groups[type].attr_count++; |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 475 | } |
| 476 | |
| 477 | of_node_put(opal); |
| 478 | |
| 479 | for (type = 0; type < MAX_SENSOR_TYPE; type++) { |
Kees Cook | a86854d | 2018-06-12 14:07:58 -0700 | [diff] [blame] | 480 | sensor_groups[type].group.attrs = devm_kcalloc(&pdev->dev, |
| 481 | sensor_groups[type].attr_count + 1, |
| 482 | sizeof(struct attribute *), |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 483 | GFP_KERNEL); |
| 484 | if (!sensor_groups[type].group.attrs) |
| 485 | return -ENOMEM; |
| 486 | |
| 487 | pgroups[type] = &sensor_groups[type].group; |
| 488 | pdata->sensors_count += sensor_groups[type].attr_count; |
| 489 | sensor_groups[type].attr_count = 0; |
| 490 | } |
| 491 | |
| 492 | return 0; |
| 493 | } |
| 494 | |
Cédric Le Goater | 9e4f74b | 2015-04-08 19:19:47 +0200 | [diff] [blame] | 495 | static void create_hwmon_attr(struct sensor_data *sdata, const char *attr_name, |
| 496 | ssize_t (*show)(struct device *dev, |
| 497 | struct device_attribute *attr, |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 498 | char *buf), |
| 499 | ssize_t (*store)(struct device *dev, |
| 500 | struct device_attribute *attr, |
| 501 | const char *buf, size_t count)) |
Cédric Le Goater | 9e4f74b | 2015-04-08 19:19:47 +0200 | [diff] [blame] | 502 | { |
| 503 | snprintf(sdata->name, MAX_ATTR_LEN, "%s%d_%s", |
| 504 | sensor_groups[sdata->type].name, sdata->hwmon_index, |
| 505 | attr_name); |
| 506 | |
| 507 | sysfs_attr_init(&sdata->dev_attr.attr); |
| 508 | sdata->dev_attr.attr.name = sdata->name; |
Cédric Le Goater | 9e4f74b | 2015-04-08 19:19:47 +0200 | [diff] [blame] | 509 | sdata->dev_attr.show = show; |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 510 | if (store) { |
| 511 | sdata->dev_attr.store = store; |
| 512 | sdata->dev_attr.attr.mode = 0664; |
| 513 | } else { |
| 514 | sdata->dev_attr.attr.mode = 0444; |
| 515 | } |
Cédric Le Goater | 9e4f74b | 2015-04-08 19:19:47 +0200 | [diff] [blame] | 516 | } |
| 517 | |
Shilpasri G Bhat | 996cf5a | 2017-05-29 10:16:01 +0530 | [diff] [blame] | 518 | static void populate_sensor(struct sensor_data *sdata, int od, int hd, int sid, |
| 519 | const char *attr_name, enum sensors type, |
| 520 | const struct attribute_group *pgroup, |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 521 | struct sensor_group_data *sgrp_data, |
Shilpasri G Bhat | 996cf5a | 2017-05-29 10:16:01 +0530 | [diff] [blame] | 522 | ssize_t (*show)(struct device *dev, |
| 523 | struct device_attribute *attr, |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 524 | char *buf), |
| 525 | ssize_t (*store)(struct device *dev, |
| 526 | struct device_attribute *attr, |
| 527 | const char *buf, size_t count)) |
Shilpasri G Bhat | 996cf5a | 2017-05-29 10:16:01 +0530 | [diff] [blame] | 528 | { |
| 529 | sdata->id = sid; |
| 530 | sdata->type = type; |
| 531 | sdata->opal_index = od; |
| 532 | sdata->hwmon_index = hd; |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 533 | create_hwmon_attr(sdata, attr_name, show, store); |
Shilpasri G Bhat | 996cf5a | 2017-05-29 10:16:01 +0530 | [diff] [blame] | 534 | pgroup->attrs[sensor_groups[type].attr_count++] = &sdata->dev_attr.attr; |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 535 | sdata->sgrp_data = sgrp_data; |
Shilpasri G Bhat | 996cf5a | 2017-05-29 10:16:01 +0530 | [diff] [blame] | 536 | } |
| 537 | |
| 538 | static char *get_max_attr(enum sensors type) |
| 539 | { |
| 540 | switch (type) { |
| 541 | case POWER_INPUT: |
| 542 | return "input_highest"; |
| 543 | default: |
| 544 | return "highest"; |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | static char *get_min_attr(enum sensors type) |
| 549 | { |
| 550 | switch (type) { |
| 551 | case POWER_INPUT: |
| 552 | return "input_lowest"; |
| 553 | default: |
| 554 | return "lowest"; |
| 555 | } |
| 556 | } |
| 557 | |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 558 | /* |
| 559 | * Iterate through the device tree for each child of 'sensors' node, create |
| 560 | * a sysfs attribute file, the file is named by translating the DT node name |
| 561 | * to the name required by the higher 'hwmon' driver like fan1_input, temp1_max |
| 562 | * etc.. |
| 563 | */ |
Neelesh Gupta | 8de303ba | 2014-11-05 16:45:14 +0530 | [diff] [blame] | 564 | static int create_device_attrs(struct platform_device *pdev) |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 565 | { |
| 566 | struct platform_data *pdata = platform_get_drvdata(pdev); |
| 567 | const struct attribute_group **pgroups = pdata->attr_groups; |
| 568 | struct device_node *opal, *np; |
| 569 | struct sensor_data *sdata; |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 570 | u32 count = 0; |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 571 | u32 group_attr_id[MAX_SENSOR_TYPE] = {0}; |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 572 | |
Kees Cook | a86854d | 2018-06-12 14:07:58 -0700 | [diff] [blame] | 573 | sdata = devm_kcalloc(&pdev->dev, |
| 574 | pdata->sensors_count, sizeof(*sdata), |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 575 | GFP_KERNEL); |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 576 | if (!sdata) |
| 577 | return -ENOMEM; |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 578 | |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 579 | opal = of_find_node_by_path("/ibm,opal/sensors"); |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 580 | for_each_child_of_node(opal, np) { |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 581 | struct sensor_group_data *sgrp_data; |
Cédric Le Goater | f9f54f1 | 2015-03-19 18:44:44 +0100 | [diff] [blame] | 582 | const char *attr_name; |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 583 | u32 opal_index, hw_id; |
| 584 | u32 sensor_id; |
Cédric Le Goater | 2bcd378 | 2015-04-08 19:19:49 +0200 | [diff] [blame] | 585 | const char *label; |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 586 | enum sensors type; |
Cédric Le Goater | f9f54f1 | 2015-03-19 18:44:44 +0100 | [diff] [blame] | 587 | |
Cédric Le Goater | c4ad472 | 2015-03-19 18:44:42 +0100 | [diff] [blame] | 588 | type = get_sensor_type(np); |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 589 | if (type == MAX_SENSOR_TYPE) |
| 590 | continue; |
| 591 | |
Cédric Le Goater | 1468163 | 2015-04-08 19:19:48 +0200 | [diff] [blame] | 592 | /* |
| 593 | * Newer device trees use a "sensor-data" property |
| 594 | * name for input. |
| 595 | */ |
| 596 | if (of_property_read_u32(np, "sensor-id", &sensor_id) && |
| 597 | of_property_read_u32(np, "sensor-data", &sensor_id)) { |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 598 | dev_info(&pdev->dev, |
Rob Herring | 0debe4d | 2018-08-27 20:52:21 -0500 | [diff] [blame] | 599 | "'sensor-id' missing in the node '%pOFn'\n", |
| 600 | np); |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 601 | continue; |
| 602 | } |
| 603 | |
Axel Lin | 18d03f3 | 2014-08-01 12:38:47 +0800 | [diff] [blame] | 604 | sdata[count].id = sensor_id; |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 605 | sdata[count].type = type; |
Cédric Le Goater | f9f54f1 | 2015-03-19 18:44:44 +0100 | [diff] [blame] | 606 | |
Cédric Le Goater | 1468163 | 2015-04-08 19:19:48 +0200 | [diff] [blame] | 607 | /* |
| 608 | * If we can not parse the node name, it means we are |
| 609 | * running on a newer device tree. We can just forget |
| 610 | * about the OPAL index and use a defaut value for the |
| 611 | * hwmon attribute name |
| 612 | */ |
Cédric Le Goater | f9f54f1 | 2015-03-19 18:44:44 +0100 | [diff] [blame] | 613 | attr_name = parse_opal_node_name(np->name, type, &opal_index); |
| 614 | if (IS_ERR(attr_name)) { |
Cédric Le Goater | 1468163 | 2015-04-08 19:19:48 +0200 | [diff] [blame] | 615 | attr_name = "input"; |
| 616 | opal_index = INVALID_INDEX; |
Cédric Le Goater | f9f54f1 | 2015-03-19 18:44:44 +0100 | [diff] [blame] | 617 | } |
| 618 | |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 619 | hw_id = get_sensor_hwmon_index(&sdata[count], sdata, count); |
| 620 | sgrp_data = get_sensor_group(pdata, np, type); |
| 621 | populate_sensor(&sdata[count], opal_index, hw_id, sensor_id, |
| 622 | attr_name, type, pgroups[type], sgrp_data, |
| 623 | show_sensor, NULL); |
| 624 | count++; |
Cédric Le Goater | 2bcd378 | 2015-04-08 19:19:49 +0200 | [diff] [blame] | 625 | |
| 626 | if (!of_property_read_string(np, "label", &label)) { |
| 627 | /* |
| 628 | * For the label attribute, we can reuse the |
| 629 | * "properties" of the previous "input" |
| 630 | * attribute. They are related to the same |
| 631 | * sensor. |
| 632 | */ |
Cédric Le Goater | 2bcd378 | 2015-04-08 19:19:49 +0200 | [diff] [blame] | 633 | |
| 634 | make_sensor_label(np, &sdata[count], label); |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 635 | populate_sensor(&sdata[count], opal_index, hw_id, |
Shilpasri G Bhat | 996cf5a | 2017-05-29 10:16:01 +0530 | [diff] [blame] | 636 | sensor_id, "label", type, pgroups[type], |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 637 | NULL, show_label, NULL); |
Shilpasri G Bhat | 996cf5a | 2017-05-29 10:16:01 +0530 | [diff] [blame] | 638 | count++; |
| 639 | } |
Cédric Le Goater | 2bcd378 | 2015-04-08 19:19:49 +0200 | [diff] [blame] | 640 | |
Shilpasri G Bhat | 996cf5a | 2017-05-29 10:16:01 +0530 | [diff] [blame] | 641 | if (!of_property_read_u32(np, "sensor-data-max", &sensor_id)) { |
| 642 | attr_name = get_max_attr(type); |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 643 | populate_sensor(&sdata[count], opal_index, hw_id, |
Shilpasri G Bhat | 996cf5a | 2017-05-29 10:16:01 +0530 | [diff] [blame] | 644 | sensor_id, attr_name, type, |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 645 | pgroups[type], sgrp_data, show_sensor, |
| 646 | NULL); |
Shilpasri G Bhat | 996cf5a | 2017-05-29 10:16:01 +0530 | [diff] [blame] | 647 | count++; |
| 648 | } |
Cédric Le Goater | 2bcd378 | 2015-04-08 19:19:49 +0200 | [diff] [blame] | 649 | |
Shilpasri G Bhat | 996cf5a | 2017-05-29 10:16:01 +0530 | [diff] [blame] | 650 | if (!of_property_read_u32(np, "sensor-data-min", &sensor_id)) { |
| 651 | attr_name = get_min_attr(type); |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 652 | populate_sensor(&sdata[count], opal_index, hw_id, |
Shilpasri G Bhat | 996cf5a | 2017-05-29 10:16:01 +0530 | [diff] [blame] | 653 | sensor_id, attr_name, type, |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 654 | pgroups[type], sgrp_data, show_sensor, |
| 655 | NULL); |
| 656 | count++; |
| 657 | } |
| 658 | |
| 659 | if (sgrp_data && !sgrp_data->enable) { |
| 660 | sgrp_data->enable = true; |
| 661 | hw_id = ++group_attr_id[type]; |
| 662 | populate_sensor(&sdata[count], opal_index, hw_id, |
| 663 | sgrp_data->gid, "enable", type, |
| 664 | pgroups[type], sgrp_data, show_enable, |
| 665 | store_enable); |
Shilpasri G Bhat | 996cf5a | 2017-05-29 10:16:01 +0530 | [diff] [blame] | 666 | count++; |
Cédric Le Goater | 2bcd378 | 2015-04-08 19:19:49 +0200 | [diff] [blame] | 667 | } |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 668 | } |
| 669 | |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 670 | of_node_put(opal); |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 671 | return 0; |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 672 | } |
| 673 | |
Neelesh Gupta | 8de303ba | 2014-11-05 16:45:14 +0530 | [diff] [blame] | 674 | static int ibmpowernv_probe(struct platform_device *pdev) |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 675 | { |
| 676 | struct platform_data *pdata; |
| 677 | struct device *hwmon_dev; |
| 678 | int err; |
| 679 | |
| 680 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); |
| 681 | if (!pdata) |
| 682 | return -ENOMEM; |
| 683 | |
| 684 | platform_set_drvdata(pdev, pdata); |
| 685 | pdata->sensors_count = 0; |
Shilpasri G Bhat | e0da991 | 2018-07-24 14:43:09 +0530 | [diff] [blame] | 686 | pdata->nr_sensor_groups = 0; |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 687 | err = populate_attr_groups(pdev); |
| 688 | if (err) |
| 689 | return err; |
| 690 | |
| 691 | /* Create sysfs attribute data for each sensor found in the DT */ |
| 692 | err = create_device_attrs(pdev); |
| 693 | if (err) |
| 694 | return err; |
| 695 | |
| 696 | /* Finally, register with hwmon */ |
| 697 | hwmon_dev = devm_hwmon_device_register_with_groups(&pdev->dev, DRVNAME, |
| 698 | pdata, |
| 699 | pdata->attr_groups); |
| 700 | |
| 701 | return PTR_ERR_OR_ZERO(hwmon_dev); |
| 702 | } |
| 703 | |
Neelesh Gupta | 8de303ba | 2014-11-05 16:45:14 +0530 | [diff] [blame] | 704 | static const struct platform_device_id opal_sensor_driver_ids[] = { |
| 705 | { |
| 706 | .name = "opal-sensor", |
| 707 | }, |
| 708 | { } |
| 709 | }; |
| 710 | MODULE_DEVICE_TABLE(platform, opal_sensor_driver_ids); |
| 711 | |
Cédric Le Goater | 0b056b2 | 2015-09-23 14:44:48 +0200 | [diff] [blame] | 712 | static const struct of_device_id opal_sensor_match[] = { |
| 713 | { .compatible = "ibm,opal-sensor" }, |
| 714 | { }, |
| 715 | }; |
| 716 | MODULE_DEVICE_TABLE(of, opal_sensor_match); |
| 717 | |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 718 | static struct platform_driver ibmpowernv_driver = { |
Neelesh Gupta | 8de303ba | 2014-11-05 16:45:14 +0530 | [diff] [blame] | 719 | .probe = ibmpowernv_probe, |
| 720 | .id_table = opal_sensor_driver_ids, |
| 721 | .driver = { |
Neelesh Gupta | 8de303ba | 2014-11-05 16:45:14 +0530 | [diff] [blame] | 722 | .name = DRVNAME, |
Cédric Le Goater | 0b056b2 | 2015-09-23 14:44:48 +0200 | [diff] [blame] | 723 | .of_match_table = opal_sensor_match, |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 724 | }, |
| 725 | }; |
| 726 | |
Axel Lin | 3bdec67 | 2014-11-12 16:36:47 +0800 | [diff] [blame] | 727 | module_platform_driver(ibmpowernv_driver); |
Neelesh Gupta | 24c1aa8 | 2014-07-08 14:38:38 +0530 | [diff] [blame] | 728 | |
| 729 | MODULE_AUTHOR("Neelesh Gupta <neelegup@linux.vnet.ibm.com>"); |
| 730 | MODULE_DESCRIPTION("IBM POWERNV platform sensors"); |
| 731 | MODULE_LICENSE("GPL"); |