Zheng Bao | 98fcc09 | 2011-03-27 16:39:58 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2010 Advanced Micro Devices, Inc. |
Timothy Pearson | 44e4a4e | 2015-08-11 17:49:06 -0500 | [diff] [blame^] | 5 | * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering |
Zheng Bao | 98fcc09 | 2011-03-27 16:39:58 +0000 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Zheng Bao | 98fcc09 | 2011-03-27 16:39:58 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #ifndef __SR5650_CMN_H__ |
| 18 | #define __SR5650_CMN_H__ |
| 19 | |
efdesign98 | 00c8c4a | 2011-07-20 12:37:58 -0600 | [diff] [blame] | 20 | #include <arch/io.h> |
| 21 | |
Zheng Bao | 98fcc09 | 2011-03-27 16:39:58 +0000 | [diff] [blame] | 22 | #define NBMISC_INDEX 0x60 |
| 23 | #define NBHTIU_INDEX 0x94 /* Note: It is different with RS690, whose HTIU index is 0xA8 */ |
| 24 | #define NBMC_INDEX 0xE8 |
| 25 | #define NBPCIE_INDEX 0xE0 |
Timothy Pearson | 44e4a4e | 2015-08-11 17:49:06 -0500 | [diff] [blame^] | 26 | #define L2CFG_INDEX 0xF0 |
| 27 | #define L1CFG_INDEX 0xF8 |
efdesign98 | 00c8c4a | 2011-07-20 12:37:58 -0600 | [diff] [blame] | 28 | #define EXT_CONF_BASE_ADDRESS CONFIG_MMCONF_BASE_ADDRESS |
Zheng Bao | 98fcc09 | 2011-03-27 16:39:58 +0000 | [diff] [blame] | 29 | #define TEMP_MMIO_BASE_ADDRESS 0xC0000000 |
| 30 | |
efdesign98 | 00c8c4a | 2011-07-20 12:37:58 -0600 | [diff] [blame] | 31 | #define axindxc_reg(reg, mask, val) \ |
| 32 | alink_ax_indx(0, (reg), (mask), (val)) |
| 33 | |
| 34 | #define AB_INDX 0xCD8 |
| 35 | #define AB_DATA (AB_INDX+4) |
| 36 | |
Zheng Bao | 98fcc09 | 2011-03-27 16:39:58 +0000 | [diff] [blame] | 37 | static inline u32 nb_read_index(device_t dev, u32 index_reg, u32 index) |
| 38 | { |
| 39 | pci_write_config32(dev, index_reg, index); |
| 40 | return pci_read_config32(dev, index_reg + 0x4); |
| 41 | } |
| 42 | |
| 43 | static inline void nb_write_index(device_t dev, u32 index_reg, u32 index, u32 data) |
| 44 | { |
| 45 | pci_write_config32(dev, index_reg, index); |
| 46 | pci_write_config32(dev, index_reg + 0x4, data); |
| 47 | } |
| 48 | |
| 49 | static inline u32 nbmisc_read_index(device_t nb_dev, u32 index) |
| 50 | { |
| 51 | return nb_read_index((nb_dev), NBMISC_INDEX, (index)); |
| 52 | } |
| 53 | |
| 54 | static inline void nbmisc_write_index(device_t nb_dev, u32 index, u32 data) |
| 55 | { |
| 56 | nb_write_index((nb_dev), NBMISC_INDEX, ((index) | 0x80), (data)); |
| 57 | } |
| 58 | |
| 59 | static inline void set_nbmisc_enable_bits(device_t nb_dev, u32 reg_pos, u32 mask, |
| 60 | u32 val) |
| 61 | { |
| 62 | u32 reg_old, reg; |
| 63 | reg = reg_old = nbmisc_read_index(nb_dev, reg_pos); |
| 64 | reg &= ~mask; |
| 65 | reg |= val; |
| 66 | if (reg != reg_old) { |
| 67 | nbmisc_write_index(nb_dev, reg_pos, reg); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | static inline u32 htiu_read_index(device_t nb_dev, u32 index) |
| 72 | { |
| 73 | return nb_read_index((nb_dev), NBHTIU_INDEX, (index)); |
| 74 | } |
| 75 | |
| 76 | static inline void htiu_write_index(device_t nb_dev, u32 index, u32 data) |
| 77 | { |
| 78 | nb_write_index((nb_dev), NBHTIU_INDEX, ((index) | 0x100), (data)); |
| 79 | } |
| 80 | |
| 81 | static inline u32 nbmc_read_index(device_t nb_dev, u32 index) |
| 82 | { |
| 83 | return nb_read_index((nb_dev), NBMC_INDEX, (index)); |
| 84 | } |
| 85 | |
| 86 | static inline void nbmc_write_index(device_t nb_dev, u32 index, u32 data) |
| 87 | { |
| 88 | nb_write_index((nb_dev), NBMC_INDEX, ((index) | 1 << 9), (data)); |
| 89 | } |
| 90 | |
| 91 | static inline void set_htiu_enable_bits(device_t nb_dev, u32 reg_pos, u32 mask, |
| 92 | u32 val) |
| 93 | { |
| 94 | u32 reg_old, reg; |
| 95 | reg = reg_old = htiu_read_index(nb_dev, reg_pos); |
| 96 | reg &= ~mask; |
| 97 | reg |= val; |
| 98 | if (reg != reg_old) { |
| 99 | htiu_write_index(nb_dev, reg_pos, reg); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | static inline void set_nbcfg_enable_bits(device_t nb_dev, u32 reg_pos, u32 mask, |
| 104 | u32 val) |
| 105 | { |
| 106 | u32 reg_old, reg; |
| 107 | reg = reg_old = pci_read_config32(nb_dev, reg_pos); |
| 108 | reg &= ~mask; |
| 109 | reg |= val; |
| 110 | if (reg != reg_old) { |
| 111 | pci_write_config32(nb_dev, reg_pos, reg); |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | static inline void set_nbcfg_enable_bits_8(device_t nb_dev, u32 reg_pos, u8 mask, |
| 116 | u8 val) |
| 117 | { |
| 118 | u8 reg_old, reg; |
| 119 | reg = reg_old = pci_read_config8(nb_dev, reg_pos); |
| 120 | reg &= ~mask; |
| 121 | reg |= val; |
| 122 | if (reg != reg_old) { |
| 123 | pci_write_config8(nb_dev, reg_pos, reg); |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | static inline void set_nbmc_enable_bits(device_t nb_dev, u32 reg_pos, u32 mask, |
| 128 | u32 val) |
| 129 | { |
| 130 | u32 reg_old, reg; |
| 131 | reg = reg_old = nbmc_read_index(nb_dev, reg_pos); |
| 132 | reg &= ~mask; |
| 133 | reg |= val; |
| 134 | if (reg != reg_old) { |
| 135 | nbmc_write_index(nb_dev, reg_pos, reg); |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | static inline void set_pcie_enable_bits(device_t dev, u32 reg_pos, u32 mask, u32 val) |
| 140 | { |
| 141 | u32 reg_old, reg; |
| 142 | reg = reg_old = nb_read_index(dev, NBPCIE_INDEX, reg_pos); |
| 143 | reg &= ~mask; |
| 144 | reg |= val; |
| 145 | if (reg != reg_old) { |
| 146 | nb_write_index(dev, NBPCIE_INDEX, reg_pos, reg); |
| 147 | } |
| 148 | } |
| 149 | #endif /* __SR5650_CMN_H__ */ |