18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * common routine and memory layout for Tundra TSI108(Grendel) host bridge 48c2ecf20Sopenharmony_ci * memory controller. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Author: Jacob Pan (jacob.pan@freescale.com) 78c2ecf20Sopenharmony_ci * Alex Bounine (alexandreb@tundra.com) 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * Copyright 2004-2006 Freescale Semiconductor, Inc. 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#ifndef __PPC_KERNEL_TSI108_H 138c2ecf20Sopenharmony_ci#define __PPC_KERNEL_TSI108_H 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include <asm/pci-bridge.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci/* Size of entire register space */ 188c2ecf20Sopenharmony_ci#define TSI108_REG_SIZE (0x10000) 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* Sizes of register spaces for individual blocks */ 218c2ecf20Sopenharmony_ci#define TSI108_HLP_SIZE 0x1000 228c2ecf20Sopenharmony_ci#define TSI108_PCI_SIZE 0x1000 238c2ecf20Sopenharmony_ci#define TSI108_CLK_SIZE 0x1000 248c2ecf20Sopenharmony_ci#define TSI108_PB_SIZE 0x1000 258c2ecf20Sopenharmony_ci#define TSI108_SD_SIZE 0x1000 268c2ecf20Sopenharmony_ci#define TSI108_DMA_SIZE 0x1000 278c2ecf20Sopenharmony_ci#define TSI108_ETH_SIZE 0x1000 288c2ecf20Sopenharmony_ci#define TSI108_I2C_SIZE 0x400 298c2ecf20Sopenharmony_ci#define TSI108_MPIC_SIZE 0x400 308c2ecf20Sopenharmony_ci#define TSI108_UART0_SIZE 0x200 318c2ecf20Sopenharmony_ci#define TSI108_GPIO_SIZE 0x200 328c2ecf20Sopenharmony_ci#define TSI108_UART1_SIZE 0x200 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* Offsets within Tsi108(A) CSR space for individual blocks */ 358c2ecf20Sopenharmony_ci#define TSI108_HLP_OFFSET 0x0000 368c2ecf20Sopenharmony_ci#define TSI108_PCI_OFFSET 0x1000 378c2ecf20Sopenharmony_ci#define TSI108_CLK_OFFSET 0x2000 388c2ecf20Sopenharmony_ci#define TSI108_PB_OFFSET 0x3000 398c2ecf20Sopenharmony_ci#define TSI108_SD_OFFSET 0x4000 408c2ecf20Sopenharmony_ci#define TSI108_DMA_OFFSET 0x5000 418c2ecf20Sopenharmony_ci#define TSI108_ETH_OFFSET 0x6000 428c2ecf20Sopenharmony_ci#define TSI108_I2C_OFFSET 0x7000 438c2ecf20Sopenharmony_ci#define TSI108_MPIC_OFFSET 0x7400 448c2ecf20Sopenharmony_ci#define TSI108_UART0_OFFSET 0x7800 458c2ecf20Sopenharmony_ci#define TSI108_GPIO_OFFSET 0x7A00 468c2ecf20Sopenharmony_ci#define TSI108_UART1_OFFSET 0x7C00 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci/* Tsi108 registers used by common code components */ 498c2ecf20Sopenharmony_ci#define TSI108_PCI_CSR (0x004) 508c2ecf20Sopenharmony_ci#define TSI108_PCI_IRP_CFG_CTL (0x180) 518c2ecf20Sopenharmony_ci#define TSI108_PCI_IRP_STAT (0x184) 528c2ecf20Sopenharmony_ci#define TSI108_PCI_IRP_ENABLE (0x188) 538c2ecf20Sopenharmony_ci#define TSI108_PCI_IRP_INTAD (0x18C) 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci#define TSI108_PCI_IRP_STAT_P_INT (0x00400000) 568c2ecf20Sopenharmony_ci#define TSI108_PCI_IRP_ENABLE_P_INT (0x00400000) 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci#define TSI108_CG_PWRUP_STATUS (0x234) 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci#define TSI108_PB_ISR (0x00C) 618c2ecf20Sopenharmony_ci#define TSI108_PB_ERRCS (0x404) 628c2ecf20Sopenharmony_ci#define TSI108_PB_AERR (0x408) 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#define TSI108_PB_ERRCS_ES (1 << 1) 658c2ecf20Sopenharmony_ci#define TSI108_PB_ISR_PBS_RD_ERR (1 << 8) 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci#define TSI108_PCI_CFG_SIZE (0x01000000) 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci/* 708c2ecf20Sopenharmony_ci * PHY Configuration Options 718c2ecf20Sopenharmony_ci * 728c2ecf20Sopenharmony_ci * Specify "bcm54xx" in the compatible property of your device tree phy 738c2ecf20Sopenharmony_ci * nodes if your board uses the Broadcom PHYs 748c2ecf20Sopenharmony_ci */ 758c2ecf20Sopenharmony_ci#define TSI108_PHY_MV88E 0 /* Marvel 88Exxxx PHY */ 768c2ecf20Sopenharmony_ci#define TSI108_PHY_BCM54XX 1 /* Broadcom BCM54xx PHY */ 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci/* Global variables */ 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ciextern u32 tsi108_pci_cfg_base; 818c2ecf20Sopenharmony_ci/* Exported functions */ 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ciextern int tsi108_direct_write_config(struct pci_bus *bus, unsigned int devfn, 848c2ecf20Sopenharmony_ci int offset, int len, u32 val); 858c2ecf20Sopenharmony_ciextern int tsi108_direct_read_config(struct pci_bus *bus, unsigned int devfn, 868c2ecf20Sopenharmony_ci int offset, int len, u32 * val); 878c2ecf20Sopenharmony_ciextern void tsi108_clear_pci_error(u32 pci_cfg_base); 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ciextern phys_addr_t get_csrbase(void); 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_citypedef struct { 928c2ecf20Sopenharmony_ci u32 regs; /* hw registers base address */ 938c2ecf20Sopenharmony_ci u32 phyregs; /* phy registers base address */ 948c2ecf20Sopenharmony_ci u16 phy; /* phy address */ 958c2ecf20Sopenharmony_ci u16 irq_num; /* irq number */ 968c2ecf20Sopenharmony_ci u8 mac_addr[6]; /* phy mac address */ 978c2ecf20Sopenharmony_ci u16 phy_type; /* type of phy on board */ 988c2ecf20Sopenharmony_ci} hw_info; 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ciextern u32 get_vir_csrbase(void); 1018c2ecf20Sopenharmony_ciextern u32 tsi108_csr_vir_base; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_cistatic inline u32 tsi108_read_reg(u32 reg_offset) 1048c2ecf20Sopenharmony_ci{ 1058c2ecf20Sopenharmony_ci return in_be32((volatile u32 *)(tsi108_csr_vir_base + reg_offset)); 1068c2ecf20Sopenharmony_ci} 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_cistatic inline void tsi108_write_reg(u32 reg_offset, u32 val) 1098c2ecf20Sopenharmony_ci{ 1108c2ecf20Sopenharmony_ci out_be32((volatile u32 *)(tsi108_csr_vir_base + reg_offset), val); 1118c2ecf20Sopenharmony_ci} 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci#endif /* __PPC_KERNEL_TSI108_H */ 114