blob: b9ba4ce9793ad1d7d22f9a217a6ab66f902cd3bd [file] [log] [blame]
Pratik Patel74929432011-12-26 12:03:41 -08001/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include <linux/kernel.h>
14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/types.h>
17#include <linux/device.h>
18#include <linux/platform_device.h>
19#include <linux/io.h>
20#include <linux/err.h>
21#include <mach/rpm.h>
22
23#include "rpm_resources.h"
24#include "qdss.h"
25
26enum {
27 QDSS_CLK_OFF,
28 QDSS_CLK_ON_DBG,
29 QDSS_CLK_ON_HSDBG,
30};
31
32
33int qdss_clk_enable(void)
34{
35 int ret;
36
37 struct msm_rpm_iv_pair iv;
38 iv.id = MSM_RPM_ID_QDSS_CLK;
39 iv.value = QDSS_CLK_ON_DBG;
40 ret = msm_rpmrs_set(MSM_RPM_CTX_SET_0, &iv, 1);
41 if (WARN(ret, "qdss clks not enabled (%d)\n", ret))
42 goto err_clk;
43
44 return 0;
45
46err_clk:
47 return ret;
48}
49
50void qdss_clk_disable(void)
51{
52 int ret;
53 struct msm_rpm_iv_pair iv;
54
55 iv.id = MSM_RPM_ID_QDSS_CLK;
56 iv.value = QDSS_CLK_OFF;
57 ret = msm_rpmrs_set(MSM_RPM_CTX_SET_0, &iv, 1);
58 WARN(ret, "qdss clks not disabled (%d)\n", ret);
59}
Pratik Patel59e29942011-12-27 10:31:33 -080060
61static int __init qdss_init(void)
62{
63 int ret;
64
65 ret = etb_init();
66 if (ret)
67 goto err_etb;
68 ret = tpiu_init();
69 if (ret)
70 goto err_tpiu;
71 ret = funnel_init();
72 if (ret)
73 goto err_funnel;
Pratik Patel492b3012012-03-06 14:22:30 -080074 ret = etm_init();
Pratik Patel59e29942011-12-27 10:31:33 -080075 if (ret)
Pratik Patel492b3012012-03-06 14:22:30 -080076 goto err_etm;
Pratik Patel59e29942011-12-27 10:31:33 -080077
Pratik Patel61de7302012-03-07 12:06:10 -080078 pr_info("QDSS initialized\n");
Pratik Patel59e29942011-12-27 10:31:33 -080079 return 0;
Pratik Patel492b3012012-03-06 14:22:30 -080080err_etm:
Pratik Patel59e29942011-12-27 10:31:33 -080081 funnel_exit();
82err_funnel:
83 tpiu_exit();
84err_tpiu:
85 etb_exit();
86err_etb:
Pratik Patel61de7302012-03-07 12:06:10 -080087 pr_err("QDSS init failed\n");
Pratik Patel59e29942011-12-27 10:31:33 -080088 return ret;
89}
90module_init(qdss_init);
91
92static void __exit qdss_exit(void)
93{
Pratik Patel492b3012012-03-06 14:22:30 -080094 etm_exit();
Pratik Patel59e29942011-12-27 10:31:33 -080095 funnel_exit();
96 tpiu_exit();
97 etb_exit();
98}
99module_exit(qdss_exit);
100
101MODULE_LICENSE("GPL v2");
102MODULE_DESCRIPTION("Qualcomm Debug SubSystem Driver");