blob: 1a0094c6b278af55d87253c26e35b62fc5e2e915 [file] [log] [blame]
Pratik Patelc35426a2012-03-17 12:02:53 -07001/* 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
Pratik Patel43e47bd2012-05-19 18:10:55 -070013#ifndef _LINUX_CS_H
14#define _LINUX_CS_H
15
Pratik Patelb84ef9d2012-05-24 14:01:43 -070016#include <linux/device.h>
17
Pratik Patel43e47bd2012-05-19 18:10:55 -070018/* Peripheral id registers (0xFD0-0xFEC) */
19#define CS_PIDR4 (0xFD0)
20#define CS_PIDR5 (0xFD4)
21#define CS_PIDR6 (0xFD8)
22#define CS_PIDR7 (0xFDC)
23#define CS_PIDR0 (0xFE0)
24#define CS_PIDR1 (0xFE4)
25#define CS_PIDR2 (0xFE8)
26#define CS_PIDR3 (0xFEC)
27/* Component id registers (0xFF0-0xFFC) */
28#define CS_CIDR0 (0xFF0)
29#define CS_CIDR1 (0xFF4)
30#define CS_CIDR2 (0xFF8)
31#define CS_CIDR3 (0xFFC)
32
33/* DBGv7 with baseline CP14 registers implemented */
34#define ARM_DEBUG_ARCH_V7B (0x3)
35/* DBGv7 with all CP14 registers implemented */
36#define ARM_DEBUG_ARCH_V7 (0x4)
37#define ARM_DEBUG_ARCH_V7_1 (0x5)
38#define ETM_ARCH_V3_3 (0x23)
39#define PFT_ARCH_V1_1 (0x31)
Pratik Patelc35426a2012-03-17 12:02:53 -070040
Pratik Patelb84ef9d2012-05-24 14:01:43 -070041enum cs_device_type {
42 CS_DEVICE_TYPE_SOURCE,
43 CS_DEVICE_TYPE_LINK,
44 CS_DEVICE_TYPE_SINK,
45 CS_DEVICE_TYPE_MAX,
46};
47
48struct cs_connection {
49 int child_id;
50 int child_port;
51 struct cs_device *child_dev;
52 struct list_head link;
53};
54
55struct cs_device {
56 int id;
57 struct cs_connection *conns;
58 int nr_conns;
59 const struct cs_ops *ops;
60 struct device dev;
61 struct mutex mutex;
62 int *refcnt;
63 struct list_head link;
64 struct module *owner;
65 bool enable;
66};
67
68#define to_cs_device(d) container_of(d, struct cs_device, dev)
69
70struct cs_ops {
71 int (*enable)(struct cs_device *csdev, int port);
72 void (*disable)(struct cs_device *csdev, int port);
73};
74
75struct cs_platform_data {
76 int id;
77 const char *name;
78 int nr_ports;
79 int *child_ids;
80 int *child_ports;
81 int nr_children;
82};
83
84struct cs_desc {
85 enum cs_device_type type;
86 const struct cs_ops *ops;
87 struct cs_platform_data *pdata;
88 struct device *dev;
89 const struct attribute_group **groups;
90 struct module *owner;
91};
92
Pratik Patel1403f2a2012-03-21 10:10:00 -070093struct qdss_source {
94 struct list_head link;
95 const char *name;
96 uint32_t fport_mask;
97};
98
99struct msm_qdss_platform_data {
100 struct qdss_source *src_table;
101 size_t size;
102 uint8_t afamily;
103};
104
Pratik Patelb84ef9d2012-05-24 14:01:43 -0700105
106extern struct cs_device *cs_register(struct cs_desc *desc);
107extern void cs_unregister(struct cs_device *csdev);
108extern int cs_enable(struct cs_device *csdev, int port);
109extern void cs_disable(struct cs_device *csdev, int port);
110
Pratik Patelbf3e77442012-03-18 18:30:43 -0700111#ifdef CONFIG_MSM_QDSS
Pratik Patel1403f2a2012-03-21 10:10:00 -0700112extern struct qdss_source *qdss_get(const char *name);
113extern void qdss_put(struct qdss_source *src);
114extern int qdss_enable(struct qdss_source *src);
115extern void qdss_disable(struct qdss_source *src);
Pratik Patelf3adf032012-05-03 12:50:21 -0700116extern void qdss_disable_sink(void);
Pratik Patelbf3e77442012-03-18 18:30:43 -0700117extern int qdss_clk_enable(void);
118extern void qdss_clk_disable(void);
119#else
Pratik Patel1403f2a2012-03-21 10:10:00 -0700120static inline struct qdss_source *qdss_get(const char *name) { return NULL; }
121static inline void qdss_put(struct qdss_source *src) {}
122static inline int qdss_enable(struct qdss_source *src) { return -ENOSYS; }
123static inline void qdss_disable(struct qdss_source *src) {}
Pratik Patelf3adf032012-05-03 12:50:21 -0700124static inline void qdss_disable_sink(void) {}
Pratik Patelbf3e77442012-03-18 18:30:43 -0700125static inline int qdss_clk_enable(void) { return -ENOSYS; }
126static inline void qdss_clk_disable(void) {}
127#endif
128
Pratik Patelc35426a2012-03-17 12:02:53 -0700129#endif