1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Copyright (C) ST-Ericsson 2010 - 2013 4*4882a593Smuzhiyun * Author: Martin Persson <martin.persson@stericsson.com> 5*4882a593Smuzhiyun * Hongbo Zhang <hongbo.zhang@linaro.com> 6*4882a593Smuzhiyun */ 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun #ifndef _ABX500_H 9*4882a593Smuzhiyun #define _ABX500_H 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun #define NUM_SENSORS 5 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun struct abx500_temp; 14*4882a593Smuzhiyun 15*4882a593Smuzhiyun /* 16*4882a593Smuzhiyun * struct abx500_temp_ops - abx500 chip specific ops 17*4882a593Smuzhiyun * @read_sensor: reads gpadc output 18*4882a593Smuzhiyun * @irq_handler: irq handler 19*4882a593Smuzhiyun * @show_name: hwmon device name 20*4882a593Smuzhiyun * @show_label: hwmon attribute label 21*4882a593Smuzhiyun * @is_visible: is attribute visible 22*4882a593Smuzhiyun */ 23*4882a593Smuzhiyun struct abx500_temp_ops { 24*4882a593Smuzhiyun int (*read_sensor)(struct abx500_temp *, u8, int *); 25*4882a593Smuzhiyun int (*irq_handler)(int, struct abx500_temp *); 26*4882a593Smuzhiyun ssize_t (*show_name)(struct device *, 27*4882a593Smuzhiyun struct device_attribute *, char *); 28*4882a593Smuzhiyun ssize_t (*show_label) (struct device *, 29*4882a593Smuzhiyun struct device_attribute *, char *); 30*4882a593Smuzhiyun int (*is_visible)(struct attribute *, int); 31*4882a593Smuzhiyun }; 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun /* 34*4882a593Smuzhiyun * struct abx500_temp - representation of temp mon device 35*4882a593Smuzhiyun * @pdev: platform device 36*4882a593Smuzhiyun * @hwmon_dev: hwmon device 37*4882a593Smuzhiyun * @ops: abx500 chip specific ops 38*4882a593Smuzhiyun * @gpadc_addr: gpadc channel address 39*4882a593Smuzhiyun * @min: sensor temperature min value 40*4882a593Smuzhiyun * @max: sensor temperature max value 41*4882a593Smuzhiyun * @max_hyst: sensor temperature hysteresis value for max limit 42*4882a593Smuzhiyun * @min_alarm: sensor temperature min alarm 43*4882a593Smuzhiyun * @max_alarm: sensor temperature max alarm 44*4882a593Smuzhiyun * @work: delayed work scheduled to monitor temperature periodically 45*4882a593Smuzhiyun * @work_active: True if work is active 46*4882a593Smuzhiyun * @lock: mutex 47*4882a593Smuzhiyun * @monitored_sensors: number of monitored sensors 48*4882a593Smuzhiyun * @plat_data: private usage, usually points to platform specific data 49*4882a593Smuzhiyun */ 50*4882a593Smuzhiyun struct abx500_temp { 51*4882a593Smuzhiyun struct platform_device *pdev; 52*4882a593Smuzhiyun struct device *hwmon_dev; 53*4882a593Smuzhiyun struct abx500_temp_ops ops; 54*4882a593Smuzhiyun u8 gpadc_addr[NUM_SENSORS]; 55*4882a593Smuzhiyun unsigned long min[NUM_SENSORS]; 56*4882a593Smuzhiyun unsigned long max[NUM_SENSORS]; 57*4882a593Smuzhiyun unsigned long max_hyst[NUM_SENSORS]; 58*4882a593Smuzhiyun bool min_alarm[NUM_SENSORS]; 59*4882a593Smuzhiyun bool max_alarm[NUM_SENSORS]; 60*4882a593Smuzhiyun struct delayed_work work; 61*4882a593Smuzhiyun bool work_active; 62*4882a593Smuzhiyun struct mutex lock; 63*4882a593Smuzhiyun int monitored_sensors; 64*4882a593Smuzhiyun void *plat_data; 65*4882a593Smuzhiyun }; 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun int abx500_hwmon_init(struct abx500_temp *data); 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun #endif /* _ABX500_H */ 70