blob: 297fef8d87de6c9b33df55b19b0118d807c78f24 [file] [log] [blame]
Neelesh Gupta24c1aa82014-07-08 14:38:38 +05301/*
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 Goater3df2f592015-04-08 19:19:50 +020033#include <asm/cputhreads.h>
Guenter Roeck84169152015-04-08 21:02:47 -070034#include <asm/smp.h>
Neelesh Gupta24c1aa82014-07-08 14:38:38 +053035
36#define MAX_ATTR_LEN 32
Cédric Le Goater2bcd3782015-04-08 19:19:49 +020037#define MAX_LABEL_LEN 64
Neelesh Gupta24c1aa82014-07-08 14:38:38 +053038
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 */
48enum sensors {
49 FAN,
Cédric Le Goater96124612015-03-19 18:44:41 +010050 TEMP,
Neelesh Gupta24c1aa82014-07-08 14:38:38 +053051 POWER_SUPPLY,
52 POWER_INPUT,
53 MAX_SENSOR_TYPE,
54};
55
Cédric Le Goater14681632015-04-08 19:19:48 +020056#define INVALID_INDEX (-1U)
57
Cédric Le Goater3ab52162017-06-20 10:38:12 +053058/*
59 * 'compatible' string properties for sensor types as defined in old
60 * PowerNV firmware (skiboot). These are ordered as 'enum sensors'.
61 */
62static const char * const legacy_compatibles[] = {
63 "ibm,opal-sensor-cooling-fan",
64 "ibm,opal-sensor-amb-temp",
65 "ibm,opal-sensor-power-supply",
66 "ibm,opal-sensor-power"
67};
68
Neelesh Gupta24c1aa82014-07-08 14:38:38 +053069static struct sensor_group {
Cédric Le Goater3ab52162017-06-20 10:38:12 +053070 const char *name; /* matches property 'sensor-type' */
Neelesh Gupta24c1aa82014-07-08 14:38:38 +053071 struct attribute_group group;
72 u32 attr_count;
Cédric Le Goaterfcaf57b2015-03-19 18:44:45 +010073 u32 hwmon_index;
Neelesh Gupta24c1aa82014-07-08 14:38:38 +053074} sensor_groups[] = {
Cédric Le Goater3ab52162017-06-20 10:38:12 +053075 { "fan" },
76 { "temp" },
77 { "in" },
78 { "power" }
Neelesh Gupta24c1aa82014-07-08 14:38:38 +053079};
80
81struct sensor_data {
82 u32 id; /* An opaque id of the firmware for each sensor */
Cédric Le Goaterfcaf57b2015-03-19 18:44:45 +010083 u32 hwmon_index;
84 u32 opal_index;
Neelesh Gupta24c1aa82014-07-08 14:38:38 +053085 enum sensors type;
Cédric Le Goater2bcd3782015-04-08 19:19:49 +020086 char label[MAX_LABEL_LEN];
Neelesh Gupta24c1aa82014-07-08 14:38:38 +053087 char name[MAX_ATTR_LEN];
88 struct device_attribute dev_attr;
89};
90
91struct platform_data {
92 const struct attribute_group *attr_groups[MAX_SENSOR_TYPE + 1];
93 u32 sensors_count; /* Total count of sensors from each group */
94};
95
Neelesh Gupta24c1aa82014-07-08 14:38:38 +053096static ssize_t show_sensor(struct device *dev, struct device_attribute *devattr,
97 char *buf)
98{
99 struct sensor_data *sdata = container_of(devattr, struct sensor_data,
100 dev_attr);
101 ssize_t ret;
102 u32 x;
103
104 ret = opal_get_sensor_data(sdata->id, &x);
105 if (ret)
106 return ret;
107
108 /* Convert temperature to milli-degrees */
Cédric Le Goater96124612015-03-19 18:44:41 +0100109 if (sdata->type == TEMP)
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530110 x *= 1000;
111 /* Convert power to micro-watts */
112 else if (sdata->type == POWER_INPUT)
113 x *= 1000000;
114
115 return sprintf(buf, "%u\n", x);
116}
117
Cédric Le Goater2bcd3782015-04-08 19:19:49 +0200118static ssize_t show_label(struct device *dev, struct device_attribute *devattr,
119 char *buf)
120{
121 struct sensor_data *sdata = container_of(devattr, struct sensor_data,
122 dev_attr);
123
124 return sprintf(buf, "%s\n", sdata->label);
125}
126
Cédric Le Goater3df2f592015-04-08 19:19:50 +0200127static int __init get_logical_cpu(int hwcpu)
128{
129 int cpu;
130
131 for_each_possible_cpu(cpu)
132 if (get_hard_smp_processor_id(cpu) == hwcpu)
133 return cpu;
134
135 return -ENOENT;
136}
137
Cédric Le Goater2bcd3782015-04-08 19:19:49 +0200138static void __init make_sensor_label(struct device_node *np,
139 struct sensor_data *sdata,
140 const char *label)
141{
Cédric Le Goater3df2f592015-04-08 19:19:50 +0200142 u32 id;
Cédric Le Goater2bcd3782015-04-08 19:19:49 +0200143 size_t n;
144
145 n = snprintf(sdata->label, sizeof(sdata->label), "%s", label);
Cédric Le Goater3df2f592015-04-08 19:19:50 +0200146
147 /*
148 * Core temp pretty print
149 */
150 if (!of_property_read_u32(np, "ibm,pir", &id)) {
151 int cpuid = get_logical_cpu(id);
152
153 if (cpuid >= 0)
154 /*
155 * The digital thermal sensors are associated
Michael Neulingacf32962016-09-13 15:47:41 +1000156 * with a core.
Cédric Le Goater3df2f592015-04-08 19:19:50 +0200157 */
158 n += snprintf(sdata->label + n,
Michael Neulingacf32962016-09-13 15:47:41 +1000159 sizeof(sdata->label) - n, " %d",
160 cpuid);
Cédric Le Goater3df2f592015-04-08 19:19:50 +0200161 else
162 n += snprintf(sdata->label + n,
163 sizeof(sdata->label) - n, " phy%d", id);
164 }
165
166 /*
167 * Membuffer pretty print
168 */
169 if (!of_property_read_u32(np, "ibm,chip-id", &id))
170 n += snprintf(sdata->label + n, sizeof(sdata->label) - n,
171 " %d", id & 0xffff);
Cédric Le Goater2bcd3782015-04-08 19:19:49 +0200172}
173
174static int get_sensor_index_attr(const char *name, u32 *index, char *attr)
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530175{
176 char *hash_pos = strchr(name, '#');
177 char buf[8] = { 0 };
178 char *dash_pos;
179 u32 copy_len;
180 int err;
181
182 if (!hash_pos)
183 return -EINVAL;
184
185 dash_pos = strchr(hash_pos, '-');
186 if (!dash_pos)
187 return -EINVAL;
188
189 copy_len = dash_pos - hash_pos - 1;
190 if (copy_len >= sizeof(buf))
191 return -EINVAL;
192
193 strncpy(buf, hash_pos + 1, copy_len);
194
195 err = kstrtou32(buf, 10, index);
196 if (err)
197 return err;
198
199 strncpy(attr, dash_pos + 1, MAX_ATTR_LEN);
200
201 return 0;
202}
203
Cédric Le Goaterccc9ac62015-03-19 18:44:43 +0100204static const char *convert_opal_attr_name(enum sensors type,
205 const char *opal_attr)
206{
207 const char *attr_name = NULL;
208
209 if (!strcmp(opal_attr, DT_FAULT_ATTR_SUFFIX)) {
210 attr_name = "fault";
211 } else if (!strcmp(opal_attr, DT_DATA_ATTR_SUFFIX)) {
212 attr_name = "input";
213 } else if (!strcmp(opal_attr, DT_THRESHOLD_ATTR_SUFFIX)) {
214 if (type == TEMP)
215 attr_name = "max";
216 else if (type == FAN)
217 attr_name = "min";
218 }
219
220 return attr_name;
221}
222
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530223/*
224 * This function translates the DT node name into the 'hwmon' attribute name.
225 * IBMPOWERNV device node appear like cooling-fan#2-data, amb-temp#1-thrs etc.
226 * which need to be mapped as fan2_input, temp1_max respectively before
227 * populating them inside hwmon device class.
228 */
Cédric Le Goaterf9f54f12015-03-19 18:44:44 +0100229static const char *parse_opal_node_name(const char *node_name,
230 enum sensors type, u32 *index)
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530231{
232 char attr_suffix[MAX_ATTR_LEN];
Cédric Le Goaterccc9ac62015-03-19 18:44:43 +0100233 const char *attr_name;
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530234 int err;
235
Cédric Le Goaterf9f54f12015-03-19 18:44:44 +0100236 err = get_sensor_index_attr(node_name, index, attr_suffix);
237 if (err)
238 return ERR_PTR(err);
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530239
Cédric Le Goaterccc9ac62015-03-19 18:44:43 +0100240 attr_name = convert_opal_attr_name(type, attr_suffix);
241 if (!attr_name)
Cédric Le Goaterf9f54f12015-03-19 18:44:44 +0100242 return ERR_PTR(-ENOENT);
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530243
Cédric Le Goaterf9f54f12015-03-19 18:44:44 +0100244 return attr_name;
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530245}
246
Cédric Le Goaterc4ad4722015-03-19 18:44:42 +0100247static int get_sensor_type(struct device_node *np)
248{
249 enum sensors type;
Cédric Le Goater14681632015-04-08 19:19:48 +0200250 const char *str;
Cédric Le Goaterc4ad4722015-03-19 18:44:42 +0100251
Cédric Le Goater3ab52162017-06-20 10:38:12 +0530252 for (type = 0; type < ARRAY_SIZE(legacy_compatibles); type++) {
253 if (of_device_is_compatible(np, legacy_compatibles[type]))
Cédric Le Goaterc4ad4722015-03-19 18:44:42 +0100254 return type;
255 }
Cédric Le Goater14681632015-04-08 19:19:48 +0200256
257 /*
258 * Let's check if we have a newer device tree
259 */
260 if (!of_device_is_compatible(np, "ibm,opal-sensor"))
261 return MAX_SENSOR_TYPE;
262
263 if (of_property_read_string(np, "sensor-type", &str))
264 return MAX_SENSOR_TYPE;
265
266 for (type = 0; type < MAX_SENSOR_TYPE; type++)
267 if (!strcmp(str, sensor_groups[type].name))
268 return type;
269
Cédric Le Goaterc4ad4722015-03-19 18:44:42 +0100270 return MAX_SENSOR_TYPE;
271}
272
Cédric Le Goaterfcaf57b2015-03-19 18:44:45 +0100273static u32 get_sensor_hwmon_index(struct sensor_data *sdata,
274 struct sensor_data *sdata_table, int count)
275{
276 int i;
277
Cédric Le Goater14681632015-04-08 19:19:48 +0200278 /*
279 * We don't use the OPAL index on newer device trees
280 */
281 if (sdata->opal_index != INVALID_INDEX) {
282 for (i = 0; i < count; i++)
283 if (sdata_table[i].opal_index == sdata->opal_index &&
284 sdata_table[i].type == sdata->type)
285 return sdata_table[i].hwmon_index;
286 }
Cédric Le Goaterfcaf57b2015-03-19 18:44:45 +0100287 return ++sensor_groups[sdata->type].hwmon_index;
288}
289
Neelesh Gupta8de303ba2014-11-05 16:45:14 +0530290static int populate_attr_groups(struct platform_device *pdev)
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530291{
292 struct platform_data *pdata = platform_get_drvdata(pdev);
293 const struct attribute_group **pgroups = pdata->attr_groups;
294 struct device_node *opal, *np;
295 enum sensors type;
296
297 opal = of_find_node_by_path("/ibm,opal/sensors");
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530298 for_each_child_of_node(opal, np) {
Cédric Le Goater2bcd3782015-04-08 19:19:49 +0200299 const char *label;
300
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530301 if (np->name == NULL)
302 continue;
303
Cédric Le Goaterc4ad4722015-03-19 18:44:42 +0100304 type = get_sensor_type(np);
Cédric Le Goater2bcd3782015-04-08 19:19:49 +0200305 if (type == MAX_SENSOR_TYPE)
306 continue;
307
308 sensor_groups[type].attr_count++;
309
310 /*
Shilpasri G Bhat996cf5a2017-05-29 10:16:01 +0530311 * add attributes for labels, min and max
Cédric Le Goater2bcd3782015-04-08 19:19:49 +0200312 */
313 if (!of_property_read_string(np, "label", &label))
Cédric Le Goaterc4ad4722015-03-19 18:44:42 +0100314 sensor_groups[type].attr_count++;
Shilpasri G Bhat996cf5a2017-05-29 10:16:01 +0530315 if (of_find_property(np, "sensor-data-min", NULL))
316 sensor_groups[type].attr_count++;
317 if (of_find_property(np, "sensor-data-max", NULL))
318 sensor_groups[type].attr_count++;
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530319 }
320
321 of_node_put(opal);
322
323 for (type = 0; type < MAX_SENSOR_TYPE; type++) {
324 sensor_groups[type].group.attrs = devm_kzalloc(&pdev->dev,
325 sizeof(struct attribute *) *
326 (sensor_groups[type].attr_count + 1),
327 GFP_KERNEL);
328 if (!sensor_groups[type].group.attrs)
329 return -ENOMEM;
330
331 pgroups[type] = &sensor_groups[type].group;
332 pdata->sensors_count += sensor_groups[type].attr_count;
333 sensor_groups[type].attr_count = 0;
334 }
335
336 return 0;
337}
338
Cédric Le Goater9e4f74b2015-04-08 19:19:47 +0200339static void create_hwmon_attr(struct sensor_data *sdata, const char *attr_name,
340 ssize_t (*show)(struct device *dev,
341 struct device_attribute *attr,
342 char *buf))
343{
344 snprintf(sdata->name, MAX_ATTR_LEN, "%s%d_%s",
345 sensor_groups[sdata->type].name, sdata->hwmon_index,
346 attr_name);
347
348 sysfs_attr_init(&sdata->dev_attr.attr);
349 sdata->dev_attr.attr.name = sdata->name;
350 sdata->dev_attr.attr.mode = S_IRUGO;
351 sdata->dev_attr.show = show;
352}
353
Shilpasri G Bhat996cf5a2017-05-29 10:16:01 +0530354static void populate_sensor(struct sensor_data *sdata, int od, int hd, int sid,
355 const char *attr_name, enum sensors type,
356 const struct attribute_group *pgroup,
357 ssize_t (*show)(struct device *dev,
358 struct device_attribute *attr,
359 char *buf))
360{
361 sdata->id = sid;
362 sdata->type = type;
363 sdata->opal_index = od;
364 sdata->hwmon_index = hd;
365 create_hwmon_attr(sdata, attr_name, show);
366 pgroup->attrs[sensor_groups[type].attr_count++] = &sdata->dev_attr.attr;
367}
368
369static char *get_max_attr(enum sensors type)
370{
371 switch (type) {
372 case POWER_INPUT:
373 return "input_highest";
374 default:
375 return "highest";
376 }
377}
378
379static char *get_min_attr(enum sensors type)
380{
381 switch (type) {
382 case POWER_INPUT:
383 return "input_lowest";
384 default:
385 return "lowest";
386 }
387}
388
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530389/*
390 * Iterate through the device tree for each child of 'sensors' node, create
391 * a sysfs attribute file, the file is named by translating the DT node name
392 * to the name required by the higher 'hwmon' driver like fan1_input, temp1_max
393 * etc..
394 */
Neelesh Gupta8de303ba2014-11-05 16:45:14 +0530395static int create_device_attrs(struct platform_device *pdev)
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530396{
397 struct platform_data *pdata = platform_get_drvdata(pdev);
398 const struct attribute_group **pgroups = pdata->attr_groups;
399 struct device_node *opal, *np;
400 struct sensor_data *sdata;
Axel Lin18d03f32014-08-01 12:38:47 +0800401 u32 sensor_id;
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530402 enum sensors type;
403 u32 count = 0;
404 int err = 0;
405
406 opal = of_find_node_by_path("/ibm,opal/sensors");
407 sdata = devm_kzalloc(&pdev->dev, pdata->sensors_count * sizeof(*sdata),
408 GFP_KERNEL);
409 if (!sdata) {
410 err = -ENOMEM;
411 goto exit_put_node;
412 }
413
414 for_each_child_of_node(opal, np) {
Cédric Le Goaterf9f54f12015-03-19 18:44:44 +0100415 const char *attr_name;
416 u32 opal_index;
Cédric Le Goater2bcd3782015-04-08 19:19:49 +0200417 const char *label;
Cédric Le Goaterf9f54f12015-03-19 18:44:44 +0100418
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530419 if (np->name == NULL)
420 continue;
421
Cédric Le Goaterc4ad4722015-03-19 18:44:42 +0100422 type = get_sensor_type(np);
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530423 if (type == MAX_SENSOR_TYPE)
424 continue;
425
Cédric Le Goater14681632015-04-08 19:19:48 +0200426 /*
427 * Newer device trees use a "sensor-data" property
428 * name for input.
429 */
430 if (of_property_read_u32(np, "sensor-id", &sensor_id) &&
431 of_property_read_u32(np, "sensor-data", &sensor_id)) {
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530432 dev_info(&pdev->dev,
433 "'sensor-id' missing in the node '%s'\n",
434 np->name);
435 continue;
436 }
437
Axel Lin18d03f32014-08-01 12:38:47 +0800438 sdata[count].id = sensor_id;
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530439 sdata[count].type = type;
Cédric Le Goaterf9f54f12015-03-19 18:44:44 +0100440
Cédric Le Goater14681632015-04-08 19:19:48 +0200441 /*
442 * If we can not parse the node name, it means we are
443 * running on a newer device tree. We can just forget
444 * about the OPAL index and use a defaut value for the
445 * hwmon attribute name
446 */
Cédric Le Goaterf9f54f12015-03-19 18:44:44 +0100447 attr_name = parse_opal_node_name(np->name, type, &opal_index);
448 if (IS_ERR(attr_name)) {
Cédric Le Goater14681632015-04-08 19:19:48 +0200449 attr_name = "input";
450 opal_index = INVALID_INDEX;
Cédric Le Goaterf9f54f12015-03-19 18:44:44 +0100451 }
452
Cédric Le Goaterfcaf57b2015-03-19 18:44:45 +0100453 sdata[count].opal_index = opal_index;
454 sdata[count].hwmon_index =
455 get_sensor_hwmon_index(&sdata[count], sdata, count);
456
Cédric Le Goater9e4f74b2015-04-08 19:19:47 +0200457 create_hwmon_attr(&sdata[count], attr_name, show_sensor);
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530458
459 pgroups[type]->attrs[sensor_groups[type].attr_count++] =
460 &sdata[count++].dev_attr.attr;
Cédric Le Goater2bcd3782015-04-08 19:19:49 +0200461
462 if (!of_property_read_string(np, "label", &label)) {
463 /*
464 * For the label attribute, we can reuse the
465 * "properties" of the previous "input"
466 * attribute. They are related to the same
467 * sensor.
468 */
Cédric Le Goater2bcd3782015-04-08 19:19:49 +0200469
470 make_sensor_label(np, &sdata[count], label);
Shilpasri G Bhat996cf5a2017-05-29 10:16:01 +0530471 populate_sensor(&sdata[count], opal_index,
472 sdata[count - 1].hwmon_index,
473 sensor_id, "label", type, pgroups[type],
474 show_label);
475 count++;
476 }
Cédric Le Goater2bcd3782015-04-08 19:19:49 +0200477
Shilpasri G Bhat996cf5a2017-05-29 10:16:01 +0530478 if (!of_property_read_u32(np, "sensor-data-max", &sensor_id)) {
479 attr_name = get_max_attr(type);
480 populate_sensor(&sdata[count], opal_index,
481 sdata[count - 1].hwmon_index,
482 sensor_id, attr_name, type,
483 pgroups[type], show_sensor);
484 count++;
485 }
Cédric Le Goater2bcd3782015-04-08 19:19:49 +0200486
Shilpasri G Bhat996cf5a2017-05-29 10:16:01 +0530487 if (!of_property_read_u32(np, "sensor-data-min", &sensor_id)) {
488 attr_name = get_min_attr(type);
489 populate_sensor(&sdata[count], opal_index,
490 sdata[count - 1].hwmon_index,
491 sensor_id, attr_name, type,
492 pgroups[type], show_sensor);
493 count++;
Cédric Le Goater2bcd3782015-04-08 19:19:49 +0200494 }
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530495 }
496
497exit_put_node:
498 of_node_put(opal);
499 return err;
500}
501
Neelesh Gupta8de303ba2014-11-05 16:45:14 +0530502static int ibmpowernv_probe(struct platform_device *pdev)
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530503{
504 struct platform_data *pdata;
505 struct device *hwmon_dev;
506 int err;
507
508 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
509 if (!pdata)
510 return -ENOMEM;
511
512 platform_set_drvdata(pdev, pdata);
513 pdata->sensors_count = 0;
514 err = populate_attr_groups(pdev);
515 if (err)
516 return err;
517
518 /* Create sysfs attribute data for each sensor found in the DT */
519 err = create_device_attrs(pdev);
520 if (err)
521 return err;
522
523 /* Finally, register with hwmon */
524 hwmon_dev = devm_hwmon_device_register_with_groups(&pdev->dev, DRVNAME,
525 pdata,
526 pdata->attr_groups);
527
528 return PTR_ERR_OR_ZERO(hwmon_dev);
529}
530
Neelesh Gupta8de303ba2014-11-05 16:45:14 +0530531static const struct platform_device_id opal_sensor_driver_ids[] = {
532 {
533 .name = "opal-sensor",
534 },
535 { }
536};
537MODULE_DEVICE_TABLE(platform, opal_sensor_driver_ids);
538
Cédric Le Goater0b056b22015-09-23 14:44:48 +0200539static const struct of_device_id opal_sensor_match[] = {
540 { .compatible = "ibm,opal-sensor" },
541 { },
542};
543MODULE_DEVICE_TABLE(of, opal_sensor_match);
544
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530545static struct platform_driver ibmpowernv_driver = {
Neelesh Gupta8de303ba2014-11-05 16:45:14 +0530546 .probe = ibmpowernv_probe,
547 .id_table = opal_sensor_driver_ids,
548 .driver = {
Neelesh Gupta8de303ba2014-11-05 16:45:14 +0530549 .name = DRVNAME,
Cédric Le Goater0b056b22015-09-23 14:44:48 +0200550 .of_match_table = opal_sensor_match,
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530551 },
552};
553
Axel Lin3bdec672014-11-12 16:36:47 +0800554module_platform_driver(ibmpowernv_driver);
Neelesh Gupta24c1aa82014-07-08 14:38:38 +0530555
556MODULE_AUTHOR("Neelesh Gupta <neelegup@linux.vnet.ibm.com>");
557MODULE_DESCRIPTION("IBM POWERNV platform sensors");
558MODULE_LICENSE("GPL");