162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * common routine and memory layout for Tundra TSI108(Grendel) host bridge
462306a36Sopenharmony_ci * memory controller.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Author: Jacob Pan (jacob.pan@freescale.com)
762306a36Sopenharmony_ci *	   Alex Bounine (alexandreb@tundra.com)
862306a36Sopenharmony_ci *
962306a36Sopenharmony_ci * Copyright 2004-2006 Freescale Semiconductor, Inc.
1062306a36Sopenharmony_ci */
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#ifndef __PPC_KERNEL_TSI108_H
1362306a36Sopenharmony_ci#define __PPC_KERNEL_TSI108_H
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#include <asm/pci-bridge.h>
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci/* Size of entire register space */
1862306a36Sopenharmony_ci#define TSI108_REG_SIZE		(0x10000)
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci/* Sizes of register spaces for individual blocks */
2162306a36Sopenharmony_ci#define TSI108_HLP_SIZE		0x1000
2262306a36Sopenharmony_ci#define TSI108_PCI_SIZE		0x1000
2362306a36Sopenharmony_ci#define TSI108_CLK_SIZE		0x1000
2462306a36Sopenharmony_ci#define TSI108_PB_SIZE		0x1000
2562306a36Sopenharmony_ci#define TSI108_SD_SIZE		0x1000
2662306a36Sopenharmony_ci#define TSI108_DMA_SIZE		0x1000
2762306a36Sopenharmony_ci#define TSI108_ETH_SIZE		0x1000
2862306a36Sopenharmony_ci#define TSI108_I2C_SIZE		0x400
2962306a36Sopenharmony_ci#define TSI108_MPIC_SIZE	0x400
3062306a36Sopenharmony_ci#define TSI108_UART0_SIZE	0x200
3162306a36Sopenharmony_ci#define TSI108_GPIO_SIZE	0x200
3262306a36Sopenharmony_ci#define TSI108_UART1_SIZE	0x200
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci/* Offsets within Tsi108(A) CSR space for individual blocks */
3562306a36Sopenharmony_ci#define TSI108_HLP_OFFSET	0x0000
3662306a36Sopenharmony_ci#define TSI108_PCI_OFFSET	0x1000
3762306a36Sopenharmony_ci#define TSI108_CLK_OFFSET	0x2000
3862306a36Sopenharmony_ci#define TSI108_PB_OFFSET	0x3000
3962306a36Sopenharmony_ci#define TSI108_SD_OFFSET	0x4000
4062306a36Sopenharmony_ci#define TSI108_DMA_OFFSET	0x5000
4162306a36Sopenharmony_ci#define TSI108_ETH_OFFSET	0x6000
4262306a36Sopenharmony_ci#define TSI108_I2C_OFFSET	0x7000
4362306a36Sopenharmony_ci#define TSI108_MPIC_OFFSET	0x7400
4462306a36Sopenharmony_ci#define TSI108_UART0_OFFSET	0x7800
4562306a36Sopenharmony_ci#define TSI108_GPIO_OFFSET	0x7A00
4662306a36Sopenharmony_ci#define TSI108_UART1_OFFSET	0x7C00
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci/* Tsi108 registers used by common code components */
4962306a36Sopenharmony_ci#define TSI108_PCI_CSR		(0x004)
5062306a36Sopenharmony_ci#define TSI108_PCI_IRP_CFG_CTL	(0x180)
5162306a36Sopenharmony_ci#define TSI108_PCI_IRP_STAT	(0x184)
5262306a36Sopenharmony_ci#define TSI108_PCI_IRP_ENABLE	(0x188)
5362306a36Sopenharmony_ci#define TSI108_PCI_IRP_INTAD	(0x18C)
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci#define TSI108_PCI_IRP_STAT_P_INT	(0x00400000)
5662306a36Sopenharmony_ci#define TSI108_PCI_IRP_ENABLE_P_INT	(0x00400000)
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci#define TSI108_CG_PWRUP_STATUS	(0x234)
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci#define TSI108_PB_ISR		(0x00C)
6162306a36Sopenharmony_ci#define TSI108_PB_ERRCS		(0x404)
6262306a36Sopenharmony_ci#define TSI108_PB_AERR		(0x408)
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ci#define TSI108_PB_ERRCS_ES		(1 << 1)
6562306a36Sopenharmony_ci#define TSI108_PB_ISR_PBS_RD_ERR	(1 << 8)
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci#define TSI108_PCI_CFG_SIZE		(0x01000000)
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci/*
7062306a36Sopenharmony_ci * PHY Configuration Options
7162306a36Sopenharmony_ci *
7262306a36Sopenharmony_ci * Specify "bcm54xx" in the compatible property of your device tree phy
7362306a36Sopenharmony_ci * nodes if your board uses the Broadcom PHYs
7462306a36Sopenharmony_ci */
7562306a36Sopenharmony_ci#define TSI108_PHY_MV88E	0	/* Marvel 88Exxxx PHY */
7662306a36Sopenharmony_ci#define TSI108_PHY_BCM54XX	1	/* Broadcom BCM54xx PHY */
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci/* Global variables */
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ciextern u32 tsi108_pci_cfg_base;
8162306a36Sopenharmony_ci/* Exported functions */
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ciextern int tsi108_direct_write_config(struct pci_bus *bus, unsigned int devfn,
8462306a36Sopenharmony_ci				      int offset, int len, u32 val);
8562306a36Sopenharmony_ciextern int tsi108_direct_read_config(struct pci_bus *bus, unsigned int devfn,
8662306a36Sopenharmony_ci				     int offset, int len, u32 * val);
8762306a36Sopenharmony_ciextern void tsi108_clear_pci_error(u32 pci_cfg_base);
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ciextern phys_addr_t get_csrbase(void);
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_citypedef struct {
9262306a36Sopenharmony_ci	u32 regs;		/* hw registers base address */
9362306a36Sopenharmony_ci	u32 phyregs;		/* phy registers base address */
9462306a36Sopenharmony_ci	u16 phy;		/* phy address */
9562306a36Sopenharmony_ci	u16 irq_num;		/* irq number */
9662306a36Sopenharmony_ci	u8 mac_addr[6];		/* phy mac address */
9762306a36Sopenharmony_ci	u16 phy_type;	/* type of phy on board */
9862306a36Sopenharmony_ci} hw_info;
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ciextern u32 get_vir_csrbase(void);
10162306a36Sopenharmony_ciextern u32 tsi108_csr_vir_base;
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_cistatic inline u32 tsi108_read_reg(u32 reg_offset)
10462306a36Sopenharmony_ci{
10562306a36Sopenharmony_ci	return in_be32((volatile u32 *)(tsi108_csr_vir_base + reg_offset));
10662306a36Sopenharmony_ci}
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_cistatic inline void tsi108_write_reg(u32 reg_offset, u32 val)
10962306a36Sopenharmony_ci{
11062306a36Sopenharmony_ci	out_be32((volatile u32 *)(tsi108_csr_vir_base + reg_offset), val);
11162306a36Sopenharmony_ci}
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci#endif				/* __PPC_KERNEL_TSI108_H */
114