blob: 5917964fdf0a7b4b2e4e8eb9492c7e7dccfab017 [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
78 return 0;
Pratik Patel492b3012012-03-06 14:22:30 -080079err_etm:
Pratik Patel59e29942011-12-27 10:31:33 -080080 funnel_exit();
81err_funnel:
82 tpiu_exit();
83err_tpiu:
84 etb_exit();
85err_etb:
86 return ret;
87}
88module_init(qdss_init);
89
90static void __exit qdss_exit(void)
91{
Pratik Patel492b3012012-03-06 14:22:30 -080092 etm_exit();
Pratik Patel59e29942011-12-27 10:31:33 -080093 funnel_exit();
94 tpiu_exit();
95 etb_exit();
96}
97module_exit(qdss_exit);
98
99MODULE_LICENSE("GPL v2");
100MODULE_DESCRIPTION("Qualcomm Debug SubSystem Driver");