Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5751325imm; Tue, 12 Jun 2018 12:43:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJGQ/xxWBafKQPI4icUpbh2uOOnCNd2cAPEYN2KQy40jh2fawJdEZXkHPf/vT2ZL3Jm5E8M X-Received: by 2002:a63:6501:: with SMTP id z1-v6mr1484442pgb.452.1528832591851; Tue, 12 Jun 2018 12:43:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528832591; cv=none; d=google.com; s=arc-20160816; b=QibqDbv/qbNuiYijYus6ur/P/xqWKMNqCZbDJgBPSvCxzzQbunAEuiFXJtRAod1Q0t nlfotSBJkrCxcjqd+Wfax+RXApgsZm7V2iuT6rRmSGmxFgA5vS3Yn68IafrFc0INteMO +4451SgY0nIRmaDE7RsS2wTvt1wnwXvlJOESEjzooKigsUcyV5FvXNjT7thmv8ESFaF+ XqVVhGqAEcu3KwMLRiGDpQlXWcmQ3SiYovHY9tabsFu8VTtsWGdeThVk8ZgvSR/YHWqC dhjHaSKJI7vygShxuE8TXcwHaxEiH7yXxvb0SATvIavh60wKw3dQzA1/cxPW3ZjPml7v WFbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=Z8tWk21EbOUM/7yZ5vR3wRSPVlC0AC0/fpwGfzSWhBw=; b=vmts70g+VZJnODr7lzuSWxAkj5R91OCGvYxLPvhLZtcygth9kRf9kNm+KMruuB1VQt fqvGkRKl9N5547c6I0ow5+44v/BndLXdCzgyvAxi1WWYC2pH1nruFz9P63OJj/rA428P ivruqM2SRIkGdNGcpCK6JfjrVdpPDNvVcKUC/2qKaHwzMOkYo8hyUVOrQckiey/pValP vPytwV5zk4RCIsNlJMVjDuPPVtdZy60upnyszAa3RfcJFZ8pb+Uw7dfRi0mr3YH4JVLu JXJ1AFp0IrlIHu5jkOrw8itO6FA0j9O8EvIur3Pd7WRfQwuQed1KaFARAnbIhv+TqPhU yHbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LRnTKc9J; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u190-v6si841911pfb.325.2018.06.12.12.42.56; Tue, 12 Jun 2018 12:43:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LRnTKc9J; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933366AbeFLTma (ORCPT + 99 others); Tue, 12 Jun 2018 15:42:30 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:38504 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932926AbeFLTm2 (ORCPT ); Tue, 12 Jun 2018 15:42:28 -0400 Received: by mail-pl0-f65.google.com with SMTP id b14-v6so74250pls.5 for ; Tue, 12 Jun 2018 12:42:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Z8tWk21EbOUM/7yZ5vR3wRSPVlC0AC0/fpwGfzSWhBw=; b=LRnTKc9JGdpVFvBJGWoEKakKeI7x5wmyY91s7ETf0OZRNJ8VU/566aD/APqA2xbp9T Y0uz5ACH75A9J8i/FAJ3tH33d2CCFv+HNrDrEdXyWTlxD1t6G7gJmU5Ymx8LVF4JwR/3 v/laIeor7dn6LObzouDA81jQ06YuTayLbri1E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Z8tWk21EbOUM/7yZ5vR3wRSPVlC0AC0/fpwGfzSWhBw=; b=WgF2oimKt+uvqAND1E74oZbEFs4oGtkfBzCF7qUggD03sJAJ2MM5cwNAmmpZU33E49 B004XrdQftWM6RAco9byzVtsZxItN2jZJU1jPVvCXD7xAKGk2Vjk9MPGJMDgaHmpDPwF JImGtDJj1TJsIhq0Bv+I6UvLSbhzxteKVaz+LJC1DK304OmNjsAJSBFSyI25HNkh8977 JB0WGB57YPW5WHvCfhbaA6qqmCUjbkUdtIEwQcYwSCaMVkeQ6A5ebC9NiegHLZjLughz kche0ArwaWAlOP/3TVAZ5cmP2OnZCXZsqZtdLjPXPFX5IU4gsqrccyeky4igjhWara5f uGHQ== X-Gm-Message-State: APt69E2ADxiLYdWmfxQc8XO/+gcZbnYyZmBnwMLyHP/su3/8bBMrvYvH jS5IXtVZ2NDR4NJIDqjfGSQpBg== X-Received: by 2002:a17:902:981:: with SMTP id 1-v6mr1870103pln.11.1528832548029; Tue, 12 Jun 2018 12:42:28 -0700 (PDT) Received: from localhost ([2620:0:1000:1501:8e2d:4727:1211:622]) by smtp.gmail.com with ESMTPSA id j127-v6sm1150382pgc.10.2018.06.12.12.42.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Jun 2018 12:42:26 -0700 (PDT) Date: Tue, 12 Jun 2018 12:42:26 -0700 From: Matthias Kaehlcke To: Rajendra Nayak Cc: viresh.kumar@linaro.org, sboyd@kernel.org, andy.gross@linaro.org, ulf.hansson@linaro.org, collinsd@codeaurora.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 6/7] soc: qcom: Add RPMh Power domain driver Message-ID: <20180612194226.GI88063@google.com> References: <20180612044052.4402-1-rnayak@codeaurora.org> <20180612044052.4402-7-rnayak@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180612044052.4402-7-rnayak@codeaurora.org> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, Jun 12, 2018 at 10:10:51AM +0530, Rajendra Nayak wrote: > The RPMh Power domain driver aggregates the corner votes from various > consumers for the ARC resources and communicates it to RPMh. > > We also add data for all power domains on sdm845 SoC as part of the patch. > The driver can be extended to support other SoCs which support RPMh > > Signed-off-by: Rajendra Nayak > --- > drivers/soc/qcom/Kconfig | 9 + > drivers/soc/qcom/Makefile | 1 + > drivers/soc/qcom/rpmhpd.c | 427 ++++++++++++++++++++++++ > include/dt-bindings/power/qcom-rpmhpd.h | 31 ++ > 4 files changed, 468 insertions(+) > create mode 100644 drivers/soc/qcom/rpmhpd.c > create mode 100644 include/dt-bindings/power/qcom-rpmhpd.h > > diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig > index 5c54931a7b99..7cb7eba2b997 100644 > --- a/drivers/soc/qcom/Kconfig > +++ b/drivers/soc/qcom/Kconfig > @@ -74,6 +74,15 @@ config QCOM_RMTFS_MEM > > Say y here if you intend to boot the modem remoteproc. > > +config QCOM_RPMHPD > + tristate "Qualcomm RPMh Power domain driver" > + depends on QCOM_RPMH && QCOM_COMMAND_DB > + help > + QCOM RPMh Power domain driver to support power-domains with > + performance states. The driver communicates a performance state > + value to RPMh which then translates it into corresponding voltage > + for the voltage rail. > + > config QCOM_RPMPD > tristate "Qualcomm RPM Power domain driver" > depends on MFD_QCOM_RPM && QCOM_SMD_RPM > diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile > index 9550c170de93..499513f63bef 100644 > --- a/drivers/soc/qcom/Makefile > +++ b/drivers/soc/qcom/Makefile > @@ -16,3 +16,4 @@ obj-$(CONFIG_QCOM_SMSM) += smsm.o > obj-$(CONFIG_QCOM_WCNSS_CTRL) += wcnss_ctrl.o > obj-$(CONFIG_QCOM_APR) += apr.o > obj-$(CONFIG_QCOM_RPMPD) += rpmpd.o > +obj-$(CONFIG_QCOM_RPMHPD) += rpmhpd.o > diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c > new file mode 100644 > index 000000000000..7083ec1590ff > --- /dev/null > +++ b/drivers/soc/qcom/rpmhpd.c > @@ -0,0 +1,427 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* Copyright (c) 2018, The Linux Foundation. All rights reserved.*/ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define domain_to_rpmhpd(domain) container_of(domain, struct rpmhpd, pd) > + > +#define DEFINE_RPMHPD_AO(_platform, _name, _active) \ > + static struct rpmhpd _platform##_##_active; \ > + static struct rpmhpd _platform##_##_name = { \ > + .pd = { .name = #_name, }, \ > + .peer = &_platform##_##_active, \ > + .res_name = #_name".lvl", \ > + .valid_state_mask = (BIT(RPMH_ACTIVE_ONLY_STATE) | \ > + BIT(RPMH_WAKE_ONLY_STATE) | \ > + BIT(RPMH_SLEEP_STATE)), \ > + }; \ > + static struct rpmhpd _platform##_##_active = { \ > + .pd = { .name = #_active, }, \ > + .peer = &_platform##_##_name, \ > + .active_only = true, \ > + .res_name = #_name".lvl", \ > + .valid_state_mask = (BIT(RPMH_ACTIVE_ONLY_STATE) | \ > + BIT(RPMH_WAKE_ONLY_STATE) | \ > + BIT(RPMH_SLEEP_STATE)), \ > + } > + > +#define DEFINE_RPMHPD(_platform, _name) \ > + static struct rpmhpd _platform##_##_name = { \ > + .pd = { .name = #_name, }, \ > + .res_name = #_name".lvl", \ > + .valid_state_mask = BIT(RPMH_ACTIVE_ONLY_STATE), \ > + } Perhaps describe briefly the concept of an AO (active-only) and a peer domain. It is not necessarily evident why an AO domain would have WAKE_ONLY and SLEEP_ONLY as valid states, while the non-AO domain has ACTIVE_ONLY as it's only state. > +/* > + * This function is used to aggregate the votes across the active only > + * resources and its peers. The aggregated votes are send to RPMh as s/send/sent/ > + * ACTIVE_ONLY votes (which take effect immediately), as WAKE_ONLY votes > + * (applied by RPMh on system wakeup) and as SLEEP votes (applied by RPMh > + * on system sleep). > + * We send ACTIVE_ONLY votes for resources without any peers. For others, > + * which have an active only peer, all 3 Votes are sent. s/Votes/votes/ > +static int rpmhpd_probe(struct platform_device *pdev) > +{ > + int i, ret; > + size_t num; nit: naming this num_pds would slightly improve readability (e.g. make it evident that the for loop iterates over the PDs). > + struct genpd_onecell_data *data; > + struct rpmhpd **rpmhpds; > + const struct rpmhpd_desc *desc; > + > + desc = of_device_get_match_data(&pdev->dev); > + if (!desc) > + return -EINVAL; > + > + rpmhpds = desc->rpmhpds; > + num = desc->num_pds; > + > + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); > + if (!data) > + return -ENOMEM; > + > + data->domains = devm_kcalloc(&pdev->dev, num, sizeof(*data->domains), > + GFP_KERNEL); Check for NULL? Thanks Matthias