#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/platform_device.h>
#include <linux/err.h>
#include <linux/kstrtox.h>
#include <linux/mutex.h>
#include <linux/hwmon.h>
#include <linux/gpio/consumer.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/thermal.h>
struct gpio_fan_speed { … };
struct gpio_fan_data { … };
static void fan_alarm_notify(struct work_struct *ws)
{ … }
static irqreturn_t fan_alarm_irq_handler(int irq, void *dev_id)
{ … }
static ssize_t fan1_alarm_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static DEVICE_ATTR_RO(fan1_alarm);
static int fan_alarm_init(struct gpio_fan_data *fan_data)
{ … }
static void __set_fan_ctrl(struct gpio_fan_data *fan_data, int ctrl_val)
{ … }
static int __get_fan_ctrl(struct gpio_fan_data *fan_data)
{ … }
static void set_fan_speed(struct gpio_fan_data *fan_data, int speed_index)
{ … }
static int get_fan_speed_index(struct gpio_fan_data *fan_data)
{ … }
static int rpm_to_speed_index(struct gpio_fan_data *fan_data, unsigned long rpm)
{ … }
static ssize_t pwm1_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t pwm1_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t pwm1_enable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t pwm1_enable_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t pwm1_mode_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t fan1_min_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t fan1_max_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t fan1_input_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t set_rpm(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(pwm1);
static DEVICE_ATTR_RW(pwm1_enable);
static DEVICE_ATTR_RO(pwm1_mode);
static DEVICE_ATTR_RO(fan1_min);
static DEVICE_ATTR_RO(fan1_max);
static DEVICE_ATTR_RO(fan1_input);
static DEVICE_ATTR(fan1_target, 0644, fan1_input_show, set_rpm);
static umode_t gpio_fan_is_visible(struct kobject *kobj,
struct attribute *attr, int index)
{ … }
static struct attribute *gpio_fan_attributes[] = …;
static const struct attribute_group gpio_fan_group = …;
static const struct attribute_group *gpio_fan_groups[] = …;
static int fan_ctrl_init(struct gpio_fan_data *fan_data)
{ … }
static int gpio_fan_get_max_state(struct thermal_cooling_device *cdev,
unsigned long *state)
{ … }
static int gpio_fan_get_cur_state(struct thermal_cooling_device *cdev,
unsigned long *state)
{ … }
static int gpio_fan_set_cur_state(struct thermal_cooling_device *cdev,
unsigned long state)
{ … }
static const struct thermal_cooling_device_ops gpio_fan_cool_ops = …;
static int gpio_fan_get_of_data(struct gpio_fan_data *fan_data)
{ … }
static const struct of_device_id of_gpio_fan_match[] = …;
MODULE_DEVICE_TABLE(of, of_gpio_fan_match);
static void gpio_fan_stop(void *data)
{ … }
static int gpio_fan_probe(struct platform_device *pdev)
{ … }
static void gpio_fan_shutdown(struct platform_device *pdev)
{ … }
static int gpio_fan_suspend(struct device *dev)
{ … }
static int gpio_fan_resume(struct device *dev)
{ … }
static DEFINE_SIMPLE_DEV_PM_OPS(gpio_fan_pm, gpio_fan_suspend, gpio_fan_resume);
static struct platform_driver gpio_fan_driver = …;
module_platform_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
MODULE_ALIAS(…) …;