Lines Matching +full:parent +full:- +full:clk
1 // SPDX-License-Identifier: GPL-2.0+
7 #include <dt-bindings/firmware/imx/rsrc.h>
8 #include <linux/arm-smccc.h>
9 #include <linux/clk-provider.h>
13 #include "clk-scu.h"
21 * struct clk_scu - Description of one SCU clock
33 * struct imx_sc_msg_req_set_clock_rate - clock set rate protocol
37 * @clk: clk type of this resource
45 u8 clk; member
50 u8 clk; member
58 * struct imx_sc_msg_get_clock_rate - clock get rate protocol
74 * struct imx_sc_msg_get_clock_parent - clock get parent protocol
76 * @req: get parent request protocol
77 * @resp: get parent response protocol
79 * This structure describes the SCU protocol of clock get parent
86 u8 clk; member
89 u8 parent; member
95 * struct imx_sc_msg_set_clock_parent - clock set parent protocol
97 * @req: set parent request protocol
99 * This structure describes the SCU protocol of clock set parent
104 u8 clk; member
105 u8 parent; member
109 * struct imx_sc_msg_req_clock_enable - clock gate protocol
112 * @clk: clk type of this resource
121 u8 clk; member
137 * clk_scu_recalc_rate - Get clock rate for a SCU clock
139 * @parent_rate: parent rate provided by common clock framework, not used
147 struct clk_scu *clk = to_clk_scu(hw); in clk_scu_recalc_rate() local
152 hdr->ver = IMX_SC_RPC_VERSION; in clk_scu_recalc_rate()
153 hdr->svc = IMX_SC_RPC_SVC_PM; in clk_scu_recalc_rate()
154 hdr->func = IMX_SC_PM_FUNC_GET_CLOCK_RATE; in clk_scu_recalc_rate()
155 hdr->size = 2; in clk_scu_recalc_rate()
157 msg.data.req.resource = cpu_to_le16(clk->rsrc_id); in clk_scu_recalc_rate()
158 msg.data.req.clk = clk->clk_type; in clk_scu_recalc_rate()
171 * clk_scu_round_rate - Round clock rate for a SCU clock
174 * @parent_rate: parent rate provided by common clock framework, not used
191 struct clk_scu *clk = to_clk_scu(hw); in clk_scu_atf_set_cpu_rate() local
195 if (clk->rsrc_id == IMX_SC_R_A35) in clk_scu_atf_set_cpu_rate()
198 return -EINVAL; in clk_scu_atf_set_cpu_rate()
200 /* CPU frequency scaling can ONLY be done by ARM-Trusted-Firmware */ in clk_scu_atf_set_cpu_rate()
208 * clk_scu_set_rate - Set rate for a SCU clock
211 * @parent_rate: rate of the clock parent, not used for SCU clocks
219 struct clk_scu *clk = to_clk_scu(hw); in clk_scu_set_rate() local
223 hdr->ver = IMX_SC_RPC_VERSION; in clk_scu_set_rate()
224 hdr->svc = IMX_SC_RPC_SVC_PM; in clk_scu_set_rate()
225 hdr->func = IMX_SC_PM_FUNC_SET_CLOCK_RATE; in clk_scu_set_rate()
226 hdr->size = 3; in clk_scu_set_rate()
229 msg.resource = cpu_to_le16(clk->rsrc_id); in clk_scu_set_rate()
230 msg.clk = clk->clk_type; in clk_scu_set_rate()
237 struct clk_scu *clk = to_clk_scu(hw); in clk_scu_get_parent() local
242 hdr->ver = IMX_SC_RPC_VERSION; in clk_scu_get_parent()
243 hdr->svc = IMX_SC_RPC_SVC_PM; in clk_scu_get_parent()
244 hdr->func = IMX_SC_PM_FUNC_GET_CLOCK_PARENT; in clk_scu_get_parent()
245 hdr->size = 2; in clk_scu_get_parent()
247 msg.data.req.resource = cpu_to_le16(clk->rsrc_id); in clk_scu_get_parent()
248 msg.data.req.clk = clk->clk_type; in clk_scu_get_parent()
252 pr_err("%s: failed to get clock parent %d\n", in clk_scu_get_parent()
257 return msg.data.resp.parent; in clk_scu_get_parent()
262 struct clk_scu *clk = to_clk_scu(hw); in clk_scu_set_parent() local
266 hdr->ver = IMX_SC_RPC_VERSION; in clk_scu_set_parent()
267 hdr->svc = IMX_SC_RPC_SVC_PM; in clk_scu_set_parent()
268 hdr->func = IMX_SC_PM_FUNC_SET_CLOCK_PARENT; in clk_scu_set_parent()
269 hdr->size = 2; in clk_scu_set_parent()
271 msg.resource = cpu_to_le16(clk->rsrc_id); in clk_scu_set_parent()
272 msg.clk = clk->clk_type; in clk_scu_set_parent()
273 msg.parent = index; in clk_scu_set_parent()
279 u8 clk, bool enable, bool autog) in sc_pm_clock_enable() argument
284 hdr->ver = IMX_SC_RPC_VERSION; in sc_pm_clock_enable()
285 hdr->svc = IMX_SC_RPC_SVC_PM; in sc_pm_clock_enable()
286 hdr->func = IMX_SC_PM_FUNC_CLOCK_ENABLE; in sc_pm_clock_enable()
287 hdr->size = 3; in sc_pm_clock_enable()
290 msg.clk = clk; in sc_pm_clock_enable()
298 * clk_scu_prepare - Enable a SCU clock
305 struct clk_scu *clk = to_clk_scu(hw); in clk_scu_prepare() local
307 return sc_pm_clock_enable(ccm_ipc_handle, clk->rsrc_id, in clk_scu_prepare()
308 clk->clk_type, true, false); in clk_scu_prepare()
312 * clk_scu_unprepare - Disable a SCU clock
319 struct clk_scu *clk = to_clk_scu(hw); in clk_scu_unprepare() local
322 ret = sc_pm_clock_enable(ccm_ipc_handle, clk->rsrc_id, in clk_scu_unprepare()
323 clk->clk_type, false, false); in clk_scu_unprepare()
325 pr_warn("%s: clk unprepare failed %d\n", clk_hw_get_name(hw), in clk_scu_unprepare()
351 struct clk_scu *clk; in __imx_clk_scu() local
355 clk = kzalloc(sizeof(*clk), GFP_KERNEL); in __imx_clk_scu()
356 if (!clk) in __imx_clk_scu()
357 return ERR_PTR(-ENOMEM); in __imx_clk_scu()
359 clk->rsrc_id = rsrc_id; in __imx_clk_scu()
360 clk->clk_type = clk_type; in __imx_clk_scu()
379 clk->hw.init = &init; in __imx_clk_scu()
381 hw = &clk->hw; in __imx_clk_scu()
384 kfree(clk); in __imx_clk_scu()