18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2003-2011 NetLogic Microsystems, Inc. (NetLogic). All rights
38c2ecf20Sopenharmony_ci * reserved.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two
68c2ecf20Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
78c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
88c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the NetLogic
98c2ecf20Sopenharmony_ci * license below:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
128c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions
138c2ecf20Sopenharmony_ci * are met:
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright
168c2ecf20Sopenharmony_ci *    notice, this list of conditions and the following disclaimer.
178c2ecf20Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright
188c2ecf20Sopenharmony_ci *    notice, this list of conditions and the following disclaimer in
198c2ecf20Sopenharmony_ci *    the documentation and/or other materials provided with the
208c2ecf20Sopenharmony_ci *    distribution.
218c2ecf20Sopenharmony_ci *
228c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY NETLOGIC ``AS IS'' AND ANY EXPRESS OR
238c2ecf20Sopenharmony_ci * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
248c2ecf20Sopenharmony_ci * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
258c2ecf20Sopenharmony_ci * ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE LIABLE
268c2ecf20Sopenharmony_ci * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
278c2ecf20Sopenharmony_ci * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
288c2ecf20Sopenharmony_ci * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
298c2ecf20Sopenharmony_ci * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
308c2ecf20Sopenharmony_ci * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
318c2ecf20Sopenharmony_ci * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
328c2ecf20Sopenharmony_ci * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
338c2ecf20Sopenharmony_ci */
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#ifndef __NLM_HAL_SYS_H__
368c2ecf20Sopenharmony_ci#define __NLM_HAL_SYS_H__
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci/**
398c2ecf20Sopenharmony_ci* @file_name sys.h
408c2ecf20Sopenharmony_ci* @author Netlogic Microsystems
418c2ecf20Sopenharmony_ci* @brief HAL for System configuration registers
428c2ecf20Sopenharmony_ci*/
438c2ecf20Sopenharmony_ci#define SYS_CHIP_RESET				0x00
448c2ecf20Sopenharmony_ci#define SYS_POWER_ON_RESET_CFG			0x01
458c2ecf20Sopenharmony_ci#define SYS_EFUSE_DEVICE_CFG_STATUS0		0x02
468c2ecf20Sopenharmony_ci#define SYS_EFUSE_DEVICE_CFG_STATUS1		0x03
478c2ecf20Sopenharmony_ci#define SYS_EFUSE_DEVICE_CFG_STATUS2		0x04
488c2ecf20Sopenharmony_ci#define SYS_EFUSE_DEVICE_CFG3			0x05
498c2ecf20Sopenharmony_ci#define SYS_EFUSE_DEVICE_CFG4			0x06
508c2ecf20Sopenharmony_ci#define SYS_EFUSE_DEVICE_CFG5			0x07
518c2ecf20Sopenharmony_ci#define SYS_EFUSE_DEVICE_CFG6			0x08
528c2ecf20Sopenharmony_ci#define SYS_EFUSE_DEVICE_CFG7			0x09
538c2ecf20Sopenharmony_ci#define SYS_PLL_CTRL				0x0a
548c2ecf20Sopenharmony_ci#define SYS_CPU_RESET				0x0b
558c2ecf20Sopenharmony_ci#define SYS_CPU_NONCOHERENT_MODE		0x0d
568c2ecf20Sopenharmony_ci#define SYS_CORE_DFS_DIS_CTRL			0x0e
578c2ecf20Sopenharmony_ci#define SYS_CORE_DFS_RST_CTRL			0x0f
588c2ecf20Sopenharmony_ci#define SYS_CORE_DFS_BYP_CTRL			0x10
598c2ecf20Sopenharmony_ci#define SYS_CORE_DFS_PHA_CTRL			0x11
608c2ecf20Sopenharmony_ci#define SYS_CORE_DFS_DIV_INC_CTRL		0x12
618c2ecf20Sopenharmony_ci#define SYS_CORE_DFS_DIV_DEC_CTRL		0x13
628c2ecf20Sopenharmony_ci#define SYS_CORE_DFS_DIV_VALUE			0x14
638c2ecf20Sopenharmony_ci#define SYS_RESET				0x15
648c2ecf20Sopenharmony_ci#define SYS_DFS_DIS_CTRL			0x16
658c2ecf20Sopenharmony_ci#define SYS_DFS_RST_CTRL			0x17
668c2ecf20Sopenharmony_ci#define SYS_DFS_BYP_CTRL			0x18
678c2ecf20Sopenharmony_ci#define SYS_DFS_DIV_INC_CTRL			0x19
688c2ecf20Sopenharmony_ci#define SYS_DFS_DIV_DEC_CTRL			0x1a
698c2ecf20Sopenharmony_ci#define SYS_DFS_DIV_VALUE0			0x1b
708c2ecf20Sopenharmony_ci#define SYS_DFS_DIV_VALUE1			0x1c
718c2ecf20Sopenharmony_ci#define SYS_SENSE_AMP_DLY			0x1d
728c2ecf20Sopenharmony_ci#define SYS_SOC_SENSE_AMP_DLY			0x1e
738c2ecf20Sopenharmony_ci#define SYS_CTRL0				0x1f
748c2ecf20Sopenharmony_ci#define SYS_CTRL1				0x20
758c2ecf20Sopenharmony_ci#define SYS_TIMEOUT_BS1				0x21
768c2ecf20Sopenharmony_ci#define SYS_BYTE_SWAP				0x22
778c2ecf20Sopenharmony_ci#define SYS_VRM_VID				0x23
788c2ecf20Sopenharmony_ci#define SYS_PWR_RAM_CMD				0x24
798c2ecf20Sopenharmony_ci#define SYS_PWR_RAM_ADDR			0x25
808c2ecf20Sopenharmony_ci#define SYS_PWR_RAM_DATA0			0x26
818c2ecf20Sopenharmony_ci#define SYS_PWR_RAM_DATA1			0x27
828c2ecf20Sopenharmony_ci#define SYS_PWR_RAM_DATA2			0x28
838c2ecf20Sopenharmony_ci#define SYS_PWR_UCODE				0x29
848c2ecf20Sopenharmony_ci#define SYS_CPU0_PWR_STATUS			0x2a
858c2ecf20Sopenharmony_ci#define SYS_CPU1_PWR_STATUS			0x2b
868c2ecf20Sopenharmony_ci#define SYS_CPU2_PWR_STATUS			0x2c
878c2ecf20Sopenharmony_ci#define SYS_CPU3_PWR_STATUS			0x2d
888c2ecf20Sopenharmony_ci#define SYS_CPU4_PWR_STATUS			0x2e
898c2ecf20Sopenharmony_ci#define SYS_CPU5_PWR_STATUS			0x2f
908c2ecf20Sopenharmony_ci#define SYS_CPU6_PWR_STATUS			0x30
918c2ecf20Sopenharmony_ci#define SYS_CPU7_PWR_STATUS			0x31
928c2ecf20Sopenharmony_ci#define SYS_STATUS				0x32
938c2ecf20Sopenharmony_ci#define SYS_INT_POL				0x33
948c2ecf20Sopenharmony_ci#define SYS_INT_TYPE				0x34
958c2ecf20Sopenharmony_ci#define SYS_INT_STATUS				0x35
968c2ecf20Sopenharmony_ci#define SYS_INT_MASK0				0x36
978c2ecf20Sopenharmony_ci#define SYS_INT_MASK1				0x37
988c2ecf20Sopenharmony_ci#define SYS_UCO_S_ECC				0x38
998c2ecf20Sopenharmony_ci#define SYS_UCO_M_ECC				0x39
1008c2ecf20Sopenharmony_ci#define SYS_UCO_ADDR				0x3a
1018c2ecf20Sopenharmony_ci#define SYS_UCO_INSTR				0x3b
1028c2ecf20Sopenharmony_ci#define SYS_MEM_BIST0				0x3c
1038c2ecf20Sopenharmony_ci#define SYS_MEM_BIST1				0x3d
1048c2ecf20Sopenharmony_ci#define SYS_MEM_BIST2				0x3e
1058c2ecf20Sopenharmony_ci#define SYS_MEM_BIST3				0x3f
1068c2ecf20Sopenharmony_ci#define SYS_MEM_BIST4				0x40
1078c2ecf20Sopenharmony_ci#define SYS_MEM_BIST5				0x41
1088c2ecf20Sopenharmony_ci#define SYS_MEM_BIST6				0x42
1098c2ecf20Sopenharmony_ci#define SYS_MEM_BIST7				0x43
1108c2ecf20Sopenharmony_ci#define SYS_MEM_BIST8				0x44
1118c2ecf20Sopenharmony_ci#define SYS_MEM_BIST9				0x45
1128c2ecf20Sopenharmony_ci#define SYS_MEM_BIST10				0x46
1138c2ecf20Sopenharmony_ci#define SYS_MEM_BIST11				0x47
1148c2ecf20Sopenharmony_ci#define SYS_MEM_BIST12				0x48
1158c2ecf20Sopenharmony_ci#define SYS_SCRTCH0				0x49
1168c2ecf20Sopenharmony_ci#define SYS_SCRTCH1				0x4a
1178c2ecf20Sopenharmony_ci#define SYS_SCRTCH2				0x4b
1188c2ecf20Sopenharmony_ci#define SYS_SCRTCH3				0x4c
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci/* PLL registers XLP2XX */
1218c2ecf20Sopenharmony_ci#define SYS_CPU_PLL_CTRL0(core)			(0x1c0 + (core * 4))
1228c2ecf20Sopenharmony_ci#define SYS_CPU_PLL_CTRL1(core)			(0x1c1 + (core * 4))
1238c2ecf20Sopenharmony_ci#define SYS_CPU_PLL_CTRL2(core)			(0x1c2 + (core * 4))
1248c2ecf20Sopenharmony_ci#define SYS_CPU_PLL_CTRL3(core)			(0x1c3 + (core * 4))
1258c2ecf20Sopenharmony_ci#define SYS_PLL_CTRL0				0x240
1268c2ecf20Sopenharmony_ci#define SYS_PLL_CTRL1				0x241
1278c2ecf20Sopenharmony_ci#define SYS_PLL_CTRL2				0x242
1288c2ecf20Sopenharmony_ci#define SYS_PLL_CTRL3				0x243
1298c2ecf20Sopenharmony_ci#define SYS_DMC_PLL_CTRL0			0x244
1308c2ecf20Sopenharmony_ci#define SYS_DMC_PLL_CTRL1			0x245
1318c2ecf20Sopenharmony_ci#define SYS_DMC_PLL_CTRL2			0x246
1328c2ecf20Sopenharmony_ci#define SYS_DMC_PLL_CTRL3			0x247
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci#define SYS_PLL_CTRL0_DEVX(x)			(0x248 + (x) * 4)
1358c2ecf20Sopenharmony_ci#define SYS_PLL_CTRL1_DEVX(x)			(0x249 + (x) * 4)
1368c2ecf20Sopenharmony_ci#define SYS_PLL_CTRL2_DEVX(x)			(0x24a + (x) * 4)
1378c2ecf20Sopenharmony_ci#define SYS_PLL_CTRL3_DEVX(x)			(0x24b + (x) * 4)
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci#define SYS_CPU_PLL_CHG_CTRL			0x288
1408c2ecf20Sopenharmony_ci#define SYS_PLL_CHG_CTRL			0x289
1418c2ecf20Sopenharmony_ci#define SYS_CLK_DEV_DIS				0x28a
1428c2ecf20Sopenharmony_ci#define SYS_CLK_DEV_SEL				0x28b
1438c2ecf20Sopenharmony_ci#define SYS_CLK_DEV_DIV				0x28c
1448c2ecf20Sopenharmony_ci#define SYS_CLK_DEV_CHG				0x28d
1458c2ecf20Sopenharmony_ci#define SYS_CLK_DEV_SEL_REG			0x28e
1468c2ecf20Sopenharmony_ci#define SYS_CLK_DEV_DIV_REG			0x28f
1478c2ecf20Sopenharmony_ci#define SYS_CPU_PLL_LOCK			0x29f
1488c2ecf20Sopenharmony_ci#define SYS_SYS_PLL_LOCK			0x2a0
1498c2ecf20Sopenharmony_ci#define SYS_PLL_MEM_CMD				0x2a1
1508c2ecf20Sopenharmony_ci#define SYS_CPU_PLL_MEM_REQ			0x2a2
1518c2ecf20Sopenharmony_ci#define SYS_SYS_PLL_MEM_REQ			0x2a3
1528c2ecf20Sopenharmony_ci#define SYS_PLL_MEM_STAT			0x2a4
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci/* PLL registers XLP9XX */
1558c2ecf20Sopenharmony_ci#define SYS_9XX_CPU_PLL_CTRL0(core)		(0xc0 + (core * 4))
1568c2ecf20Sopenharmony_ci#define SYS_9XX_CPU_PLL_CTRL1(core)		(0xc1 + (core * 4))
1578c2ecf20Sopenharmony_ci#define SYS_9XX_CPU_PLL_CTRL2(core)		(0xc2 + (core * 4))
1588c2ecf20Sopenharmony_ci#define SYS_9XX_CPU_PLL_CTRL3(core)		(0xc3 + (core * 4))
1598c2ecf20Sopenharmony_ci#define SYS_9XX_DMC_PLL_CTRL0			0x140
1608c2ecf20Sopenharmony_ci#define SYS_9XX_DMC_PLL_CTRL1			0x141
1618c2ecf20Sopenharmony_ci#define SYS_9XX_DMC_PLL_CTRL2			0x142
1628c2ecf20Sopenharmony_ci#define SYS_9XX_DMC_PLL_CTRL3			0x143
1638c2ecf20Sopenharmony_ci#define SYS_9XX_PLL_CTRL0			0x144
1648c2ecf20Sopenharmony_ci#define SYS_9XX_PLL_CTRL1			0x145
1658c2ecf20Sopenharmony_ci#define SYS_9XX_PLL_CTRL2			0x146
1668c2ecf20Sopenharmony_ci#define SYS_9XX_PLL_CTRL3			0x147
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci#define SYS_9XX_PLL_CTRL0_DEVX(x)		(0x148 + (x) * 4)
1698c2ecf20Sopenharmony_ci#define SYS_9XX_PLL_CTRL1_DEVX(x)		(0x149 + (x) * 4)
1708c2ecf20Sopenharmony_ci#define SYS_9XX_PLL_CTRL2_DEVX(x)		(0x14a + (x) * 4)
1718c2ecf20Sopenharmony_ci#define SYS_9XX_PLL_CTRL3_DEVX(x)		(0x14b + (x) * 4)
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci#define SYS_9XX_CPU_PLL_CHG_CTRL		0x188
1748c2ecf20Sopenharmony_ci#define SYS_9XX_PLL_CHG_CTRL			0x189
1758c2ecf20Sopenharmony_ci#define SYS_9XX_CLK_DEV_DIS			0x18a
1768c2ecf20Sopenharmony_ci#define SYS_9XX_CLK_DEV_SEL			0x18b
1778c2ecf20Sopenharmony_ci#define SYS_9XX_CLK_DEV_DIV			0x18d
1788c2ecf20Sopenharmony_ci#define SYS_9XX_CLK_DEV_CHG			0x18f
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci#define SYS_9XX_CLK_DEV_SEL_REG			0x1a4
1818c2ecf20Sopenharmony_ci#define SYS_9XX_CLK_DEV_DIV_REG			0x1a6
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_ci/* Registers changed on 9XX */
1848c2ecf20Sopenharmony_ci#define SYS_9XX_POWER_ON_RESET_CFG		0x00
1858c2ecf20Sopenharmony_ci#define SYS_9XX_CHIP_RESET			0x01
1868c2ecf20Sopenharmony_ci#define SYS_9XX_CPU_RESET			0x02
1878c2ecf20Sopenharmony_ci#define SYS_9XX_CPU_NONCOHERENT_MODE		0x03
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_ci/* XLP 9XX fuse block registers */
1908c2ecf20Sopenharmony_ci#define FUSE_9XX_DEVCFG6			0xc6
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci#define nlm_read_sys_reg(b, r)		nlm_read_reg(b, r)
1958c2ecf20Sopenharmony_ci#define nlm_write_sys_reg(b, r, v)	nlm_write_reg(b, r, v)
1968c2ecf20Sopenharmony_ci#define nlm_get_sys_pcibase(node)	nlm_pcicfg_base(cpu_is_xlp9xx() ? \
1978c2ecf20Sopenharmony_ci		XLP9XX_IO_SYS_OFFSET(node) : XLP_IO_SYS_OFFSET(node))
1988c2ecf20Sopenharmony_ci#define nlm_get_sys_regbase(node) (nlm_get_sys_pcibase(node) + XLP_IO_PCI_HDRSZ)
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci/* XLP9XX fuse block */
2018c2ecf20Sopenharmony_ci#define nlm_get_fuse_pcibase(node)	\
2028c2ecf20Sopenharmony_ci			nlm_pcicfg_base(XLP9XX_IO_FUSE_OFFSET(node))
2038c2ecf20Sopenharmony_ci#define nlm_get_fuse_regbase(node)	\
2048c2ecf20Sopenharmony_ci			(nlm_get_fuse_pcibase(node) + XLP_IO_PCI_HDRSZ)
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_ci#define nlm_get_clock_pcibase(node)	\
2078c2ecf20Sopenharmony_ci			nlm_pcicfg_base(XLP9XX_IO_CLOCK_OFFSET(node))
2088c2ecf20Sopenharmony_ci#define nlm_get_clock_regbase(node)	\
2098c2ecf20Sopenharmony_ci			(nlm_get_clock_pcibase(node) + XLP_IO_PCI_HDRSZ)
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ciunsigned int nlm_get_pic_frequency(int node);
2128c2ecf20Sopenharmony_ci#endif
2138c2ecf20Sopenharmony_ci#endif
214