Pratik Patel | c35426a | 2012-03-17 12:02:53 -0700 | [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 | |
Pratik Patel | 43e47bd | 2012-05-19 18:10:55 -0700 | [diff] [blame] | 13 | #ifndef _LINUX_CS_H |
| 14 | #define _LINUX_CS_H |
| 15 | |
Pratik Patel | b84ef9d | 2012-05-24 14:01:43 -0700 | [diff] [blame^] | 16 | #include <linux/device.h> |
| 17 | |
Pratik Patel | 43e47bd | 2012-05-19 18:10:55 -0700 | [diff] [blame] | 18 | /* 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 Patel | c35426a | 2012-03-17 12:02:53 -0700 | [diff] [blame] | 40 | |
Pratik Patel | b84ef9d | 2012-05-24 14:01:43 -0700 | [diff] [blame^] | 41 | enum 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 | |
| 48 | struct cs_connection { |
| 49 | int child_id; |
| 50 | int child_port; |
| 51 | struct cs_device *child_dev; |
| 52 | struct list_head link; |
| 53 | }; |
| 54 | |
| 55 | struct 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 | |
| 70 | struct cs_ops { |
| 71 | int (*enable)(struct cs_device *csdev, int port); |
| 72 | void (*disable)(struct cs_device *csdev, int port); |
| 73 | }; |
| 74 | |
| 75 | struct 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 | |
| 84 | struct 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 Patel | 1403f2a | 2012-03-21 10:10:00 -0700 | [diff] [blame] | 93 | struct qdss_source { |
| 94 | struct list_head link; |
| 95 | const char *name; |
| 96 | uint32_t fport_mask; |
| 97 | }; |
| 98 | |
| 99 | struct msm_qdss_platform_data { |
| 100 | struct qdss_source *src_table; |
| 101 | size_t size; |
| 102 | uint8_t afamily; |
| 103 | }; |
| 104 | |
Pratik Patel | b84ef9d | 2012-05-24 14:01:43 -0700 | [diff] [blame^] | 105 | |
| 106 | extern struct cs_device *cs_register(struct cs_desc *desc); |
| 107 | extern void cs_unregister(struct cs_device *csdev); |
| 108 | extern int cs_enable(struct cs_device *csdev, int port); |
| 109 | extern void cs_disable(struct cs_device *csdev, int port); |
| 110 | |
Pratik Patel | bf3e7744 | 2012-03-18 18:30:43 -0700 | [diff] [blame] | 111 | #ifdef CONFIG_MSM_QDSS |
Pratik Patel | 1403f2a | 2012-03-21 10:10:00 -0700 | [diff] [blame] | 112 | extern struct qdss_source *qdss_get(const char *name); |
| 113 | extern void qdss_put(struct qdss_source *src); |
| 114 | extern int qdss_enable(struct qdss_source *src); |
| 115 | extern void qdss_disable(struct qdss_source *src); |
Pratik Patel | f3adf03 | 2012-05-03 12:50:21 -0700 | [diff] [blame] | 116 | extern void qdss_disable_sink(void); |
Pratik Patel | bf3e7744 | 2012-03-18 18:30:43 -0700 | [diff] [blame] | 117 | extern int qdss_clk_enable(void); |
| 118 | extern void qdss_clk_disable(void); |
| 119 | #else |
Pratik Patel | 1403f2a | 2012-03-21 10:10:00 -0700 | [diff] [blame] | 120 | static inline struct qdss_source *qdss_get(const char *name) { return NULL; } |
| 121 | static inline void qdss_put(struct qdss_source *src) {} |
| 122 | static inline int qdss_enable(struct qdss_source *src) { return -ENOSYS; } |
| 123 | static inline void qdss_disable(struct qdss_source *src) {} |
Pratik Patel | f3adf03 | 2012-05-03 12:50:21 -0700 | [diff] [blame] | 124 | static inline void qdss_disable_sink(void) {} |
Pratik Patel | bf3e7744 | 2012-03-18 18:30:43 -0700 | [diff] [blame] | 125 | static inline int qdss_clk_enable(void) { return -ENOSYS; } |
| 126 | static inline void qdss_clk_disable(void) {} |
| 127 | #endif |
| 128 | |
Pratik Patel | c35426a | 2012-03-17 12:02:53 -0700 | [diff] [blame] | 129 | #endif |