|
| 1 | +/* |
| 2 | + * Copyright (c) 2018, Intel Corporation |
| 3 | + * All rights reserved. |
| 4 | + * |
| 5 | + * Redistribution and use in source and binary forms, with or without |
| 6 | + * modification, are permitted provided that the following conditions are met: |
| 7 | + * * Redistributions of source code must retain the above copyright |
| 8 | + * notice, this list of conditions and the following disclaimer. |
| 9 | + * * Redistributions in binary form must reproduce the above copyright |
| 10 | + * notice, this list of conditions and the following disclaimer in the |
| 11 | + * documentation and/or other materials provided with the distribution. |
| 12 | + * * Neither the name of the Intel Corporation nor the |
| 13 | + * names of its contributors may be used to endorse or promote products |
| 14 | + * derived from this software without specific prior written permission. |
| 15 | + * |
| 16 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 17 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 19 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 20 | + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 | + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 23 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 24 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 25 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 26 | + * POSSIBILITY OF SUCH DAMAGE. |
| 27 | + * |
| 28 | + * Author: Lech Betlej <lech.betlej@linux.intel.com> |
| 29 | + */ |
| 30 | + |
| 31 | +/** |
| 32 | + * \file platform/apollolake/include/platform/asm_memory_management.h |
| 33 | + * \brief Macros for power gating memory banks specific for Apollolake |
| 34 | + * \author Lech Betlej <lech.betlej@linux.intel.com> |
| 35 | + */ |
| 36 | +#ifndef ASM_MEMORY_MANAGEMENT_H |
| 37 | +#define ASM_MEMORY_MANAGEMENT_H |
| 38 | + |
| 39 | +#ifndef ASSEMBLY |
| 40 | +#warning "ASSEMBLY macro not defined." |
| 41 | +#endif |
| 42 | + |
| 43 | +#include <platform/shim.h> |
| 44 | +#include <platform/platcfg.h> |
| 45 | + |
| 46 | +#define HPSRAM_MASK ((1 << PLATFORM_HPSRAM_EBB_COUNT) - 1) |
| 47 | +#define LPSRAM_MASK ((1 << PLATFORM_LPSRAM_EBB_COUNT) - 1) |
| 48 | + |
| 49 | + /* Macro powers down entire hpsram. on entry literals and code for |
| 50 | + * section from where this code is executed needs to be placed in |
| 51 | + * memory which is not HPSRAM (in case when this code is located in |
| 52 | + * HPSRAM lock memory in L1$ or L1 SRAM) |
| 53 | + */ |
| 54 | + .macro m_cavs_hpsram_power_off ax, ay, az |
| 55 | + // SEGMENT #0 |
| 56 | + movi \az, (SHIM_BASE + SHIM_HSPGISTS) |
| 57 | + movi \ax, (SHIM_BASE + SHIM_HSPGCTL) |
| 58 | + movi \ay, HPSRAM_MASK |
| 59 | + s32i \ay, \ax, 0 |
| 60 | + memw |
| 61 | + /* since HPSRAM EBB bank #0 might be used as buffer for legacy |
| 62 | + * streaming, should not be checked in status |
| 63 | + */ |
| 64 | + movi \ax, 0xfffffffe |
| 65 | + and \ay, \ay, \ax |
| 66 | + 1 : |
| 67 | + l32i \ax, \az, 0 |
| 68 | + and \ax, \ax, \ay |
| 69 | + bne \ax, \ay, 1b |
| 70 | + /* there is no possibility to check from DSP whether EBB #0 is actually |
| 71 | + * in use therefore wait additional 4K DSP cycles as chicken check - |
| 72 | + * after that time EBB #0 should be already power gated unless is used |
| 73 | + * by other HW components (like HD-A) |
| 74 | + */ |
| 75 | + l32i \ax, \az, 0 |
| 76 | + beq \ax, \ay, m_cavs_hpsram_power_off_end |
| 77 | + movi \ax, 4096 |
| 78 | + 1 : |
| 79 | + addi \ax, \ax, -1 |
| 80 | + bnez \ax, 1b |
| 81 | + m_cavs_hpsram_power_off_end : |
| 82 | + .endm |
| 83 | + |
| 84 | + .macro m_cavs_lpsram_power_off ax, ay, az |
| 85 | + movi \az, (SHIM_BASE + SHIM_LSPGISTS) |
| 86 | + movi \ax, (SHIM_BASE + SHIM_LSPGCTL) |
| 87 | + movi \ay, LPSRAM_MASK |
| 88 | + s32i \ay, \ax, 0 |
| 89 | + memw |
| 90 | + 1 : |
| 91 | + l32i \ax, \az, 0 |
| 92 | + bne \ax, \ay, 1b |
| 93 | + .endm |
| 94 | + |
| 95 | +#endif /* ASM_MEMORY_MANAGEMENT_H */ |
0 commit comments