From patchwork Sat Nov 5 04:57:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Crawford X-Patchwork-Id: 13032834 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5323C4332F for ; Sat, 5 Nov 2022 04:59:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229469AbiKEE7G (ORCPT ); Sat, 5 Nov 2022 00:59:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229666AbiKEE6t (ORCPT ); Sat, 5 Nov 2022 00:58:49 -0400 Received: from ipmail03.adl2.internode.on.net (ipmail03.adl2.internode.on.net [150.101.137.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B5299311 for ; Fri, 4 Nov 2022 21:58:25 -0700 (PDT) IronPort-SDR: iQMq4EQ5v5seZh3ZddiIm+2iudHpTzITLr37kmoPsdIntikDt9vKBEOaWkWVP4EjOqZLkZr1bd v2K6ZVz65GfXqrR76nlJgWvOtoMEd+6oCTjXA6ona/GTPMwnToVfMdJw2HxL4uY9Yt/9Uyi7Dc 4JTINKP4hcWzZ8ra84rHDCQBXtl9etE7B25jImenjvNJKpnTTliagdhlAPiuMn7QqHQ9pLgVv4 UoT/zCX1OioqUhq6c+CqzagMV4w3hEteb8ei4i20a78r0Oxi2OYlZyq50hppjI82MVdU2MEPC1 azfra+uwTjYLQ4fUE0OfUfqz X-SMTP-MATCH: 0 X-IPAS-Result: A2DjDADA62Vj//Qc8jxaHgEBCxIMSYE7C4ItglqVaJ8pDwEPAQFEBAEBhQWEeyY3Bg4BAgQBAQEBAwIDAQEBAQEBAwEBBgEB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06LXLz6DJz4LfaA15ZOAOBiXIBIbZ4bNElz OMmtJJE4gCzkEBxYNyHkjsS/H6FMXIHSalhu5QHRo7nzAM2kwkQbZvZAy7wwZeOd9QVbBd3e mTO3vqTiuQO3FfGfloyCWPJg7hXi6MOjxYWnlUMEEvYyNPKi8g+0ABV7TlqHB9eyQ9K0rwvN 2U3ZVd5I76Co2VhiMRZBDr+RVkEXkHDvxahjgFVyCvCU0C0V2eLMHUyOKCG+0Vf+n8FJmpX+ 7SRyWDEVzf2fZivgHZqAhQ/+63uHY5r6wnPuMG7BMDZTZM0Vjy00KahaF0BpwbjHc5s1lbMo vNn/bgsZKD2XcLKT3bX12VHOWwsdS25 IronPort-HdrOrdr: A9a23:tqvlB65yY0FPs9XvfwPXwObXdLJyesId70hD6qkQc3ZomwKj9v xG+85rsiMd6l4qNU3I/OrtBEDuewK+yXcY2+Ys1NSZLW3bURWTXeNfBOLZqlWKJ8SUzI5gPM lbHZSXh7DLfD5HZL7BkWyF+s4bsaO6Gb6T9JzjJqhWPHhXg3AJ1XYANjqm X-IronPort-Anti-Spam-Filtered: true Received: from 60-242-28-244.static.tpgi.com.au (HELO bits.crawford.emu.id.au) ([60.242.28.244]) by ipmail03.adl2.internode.on.net with ESMTP; 05 Nov 2022 15:28:10 +1030 Received: from agc.crawford.emu.id.au (agc.crawford.emu.id.au [IPv6:fdd2:7aad:d478:1:0:0:cb10:cc07]) (authenticated bits=0) by bits.crawford.emu.id.au (8.17.1/8.17.1) with ESMTPSA id 2A54vv7a2655766 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sat, 5 Nov 2022 15:58:03 +1100 Authentication-Results: bits.crawford.emu.id.au; arc=none smtp.remote-ip=fdd2:7aad:d478:1::cb10:cc07 DKIM-Filter: OpenDKIM Filter v2.11.0 bits.crawford.emu.id.au 2A54vv7a2655766 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crawford.emu.id.au; s=s1; t=1667624283; bh=O5I/l6HhGKpVtBP5RZcNFlxdukCKrt4vYh68G2abvEc=; h=From:To:Cc:Subject:Date:From; b=HoRkUdTgkM3MQRJBVyVpVz5BMWGiAaoP8ZlO5CO0j2JZodww8YM6S1y1i38aUG8LN 4ZIMbkpdBwyztoTVizzjtIh+TkpZyo08ZGyMQpFtLRBIJlRP5QfJukUPh32IDWjNAS vso9O8pibMzjLKZnWR6o34T3X6BFsusQo+j3cdw/90/qgrrFFpOpa8YLhTKpI0740P OBQI0mcZD7QPsb1i4IsqFDWZNvpM9XqDHMNtl1Fe6XuQGn60WtQW/oksKjg10ggB+C eWgCSV57OKq/KvIxwDj44gl6QbVFmg0PQIBzhVl5HmtHXm8QS+3ryQwEljMUqL2w+a Avy2tOlTU2QDg== From: Frank Crawford To: Jean Delvare , Guenter Roeck Cc: linux-hwmon@vger.kernel.org, Frank Crawford Subject: [PATCH v4 1/1] hwmon: (it87) Add DMI table for future extensions Date: Sat, 5 Nov 2022 15:57:54 +1100 Message-Id: <20221105045754.1439809-1-frank@crawford.emu.id.au> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.4 (bits.crawford.emu.id.au [IPv6:fdd2:7aad:d478:1:0:0:cb10:cc01]); Sat, 05 Nov 2022 15:58:03 +1100 (AEDT) X-Virus-Scanned: clamav-milter 0.103.7 at bits.crawford.emu.id.au X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Changes in this patch set: * Define the DMI matching table for board specific settings during the chip initialisation and move the only current board specific setting to this new table. * Export the table for use by udev. v2: updates following comments: * Converted to use callback function. * Moved call to callback funtion to sio_data into it87_find in line with other settings for sio_data. This requires dmi_data also passed to access additional data. * Added macro for defining entries in DMI table to simplify future additions. * Note dmi_data is defined in sm_it87_init to simplify tests and for future additions. v3: further updates following comments: * Proper use of callback functions for DMI functions. This also involves saving dmi_data in a static variable for use as required. * Moved to dmi_check_system() for testing DMI table. v4: further cleanups following comments * Note the macro IT87_DMI_MATCH_VND includes callback argument for use by a future update. Signed-off-by: Frank Crawford --- drivers/hwmon/it87.c | 72 ++++++++++++++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 19 deletions(-) diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 73ed21ab325b..9997f76b1f4a 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -567,6 +567,14 @@ struct it87_data { s8 auto_temp[NUM_AUTO_PWM][5]; /* [nr][0] is point1_temp_hyst */ }; +/* Board specific settings from DMI matching */ +struct it87_dmi_data { + u8 skip_pwm; /* pwm channels to skip for this board */ +}; + +/* Global for results from DMI matching, if needed */ +static struct it87_dmi_data *dmi_data; + static int adc_lsb(const struct it87_data *data, int nr) { int lsb; @@ -2393,7 +2401,6 @@ static int __init it87_find(int sioaddr, unsigned short *address, { int err; u16 chip_type; - const char *board_vendor, *board_name; const struct it87_devices *config; err = superio_enter(sioaddr); @@ -2812,24 +2819,9 @@ static int __init it87_find(int sioaddr, unsigned short *address, if (sio_data->beep_pin) pr_info("Beeping is supported\n"); - /* Disable specific features based on DMI strings */ - board_vendor = dmi_get_system_info(DMI_BOARD_VENDOR); - board_name = dmi_get_system_info(DMI_BOARD_NAME); - if (board_vendor && board_name) { - if (strcmp(board_vendor, "nVIDIA") == 0 && - strcmp(board_name, "FN68PT") == 0) { - /* - * On the Shuttle SN68PT, FAN_CTL2 is apparently not - * connected to a fan, but to something else. One user - * has reported instant system power-off when changing - * the PWM2 duty cycle, so we disable it. - * I use the board name string as the trigger in case - * the same board is ever used in other systems. - */ - pr_info("Disabling pwm2 due to hardware constraints\n"); - sio_data->skip_pwm = BIT(1); - } - } + /* Set values based on DMI matches */ + if (dmi_data) + sio_data->skip_pwm |= dmi_data->skip_pwm; exit: superio_exit(sioaddr); @@ -3307,6 +3299,46 @@ static int __init it87_device_add(int index, unsigned short address, return err; } +/* callback function for DMI */ +static int it87_dmi_cb(const struct dmi_system_id *dmi_entry) +{ + dmi_data = dmi_entry->driver_data; + + if (dmi_data && dmi_data->skip_pwm) + pr_info("Disabling pwm2 due to hardware constraints\n"); + + return 1; +} + +/* + * On the Shuttle SN68PT, FAN_CTL2 is apparently not + * connected to a fan, but to something else. One user + * has reported instant system power-off when changing + * the PWM2 duty cycle, so we disable it. + * I use the board name string as the trigger in case + * the same board is ever used in other systems. + */ +static struct it87_dmi_data nvidia_fn68pt = { + .skip_pwm = BIT(1), +}; + +#define IT87_DMI_MATCH_VND(vendor, name, cb, data) \ + { \ + .callback = cb, \ + .matches = { \ + DMI_EXACT_MATCH(DMI_BOARD_VENDOR, vendor), \ + DMI_EXACT_MATCH(DMI_BOARD_NAME, name), \ + }, \ + .driver_data = data, \ + } + +static const struct dmi_system_id it87_dmi_table[] __initconst = { + IT87_DMI_MATCH_VND("nVIDIA", "FN68PT", it87_dmi_cb, &nvidia_fn68pt), + { } + +}; +MODULE_DEVICE_TABLE(dmi, it87_dmi_table); + static int __init sm_it87_init(void) { int sioaddr[2] = { REG_2E, REG_4E }; @@ -3319,6 +3351,8 @@ static int __init sm_it87_init(void) if (err) return err; + dmi_check_system(it87_dmi_table); + for (i = 0; i < ARRAY_SIZE(sioaddr); i++) { memset(&sio_data, 0, sizeof(struct it87_sio_data)); isa_address[i] = 0;