xref: /openbmc/linux/arch/powerpc/include/asm/tsi108.h (revision 2874c5fd)
12874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2b8b572e1SStephen Rothwell /*
3b8b572e1SStephen Rothwell  * common routine and memory layout for Tundra TSI108(Grendel) host bridge
4b8b572e1SStephen Rothwell  * memory controller.
5b8b572e1SStephen Rothwell  *
6b8b572e1SStephen Rothwell  * Author: Jacob Pan (jacob.pan@freescale.com)
7b8b572e1SStephen Rothwell  *	   Alex Bounine (alexandreb@tundra.com)
8b8b572e1SStephen Rothwell  *
9b8b572e1SStephen Rothwell  * Copyright 2004-2006 Freescale Semiconductor, Inc.
10b8b572e1SStephen Rothwell  */
11b8b572e1SStephen Rothwell 
12b8b572e1SStephen Rothwell #ifndef __PPC_KERNEL_TSI108_H
13b8b572e1SStephen Rothwell #define __PPC_KERNEL_TSI108_H
14b8b572e1SStephen Rothwell 
15b8b572e1SStephen Rothwell #include <asm/pci-bridge.h>
16b8b572e1SStephen Rothwell 
17b8b572e1SStephen Rothwell /* Size of entire register space */
18b8b572e1SStephen Rothwell #define TSI108_REG_SIZE		(0x10000)
19b8b572e1SStephen Rothwell 
20b8b572e1SStephen Rothwell /* Sizes of register spaces for individual blocks */
21b8b572e1SStephen Rothwell #define TSI108_HLP_SIZE		0x1000
22b8b572e1SStephen Rothwell #define TSI108_PCI_SIZE		0x1000
23b8b572e1SStephen Rothwell #define TSI108_CLK_SIZE		0x1000
24b8b572e1SStephen Rothwell #define TSI108_PB_SIZE		0x1000
25b8b572e1SStephen Rothwell #define TSI108_SD_SIZE		0x1000
26b8b572e1SStephen Rothwell #define TSI108_DMA_SIZE		0x1000
27b8b572e1SStephen Rothwell #define TSI108_ETH_SIZE		0x1000
28b8b572e1SStephen Rothwell #define TSI108_I2C_SIZE		0x400
29b8b572e1SStephen Rothwell #define TSI108_MPIC_SIZE	0x400
30b8b572e1SStephen Rothwell #define TSI108_UART0_SIZE	0x200
31b8b572e1SStephen Rothwell #define TSI108_GPIO_SIZE	0x200
32b8b572e1SStephen Rothwell #define TSI108_UART1_SIZE	0x200
33b8b572e1SStephen Rothwell 
34b8b572e1SStephen Rothwell /* Offsets within Tsi108(A) CSR space for individual blocks */
35b8b572e1SStephen Rothwell #define TSI108_HLP_OFFSET	0x0000
36b8b572e1SStephen Rothwell #define TSI108_PCI_OFFSET	0x1000
37b8b572e1SStephen Rothwell #define TSI108_CLK_OFFSET	0x2000
38b8b572e1SStephen Rothwell #define TSI108_PB_OFFSET	0x3000
39b8b572e1SStephen Rothwell #define TSI108_SD_OFFSET	0x4000
40b8b572e1SStephen Rothwell #define TSI108_DMA_OFFSET	0x5000
41b8b572e1SStephen Rothwell #define TSI108_ETH_OFFSET	0x6000
42b8b572e1SStephen Rothwell #define TSI108_I2C_OFFSET	0x7000
43b8b572e1SStephen Rothwell #define TSI108_MPIC_OFFSET	0x7400
44b8b572e1SStephen Rothwell #define TSI108_UART0_OFFSET	0x7800
45b8b572e1SStephen Rothwell #define TSI108_GPIO_OFFSET	0x7A00
46b8b572e1SStephen Rothwell #define TSI108_UART1_OFFSET	0x7C00
47b8b572e1SStephen Rothwell 
48b8b572e1SStephen Rothwell /* Tsi108 registers used by common code components */
49b8b572e1SStephen Rothwell #define TSI108_PCI_CSR		(0x004)
50b8b572e1SStephen Rothwell #define TSI108_PCI_IRP_CFG_CTL	(0x180)
51b8b572e1SStephen Rothwell #define TSI108_PCI_IRP_STAT	(0x184)
52b8b572e1SStephen Rothwell #define TSI108_PCI_IRP_ENABLE	(0x188)
53b8b572e1SStephen Rothwell #define TSI108_PCI_IRP_INTAD	(0x18C)
54b8b572e1SStephen Rothwell 
55b8b572e1SStephen Rothwell #define TSI108_PCI_IRP_STAT_P_INT	(0x00400000)
56b8b572e1SStephen Rothwell #define TSI108_PCI_IRP_ENABLE_P_INT	(0x00400000)
57b8b572e1SStephen Rothwell 
58b8b572e1SStephen Rothwell #define TSI108_CG_PWRUP_STATUS	(0x234)
59b8b572e1SStephen Rothwell 
60b8b572e1SStephen Rothwell #define TSI108_PB_ISR		(0x00C)
61b8b572e1SStephen Rothwell #define TSI108_PB_ERRCS		(0x404)
62b8b572e1SStephen Rothwell #define TSI108_PB_AERR		(0x408)
63b8b572e1SStephen Rothwell 
64b8b572e1SStephen Rothwell #define TSI108_PB_ERRCS_ES		(1 << 1)
65b8b572e1SStephen Rothwell #define TSI108_PB_ISR_PBS_RD_ERR	(1 << 8)
66b8b572e1SStephen Rothwell 
67b8b572e1SStephen Rothwell #define TSI108_PCI_CFG_SIZE		(0x01000000)
68b8b572e1SStephen Rothwell 
69b8b572e1SStephen Rothwell /*
70b8b572e1SStephen Rothwell  * PHY Configuration Options
71b8b572e1SStephen Rothwell  *
72b8b572e1SStephen Rothwell  * Specify "bcm54xx" in the compatible property of your device tree phy
73b8b572e1SStephen Rothwell  * nodes if your board uses the Broadcom PHYs
74b8b572e1SStephen Rothwell  */
75b8b572e1SStephen Rothwell #define TSI108_PHY_MV88E	0	/* Marvel 88Exxxx PHY */
76027dfac6SMichael Ellerman #define TSI108_PHY_BCM54XX	1	/* Broadcom BCM54xx PHY */
77b8b572e1SStephen Rothwell 
78b8b572e1SStephen Rothwell /* Global variables */
79b8b572e1SStephen Rothwell 
80b8b572e1SStephen Rothwell extern u32 tsi108_pci_cfg_base;
81b8b572e1SStephen Rothwell /* Exported functions */
82b8b572e1SStephen Rothwell 
83b8b572e1SStephen Rothwell extern int tsi108_direct_write_config(struct pci_bus *bus, unsigned int devfn,
84b8b572e1SStephen Rothwell 				      int offset, int len, u32 val);
85b8b572e1SStephen Rothwell extern int tsi108_direct_read_config(struct pci_bus *bus, unsigned int devfn,
86b8b572e1SStephen Rothwell 				     int offset, int len, u32 * val);
87b8b572e1SStephen Rothwell extern void tsi108_clear_pci_error(u32 pci_cfg_base);
88b8b572e1SStephen Rothwell 
89b8b572e1SStephen Rothwell extern phys_addr_t get_csrbase(void);
90b8b572e1SStephen Rothwell 
91b8b572e1SStephen Rothwell typedef struct {
92b8b572e1SStephen Rothwell 	u32 regs;		/* hw registers base address */
93b8b572e1SStephen Rothwell 	u32 phyregs;		/* phy registers base address */
94b8b572e1SStephen Rothwell 	u16 phy;		/* phy address */
95b8b572e1SStephen Rothwell 	u16 irq_num;		/* irq number */
96b8b572e1SStephen Rothwell 	u8 mac_addr[6];		/* phy mac address */
97b8b572e1SStephen Rothwell 	u16 phy_type;	/* type of phy on board */
98b8b572e1SStephen Rothwell } hw_info;
99b8b572e1SStephen Rothwell 
100b8b572e1SStephen Rothwell extern u32 get_vir_csrbase(void);
101b8b572e1SStephen Rothwell extern u32 tsi108_csr_vir_base;
102b8b572e1SStephen Rothwell 
tsi108_read_reg(u32 reg_offset)103b8b572e1SStephen Rothwell static inline u32 tsi108_read_reg(u32 reg_offset)
104b8b572e1SStephen Rothwell {
105b8b572e1SStephen Rothwell 	return in_be32((volatile u32 *)(tsi108_csr_vir_base + reg_offset));
106b8b572e1SStephen Rothwell }
107b8b572e1SStephen Rothwell 
tsi108_write_reg(u32 reg_offset,u32 val)108b8b572e1SStephen Rothwell static inline void tsi108_write_reg(u32 reg_offset, u32 val)
109b8b572e1SStephen Rothwell {
110b8b572e1SStephen Rothwell 	out_be32((volatile u32 *)(tsi108_csr_vir_base + reg_offset), val);
111b8b572e1SStephen Rothwell }
112b8b572e1SStephen Rothwell 
113b8b572e1SStephen Rothwell #endif				/* __PPC_KERNEL_TSI108_H */
114