2 * Copyright (c) 2015, Linaro Limited
3 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #ifndef __QCOM_CLK_SMD_RPM_H__
16 #define __QCOM_CLK_SMD_RPM_H__
18 #include <linux/clk-provider.h>
20 #define QCOM_RPM_KEY_SOFTWARE_ENABLE 0x6e657773
21 #define QCOM_RPM_KEY_PIN_CTRL_CLK_BUFFER_ENABLE_KEY 0x62636370
22 #define QCOM_RPM_SMD_KEY_RATE 0x007a484b
23 #define QCOM_RPM_SMD_KEY_ENABLE 0x62616e45
24 #define QCOM_RPM_SMD_KEY_STATE 0x54415453
25 #define QCOM_RPM_SCALING_ENABLE_ID 0x2
30 const int rpm_res_type;
33 const int rpm_status_id;
34 const bool active_only;
37 struct clk_smd_rpm *peer;
40 struct qcom_smd_rpm *rpm;
43 struct clk_smd_rpm_req {
49 extern const struct clk_ops clk_smd_rpm_ops;
50 extern const struct clk_ops clk_smd_rpm_branch_ops;
52 #define __DEFINE_CLK_SMD_RPM(_platform, _name, _active, type, r_id, stat_id, \
54 static struct clk_smd_rpm _platform##_##_active; \
55 static struct clk_smd_rpm _platform##_##_name = { \
56 .rpm_res_type = (type), \
57 .rpm_clk_id = (r_id), \
58 .rpm_status_id = (stat_id), \
60 .peer = &_platform##_##_active, \
62 .hw.init = &(struct clk_init_data){ \
63 .ops = &clk_smd_rpm_ops, \
65 .parent_names = (const char *[]){ "xo_board" }, \
69 static struct clk_smd_rpm _platform##_##_active = { \
70 .rpm_res_type = (type), \
71 .rpm_clk_id = (r_id), \
72 .rpm_status_id = (stat_id), \
74 .peer = &_platform##_##_name, \
75 .active_only = true, \
77 .hw.init = &(struct clk_init_data){ \
78 .ops = &clk_smd_rpm_ops, \
80 .parent_names = (const char *[]){ "xo_board" }, \
85 #define __DEFINE_CLK_SMD_RPM_BRANCH(_platform, _name, _active, type, r_id, \
87 static struct clk_smd_rpm _platform##_##_active; \
88 static struct clk_smd_rpm _platform##_##_name = { \
89 .rpm_res_type = (type), \
90 .rpm_clk_id = (r_id), \
91 .rpm_status_id = (stat_id), \
93 .peer = &_platform##_##_active, \
96 .hw.init = &(struct clk_init_data){ \
97 .ops = &clk_smd_rpm_branch_ops, \
99 .parent_names = (const char *[]){ "xo_board" }, \
103 static struct clk_smd_rpm _platform##_##_active = { \
104 .rpm_res_type = (type), \
105 .rpm_clk_id = (r_id), \
106 .rpm_status_id = (stat_id), \
108 .peer = &_platform##_##_name, \
109 .active_only = true, \
112 .hw.init = &(struct clk_init_data){ \
113 .ops = &clk_smd_rpm_branch_ops, \
115 .parent_names = (const char *[]){ "xo_board" }, \
120 #define DEFINE_CLK_SMD_RPM(_platform, _name, _active, type, r_id) \
121 __DEFINE_CLK_SMD_RPM(_platform, _name, _active, type, r_id, \
122 0, QCOM_RPM_SMD_KEY_RATE)
124 #define DEFINE_CLK_SMD_RPM_BRANCH(_platform, _name, _active, type, r_id, r) \
125 __DEFINE_CLK_SMD_RPM_BRANCH(_platform, _name, _active, type, \
126 r_id, 0, r, QCOM_RPM_SMD_KEY_ENABLE)
128 #define DEFINE_CLK_SMD_RPM_QDSS(_platform, _name, _active, type, r_id) \
129 __DEFINE_CLK_SMD_RPM(_platform, _name, _active, type, r_id, \
130 0, QCOM_RPM_SMD_KEY_STATE)
132 #define DEFINE_CLK_SMD_RPM_XO_BUFFER(_platform, _name, _active, r_id) \
133 __DEFINE_CLK_SMD_RPM_BRANCH(_platform, _name, _active, \
134 QCOM_SMD_RPM_CLK_BUF_A, r_id, 0, 1000, \
135 QCOM_RPM_KEY_SOFTWARE_ENABLE)
137 #define DEFINE_CLK_SMD_RPM_XO_BUFFER_PINCTRL(_platform, _name, _active, r_id) \
138 __DEFINE_CLK_SMD_RPM_BRANCH(_platform, _name, _active, \
139 QCOM_SMD_RPM_CLK_BUF_A, r_id, 0, 1000, \
140 QCOM_RPM_KEY_PIN_CTRL_CLK_BUFFER_ENABLE_KEY)