ibmpowernv.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  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. #define DRVNAME "ibmpowernv"
  19. #define pr_fmt(fmt) DRVNAME ": " fmt
  20. #include <linux/init.h>
  21. #include <linux/module.h>
  22. #include <linux/kernel.h>
  23. #include <linux/hwmon.h>
  24. #include <linux/hwmon-sysfs.h>
  25. #include <linux/of.h>
  26. #include <linux/slab.h>
  27. #include <linux/platform_device.h>
  28. #include <asm/opal.h>
  29. #include <linux/err.h>
  30. #include <asm/cputhreads.h>
  31. #include <asm/smp.h>
  32. #define MAX_ATTR_LEN 32
  33. #define MAX_LABEL_LEN 64
  34. /* Sensor suffix name from DT */
  35. #define DT_FAULT_ATTR_SUFFIX "faulted"
  36. #define DT_DATA_ATTR_SUFFIX "data"
  37. #define DT_THRESHOLD_ATTR_SUFFIX "thrs"
  38. /*
  39. * Enumerates all the types of sensors in the POWERNV platform and does index
  40. * into 'struct sensor_group'
  41. */
  42. enum sensors {
  43. FAN,
  44. TEMP,
  45. POWER_SUPPLY,
  46. POWER_INPUT,
  47. CURRENT,
  48. ENERGY,
  49. MAX_SENSOR_TYPE,
  50. };
  51. #define INVALID_INDEX (-1U)
  52. /*
  53. * 'compatible' string properties for sensor types as defined in old
  54. * PowerNV firmware (skiboot). These are ordered as 'enum sensors'.
  55. */
  56. static const char * const legacy_compatibles[] = {
  57. "ibm,opal-sensor-cooling-fan",
  58. "ibm,opal-sensor-amb-temp",
  59. "ibm,opal-sensor-power-supply",
  60. "ibm,opal-sensor-power"
  61. };
  62. static struct sensor_group {
  63. const char *name; /* matches property 'sensor-type' */
  64. struct attribute_group group;
  65. u32 attr_count;
  66. u32 hwmon_index;
  67. } sensor_groups[] = {
  68. { "fan" },
  69. { "temp" },
  70. { "in" },
  71. { "power" },
  72. { "curr" },
  73. { "energy" },
  74. };
  75. struct sensor_data {
  76. u32 id; /* An opaque id of the firmware for each sensor */
  77. u32 hwmon_index;
  78. u32 opal_index;
  79. enum sensors type;
  80. char label[MAX_LABEL_LEN];
  81. char name[MAX_ATTR_LEN];
  82. struct device_attribute dev_attr;
  83. struct sensor_group_data *sgrp_data;
  84. };
  85. struct sensor_group_data {
  86. struct mutex mutex;
  87. u32 gid;
  88. bool enable;
  89. };
  90. struct platform_data {
  91. const struct attribute_group *attr_groups[MAX_SENSOR_TYPE + 1];
  92. struct sensor_group_data *sgrp_data;
  93. u32 sensors_count; /* Total count of sensors from each group */
  94. u32 nr_sensor_groups; /* Total number of sensor groups */
  95. };
  96. static 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. u64 x;
  103. if (sdata->sgrp_data && !sdata->sgrp_data->enable)
  104. return -ENODATA;
  105. ret = opal_get_sensor_data_u64(sdata->id, &x);
  106. if (ret)
  107. return ret;
  108. /* Convert temperature to milli-degrees */
  109. if (sdata->type == TEMP)
  110. x *= 1000;
  111. /* Convert power to micro-watts */
  112. else if (sdata->type == POWER_INPUT)
  113. x *= 1000000;
  114. return sprintf(buf, "%llu\n", x);
  115. }
  116. static ssize_t show_enable(struct device *dev,
  117. struct device_attribute *devattr, char *buf)
  118. {
  119. struct sensor_data *sdata = container_of(devattr, struct sensor_data,
  120. dev_attr);
  121. return sprintf(buf, "%u\n", sdata->sgrp_data->enable);
  122. }
  123. static ssize_t store_enable(struct device *dev,
  124. struct device_attribute *devattr,
  125. const char *buf, size_t count)
  126. {
  127. struct sensor_data *sdata = container_of(devattr, struct sensor_data,
  128. dev_attr);
  129. struct sensor_group_data *sgrp_data = sdata->sgrp_data;
  130. int ret;
  131. bool data;
  132. ret = kstrtobool(buf, &data);
  133. if (ret)
  134. return ret;
  135. ret = mutex_lock_interruptible(&sgrp_data->mutex);
  136. if (ret)
  137. return ret;
  138. if (data != sgrp_data->enable) {
  139. ret = sensor_group_enable(sgrp_data->gid, data);
  140. if (!ret)
  141. sgrp_data->enable = data;
  142. }
  143. if (!ret)
  144. ret = count;
  145. mutex_unlock(&sgrp_data->mutex);
  146. return ret;
  147. }
  148. static ssize_t show_label(struct device *dev, struct device_attribute *devattr,
  149. char *buf)
  150. {
  151. struct sensor_data *sdata = container_of(devattr, struct sensor_data,
  152. dev_attr);
  153. return sprintf(buf, "%s\n", sdata->label);
  154. }
  155. static int get_logical_cpu(int hwcpu)
  156. {
  157. int cpu;
  158. for_each_possible_cpu(cpu)
  159. if (get_hard_smp_processor_id(cpu) == hwcpu)
  160. return cpu;
  161. return -ENOENT;
  162. }
  163. static void make_sensor_label(struct device_node *np,
  164. struct sensor_data *sdata, const char *label)
  165. {
  166. u32 id;
  167. size_t n;
  168. n = snprintf(sdata->label, sizeof(sdata->label), "%s", label);
  169. /*
  170. * Core temp pretty print
  171. */
  172. if (!of_property_read_u32(np, "ibm,pir", &id)) {
  173. int cpuid = get_logical_cpu(id);
  174. if (cpuid >= 0)
  175. /*
  176. * The digital thermal sensors are associated
  177. * with a core.
  178. */
  179. n += snprintf(sdata->label + n,
  180. sizeof(sdata->label) - n, " %d",
  181. cpuid);
  182. else
  183. n += snprintf(sdata->label + n,
  184. sizeof(sdata->label) - n, " phy%d", id);
  185. }
  186. /*
  187. * Membuffer pretty print
  188. */
  189. if (!of_property_read_u32(np, "ibm,chip-id", &id))
  190. n += snprintf(sdata->label + n, sizeof(sdata->label) - n,
  191. " %d", id & 0xffff);
  192. }
  193. static int get_sensor_index_attr(const char *name, u32 *index, char *attr)
  194. {
  195. char *hash_pos = strchr(name, '#');
  196. char buf[8] = { 0 };
  197. char *dash_pos;
  198. u32 copy_len;
  199. int err;
  200. if (!hash_pos)
  201. return -EINVAL;
  202. dash_pos = strchr(hash_pos, '-');
  203. if (!dash_pos)
  204. return -EINVAL;
  205. copy_len = dash_pos - hash_pos - 1;
  206. if (copy_len >= sizeof(buf))
  207. return -EINVAL;
  208. strncpy(buf, hash_pos + 1, copy_len);
  209. err = kstrtou32(buf, 10, index);
  210. if (err)
  211. return err;
  212. strncpy(attr, dash_pos + 1, MAX_ATTR_LEN);
  213. return 0;
  214. }
  215. static const char *convert_opal_attr_name(enum sensors type,
  216. const char *opal_attr)
  217. {
  218. const char *attr_name = NULL;
  219. if (!strcmp(opal_attr, DT_FAULT_ATTR_SUFFIX)) {
  220. attr_name = "fault";
  221. } else if (!strcmp(opal_attr, DT_DATA_ATTR_SUFFIX)) {
  222. attr_name = "input";
  223. } else if (!strcmp(opal_attr, DT_THRESHOLD_ATTR_SUFFIX)) {
  224. if (type == TEMP)
  225. attr_name = "max";
  226. else if (type == FAN)
  227. attr_name = "min";
  228. }
  229. return attr_name;
  230. }
  231. /*
  232. * This function translates the DT node name into the 'hwmon' attribute name.
  233. * IBMPOWERNV device node appear like cooling-fan#2-data, amb-temp#1-thrs etc.
  234. * which need to be mapped as fan2_input, temp1_max respectively before
  235. * populating them inside hwmon device class.
  236. */
  237. static const char *parse_opal_node_name(const char *node_name,
  238. enum sensors type, u32 *index)
  239. {
  240. char attr_suffix[MAX_ATTR_LEN];
  241. const char *attr_name;
  242. int err;
  243. err = get_sensor_index_attr(node_name, index, attr_suffix);
  244. if (err)
  245. return ERR_PTR(err);
  246. attr_name = convert_opal_attr_name(type, attr_suffix);
  247. if (!attr_name)
  248. return ERR_PTR(-ENOENT);
  249. return attr_name;
  250. }
  251. static int get_sensor_type(struct device_node *np)
  252. {
  253. enum sensors type;
  254. const char *str;
  255. for (type = 0; type < ARRAY_SIZE(legacy_compatibles); type++) {
  256. if (of_device_is_compatible(np, legacy_compatibles[type]))
  257. return type;
  258. }
  259. /*
  260. * Let's check if we have a newer device tree
  261. */
  262. if (!of_device_is_compatible(np, "ibm,opal-sensor"))
  263. return MAX_SENSOR_TYPE;
  264. if (of_property_read_string(np, "sensor-type", &str))
  265. return MAX_SENSOR_TYPE;
  266. for (type = 0; type < MAX_SENSOR_TYPE; type++)
  267. if (!strcmp(str, sensor_groups[type].name))
  268. return type;
  269. return MAX_SENSOR_TYPE;
  270. }
  271. static u32 get_sensor_hwmon_index(struct sensor_data *sdata,
  272. struct sensor_data *sdata_table, int count)
  273. {
  274. int i;
  275. /*
  276. * We don't use the OPAL index on newer device trees
  277. */
  278. if (sdata->opal_index != INVALID_INDEX) {
  279. for (i = 0; i < count; i++)
  280. if (sdata_table[i].opal_index == sdata->opal_index &&
  281. sdata_table[i].type == sdata->type)
  282. return sdata_table[i].hwmon_index;
  283. }
  284. return ++sensor_groups[sdata->type].hwmon_index;
  285. }
  286. static int init_sensor_group_data(struct platform_device *pdev,
  287. struct platform_data *pdata)
  288. {
  289. struct sensor_group_data *sgrp_data;
  290. struct device_node *groups, *sgrp;
  291. int count = 0, ret = 0;
  292. enum sensors type;
  293. groups = of_find_compatible_node(NULL, NULL, "ibm,opal-sensor-group");
  294. if (!groups)
  295. return ret;
  296. for_each_child_of_node(groups, sgrp) {
  297. type = get_sensor_type(sgrp);
  298. if (type != MAX_SENSOR_TYPE)
  299. pdata->nr_sensor_groups++;
  300. }
  301. if (!pdata->nr_sensor_groups)
  302. goto out;
  303. sgrp_data = devm_kcalloc(&pdev->dev, pdata->nr_sensor_groups,
  304. sizeof(*sgrp_data), GFP_KERNEL);
  305. if (!sgrp_data) {
  306. ret = -ENOMEM;
  307. goto out;
  308. }
  309. for_each_child_of_node(groups, sgrp) {
  310. u32 gid;
  311. type = get_sensor_type(sgrp);
  312. if (type == MAX_SENSOR_TYPE)
  313. continue;
  314. if (of_property_read_u32(sgrp, "sensor-group-id", &gid))
  315. continue;
  316. if (of_count_phandle_with_args(sgrp, "sensors", NULL) <= 0)
  317. continue;
  318. sensor_groups[type].attr_count++;
  319. sgrp_data[count].gid = gid;
  320. mutex_init(&sgrp_data[count].mutex);
  321. sgrp_data[count++].enable = false;
  322. }
  323. pdata->sgrp_data = sgrp_data;
  324. out:
  325. of_node_put(groups);
  326. return ret;
  327. }
  328. static struct sensor_group_data *get_sensor_group(struct platform_data *pdata,
  329. struct device_node *node,
  330. enum sensors gtype)
  331. {
  332. struct sensor_group_data *sgrp_data = pdata->sgrp_data;
  333. struct device_node *groups, *sgrp;
  334. groups = of_find_compatible_node(NULL, NULL, "ibm,opal-sensor-group");
  335. if (!groups)
  336. return NULL;
  337. for_each_child_of_node(groups, sgrp) {
  338. struct of_phandle_iterator it;
  339. u32 gid;
  340. int rc, i;
  341. enum sensors type;
  342. type = get_sensor_type(sgrp);
  343. if (type != gtype)
  344. continue;
  345. if (of_property_read_u32(sgrp, "sensor-group-id", &gid))
  346. continue;
  347. of_for_each_phandle(&it, rc, sgrp, "sensors", NULL, 0)
  348. if (it.phandle == node->phandle) {
  349. of_node_put(it.node);
  350. break;
  351. }
  352. if (rc)
  353. continue;
  354. for (i = 0; i < pdata->nr_sensor_groups; i++)
  355. if (gid == sgrp_data[i].gid) {
  356. of_node_put(sgrp);
  357. of_node_put(groups);
  358. return &sgrp_data[i];
  359. }
  360. }
  361. of_node_put(groups);
  362. return NULL;
  363. }
  364. static int populate_attr_groups(struct platform_device *pdev)
  365. {
  366. struct platform_data *pdata = platform_get_drvdata(pdev);
  367. const struct attribute_group **pgroups = pdata->attr_groups;
  368. struct device_node *opal, *np;
  369. enum sensors type;
  370. int ret;
  371. ret = init_sensor_group_data(pdev, pdata);
  372. if (ret)
  373. return ret;
  374. opal = of_find_node_by_path("/ibm,opal/sensors");
  375. for_each_child_of_node(opal, np) {
  376. const char *label;
  377. if (np->name == NULL)
  378. continue;
  379. type = get_sensor_type(np);
  380. if (type == MAX_SENSOR_TYPE)
  381. continue;
  382. sensor_groups[type].attr_count++;
  383. /*
  384. * add attributes for labels, min and max
  385. */
  386. if (!of_property_read_string(np, "label", &label))
  387. sensor_groups[type].attr_count++;
  388. if (of_find_property(np, "sensor-data-min", NULL))
  389. sensor_groups[type].attr_count++;
  390. if (of_find_property(np, "sensor-data-max", NULL))
  391. sensor_groups[type].attr_count++;
  392. }
  393. of_node_put(opal);
  394. for (type = 0; type < MAX_SENSOR_TYPE; type++) {
  395. sensor_groups[type].group.attrs = devm_kcalloc(&pdev->dev,
  396. sensor_groups[type].attr_count + 1,
  397. sizeof(struct attribute *),
  398. GFP_KERNEL);
  399. if (!sensor_groups[type].group.attrs)
  400. return -ENOMEM;
  401. pgroups[type] = &sensor_groups[type].group;
  402. pdata->sensors_count += sensor_groups[type].attr_count;
  403. sensor_groups[type].attr_count = 0;
  404. }
  405. return 0;
  406. }
  407. static void create_hwmon_attr(struct sensor_data *sdata, const char *attr_name,
  408. ssize_t (*show)(struct device *dev,
  409. struct device_attribute *attr,
  410. char *buf),
  411. ssize_t (*store)(struct device *dev,
  412. struct device_attribute *attr,
  413. const char *buf, size_t count))
  414. {
  415. snprintf(sdata->name, MAX_ATTR_LEN, "%s%d_%s",
  416. sensor_groups[sdata->type].name, sdata->hwmon_index,
  417. attr_name);
  418. sysfs_attr_init(&sdata->dev_attr.attr);
  419. sdata->dev_attr.attr.name = sdata->name;
  420. sdata->dev_attr.show = show;
  421. if (store) {
  422. sdata->dev_attr.store = store;
  423. sdata->dev_attr.attr.mode = 0664;
  424. } else {
  425. sdata->dev_attr.attr.mode = 0444;
  426. }
  427. }
  428. static void populate_sensor(struct sensor_data *sdata, int od, int hd, int sid,
  429. const char *attr_name, enum sensors type,
  430. const struct attribute_group *pgroup,
  431. struct sensor_group_data *sgrp_data,
  432. ssize_t (*show)(struct device *dev,
  433. struct device_attribute *attr,
  434. char *buf),
  435. ssize_t (*store)(struct device *dev,
  436. struct device_attribute *attr,
  437. const char *buf, size_t count))
  438. {
  439. sdata->id = sid;
  440. sdata->type = type;
  441. sdata->opal_index = od;
  442. sdata->hwmon_index = hd;
  443. create_hwmon_attr(sdata, attr_name, show, store);
  444. pgroup->attrs[sensor_groups[type].attr_count++] = &sdata->dev_attr.attr;
  445. sdata->sgrp_data = sgrp_data;
  446. }
  447. static char *get_max_attr(enum sensors type)
  448. {
  449. switch (type) {
  450. case POWER_INPUT:
  451. return "input_highest";
  452. default:
  453. return "highest";
  454. }
  455. }
  456. static char *get_min_attr(enum sensors type)
  457. {
  458. switch (type) {
  459. case POWER_INPUT:
  460. return "input_lowest";
  461. default:
  462. return "lowest";
  463. }
  464. }
  465. /*
  466. * Iterate through the device tree for each child of 'sensors' node, create
  467. * a sysfs attribute file, the file is named by translating the DT node name
  468. * to the name required by the higher 'hwmon' driver like fan1_input, temp1_max
  469. * etc..
  470. */
  471. static int create_device_attrs(struct platform_device *pdev)
  472. {
  473. struct platform_data *pdata = platform_get_drvdata(pdev);
  474. const struct attribute_group **pgroups = pdata->attr_groups;
  475. struct device_node *opal, *np;
  476. struct sensor_data *sdata;
  477. u32 count = 0;
  478. u32 group_attr_id[MAX_SENSOR_TYPE] = {0};
  479. sdata = devm_kcalloc(&pdev->dev,
  480. pdata->sensors_count, sizeof(*sdata),
  481. GFP_KERNEL);
  482. if (!sdata)
  483. return -ENOMEM;
  484. opal = of_find_node_by_path("/ibm,opal/sensors");
  485. for_each_child_of_node(opal, np) {
  486. struct sensor_group_data *sgrp_data;
  487. const char *attr_name;
  488. u32 opal_index, hw_id;
  489. u32 sensor_id;
  490. const char *label;
  491. enum sensors type;
  492. if (np->name == NULL)
  493. continue;
  494. type = get_sensor_type(np);
  495. if (type == MAX_SENSOR_TYPE)
  496. continue;
  497. /*
  498. * Newer device trees use a "sensor-data" property
  499. * name for input.
  500. */
  501. if (of_property_read_u32(np, "sensor-id", &sensor_id) &&
  502. of_property_read_u32(np, "sensor-data", &sensor_id)) {
  503. dev_info(&pdev->dev,
  504. "'sensor-id' missing in the node '%s'\n",
  505. np->name);
  506. continue;
  507. }
  508. sdata[count].id = sensor_id;
  509. sdata[count].type = type;
  510. /*
  511. * If we can not parse the node name, it means we are
  512. * running on a newer device tree. We can just forget
  513. * about the OPAL index and use a defaut value for the
  514. * hwmon attribute name
  515. */
  516. attr_name = parse_opal_node_name(np->name, type, &opal_index);
  517. if (IS_ERR(attr_name)) {
  518. attr_name = "input";
  519. opal_index = INVALID_INDEX;
  520. }
  521. hw_id = get_sensor_hwmon_index(&sdata[count], sdata, count);
  522. sgrp_data = get_sensor_group(pdata, np, type);
  523. populate_sensor(&sdata[count], opal_index, hw_id, sensor_id,
  524. attr_name, type, pgroups[type], sgrp_data,
  525. show_sensor, NULL);
  526. count++;
  527. if (!of_property_read_string(np, "label", &label)) {
  528. /*
  529. * For the label attribute, we can reuse the
  530. * "properties" of the previous "input"
  531. * attribute. They are related to the same
  532. * sensor.
  533. */
  534. make_sensor_label(np, &sdata[count], label);
  535. populate_sensor(&sdata[count], opal_index, hw_id,
  536. sensor_id, "label", type, pgroups[type],
  537. NULL, show_label, NULL);
  538. count++;
  539. }
  540. if (!of_property_read_u32(np, "sensor-data-max", &sensor_id)) {
  541. attr_name = get_max_attr(type);
  542. populate_sensor(&sdata[count], opal_index, hw_id,
  543. sensor_id, attr_name, type,
  544. pgroups[type], sgrp_data, show_sensor,
  545. NULL);
  546. count++;
  547. }
  548. if (!of_property_read_u32(np, "sensor-data-min", &sensor_id)) {
  549. attr_name = get_min_attr(type);
  550. populate_sensor(&sdata[count], opal_index, hw_id,
  551. sensor_id, attr_name, type,
  552. pgroups[type], sgrp_data, show_sensor,
  553. NULL);
  554. count++;
  555. }
  556. if (sgrp_data && !sgrp_data->enable) {
  557. sgrp_data->enable = true;
  558. hw_id = ++group_attr_id[type];
  559. populate_sensor(&sdata[count], opal_index, hw_id,
  560. sgrp_data->gid, "enable", type,
  561. pgroups[type], sgrp_data, show_enable,
  562. store_enable);
  563. count++;
  564. }
  565. }
  566. of_node_put(opal);
  567. return 0;
  568. }
  569. static int ibmpowernv_probe(struct platform_device *pdev)
  570. {
  571. struct platform_data *pdata;
  572. struct device *hwmon_dev;
  573. int err;
  574. pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
  575. if (!pdata)
  576. return -ENOMEM;
  577. platform_set_drvdata(pdev, pdata);
  578. pdata->sensors_count = 0;
  579. pdata->nr_sensor_groups = 0;
  580. err = populate_attr_groups(pdev);
  581. if (err)
  582. return err;
  583. /* Create sysfs attribute data for each sensor found in the DT */
  584. err = create_device_attrs(pdev);
  585. if (err)
  586. return err;
  587. /* Finally, register with hwmon */
  588. hwmon_dev = devm_hwmon_device_register_with_groups(&pdev->dev, DRVNAME,
  589. pdata,
  590. pdata->attr_groups);
  591. return PTR_ERR_OR_ZERO(hwmon_dev);
  592. }
  593. static const struct platform_device_id opal_sensor_driver_ids[] = {
  594. {
  595. .name = "opal-sensor",
  596. },
  597. { }
  598. };
  599. MODULE_DEVICE_TABLE(platform, opal_sensor_driver_ids);
  600. static const struct of_device_id opal_sensor_match[] = {
  601. { .compatible = "ibm,opal-sensor" },
  602. { },
  603. };
  604. MODULE_DEVICE_TABLE(of, opal_sensor_match);
  605. static struct platform_driver ibmpowernv_driver = {
  606. .probe = ibmpowernv_probe,
  607. .id_table = opal_sensor_driver_ids,
  608. .driver = {
  609. .name = DRVNAME,
  610. .of_match_table = opal_sensor_match,
  611. },
  612. };
  613. module_platform_driver(ibmpowernv_driver);
  614. MODULE_AUTHOR("Neelesh Gupta <neelegup@linux.vnet.ibm.com>");
  615. MODULE_DESCRIPTION("IBM POWERNV platform sensors");
  616. MODULE_LICENSE("GPL");