Angel Pons | 1c505f8 | 2020-11-11 20:55:35 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <commonlib/helpers.h> |
| 4 | #include <console/console.h> |
| 5 | #include <delay.h> |
| 6 | #include <types.h> |
| 7 | |
| 8 | #include "raminit_native.h" |
| 9 | #include "raminit_common.h" |
| 10 | #include "raminit_tables.h" |
| 11 | #include "sandybridge.h" |
| 12 | |
| 13 | /* FIXME: no support for 3-channel chipsets */ |
| 14 | |
| 15 | /* Number of programmed IOSAV subsequences. */ |
| 16 | static unsigned int ssq_count = 0; |
| 17 | |
Angel Pons | 8f0757e | 2020-11-11 23:03:36 +0100 | [diff] [blame^] | 18 | void iosav_write_sequence(const int ch, const struct iosav_ssq *seq, const unsigned int length) |
Angel Pons | 1c505f8 | 2020-11-11 20:55:35 +0100 | [diff] [blame] | 19 | { |
Angel Pons | 8f0757e | 2020-11-11 23:03:36 +0100 | [diff] [blame^] | 20 | for (unsigned int i = 0; i < length; i++) { |
| 21 | MCHBAR32(IOSAV_n_SP_CMD_CTRL_ch(ch, i)) = seq[i].sp_cmd_ctrl.raw; |
| 22 | MCHBAR32(IOSAV_n_SUBSEQ_CTRL_ch(ch, i)) = seq[i].subseq_ctrl.raw; |
| 23 | MCHBAR32(IOSAV_n_SP_CMD_ADDR_ch(ch, i)) = seq[i].sp_cmd_addr.raw; |
| 24 | MCHBAR32(IOSAV_n_ADDR_UPDATE_ch(ch, i)) = seq[i].addr_update.raw; |
| 25 | } |
Angel Pons | 1c505f8 | 2020-11-11 20:55:35 +0100 | [diff] [blame] | 26 | |
Angel Pons | 8f0757e | 2020-11-11 23:03:36 +0100 | [diff] [blame^] | 27 | ssq_count = length; |
Angel Pons | 1c505f8 | 2020-11-11 20:55:35 +0100 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | void iosav_run_queue(const int ch, const u8 loops, const u8 as_timer) |
| 31 | { |
Angel Pons | 8f0757e | 2020-11-11 23:03:36 +0100 | [diff] [blame^] | 32 | /* Should never happen */ |
| 33 | if (ssq_count == 0) |
| 34 | return; |
Angel Pons | 1c505f8 | 2020-11-11 20:55:35 +0100 | [diff] [blame] | 35 | |
Angel Pons | 8f0757e | 2020-11-11 23:03:36 +0100 | [diff] [blame^] | 36 | MCHBAR32(IOSAV_SEQ_CTL_ch(ch)) = loops | ((ssq_count - 1) << 18) | (as_timer << 22); |
Angel Pons | 1c505f8 | 2020-11-11 20:55:35 +0100 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | void iosav_run_once(const int ch) |
| 40 | { |
| 41 | iosav_run_queue(ch, 1, 0); |
| 42 | } |
| 43 | |
| 44 | void wait_for_iosav(int channel) |
| 45 | { |
| 46 | while (1) { |
| 47 | if (MCHBAR32(IOSAV_STATUS_ch(channel)) & 0x50) |
| 48 | return; |
| 49 | } |
| 50 | } |