gpio-fan.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  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. int r;
  328. if (!fan_data)
  329. return -EINVAL;
  330. r = get_fan_speed_index(fan_data);
  331. if (r < 0)
  332. return r;
  333. *state = r;
  334. return 0;
  335. }
  336. static int gpio_fan_set_cur_state(struct thermal_cooling_device *cdev,
  337. unsigned long state)
  338. {
  339. struct gpio_fan_data *fan_data = cdev->devdata;
  340. if (!fan_data)
  341. return -EINVAL;
  342. set_fan_speed(fan_data, state);
  343. return 0;
  344. }
  345. static const struct thermal_cooling_device_ops gpio_fan_cool_ops = {
  346. .get_max_state = gpio_fan_get_max_state,
  347. .get_cur_state = gpio_fan_get_cur_state,
  348. .set_cur_state = gpio_fan_set_cur_state,
  349. };
  350. #ifdef CONFIG_OF_GPIO
  351. /*
  352. * Translate OpenFirmware node properties into platform_data
  353. */
  354. static int gpio_fan_get_of_pdata(struct device *dev,
  355. struct gpio_fan_platform_data *pdata)
  356. {
  357. struct device_node *node;
  358. struct gpio_fan_speed *speed;
  359. unsigned *ctrl;
  360. unsigned i;
  361. u32 u;
  362. struct property *prop;
  363. const __be32 *p;
  364. node = dev->of_node;
  365. /* Alarm GPIO if one exists */
  366. if (of_gpio_named_count(node, "alarm-gpios") > 0) {
  367. struct gpio_fan_alarm *alarm;
  368. int val;
  369. enum of_gpio_flags flags;
  370. alarm = devm_kzalloc(dev, sizeof(struct gpio_fan_alarm),
  371. GFP_KERNEL);
  372. if (!alarm)
  373. return -ENOMEM;
  374. val = of_get_named_gpio_flags(node, "alarm-gpios", 0, &flags);
  375. if (val < 0)
  376. return val;
  377. alarm->gpio = val;
  378. alarm->active_low = flags & OF_GPIO_ACTIVE_LOW;
  379. pdata->alarm = alarm;
  380. }
  381. /* Fill GPIO pin array */
  382. pdata->num_ctrl = of_gpio_count(node);
  383. if (pdata->num_ctrl <= 0) {
  384. if (pdata->alarm)
  385. return 0;
  386. dev_err(dev, "DT properties empty / missing");
  387. return -ENODEV;
  388. }
  389. ctrl = devm_kzalloc(dev, pdata->num_ctrl * sizeof(unsigned),
  390. GFP_KERNEL);
  391. if (!ctrl)
  392. return -ENOMEM;
  393. for (i = 0; i < pdata->num_ctrl; i++) {
  394. int val;
  395. val = of_get_gpio(node, i);
  396. if (val < 0)
  397. return val;
  398. ctrl[i] = val;
  399. }
  400. pdata->ctrl = ctrl;
  401. /* Get number of RPM/ctrl_val pairs in speed map */
  402. prop = of_find_property(node, "gpio-fan,speed-map", &i);
  403. if (!prop) {
  404. dev_err(dev, "gpio-fan,speed-map DT property missing");
  405. return -ENODEV;
  406. }
  407. i = i / sizeof(u32);
  408. if (i == 0 || i & 1) {
  409. dev_err(dev, "gpio-fan,speed-map contains zero/odd number of entries");
  410. return -ENODEV;
  411. }
  412. pdata->num_speed = i / 2;
  413. /*
  414. * Populate speed map
  415. * Speed map is in the form <RPM ctrl_val RPM ctrl_val ...>
  416. * this needs splitting into pairs to create gpio_fan_speed structs
  417. */
  418. speed = devm_kzalloc(dev,
  419. pdata->num_speed * sizeof(struct gpio_fan_speed),
  420. GFP_KERNEL);
  421. if (!speed)
  422. return -ENOMEM;
  423. p = NULL;
  424. for (i = 0; i < pdata->num_speed; i++) {
  425. p = of_prop_next_u32(prop, p, &u);
  426. if (!p)
  427. return -ENODEV;
  428. speed[i].rpm = u;
  429. p = of_prop_next_u32(prop, p, &u);
  430. if (!p)
  431. return -ENODEV;
  432. speed[i].ctrl_val = u;
  433. }
  434. pdata->speed = speed;
  435. return 0;
  436. }
  437. static const struct of_device_id of_gpio_fan_match[] = {
  438. { .compatible = "gpio-fan", },
  439. {},
  440. };
  441. #endif /* CONFIG_OF_GPIO */
  442. static int gpio_fan_probe(struct platform_device *pdev)
  443. {
  444. int err;
  445. struct gpio_fan_data *fan_data;
  446. struct gpio_fan_platform_data *pdata = dev_get_platdata(&pdev->dev);
  447. fan_data = devm_kzalloc(&pdev->dev, sizeof(struct gpio_fan_data),
  448. GFP_KERNEL);
  449. if (!fan_data)
  450. return -ENOMEM;
  451. #ifdef CONFIG_OF_GPIO
  452. if (!pdata) {
  453. pdata = devm_kzalloc(&pdev->dev,
  454. sizeof(struct gpio_fan_platform_data),
  455. GFP_KERNEL);
  456. if (!pdata)
  457. return -ENOMEM;
  458. err = gpio_fan_get_of_pdata(&pdev->dev, pdata);
  459. if (err)
  460. return err;
  461. }
  462. #else /* CONFIG_OF_GPIO */
  463. if (!pdata)
  464. return -EINVAL;
  465. #endif /* CONFIG_OF_GPIO */
  466. fan_data->pdev = pdev;
  467. platform_set_drvdata(pdev, fan_data);
  468. mutex_init(&fan_data->lock);
  469. /* Configure alarm GPIO if available. */
  470. if (pdata->alarm) {
  471. err = fan_alarm_init(fan_data, pdata->alarm);
  472. if (err)
  473. return err;
  474. }
  475. /* Configure control GPIOs if available. */
  476. if (pdata->ctrl && pdata->num_ctrl > 0) {
  477. if (!pdata->speed || pdata->num_speed <= 1)
  478. return -EINVAL;
  479. err = fan_ctrl_init(fan_data, pdata);
  480. if (err)
  481. return err;
  482. }
  483. /* Make this driver part of hwmon class. */
  484. fan_data->hwmon_dev =
  485. devm_hwmon_device_register_with_groups(&pdev->dev,
  486. "gpio_fan", fan_data,
  487. gpio_fan_groups);
  488. if (IS_ERR(fan_data->hwmon_dev))
  489. return PTR_ERR(fan_data->hwmon_dev);
  490. #ifdef CONFIG_OF_GPIO
  491. /* Optional cooling device register for Device tree platforms */
  492. fan_data->cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
  493. "gpio-fan",
  494. fan_data,
  495. &gpio_fan_cool_ops);
  496. #else /* CONFIG_OF_GPIO */
  497. /* Optional cooling device register for non Device tree platforms */
  498. fan_data->cdev = thermal_cooling_device_register("gpio-fan", fan_data,
  499. &gpio_fan_cool_ops);
  500. #endif /* CONFIG_OF_GPIO */
  501. dev_info(&pdev->dev, "GPIO fan initialized\n");
  502. return 0;
  503. }
  504. static int gpio_fan_remove(struct platform_device *pdev)
  505. {
  506. struct gpio_fan_data *fan_data = platform_get_drvdata(pdev);
  507. if (!IS_ERR(fan_data->cdev))
  508. thermal_cooling_device_unregister(fan_data->cdev);
  509. if (fan_data->ctrl)
  510. set_fan_speed(fan_data, 0);
  511. return 0;
  512. }
  513. static void gpio_fan_shutdown(struct platform_device *pdev)
  514. {
  515. gpio_fan_remove(pdev);
  516. }
  517. #ifdef CONFIG_PM_SLEEP
  518. static int gpio_fan_suspend(struct device *dev)
  519. {
  520. struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
  521. if (fan_data->ctrl) {
  522. fan_data->resume_speed = fan_data->speed_index;
  523. set_fan_speed(fan_data, 0);
  524. }
  525. return 0;
  526. }
  527. static int gpio_fan_resume(struct device *dev)
  528. {
  529. struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
  530. if (fan_data->ctrl)
  531. set_fan_speed(fan_data, fan_data->resume_speed);
  532. return 0;
  533. }
  534. static SIMPLE_DEV_PM_OPS(gpio_fan_pm, gpio_fan_suspend, gpio_fan_resume);
  535. #define GPIO_FAN_PM (&gpio_fan_pm)
  536. #else
  537. #define GPIO_FAN_PM NULL
  538. #endif
  539. static struct platform_driver gpio_fan_driver = {
  540. .probe = gpio_fan_probe,
  541. .remove = gpio_fan_remove,
  542. .shutdown = gpio_fan_shutdown,
  543. .driver = {
  544. .name = "gpio-fan",
  545. .pm = GPIO_FAN_PM,
  546. #ifdef CONFIG_OF_GPIO
  547. .of_match_table = of_match_ptr(of_gpio_fan_match),
  548. #endif
  549. },
  550. };
  551. module_platform_driver(gpio_fan_driver);
  552. MODULE_AUTHOR("Simon Guinot <sguinot@lacie.com>");
  553. MODULE_DESCRIPTION("GPIO FAN driver");
  554. MODULE_LICENSE("GPL");
  555. MODULE_ALIAS("platform:gpio-fan");