--- zzzz-none-000/linux-4.4.271/include/linux/coresight.h 2021-06-03 06:22:09.000000000 +0000 +++ hawkeye-5590-750/linux-4.4.271/include/linux/coresight.h 2023-04-19 10:22:30.000000000 +0000 @@ -1,4 +1,4 @@ -/* Copyright (c) 2012, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012, 2016 The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -15,6 +15,29 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* Peripheral id registers (0xFD0-0xFEC) */ #define CORESIGHT_PERIPHIDR4 0xfd0 @@ -38,6 +61,13 @@ #define CORESIGHT_UNLOCK 0xc5acce55 +#define TMC_ETR_SG_ENT_TO_BLK(phys_pte) (((phys_addr_t)phys_pte >> 4) \ + << PAGE_SHIFT) +#define Q6STREAM_SIZE (1024 * 1024) +#define TOTAL_PAGES_PER_DATA (Q6STREAM_SIZE / PAGE_SIZE) +#define PAGES_PER_DATA 8 +#define COMP_PAGES_PER_DATA (TOTAL_PAGES_PER_DATA - PAGES_PER_DATA) + extern struct bus_type coresight_bustype; enum coresight_dev_type { @@ -94,6 +124,7 @@ connected to. * @nr_outport: number of output ports for this component. * @clk: The clock this component is associated to. + * @default_sink: Flag to set default sink */ struct coresight_platform_data { int cpu; @@ -104,6 +135,7 @@ int *child_ports; int nr_outport; struct clk *clk; + bool default_sink; }; /** @@ -185,10 +217,12 @@ * Operations available for sinks * @enable: enables the sink. * @disable: disables the sink. + * @abort: captures sink trace on abort */ struct coresight_ops_sink { int (*enable)(struct coresight_device *csdev); void (*disable)(struct coresight_device *csdev); + void (*abort)(struct coresight_device *csdev); }; /** @@ -222,6 +256,110 @@ const struct coresight_ops_source *source_ops; }; +enum tmc_config_type { + TMC_CONFIG_TYPE_ETB, + TMC_CONFIG_TYPE_ETR, + TMC_CONFIG_TYPE_ETF, +}; + +enum tmc_mode { + TMC_MODE_CIRCULAR_BUFFER, + TMC_MODE_SOFTWARE_FIFO, + TMC_MODE_HARDWARE_FIFO, +}; + +enum tmc_mem_intf_width { + TMC_MEM_INTF_WIDTH_32BITS = 0x2, + TMC_MEM_INTF_WIDTH_64BITS = 0x3, + TMC_MEM_INTF_WIDTH_128BITS = 0x4, + TMC_MEM_INTF_WIDTH_256BITS = 0x5, +}; + +enum tmc_etr_mem_type { + TMC_ETR_MEM_TYPE_CONTIG, + TMC_ETR_MEM_TYPE_SG, +}; + +static const char * const str_tmc_etr_mem_type[] = { + [TMC_ETR_MEM_TYPE_CONTIG] = "contig", + [TMC_ETR_MEM_TYPE_SG] = "sg", +}; + +enum tmc_etr_out_mode { + TMC_ETR_OUT_MODE_NONE, + TMC_ETR_OUT_MODE_MEM, + TMC_ETR_OUT_MODE_USB, + TMC_ETR_OUT_MODE_Q6MEM, + TMC_ETR_OUT_MODE_Q6MEM_STREAM, +}; + +/** + * struct tmc_drvdata - specifics associated to an TMC component + * @base: memory mapped base address for this component. + * @dev: the device entity associated to this component. + * @csdev: component vitals needed by the framework. + * @miscdev: specifics to handle "/dev/xyz.tmc" entry. + * @spinlock: only one at a time pls. + * @read_count: manages preparation of buffer for reading. + * @buf: area of memory where trace data get sent. + * @paddr: DMA start location in RAM. + * @vaddr: virtual representation of @paddr. + * @size: @buf size. + * @enable: this TMC is being used. + * @config_type: TMC variant, must be of type @tmc_config_type. + * @trigger_cntr: amount of words to store after a trigger. + * @reg_data: MSM memory dump data to store TMC registers. + * @buf_data: MSM memory dump data to store ETF/ETB buffer. + */ +struct tmc_drvdata { + void __iomem *base; + struct device *dev; + struct coresight_device *csdev; + struct miscdevice miscdev; + spinlock_t spinlock; + int read_count; + bool reading; + bool aborting; + char *buf; + dma_addr_t paddr; + void *vaddr; + u32 size; + struct mutex mem_lock; + u32 mem_size; + bool enable; + bool sticky_enable; + enum tmc_config_type config_type; + u32 trigger_cntr; + enum tmc_etr_mem_type mem_type; + enum tmc_etr_mem_type memtype; + u32 delta_bottom; + int sg_blk_num; + enum tmc_etr_out_mode out_mode; + struct usb_qdss_ch *usbch; + struct tmc_etr_bam_data *bamdata; + bool enable_to_bam; + struct msm_dump_data reg_data; + struct msm_dump_data buf_data; + struct coresight_cti *cti_flush; + struct coresight_cti *cti_reset; + char *reg_buf; + bool force_reg_dump; + bool is_emulation; + bool dump_reg; + void __iomem *q6_etr_vaddr; + dma_addr_t q6_etr_paddr; + u32 q6_size; + int byte_cntr_irq; + int occupied_pingpong; + int current_pingpong; + struct work_struct qld_stream_work; + struct socket *qld_stream_sock; + atomic_t seq_no; + atomic_t completed_seq_no; +}; + + + #ifdef CONFIG_CORESIGHT extern struct coresight_device * coresight_register(struct coresight_desc *desc); @@ -230,6 +368,9 @@ extern void coresight_disable(struct coresight_device *csdev); extern int coresight_timeout(void __iomem *addr, u32 offset, int position, int value); +extern void coresight_abort(void); +extern void register_usb_qdss_open(void *fn); +extern void register_usb_qdss_close(void *fn); #else static inline struct coresight_device * coresight_register(struct coresight_desc *desc) { return NULL; } @@ -239,14 +380,21 @@ static inline void coresight_disable(struct coresight_device *csdev) {} static inline int coresight_timeout(void __iomem *addr, u32 offset, int position, int value) { return 1; } +static inline void coresight_abort(void) {} +static inline void register_usb_qdss_open(void *fn) {} +static inline void register_usb_qdss_close(void *fn) {} #endif -#ifdef CONFIG_OF +#if defined(CONFIG_OF) && defined(CONFIG_CORESIGHT) extern struct coresight_platform_data *of_get_coresight_platform_data( struct device *dev, struct device_node *node); +extern struct coresight_cti_data *of_get_coresight_cti_data( + struct device *dev, struct device_node *node); #else static inline struct coresight_platform_data *of_get_coresight_platform_data( struct device *dev, struct device_node *node) { return NULL; } +static inline struct coresight_cti_data *of_get_coresight_cti_data( + struct device *dev, struct device_node *node) { return NULL; } #endif #ifdef CONFIG_PID_NS