From patchwork Thu Oct 10 07:43:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 13829705 Received: from mail.andi.de1.cc (mail.andi.de1.cc [178.238.236.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF0E31C578E; Thu, 10 Oct 2024 07:44:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.238.236.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728546253; cv=none; b=ReOiEz/5W+gdDFjQcW20lwiEyvUc8Qj65YwOC0kPYiKZ3e0oEiEHq4a/ituiGxs/JNom1wJwcR4hJQPQU/ksLYCBLZ4uonYMTOWe7aQ+I6jnV3xmc5fpeVioleEofK/oPPxJi3FfAdnQsJorVdP6ptEainQYO5QFDwCdFCqQuUw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728546253; c=relaxed/simple; bh=UcH6ZwQpDDpiAPLT6qRi38NHMPG4XswrW05ZPPtVgqI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=P0FS+eUBZ53hrd5BHCCk6xTnDRSzbC+KpAS2LyZar1QyvXqkH5PzpKAohk7iiY5+jxSCZWA1wV01AMWm4pd1rtZAOqIRJEgR+kQV4gvG11XJa1hlHadvsvzR3PUo6B+apEIVnDZsauQInmCEgAJLvpKwR5/qPXsbMxEIIj7B17Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=kemnade.info; spf=pass smtp.mailfrom=kemnade.info; dkim=pass (2048-bit key) header.d=kemnade.info header.i=@kemnade.info header.b=zITA+Jb5; arc=none smtp.client-ip=178.238.236.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=kemnade.info Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kemnade.info Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kemnade.info header.i=@kemnade.info header.b="zITA+Jb5" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20220719; h=References:In-Reply-To:Cc:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=spHaL3P3DN7KW+wQRhWKlP9ALzDUk/VvDg6u1f0Em0E=; b=zITA+Jb5ccN8C5m6aLnbqCUFrc 8FCH0jOmljsG9BXsr8vj51sbWmKjpAto3sTZdMogC/L0EtJP43GlNIC2rYzKfUHZXOd1Kz/y4CUwg bIJbJFrXaBjz9whKMtGNyGWeIeFJetfXmrlj5JAip+XiHYy1P97IaPgo9Rdkdl6VxKVHU9VMdqgRp 9YoSsBElnRHmWnGsrdyIQy9XOM5kbreszbyu3dawlXN336rGLB3G3H67skqLoTO1SAEuAk3jYagfd J5qhitHW7D/JxGAWzNRS3O8agaWreYxK6IXxOA2v70xGx9khjqrtbk7NJJfR4Ba2yRRhrdLyzjB9l EE78sdFA==; From: Andreas Kemnade To: Kevin Hilman , Michael Turquette , Aaro Koskinen , linux-kernel@vger.kernel.org, Tony Lindgren , linux-clk@vger.kernel.org, Lee Jones , Roger Quadros , Stephen Boyd , linux-omap@vger.kernel.org Cc: Andreas Kemnade Subject: [PATCH v4 1/3] mfd: twl-core: Add a clock subdevice for the TWL6030 Date: Thu, 10 Oct 2024 09:43:53 +0200 Message-Id: <20241010074355.58161-2-andreas@kemnade.info> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241010074355.58161-1-andreas@kemnade.info> References: <20241010074355.58161-1-andreas@kemnade.info> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Also the TWL6030 has some clocks, so add a subdevice for that. Signed-off-by: Andreas Kemnade Reviewed-by: Roger Quadros --- drivers/mfd/twl-core.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index c130ffef182f..f89eda4a17fe 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c @@ -711,6 +711,10 @@ static struct of_dev_auxdata twl_auxdata_lookup[] = { { /* sentinel */ }, }; +static const struct mfd_cell twl6030_cells[] = { + { .name = "twl6030-clk" }, +}; + static const struct mfd_cell twl6032_cells[] = { { .name = "twl6032-clk" }, }; @@ -861,17 +865,23 @@ twl_probe(struct i2c_client *client) TWL4030_DCDC_GLOBAL_CFG); } - if (id->driver_data == (TWL6030_CLASS | TWL6032_SUBCLASS)) { - status = devm_mfd_add_devices(&client->dev, - PLATFORM_DEVID_NONE, - twl6032_cells, - ARRAY_SIZE(twl6032_cells), - NULL, 0, NULL); + if (twl_class_is_6030()) { + const struct mfd_cell *cells; + int num_cells; + + if (id->driver_data & TWL6032_SUBCLASS) { + cells = twl6032_cells; + num_cells = ARRAY_SIZE(twl6032_cells); + } else { + cells = twl6030_cells; + num_cells = ARRAY_SIZE(twl6030_cells); + } + + status = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE, + cells, num_cells, NULL, 0, NULL); if (status < 0) goto free; - } - if (twl_class_is_6030()) { if (of_device_is_system_power_controller(node)) { if (!pm_power_off) pm_power_off = twl6030_power_off; From patchwork Thu Oct 10 07:43:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 13829706 Received: from mail.andi.de1.cc (mail.andi.de1.cc [178.238.236.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2BA9D1F9417; Thu, 10 Oct 2024 07:44:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.238.236.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728546253; cv=none; b=ixxACix+9LuUU3MDuiUr+g2h/E93rQJqpFldONtZH9usOfaFFH9Z8SgHp8mx50wJp+MgkBNFZTItYIuvXRlUBpXIuxcuGPDREx5anNp8H8wDVNhrjmq1dNCMuedXFJN0saxtH+HeDOPXkQxN5dJICSbXzfwkpJpnrHzXXbFZDm0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728546253; c=relaxed/simple; bh=Zfm5WdnxB5JQj8ViyWS1iuKc6KGaS55oRV/JIcQEN9g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LFYsfmFxyT7TfQQz674a043E/UVBd4DW/RghG7iPbDBMuMr7TzM5F3T1ctXn5gVcNjZ4xnAtPrqliYNGVJ3qjaKjI1x8X7LDrMCM5h3qGmytwDNK/XTAu3vqq+rDC4xYyOdiQQK2ordyVWwVwf+w6DSuM0KP6wukFGy2PFysNQA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=kemnade.info; spf=pass smtp.mailfrom=kemnade.info; dkim=pass (2048-bit key) header.d=kemnade.info header.i=@kemnade.info header.b=dPwUfmjd; arc=none smtp.client-ip=178.238.236.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=kemnade.info Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kemnade.info Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kemnade.info header.i=@kemnade.info header.b="dPwUfmjd" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20220719; h=References:In-Reply-To:Cc:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=n0WcT2lZw1h2vJag9n+5dAZkKzRqfsiI2Q87+Bz0eX4=; b=dPwUfmjdC/U7ZKIyAtRNaWH5ne J9Etce4G/IbhoaZ0Rs4u/aZXanIHnghWxjgumYi1vs0pbM+x5I+tSKNyKeluR8yZuRe06D55Z0IyZ yHKbyMZQSLjFQw03b7bCm6J+paa1eNrBIAc5Z3Uh5pz+6N50gCA7Os9TloUZ/cp+PHyQnOjOslGK1 Cnwt4DjHTMb6d27xXsbonWjK2uOVRiMg1GHeKQIWB42SkZviRazhi4oyhesZZiZeeFEx8EAXz7hFq okTNiQpZm8FYaF6/rZFTqfloK/l52ZIfpGK+m6CmKYK12v+6qBCDAvmAxh8KgBO3NscQeddV6kmPf C/yKb1Cg==; From: Andreas Kemnade To: Kevin Hilman , Michael Turquette , Aaro Koskinen , linux-kernel@vger.kernel.org, Tony Lindgren , linux-clk@vger.kernel.org, Lee Jones , Roger Quadros , Stephen Boyd , linux-omap@vger.kernel.org Cc: Andreas Kemnade Subject: [PATCH v4 2/3] clk: twl: remove is_prepared Date: Thu, 10 Oct 2024 09:43:54 +0200 Message-Id: <20241010074355.58161-3-andreas@kemnade.info> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241010074355.58161-1-andreas@kemnade.info> References: <20241010074355.58161-1-andreas@kemnade.info> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove is_prepared to simplify adding of TWL6030 support. The default implementation should be enough. Signed-off-by: Andreas Kemnade Reviewed-by: Roger Quadros --- drivers/clk/clk-twl.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/drivers/clk/clk-twl.c b/drivers/clk/clk-twl.c index eab9d3c8ed8a..1d684b358401 100644 --- a/drivers/clk/clk-twl.c +++ b/drivers/clk/clk-twl.c @@ -77,26 +77,9 @@ static void twl6032_clks_unprepare(struct clk_hw *hw) dev_err(cinfo->dev, "clk unprepare failed\n"); } -static int twl6032_clks_is_prepared(struct clk_hw *hw) -{ - struct twl_clock_info *cinfo = to_twl_clks_info(hw); - int val; - - val = twlclk_read(cinfo, TWL_MODULE_PM_RECEIVER, VREG_STATE); - if (val < 0) { - dev_err(cinfo->dev, "clk read failed\n"); - return val; - } - - val &= TWL6030_CFG_STATE_MASK; - - return val == TWL6030_CFG_STATE_ON; -} - static const struct clk_ops twl6032_clks_ops = { .prepare = twl6032_clks_prepare, .unprepare = twl6032_clks_unprepare, - .is_prepared = twl6032_clks_is_prepared, .recalc_rate = twl_clks_recalc_rate, }; From patchwork Thu Oct 10 07:43:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 13829707 Received: from mail.andi.de1.cc (mail.andi.de1.cc [178.238.236.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A96CC1BCA11; Thu, 10 Oct 2024 07:44:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.238.236.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728546254; cv=none; b=mTn1hdvaV8woI0niR45KE13nx9fh7vL4FhLu0Bc2i7SMGgo+iwt0NhuWnDF3G+NObKu686/F8foZVvWQUYWkfPcpm/OzzteteCneeg59+lndN5o/MCB2ykgbaFGTcTXbvR23PJ04UTgvQw/CLKPRv2lakN1DT50wGFvjNOT8hIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728546254; c=relaxed/simple; bh=x5FhYGi0PCWOfztI/IQyaGgm3sDuZ7lLD3ZhEv6wc7M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NfCvG/4dzrtAuiBOkc5BKfPi6ZzhKg5oLAuN93N2f7d7OgNPL9Ui/UqrLWV5T+hwDKMFtW69Yg5Vk9JqF2Bq1ImUCFDL9Ej8Y1cg6UD4bXH9Xf+sBoR4EjdI0IFFiYrUHFkbLA2JjtdeSEkUN0+S5HX1JaQSXXAQAl0PH/10tZA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=kemnade.info; spf=pass smtp.mailfrom=kemnade.info; dkim=pass (2048-bit key) header.d=kemnade.info header.i=@kemnade.info header.b=G+IhLX+n; arc=none smtp.client-ip=178.238.236.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=kemnade.info Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kemnade.info Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kemnade.info header.i=@kemnade.info header.b="G+IhLX+n" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20220719; h=References:In-Reply-To:Cc:From:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=7tN5cZxpEROorCLkrxgCiTuqn2sXTFFrUxuWOjArPwI=; b=G+IhLX+n58SIUp70ZTrLN+BR9y voqN52PrXemM1U5GHmQBCO6+PlcrBLOZgsJbZyLLK2LJzQSHyX/Ny6pOasFVaBq0fwI6J9SFwuHFn pQA1WFyAnPShXCL85IKrUQQRw+S9sLfHAv02Yh2nXl54tkrZiS4ElsqLLSFfhdvPeaTFAVcDnU5NP b/4X+vIHOIDwPNOQkQEEooxnpv54FY0uhMY/Nv/JC86Um/kexlJSEaICWh0Hb7bcHrvzfsCGo6lz+ 61mCe/yX8Q8SqScIPiSt5muyH8edQsmnKJoByK3xEWpBkicVvs6dmR9ARkfsmkHelxZnVQNPewa8n 1wX7oAOg==; From: Andreas Kemnade To: Kevin Hilman , Michael Turquette , Aaro Koskinen , linux-kernel@vger.kernel.org, Tony Lindgren , linux-clk@vger.kernel.org, Lee Jones , Roger Quadros , Stephen Boyd , linux-omap@vger.kernel.org Cc: Andreas Kemnade Subject: [PATCH v4 3/3] clk: twl: add TWL6030 support Date: Thu, 10 Oct 2024 09:43:55 +0200 Message-Id: <20241010074355.58161-4-andreas@kemnade.info> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241010074355.58161-1-andreas@kemnade.info> References: <20241010074355.58161-1-andreas@kemnade.info> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The TWL6030 has similar clocks, so add support for it. Take care of the resource grouping handling needed. Signed-off-by: Andreas Kemnade --- drivers/clk/Kconfig | 2 +- drivers/clk/clk-twl.c | 52 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig index 299bc678ed1b..82ec12f9b82c 100644 --- a/drivers/clk/Kconfig +++ b/drivers/clk/Kconfig @@ -291,7 +291,7 @@ config CLK_TWL help Enable support for controlling the clock resources on TWL family PMICs. These devices have some 32K clock outputs which can be - controlled by software. For now, only the TWL6032 clocks are + controlled by software. For now, the TWL6032 and TWL6030 clocks are supported. config CLK_TWL6040 diff --git a/drivers/clk/clk-twl.c b/drivers/clk/clk-twl.c index 1d684b358401..c04bcb61e260 100644 --- a/drivers/clk/clk-twl.c +++ b/drivers/clk/clk-twl.c @@ -11,13 +11,29 @@ #include #include -#define VREG_STATE 2 +#define VREG_STATE 2 +#define VREG_GRP 0 #define TWL6030_CFG_STATE_OFF 0x00 #define TWL6030_CFG_STATE_ON 0x01 #define TWL6030_CFG_STATE_MASK 0x03 +#define TWL6030_CFG_STATE_GRP_SHIFT 5 +#define TWL6030_CFG_STATE_APP_SHIFT 2 +#define TWL6030_CFG_STATE_APP_MASK (0x03 << TWL6030_CFG_STATE_APP_SHIFT) +#define TWL6030_CFG_STATE_APP(v) (((v) & TWL6030_CFG_STATE_APP_MASK) >>\ + TWL6030_CFG_STATE_APP_SHIFT) +#define P1_GRP BIT(0) /* processor power group */ +#define P2_GRP BIT(1) +#define P3_GRP BIT(2) +#define ALL_GRP (P1_GRP | P2_GRP | P3_GRP) + +enum twl_type { + TWL_TYPE_6030, + TWL_TYPE_6032, +}; struct twl_clock_info { struct device *dev; + enum twl_type type; u8 base; struct clk_hw hw; }; @@ -56,14 +72,21 @@ static unsigned long twl_clks_recalc_rate(struct clk_hw *hw, static int twl6032_clks_prepare(struct clk_hw *hw) { struct twl_clock_info *cinfo = to_twl_clks_info(hw); - int ret; - ret = twlclk_write(cinfo, TWL_MODULE_PM_RECEIVER, VREG_STATE, - TWL6030_CFG_STATE_ON); - if (ret < 0) - dev_err(cinfo->dev, "clk prepare failed\n"); + if (cinfo->type == TWL_TYPE_6030) { + int grp; + + grp = twlclk_read(cinfo, TWL_MODULE_PM_RECEIVER, VREG_GRP); + if (grp < 0) + return grp; - return ret; + return twlclk_write(cinfo, TWL_MODULE_PM_RECEIVER, VREG_STATE, + grp << TWL6030_CFG_STATE_GRP_SHIFT | + TWL6030_CFG_STATE_ON); + } + + return twlclk_write(cinfo, TWL_MODULE_PM_RECEIVER, VREG_STATE, + TWL6030_CFG_STATE_ON); } static void twl6032_clks_unprepare(struct clk_hw *hw) @@ -71,8 +94,14 @@ static void twl6032_clks_unprepare(struct clk_hw *hw) struct twl_clock_info *cinfo = to_twl_clks_info(hw); int ret; - ret = twlclk_write(cinfo, TWL_MODULE_PM_RECEIVER, VREG_STATE, - TWL6030_CFG_STATE_OFF); + if (cinfo->type == TWL_TYPE_6032) + ret = twlclk_write(cinfo, TWL_MODULE_PM_RECEIVER, VREG_STATE, + ALL_GRP << TWL6030_CFG_STATE_GRP_SHIFT | + TWL6030_CFG_STATE_OFF); + else + ret = twlclk_write(cinfo, TWL_MODULE_PM_RECEIVER, VREG_STATE, + TWL6030_CFG_STATE_OFF); + if (ret < 0) dev_err(cinfo->dev, "clk unprepare failed\n"); } @@ -138,6 +167,7 @@ static int twl_clks_probe(struct platform_device *pdev) for (i = 0; i < count; i++) { cinfo[i].base = hw_data[i].base; cinfo[i].dev = &pdev->dev; + cinfo[i].type = platform_get_device_id(pdev)->driver_data; cinfo[i].hw.init = &hw_data[i].init; ret = devm_clk_hw_register(&pdev->dev, &cinfo[i].hw); if (ret) { @@ -159,7 +189,11 @@ static int twl_clks_probe(struct platform_device *pdev) static const struct platform_device_id twl_clks_id[] = { { + .name = "twl6030-clk", + .driver_data = TWL_TYPE_6030, + }, { .name = "twl6032-clk", + .driver_data = TWL_TYPE_6032, }, { /* sentinel */ }