From patchwork Mon Jan 3 16:33:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcello Sylvester Bauer X-Patchwork-Id: 12702664 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 D212AC4332F for ; Mon, 3 Jan 2022 16:41:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230149AbiACQll (ORCPT ); Mon, 3 Jan 2022 11:41:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230517AbiACQlk (ORCPT ); Mon, 3 Jan 2022 11:41:40 -0500 X-Greylist: delayed 401 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 03 Jan 2022 08:41:40 PST Received: from mout-y-111.mailbox.org (mout-y-111.mailbox.org [IPv6:2001:67c:2050:1::465:111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12F46C061761; Mon, 3 Jan 2022 08:41:40 -0800 (PST) Received: from smtp202.mailbox.org (unknown [91.198.250.118]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-y-111.mailbox.org (Postfix) with ESMTPS id 4JSLv925YmzQlLQ; Mon, 3 Jan 2022 17:35:01 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sylv.io; s=MBO0001; t=1641227700; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eVaFMeMetbF2chCKkaAP7mGT+Mpn+9qurXFgcY31yEw=; b=Ft18cB8WzNQOXw5b2wYqIlYweCebjU2JnRNNYrh6cxhIfQ9krzjXMF779dY3PqaYcV0KMl OpcPwPa/lm1rNc9sL1CIL7IqeHx5mj0AlfKmkssr52RyOyw6Nmy2JSxb6H57pPjQoQmyW1 qBTUFjf1yHyOk9kBZb5fT97rz+F6W1buTm8qF6/5HgLou3IDMhFrCI4+XJjStRNOyHiFBQ bMb/rV8c66vCxJmBVMmxPc0OseF7YNoLPA9rklTaNBVV/9q2w46IdQbhA48hVp/Rp09bNq WnN17Xx9nWdyuMrDYAGUncIFOuSiGuBrTbyiHNPFMkIZ765C/MNV7HfhQIRAKw== From: Marcello Sylvester Bauer To: linux-hwmon@vger.kernel.org Cc: Marcello Sylvester Bauer , Patrick Rudolph , Jean Delvare , Guenter Roeck , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/4] hwmon: (max6639) Update Datasheet URL Date: Mon, 3 Jan 2022 17:33:51 +0100 Message-Id: <9de5b23396e4031158a68bfbd47d370b50080e43.1641224715.git.sylv@sylv.io> In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org The old Datasheet does not exist anymore. Signed-off-by: Marcello Sylvester Bauer --- Documentation/hwmon/max6639.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/hwmon/max6639.rst b/Documentation/hwmon/max6639.rst index 3da54225f83c..c85d285a3489 100644 --- a/Documentation/hwmon/max6639.rst +++ b/Documentation/hwmon/max6639.rst @@ -9,7 +9,7 @@ Supported chips: Addresses scanned: I2C 0x2c, 0x2e, 0x2f - Datasheet: http://pdfserv.maxim-ic.com/en/ds/MAX6639.pdf + Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX6639-MAX6639F.pdf Authors: - He Changqing From patchwork Mon Jan 3 16:33:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcello Sylvester Bauer X-Patchwork-Id: 12702663 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 54A63C433FE for ; Mon, 3 Jan 2022 16:41:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231415AbiACQlk (ORCPT ); Mon, 3 Jan 2022 11:41:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230170AbiACQlk (ORCPT ); Mon, 3 Jan 2022 11:41:40 -0500 X-Greylist: delayed 415 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 03 Jan 2022 08:41:40 PST Received: from mout-y-111.mailbox.org (mout-y-111.mailbox.org [IPv6:2001:67c:2050:1::465:111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C3A3C061784; Mon, 3 Jan 2022 08:41:40 -0800 (PST) Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:105:465:1:4:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-y-111.mailbox.org (Postfix) with ESMTPS id 4JSLvB4T1qzQlLR; Mon, 3 Jan 2022 17:35:02 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sylv.io; s=MBO0001; t=1641227702; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Gy/SaMPYaRnqLDcyWl/RE0Zx5SaX9Qnp25v+7IjRdcc=; b=IYv8pjjjq+7PPs6xmJHoJpSyoGDum3I+CTKEbVx8gruS0exHuCIanAlwMLSX2lC1lXWw7q e5alSIeGAHo2focbad/0q4VIbZf+dP2LSlH+wbVicCZkFm2SWrIT8a0JMCIAVudQRulNGh S9hs6PVgZWYr5LClCzGK9/T72CQyb2Loskf0XwJZjwXrPveWZ3YwMGpNWP6KtUmjxqkdBp XDtc8gaKLBAJRFAgYJmTGMoGL8avIpgc54OyTdGCo27HjCpe6wyqIDHlFEbpZHQj9H9s0V eExUtG0rXUNS6+vockFk5hK3bwjHCIHru8uujwrDSP1AOJ6cswxlb2Gs6/svUA== From: Marcello Sylvester Bauer To: linux-hwmon@vger.kernel.org Cc: Marcello Sylvester Bauer , Patrick Rudolph , Jean Delvare , Guenter Roeck , Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH v1 2/4] hwmon: (max6639) Add regulator support Date: Mon, 3 Jan 2022 17:33:52 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add regulator support for boards where the fan-supply have to be powered up before it can be used. Signed-off-by: Patrick Rudolph Signed-off-by: Marcello Sylvester Bauer --- drivers/hwmon/max6639.c | 75 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 67 insertions(+), 8 deletions(-) diff --git a/drivers/hwmon/max6639.c b/drivers/hwmon/max6639.c index ccc0f047bd44..d733c35b5bcf 100644 --- a/drivers/hwmon/max6639.c +++ b/drivers/hwmon/max6639.c @@ -87,6 +87,9 @@ struct max6639_data { /* Register values initialized only once */ u8 ppr; /* Pulses per rotation 0..3 for 1..4 ppr */ u8 rpm_range; /* Index in above rpm_ranges table */ + + /* Optional regulator for FAN supply */ + struct regulator *reg; }; static struct max6639_data *max6639_update_device(struct device *dev) @@ -296,6 +299,17 @@ static ssize_t pwm_store(struct device *dev, return res; val = clamp_val(val, 0, 255); + if (data->reg) { + res = 0; + if (val == 0) + res = regulator_disable(data->reg); + else + res = regulator_enable(data->reg); + if (res) { + dev_err(dev, "Failed to operate fan supply: %d\n", res); + return res; + } + } mutex_lock(&data->update_lock); data->pwm[attr->index] = (u8)(val * 120 / 255); @@ -516,6 +530,11 @@ static int max6639_detect(struct i2c_client *client, return 0; } +static void max6639_regulator_disable(void *data) +{ + regulator_disable(data); +} + static int max6639_probe(struct i2c_client *client) { struct device *dev = &client->dev; @@ -528,6 +547,30 @@ static int max6639_probe(struct i2c_client *client) return -ENOMEM; data->client = client; + + data->reg = devm_regulator_get_optional(dev, "fan"); + if (IS_ERR(data->reg)) { + if (PTR_ERR(data->reg) != -ENODEV) { + err = (int)PTR_ERR(data->reg); + dev_warn(dev, "Failed looking up fan supply: %d\n", err); + return err; + } + data->reg = NULL; + } else { + /* Spin up fans */ + err = regulator_enable(data->reg); + if (err) { + dev_err(dev, "Failed to enable fan supply: %d\n", err); + return err; + } + err = devm_add_action_or_reset(dev, max6639_regulator_disable, + data->reg); + if (err) { + dev_err(dev, "Failed to register action: %d\n", err); + return err; + } + } + mutex_init(&data->update_lock); /* Initialize the max6639 chip */ @@ -545,23 +588,39 @@ static int max6639_probe(struct i2c_client *client) static int max6639_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); - int data = i2c_smbus_read_byte_data(client, MAX6639_REG_GCONFIG); - if (data < 0) - return data; + struct max6639_data *data = dev_get_drvdata(dev); + int ret = i2c_smbus_read_byte_data(client, MAX6639_REG_GCONFIG); + + if (ret < 0) + return ret; + + if (data->reg) + regulator_disable(data->reg); return i2c_smbus_write_byte_data(client, - MAX6639_REG_GCONFIG, data | MAX6639_GCONFIG_STANDBY); + MAX6639_REG_GCONFIG, ret | MAX6639_GCONFIG_STANDBY); } static int max6639_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); - int data = i2c_smbus_read_byte_data(client, MAX6639_REG_GCONFIG); - if (data < 0) - return data; + struct max6639_data *data = dev_get_drvdata(dev); + int ret; + + if (data->reg) { + ret = regulator_enable(data->reg); + if (ret) { + dev_err(dev, "Failed to enable fan supply: %d\n", ret); + return ret; + } + } + + ret = i2c_smbus_read_byte_data(client, MAX6639_REG_GCONFIG); + if (ret < 0) + return ret; return i2c_smbus_write_byte_data(client, - MAX6639_REG_GCONFIG, data & ~MAX6639_GCONFIG_STANDBY); + MAX6639_REG_GCONFIG, ret & ~MAX6639_GCONFIG_STANDBY); } #endif /* CONFIG_PM_SLEEP */ From patchwork Mon Jan 3 16:33:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcello Sylvester Bauer X-Patchwork-Id: 12702665 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 107AEC433FE for ; Mon, 3 Jan 2022 16:41:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233048AbiACQlm (ORCPT ); Mon, 3 Jan 2022 11:41:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231146AbiACQlk (ORCPT ); Mon, 3 Jan 2022 11:41:40 -0500 X-Greylist: delayed 399 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 03 Jan 2022 08:41:40 PST Received: from mout-y-111.mailbox.org (mout-y-111.mailbox.org [IPv6:2001:67c:2050:1::465:111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2042EC061785; Mon, 3 Jan 2022 08:41:40 -0800 (PST) Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:105:465:1:4:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-y-111.mailbox.org (Postfix) with ESMTPS id 4JSLv74cSrzQlLN; Mon, 3 Jan 2022 17:34:59 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sylv.io; s=MBO0001; t=1641227697; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xMrRSAFFQ28kkRErHsEHfo+NPf5sueFwy0kVjjKr9jw=; b=obmSI9kz6ea/GSHI0nlpnkgVVFZvRG7UR6KcbP+zmWhL6YWTZRWBw6qdiWEhe6Igx31Wtf kMLxDAuNsTo+oPbVD3l7l24xmxDbx1H9PcItAV/wR6SW/BU9yONh6YvYW8c1LBgHwU2MDN mCw6Cp/K3LFYFnNk0OtB0IAXi1vloGfVWQ9Zx63j5N2MzXfcxy70C8FNJhjduskXT2SUv1 tyiio4Zy2uzgqkMAxd92twhu4Bvjj2T9DXIuuELRnlQYPfFr5Rl2nWXQaUN6QWe6ADGehU fohDY6khF3GZtZvgG9zff99oSpqu/FlvdbBycEKaCJ50JqW6iZhnnEa+LHHPkg== From: Marcello Sylvester Bauer To: linux-hwmon@vger.kernel.org Cc: Marcello Sylvester Bauer , Patrick Rudolph , Jean Delvare , Guenter Roeck , Rob Herring , Roland Stigge , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 3/4] dt-bindings: hwmon: Add binding for max6639 Date: Mon, 3 Jan 2022 17:33:48 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add Devicetree binding documentation for Maxim MAX6639 temperature monitor with PWM fan-speed controller. The devicetree documentation for the SD3078 device tree. Signed-off-by: Marcello Sylvester Bauer --- .../bindings/hwmon/maxim,max6639.yaml | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml diff --git a/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml b/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml new file mode 100644 index 000000000000..136ed37b6aac --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- + +$id: http://devicetree.org/schemas/hwmon/maxim,max6639.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim max6639 + +maintainers: + - Roland Stigge + +description: | + The MAX6639 is a 2-channel temperature monitor with dual, automatic, PWM + fan-speed controller. It monitors its own temperature and one external + diode-connected transistor or the temperatures of two external diode-connected + transistors, typically available in CPUs, FPGAs, or GPUs. + + Datasheets: + https://datasheets.maximintegrated.com/en/ds/MAX6639-MAX6639F.pdf + +properties: + compatible: + enum: + - maxim,max6639 + + reg: + maxItems: 1 + + polarity: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1] + description: + PWM output is low at 100% duty cycle when this bit is set to zero. PWM + output is high at 100% duty cycle when this bit is set to 1. + Fans PWM polarity is set to high (1) by default. + + pulses-per-revolution: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [1, 2, 3, 4] + description: + Value specifying the number of pulses per revolution of the controlled + FAN. + + rpm-range: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [2000, 4000, 8000, 16000] + description: + Scales the tachometer counter by setting the maximum (full-scale) value + of the RPM range. + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + max6639@10 { + compatible = "maxim,max6639"; + reg = <0x10>; + polarity = <1>; + pulses-per-revolution = <2>; + rpm-range = <4000>; + }; + }; From patchwork Mon Jan 3 16:33:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcello Sylvester Bauer X-Patchwork-Id: 12702662 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 AE338C433F5 for ; Mon, 3 Jan 2022 16:41:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230210AbiACQlk (ORCPT ); Mon, 3 Jan 2022 11:41:40 -0500 Received: from mout-y-111.mailbox.org ([91.198.250.236]:47502 "EHLO mout-y-111.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230149AbiACQlk (ORCPT ); Mon, 3 Jan 2022 11:41:40 -0500 X-Greylist: delayed 418 seconds by postgrey-1.27 at vger.kernel.org; Mon, 03 Jan 2022 11:41:39 EST Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:105:465:1:4:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-y-111.mailbox.org (Postfix) with ESMTPS id 4JSLvD4QBgzQlLT; Mon, 3 Jan 2022 17:35:04 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sylv.io; s=MBO0001; t=1641227704; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jGg109/SdVHAGsrAmpzH9OY+vbgtukVPEWTK0WDru0U=; b=JPiCmn4viCFV5AgGgiXuMVhdjihzp9zD9mToOIWkQ7kOssdUJ1uVQatFtHPjjemejZNm2m jXJyqbGr54wvezf4JWOUBqZ3BwI9+Fly+lcQNTnFCBCZB5Sas++7/kIneb/bDm0sprKHs/ CZaZwDbd8LYSvaZIFsb0rMpgmCyLJ/wTkWCJ4Bs3yyvGCRHVsuiCzFPtFxUO2/AN6+5b5F ydQDl4vJhHeTirNyUBWOah+uWAb2RhTBcVlryyt4HOe9U7Xe7xBOygEredkuIA6mc23Gtb obvY8yKyyxy3Lt/jq0JDUe2NqzV/XsNFMiTlCNP6Fat+DWikEbbtjfdhb+deAA== From: Marcello Sylvester Bauer To: linux-hwmon@vger.kernel.org Cc: Marcello Sylvester Bauer , Patrick Rudolph , Jean Delvare , Guenter Roeck , linux-kernel@vger.kernel.org Subject: [PATCH v1 4/4] hwmon: (max6639) Add devicetree support Date: Mon, 3 Jan 2022 17:33:54 +0100 Message-Id: <18f099abda66841042d71739c6ffd41c84434106.1641224715.git.sylv@sylv.io> In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Allow the driver to work with device tree support. Signed-off-by: Marcello Sylvester Bauer --- drivers/hwmon/max6639.c | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/hwmon/max6639.c b/drivers/hwmon/max6639.c index d733c35b5bcf..f84ee4a05f80 100644 --- a/drivers/hwmon/max6639.c +++ b/drivers/hwmon/max6639.c @@ -412,6 +412,38 @@ static int rpm_range_to_reg(int range) return 1; /* default: 4000 RPM */ } +static struct max6639_platform_data *get_pdata_from_dt_node(struct device *dev) +{ + struct max6639_platform_data *pdata; + u32 pol, ppr, rpm; + int ret; + + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return ERR_PTR(-ENOMEM); + + pdata->pwm_polarity = true; + ret = of_property_read_u32(dev->of_node, "polarity", &pol); + if (!ret && !pol) + pdata->pwm_polarity = false; + + ret = of_property_read_u32(dev->of_node, "pulses-per-revolution", &ppr); + if (ret < 0) + dev_warn(dev, "No pulses-per-revolution property\n"); + else + pdata->ppr = ppr; + + ret = of_property_read_u32(dev->of_node, "rpm-range", &rpm); + if (ret < 0) { + dev_warn(dev, "no rpm-range property\n"); + pdata->rpm_range = 4000; + } else { + pdata->rpm_range = rpm; + } + + return pdata; +} + static int max6639_init_client(struct i2c_client *client, struct max6639_data *data) { @@ -421,6 +453,12 @@ static int max6639_init_client(struct i2c_client *client, int rpm_range = 1; /* default: 4000 RPM */ int err; + if (!max6639_info && client->dev.of_node) { + max6639_info = get_pdata_from_dt_node(&client->dev); + if (IS_ERR(max6639_info)) + return PTR_ERR(max6639_info); + } + /* Reset chip to default values, see below for GCONFIG setup */ err = i2c_smbus_write_byte_data(client, MAX6639_REG_GCONFIG, MAX6639_GCONFIG_POR); @@ -631,6 +669,14 @@ static const struct i2c_device_id max6639_id[] = { MODULE_DEVICE_TABLE(i2c, max6639_id); +#ifdef CONFIG_OF +static const struct of_device_id maxim_of_platform_match[] = { + {.compatible = "maxim,max6639"}, + {}, +}; +MODULE_DEVICE_TABLE(of, maxim_of_platform_match); +#endif + static SIMPLE_DEV_PM_OPS(max6639_pm_ops, max6639_suspend, max6639_resume); static struct i2c_driver max6639_driver = { @@ -638,6 +684,7 @@ static struct i2c_driver max6639_driver = { .driver = { .name = "max6639", .pm = &max6639_pm_ops, + .of_match_table = of_match_ptr(maxim_of_platform_match), }, .probe_new = max6639_probe, .id_table = max6639_id,