From patchwork Fri May 7 20:20:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 12245179 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13A67C433ED for ; Fri, 7 May 2021 20:22:15 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8165C610A0 for ; Fri, 7 May 2021 20:22:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8165C610A0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:cc:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=i/bihlW8hPlCZXphRjXnun/YWXNXlwDc1IZfNcj4zNs=; b=dI+SW89QuZAAwc91cgGgRxzeyG 1AUWdYpWCn8czTui6yxH/WgBKCtoypS68w8VFOE3gunrzQDGPMrQBDCnau4IWSXcLpsl+Kiz8vun0 4kT/dKTqLEM9eZUTR83KI3RTNkpKtiTK0jaJCT1CzZDV8NSMrHl5E4LtUPoj+Ak5+tKhpx2GALab0 3dPrCXpoId6TIHCsdqe5/tIUaHWbdAx2ReV/i0gzIuM5nnpD02zPuZ3sYGdKEaVf0tr0CXoWsyT/k AcDWWW1GaDr66Yv6KfqA0Fvdt2ytujO64qTWnp9Q4xvBA3OHhh6TmwMVwdT3uKQLXEptalCFGHu4x LVGYlYCA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lf6xs-007xZA-91; Fri, 07 May 2021 20:20:48 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lf6xp-007xZ1-9Z for linux-arm-kernel@desiato.infradead.org; Fri, 07 May 2021 20:20:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:MIME-Version:Message-ID: Subject:cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:In-Reply-To:References; bh=IBj/oZGsokAaKHrJmMkspt5KMjTgwL9D5Zw2L25XmNk=; b=L3yGpvry1KkhUFTSZmOtonP1NU fm3CJva1YEMsKSIBfjIqZPbq29F07ku4pwG2Gui19wieFqRgbyFSH8sRI7qpHPYw82JzuGDjcHq6E 2PgnKdD9GfttunuRq+4FaEouFjL56nuz864/ZJsdkYrnzmoAVrjV1RvM2eBiX5l6S8d3G+NSY8+Ya 0iDCGd61WBQSv/WIvuTmC+265ThT9G7X+jkamju8crrkJtoDhzcwbjI4wvZ6ro81KQ5ota+A1CG2H YcMLkAkmxhRiq61bRQ8msTNn7AkTE2F69GR8nf8QwBYfKcDA5SUmD1D5WZMsOh8hLDM/6NMLd7usb RbYen/FA==; Received: from mail-qk1-x72f.google.com ([2607:f8b0:4864:20::72f]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lf6xl-007A5s-E3 for linux-arm-kernel@lists.infradead.org; Fri, 07 May 2021 20:20:43 +0000 Received: by mail-qk1-x72f.google.com with SMTP id 76so9791220qkn.13 for ; Fri, 07 May 2021 13:20:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version; bh=IBj/oZGsokAaKHrJmMkspt5KMjTgwL9D5Zw2L25XmNk=; b=Hg1rtZXFeW6k0VRLwuyxYAG198xLkQPyq0rq2h1n9KGeAISifksU5Jqqfcuf5OEE37 46cb7gU2WIcCR6fPIba4AOAB/ebM3SAwW3qwcUNcKIQei8juISKEqcVJPflc1ZQ9o7yd 5u7tPIdp5UB0K4AfMUgXdauaUtlJhLIQn9Ut9pT/jEIFUiz5tkNXY7NBKmd8gXQdGd3/ Ihhbjhx1BOn5rtrw6cchNsqmopDheG9DVRvbAP/IyZcVd5nI5CDj1U2zxTUIUIG6Oce+ ueDV+oM5bTPNH3ARStg4Bqzw82+ddJ6rMpopg9J+9kQEUc9rQ50ZehwVqIrIMv53ulrE IrOw== 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:mime-version; bh=IBj/oZGsokAaKHrJmMkspt5KMjTgwL9D5Zw2L25XmNk=; b=HMpppNHCGML5s/uEzF15PoHra5Ps2Qvmnp1GQg8QOOqc68PS108JnhAVfcL6izkw+q j2SrzMYU2xSPpQCzd/fxfCirO0G2dIRZhshzDMVqCvkxze8uaymmX/tppm2XOzaH+uzR IxRmXdimdGhYFWP409Vnuk8gFDEcmaCgOf53wbuPRK1pdepkbdzvxpzCxsy8SjJlwfkE SMxq5oIZJj9te0U0/H+3rgQAoEZS5SJwc6lq8aE/KXG+JoxWVeBpHoiUPFnHRbY3/ELe xaUSsxMeBT+y17faDjz/hO2uiqE6dfggeYwBZwiF8HMF7w4vcupFTLFoDZyZkbN3of4v iy8w== X-Gm-Message-State: AOAM531Q3J+p0Btd6N3yASZHCCab0YrtzFDlS3ji+Qj/M+qp0/m0l6+D 4qs+JksJt2tTrycBZPou7Fuq0w== X-Google-Smtp-Source: ABdhPJwus0Ph9xG7MvqxFxPk9LK37uTs096ZLwxIn0l0Ix59WRUCyLGpRDMDo618OkJJVrzzFytLjg== X-Received: by 2002:a37:8906:: with SMTP id l6mr12145662qkd.198.1620418837280; Fri, 07 May 2021 13:20:37 -0700 (PDT) Received: from xanadu.home (modemcable076.50-203-24.mc.videotron.ca. [24.203.50.76]) by smtp.gmail.com with ESMTPSA id g13sm5320343qtp.31.2021.05.07.13.20.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 13:20:36 -0700 (PDT) Date: Fri, 7 May 2021 16:20:36 -0400 (EDT) From: Nicolas Pitre To: Sudeep Holla , Cristian Marussi cc: Dien Pham , Gaku Inami , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] firmware: arm_scmi: add clock management to the SCMI power domain Message-ID: <5q88n947-pon-4940-3or6-s54o4r361o5s@onlyvoer.pbz> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210507_132041_638353_E1BA35D0 X-CRM114-Status: GOOD ( 11.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Clocks requiring non-atomic contexts are supported by the generic clock PM layer since commit 0bfa0820c274 ("PM: clk: make PM clock layer compatible with clocks that must sleep"). That means we can have SCMI-based clocks be managed by the SCMI power domain now. Signed-off-by: Nicolas Pitre Tested-by: Dien Pham Reviewed-by: Gaku Inami diff --git a/drivers/firmware/arm_scmi/scmi_pm_domain.c b/drivers/firmware/arm_scmi/scmi_pm_domain.c index 9d36d5c062..4371fdcd5a 100644 --- a/drivers/firmware/arm_scmi/scmi_pm_domain.c +++ b/drivers/firmware/arm_scmi/scmi_pm_domain.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -52,6 +53,27 @@ static int scmi_pd_power_off(struct generic_pm_domain *domain) return scmi_pd_power(domain, false); } +static int scmi_pd_attach_dev(struct generic_pm_domain *pd, struct device *dev) +{ + int ret; + + ret = pm_clk_create(dev); + if (ret) + return ret; + + ret = of_pm_clk_add_clks(dev); + if (ret >= 0) + return 0; + + pm_clk_destroy(dev); + return ret; +} + +static void scmi_pd_detach_dev(struct generic_pm_domain *pd, struct device *dev) +{ + pm_clk_destroy(dev); +} + static int scmi_pm_domain_probe(struct scmi_device *sdev) { int num_domains, i; @@ -102,6 +124,10 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev) scmi_pd->genpd.name = scmi_pd->name; scmi_pd->genpd.power_off = scmi_pd_power_off; scmi_pd->genpd.power_on = scmi_pd_power_on; + scmi_pd->genpd.attach_dev = scmi_pd_attach_dev; + scmi_pd->genpd.detach_dev = scmi_pd_detach_dev; + scmi_pd->genpd.flags = GENPD_FLAG_PM_CLK | + GENPD_FLAG_ACTIVE_WAKEUP; pm_genpd_init(&scmi_pd->genpd, NULL, state == SCMI_POWER_STATE_GENERIC_OFF);