Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Stefan Roese | 6a90595 | 2015-04-20 09:31:27 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) Marvell International Ltd. and its affiliates |
Stefan Roese | 6a90595 | 2015-04-20 09:31:27 +0200 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef _CTRL_PEX_H |
| 7 | #define _CTRL_PEX_H |
| 8 | |
| 9 | #include "high_speed_env_spec.h" |
| 10 | |
| 11 | /* Sample at Reset */ |
| 12 | #define MPP_SAMPLE_AT_RESET(id) (0xe4200 + (id * 4)) |
| 13 | |
| 14 | /* PCI Express Control and Status Registers */ |
| 15 | #define MAX_PEX_BUSSES 256 |
| 16 | |
| 17 | #define MISC_REGS_OFFSET 0x18200 |
| 18 | #define MV_MISC_REGS_BASE MISC_REGS_OFFSET |
| 19 | #define SOC_CTRL_REG (MV_MISC_REGS_BASE + 0x4) |
| 20 | |
Stefan Roese | 61cee0a | 2015-06-08 17:01:26 +0200 | [diff] [blame] | 21 | #define PEX_IF_REGS_OFFSET(if) ((if) > 0 ? \ |
| 22 | (0x40000 + ((if) - 1) * 0x4000) : \ |
| 23 | 0x80000) |
| 24 | #define PEX_IF_REGS_BASE(if) (PEX_IF_REGS_OFFSET(if)) |
Stefan Roese | 6a90595 | 2015-04-20 09:31:27 +0200 | [diff] [blame] | 25 | #define PEX_CAPABILITIES_REG(if) ((PEX_IF_REGS_BASE(if)) + 0x60) |
| 26 | #define PEX_LINK_CTRL_STATUS2_REG(if) ((PEX_IF_REGS_BASE(if)) + 0x90) |
| 27 | #define PEX_CTRL_REG(if) ((PEX_IF_REGS_BASE(if)) + 0x1a00) |
| 28 | #define PEX_STATUS_REG(if) ((PEX_IF_REGS_BASE(if)) + 0x1a04) |
| 29 | #define PEX_DBG_STATUS_REG(if) ((PEX_IF_REGS_BASE(if)) + 0x1a64) |
| 30 | #define PEX_LINK_CAPABILITY_REG 0x6c |
| 31 | #define PEX_LINK_CTRL_STAT_REG 0x70 |
| 32 | #define PXSR_PEX_DEV_NUM_OFFS 16 /* Device Number Indication */ |
| 33 | #define PXSR_PEX_DEV_NUM_MASK (0x1f << PXSR_PEX_DEV_NUM_OFFS) |
| 34 | #define PXSR_PEX_BUS_NUM_OFFS 8 /* Bus Number Indication */ |
| 35 | #define PXSR_PEX_BUS_NUM_MASK (0xff << PXSR_PEX_BUS_NUM_OFFS) |
| 36 | |
| 37 | /* PEX_CAPABILITIES_REG fields */ |
| 38 | #define PCIE0_ENABLE_OFFS 0 |
| 39 | #define PCIE0_ENABLE_MASK (0x1 << PCIE0_ENABLE_OFFS) |
| 40 | #define PCIE1_ENABLE_OFFS 1 |
| 41 | #define PCIE1_ENABLE_MASK (0x1 << PCIE1_ENABLE_OFFS) |
| 42 | #define PCIE2_ENABLE_OFFS 2 |
| 43 | #define PCIE2_ENABLE_MASK (0x1 << PCIE2_ENABLE_OFFS) |
| 44 | #define PCIE3_ENABLE_OFFS 3 |
| 45 | #define PCIE4_ENABLE_MASK (0x1 << PCIE3_ENABLE_OFFS) |
| 46 | |
| 47 | /* Controller revision info */ |
| 48 | #define PEX_DEVICE_AND_VENDOR_ID 0x000 |
| 49 | |
| 50 | /* PCI Express Configuration Address Register */ |
| 51 | #define PXCAR_REG_NUM_OFFS 2 |
| 52 | #define PXCAR_REG_NUM_MAX 0x3f |
| 53 | #define PXCAR_REG_NUM_MASK (PXCAR_REG_NUM_MAX << \ |
| 54 | PXCAR_REG_NUM_OFFS) |
| 55 | #define PXCAR_FUNC_NUM_OFFS 8 |
| 56 | #define PXCAR_FUNC_NUM_MAX 0x7 |
| 57 | #define PXCAR_FUNC_NUM_MASK (PXCAR_FUNC_NUM_MAX << \ |
| 58 | PXCAR_FUNC_NUM_OFFS) |
| 59 | #define PXCAR_DEVICE_NUM_OFFS 11 |
| 60 | #define PXCAR_DEVICE_NUM_MAX 0x1f |
| 61 | #define PXCAR_DEVICE_NUM_MASK (PXCAR_DEVICE_NUM_MAX << \ |
| 62 | PXCAR_DEVICE_NUM_OFFS) |
| 63 | #define PXCAR_BUS_NUM_OFFS 16 |
| 64 | #define PXCAR_BUS_NUM_MAX 0xff |
| 65 | #define PXCAR_BUS_NUM_MASK (PXCAR_BUS_NUM_MAX << \ |
| 66 | PXCAR_BUS_NUM_OFFS) |
| 67 | #define PXCAR_EXT_REG_NUM_OFFS 24 |
| 68 | #define PXCAR_EXT_REG_NUM_MAX 0xf |
| 69 | |
| 70 | #define PEX_CFG_ADDR_REG(if) ((PEX_IF_REGS_BASE(if)) + 0x18f8) |
| 71 | #define PEX_CFG_DATA_REG(if) ((PEX_IF_REGS_BASE(if)) + 0x18fc) |
| 72 | |
| 73 | #define PXCAR_REAL_EXT_REG_NUM_OFFS 8 |
| 74 | #define PXCAR_REAL_EXT_REG_NUM_MASK (0xf << PXCAR_REAL_EXT_REG_NUM_OFFS) |
| 75 | |
| 76 | #define PXCAR_CONFIG_EN BIT(31) |
| 77 | #define PEX_STATUS_AND_COMMAND 0x004 |
| 78 | #define PXSAC_MABORT BIT(29) /* Recieved Master Abort */ |
| 79 | |
Kevin Smith | 6406d43 | 2015-10-23 17:53:19 +0000 | [diff] [blame] | 80 | int hws_pex_config(const struct serdes_map *serdes_map, u8 count); |
Stefan Roese | 6a90595 | 2015-04-20 09:31:27 +0200 | [diff] [blame] | 81 | int pex_local_bus_num_set(u32 pex_if, u32 bus_num); |
| 82 | int pex_local_dev_num_set(u32 pex_if, u32 dev_num); |
| 83 | u32 pex_config_read(u32 pex_if, u32 bus, u32 dev, u32 func, u32 reg_off); |
| 84 | |
Mario Six | a3d1834 | 2017-01-11 16:00:47 +0100 | [diff] [blame] | 85 | void board_pex_config(void); |
| 86 | |
Stefan Roese | 6a90595 | 2015-04-20 09:31:27 +0200 | [diff] [blame] | 87 | #endif |