Rayagonda Kokatanur | 13dc1c2 | 2020-07-15 22:48:56 +0530 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | /* |
| 3 | * Copyright 2020 Broadcom. |
| 4 | * |
| 5 | */ |
| 6 | |
| 7 | #include <asm/macro.h> |
| 8 | #include <linux/linkage.h> |
| 9 | |
| 10 | hnf_pstate_poll: |
| 11 | /* x0 has the desired status, return 0 for success, 1 for timeout |
| 12 | * clobber x1, x2, x3, x4, x6, x7 |
| 13 | */ |
| 14 | mov x1, x0 |
| 15 | mov x7, #0 /* flag for timeout */ |
| 16 | mrs x3, cntpct_el0 /* read timer */ |
| 17 | mov w0, #600 |
| 18 | mov w6, #1000 |
| 19 | mul w0, w0, w6 |
| 20 | add x3, x3, x0 /* timeout after 100 microseconds */ |
| 21 | mov x0, #0x18 |
| 22 | movk x0, #0x6120, lsl #16 /* HNF0_PSTATE_STATUS */ |
| 23 | mov w6, #4 /* HN-F node count */ |
| 24 | 1: |
| 25 | ldr x2, [x0] |
| 26 | cmp x2, x1 /* check status */ |
| 27 | b.eq 2f |
| 28 | mrs x4, cntpct_el0 |
| 29 | cmp x4, x3 |
| 30 | b.ls 1b |
| 31 | mov x7, #1 /* timeout */ |
| 32 | b 3f |
| 33 | 2: |
| 34 | add x0, x0, #0x10000 /* move to next node */ |
| 35 | subs w6, w6, #1 |
| 36 | cbnz w6, 1b |
| 37 | 3: |
| 38 | mov x0, x7 |
| 39 | ret |
| 40 | |
| 41 | hnf_set_pstate: |
| 42 | /* x0 has the desired state, clobber x1, x2, x6 */ |
| 43 | mov x1, x0 |
| 44 | /* power state to SFONLY */ |
| 45 | mov w6, #4 /* HN-F node count */ |
| 46 | mov x0, #0x10 |
| 47 | movk x0, #0x6120, lsl #16 /* HNF0_PSTATE_REQ */ |
| 48 | 1: /* set pstate to sfonly */ |
| 49 | ldr x2, [x0] |
| 50 | and x2, x2, #0xfffffffffffffffc /* & HNFPSTAT_MASK */ |
| 51 | orr x2, x2, x1 |
| 52 | str x2, [x0] |
| 53 | add x0, x0, #0x10000 /* move to next node */ |
| 54 | subs w6, w6, #1 |
| 55 | cbnz w6, 1b |
| 56 | |
| 57 | ret |
| 58 | |
| 59 | ENTRY(__asm_flush_l3_dcache) |
| 60 | /* |
| 61 | * Return status in x0 |
| 62 | * success 0 |
| 63 | * timeout 1 for setting SFONLY, 2 for FAM, 3 for both |
| 64 | */ |
| 65 | mov x29, lr |
| 66 | mov x8, #0 |
| 67 | |
| 68 | dsb sy |
| 69 | mov x0, #0x1 /* HNFPSTAT_SFONLY */ |
| 70 | bl hnf_set_pstate |
| 71 | |
| 72 | mov x0, #0x4 /* SFONLY status */ |
| 73 | bl hnf_pstate_poll |
| 74 | cbz x0, 1f |
| 75 | mov x8, #1 /* timeout */ |
| 76 | 1: |
| 77 | dsb sy |
| 78 | mov x0, #0x3 /* HNFPSTAT_FAM */ |
| 79 | bl hnf_set_pstate |
| 80 | |
| 81 | mov x0, #0xc /* FAM status */ |
| 82 | bl hnf_pstate_poll |
| 83 | cbz x0, 1f |
| 84 | add x8, x8, #0x2 |
| 85 | 1: |
| 86 | mov x0, x8 |
| 87 | mov lr, x29 |
| 88 | ret |
| 89 | ENDPROC(__asm_flush_l3_dcache) |