Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp847419pxb; Wed, 6 Apr 2022 01:47:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwW6ApgdxZWOm6RqgncHwdPgxPAJtvjYaRdp+wvjFGpTT9tokX8/7Wh2khHE3J4Cqf15BV/ X-Received: by 2002:a63:51:0:b0:398:a2b7:be6 with SMTP id 78-20020a630051000000b00398a2b70be6mr4137807pga.214.1649234825885; Wed, 06 Apr 2022 01:47:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649234825; cv=none; d=google.com; s=arc-20160816; b=FT6noQTfMyiorsJCIulQWcoDXsgjLxLlwPhivqzS0yi+/4hoxvHSpdtuF7L46RQxJA V+j1LC5cIJNj74jzfj+VBGF+UPu+SPuHWtoQMjYAk7auqvqugsBoRYKYIghyZMlZvzxL Q1SugRhdZsfQSvtT9OHRjatUONKe4ln5VisaApVWUiiUn+pUiy6qulLyzw1tKfCv5PV3 P29n6bVVtSs5gNWfHJqyc6BF6OupSSXvs4lc4NBOwqeu0DA+MmGS7FFaRtvY6rAmOzKz r8PH05l5GmxBSMoiU0gcb0i9xzrC2hShUO3UTG4g3dLIxdn0Q9FqnxlwEteZxypUEOMX O3LA== 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=hMIn10jdMOZ3d+zm3mh/P4foFQUZ8FiHKOHW1rBiQyk=; b=aHLSHe+5r7GPif2xMlQBoCdtf01gobpEEAiDEJik+9Su4/DyZ1ajFo0XM3cQMSfkXB ApDohILx/wrS5Wfm8mMy7F2G633Oj5aZR8wPIuWlGyLXxw98ao6kVh46Dw1YdVaPj+u7 HXPCeJwjfCWUSX9UwJxvgOX+pQlRRinQO1QvidaL6SEmqSledeFhgTHOTTcMQGNfsMyX y5qttDbwVYcHQgGTynsX5JsPWdFaL/ayogZSZK2IJD5CmeroSVjODjM0NnrVJCT9AMr2 y/2KynpuMx5rpd9C2sIHrzDQHJC1VNi72zaAqpBj/8FIgSgoFjuYSQ52oM7YIUosU5gq n3dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=KjFLfrB7; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d7-20020a170903230700b00156bdbdedf4si6301858plh.269.2022.04.06.01.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 01:47:05 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=KjFLfrB7; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B82C5588358; Wed, 6 Apr 2022 01:32:57 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1584115AbiDEX5y (ORCPT + 99 others); Tue, 5 Apr 2022 19:57:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442202AbiDEPhI (ORCPT ); Tue, 5 Apr 2022 11:37:08 -0400 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0D5BF1EA7; Tue, 5 Apr 2022 06:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1649166684; x=1680702684; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=hMIn10jdMOZ3d+zm3mh/P4foFQUZ8FiHKOHW1rBiQyk=; b=KjFLfrB70J1Uc7rMVAQpTc0ojUYjsennUg7P6N9rjiPtJleyoig263ug w8w4Y8x5uuz1NoosSqb2az12PsGe23OYYmP20MVv3fdgdXp2lXgmL2isu YkBN69zLICYLEW4qkx1JT1gErd6PSpq37O0ATFLUEgJwUDA2AzE43I0m1 Y=; Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by alexa-out-sd-02.qualcomm.com with ESMTP; 05 Apr 2022 06:51:24 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg02-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2022 06:51:23 -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; Tue, 5 Apr 2022 06:51:23 -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; Tue, 5 Apr 2022 06:51:19 -0700 From: Satya Priya To: Bjorn Andersson , Rob Herring CC: Lee Jones , Liam Girdwood , Mark Brown , , , , , , , , Satya Priya Subject: [PATCH V9 3/6] mfd: pm8008: Add mfd cell struct to register LDOs Date: Tue, 5 Apr 2022 19:20:30 +0530 Message-ID: <1649166633-25872-4-git-send-email-quic_c_skakit@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1649166633-25872-1-git-send-email-quic_c_skakit@quicinc.com> References: <1649166633-25872-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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Add mfd cell struct to match with the "qcom,pm8008-regulator" driver and a separate probe to add pm8008_regulator_devs. This separate probe is required to ensure the regulators are registered only with the mfd device which contains regulators. Add the reset-gpio toggling in the pm8008_probe() to bring pm8008 chip out of reset instead of doing it in DT node using "output-high" property. Signed-off-by: Satya Priya --- Changes in V6: - Changed the mfd_cell struct to have only name of the regulator driver. - Using device_get_match_data() instead of of_match_node() to match data. - Fixed few nits. Changes in V7: - Fixed minor errors. Changes in V8: - Split the probe for infra and regulator devices - Add the reset-gpio toggling in the infra driver probe Changes in V9: - Fixed nits. drivers/mfd/qcom-pm8008.c | 80 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 2 deletions(-) diff --git a/drivers/mfd/qcom-pm8008.c b/drivers/mfd/qcom-pm8008.c index c472d7f..c7781ab 100644 --- a/drivers/mfd/qcom-pm8008.c +++ b/drivers/mfd/qcom-pm8008.c @@ -4,10 +4,12 @@ */ #include +#include #include #include #include #include +#include #include #include #include @@ -27,6 +29,10 @@ #define INT_EN_CLR_OFFSET 0x16 #define INT_LATCHED_STS_OFFSET 0x18 +static const struct mfd_cell pm8008_regulator_devs[] = { + MFD_CELL_NAME("qcom,pm8008-regulators"), +}; + enum { PM8008_MISC, PM8008_TEMP_ALARM, @@ -57,6 +63,7 @@ enum { struct pm8008_data { struct device *dev; struct regmap *regmap; + struct gpio_desc *reset_gpio; int irq; struct regmap_irq_chip_data *irq_data; }; @@ -239,13 +246,44 @@ static int pm8008_probe(struct i2c_client *client) dev_err(chip->dev, "Failed to probe irq periphs: %d\n", rc); } + chip->reset_gpio = devm_gpiod_get(chip->dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(chip->reset_gpio)) { + dev_err(chip->dev, "failed to acquire reset gpio\n"); + return PTR_ERR(chip->reset_gpio); + } + gpiod_set_value(chip->reset_gpio, 1); + return devm_of_platform_populate(chip->dev); } +static int pm8008_probe_regulators(struct i2c_client *client) +{ + + int rc; + struct pm8008_data *chip; + + chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); + if (!chip) + return -ENOMEM; + + chip->dev = &client->dev; + chip->regmap = devm_regmap_init_i2c(client, &qcom_mfd_regmap_cfg); + if (!chip->regmap) + return -ENODEV; + + rc = devm_mfd_add_devices(chip->dev, 0, pm8008_regulator_devs, + ARRAY_SIZE(pm8008_regulator_devs), NULL, 0, NULL); + if (rc) + dev_err(chip->dev, "Failed to add children: %d\n", rc); + + return rc; +} + static const struct of_device_id pm8008_match[] = { { .compatible = "qcom,pm8008", }, - { }, + { } }; +MODULE_DEVICE_TABLE(of, pm8008_match); static struct i2c_driver pm8008_mfd_driver = { .driver = { @@ -254,7 +292,45 @@ static struct i2c_driver pm8008_mfd_driver = { }, .probe_new = pm8008_probe, }; -module_i2c_driver(pm8008_mfd_driver); + +static const struct of_device_id pm8008_regulators_match[] = { + { .compatible = "qcom,pm8008-regulators", }, + { } +}; +MODULE_DEVICE_TABLE(of, pm8008_regulators_match); + +static struct i2c_driver pm8008_regulators_driver = { + .driver = { + .name = "pm8008-regulators", + .of_match_table = pm8008_regulators_match, + }, + .probe_new = pm8008_probe_regulators, +}; + +static int __init pm8008_i2c_init(void) +{ + int ret; + + ret = i2c_add_driver(&pm8008_mfd_driver); + if (ret) { + pr_err("Failed to register driver for pm8008_infra: %d\n", ret); + return ret; + } + + ret = i2c_add_driver(&pm8008_regulators_driver); + if (ret) + pr_err("Failed to register driver for pm8008_regulators: %d\n", ret); + + return ret; +} +module_init(pm8008_i2c_init); + +static void __exit pm8008_i2c_exit(void) +{ + i2c_del_driver(&pm8008_mfd_driver); + i2c_del_driver(&pm8008_regulators_driver); +} +module_exit(pm8008_i2c_exit); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("i2c:qcom-pm8008"); -- 2.7.4