2014-11-03 11:07:35 -07:00
/* Copyright (c) 2011-2012, 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
* only version 2 as published by the Free Software Foundation .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*/
# ifndef _CORESIGHT_PRIV_H
# define _CORESIGHT_PRIV_H
# include <linux/bitops.h>
# include <linux/io.h>
# include <linux/coresight.h>
/*
* Coresight management registers ( 0xf00 - 0xfcc )
* 0xfa0 - 0xfa4 : Management registers in PFTv1 .0
* Trace registers in PFTv1 .1
*/
# define CORESIGHT_ITCTRL 0xf00
# define CORESIGHT_CLAIMSET 0xfa0
# define CORESIGHT_CLAIMCLR 0xfa4
# define CORESIGHT_LAR 0xfb0
# define CORESIGHT_LSR 0xfb4
# define CORESIGHT_AUTHSTATUS 0xfb8
# define CORESIGHT_DEVID 0xfc8
# define CORESIGHT_DEVTYPE 0xfcc
# define TIMEOUT_US 100
# define BMVAL(val, lsb, msb) ((val & GENMASK(msb, lsb)) >> lsb)
2016-02-17 17:51:56 -07:00
# define ETM_MODE_EXCL_KERN BIT(30)
# define ETM_MODE_EXCL_USER BIT(31)
2016-04-05 11:53:50 -06:00
# define coresight_simple_func(type, name, offset) \
static ssize_t name # # _show ( struct device * _dev , \
struct device_attribute * attr , char * buf ) \
{ \
type * drvdata = dev_get_drvdata ( _dev - > parent ) ; \
return scnprintf ( buf , PAGE_SIZE , " 0x%x \n " , \
readl_relaxed ( drvdata - > base + offset ) ) ; \
} \
static DEVICE_ATTR_RO ( name )
2016-02-17 17:51:52 -07:00
enum cs_mode {
CS_MODE_DISABLED ,
CS_MODE_SYSFS ,
CS_MODE_PERF ,
} ;
2014-11-03 11:07:35 -07:00
static inline void CS_LOCK ( void __iomem * addr )
{
do {
/* Wait for things to settle */
mb ( ) ;
writel_relaxed ( 0x0 , addr + CORESIGHT_LAR ) ;
} while ( 0 ) ;
}
static inline void CS_UNLOCK ( void __iomem * addr )
{
do {
writel_relaxed ( CORESIGHT_UNLOCK , addr + CORESIGHT_LAR ) ;
2014-11-13 14:12:47 +05:30
/* Make sure everyone has seen this */
2014-11-03 11:07:35 -07:00
mb ( ) ;
} while ( 0 ) ;
}
2016-02-17 17:51:45 -07:00
void coresight_disable_path ( struct list_head * path ) ;
2016-02-17 17:51:59 -07:00
int coresight_enable_path ( struct list_head * path , u32 mode ) ;
2016-02-17 17:51:46 -07:00
struct coresight_device * coresight_get_sink ( struct list_head * path ) ;
2016-02-17 17:51:45 -07:00
struct list_head * coresight_build_path ( struct coresight_device * csdev ) ;
void coresight_release_path ( struct list_head * path ) ;
2014-11-03 11:07:35 -07:00
# ifdef CONFIG_CORESIGHT_SOURCE_ETM3X
extern int etm_readl_cp14 ( u32 off , unsigned int * val ) ;
extern int etm_writel_cp14 ( u32 off , u32 val ) ;
# else
static inline int etm_readl_cp14 ( u32 off , unsigned int * val ) { return 0 ; }
2015-01-26 09:22:25 -07:00
static inline int etm_writel_cp14 ( u32 off , u32 val ) { return 0 ; }
2014-11-03 11:07:35 -07:00
# endif
# endif