gpio-fan.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. /*
  2. * gpio-fan.c - Hwmon driver for fans connected to GPIO lines.
  3. *
  4. * Copyright (C) 2010 LaCie
  5. *
  6. * Author: Simon Guinot <sguinot@lacie.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #include <linux/module.h>
  23. #include <linux/init.h>
  24. #include <linux/slab.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/irq.h>
  27. #include <linux/platform_device.h>
  28. #include <linux/err.h>
  29. #include <linux/mutex.h>
  30. #include <linux/hwmon.h>
  31. #include <linux/gpio.h>
  32. #include <linux/gpio-fan.h>
  33. #include <linux/of.h>
  34. #include <linux/of_platform.h>
  35. #include <linux/of_gpio.h>
  36. #include <linux/thermal.h>
  37. struct gpio_fan_data {
  38. struct platform_device *pdev;
  39. struct device *hwmon_dev;
  40. /* Cooling device if any */
  41. struct thermal_cooling_device *cdev;
  42. struct mutex lock; /* lock GPIOs operations. */
  43. int num_ctrl;
  44. unsigned *ctrl;
  45. int num_speed;
  46. struct gpio_fan_speed *speed;
  47. int speed_index;
  48. #ifdef CONFIG_PM_SLEEP
  49. int resume_speed;
  50. #endif
  51. bool pwm_enable;
  52. struct gpio_fan_alarm *alarm;
  53. struct work_struct alarm_work;
  54. };
  55. /*
  56. * Alarm GPIO.
  57. */
  58. static void fan_alarm_notify(struct work_struct *ws)
  59. {
  60. struct gpio_fan_data *fan_data =
  61. container_of(ws, struct gpio_fan_data, alarm_work);
  62. sysfs_notify(&fan_data->pdev->dev.kobj, NULL, "fan1_alarm");
  63. kobject_uevent(&fan_data->pdev->dev.kobj, KOBJ_CHANGE);
  64. }
  65. static irqreturn_t fan_alarm_irq_handler(int irq, void *dev_id)
  66. {
  67. struct gpio_fan_data *fan_data = dev_id;
  68. schedule_work(&fan_data->alarm_work);
  69. return IRQ_NONE;
  70. }
  71. static ssize_t show_fan_alarm(struct device *dev,
  72. struct device_attribute *attr, char *buf)
  73. {
  74. struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
  75. struct gpio_fan_alarm *alarm = fan_data->alarm;
  76. int value = gpio_get_value_cansleep(alarm->gpio);
  77. if (alarm->active_low)
  78. value = !value;
  79. return sprintf(buf, "%d\n", value);
  80. }
  81. static DEVICE_ATTR(fan1_alarm, S_IRUGO, show_fan_alarm, NULL);
  82. static int fan_alarm_init(struct gpio_fan_data *fan_data,
  83. struct gpio_fan_alarm *alarm)
  84. {
  85. int err;
  86. int alarm_irq;
  87. struct platform_device *pdev = fan_data->pdev;
  88. fan_data->alarm = alarm;
  89. err = devm_gpio_request(&pdev->dev, alarm->gpio, "GPIO fan alarm");
  90. if (err)
  91. return err;
  92. err = gpio_direction_input(alarm->gpio);
  93. if (err)
  94. return err;
  95. /*
  96. * If the alarm GPIO don't support interrupts, just leave
  97. * without initializing the fail notification support.
  98. */
  99. alarm_irq = gpio_to_irq(alarm->gpio);
  100. if (alarm_irq < 0)
  101. return 0;
  102. INIT_WORK(&fan_data->alarm_work, fan_alarm_notify);
  103. irq_set_irq_type(alarm_irq, IRQ_TYPE_EDGE_BOTH);
  104. err = devm_request_irq(&pdev->dev, alarm_irq, fan_alarm_irq_handler,
  105. IRQF_SHARED, "GPIO fan alarm", fan_data);
  106. return err;
  107. }
  108. /*
  109. * Control GPIOs.
  110. */
  111. /* Must be called with fan_data->lock held, except during initialization. */
  112. static void __set_fan_ctrl(struct gpio_fan_data *fan_data, int ctrl_val)
  113. {
  114. int i;
  115. for (i = 0; i < fan_data->num_ctrl; i++)
  116. gpio_set_value_cansleep(fan_data->ctrl[i], (ctrl_val >> i) & 1);
  117. }
  118. static int __get_fan_ctrl(struct gpio_fan_data *fan_data)
  119. {
  120. int i;
  121. int ctrl_val = 0;
  122. for (i = 0; i < fan_data->num_ctrl; i++) {
  123. int value;
  124. value = gpio_get_value_cansleep(fan_data->ctrl[i]);
  125. ctrl_val |= (value << i);
  126. }
  127. return ctrl_val;
  128. }
  129. /* Must be called with fan_data->lock held, except during initialization. */
  130. static void set_fan_speed(struct gpio_fan_data *fan_data, int speed_index)
  131. {
  132. if (fan_data->speed_index == speed_index)
  133. return;
  134. __set_fan_ctrl(fan_data, fan_data->speed[speed_index].ctrl_val);
  135. fan_data->speed_index = speed_index;
  136. }
  137. static int get_fan_speed_index(struct gpio_fan_data *fan_data)
  138. {
  139. int ctrl_val = __get_fan_ctrl(fan_data);
  140. int i;
  141. for (i = 0; i < fan_data->num_speed; i++)
  142. if (fan_data->speed[i].ctrl_val == ctrl_val)
  143. return i;
  144. dev_warn(&fan_data->pdev->dev,
  145. "missing speed array entry for GPIO value 0x%x\n", ctrl_val);
  146. return -ENODEV;
  147. }
  148. static int rpm_to_speed_index(struct gpio_fan_data *fan_data, unsigned long rpm)
  149. {
  150. struct gpio_fan_speed *speed = fan_data->speed;
  151. int i;
  152. for (i = 0; i < fan_data->num_speed; i++)
  153. if (speed[i].rpm >= rpm)
  154. return i;
  155. return fan_data->num_speed - 1;
  156. }
  157. static ssize_t show_pwm(struct device *dev,
  158. struct device_attribute *attr, char *buf)
  159. {
  160. struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
  161. u8 pwm = fan_data->speed_index * 255 / (fan_data->num_speed - 1);
  162. return sprintf(buf, "%d\n", pwm);
  163. }
  164. static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
  165. const char *buf, size_t count)
  166. {
  167. struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
  168. unsigned long pwm;
  169. int speed_index;
  170. int ret = count;
  171. if (kstrtoul(buf, 10, &pwm) || pwm > 255)
  172. return -EINVAL;
  173. mutex_lock(&fan_data->lock);
  174. if (!fan_data->pwm_enable) {
  175. ret = -EPERM;
  176. goto exit_unlock;
  177. }
  178. speed_index = DIV_ROUND_UP(pwm * (fan_data->num_speed - 1), 255);
  179. set_fan_speed(fan_data, speed_index);
  180. exit_unlock:
  181. mutex_unlock(&fan_data->lock);
  182. return ret;
  183. }
  184. static ssize_t show_pwm_enable(struct device *dev,
  185. struct device_attribute *attr, char *buf)
  186. {
  187. struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
  188. return sprintf(buf, "%d\n", fan_data->pwm_enable);
  189. }
  190. static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr,
  191. const char *buf, size_t count)
  192. {
  193. struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
  194. unsigned long val;
  195. if (kstrtoul(buf, 10, &val) || val > 1)
  196. return -EINVAL;
  197. if (fan_data->pwm_enable == val)
  198. return count;
  199. mutex_lock(&fan_data->lock);
  200. fan_data->pwm_enable = val;
  201. /* Disable manual control mode: set fan at full speed. */
  202. if (val == 0)
  203. set_fan_speed(fan_data, fan_data->num_speed - 1);
  204. mutex_unlock(&fan_data->lock);
  205. return count;
  206. }
  207. static ssize_t show_pwm_mode(struct device *dev,
  208. struct device_attribute *attr, char *buf)
  209. {
  210. return sprintf(buf, "0\n");
  211. }
  212. static ssize_t show_rpm_min(struct device *dev,
  213. struct device_attribute *attr, char *buf)
  214. {
  215. struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
  216. return sprintf(buf, "%d\n", fan_data->speed[0].rpm);
  217. }
  218. static ssize_t show_rpm_max(struct device *dev,
  219. struct device_attribute *attr, char *buf)
  220. {
  221. struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
  222. return sprintf(buf, "%d\n",
  223. fan_data->speed[fan_data->num_speed - 1].rpm);
  224. }
  225. static ssize_t show_rpm(struct device *dev,
  226. struct device_attribute *attr, char *buf)
  227. {
  228. struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
  229. return sprintf(buf, "%d\n", fan_data->speed[fan_data->speed_index].rpm);
  230. }
  231. static ssize_t set_rpm(struct device *dev, struct device_attribute *attr,
  232. const char *buf, size_t count)
  233. {
  234. struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
  235. unsigned long rpm;
  236. int ret = count;
  237. if (kstrtoul(buf, 10, &rpm))
  238. return -EINVAL;
  239. mutex_lock(&fan_data->lock);
  240. if (!fan_data->pwm_enable) {
  241. ret = -EPERM;
  242. goto exit_unlock;
  243. }
  244. set_fan_speed(fan_data, rpm_to_speed_index(fan_data, rpm));
  245. exit_unlock:
  246. mutex_unlock(&fan_data->lock);
  247. return ret;
  248. }
  249. static DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm, set_pwm);
  250. static DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR,
  251. show_pwm_enable, set_pwm_enable);
  252. static DEVICE_ATTR(pwm1_mode, S_IRUGO, show_pwm_mode, NULL);
  253. static DEVICE_ATTR(fan1_min, S_IRUGO, show_rpm_min, NULL);
  254. static DEVICE_ATTR(fan1_max, S_IRUGO, show_rpm_max, NULL);
  255. static DEVICE_ATTR(fan1_input, S_IRUGO, show_rpm, NULL);
  256. static DEVICE_ATTR(fan1_target, S_IRUGO | S_IWUSR, show_rpm, set_rpm);
  257. static umode_t gpio_fan_is_visible(struct kobject *kobj,
  258. struct attribute *attr, int index)
  259. {
  260. struct device *dev = container_of(kobj, struct device, kobj);
  261. struct gpio_fan_data *data = dev_get_drvdata(dev);
  262. if (index == 0 && !data->alarm)
  263. return 0;
  264. if (index > 0 && !data->ctrl)
  265. return 0;
  266. return attr->mode;
  267. }
  268. static struct attribute *gpio_fan_attributes[] = {
  269. &dev_attr_fan1_alarm.attr, /* 0 */
  270. &dev_attr_pwm1.attr, /* 1 */
  271. &dev_attr_pwm1_enable.attr,
  272. &dev_attr_pwm1_mode.attr,
  273. &dev_attr_fan1_input.attr,
  274. &dev_attr_fan1_target.attr,
  275. &dev_attr_fan1_min.attr,
  276. &dev_attr_fan1_max.attr,
  277. NULL
  278. };
  279. static const struct attribute_group gpio_fan_group = {
  280. .attrs = gpio_fan_attributes,
  281. .is_visible = gpio_fan_is_visible,
  282. };
  283. static const struct attribute_group *gpio_fan_groups[] = {
  284. &gpio_fan_group,
  285. NULL
  286. };
  287. static int fan_ctrl_init(struct gpio_fan_data *fan_data,
  288. struct gpio_fan_platform_data *pdata)
  289. {
  290. struct platform_device *pdev = fan_data->pdev;
  291. int num_ctrl = pdata->num_ctrl;
  292. unsigned *ctrl = pdata->ctrl;
  293. int i, err;
  294. for (i = 0; i < num_ctrl; i++) {
  295. err = devm_gpio_request(&pdev->dev, ctrl[i],
  296. "GPIO fan control");
  297. if (err)
  298. return err;
  299. err = gpio_direction_output(ctrl[i],
  300. gpio_get_value_cansleep(ctrl[i]));
  301. if (err)
  302. return err;
  303. }
  304. fan_data->num_ctrl = num_ctrl;
  305. fan_data->ctrl = ctrl;
  306. fan_data->num_speed = pdata->num_speed;
  307. fan_data->speed = pdata->speed;
  308. fan_data->pwm_enable = true; /* Enable manual fan speed control. */
  309. fan_data->speed_index = get_fan_speed_index(fan_data);
  310. if (fan_data->speed_index < 0)
  311. return fan_data->speed_index;
  312. return 0;
  313. }
  314. static int gpio_fan_get_max_state(struct thermal_cooling_device *cdev,
  315. unsigned long *state)
  316. {
  317. struct gpio_fan_data *fan_data = cdev->devdata;
  318. if (!fan_data)
  319. return -EINVAL;
  320. *state = fan_data->num_speed - 1;
  321. return 0;
  322. }
  323. static int gpio_fan_get_cur_state(struct thermal_cooling_device *cdev,
  324. unsigned long *state)
  325. {
  326. struct gpio_fan_data *fan_data = cdev->devdata;
  327. if (!fan_data)
  328. return -EINVAL;
  329. *state = fan_data->speed_index;
  330. return 0;
  331. }
  332. static int gpio_fan_set_cur_state(struct thermal_cooling_device *cdev,
  333. unsigned long state)
  334. {
  335. struct gpio_fan_data *fan_data = cdev->devdata;
  336. if (!fan_data)
  337. return -EINVAL;
  338. set_fan_speed(fan_data, state);
  339. return 0;
  340. }
  341. static const struct thermal_cooling_device_ops gpio_fan_cool_ops = {
  342. .get_max_state = gpio_fan_get_max_state,
  343. .get_cur_state = gpio_fan_get_cur_state,
  344. .set_cur_state = gpio_fan_set_cur_state,
  345. };
  346. #ifdef CONFIG_OF_GPIO
  347. /*
  348. * Translate OpenFirmware node properties into platform_data
  349. */
  350. static int gpio_fan_get_of_pdata(struct device *dev,
  351. struct gpio_fan_platform_data *pdata)
  352. {
  353. struct device_node *node;
  354. struct gpio_fan_speed *speed;
  355. unsigned *ctrl;
  356. unsigned i;
  357. u32 u;
  358. struct property *prop;
  359. const __be32 *p;
  360. node = dev->of_node;
  361. /* Alarm GPIO if one exists */
  362. if (of_gpio_named_count(node, "alarm-gpios") > 0) {
  363. struct gpio_fan_alarm *alarm;
  364. int val;
  365. enum of_gpio_flags flags;
  366. alarm = devm_kzalloc(dev, sizeof(struct gpio_fan_alarm),
  367. GFP_KERNEL);
  368. if (!alarm)
  369. return -ENOMEM;
  370. val = of_get_named_gpio_flags(node, "alarm-gpios", 0, &flags);
  371. if (val < 0)
  372. return val;
  373. alarm->gpio = val;
  374. alarm->active_low = flags & OF_GPIO_ACTIVE_LOW;
  375. pdata->alarm = alarm;
  376. }
  377. /* Fill GPIO pin array */
  378. pdata->num_ctrl = of_gpio_count(node);
  379. if (pdata->num_ctrl <= 0) {
  380. if (pdata->alarm)
  381. return 0;
  382. dev_err(dev, "DT properties empty / missing");
  383. return -ENODEV;
  384. }
  385. ctrl = devm_kzalloc(dev, pdata->num_ctrl * sizeof(unsigned),
  386. GFP_KERNEL);
  387. if (!ctrl)
  388. return -ENOMEM;
  389. for (i = 0; i < pdata->num_ctrl; i++) {
  390. int val;
  391. val = of_get_gpio(node, i);
  392. if (val < 0)
  393. return val;
  394. ctrl[i] = val;
  395. }
  396. pdata->ctrl = ctrl;
  397. /* Get number of RPM/ctrl_val pairs in speed map */
  398. prop = of_find_property(node, "gpio-fan,speed-map", &i);
  399. if (!prop) {
  400. dev_err(dev, "gpio-fan,speed-map DT property missing");
  401. return -ENODEV;
  402. }
  403. i = i / sizeof(u32);
  404. if (i == 0 || i & 1) {
  405. dev_err(dev, "gpio-fan,speed-map contains zero/odd number of entries");
  406. return -ENODEV;
  407. }
  408. pdata->num_speed = i / 2;
  409. /*
  410. * Populate speed map
  411. * Speed map is in the form <RPM ctrl_val RPM ctrl_val ...>
  412. * this needs splitting into pairs to create gpio_fan_speed structs
  413. */
  414. speed = devm_kzalloc(dev,
  415. pdata->num_speed * sizeof(struct gpio_fan_speed),
  416. GFP_KERNEL);
  417. if (!speed)
  418. return -ENOMEM;
  419. p = NULL;
  420. for (i = 0; i < pdata->num_speed; i++) {
  421. p = of_prop_next_u32(prop, p, &u);
  422. if (!p)
  423. return -ENODEV;
  424. speed[i].rpm = u;
  425. p = of_prop_next_u32(prop, p, &u);
  426. if (!p)
  427. return -ENODEV;
  428. speed[i].ctrl_val = u;
  429. }
  430. pdata->speed = speed;
  431. return 0;
  432. }
  433. static const struct of_device_id of_gpio_fan_match[] = {
  434. { .compatible = "gpio-fan", },
  435. {},
  436. };
  437. MODULE_DEVICE_TABLE(of, of_gpio_fan_match);
  438. #endif /* CONFIG_OF_GPIO */
  439. static int gpio_fan_probe(struct platform_device *pdev)
  440. {
  441. int err;
  442. struct gpio_fan_data *fan_data;
  443. struct gpio_fan_platform_data *pdata = dev_get_platdata(&pdev->dev);
  444. fan_data = devm_kzalloc(&pdev->dev, sizeof(struct gpio_fan_data),
  445. GFP_KERNEL);
  446. if (!fan_data)
  447. return -ENOMEM;
  448. #ifdef CONFIG_OF_GPIO
  449. if (!pdata) {
  450. pdata = devm_kzalloc(&pdev->dev,
  451. sizeof(struct gpio_fan_platform_data),
  452. GFP_KERNEL);
  453. if (!pdata)
  454. return -ENOMEM;
  455. err = gpio_fan_get_of_pdata(&pdev->dev, pdata);
  456. if (err)
  457. return err;
  458. }
  459. #else /* CONFIG_OF_GPIO */
  460. if (!pdata)
  461. return -EINVAL;
  462. #endif /* CONFIG_OF_GPIO */
  463. fan_data->pdev = pdev;
  464. platform_set_drvdata(pdev, fan_data);
  465. mutex_init(&fan_data->lock);
  466. /* Configure alarm GPIO if available. */
  467. if (pdata->alarm) {
  468. err = fan_alarm_init(fan_data, pdata->alarm);
  469. if (err)
  470. return err;
  471. }
  472. /* Configure control GPIOs if available. */
  473. if (pdata->ctrl && pdata->num_ctrl > 0) {
  474. if (!pdata->speed || pdata->num_speed <= 1)
  475. return -EINVAL;
  476. err = fan_ctrl_init(fan_data, pdata);
  477. if (err)
  478. return err;
  479. }
  480. /* Make this driver part of hwmon class. */
  481. fan_data->hwmon_dev =
  482. devm_hwmon_device_register_with_groups(&pdev->dev,
  483. "gpio_fan", fan_data,
  484. gpio_fan_groups);
  485. if (IS_ERR(fan_data->hwmon_dev))
  486. return PTR_ERR(fan_data->hwmon_dev);
  487. #ifdef CONFIG_OF_GPIO
  488. /* Optional cooling device register for Device tree platforms */
  489. fan_data->cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
  490. "gpio-fan",
  491. fan_data,
  492. &gpio_fan_cool_ops);
  493. #else /* CONFIG_OF_GPIO */
  494. /* Optional cooling device register for non Device tree platforms */
  495. fan_data->cdev = thermal_cooling_device_register("gpio-fan", fan_data,
  496. &gpio_fan_cool_ops);
  497. #endif /* CONFIG_OF_GPIO */
  498. dev_info(&pdev->dev, "GPIO fan initialized\n");
  499. return 0;
  500. }
  501. static int gpio_fan_remove(struct platform_device *pdev)
  502. {
  503. struct gpio_fan_data *fan_data = platform_get_drvdata(pdev);
  504. if (!IS_ERR(fan_data->cdev))
  505. thermal_cooling_device_unregister(fan_data->cdev);
  506. if (fan_data->ctrl)
  507. set_fan_speed(fan_data, 0);
  508. return 0;
  509. }
  510. static void gpio_fan_shutdown(struct platform_device *pdev)
  511. {
  512. gpio_fan_remove(pdev);
  513. }
  514. #ifdef CONFIG_PM_SLEEP
  515. static int gpio_fan_suspend(struct device *dev)
  516. {
  517. struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
  518. if (fan_data->ctrl) {
  519. fan_data->resume_speed = fan_data->speed_index;
  520. set_fan_speed(fan_data, 0);
  521. }
  522. return 0;
  523. }
  524. static int gpio_fan_resume(struct device *dev)
  525. {
  526. struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
  527. if (fan_data->ctrl)
  528. set_fan_speed(fan_data, fan_data->resume_speed);
  529. return 0;
  530. }
  531. static SIMPLE_DEV_PM_OPS(gpio_fan_pm, gpio_fan_suspend, gpio_fan_resume);
  532. #define GPIO_FAN_PM (&gpio_fan_pm)
  533. #else
  534. #define GPIO_FAN_PM NULL
  535. #endif
  536. static struct platform_driver gpio_fan_driver = {
  537. .probe = gpio_fan_probe,
  538. .remove = gpio_fan_remove,
  539. .shutdown = gpio_fan_shutdown,
  540. .driver = {
  541. .name = "gpio-fan",
  542. .pm = GPIO_FAN_PM,
  543. #ifdef CONFIG_OF_GPIO
  544. .of_match_table = of_match_ptr(of_gpio_fan_match),
  545. #endif
  546. },
  547. };
  548. module_platform_driver(gpio_fan_driver);
  549. MODULE_AUTHOR("Simon Guinot <sguinot@lacie.com>");
  550. MODULE_DESCRIPTION("GPIO FAN driver");
  551. MODULE_LICENSE("GPL");
  552. MODULE_ALIAS("platform:gpio-fan");