Bin Meng | 00ffb4d | 2015-02-02 22:35:23 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #ifndef _QUARK_H_ |
| 8 | #define _QUARK_H_ |
| 9 | |
| 10 | /* Message Bus Ports */ |
| 11 | #define MSG_PORT_MEM_ARBITER 0x00 |
| 12 | #define MSG_PORT_HOST_BRIDGE 0x03 |
| 13 | #define MSG_PORT_RMU 0x04 |
| 14 | #define MSG_PORT_MEM_MGR 0x05 |
Bin Meng | f376372 | 2015-09-03 05:37:27 -0700 | [diff] [blame] | 15 | #define MSG_PORT_USB_AFE 0x14 |
Bin Meng | 4756cac | 2015-09-03 05:37:25 -0700 | [diff] [blame] | 16 | #define MSG_PORT_PCIE_AFE 0x16 |
Bin Meng | 00ffb4d | 2015-02-02 22:35:23 +0800 | [diff] [blame] | 17 | #define MSG_PORT_SOC_UNIT 0x31 |
| 18 | |
Bin Meng | 3446986 | 2015-02-04 16:26:09 +0800 | [diff] [blame] | 19 | /* Port 0x00: Memory Arbiter Message Port Registers */ |
| 20 | |
| 21 | /* Enhanced Configuration Space */ |
| 22 | #define AEC_CTRL 0x00 |
| 23 | |
| 24 | /* Port 0x03: Host Bridge Message Port Registers */ |
| 25 | |
Bin Meng | 6db1448 | 2015-04-27 14:16:02 +0800 | [diff] [blame] | 26 | /* Host Miscellaneous Controls 2 */ |
| 27 | #define HMISC2 0x03 |
| 28 | |
| 29 | #define HMISC2_SEGE 0x00000002 |
| 30 | #define HMISC2_SEGF 0x00000004 |
| 31 | #define HMISC2_SEGAB 0x00000010 |
| 32 | |
Bin Meng | 00ffb4d | 2015-02-02 22:35:23 +0800 | [diff] [blame] | 33 | /* Host Memory I/O Boundary */ |
| 34 | #define HM_BOUND 0x08 |
| 35 | |
Bin Meng | 3446986 | 2015-02-04 16:26:09 +0800 | [diff] [blame] | 36 | /* Extended Configuration Space */ |
| 37 | #define HEC_REG 0x09 |
| 38 | |
| 39 | /* Port 0x04: Remote Management Unit Message Port Registers */ |
| 40 | |
| 41 | /* ACPI PBLK Base Address Register */ |
| 42 | #define PBLK_BA 0x70 |
| 43 | |
| 44 | /* SPI DMA Base Address Register */ |
| 45 | #define SPI_DMA_BA 0x7a |
| 46 | |
| 47 | /* Port 0x05: Memory Manager Message Port Registers */ |
| 48 | |
Bin Meng | 00ffb4d | 2015-02-02 22:35:23 +0800 | [diff] [blame] | 49 | /* eSRAM Block Page Control */ |
| 50 | #define ESRAM_BLK_CTRL 0x82 |
| 51 | #define ESRAM_BLOCK_MODE 0x10000000 |
| 52 | |
Bin Meng | f376372 | 2015-09-03 05:37:27 -0700 | [diff] [blame] | 53 | /* Port 0x14: USB2 AFE Unit Port Registers */ |
| 54 | |
| 55 | #define USB2_GLOBAL_PORT 0x4001 |
| 56 | #define USB2_PLL1 0x7f02 |
| 57 | #define USB2_PLL2 0x7f03 |
| 58 | #define USB2_COMPBG 0x7f04 |
| 59 | |
Bin Meng | 4756cac | 2015-09-03 05:37:25 -0700 | [diff] [blame] | 60 | /* Port 0x16: PCIe AFE Unit Port Registers */ |
| 61 | |
| 62 | #define PCIE_RXPICTRL0_L0 0x2080 |
| 63 | #define PCIE_RXPICTRL0_L1 0x2180 |
| 64 | |
| 65 | /* Port 0x31: SoC Unit Port Registers */ |
| 66 | |
| 67 | /* PCIe Controller Config */ |
| 68 | #define PCIE_CFG 0x36 |
| 69 | #define PCIE_CTLR_PRI_RST 0x00010000 |
| 70 | #define PCIE_PHY_SB_RST 0x00020000 |
| 71 | #define PCIE_CTLR_SB_RST 0x00040000 |
| 72 | #define PCIE_PHY_LANE_RST 0x00090000 |
| 73 | #define PCIE_CTLR_MAIN_RST 0x00100000 |
| 74 | |
Bin Meng | 00ffb4d | 2015-02-02 22:35:23 +0800 | [diff] [blame] | 75 | /* DRAM */ |
| 76 | #define DRAM_BASE 0x00000000 |
| 77 | #define DRAM_MAX_SIZE 0x80000000 |
| 78 | |
| 79 | /* eSRAM */ |
| 80 | #define ESRAM_SIZE 0x80000 |
| 81 | |
| 82 | /* Memory BAR Enable */ |
| 83 | #define MEM_BAR_EN 0x00000001 |
| 84 | |
| 85 | /* I/O BAR Enable */ |
| 86 | #define IO_BAR_EN 0x80000000 |
| 87 | |
| 88 | /* 64KiB of RMU binary in flash */ |
| 89 | #define RMU_BINARY_SIZE 0x10000 |
| 90 | |
Bin Meng | 4e19d7c | 2015-09-11 03:24:37 -0700 | [diff] [blame^] | 91 | /* PCIe Root Port Configuration Registers */ |
| 92 | |
| 93 | #define PCIE_RP_CCFG 0xd0 |
| 94 | #define CCFG_UPRS (1 << 14) |
| 95 | #define CCFG_UNRS (1 << 15) |
| 96 | #define CCFG_UNSD (1 << 23) |
| 97 | #define CCFG_UPSD (1 << 24) |
| 98 | |
| 99 | #define PCIE_RP_MPC2 0xd4 |
| 100 | #define MPC2_IPF (1 << 11) |
| 101 | |
| 102 | #define PCIE_RP_MBC 0xf4 |
| 103 | #define MBC_SBIC (3 << 16) |
| 104 | |
Bin Meng | 3446986 | 2015-02-04 16:26:09 +0800 | [diff] [blame] | 105 | /* Legacy Bridge PCI Configuration Registers */ |
| 106 | #define LB_GBA 0x44 |
| 107 | #define LB_PM1BLK 0x48 |
| 108 | #define LB_GPE0BLK 0x4c |
| 109 | #define LB_ACTL 0x58 |
| 110 | #define LB_PABCDRC 0x60 |
| 111 | #define LB_PEFGHRC 0x64 |
| 112 | #define LB_WDTBA 0x84 |
| 113 | #define LB_BCE 0xd4 |
| 114 | #define LB_BC 0xd8 |
| 115 | #define LB_RCBA 0xf0 |
| 116 | |
Bin Meng | 4e19d7c | 2015-09-11 03:24:37 -0700 | [diff] [blame^] | 117 | /* USB EHCI memory-mapped registers */ |
| 118 | #define EHCI_INSNREG01 0x94 |
| 119 | |
| 120 | /* USB device memory-mapped registers */ |
| 121 | #define USBD_INT_MASK 0x410 |
| 122 | #define USBD_EP_INT_STS 0x414 |
| 123 | #define USBD_EP_INT_MASK 0x418 |
| 124 | |
Bin Meng | ef9e9f9 | 2015-05-25 22:35:06 +0800 | [diff] [blame] | 125 | #ifndef __ASSEMBLY__ |
| 126 | |
| 127 | /* Root Complex Register Block */ |
| 128 | struct quark_rcba { |
| 129 | u32 rctl; |
| 130 | u32 esd; |
| 131 | u32 rsvd1[3150]; |
| 132 | u16 rmu_ir; |
| 133 | u16 d23_ir; |
| 134 | u16 core_ir; |
| 135 | u16 d20d21_ir; |
| 136 | }; |
| 137 | |
Bin Meng | 7ba52a0 | 2015-09-03 05:37:23 -0700 | [diff] [blame] | 138 | #include <asm/io.h> |
| 139 | #include <asm/pci.h> |
| 140 | |
| 141 | /** |
| 142 | * qrk_pci_read_config_dword() - Read a configuration value |
| 143 | * |
| 144 | * @dev: PCI device address: bus, device and function |
| 145 | * @offset: Dword offset within the device's configuration space |
| 146 | * @valuep: Place to put the returned value |
| 147 | * |
| 148 | * Note: This routine is inlined to provide better performance on Quark |
| 149 | */ |
| 150 | static inline void qrk_pci_read_config_dword(pci_dev_t dev, int offset, |
| 151 | u32 *valuep) |
| 152 | { |
| 153 | outl(dev | offset | PCI_CFG_EN, PCI_REG_ADDR); |
| 154 | *valuep = inl(PCI_REG_DATA); |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * qrk_pci_write_config_dword() - Write a PCI configuration value |
| 159 | * |
| 160 | * @dev: PCI device address: bus, device and function |
| 161 | * @offset: Dword offset within the device's configuration space |
| 162 | * @value: Value to write |
| 163 | * |
| 164 | * Note: This routine is inlined to provide better performance on Quark |
| 165 | */ |
| 166 | static inline void qrk_pci_write_config_dword(pci_dev_t dev, int offset, |
| 167 | u32 value) |
| 168 | { |
| 169 | outl(dev | offset | PCI_CFG_EN, PCI_REG_ADDR); |
| 170 | outl(value, PCI_REG_DATA); |
| 171 | } |
| 172 | |
Bin Meng | 4756cac | 2015-09-03 05:37:25 -0700 | [diff] [blame] | 173 | /** |
| 174 | * board_assert_perst() - Assert the PERST# pin |
| 175 | * |
| 176 | * The CPU interface to the PERST# signal on Quark is platform dependent. |
| 177 | * Board-specific codes need supply this routine to assert PCIe slot reset. |
| 178 | * |
| 179 | * The tricky part in this routine is that any APIs that may trigger PCI |
| 180 | * enumeration process are strictly forbidden, as any access to PCIe root |
| 181 | * port's configuration registers will cause system hang while it is held |
| 182 | * in reset. |
| 183 | */ |
| 184 | void board_assert_perst(void); |
| 185 | |
| 186 | /** |
| 187 | * board_deassert_perst() - De-assert the PERST# pin |
| 188 | * |
| 189 | * The CPU interface to the PERST# signal on Quark is platform dependent. |
| 190 | * Board-specific codes need supply this routine to de-assert PCIe slot reset. |
| 191 | * |
| 192 | * The tricky part in this routine is that any APIs that may trigger PCI |
| 193 | * enumeration process are strictly forbidden, as any access to PCIe root |
| 194 | * port's configuration registers will cause system hang while it is held |
| 195 | * in reset. |
| 196 | */ |
| 197 | void board_deassert_perst(void); |
| 198 | |
Bin Meng | ef9e9f9 | 2015-05-25 22:35:06 +0800 | [diff] [blame] | 199 | #endif /* __ASSEMBLY__ */ |
| 200 | |
Bin Meng | 00ffb4d | 2015-02-02 22:35:23 +0800 | [diff] [blame] | 201 | #endif /* _QUARK_H_ */ |