10bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang/* 20bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * Copyright (C) ST-Ericsson 2010 - 2013 30bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * License terms: GNU General Public License v2 40bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * Author: Martin Persson <martin.persson@stericsson.com> 50bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * Hongbo Zhang <hongbo.zhang@linaro.com> 60bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang */ 70bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang 80bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang#ifndef _ABX500_H 90bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang#define _ABX500_H 100bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang 110bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang#define NUM_SENSORS 5 120bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang 130bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhangstruct abx500_temp; 140bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang 150bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang/* 160bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * struct abx500_temp_ops - abx500 chip specific ops 170bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * @read_sensor: reads gpadc output 180bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * @irq_handler: irq handler 190bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * @show_name: hwmon device name 200bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * @show_label: hwmon attribute label 210bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * @is_visible: is attribute visible 220bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang */ 230bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhangstruct abx500_temp_ops { 240bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang int (*read_sensor)(struct abx500_temp *, u8, int *); 250bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang int (*irq_handler)(int, struct abx500_temp *); 260bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang ssize_t (*show_name)(struct device *, 270bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang struct device_attribute *, char *); 280bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang ssize_t (*show_label) (struct device *, 290bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang struct device_attribute *, char *); 300bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang int (*is_visible)(struct attribute *, int); 310bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang}; 320bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang 330bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang/* 340bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * struct abx500_temp - representation of temp mon device 350bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * @pdev: platform device 360bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * @hwmon_dev: hwmon device 370bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * @ops: abx500 chip specific ops 380bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * @gpadc_addr: gpadc channel address 390bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * @min: sensor temperature min value 400bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * @max: sensor temperature max value 410bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * @max_hyst: sensor temperature hysteresis value for max limit 420bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * @min_alarm: sensor temperature min alarm 430bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * @max_alarm: sensor temperature max alarm 440bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * @work: delayed work scheduled to monitor temperature periodically 450bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * @work_active: True if work is active 460bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * @lock: mutex 470bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * @monitored_sensors: number of monitored sensors 480bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang * @plat_data: private usage, usually points to platform specific data 490bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang */ 500bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhangstruct abx500_temp { 510bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang struct platform_device *pdev; 520bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang struct device *hwmon_dev; 530bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang struct abx500_temp_ops ops; 540bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang u8 gpadc_addr[NUM_SENSORS]; 550bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang unsigned long min[NUM_SENSORS]; 560bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang unsigned long max[NUM_SENSORS]; 570bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang unsigned long max_hyst[NUM_SENSORS]; 580bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang bool min_alarm[NUM_SENSORS]; 590bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang bool max_alarm[NUM_SENSORS]; 600bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang struct delayed_work work; 610bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang bool work_active; 620bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang struct mutex lock; 630bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang int monitored_sensors; 640bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang void *plat_data; 650bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang}; 660bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang 670bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhangint abx500_hwmon_init(struct abx500_temp *data); 680bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang 690bbb06ed564d211d10eae12bdb423fce6178468fHongbo Zhang#endif /* _ABX500_H */ 70