X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fhwmon%2Fabituguru3.c;h=d568c65c137089a1f6402237404c80bb1d402dc1;hb=4777e4e6b8540ee4226876a737833d03bbc55394;hp=f00f497b9ca9b38ed615a17955d42da607601214;hpb=6924d1ab8b7bbe5ab416713f5701b3316b2df85b;p=linux-2.6-omap-h63xx.git diff --git a/drivers/hwmon/abituguru3.c b/drivers/hwmon/abituguru3.c index f00f497b9ca..c28cd6ca372 100644 --- a/drivers/hwmon/abituguru3.c +++ b/drivers/hwmon/abituguru3.c @@ -1,5 +1,8 @@ /* - abituguru3.c Copyright (c) 2006 Hans de Goede + abituguru3.c + + Copyright (c) 2006-2008 Hans de Goede + Copyright (c) 2008 Alistair John Strachan 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 @@ -116,7 +119,7 @@ struct abituguru3_sensor_info { struct abituguru3_motherboard_info { u16 id; - const char *name; + const char *dmi_name; /* + 1 -> end of sensors indicated by a sensor with name == NULL */ struct abituguru3_sensor_info sensors[ABIT_UGURU3_MAX_NO_SENSORS + 1]; }; @@ -161,7 +164,7 @@ struct abituguru3_data { /* Constants */ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { - { 0x000C, "unknown", { + { 0x000C, NULL /* Unknown, need DMI string */, { { "CPU Core", 0, 0, 10, 1, 0 }, { "DDR", 1, 0, 10, 1, 0 }, { "DDR VTT", 2, 0, 10, 1, 0 }, @@ -175,7 +178,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "+3.3V", 10, 0, 20, 1, 0 }, { "5VSB", 11, 0, 30, 1, 0 }, { "CPU", 24, 1, 1, 1, 0 }, - { "System ", 25, 1, 1, 1, 0 }, + { "System", 25, 1, 1, 1, 0 }, { "PWM", 26, 1, 1, 1, 0 }, { "CPU Fan", 32, 2, 60, 1, 0 }, { "NB Fan", 33, 2, 60, 1, 0 }, @@ -183,7 +186,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "AUX1 Fan", 35, 2, 60, 1, 0 }, { NULL, 0, 0, 0, 0, 0 } } }, - { 0x000D, "Abit AW8", { + { 0x000D, NULL /* Abit AW8, need DMI string */, { { "CPU Core", 0, 0, 10, 1, 0 }, { "DDR", 1, 0, 10, 1, 0 }, { "DDR VTT", 2, 0, 10, 1, 0 }, @@ -197,7 +200,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "+3.3V", 10, 0, 20, 1, 0 }, { "5VSB", 11, 0, 30, 1, 0 }, { "CPU", 24, 1, 1, 1, 0 }, - { "System ", 25, 1, 1, 1, 0 }, + { "System", 25, 1, 1, 1, 0 }, { "PWM1", 26, 1, 1, 1, 0 }, { "PWM2", 27, 1, 1, 1, 0 }, { "PWM3", 28, 1, 1, 1, 0 }, @@ -212,7 +215,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "AUX5 Fan", 39, 2, 60, 1, 0 }, { NULL, 0, 0, 0, 0, 0 } } }, - { 0x000E, "AL-8", { + { 0x000E, NULL /* AL-8, need DMI string */, { { "CPU Core", 0, 0, 10, 1, 0 }, { "DDR", 1, 0, 10, 1, 0 }, { "DDR VTT", 2, 0, 10, 1, 0 }, @@ -226,14 +229,14 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "+3.3V", 10, 0, 20, 1, 0 }, { "5VSB", 11, 0, 30, 1, 0 }, { "CPU", 24, 1, 1, 1, 0 }, - { "System ", 25, 1, 1, 1, 0 }, + { "System", 25, 1, 1, 1, 0 }, { "PWM", 26, 1, 1, 1, 0 }, { "CPU Fan", 32, 2, 60, 1, 0 }, { "NB Fan", 33, 2, 60, 1, 0 }, { "SYS Fan", 34, 2, 60, 1, 0 }, { NULL, 0, 0, 0, 0, 0 } } }, - { 0x000F, "unknown", { + { 0x000F, NULL /* Unknown, need DMI string */, { { "CPU Core", 0, 0, 10, 1, 0 }, { "DDR", 1, 0, 10, 1, 0 }, { "DDR VTT", 2, 0, 10, 1, 0 }, @@ -247,14 +250,14 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "+3.3V", 10, 0, 20, 1, 0 }, { "5VSB", 11, 0, 30, 1, 0 }, { "CPU", 24, 1, 1, 1, 0 }, - { "System ", 25, 1, 1, 1, 0 }, + { "System", 25, 1, 1, 1, 0 }, { "PWM", 26, 1, 1, 1, 0 }, { "CPU Fan", 32, 2, 60, 1, 0 }, { "NB Fan", 33, 2, 60, 1, 0 }, { "SYS Fan", 34, 2, 60, 1, 0 }, { NULL, 0, 0, 0, 0, 0 } } }, - { 0x0010, "Abit NI8 SLI GR", { + { 0x0010, NULL /* Abit NI8 SLI GR, need DMI string */, { { "CPU Core", 0, 0, 10, 1, 0 }, { "DDR", 1, 0, 10, 1, 0 }, { "DDR VTT", 2, 0, 10, 1, 0 }, @@ -276,7 +279,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "OTES1 Fan", 36, 2, 60, 1, 0 }, { NULL, 0, 0, 0, 0, 0 } } }, - { 0x0011, "Abit AT8 32X", { + { 0x0011, "AT8 32X(ATI RD580-ULI M1575)", { { "CPU Core", 0, 0, 10, 1, 0 }, { "DDR", 1, 0, 20, 1, 0 }, { "DDR VTT", 2, 0, 10, 1, 0 }, @@ -300,9 +303,10 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "SYS Fan", 34, 2, 60, 1, 0 }, { "AUX1 Fan", 35, 2, 60, 1, 0 }, { "AUX2 Fan", 36, 2, 60, 1, 0 }, + { "AUX3 Fan", 37, 2, 60, 1, 0 }, { NULL, 0, 0, 0, 0, 0 } } }, - { 0x0012, "Abit AN8 32X", { + { 0x0012, NULL /* Abit AN8 32X, need DMI string */, { { "CPU Core", 0, 0, 10, 1, 0 }, { "DDR", 1, 0, 20, 1, 0 }, { "DDR VTT", 2, 0, 10, 1, 0 }, @@ -324,7 +328,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "AUX1 Fan", 36, 2, 60, 1, 0 }, { NULL, 0, 0, 0, 0, 0 } } }, - { 0x0013, "Abit AW8D", { + { 0x0013, NULL /* Abit AW8D, need DMI string */, { { "CPU Core", 0, 0, 10, 1, 0 }, { "DDR", 1, 0, 10, 1, 0 }, { "DDR VTT", 2, 0, 10, 1, 0 }, @@ -338,7 +342,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "+3.3V", 10, 0, 20, 1, 0 }, { "5VSB", 11, 0, 30, 1, 0 }, { "CPU", 24, 1, 1, 1, 0 }, - { "System ", 25, 1, 1, 1, 0 }, + { "System", 25, 1, 1, 1, 0 }, { "PWM1", 26, 1, 1, 1, 0 }, { "PWM2", 27, 1, 1, 1, 0 }, { "PWM3", 28, 1, 1, 1, 0 }, @@ -353,7 +357,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "AUX5 Fan", 39, 2, 60, 1, 0 }, { NULL, 0, 0, 0, 0, 0 } } }, - { 0x0014, "Abit AB9 Pro", { + { 0x0014, NULL /* Abit AB9 Pro, need DMI string */, { { "CPU Core", 0, 0, 10, 1, 0 }, { "DDR", 1, 0, 10, 1, 0 }, { "DDR VTT", 2, 0, 10, 1, 0 }, @@ -367,14 +371,14 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "+3.3V", 10, 0, 20, 1, 0 }, { "5VSB", 11, 0, 30, 1, 0 }, { "CPU", 24, 1, 1, 1, 0 }, - { "System ", 25, 1, 1, 1, 0 }, + { "System", 25, 1, 1, 1, 0 }, { "PWM", 26, 1, 1, 1, 0 }, { "CPU Fan", 32, 2, 60, 1, 0 }, { "NB Fan", 33, 2, 60, 1, 0 }, { "SYS Fan", 34, 2, 60, 1, 0 }, { NULL, 0, 0, 0, 0, 0 } } }, - { 0x0015, "unknown", { + { 0x0015, NULL /* Unknown, need DMI string */, { { "CPU Core", 0, 0, 10, 1, 0 }, { "DDR", 1, 0, 20, 1, 0 }, { "DDR VTT", 2, 0, 10, 1, 0 }, @@ -398,7 +402,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "AUX3 Fan", 36, 2, 60, 1, 0 }, { NULL, 0, 0, 0, 0, 0 } } }, - { 0x0016, "AW9D-MAX", { + { 0x0016, NULL /* AW9D-MAX, need DMI string */, { { "CPU Core", 0, 0, 10, 1, 0 }, { "DDR2", 1, 0, 20, 1, 0 }, { "DDR2 VTT", 2, 0, 10, 1, 0 }, @@ -412,7 +416,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "+3.3V", 10, 0, 20, 1, 0 }, { "5VSB", 11, 0, 30, 1, 0 }, { "CPU", 24, 1, 1, 1, 0 }, - { "System ", 25, 1, 1, 1, 0 }, + { "System", 25, 1, 1, 1, 0 }, { "PWM1", 26, 1, 1, 1, 0 }, { "PWM2", 27, 1, 1, 1, 0 }, { "PWM3", 28, 1, 1, 1, 0 }, @@ -426,7 +430,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "OTES1 Fan", 38, 2, 60, 1, 0 }, { NULL, 0, 0, 0, 0, 0 } } }, - { 0x0017, "unknown", { + { 0x0017, NULL /* Unknown, need DMI string */, { { "CPU Core", 0, 0, 10, 1, 0 }, { "DDR2", 1, 0, 20, 1, 0 }, { "DDR2 VTT", 2, 0, 10, 1, 0 }, @@ -442,7 +446,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "ATX +3.3V", 10, 0, 20, 1, 0 }, { "ATX 5VSB", 11, 0, 30, 1, 0 }, { "CPU", 24, 1, 1, 1, 0 }, - { "System ", 26, 1, 1, 1, 0 }, + { "System", 26, 1, 1, 1, 0 }, { "PWM", 27, 1, 1, 1, 0 }, { "CPU FAN", 32, 2, 60, 1, 0 }, { "SYS FAN", 34, 2, 60, 1, 0 }, @@ -451,7 +455,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "AUX3 FAN", 37, 2, 60, 1, 0 }, { NULL, 0, 0, 0, 0, 0 } } }, - { 0x0018, "unknown", { + { 0x0018, NULL /* Unknown, need DMI string */, { { "CPU Core", 0, 0, 10, 1, 0 }, { "DDR2", 1, 0, 20, 1, 0 }, { "DDR2 VTT", 2, 0, 10, 1, 0 }, @@ -465,7 +469,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "+3.3V", 10, 0, 20, 1, 0 }, { "5VSB", 11, 0, 30, 1, 0 }, { "CPU", 24, 1, 1, 1, 0 }, - { "System ", 25, 1, 1, 1, 0 }, + { "System", 25, 1, 1, 1, 0 }, { "PWM Phase1", 26, 1, 1, 1, 0 }, { "PWM Phase2", 27, 1, 1, 1, 0 }, { "PWM Phase3", 28, 1, 1, 1, 0 }, @@ -478,12 +482,12 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "AUX3 Fan", 36, 2, 60, 1, 0 }, { NULL, 0, 0, 0, 0, 0 } } }, - { 0x0019, "unknown", { + { 0x0019, NULL /* Unknown, need DMI string */, { { "CPU Core", 7, 0, 10, 1, 0 }, { "DDR2", 13, 0, 20, 1, 0 }, { "DDR2 VTT", 14, 0, 10, 1, 0 }, { "CPU VTT", 3, 0, 20, 1, 0 }, - { "NB 1.2V ", 4, 0, 10, 1, 0 }, + { "NB 1.2V", 4, 0, 10, 1, 0 }, { "SB 1.5V", 6, 0, 10, 1, 0 }, { "HyperTransport", 5, 0, 10, 1, 0 }, { "ATX +12V (24-Pin)", 12, 0, 60, 1, 0 }, @@ -492,7 +496,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "ATX +3.3V", 10, 0, 20, 1, 0 }, { "ATX 5VSB", 11, 0, 30, 1, 0 }, { "CPU", 24, 1, 1, 1, 0 }, - { "System ", 25, 1, 1, 1, 0 }, + { "System", 25, 1, 1, 1, 0 }, { "PWM Phase1", 26, 1, 1, 1, 0 }, { "PWM Phase2", 27, 1, 1, 1, 0 }, { "PWM Phase3", 28, 1, 1, 1, 0 }, @@ -505,7 +509,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "AUX3 FAN", 36, 2, 60, 1, 0 }, { NULL, 0, 0, 0, 0, 0 } } }, - { 0x001A, "Abit IP35 Pro", { + { 0x001A, "IP35 Pro(Intel P35-ICH9R)", { { "CPU Core", 0, 0, 10, 1, 0 }, { "DDR2", 1, 0, 20, 1, 0 }, { "DDR2 VTT", 2, 0, 10, 1, 0 }, @@ -519,8 +523,8 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "+3.3V", 10, 0, 20, 1, 0 }, { "5VSB", 11, 0, 30, 1, 0 }, { "CPU", 24, 1, 1, 1, 0 }, - { "System ", 25, 1, 1, 1, 0 }, - { "PWM ", 26, 1, 1, 1, 0 }, + { "System", 25, 1, 1, 1, 0 }, + { "PWM", 26, 1, 1, 1, 0 }, { "PWM Phase2", 27, 1, 1, 1, 0 }, { "PWM Phase3", 28, 1, 1, 1, 0 }, { "PWM Phase4", 29, 1, 1, 1, 0 }, @@ -533,7 +537,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "AUX4 Fan", 37, 2, 60, 1, 0 }, { NULL, 0, 0, 0, 0, 0 } } }, - { 0x001B, "unknown", { + { 0x001B, NULL /* Unknown, need DMI string */, { { "CPU Core", 0, 0, 10, 1, 0 }, { "DDR3", 1, 0, 20, 1, 0 }, { "DDR3 VTT", 2, 0, 10, 1, 0 }, @@ -560,7 +564,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = { { "AUX3 Fan", 36, 2, 60, 1, 0 }, { NULL, 0, 0, 0, 0, 0 } } }, - { 0x001C, "unknown", { + { 0x001C, NULL /* Unknown, need DMI string */, { { "CPU Core", 0, 0, 10, 1, 0 }, { "DDR2", 1, 0, 20, 1, 0 }, { "DDR2 VTT", 2, 0, 10, 1, 0 }, @@ -935,9 +939,18 @@ static int __devinit abituguru3_probe(struct platform_device *pdev) goto abituguru3_probe_error; } data->sensors = abituguru3_motherboards[i].sensors; + printk(KERN_INFO ABIT_UGURU3_NAME ": found Abit uGuru3, motherboard " - "ID: %04X (%s)\n", (unsigned int)id, - abituguru3_motherboards[i].name); + "ID: %04X\n", (unsigned int)id); + +#ifdef CONFIG_DMI + if (!abituguru3_motherboards[i].dmi_name) { + printk(KERN_WARNING ABIT_UGURU3_NAME ": this motherboard was " + "not detected using DMI. Please send the output of " + "\"dmidecode\" to the abituguru3 maintainer " + "(see MAINTAINERS)\n"); + } +#endif /* Fill the sysfs attr array */ sysfs_attr_i = 0; @@ -1109,6 +1122,46 @@ static struct platform_driver abituguru3_driver = { .resume = abituguru3_resume }; +#ifdef CONFIG_DMI + +static int __init abituguru3_dmi_detect(void) +{ + const char *board_vendor, *board_name; + int i, err = (force) ? 1 : -ENODEV; + + board_vendor = dmi_get_system_info(DMI_BOARD_VENDOR); + if (!board_vendor || strcmp(board_vendor, "http://www.abit.com.tw/")) + return err; + + board_name = dmi_get_system_info(DMI_BOARD_NAME); + if (!board_name) + return err; + + for (i = 0; abituguru3_motherboards[i].id; i++) { + const char *dmi_name = abituguru3_motherboards[i].dmi_name; + if (dmi_name && !strcmp(dmi_name, board_name)) + break; + } + + if (!abituguru3_motherboards[i].id) + return 1; + + return 0; +} + +#else /* !CONFIG_DMI */ + +static inline int abituguru3_dmi_detect(void) +{ + return -ENODEV; +} + +#endif /* CONFIG_DMI */ + +/* FIXME: Manual detection should die eventually; we need to collect stable + * DMI model names first before we can rely entirely on CONFIG_DMI. + */ + static int __init abituguru3_detect(void) { /* See if there is an uguru3 there. An idle uGuru3 will hold 0x00 or @@ -1119,7 +1172,7 @@ static int __init abituguru3_detect(void) if (((data_val == 0x00) || (data_val == 0x08)) && ((cmd_val == 0xAC) || (cmd_val == 0x05) || (cmd_val == 0x55))) - return ABIT_UGURU3_BASE; + return 0; ABIT_UGURU3_DEBUG("no Abit uGuru3 found, data = 0x%02X, cmd = " "0x%02X\n", (unsigned int)data_val, (unsigned int)cmd_val); @@ -1127,7 +1180,7 @@ static int __init abituguru3_detect(void) if (force) { printk(KERN_INFO ABIT_UGURU3_NAME ": Assuming Abit uGuru3 is " "present because of \"force\" parameter\n"); - return ABIT_UGURU3_BASE; + return 0; } /* No uGuru3 found */ @@ -1138,27 +1191,29 @@ static struct platform_device *abituguru3_pdev; static int __init abituguru3_init(void) { - int address, err; struct resource res = { .flags = IORESOURCE_IO }; - -#ifdef CONFIG_DMI - const char *board_vendor = dmi_get_system_info(DMI_BOARD_VENDOR); - - /* safety check, refuse to load on non Abit motherboards */ - if (!force && (!board_vendor || - strcmp(board_vendor, "http://www.abit.com.tw/"))) - return -ENODEV; -#endif - - address = abituguru3_detect(); - if (address < 0) - return address; + int err; + + /* Attempt DMI detection first */ + err = abituguru3_dmi_detect(); + if (err < 0) + return err; + + /* Fall back to manual detection if there was no exact + * board name match, or force was specified. + */ + if (err > 0) { + err = abituguru3_detect(); + if (err) + return err; + } err = platform_driver_register(&abituguru3_driver); if (err) goto exit; - abituguru3_pdev = platform_device_alloc(ABIT_UGURU3_NAME, address); + abituguru3_pdev = platform_device_alloc(ABIT_UGURU3_NAME, + ABIT_UGURU3_BASE); if (!abituguru3_pdev) { printk(KERN_ERR ABIT_UGURU3_NAME ": Device allocation failed\n"); @@ -1166,8 +1221,8 @@ static int __init abituguru3_init(void) goto exit_driver_unregister; } - res.start = address; - res.end = address + ABIT_UGURU3_REGION_LENGTH - 1; + res.start = ABIT_UGURU3_BASE; + res.end = ABIT_UGURU3_BASE + ABIT_UGURU3_REGION_LENGTH - 1; res.name = ABIT_UGURU3_NAME; err = platform_device_add_resources(abituguru3_pdev, &res, 1);