Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47064d64 authored by Ben Hutchings's avatar Ben Hutchings Committed by Jean Delvare
Browse files

hwmon: (lm87) Add support for configuration through platform_data



The lm87 driver normally assumes that firmware configured the chip
correctly.  Since this is not always the case, alllow platform code to
set the channel register value via platform_data.  All other
configuration registers can be changed after driver initialisation.

Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
parent d2cac802
Loading
Loading
Loading
Loading
+4 −5
Original line number Original line Diff line number Diff line
@@ -65,11 +65,10 @@ The LM87 has four pins which can serve one of two possible functions,
depending on the hardware configuration.
depending on the hardware configuration.


Some functions share pins, so not all functions are available at the same
Some functions share pins, so not all functions are available at the same
time. Which are depends on the hardware setup. This driver assumes that
time. Which are depends on the hardware setup. This driver normally
the BIOS configured the chip correctly. In that respect, it differs from
assumes that firmware configured the chip correctly. Where this is not
the original driver (from lm_sensors for Linux 2.4), which would force the
the case, platform code must set the I2C client's platform_data to point
LM87 to an arbitrary, compile-time chosen mode, regardless of the actual
to a u8 value to be written to the channel register.
chipset wiring.


For reference, here is the list of exclusive functions:
For reference, here is the list of exclusive functions:
 - in0+in5 (default) or temp3
 - in0+in5 (default) or temp3
+11 −6
Original line number Original line Diff line number Diff line
@@ -21,11 +21,10 @@
 *   http://www.national.com/pf/LM/LM87.html
 *   http://www.national.com/pf/LM/LM87.html
 *
 *
 * Some functions share pins, so not all functions are available at the same
 * Some functions share pins, so not all functions are available at the same
 * time. Which are depends on the hardware setup. This driver assumes that
 * time. Which are depends on the hardware setup. This driver normally
 * the BIOS configured the chip correctly. In that respect, it  differs from
 * assumes that firmware configured the chip correctly. Where this is not
 * the original driver (from lm_sensors for Linux 2.4), which would force the
 * the case, platform code must set the I2C client's platform_data to point
 * LM87 to an arbitrary, compile-time chosen mode, regardless of the actual
 * to a u8 value to be written to the channel register.
 * chipset wiring.
 * For reference, here is the list of exclusive functions:
 * For reference, here is the list of exclusive functions:
 *  - in0+in5 (default) or temp3
 *  - in0+in5 (default) or temp3
 *  - fan1 (default) or in6
 *  - fan1 (default) or in6
@@ -843,7 +842,13 @@ static void lm87_init_client(struct i2c_client *client)
{
{
	struct lm87_data *data = i2c_get_clientdata(client);
	struct lm87_data *data = i2c_get_clientdata(client);


	if (client->dev.platform_data) {
		data->channel = *(u8 *)client->dev.platform_data;
		lm87_write_value(client,
				 LM87_REG_CHANNEL_MODE, data->channel);
	} else {
		data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE);
		data->channel = lm87_read_value(client, LM87_REG_CHANNEL_MODE);
	}
	data->config = lm87_read_value(client, LM87_REG_CONFIG) & 0x6F;
	data->config = lm87_read_value(client, LM87_REG_CONFIG) & 0x6F;


	if (!(data->config & 0x01)) {
	if (!(data->config & 0x01)) {