Lines Matching +full:sci +full:- +full:dev +full:- +full:id
1 // SPDX-License-Identifier: GPL-2.0+
3 * Texas Instruments System Control Interface (TI SCI) clock driver
5 * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
8 * Loosely based on Linux kernel sci-clk.c...
14 #include <clk-uclass.h>
18 * struct ti_sci_clk_data - clock controller information structure
19 * @sci: TI SCI handle used for communication with system controller
22 const struct ti_sci_handle *sci; member
25 static int ti_sci_clk_probe(struct udevice *dev) in ti_sci_clk_probe() argument
27 struct ti_sci_clk_data *data = dev_get_priv(dev); in ti_sci_clk_probe()
29 debug("%s(dev=%p)\n", __func__, dev); in ti_sci_clk_probe()
32 return -ENOMEM; in ti_sci_clk_probe()
35 data->sci = ti_sci_get_handle(dev); in ti_sci_clk_probe()
36 if (IS_ERR(data->sci)) in ti_sci_clk_probe()
37 return PTR_ERR(data->sci); in ti_sci_clk_probe()
45 debug("%s(clk=%p, args_count=%d)\n", __func__, clk, args->args_count); in ti_sci_clk_of_xlate()
47 if (args->args_count != 2) { in ti_sci_clk_of_xlate()
48 debug("Invalid args_count: %d\n", args->args_count); in ti_sci_clk_of_xlate()
49 return -EINVAL; in ti_sci_clk_of_xlate()
53 * On TI SCI-based devices, the clock provider id field is used as a in ti_sci_clk_of_xlate()
54 * device ID, and the data field is used as the associated sub-ID. in ti_sci_clk_of_xlate()
56 clk->id = args->args[0]; in ti_sci_clk_of_xlate()
57 clk->data = args->args[1]; in ti_sci_clk_of_xlate()
76 struct ti_sci_clk_data *data = dev_get_priv(clk->dev); in ti_sci_clk_get_rate()
77 const struct ti_sci_handle *sci = data->sci; in ti_sci_clk_get_rate() local
78 const struct ti_sci_clk_ops *cops = &sci->ops.clk_ops; in ti_sci_clk_get_rate()
84 ret = cops->get_freq(sci, clk->id, clk->data, ¤t_freq); in ti_sci_clk_get_rate()
86 dev_err(clk->dev, "%s: get_freq failed (%d)\n", __func__, ret); in ti_sci_clk_get_rate()
97 struct ti_sci_clk_data *data = dev_get_priv(clk->dev); in ti_sci_clk_set_rate()
98 const struct ti_sci_handle *sci = data->sci; in ti_sci_clk_set_rate() local
99 const struct ti_sci_clk_ops *cops = &sci->ops.clk_ops; in ti_sci_clk_set_rate()
105 ret = cops->set_freq(sci, clk->id, clk->data, rate, rate, rate); in ti_sci_clk_set_rate()
107 dev_err(clk->dev, "%s: set_freq failed (%d)\n", __func__, ret); in ti_sci_clk_set_rate()
114 struct ti_sci_clk_data *data = dev_get_priv(clk->dev); in ti_sci_clk_set_parent()
115 const struct ti_sci_handle *sci = data->sci; in ti_sci_clk_set_parent() local
116 const struct ti_sci_clk_ops *cops = &sci->ops.clk_ops; in ti_sci_clk_set_parent()
123 /* Make sure the clock parent is valid for a given device ID */ in ti_sci_clk_set_parent()
124 if (clk->id != parent->id) in ti_sci_clk_set_parent()
125 return -EINVAL; in ti_sci_clk_set_parent()
128 ret = cops->get_num_parents(sci, clk->id, clk->data, &num_parents); in ti_sci_clk_set_parent()
130 dev_err(clk->dev, "%s: get_num_parents failed (%d)\n", in ti_sci_clk_set_parent()
135 dev_err(clk->dev, "%s: clock has no settable parents!\n", in ti_sci_clk_set_parent()
137 return -EINVAL; in ti_sci_clk_set_parent()
140 /* Make sure parent clock ID is valid */ in ti_sci_clk_set_parent()
141 parent_cid = parent->data - clk->data - 1; in ti_sci_clk_set_parent()
143 dev_err(clk->dev, "%s: invalid parent clock!\n", __func__); in ti_sci_clk_set_parent()
144 return -EINVAL; in ti_sci_clk_set_parent()
148 ret = cops->set_parent(sci, clk->id, clk->data, parent->data); in ti_sci_clk_set_parent()
150 dev_err(clk->dev, "%s: set_parent failed (%d)\n", __func__, in ti_sci_clk_set_parent()
158 struct ti_sci_clk_data *data = dev_get_priv(clk->dev); in ti_sci_clk_enable()
159 const struct ti_sci_handle *sci = data->sci; in ti_sci_clk_enable() local
160 const struct ti_sci_clk_ops *cops = &sci->ops.clk_ops; in ti_sci_clk_enable()
169 ret = cops->put_clock(sci, clk->id, clk->data); in ti_sci_clk_enable()
171 dev_err(clk->dev, "%s: put_clock failed (%d)\n", __func__, ret); in ti_sci_clk_enable()
178 struct ti_sci_clk_data *data = dev_get_priv(clk->dev); in ti_sci_clk_disable()
179 const struct ti_sci_handle *sci = data->sci; in ti_sci_clk_disable() local
180 const struct ti_sci_clk_ops *cops = &sci->ops.clk_ops; in ti_sci_clk_disable()
186 ret = cops->idle_clock(sci, clk->id, clk->data); in ti_sci_clk_disable()
188 dev_err(clk->dev, "%s: idle_clock failed (%d)\n", __func__, in ti_sci_clk_disable()
195 { .compatible = "ti,k2g-sci-clk" },
211 .name = "ti-sci-clk",
212 .id = UCLASS_CLK,