From 2740c60c4ab9a8c6169d7925014f57440361f698 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 26 Mar 2011 10:45:01 +0100 Subject: hwmon: (f71882fg) Secure chip property definition arrays Using C99-style array initialization will ensure definitions won't drift if the chips enum gets new values added. Signed-off-by: Jean Delvare Acked-by: Hans de Goede Acked-by: Guenter Roeck diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c index a4d430e..0f60b05 100644 --- a/drivers/hwmon/f71882fg.c +++ b/drivers/hwmon/f71882fg.c @@ -119,37 +119,37 @@ static const char *f71882fg_names[] = { "f8000", }; -static const char f71882fg_has_in[8][F71882FG_MAX_INS] = { - { 1, 1, 1, 1, 1, 1, 0, 1, 1 }, /* f71808e */ - { 1, 1, 1, 0, 0, 0, 0, 0, 0 }, /* f71858fg */ - { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* f71862fg */ - { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* f71869 */ - { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* f71882fg */ - { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* f71889fg */ - { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* f71889ed */ - { 1, 1, 1, 0, 0, 0, 0, 0, 0 }, /* f8000 */ +static const char f71882fg_has_in[][F71882FG_MAX_INS] = { + [f71808e] = { 1, 1, 1, 1, 1, 1, 0, 1, 1 }, + [f71858fg] = { 1, 1, 1, 0, 0, 0, 0, 0, 0 }, + [f71862fg] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + [f71869] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + [f71882fg] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + [f71889fg] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + [f71889ed] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + [f8000] = { 1, 1, 1, 0, 0, 0, 0, 0, 0 }, }; -static const char f71882fg_has_in1_alarm[8] = { - 0, /* f71808e */ - 0, /* f71858fg */ - 0, /* f71862fg */ - 0, /* f71869 */ - 1, /* f71882fg */ - 1, /* f71889fg */ - 1, /* f71889ed */ - 0, /* f8000 */ +static const char f71882fg_has_in1_alarm[] = { + [f71808e] = 0, + [f71858fg] = 0, + [f71862fg] = 0, + [f71869] = 0, + [f71882fg] = 1, + [f71889fg] = 1, + [f71889ed] = 1, + [f8000] = 0, }; -static const char f71882fg_has_beep[8] = { - 0, /* f71808e */ - 0, /* f71858fg */ - 1, /* f71862fg */ - 1, /* f71869 */ - 1, /* f71882fg */ - 1, /* f71889fg */ - 1, /* f71889ed */ - 0, /* f8000 */ +static const char f71882fg_has_beep[] = { + [f71808e] = 0, + [f71858fg] = 0, + [f71862fg] = 1, + [f71869] = 1, + [f71882fg] = 1, + [f71889fg] = 1, + [f71889ed] = 1, + [f8000] = 0, }; static struct platform_device *f71882fg_pdev; -- cgit v0.10.2 From f27def07bfb296d5eb441cd5777d351c7afcb4a1 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 26 Mar 2011 10:45:01 +0100 Subject: hwmon: (f71882fg) Per-chip fan/temperature input count tables Use tables to list the count of fan and temperature inputs for all supported chips, almost similar to (but more simple than) what is already done for voltage inputs. This avoids repeating the same tests in different functions, and will make it easier to add support for chips with a different count of fan or temperature inputs. Signed-off-by: Jean Delvare Acked-by: Hans de Goede Acked-by: Guenter Roeck diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c index 0f60b05..222c7f4 100644 --- a/drivers/hwmon/f71882fg.c +++ b/drivers/hwmon/f71882fg.c @@ -152,6 +152,28 @@ static const char f71882fg_has_beep[] = { [f8000] = 0, }; +static const char f71882fg_nr_fans[] = { + [f71808e] = 3, + [f71858fg] = 3, + [f71862fg] = 3, + [f71869] = 3, + [f71882fg] = 4, + [f71889fg] = 3, + [f71889ed] = 3, + [f8000] = 3, +}; + +static const char f71882fg_nr_temps[] = { + [f71808e] = 2, + [f71858fg] = 3, + [f71862fg] = 3, + [f71869] = 3, + [f71882fg] = 3, + [f71889fg] = 3, + [f71889ed] = 3, + [f8000] = 3, +}; + static struct platform_device *f71882fg_pdev; /* Super-I/O Function prototypes */ @@ -1071,9 +1093,9 @@ static u16 f71882fg_read_temp(struct f71882fg_data *data, int nr) static struct f71882fg_data *f71882fg_update_device(struct device *dev) { struct f71882fg_data *data = dev_get_drvdata(dev); + int nr_fans = f71882fg_nr_fans[data->type]; + int nr_temps = f71882fg_nr_temps[data->type]; int nr, reg, point; - int nr_fans = (data->type == f71882fg) ? 4 : 3; - int nr_temps = (data->type == f71808e) ? 2 : 3; mutex_lock(&data->update_lock); @@ -2042,8 +2064,9 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) { struct f71882fg_data *data; struct f71882fg_sio_data *sio_data = pdev->dev.platform_data; - int err, i, nr_fans = (sio_data->type == f71882fg) ? 4 : 3; - int nr_temps = (sio_data->type == f71808e) ? 2 : 3; + int nr_fans = f71882fg_nr_fans[sio_data->type]; + int nr_temps = f71882fg_nr_temps[sio_data->type]; + int err, i; u8 start_reg, reg; data = kzalloc(sizeof(struct f71882fg_data), GFP_KERNEL); @@ -2276,8 +2299,9 @@ exit_free: static int f71882fg_remove(struct platform_device *pdev) { struct f71882fg_data *data = platform_get_drvdata(pdev); - int i, nr_fans = (data->type == f71882fg) ? 4 : 3; - int nr_temps = (data->type == f71808e) ? 2 : 3; + int nr_fans = f71882fg_nr_fans[data->type]; + int nr_temps = f71882fg_nr_temps[data->type]; + int i; u8 start_reg = f71882fg_read8(data, F71882FG_REG_START); if (data->hwmon_dev) -- cgit v0.10.2 From 5d7f77bf66bfa986754b3e12073bef0ab8cd61bd Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 26 Mar 2011 10:45:02 +0100 Subject: hwmon: (f71882fg) Document all supported devices The list of supported devices was not always well documented in all places. Clarify and list all devices in documentation, Kconfig and the driver itself. Signed-off-by: Jean Delvare Acked-by: Hans de Goede Acked-by: Guenter Roeck diff --git a/Documentation/hwmon/f71882fg b/Documentation/hwmon/f71882fg index 4d0bc70..ed2a7aa 100644 --- a/Documentation/hwmon/f71882fg +++ b/Documentation/hwmon/f71882fg @@ -2,6 +2,10 @@ Kernel driver f71882fg ====================== Supported chips: + * Fintek F71808E + Prefix: 'f71808e' + Addresses scanned: none, address read from Super I/O config space + Datasheet: Not public * Fintek F71858FG Prefix: 'f71858fg' Addresses scanned: none, address read from Super I/O config space @@ -30,6 +34,13 @@ Supported chips: Prefix: 'f8000' Addresses scanned: none, address read from Super I/O config space Datasheet: Not public + * Fintek F81801U + Prefix: 'f71889fg' + Addresses scanned: none, address read from Super I/O config space + Datasheet: Not public + Note: This is the 64-pin variant of the F71889FG, they have the + same device ID and are fully compatible as far as hardware + monitoring is concerned. Author: Hans de Goede diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 81131ed..51255b3 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -315,11 +315,21 @@ config SENSORS_F71805F will be called f71805f. config SENSORS_F71882FG - tristate "Fintek F71858FG, F71862FG, F71882FG, F71889FG and F8000" + tristate "Fintek F71882FG and compatibles" help If you say yes here you get support for hardware monitoring - features of the Fintek F71858FG, F71862FG/71863FG, F71882FG/F71883FG, - F71889FG and F8000 Super-I/O chips. + features of many Fintek Super-I/O (LPC) chips. The currently + supported chips are: + F71808E + F71858FG + F71862FG + F71863FG + F71869F/E + F71882FG + F71883FG + F71889FG/ED + F8000 + F81801U This driver can also be built as a module. If so, the module will be called f71882fg. diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c index 222c7f4..2987904 100644 --- a/drivers/hwmon/f71882fg.c +++ b/drivers/hwmon/f71882fg.c @@ -114,7 +114,7 @@ static const char *f71882fg_names[] = { "f71862fg", "f71869", /* Both f71869f and f71869e, reg. compatible and same id */ "f71882fg", - "f71889fg", + "f71889fg", /* f81801u too, same id */ "f71889ed", "f8000", }; -- cgit v0.10.2 From 383586b12d89ba4297c49898645658cdb324b918 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 26 Mar 2011 10:45:02 +0100 Subject: hwmon: (f71882fg) Add support for the F81865F Add support for the Fintek F81865F. It's essentially compatible with the F71882FG, but has fewer inputs: 7 voltage, 2 temperature and 2 fan inputs only. Signed-off-by: Jean Delvare Acked-by: Hans de Goede Acked-by: Guenter Roeck diff --git a/Documentation/hwmon/f71882fg b/Documentation/hwmon/f71882fg index ed2a7aa..b802a22 100644 --- a/Documentation/hwmon/f71882fg +++ b/Documentation/hwmon/f71882fg @@ -41,6 +41,10 @@ Supported chips: Note: This is the 64-pin variant of the F71889FG, they have the same device ID and are fully compatible as far as hardware monitoring is concerned. + * Fintek F81865F + Prefix: 'f81865f' + Addresses scanned: none, address read from Super I/O config space + Datasheet: Available from the Fintek website Author: Hans de Goede diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 51255b3..df9944b 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -330,6 +330,7 @@ config SENSORS_F71882FG F71889FG/ED F8000 F81801U + F81865F This driver can also be built as a module. If so, the module will be called f71882fg. diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c index 2987904..aa8cf5d 100644 --- a/drivers/hwmon/f71882fg.c +++ b/drivers/hwmon/f71882fg.c @@ -55,6 +55,7 @@ #define SIO_F71889_ID 0x0723 /* Chipset ID */ #define SIO_F71889E_ID 0x0909 /* Chipset ID */ #define SIO_F8000_ID 0x0581 /* Chipset ID */ +#define SIO_F81865_ID 0x0704 /* Chipset ID */ #define REGION_LENGTH 8 #define ADDR_REG_OFFSET 5 @@ -106,7 +107,7 @@ module_param(force_id, ushort, 0); MODULE_PARM_DESC(force_id, "Override the detected device ID"); enum chips { f71808e, f71858fg, f71862fg, f71869, f71882fg, f71889fg, - f71889ed, f8000 }; + f71889ed, f8000, f81865f }; static const char *f71882fg_names[] = { "f71808e", @@ -117,6 +118,7 @@ static const char *f71882fg_names[] = { "f71889fg", /* f81801u too, same id */ "f71889ed", "f8000", + "f81865f", }; static const char f71882fg_has_in[][F71882FG_MAX_INS] = { @@ -128,6 +130,7 @@ static const char f71882fg_has_in[][F71882FG_MAX_INS] = { [f71889fg] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, [f71889ed] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, [f8000] = { 1, 1, 1, 0, 0, 0, 0, 0, 0 }, + [f81865f] = { 1, 1, 1, 1, 1, 1, 1, 0, 0 }, }; static const char f71882fg_has_in1_alarm[] = { @@ -139,6 +142,7 @@ static const char f71882fg_has_in1_alarm[] = { [f71889fg] = 1, [f71889ed] = 1, [f8000] = 0, + [f81865f] = 1, }; static const char f71882fg_has_beep[] = { @@ -150,6 +154,7 @@ static const char f71882fg_has_beep[] = { [f71889fg] = 1, [f71889ed] = 1, [f8000] = 0, + [f81865f] = 1, }; static const char f71882fg_nr_fans[] = { @@ -161,6 +166,7 @@ static const char f71882fg_nr_fans[] = { [f71889fg] = 3, [f71889ed] = 3, [f8000] = 3, + [f81865f] = 2, }; static const char f71882fg_nr_temps[] = { @@ -172,6 +178,7 @@ static const char f71882fg_nr_temps[] = { [f71889fg] = 3, [f71889ed] = 3, [f8000] = 3, + [f81865f] = 2, }; static struct platform_device *f71882fg_pdev; @@ -2186,16 +2193,12 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) case f71862fg: err = (data->pwm_enable & 0x15) != 0x15; break; - case f71808e: - case f71869: - case f71882fg: - case f71889fg: - case f71889ed: - err = 0; - break; case f8000: err = data->pwm_enable & 0x20; break; + default: + err = 0; + break; } if (err) { dev_err(&pdev->dev, @@ -2433,6 +2436,9 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address, case SIO_F8000_ID: sio_data->type = f8000; break; + case SIO_F81865_ID: + sio_data->type = f81865f; + break; default: pr_info("Unsupported Fintek device: %04x\n", (unsigned int)devid); -- cgit v0.10.2 From a66c10887ad2a99e172111cc94087ba4bed8fa92 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 26 Mar 2011 10:45:02 +0100 Subject: hwmon: (f71882fg) Add support for the F71889A Signed-off-by: Hans de Goede Acked-by: Guenter Roeck Signed-off-by: Jean Delvare diff --git a/Documentation/hwmon/f71882fg b/Documentation/hwmon/f71882fg index b802a22..df02245 100644 --- a/Documentation/hwmon/f71882fg +++ b/Documentation/hwmon/f71882fg @@ -30,6 +30,10 @@ Supported chips: Prefix: 'f71889ed' Addresses scanned: none, address read from Super I/O config space Datasheet: Should become available on the Fintek website soon + * Fintek F71889A + Prefix: 'f71889a' + Addresses scanned: none, address read from Super I/O config space + Datasheet: Should become available on the Fintek website soon * Fintek F8000 Prefix: 'f8000' Addresses scanned: none, address read from Super I/O config space diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index df9944b..060ef63 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -327,7 +327,7 @@ config SENSORS_F71882FG F71869F/E F71882FG F71883FG - F71889FG/ED + F71889FG/ED/A F8000 F81801U F81865F diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c index aa8cf5d..ca07a32 100644 --- a/drivers/hwmon/f71882fg.c +++ b/drivers/hwmon/f71882fg.c @@ -54,6 +54,7 @@ #define SIO_F71882_ID 0x0541 /* Chipset ID */ #define SIO_F71889_ID 0x0723 /* Chipset ID */ #define SIO_F71889E_ID 0x0909 /* Chipset ID */ +#define SIO_F71889A_ID 0x1005 /* Chipset ID */ #define SIO_F8000_ID 0x0581 /* Chipset ID */ #define SIO_F81865_ID 0x0704 /* Chipset ID */ @@ -107,7 +108,7 @@ module_param(force_id, ushort, 0); MODULE_PARM_DESC(force_id, "Override the detected device ID"); enum chips { f71808e, f71858fg, f71862fg, f71869, f71882fg, f71889fg, - f71889ed, f8000, f81865f }; + f71889ed, f71889a, f8000, f81865f }; static const char *f71882fg_names[] = { "f71808e", @@ -117,6 +118,7 @@ static const char *f71882fg_names[] = { "f71882fg", "f71889fg", /* f81801u too, same id */ "f71889ed", + "f71889a", "f8000", "f81865f", }; @@ -129,6 +131,7 @@ static const char f71882fg_has_in[][F71882FG_MAX_INS] = { [f71882fg] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, [f71889fg] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, [f71889ed] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + [f71889a] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, [f8000] = { 1, 1, 1, 0, 0, 0, 0, 0, 0 }, [f81865f] = { 1, 1, 1, 1, 1, 1, 1, 0, 0 }, }; @@ -141,6 +144,7 @@ static const char f71882fg_has_in1_alarm[] = { [f71882fg] = 1, [f71889fg] = 1, [f71889ed] = 1, + [f71889a] = 1, [f8000] = 0, [f81865f] = 1, }; @@ -153,6 +157,7 @@ static const char f71882fg_has_beep[] = { [f71882fg] = 1, [f71889fg] = 1, [f71889ed] = 1, + [f71889a] = 1, [f8000] = 0, [f81865f] = 1, }; @@ -165,6 +170,7 @@ static const char f71882fg_nr_fans[] = { [f71882fg] = 4, [f71889fg] = 3, [f71889ed] = 3, + [f71889a] = 3, [f8000] = 3, [f81865f] = 2, }; @@ -177,6 +183,7 @@ static const char f71882fg_nr_temps[] = { [f71882fg] = 3, [f71889fg] = 3, [f71889ed] = 3, + [f71889a] = 3, [f8000] = 3, [f81865f] = 2, }; @@ -2168,6 +2175,7 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) /* Fall through to select correct fan/pwm reg bank! */ case f71889fg: case f71889ed: + case f71889a: reg = f71882fg_read8(data, F71882FG_REG_FAN_FAULT_T); if (reg & F71882FG_FAN_NEG_TEMP_EN) data->auto_point_temp_signed = 1; @@ -2225,6 +2233,7 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) case f71869: case f71889fg: case f71889ed: + case f71889a: for (i = 0; i < nr_fans; i++) { data->pwm_auto_point_mapping[i] = f71882fg_read8(data, @@ -2433,6 +2442,9 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address, case SIO_F71889E_ID: sio_data->type = f71889ed; break; + case SIO_F71889A_ID: + sio_data->type = f71889a; + break; case SIO_F8000_ID: sio_data->type = f8000; break; -- cgit v0.10.2