Source
static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, alarm, DS620_REG_CONFIG_TLF);
/*
* ds620.c - Support for temperature sensor and thermostat DS620
*
* Copyright (C) 2010, 2011 Roland Stigge <stigge@antcom.de>
*
* based on ds1621.c by Christian W. Zuckschwerdt <zany@triq.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Many DS620 constants specified below
* 15 14 13 12 11 10 09 08
* |Done|NVB |THF |TLF |R1 |R0 |AUTOC|1SHOT|
*
* 07 06 05 04 03 02 01 00
* |PO2 |PO1 |A2 |A1 |A0 | | | |
*/
/* The DS620 registers */
static const u8 DS620_REG_TEMP[3] = {
0xAA, /* input, word, RO */
0xA2, /* min, word, RW */
0xA0, /* max, word, RW */
};
/* word, RW */
/* no data */
/* no data */
/* Each client has this additional data */
struct ds620_data {
struct i2c_client *client;
struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
s16 temp[3]; /* Register values, word */
};
static void ds620_init_client(struct i2c_client *client)
{
struct ds620_platform_data *ds620_info = dev_get_platdata(&client->dev);
u16 conf, new_conf;
new_conf = conf =
i2c_smbus_read_word_swapped(client, DS620_REG_CONF);
/* switch to continuous conversion mode */
new_conf &= ~DS620_REG_CONFIG_1SHOT;
/* already high at power-on, but don't trust the BIOS! */
new_conf |= DS620_REG_CONFIG_PO2;
/* thermostat mode according to platform data */
if (ds620_info && ds620_info->pomode == 1)
new_conf &= ~DS620_REG_CONFIG_PO1; /* PO_LOW */