Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp2491206rwp; Fri, 14 Jul 2023 07:03:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlEmye9xGzDjkk5hoAjimGFcVUYBaMMn1FLbWZi8CqXePRIAN6FDOMVBzzKRBXi8GwXaqbDV X-Received: by 2002:a05:6870:6488:b0:1b7:24d4:a8e9 with SMTP id cz8-20020a056870648800b001b724d4a8e9mr6500268oab.38.1689343380041; Fri, 14 Jul 2023 07:03:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689343380; cv=none; d=google.com; s=arc-20160816; b=jMeAGv97UHe4pqTO0VZcZ+22ODGlt7/tNUVcBAGHqqaj3e065kdTxj9qf2cFbM7Bmk E+gEgxtcHizn7+TaKDahF0KyEuo3DcfPed4H04ewoMK+r4l3YyMgpsSZEDgKJIP7wi0B R9Dn+7v8ejy5Wlncr6QUbTYdr8isabbYXq5DzwybuZNdlkzzhr5aBwATlQDK0j6YAKkW wi1ZaCckQ1vxszHaV2kzbG2Y9JtwYfAODaJQKs48wS89SwI0+ymCcEpQmEjP2WIEe8AL +YfO/iELHrRzyUBLO29/rQb/+KQdE/38I7zaW5E9/qrziwXlOj87YRW0enIujY13VLMW ATxA== 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=rS/uUew7zAKAy9fkv+PU5+3sx8fio6b/ogujgUMAdAlUVLAcPp6r9wa9uhRjETA4oG y0R2SQteDENE2PqiGtKw3aSPym2DkZ+TqFjvaSnvwCVVHrNnQ0vBvdc6r3W+8kQMll03 AbdVw2Pn+NQUDd9OuqthBWD2u2t/W6v+p34FGwGiwLdVMuSxcry3TMHGHWXU+5VezUlK Ud1IP849t8DQ2lvzxWRXjTNboashBxdB9rMVISFdtoajNwe6x+37a6aKID9m+AmzyyiD EBZHODi/6guj/RmHpBegjWR1Qa2EFBFTSz42/E6MAs4x9JZ3QTRs2Oe/9TuyneS5kASR aUDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=CAoScYra; 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 j63-20020a638042000000b0055ab9bf1e3csi1397346pgd.738.2023.07.14.07.02.46; Fri, 14 Jul 2023 07:02:59 -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=CAoScYra; 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 S235487AbjGNNvr (ORCPT + 99 others); Fri, 14 Jul 2023 09:51:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235849AbjGNNvm (ORCPT ); Fri, 14 Jul 2023 09:51:42 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 079B735AE for ; Fri, 14 Jul 2023 06:51:34 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-4fb8574a3a1so3253835e87.1 for ; Fri, 14 Jul 2023 06:51:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1689342692; x=1691934692; 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=CAoScYrac6wbsvgf3sCMIHSfG/XzOgLvZwMP16U/7iGRxj0aeq6Qmevw4df6X9scar SzZtfeh+IvZxJHqY+y8996NhE8uM/yj4/2X1rLO/2mc7fUJwLd/MJHEYcklGEEtg9dVE HfVkUBg1Hu0OBW0vJ+5vJZzpXhPnMobGOs9u5EdqsCTFSK90I0Cbl0wd8C6gdOf5+K7N 0C5hoKxZir6Xxx3OVQ5clhrtdGIyJcXS8v0fDYj79V7kM4Xoqx9HVXvQKXcaTH07j5wI 78S4zgXWu4YOvicqE/rw6CJ2GSLWHKXQiq7gyJxy4EC4h0UYo8C40ct9Ap8DgdBPLmxV Fy2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689342692; x=1691934692; 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=IKlcX/MXuJIMCsdAIKaPP5RD+0WTT5of5QyBo/l2d8MTJIkwpdsnQMVKWfMqv5d3HW O8biY+8x9WPP/w9aSh4P7eVHB6j5FqAkI6yTHEaTub5z7ZJTj/9+vwbD6AXgogwxsQ3J ho9c8YCy2MlpokQw2ZWMLrZhlPJHhztkv902N+dLnBS/uhjO/qslZVnHTWU5JXU43ixL Z6ron4rjogsfBll0pSORhF0J9C/zOqNjXPuacerzklKyDcwsFuFblU0vCc20DNYPXcdz ApOHcM+B25uyZoMdDwEUhQhgQLzTIO4p1QBUgykpNZjrz5s/UPVfPHlR5Gph5RS+m8N7 8xDg== X-Gm-Message-State: ABy/qLZNHP+nTBvzZ1UIEsu9PiEqvFkbXBgGifuD3hgTT4T530HETNyI 9IwxgojMJWANsAEBaLVCYVB5Qw== X-Received: by 2002:a05:6512:2202:b0:4f6:2a02:fc1a with SMTP id h2-20020a056512220200b004f62a02fc1amr4347481lfu.17.1689342692293; Fri, 14 Jul 2023 06:51:32 -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 h21-20020a170906261500b0099236e3f270sm5405991ejc.58.2023.07.14.06.51.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 06:51:31 -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 v2 3/8] hwmon: (pmbus/mp2975) Prepare for MP2973 and MP2971 Date: Fri, 14 Jul 2023 15:51:11 +0200 Message-ID: <20230714135124.2645339-3-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230714135124.2645339-1-Naresh.Solanki@9elements.com> References: <20230714135124.2645339-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