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 | |
| 18 | void iosav_write_ssq(const int ch, const struct iosav_ssq *ssq) |
| 19 | { |
| 20 | MCHBAR32(IOSAV_n_SP_CMD_CTRL_ch(ch, ssq_count)) = ssq->sp_cmd_ctrl.raw; |
| 21 | MCHBAR32(IOSAV_n_SUBSEQ_CTRL_ch(ch, ssq_count)) = ssq->subseq_ctrl.raw; |
| 22 | MCHBAR32(IOSAV_n_SP_CMD_ADDR_ch(ch, ssq_count)) = ssq->sp_cmd_addr.raw; |
| 23 | MCHBAR32(IOSAV_n_ADDR_UPDATE_ch(ch, ssq_count)) = ssq->addr_update.raw; |
| 24 | |
| 25 | ssq_count++; |
| 26 | } |
| 27 | |
| 28 | void iosav_run_queue(const int ch, const u8 loops, const u8 as_timer) |
| 29 | { |
| 30 | MCHBAR32(IOSAV_SEQ_CTL_ch(ch)) = loops | ((ssq_count - 1) << 18) | (as_timer << 22); |
| 31 | |
| 32 | ssq_count = 0; |
| 33 | } |
| 34 | |
| 35 | void iosav_run_once(const int ch) |
| 36 | { |
| 37 | iosav_run_queue(ch, 1, 0); |
| 38 | } |
| 39 | |
| 40 | void wait_for_iosav(int channel) |
| 41 | { |
| 42 | while (1) { |
| 43 | if (MCHBAR32(IOSAV_STATUS_ch(channel)) & 0x50) |
| 44 | return; |
| 45 | } |
| 46 | } |