]> Git Repo - linux.git/blame - drivers/clk/ti/interface.c
Merge tag 'smp-urgent-2023-09-02' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux.git] / drivers / clk / ti / interface.c
CommitLineData
5a729246 1// SPDX-License-Identifier: GPL-2.0-only
24582b34
TK
2/*
3 * OMAP interface clock support
4 *
5 * Copyright (C) 2013 Texas Instruments, Inc.
6 *
7 * Tero Kristo <[email protected]>
24582b34
TK
8 */
9
10#include <linux/clk-provider.h>
11#include <linux/slab.h>
12#include <linux/of.h>
13#include <linux/of_address.h>
14#include <linux/clk/ti.h>
06524fa4 15#include "clock.h"
24582b34
TK
16
17#undef pr_fmt
18#define pr_fmt(fmt) "%s: " fmt, __func__
19
20static const struct clk_ops ti_interface_clk_ops = {
21 .init = &omap2_init_clk_clkdm,
22 .enable = &omap2_dflt_clk_enable,
23 .disable = &omap2_dflt_clk_disable,
24 .is_enabled = &omap2_dflt_clk_is_enabled,
25};
26
3400d546
DB
27static struct clk *_register_interface(struct device_node *node,
28 const char *name,
06524fa4 29 const char *parent_name,
6c0afb50 30 struct clk_omap_reg *reg, u8 bit_idx,
06524fa4 31 const struct clk_hw_omap_ops *ops)
24582b34 32{
24582b34
TK
33 struct clk_init_data init = { NULL };
34 struct clk_hw_omap *clk_hw;
06524fa4 35 struct clk *clk;
24582b34
TK
36
37 clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
38 if (!clk_hw)
06524fa4 39 return ERR_PTR(-ENOMEM);
24582b34
TK
40
41 clk_hw->hw.init = &init;
42 clk_hw->ops = ops;
6c0afb50 43 memcpy(&clk_hw->enable_reg, reg, sizeof(*reg));
06524fa4 44 clk_hw->enable_bit = bit_idx;
24582b34 45
06524fa4 46 init.name = name;
24582b34
TK
47 init.ops = &ti_interface_clk_ops;
48 init.flags = 0;
49
24582b34
TK
50 init.num_parents = 1;
51 init.parent_names = &parent_name;
52
3400d546 53 clk = of_ti_clk_register_omap_hw(node, &clk_hw->hw, name);
24582b34 54
06524fa4
TK
55 if (IS_ERR(clk))
56 kfree(clk_hw);
06524fa4
TK
57
58 return clk;
59}
60
06524fa4
TK
61static void __init _of_ti_interface_clk_setup(struct device_node *node,
62 const struct clk_hw_omap_ops *ops)
63{
64 struct clk *clk;
65 const char *parent_name;
6c0afb50 66 struct clk_omap_reg reg;
06524fa4 67 u8 enable_bit = 0;
ed06099c 68 const char *name;
06524fa4
TK
69 u32 val;
70
6c0afb50 71 if (ti_clk_get_reg_addr(node, 0, &reg))
06524fa4
TK
72 return;
73
74 if (!of_property_read_u32(node, "ti,bit-shift", &val))
75 enable_bit = val;
76
77 parent_name = of_clk_get_parent_name(node, 0);
78 if (!parent_name) {
e665f029 79 pr_err("%pOFn must have a parent\n", node);
24582b34
TK
80 return;
81 }
82
ed06099c 83 name = ti_dt_clk_name(node);
3400d546 84 clk = _register_interface(node, name, parent_name, &reg,
06524fa4
TK
85 enable_bit, ops);
86
87 if (!IS_ERR(clk))
88 of_clk_add_provider(node, of_clk_src_simple_get, clk);
24582b34
TK
89}
90
91static void __init of_ti_interface_clk_setup(struct device_node *node)
92{
93 _of_ti_interface_clk_setup(node, &clkhwops_iclk_wait);
94}
95CLK_OF_DECLARE(ti_interface_clk, "ti,omap3-interface-clock",
96 of_ti_interface_clk_setup);
97
98static void __init of_ti_no_wait_interface_clk_setup(struct device_node *node)
99{
100 _of_ti_interface_clk_setup(node, &clkhwops_iclk);
101}
102CLK_OF_DECLARE(ti_no_wait_interface_clk, "ti,omap3-no-wait-interface-clock",
103 of_ti_no_wait_interface_clk_setup);
104
de742570 105#ifdef CONFIG_ARCH_OMAP3
24582b34
TK
106static void __init of_ti_hsotgusb_interface_clk_setup(struct device_node *node)
107{
108 _of_ti_interface_clk_setup(node,
109 &clkhwops_omap3430es2_iclk_hsotgusb_wait);
110}
111CLK_OF_DECLARE(ti_hsotgusb_interface_clk, "ti,omap3-hsotgusb-interface-clock",
112 of_ti_hsotgusb_interface_clk_setup);
113
114static void __init of_ti_dss_interface_clk_setup(struct device_node *node)
115{
116 _of_ti_interface_clk_setup(node,
117 &clkhwops_omap3430es2_iclk_dss_usbhost_wait);
118}
119CLK_OF_DECLARE(ti_dss_interface_clk, "ti,omap3-dss-interface-clock",
120 of_ti_dss_interface_clk_setup);
121
122static void __init of_ti_ssi_interface_clk_setup(struct device_node *node)
123{
124 _of_ti_interface_clk_setup(node, &clkhwops_omap3430es2_iclk_ssi_wait);
125}
126CLK_OF_DECLARE(ti_ssi_interface_clk, "ti,omap3-ssi-interface-clock",
127 of_ti_ssi_interface_clk_setup);
128
129static void __init of_ti_am35xx_interface_clk_setup(struct device_node *node)
130{
131 _of_ti_interface_clk_setup(node, &clkhwops_am35xx_ipss_wait);
132}
133CLK_OF_DECLARE(ti_am35xx_interface_clk, "ti,am35xx-interface-clock",
134 of_ti_am35xx_interface_clk_setup);
de742570
TK
135#endif
136
137#ifdef CONFIG_SOC_OMAP2430
138static void __init of_ti_omap2430_interface_clk_setup(struct device_node *node)
139{
140 _of_ti_interface_clk_setup(node, &clkhwops_omap2430_i2chs_wait);
141}
142CLK_OF_DECLARE(ti_omap2430_interface_clk, "ti,omap2430-interface-clock",
143 of_ti_omap2430_interface_clk_setup);
144#endif
This page took 0.571819 seconds and 4 git commands to generate.