hwpmc_xscale.h revision 200928
1181424Sedwin/*-
275267Swollman * Copyright (c) 2009 Rui Paulo <rpaulo@FreeBSD.org>
32742Swollman * All rights reserved.
42742Swollman *
52742Swollman * Redistribution and use in source and binary forms, with or without
658787Sru * modification, are permitted provided that the following conditions
758787Sru * are met:
82742Swollman * 1. Redistributions of source code must retain the above copyright
92742Swollman *    notice, this list of conditions and the following disclaimer.
102742Swollman * 2. Redistributions in binary form must reproduce the above copyright
112742Swollman *    notice, this list of conditions and the following disclaimer in the
122742Swollman *    documentation and/or other materials provided with the distribution.
132742Swollman *
142742Swollman * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
152742Swollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
162742Swollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
172742Swollman * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
182742Swollman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
192742Swollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
202742Swollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2143014Swollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
222742Swollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
232742Swollman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
242742Swollman * SUCH DAMAGE.
252742Swollman *
262742Swollman * $FreeBSD: head/sys/dev/hwpmc/hwpmc_xscale.h 200928 2009-12-23 23:16:54Z rpaulo $
272742Swollman */
282742Swollman
292742Swollman#ifndef _DEV_HWPMC_XSCALE_H_
302742Swollman#define _DEV_HWPMC_XSCALE_H_
312742Swollman
322742Swollman#define	XSCALE_PMC_CAPS		(PMC_CAP_INTERRUPT | PMC_CAP_USER |     \
332742Swollman				 PMC_CAP_SYSTEM | PMC_CAP_EDGE |	\
342742Swollman				 PMC_CAP_THRESHOLD | PMC_CAP_READ |	\
352742Swollman				 PMC_CAP_WRITE | PMC_CAP_INVERT |	\
362742Swollman				 PMC_CAP_QUALIFIER)
372742Swollman
382742Swollman
392742Swollman#define	XSCALE_PMNC_ENABLE		0x01	/* Enable all Counters */
402742Swollman#define	XSCALE_PMNC_PMNRESET		0x02	/* Performance Counter Reset */
412742Swollman#define	XSCALE_PMNC_CCNTRESET		0x04	/* Clock Counter Reset */
422742Swollman#define	XSCALE_PMNC_CCNTDIV		0x08	/* Clock Counter Divider */
4339871Sphk/* IXP425 only -- first generation */
4439871Sphk#define	XSCALE_PMNC_EVT0_MASK		0x00ff000
4539898Sphk#define	XSCALE_PMNC_EVT1_MASK		0xff00000
46147771Sphk
47181424Sedwin#define	XSCALE_INTEN_CCNT		0x01	/* Enable Clock Counter Int. */
4886222Swollman#define	XSCALE_INTEN_PMN0		0x02	/* Enable PMN0 Interrupts */
49171948Sedwin#define	XSCALE_INTEN_PMN1		0x04	/* Enable PMN1 Interrupts */
50176974Sedwin#define	XSCALE_INTEN_PMN2		0x08	/* Enable PMN2 Interrupts */
51136638Swollman#define	XSCALE_INTEN_PMN3		0x10	/* Enable PMN3 Interrupts */
52149514Swollman
5375267Swollman#define	XSCALE_EVTSEL_EVT0_MASK		0x000000ff
54181424Sedwin#define	XSCALE_EVTSEL_EVT1_MASK		0x0000ff00
5575267Swollman#define	XSCALE_EVTSEL_EVT2_MASK		0x00ff0000
56171948Sedwin#define	XSCALE_EVTSEL_EVT3_MASK		0xff000000
57171948Sedwin
58181424Sedwin#define	XSCALE_FLAG_CCNT_OVERFLOW	0x01
59181424Sedwin#define	XSCALE_FLAG_PMN0_OVERFLOW	0x02
60149514Swollman#define	XSCALE_FLAG_PMN1_OVERFLOW	0x04
61187524Sphk#define	XSCALE_FLAG_PMN2_OVERFLOW	0x08
62149514Swollman#define	XSCALE_FLAG_PMN3_OVERFLOW	0x10
63187524Sphk
64149514Swollman#define	XSCALE_RELOAD_COUNT_TO_PERFCTR_VALUE(R)	(-(R))
65181424Sedwin#define	XSCALE_PERFCTR_VALUE_TO_RELOAD_COUNT(P)	(-(P))
66171948Sedwin
67181424Sedwin#ifdef _KERNEL
68171948Sedwin/* MD extension for 'struct pmc' */
69187524Sphkstruct pmc_md_xscale_pmc {
70187524Sphk	uint32_t	pm_xscale_evsel;
71187524Sphk};
72187524Sphk#endif /* _KERNEL */
73187524Sphk#endif /* _DEV_HWPMC_XSCALE_H_ */
74171948Sedwin