From patchwork Wed Oct 2 11:07:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 13819661 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 D834A1940AA; Wed, 2 Oct 2024 11:07:35 +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=1727867258; cv=none; b=hjXgHsZOTy7h7XCPEJm8wXCLYMtqXE5i0SbwASSbpTWG6Ar0H1GvUzopRy6Ul/3fF8UsmTihTJL22JiMsjqc0EXCCJMqJe9N3nY8l70wqma48K06WSppBAA6nR1YsGy4rihirRgycjy17CnOCqKOQ/l3lYLh2/YUtWI5DozAUrQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727867258; c=relaxed/simple; bh=w6NUHNgk5fQy3ZvEAcTfcWJZZNi43o1KIpFRTO+yMN8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LtHllCgLDCRAi2ucUdD1llr5yH1WfDZ361kFa4sIVNGEIyquBKRqg+k7VtpvjthKDqjBTIl7JItLizjlM3p1c2qVaCoVpp9oLYzQr3mahVxJh3KpI+QowCWVGpLDbDN55o6DFeIPriOr1TAoW7c4AKqIzQdCaYLCYIq8uYOokvQ= 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=qUNOTZxA; 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="qUNOTZxA" 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=qUNOTZxAlaT1aNDiDa0FFJZt0d S+Wzt10YiS94ztjaoL7QAU2sfSTtxhxRklhhW8RNYsCresPnsFrdSA1kTCK4p/Ti4K+cKxA9iDhQ0 ukPU3xd42JfmVFSQ7/L9r3I0Wb41+/CDZ6AVOk619Eu6G5QiGkDAYTfPKBRs3xSQYVpjC1eX7RTek RwYvgU5FsCYkDJ8IpFnOkHf5FKfADxipVE478g8wmhdBwIiUOHAVQaIyz11XCemATPxJWc2IQ0BsD tTnOZkAaDSHhRmwMIx1L/M4pLyRBUad2pSEnb6YP57dgrNzwwLJSXUzMdsYSrfTYXxr2eii8rk869 pWeoEYcQ==; From: Andreas Kemnade To: Stephen Boyd , Tony Lindgren , Aaro Koskinen , Kevin Hilman , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Lee Jones , linux-omap@vger.kernel.org, Roger Quadros , Michael Turquette Cc: Andreas Kemnade Subject: [PATCH v2 1/3] mfd: twl-core: Add a clock subdevice for the TWL6030 Date: Wed, 2 Oct 2024 13:07:16 +0200 Message-Id: <20241002110718.528337-2-andreas@kemnade.info> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241002110718.528337-1-andreas@kemnade.info> References: <20241002110718.528337-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 | 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 Wed Oct 2 11:07:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 13819660 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 D839F19D07D; Wed, 2 Oct 2024 11:07:35 +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=1727867257; cv=none; b=PLDn9aIdAhX1bWdLMKORvw5bXTKgNyuxc0LUzuP2018mWsqg9orwsqMSCp+Jo+h6wB5vrL9aUHKMSbQqZ0e2+EFLOdSrSrGdYRpntNzyW5ePynYxGB/uopjpkKiorf6ipA52S/zpuVCseKLn9OdicMVbGOMK5owZ4gbXdsbHqdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727867257; c=relaxed/simple; bh=3yXEUzconOtIkk4NPQcgTFwK9TurmiOWQFGd+HRirJA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cVZRN54iWT5Mkw/gvX90ipKJpt83ZojiShfGaNmd7s+UehfUT84h9jL6x6/OApoZJK98hcMuU3n7n+S8JZXcadBpn1IvzISRw9esA98ZS/k9fiJ2KRaL3hUhfDGn8kaGZtrCy3sjtfS+hEi8RaikOZbRizCucvsF/62pXFDi/qE= 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=m2YgW4It; 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="m2YgW4It" 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=B7At8BuiWMC0EtZ0gWWkKYgt1LQkrFiLgOqHpS4o1Tg=; b=m2YgW4ItKGsc+f8/tAoCxDcQ5B 08en79lRotBPHo9YD7QTvVBJHjHApE8HHhZRF9shXjYScaY1W727sfxkIeT18CtiawNy2WL4htLZ9 +6DwQUhiD3VyXp16LSma7Mo0aISDu4XbNk9/FblDc2rQXpPbpA9lTZrV18NqYl0vGY0+3XhwUyRJC ryLl8ehqoBGdAjMsVBI+drtPzN9WY/kJdZ1hyO05frrmrv12Nc3pv32UtJ2UsA5xr3DxjKB0nOOxn X6Yriq7X6Kb3nU6mPmrjsyf+qYgTMT/eoQuiQHZ7uydgs1DLlNgMSYdDlMeCB5BjVfjdMjxgX6trs Dt/ihfiA==; From: Andreas Kemnade To: Stephen Boyd , Tony Lindgren , Aaro Koskinen , Kevin Hilman , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Lee Jones , linux-omap@vger.kernel.org, Roger Quadros , Michael Turquette Cc: Andreas Kemnade Subject: [PATCH v2 2/3] clk: twl: remove is_prepared Date: Wed, 2 Oct 2024 13:07:17 +0200 Message-Id: <20241002110718.528337-3-andreas@kemnade.info> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241002110718.528337-1-andreas@kemnade.info> References: <20241002110718.528337-1-andreas@kemnade.info> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remave 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 Wed Oct 2 11:07:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 13819659 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 9DC9F19409C; Wed, 2 Oct 2024 11:07:34 +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=1727867256; cv=none; b=E/fAHDFrY8gGW85h3BeMT/ZIWQBnzHItwiK1lBCiwG4mUntNMCyvHQ/1k+t7jJXJfwj2tcNeHpuf4+2QumX/b1igd4E8gre/vUcGvowM98+KXEwVNcq6BIuQ/xa1EXw8wMsLafVVPMaYBoTVZ/xy21Ye88nGgSrl6ZeK9fxXQcY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727867256; c=relaxed/simple; bh=ORTJRm22ddAJfzALidDTq04r5FAZBeXSdbCkuCvQ3Ss=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gVOY66Hm5ubm3CO4mI7C5aoi9gNIFIydamvTaSa5/SEQaAj5IwZYgK0oKU2PI4JfxEwV2LpP4LidT4SWWyFzEW89bUCugyLi98KWHqbxHaicXIq34nALFBdFnLM4mf97TDJdWjYfkSpQ4kAxfXhZS0SngcAJRupgF8UR8ABPQ+0= 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=UKNTM0/L; 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="UKNTM0/L" 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=O3KKzCLh21dqde597mGqNjSl+BqkXtinmSgN7o8hns4=; b=UKNTM0/Ly52uyCJzEhybtOcEFZ Sxxk9Ue+UGaD+vXL56VcczmLCp9kLfHH/XMJKnm1E84dYQmNmiC/5UMmz/274OJT7gRxUN1eAtd0a 4eA9RyvtMC+X+dBu4ikQHPeNbbHRklWuisCTZLCa5496NPkF/OEVcp0r+FJANE4uXYxrcKdiaxihH HnmpSvSutJ3PG3yC3z69TEftYckkChgzaDtrbbJv45mKBaxGQnRlobOWLoulxqdfZfEP7RA8a7tcw 9X1w2dJpZ4Ds2McZa+HbPe7lsyCoykONx/MZduR5L94keppmcRDTWBhUZSV/idpGcmErw6MjeYxab 4d+U9qbw==; From: Andreas Kemnade To: Stephen Boyd , Tony Lindgren , Aaro Koskinen , Kevin Hilman , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Lee Jones , linux-omap@vger.kernel.org, Roger Quadros , Michael Turquette Cc: Andreas Kemnade Subject: [PATCH v2 3/3] clk: twl: add TWL6030 support Date: Wed, 2 Oct 2024 13:07:18 +0200 Message-Id: <20241002110718.528337-4-andreas@kemnade.info> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241002110718.528337-1-andreas@kemnade.info> References: <20241002110718.528337-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 | 54 +++++++++++++++++++++++++++++++++---------- 2 files changed, 43 insertions(+), 13 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..f3a52f568887 100644 --- a/drivers/clk/clk-twl.c +++ b/drivers/clk/clk-twl.c @@ -11,13 +11,26 @@ #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) + +#define DRIVER_DATA_TWL6030 0 +#define DRIVER_DATA_TWL6032 1 struct twl_clock_info { - struct device *dev; + struct platform_device *pdev; u8 base; struct clk_hw hw; }; @@ -56,14 +69,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 (platform_get_device_id(cinfo->pdev)->driver_data == DRIVER_DATA_TWL6030) { + int grp; - return ret; + grp = twlclk_read(cinfo, TWL_MODULE_PM_RECEIVER, VREG_GRP); + if (grp < 0) + return grp; + + 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,10 +91,16 @@ 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 (platform_get_device_id(cinfo->pdev)->driver_data == DRIVER_DATA_TWL6030) + 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"); + dev_err(&cinfo->pdev->dev, "clk unprepare failed\n"); } static const struct clk_ops twl6032_clks_ops = { @@ -137,7 +163,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].pdev = pdev; cinfo[i].hw.init = &hw_data[i].init; ret = devm_clk_hw_register(&pdev->dev, &cinfo[i].hw); if (ret) { @@ -159,7 +185,11 @@ static int twl_clks_probe(struct platform_device *pdev) static const struct platform_device_id twl_clks_id[] = { { + .name = "twl6030-clk", + .driver_data = DRIVER_DATA_TWL6030, + }, { .name = "twl6032-clk", + .driver_data = DRIVER_DATA_TWL6032, }, { /* sentinel */ }