2 * OMAP interface clock support
4 * Copyright (C) 2013 Texas Instruments, Inc.
6 * Tero Kristo <t-kristo@ti.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
13 * kind, whether express or implied; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
18 #include <linux/clk-provider.h>
19 #include <linux/slab.h>
21 #include <linux/of_address.h>
22 #include <linux/clk/ti.h>
25 #define pr_fmt(fmt) "%s: " fmt, __func__
27 static const struct clk_ops ti_interface_clk_ops
= {
28 .init
= &omap2_init_clk_clkdm
,
29 .enable
= &omap2_dflt_clk_enable
,
30 .disable
= &omap2_dflt_clk_disable
,
31 .is_enabled
= &omap2_dflt_clk_is_enabled
,
34 static void __init
_of_ti_interface_clk_setup(struct device_node
*node
,
35 const struct clk_hw_omap_ops
*ops
)
38 struct clk_init_data init
= { NULL
};
39 struct clk_hw_omap
*clk_hw
;
40 const char *parent_name
;
43 clk_hw
= kzalloc(sizeof(*clk_hw
), GFP_KERNEL
);
47 clk_hw
->hw
.init
= &init
;
49 clk_hw
->flags
= MEMMAP_ADDRESSING
;
51 clk_hw
->enable_reg
= ti_clk_get_reg_addr(node
, 0);
52 if (!clk_hw
->enable_reg
)
55 if (!of_property_read_u32(node
, "ti,bit-shift", &val
))
56 clk_hw
->enable_bit
= val
;
58 init
.name
= node
->name
;
59 init
.ops
= &ti_interface_clk_ops
;
62 parent_name
= of_clk_get_parent_name(node
, 0);
64 pr_err("%s must have a parent\n", node
->name
);
69 init
.parent_names
= &parent_name
;
71 clk
= clk_register(NULL
, &clk_hw
->hw
);
74 of_clk_add_provider(node
, of_clk_src_simple_get
, clk
);
75 omap2_init_clk_hw_omap_clocks(clk
);
83 static void __init
of_ti_interface_clk_setup(struct device_node
*node
)
85 _of_ti_interface_clk_setup(node
, &clkhwops_iclk_wait
);
87 CLK_OF_DECLARE(ti_interface_clk
, "ti,omap3-interface-clock",
88 of_ti_interface_clk_setup
);
90 static void __init
of_ti_no_wait_interface_clk_setup(struct device_node
*node
)
92 _of_ti_interface_clk_setup(node
, &clkhwops_iclk
);
94 CLK_OF_DECLARE(ti_no_wait_interface_clk
, "ti,omap3-no-wait-interface-clock",
95 of_ti_no_wait_interface_clk_setup
);
97 static void __init
of_ti_hsotgusb_interface_clk_setup(struct device_node
*node
)
99 _of_ti_interface_clk_setup(node
,
100 &clkhwops_omap3430es2_iclk_hsotgusb_wait
);
102 CLK_OF_DECLARE(ti_hsotgusb_interface_clk
, "ti,omap3-hsotgusb-interface-clock",
103 of_ti_hsotgusb_interface_clk_setup
);
105 static void __init
of_ti_dss_interface_clk_setup(struct device_node
*node
)
107 _of_ti_interface_clk_setup(node
,
108 &clkhwops_omap3430es2_iclk_dss_usbhost_wait
);
110 CLK_OF_DECLARE(ti_dss_interface_clk
, "ti,omap3-dss-interface-clock",
111 of_ti_dss_interface_clk_setup
);
113 static void __init
of_ti_ssi_interface_clk_setup(struct device_node
*node
)
115 _of_ti_interface_clk_setup(node
, &clkhwops_omap3430es2_iclk_ssi_wait
);
117 CLK_OF_DECLARE(ti_ssi_interface_clk
, "ti,omap3-ssi-interface-clock",
118 of_ti_ssi_interface_clk_setup
);
120 static void __init
of_ti_am35xx_interface_clk_setup(struct device_node
*node
)
122 _of_ti_interface_clk_setup(node
, &clkhwops_am35xx_ipss_wait
);
124 CLK_OF_DECLARE(ti_am35xx_interface_clk
, "ti,am35xx-interface-clock",
125 of_ti_am35xx_interface_clk_setup
);