Pratik Patel | 7492943 | 2011-12-26 12:03:41 -0800 | [diff] [blame] | 1 | /* 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 | |
| 26 | enum { |
| 27 | QDSS_CLK_OFF, |
| 28 | QDSS_CLK_ON_DBG, |
| 29 | QDSS_CLK_ON_HSDBG, |
| 30 | }; |
| 31 | |
| 32 | |
| 33 | int 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 | |
| 46 | err_clk: |
| 47 | return ret; |
| 48 | } |
| 49 | |
| 50 | void 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 Patel | 59e2994 | 2011-12-27 10:31:33 -0800 | [diff] [blame] | 60 | |
| 61 | static 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 Patel | 492b301 | 2012-03-06 14:22:30 -0800 | [diff] [blame^] | 74 | ret = etm_init(); |
Pratik Patel | 59e2994 | 2011-12-27 10:31:33 -0800 | [diff] [blame] | 75 | if (ret) |
Pratik Patel | 492b301 | 2012-03-06 14:22:30 -0800 | [diff] [blame^] | 76 | goto err_etm; |
Pratik Patel | 59e2994 | 2011-12-27 10:31:33 -0800 | [diff] [blame] | 77 | |
| 78 | return 0; |
Pratik Patel | 492b301 | 2012-03-06 14:22:30 -0800 | [diff] [blame^] | 79 | err_etm: |
Pratik Patel | 59e2994 | 2011-12-27 10:31:33 -0800 | [diff] [blame] | 80 | funnel_exit(); |
| 81 | err_funnel: |
| 82 | tpiu_exit(); |
| 83 | err_tpiu: |
| 84 | etb_exit(); |
| 85 | err_etb: |
| 86 | return ret; |
| 87 | } |
| 88 | module_init(qdss_init); |
| 89 | |
| 90 | static void __exit qdss_exit(void) |
| 91 | { |
Pratik Patel | 492b301 | 2012-03-06 14:22:30 -0800 | [diff] [blame^] | 92 | etm_exit(); |
Pratik Patel | 59e2994 | 2011-12-27 10:31:33 -0800 | [diff] [blame] | 93 | funnel_exit(); |
| 94 | tpiu_exit(); |
| 95 | etb_exit(); |
| 96 | } |
| 97 | module_exit(qdss_exit); |
| 98 | |
| 99 | MODULE_LICENSE("GPL v2"); |
| 100 | MODULE_DESCRIPTION("Qualcomm Debug SubSystem Driver"); |