xref: /freebsd/sys/arm/ti/ti_cpuid.h (revision 56d8b96cbc3bd204e30061ff5c554f0c9acb3662)
1e53470feSOleksandr Tymoshenko /*-
2e53470feSOleksandr Tymoshenko  * Copyright (c) 2011
3e53470feSOleksandr Tymoshenko  *	Ben Gray <ben.r.gray@gmail.com>.
4e53470feSOleksandr Tymoshenko  * All rights reserved.
5e53470feSOleksandr Tymoshenko  *
6e53470feSOleksandr Tymoshenko  * Redistribution and use in source and binary forms, with or without
7e53470feSOleksandr Tymoshenko  * modification, are permitted provided that the following conditions
8e53470feSOleksandr Tymoshenko  * are met:
9e53470feSOleksandr Tymoshenko  * 1. Redistributions of source code must retain the above copyright
10e53470feSOleksandr Tymoshenko  *    notice, this list of conditions and the following disclaimer.
11e53470feSOleksandr Tymoshenko  * 2. Redistributions in binary form must reproduce the above copyright
12e53470feSOleksandr Tymoshenko  *    notice, this list of conditions and the following disclaimer in the
13e53470feSOleksandr Tymoshenko  *    documentation and/or other materials provided with the distribution.
14e53470feSOleksandr Tymoshenko  *
15e53470feSOleksandr Tymoshenko  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16e53470feSOleksandr Tymoshenko  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17e53470feSOleksandr Tymoshenko  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18e53470feSOleksandr Tymoshenko  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
19e53470feSOleksandr Tymoshenko  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20e53470feSOleksandr Tymoshenko  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21e53470feSOleksandr Tymoshenko  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22e53470feSOleksandr Tymoshenko  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23e53470feSOleksandr Tymoshenko  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24e53470feSOleksandr Tymoshenko  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25e53470feSOleksandr Tymoshenko  * SUCH DAMAGE.
26e53470feSOleksandr Tymoshenko  *
27e53470feSOleksandr Tymoshenko  * $FreeBSD$
28e53470feSOleksandr Tymoshenko  */
29e53470feSOleksandr Tymoshenko 
30e53470feSOleksandr Tymoshenko #ifndef _TI_CPUID_H_
31e53470feSOleksandr Tymoshenko #define	_TI_CPUID_H_
32e53470feSOleksandr Tymoshenko 
33e53470feSOleksandr Tymoshenko #define	OMAP_MAKEREV(d, a, b, c) \
34e53470feSOleksandr Tymoshenko 	(uint32_t)(((d) << 16) | (((a) & 0xf) << 8) | (((b) & 0xf) << 4) | ((c) & 0xf))
35e53470feSOleksandr Tymoshenko 
36e53470feSOleksandr Tymoshenko #define	OMAP_REV_DEVICE(x)	(((x) >> 16) & 0xffff)
37e53470feSOleksandr Tymoshenko #define	OMAP_REV_MAJOR(x)	(((x) >> 8) & 0xf)
38e53470feSOleksandr Tymoshenko #define	OMAP_REV_MINOR(x)	(((x) >> 4) & 0xf)
39e53470feSOleksandr Tymoshenko #define	OMAP_REV_MINOR_MINOR(x)	(((x) >> 0) & 0xf)
40e53470feSOleksandr Tymoshenko 
41e53470feSOleksandr Tymoshenko #define	OMAP3350_DEV		0x3530
42e53470feSOleksandr Tymoshenko #define	OMAP3350_REV_ES1_0	OMAP_MAKEREV(OMAP3350_DEV, 1, 0, 0)
43e53470feSOleksandr Tymoshenko #define	OMAP3530_REV_ES2_0	OMAP_MAKEREV(OMAP3350_DEV, 2, 0, 0)
44e53470feSOleksandr Tymoshenko #define	OMAP3530_REV_ES2_1	OMAP_MAKEREV(OMAP3350_DEV, 2, 1, 0)
45e53470feSOleksandr Tymoshenko #define	OMAP3530_REV_ES3_0	OMAP_MAKEREV(OMAP3350_DEV, 3, 0, 0)
46e53470feSOleksandr Tymoshenko #define	OMAP3530_REV_ES3_1	OMAP_MAKEREV(OMAP3350_DEV, 3, 1, 0)
47e53470feSOleksandr Tymoshenko #define	OMAP3530_REV_ES3_1_2	OMAP_MAKEREV(OMAP3350_DEV, 3, 1, 2)
48e53470feSOleksandr Tymoshenko 
49e53470feSOleksandr Tymoshenko #define	OMAP4430_DEV		0x4430
50e53470feSOleksandr Tymoshenko #define	OMAP4430_REV_ES1_0	OMAP_MAKEREV(OMAP4430_DEV, 1, 0, 0)
51e53470feSOleksandr Tymoshenko #define	OMAP4430_REV_ES2_0	OMAP_MAKEREV(OMAP4430_DEV, 2, 0, 0)
52e53470feSOleksandr Tymoshenko #define	OMAP4430_REV_ES2_1	OMAP_MAKEREV(OMAP4430_DEV, 2, 1, 0)
53e53470feSOleksandr Tymoshenko #define	OMAP4430_REV_ES2_2	OMAP_MAKEREV(OMAP4430_DEV, 2, 2, 0)
54e53470feSOleksandr Tymoshenko #define	OMAP4430_REV_ES2_3	OMAP_MAKEREV(OMAP4430_DEV, 2, 3, 0)
555c79e1ddSOleksandr Tymoshenko #define	OMAP4430_REV_UNKNOWN	OMAP_MAKEREV(OMAP4430_DEV, 9, 9, 9)
565c79e1ddSOleksandr Tymoshenko 
575c79e1ddSOleksandr Tymoshenko #define	OMAP4460_DEV		0x4460
585c79e1ddSOleksandr Tymoshenko #define	OMAP4460_REV_ES1_0	OMAP_MAKEREV(OMAP4460_DEV, 1, 0, 0)
595c79e1ddSOleksandr Tymoshenko #define	OMAP4460_REV_ES1_1	OMAP_MAKEREV(OMAP4460_DEV, 1, 1, 0)
605c79e1ddSOleksandr Tymoshenko #define	OMAP4460_REV_UNKNOWN	OMAP_MAKEREV(OMAP4460_DEV, 9, 9, 9)
615c79e1ddSOleksandr Tymoshenko 
625c79e1ddSOleksandr Tymoshenko #define	OMAP4470_DEV		0x4470
635c79e1ddSOleksandr Tymoshenko #define	OMAP4470_REV_ES1_0	OMAP_MAKEREV(OMAP4470_DEV, 1, 0, 0)
645c79e1ddSOleksandr Tymoshenko #define	OMAP4470_REV_UNKNOWN	OMAP_MAKEREV(OMAP4470_DEV, 9, 9, 9)
655c79e1ddSOleksandr Tymoshenko 
665c79e1ddSOleksandr Tymoshenko #define	OMAP_UNKNOWN_DEV	OMAP_MAKEREV(0x9999, 9, 9, 9)
67e53470feSOleksandr Tymoshenko 
68e53470feSOleksandr Tymoshenko #define	AM335X_DEVREV(x)	((x) >> 28)
69e53470feSOleksandr Tymoshenko 
70*56d8b96cSAndrew Turner #define	CHIP_OMAP_4	0
71*56d8b96cSAndrew Turner #define	CHIP_AM335X	1
72e53470feSOleksandr Tymoshenko 
73e53470feSOleksandr Tymoshenko static __inline int ti_chip(void)
74e53470feSOleksandr Tymoshenko {
75e53470feSOleksandr Tymoshenko #if defined(SOC_OMAP4)
76e53470feSOleksandr Tymoshenko 	return CHIP_OMAP_4;
77e53470feSOleksandr Tymoshenko #elif defined(SOC_TI_AM335X)
78e53470feSOleksandr Tymoshenko 	return CHIP_AM335X;
79e53470feSOleksandr Tymoshenko #else
80e53470feSOleksandr Tymoshenko #  error Chip type not defined, ensure SOC_xxxx is defined
81e53470feSOleksandr Tymoshenko #endif
82e53470feSOleksandr Tymoshenko }
83e53470feSOleksandr Tymoshenko 
84e53470feSOleksandr Tymoshenko uint32_t ti_revision(void);
85e53470feSOleksandr Tymoshenko 
86e53470feSOleksandr Tymoshenko #endif  /* _TI_CPUID_H_ */
87