diff options
author | Konstantin Porotchkin <kostap@marvell.com> | 2018-03-06 16:14:18 +0200 |
---|---|---|
committer | Kostya Porotchkin <kostap@marvell.com> | 2018-03-18 10:29:20 +0200 |
commit | d93f9a6778ae330daaaacff473dfe353e024b7c8 (patch) | |
tree | 3e002544aa4805331a451838501fc8db97b50caa /drivers | |
parent | 3f373a344e960ee4b6a1c03f283d5818b616fa63 (diff) |
drivers: marvell: io-win: Add API for save and restore windows
Add API for saving and restoring IOW windows on a specific AP.
The main reason for this API addition is the BLE code cleanup
and switching from direct access of the IOW registers to usage
of the dedicated driver APIs.
Change-Id: Ie10b2a69bbb738aaef003546d94a7291ff87c397
Signed-off-by: Konstantin Porotchkin <kostap@marvell.com>
Reviewed-on: http://vgitil04.il.marvell.com:8080/51393
Tested-by: iSoC Platform CI <ykjenk@marvell.com>
Reviewed-by: Hanna Hawa <hannah@marvell.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/marvell/io_win.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/marvell/io_win.c b/drivers/marvell/io_win.c index 845b7e61..7b4fbcbe 100644 --- a/drivers/marvell/io_win.c +++ b/drivers/marvell/io_win.c @@ -56,6 +56,9 @@ #define IO_WIN_AHR_OFFSET(ap, win) (MVEBU_IO_WIN_BASE(ap) + 0x8 + (0x10 * win)) #define IO_WIN_CR_OFFSET(ap, win) (MVEBU_IO_WIN_BASE(ap) + 0xC + (0x10 * win)) +/* For storega of CR, ALR, AHR abd GCR */ +static uint32_t io_win_regs_save[MVEBU_IO_WIN_MAX_WINS * 3 + 1]; + static void io_win_check(struct addr_map_win *win) { /* for IO The base is always 1M aligned */ @@ -191,6 +194,44 @@ static void dump_io_win(int ap_index) } #endif +static void iow_save_win_range(int ap_id, int win_first, int win_last, uint32_t *buffer) +{ + int win_id, idx; + + /* Save IOW */ + for (idx = 0, win_id = win_first; win_id <= win_last; win_id++) { + buffer[idx++] = mmio_read_32(IO_WIN_CR_OFFSET(ap_id, win_id)); + buffer[idx++] = mmio_read_32(IO_WIN_ALR_OFFSET(ap_id, win_id)); + buffer[idx++] = mmio_read_32(IO_WIN_AHR_OFFSET(ap_id, win_id)); + } + buffer[idx] = mmio_read_32(MVEBU_IO_WIN_BASE(ap_id) + + MVEBU_IO_WIN_GCR_OFFSET); +} + +static void iow_restore_win_range(int ap_id, int win_first, int win_last, uint32_t *buffer) +{ + int win_id, idx; + + /* Restore IOW */ + for (idx = 0, win_id = win_first; win_id <= win_last; win_id++) { + mmio_write_32(IO_WIN_CR_OFFSET(ap_id, win_id), buffer[idx++]); + mmio_write_32(IO_WIN_ALR_OFFSET(ap_id, win_id), buffer[idx++]); + mmio_write_32(IO_WIN_AHR_OFFSET(ap_id, win_id), buffer[idx++]); + } + mmio_write_32(MVEBU_IO_WIN_BASE(ap_id) + MVEBU_IO_WIN_GCR_OFFSET, + buffer[idx++]); +} + +void iow_save_win_all(int ap_id) +{ + iow_save_win_range(ap_id, 0, MVEBU_IO_WIN_MAX_WINS - 1, io_win_regs_save); +} + +void iow_restore_win_all(int ap_id) +{ + iow_restore_win_range(ap_id, 0, MVEBU_IO_WIN_MAX_WINS - 1, io_win_regs_save); +} + int init_io_win(int ap_index) { struct addr_map_win *win; |