Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1715969iob; Thu, 5 May 2022 07:03:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyT4sI+acwVwO63L2AtTDdMmH5knd7gFw2kJWsmb8tCpMQV3J3Qf2on5R4asgM8tH0oHjqh X-Received: by 2002:a05:6638:2603:b0:32b:a724:2b8c with SMTP id m3-20020a056638260300b0032ba7242b8cmr1722381jat.278.1651759381718; Thu, 05 May 2022 07:03:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651759381; cv=none; d=google.com; s=arc-20160816; b=bUxSPT//eWkoQoTbXG/h/PHyDeGtsXvWeUDRgXnjAuLe58/ymeIxXp373oEElIi/6T /x+WNe45Kx0Hkga7c+S3xPtnVwbY53XRtkYfQS0ONeuEH2tmL7rpyzPSfKRYWCPddXm0 LZEp+x8wlMKsLKEun3Tco22/rjW3kwxxfcKF4HkMusiBKCK8liujEGk22HeVyBUf1gnU p9OY+pLre44NCs8bSabFrUYAZ7AZnYwkqsRmWu86GZaoQlDLVrKmWlrf130r6HZRMoR4 fHOmZ/I5KZ8kvtZ+tbr/gFRTkfGhhmxPOlRZVj/9i56bGaMj5s7+UpSsoNFEmBOTSWqM RrTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ivtpQPArnDii4Ak4RagQBPep9wABiYjWaqMTgrBJNVU=; b=XkoYQc/02GlRZf6a5Hpx6mbQcl0xSskiQ8ilSYcIuOQaSY5IYYFU8AK7WS65mPM6Sg VhpQvfekVejnvFj8nkvXvFTVTfsOA+lJc3mw3J5T3elOG+7uHFo4W4i9N9hrZwZxsFvE U4kUfGxquYGI+onrp4wrUIQdtCi0ijGs7Wm1d+d+ym0Pa5be3MpAFASUZRQQyhXoP9Ye U/PVLcbAqy9zK4POaLwxzy+/9Icdq78B1vp47MCLdrOxEqanND9dTRevA9EJDYC7Dj67 PgD76Ye5IiYmSX+LQoj610IzZv87MNOCQBK+w+JWcBkXsmieJYEfTpGW7cQyxxSi1JKp 5ihw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b="rWM/qFOv"; 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=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p14-20020a056e02144e00b002cc55127a33si1414626ilo.144.2022.05.05.07.02.44; Thu, 05 May 2022 07:03:01 -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=@quicinc.com header.s=qcdkim header.b="rWM/qFOv"; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353471AbiEEJbM (ORCPT + 99 others); Thu, 5 May 2022 05:31:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353375AbiEEJam (ORCPT ); Thu, 5 May 2022 05:30:42 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 032194C411; Thu, 5 May 2022 02:27:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1651742823; x=1683278823; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=ivtpQPArnDii4Ak4RagQBPep9wABiYjWaqMTgrBJNVU=; b=rWM/qFOvqtOcImh4r85lV2po2Yw03igJu7gPVcLN+yyCps0Rurx0q2bp bGqLHk/i0zC229x6e4oLusSyFEPvM1ymxaahbxn9gm8NDBP1zXhFN1qIY ox40lqihrctv5neLuxSbi+5yRr5t0+bTTlGSLa7tnlJRoYS1v5B1r/5IS Q=; Received: from ironmsg-lv-alpha.qualcomm.com ([10.47.202.13]) by alexa-out.qualcomm.com with ESMTP; 05 May 2022 02:27:03 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg-lv-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2022 02:27:02 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Thu, 5 May 2022 02:27:02 -0700 Received: from c-skakit-linux.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Thu, 5 May 2022 02:26:58 -0700 From: Satya Priya To: Bjorn Andersson , Rob Herring CC: Lee Jones , Liam Girdwood , Mark Brown , , , , , , , , Satya Priya Subject: [PATCH V11 6/9] mfd: pm8008: Use i2c_new_dummy_device() API Date: Thu, 5 May 2022 14:55:36 +0530 Message-ID: <1651742739-12338-7-git-send-email-quic_c_skakit@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1651742739-12338-1-git-send-email-quic_c_skakit@quicinc.com> References: <1651742739-12338-1-git-send-email-quic_c_skakit@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Use i2c_new_dummy_device() to register pm8008-regulator client present at a different address space, instead of defining a separate DT node. This avoids calling the probe twice for the same chip, once for each client pm8008-infra and pm8008-regulator. As a part of this define pm8008_regmap_init() to do regmap init for both the clients and define pm8008_get_regmap() to pass the regmap to the regulator driver. Signed-off-by: Satya Priya --- Changes in V11: - Remove the for loop and register dummy directly as there are only 2 clients. - Define pm8008_regmap_init() API to do the redundant init part. Changes in V10: - Implement i2c_new_dummy_device to register extra clients. drivers/mfd/qcom-pm8008.c | 31 +++++++++++++++++++++++++++++-- include/linux/mfd/qcom_pm8008.h | 8 ++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 include/linux/mfd/qcom_pm8008.h diff --git a/drivers/mfd/qcom-pm8008.c b/drivers/mfd/qcom-pm8008.c index 40a67f0..25e8d0b 100644 --- a/drivers/mfd/qcom-pm8008.c +++ b/drivers/mfd/qcom-pm8008.c @@ -57,6 +57,7 @@ enum { struct pm8008_data { struct device *dev; + struct regmap *regulators_regmap; int irq; struct regmap_irq_chip_data *irq_data; }; @@ -150,6 +151,11 @@ static struct regmap_config qcom_mfd_regmap_cfg = { .max_register = 0xFFFF, }; +struct regmap *pm8008_get_regmap(struct pm8008_data *chip) +{ + return chip->regulators_regmap; +} + static int pm8008_init(struct regmap *regmap) { int rc; @@ -217,11 +223,25 @@ static int pm8008_probe_irq_peripherals(struct pm8008_data *chip, return 0; } +static struct regmap *pm8008_regmap_init(struct i2c_client *client, + struct pm8008_data *chip) +{ + struct regmap *regmap; + + regmap = devm_regmap_init_i2c(client, &qcom_mfd_regmap_cfg); + if (!regmap) + return NULL; + + i2c_set_clientdata(client, chip); + return regmap; +} + static int pm8008_probe(struct i2c_client *client) { int rc; struct pm8008_data *chip; struct gpio_desc *reset_gpio; + struct i2c_client *regulators_client; struct regmap *regmap; chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); @@ -229,11 +249,18 @@ static int pm8008_probe(struct i2c_client *client) return -ENOMEM; chip->dev = &client->dev; - regmap = devm_regmap_init_i2c(client, &qcom_mfd_regmap_cfg); + regmap = pm8008_regmap_init(client, chip); if (!regmap) return -ENODEV; - i2c_set_clientdata(client, chip); + regulators_client = i2c_new_dummy_device(client->adapter, client->addr + 1); + if (IS_ERR(regulators_client)) { + dev_err(&client->dev, "can't attach client\n"); + return PTR_ERR(regulators_client); + } + chip->regulators_regmap = pm8008_regmap_init(regulators_client, chip); + if (!chip->regulators_regmap) + return -ENODEV; if (of_property_read_bool(chip->dev->of_node, "interrupt-controller")) { rc = pm8008_probe_irq_peripherals(chip, regmap, client->irq); diff --git a/include/linux/mfd/qcom_pm8008.h b/include/linux/mfd/qcom_pm8008.h new file mode 100644 index 0000000..e79e578 --- /dev/null +++ b/include/linux/mfd/qcom_pm8008.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __QCOM_PM8008_H__ +#define __QCOM_PM8008_H__ + +struct pm8008_data; +struct regmap *pm8008_get_regmap(struct pm8008_data *chip); + +#endif -- 2.7.4