From patchwork Sat Oct 5 12:47:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 833164 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 28A9852F88; Sat, 5 Oct 2024 12:47:24 +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=1728132445; cv=none; b=lhbG3A3FnrjJlWqGpDRkMWV2K7j/OCIs8NaGe5pPDaXfosvFWxULf544x94rO6MU0zo2t0hocuM5utS8m2eMOVOr+41RheNmXSBL//opajcV5vIO6J1EMC8NXy36DuIZszanUDjHbRUA+JDDjPPDnknUZeagThOX3d9mKkoC8bE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728132445; c=relaxed/simple; bh=w6NUHNgk5fQy3ZvEAcTfcWJZZNi43o1KIpFRTO+yMN8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DXd2c5N7DF6hyv92kx+Rs56vcO8ybmwHSF2h0HoVvRyhfA4ElrJA4klZSnfpvkusve28tJc6XGlTBd+BxtVn063H/opQv0QgsbEdJ2ibwDXRCLX3S8vBj7yNpLZ/JZuchsz9A3eo6WfolR/+jrG0lroQ98+oKTOdGj2seokNmz0= 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=pst2N2Gi; 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="pst2N2Gi" 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=gvgKHqill5h7LNCZgWlTthTr5OPqrMhJylEvVsoYuv8=; b=pst2N2GifES2vgewrkfGsirNmu MuAr4Ym1dCiOk/fcHZI4YYEiGeXCRcVRqiBr1R3jS79NvvulWDQpAKDfBkKTGhSrVxJKuM2xAJDGj K/4pcvLCVMmlBNsQ+Z4evjd1qv/nGt2IU83V918k8f/wQOBXws9r4eN4OB9XfyA5BV9Aqa3mNSC8T e+R/q3zZorS1QMjaGbhoJwIOKQoynjRthnutEBmDomYpT2TRckj3eaOkW2uqM73pWGcoDyr3EcFLb oeIRsgXy85v83qwhG6J5vncX9l0Ztca9xMHbcyOZVH7b9KV53UMkQBkBJDN4+mQUn2jb4dYZNwtqf g3W0ghKA==; From: Andreas Kemnade To: Tony Lindgren , Michael Turquette , Aaro Koskinen , Lee Jones , Roger Quadros , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Kevin Hilman , linux-omap@vger.kernel.org, Stephen Boyd Cc: Andreas Kemnade Subject: [PATCH v3 1/3] mfd: twl-core: Add a clock subdevice for the TWL6030 Date: Sat, 5 Oct 2024 14:47:04 +0200 Message-Id: <20241005124706.601393-2-andreas@kemnade.info> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241005124706.601393-1-andreas@kemnade.info> References: <20241005124706.601393-1-andreas@kemnade.info> Precedence: bulk X-Mailing-List: linux-omap@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 | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index c130ffef182f..c981922f62d5 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,25 @@ 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 (status < 0) - goto free; - } - if (twl_class_is_6030()) { + if (id->driver_data & TWL6032_SUBCLASS) { + status = devm_mfd_add_devices(&client->dev, + PLATFORM_DEVID_NONE, + twl6032_cells, + ARRAY_SIZE(twl6032_cells), + NULL, 0, NULL); + if (status < 0) + goto free; + } else { + status = devm_mfd_add_devices(&client->dev, + PLATFORM_DEVID_NONE, + twl6030_cells, + ARRAY_SIZE(twl6030_cells), + NULL, 0, NULL); + if (status < 0) + goto free; + } + if (of_device_is_system_power_controller(node)) { if (!pm_power_off) pm_power_off = twl6030_power_off; From patchwork Sat Oct 5 12:47:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 835048 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 28B6614C5AE; Sat, 5 Oct 2024 12:47:24 +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=1728132446; cv=none; b=OJaPrz8HgCcvqzTIKRjDFcfOtMNQTa8FHdp30GyGnQOvrQYKiV4FYEodrnbmdFXz0SQm2jTXEI7K0wnTD3k9IqCvtWFn4RMTBKmCNr541euYbKQG91bgHgtkzp43PhhublUt2n5EIX3T6afR/Il0DtISEdyhKQZIWM8APIfQPWc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728132446; c=relaxed/simple; bh=Zfm5WdnxB5JQj8ViyWS1iuKc6KGaS55oRV/JIcQEN9g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WTBd9M8VLmczFmIDGbE7RG28tzW/UgDfo4hdlO6gUUeo0+PkROLxpIeWAQVACb1BLF9JlL7u1Xh8EEvkPHdpQ5DYUxK3tdNWN3EmrEbRkaWR3aGyhNraaWngs2qC0GalDdqhNPlC/ENznyNxPxMfOKAk0tcCs0IPgMiGOAlWm8M= 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=QIrtBm0g; 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="QIrtBm0g" 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=QIrtBm0gBkQe8TKaxTfmkVzp1U yCDeBxk/KCJdx3UWdNOUfd88mJcmCLhfCg3BWPWd0122//WcsisUzDf3I5+27iG138nS1Ub95aoDe Kd4UNHiO1lqy35n8n4bpQ+BMV7EMYqID3Cyk7GpybfYTwyJUeGtWynF3SNLa8x6pjcdGDF/DXjqgV 3c/unR1ksXLxhrDq8gwdY5+GvCeS8xlzeL5DVuXC0NQ4zQcPazzK2W3FI/P0PfWbDpXS3H0NcIdbD AEy2rZ8qjyg2J4PRGpXNEH9Paq6OojsaUC9CzUF4SIBQng6Z3xfmWG9ckXBtfUlYh5ew3SToQEW6k SIE0lGZg==; From: Andreas Kemnade To: Tony Lindgren , Michael Turquette , Aaro Koskinen , Lee Jones , Roger Quadros , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Kevin Hilman , linux-omap@vger.kernel.org, Stephen Boyd Cc: Andreas Kemnade Subject: [PATCH v3 2/3] clk: twl: remove is_prepared Date: Sat, 5 Oct 2024 14:47:05 +0200 Message-Id: <20241005124706.601393-3-andreas@kemnade.info> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241005124706.601393-1-andreas@kemnade.info> References: <20241005124706.601393-1-andreas@kemnade.info> Precedence: bulk X-Mailing-List: linux-omap@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 Sat Oct 5 12:47:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 833163 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 28AE814A4DF; Sat, 5 Oct 2024 12:47:24 +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=1728132445; cv=none; b=GnUwGZzjfNQZHApjsekXWHGtUfRMEsCWlWCVCT69Hjjd9E209PxAg4rdLh4l/ltHGoVBTKq2X8Epbb14AskObKZY1YAWDKmTHVZEMCpdRwxYVCp+aeGkWbCENrpGNThjKqjvOaEqfrc7XDro2NrA8FWQzNeWgtaApQVXNt9PQJk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728132445; c=relaxed/simple; bh=x5FhYGi0PCWOfztI/IQyaGgm3sDuZ7lLD3ZhEv6wc7M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=s3deEenhXI3VsBctsR2usHNYg1qusy3qEns88s7ZtTvIGwlem47lsffK4Y6Njvge9hnovdXhBIWu16/WqMfPkVTq3pudZTQPzP6MaoEYxw06W54N6iatTc5zpPea12RElcGtkyzr6VT4vJ9fVEg7pEVo7aYgxMQt6l79UhM1Rqo= 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=OoYBSfwQ; 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="OoYBSfwQ" 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=OoYBSfwQCkH6Mxa+mpmzeNl/Dn tUWNNK1JVZqQ3IDQsgcVenN+YPts5Irw4sbwJfgtyRS9/fnJgykbjqaMGhfoybOflNEqcvnxNI2Xz 4Pk3qxRPG9MsBuqjTgjnmr3xSoMpXoxkkNHur7ozjzPQAW/PRQpRvWE7Q0kkz2Z9zDOuom/MxchDb Bb6/SyYEr2xXkj1GwDmCejfY9ZrB5H7Ld+5PPhpOv+Y/r1XOgNWsEvb2FFIawffc2ho0x6L1qanWG RqhOR0HmYVpysGcit0soUK8uwSM2bepuGH+wcx5ZHnTWa0+9a5SvPcPSvq3Ux6PDCxLPYoi9S9CLt veSJKS0A==; From: Andreas Kemnade To: Tony Lindgren , Michael Turquette , Aaro Koskinen , Lee Jones , Roger Quadros , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Kevin Hilman , linux-omap@vger.kernel.org, Stephen Boyd Cc: Andreas Kemnade Subject: [PATCH v3 3/3] clk: twl: add TWL6030 support Date: Sat, 5 Oct 2024 14:47:06 +0200 Message-Id: <20241005124706.601393-4-andreas@kemnade.info> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241005124706.601393-1-andreas@kemnade.info> References: <20241005124706.601393-1-andreas@kemnade.info> Precedence: bulk X-Mailing-List: linux-omap@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 */ }