Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp38214444rwd; Wed, 12 Jul 2023 04:55:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlHue3cKOCcVuKfmKtDd1ADM74qlNCdopYkgpI4MF1GhyWn+IOHObfq25x7xkWInwu0pJgWL X-Received: by 2002:aa7:88cf:0:b0:681:d247:8987 with SMTP id k15-20020aa788cf000000b00681d2478987mr16770803pff.17.1689162927168; Wed, 12 Jul 2023 04:55:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689162927; cv=none; d=google.com; s=arc-20160816; b=QvtKWhJhLPiYWVhgcpVlnr9nfY9wBuJZhzznci1Tr6olFpN+Rx+YVxtQzls4t5HQ6+ qLcRjzhUIbw7qekJZGKjeRFuioXmhet8SmR7WP4Q3/+7YY3yog1CS/Vuz0iUq205SeIr v+QaJVwOcXi7RXErnD1b67GTQTGtWYyjU/zwu/EmHxUVCPYb98f1BdEsLTx7cbCSTIl1 VuiGbWtATTApA9QzWciKG3WpVSxnJItvIVw1wRJBMRbqo3+xlANPka0buKIuYEoI9mXq F1ppBMDD39LBChyM+CBiJynOxa7HYVuNgSJnHrPKl8WviaVPuwN5BFvSfVesWm47OSSZ 43rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nNQjkE8rt0loSfu/6IF9XOAi/Sv+jFDCxC5ymTmcAL4=; fh=JUrxmAGZpf2um0PJXMa+5wJ3JrTNc+xhv0SKeec5FHw=; b=cY7abhLHd5swiOcPT2ZX92A6vwQuiQjnLJ+iuUd331ViwUaldgqHQPcEE6q6ajbCJE HNYNgWeMTwhwFdZhAmYiJX3m2+sWZHs9SU4catshj1Ihb2CC/78a4A6jklteCpLfEeDD b0twtu/j4+/OEfyG0LmfD0E+Vc1YAAbrp9t/sI00OIiGePejPvtSeg1rqEwXhl/RKAiX KXZDWDyhqR84UnyzVwhHYJX9xkIi9BIIAjOFXmPrSCbIyHiWp2woAE6LhdDf6XUq//dY TrNRhtfsaOnJGB/SdnrzJffPJChZZpQHqxpXUccWmUTJH3bVEwemnKIp0Nna172cKDnh pvag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=QW1OxwFc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=9elements.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h6-20020a654686000000b0055ad86f58fcsi3086804pgr.553.2023.07.12.04.55.13; Wed, 12 Jul 2023 04:55:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=QW1OxwFc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=9elements.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233285AbjGLLtl (ORCPT + 99 others); Wed, 12 Jul 2023 07:49:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233253AbjGLLtF (ORCPT ); Wed, 12 Jul 2023 07:49:05 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1F551FFC for ; Wed, 12 Jul 2023 04:48:21 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3158a5e64b6so5158407f8f.0 for ; Wed, 12 Jul 2023 04:48:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1689162496; x=1691754496; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nNQjkE8rt0loSfu/6IF9XOAi/Sv+jFDCxC5ymTmcAL4=; b=QW1OxwFcn9/fM3iz2FPMk84jEGix8ud6DvyCVmxBy/7qEKrS9e/ynEzWm9B+Am0Hg/ QQmzkhQhEPk14OWaW4uMddOPGEYsw+4C/4LqtG2r4YaDKwhKwwh2w8FJQ16TOnsNzET8 ymxGgCI2DCwcXjH/0bcJMQlO+w+iaR+QY5GeOT+7C/93teYnYK+UBNGc4E8qFIPyN//b rwlaGuN8g0yMFFFSnnyjaMqJXHYHB//ROaId+Dvm8/cXVeyQRREweVth953vMnFKU+69 eixZmccmqrDJ5M9O03PIuS5DGnkQY0ShbrD2vWEKqPQNRaWPL8qH43rZN3XuaVO43G7i H7rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689162496; x=1691754496; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nNQjkE8rt0loSfu/6IF9XOAi/Sv+jFDCxC5ymTmcAL4=; b=ea9W0v/6KtChmzj/KpQBdUp2g+8cs/Kk8HoiaoNK5GgLiYURpt0XiMfCOxKvBHxlI6 08MbFuTtWd1fomN50p7bFS4737vOzw1JghWt2j06HBVsEAHeWz8fYh8YC5on4IB83DFx vkvzwGOQMXjKcO+d0owdr02hFyv/O9JXej0yMmgGo5F9urScZhspMCHv7DEvqRNTXiwx u60nbotE2liUujZZipqZcoElo1MBXWtzGqXu3FPv1eKjqOzEk5u5BXbE6sWrgs1TERwz obJ1isIkuvKLJ5LfPzGV4bK72aKvubX2nIzv8dcZYXe93OOZv3z14i/AuGvITCrxRVK9 UpCQ== X-Gm-Message-State: ABy/qLZI1fngRym8oewfqeK9S89amnVAqNMb4cI5c/q3HDj02sPkch8r kf8tVpLYt7hcC9zNiDDUwhiHPil7ZYI2YCnlydmToA== X-Received: by 2002:adf:e483:0:b0:314:1bb7:8a19 with SMTP id i3-20020adfe483000000b003141bb78a19mr15814202wrm.35.1689162496665; Wed, 12 Jul 2023 04:48:16 -0700 (PDT) Received: from stroh80.sec.9e.network (ip-078-094-000-051.um19.pools.vodafone-ip.de. [78.94.0.51]) by smtp.gmail.com with ESMTPSA id j2-20020a5d4482000000b003143867d2ebsm4867463wrq.63.2023.07.12.04.48.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 04:48:16 -0700 (PDT) From: Naresh Solanki X-Google-Original-From: Naresh Solanki To: devicetree@vger.kernel.org, Guenter Roeck , Jean Delvare Cc: linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, Patrick Rudolph , Naresh Solanki Subject: [PATCH 3/8] hwmon: (pmbus/mp2975) Prepare for MP2973 and MP2971 Date: Wed, 12 Jul 2023 13:47:44 +0200 Message-ID: <20230712114754.500477-3-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230712114754.500477-1-Naresh.Solanki@9elements.com> References: <20230712114754.500477-1-Naresh.Solanki@9elements.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Patrick Rudolph Add support for differntiating between the chips. The following commits will make use of this mechanism. Signed-off-by: Patrick Rudolph Signed-off-by: Naresh Solanki --- drivers/hwmon/pmbus/mp2975.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/hwmon/pmbus/mp2975.c b/drivers/hwmon/pmbus/mp2975.c index 130cfde52e42..04778f2dcbdb 100644 --- a/drivers/hwmon/pmbus/mp2975.c +++ b/drivers/hwmon/pmbus/mp2975.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "pmbus.h" /* Vendor specific registers. */ @@ -56,8 +57,13 @@ PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | \ PMBUS_HAVE_POUT | PMBUS_PHASE_VIRTUAL) +enum chips { + mp2975 +}; + struct mp2975_data { struct pmbus_driver_info info; + enum chips chip_id; int vout_scale; int vid_step[MP2975_PAGE_NUM]; int vref[MP2975_PAGE_NUM]; @@ -68,6 +74,13 @@ struct mp2975_data { int curr_sense_gain[MP2975_PAGE_NUM]; }; +static const struct i2c_device_id mp2975_id[] = { + {"mp2975", mp2975}, + {} +}; + +MODULE_DEVICE_TABLE(i2c, mp2975_id); + #define to_mp2975_data(x) container_of(x, struct mp2975_data, info) static int mp2975_read_byte_data(struct i2c_client *client, int page, int reg) @@ -691,6 +704,11 @@ static int mp2975_probe(struct i2c_client *client) if (!data) return -ENOMEM; + if (client->dev.of_node) + data->chip_id = (enum chips)of_device_get_match_data(&client->dev); + else + data->chip_id = i2c_match_id(mp2975_id, client)->driver_data; + memcpy(&data->info, &mp2975_info, sizeof(*info)); info = &data->info; @@ -739,15 +757,8 @@ static int mp2975_probe(struct i2c_client *client) return pmbus_do_probe(client, info); } -static const struct i2c_device_id mp2975_id[] = { - {"mp2975", 0}, - {} -}; - -MODULE_DEVICE_TABLE(i2c, mp2975_id); - static const struct of_device_id __maybe_unused mp2975_of_match[] = { - {.compatible = "mps,mp2975"}, + {.compatible = "mps,mp2975", .data = (void *)mp2975}, {} }; MODULE_DEVICE_TABLE(of, mp2975_of_match); -- 2.41.0