Maria Yu | beabb33 | 2017-03-02 17:04:24 +0800 | [diff] [blame] | 1 | /* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * Redistribution and use in source and binary forms, with or without |
| 4 | * modification, are permitted provided that the following conditions are |
| 5 | * met: |
| 6 | * * Redistributions of source code must retain the above copyright |
| 7 | * notice, this list of conditions and the following disclaimer. |
| 8 | * * Redistributions in binary form must reproduce the above |
| 9 | * copyright notice, this list of conditions and the following |
| 10 | * disclaimer in the documentation and/or other materials provided |
| 11 | * with the distribution. |
| 12 | * * Neither the name of The Linux Foundation, Inc. nor the names of its |
| 13 | * contributors may be used to endorse or promote products derived |
| 14 | * from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 20 | * BE 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 |
| 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
| 28 | |
| 29 | #ifndef __QUP__ |
| 30 | #define __QUP__ |
| 31 | |
| 32 | #include <stdint.h> |
| 33 | |
Wenjun Zhang | e9647e2 | 2018-02-01 03:42:29 -0500 | [diff] [blame^] | 34 | #define MAX_READ_SPEED_HZ 9600000 |
| 35 | #define MAX_SPEED_HZ 50000000 |
| 36 | |
Maria Yu | beabb33 | 2017-03-02 17:04:24 +0800 | [diff] [blame] | 37 | /* QUP_IO_MODES fields */ |
| 38 | #define QUP_IO_MODES_OUTPUT_BIT_SHIFT_EN 0x00010000 |
| 39 | #define QUP_IO_MODES_PACK_EN 0x00008000 |
| 40 | #define QUP_IO_MODES_UNPACK_EN 0x00004000 |
| 41 | #define QUP_IO_MODES_INPUT_MODE 0x00003000 |
| 42 | #define QUP_IO_MODES_OUTPUT_MODE 0x00000C00 |
| 43 | #define QUP_IO_MODES_INPUT_FIFO_SIZE 0x00000380 |
| 44 | #define QUP_IO_MODES_INPUT_BLOCK_SIZE 0x00000060 |
| 45 | #define QUP_IO_MODES_OUTPUT_FIFO_SIZE 0x0000001C |
| 46 | #define QUP_IO_MODES_OUTPUT_BLOCK_SIZE 0x00000003 |
| 47 | |
| 48 | #define INPUT_BLOCK_SZ_SHIFT 5 |
| 49 | #define INPUT_FIFO_SZ_SHIFT 7 |
| 50 | #define OUTPUT_BLOCK_SZ_SHIFT 0 |
| 51 | #define OUTPUT_FIFO_SZ_SHIFT 2 |
| 52 | #define OUTPUT_MODE_SHIFT 10 |
| 53 | #define INPUT_MODE_SHIFT 12 |
| 54 | #define INPUT_MODE_MASK (3 << INPUT_MODE_SHIFT) |
| 55 | #define OUTPUT_MODE_MASK (3 << OUTPUT_MODE_SHIFT) |
| 56 | |
| 57 | /* QUP_STATE fields */ |
| 58 | #define QUP_STATE_CLEAR_BITS 0x2 |
| 59 | |
| 60 | /* QUP_ERROR_FLAGS fields */ |
| 61 | #define QUP_ERROR_OUTPUT_OVER_RUN BIT(5) |
| 62 | #define QUP_ERROR_INPUT_UNDER_RUN BIT(4) |
| 63 | #define QUP_ERROR_OUTPUT_UNDER_RUN BIT(3) |
| 64 | #define QUP_ERROR_INPUT_OVER_RUN BIT(2) |
| 65 | |
| 66 | /* QUP_OPERATIONAL fields */ |
| 67 | #define QUP_OP_MAX_INPUT_DONE_FLAG BIT(11) |
| 68 | #define QUP_OP_MAX_OUTPUT_DONE_FLAG BIT(10) |
| 69 | #define QUP_OP_IN_SERVICE_FLAG BIT(9) |
| 70 | #define QUP_OP_OUT_SERVICE_FLAG BIT(8) |
| 71 | #define QUP_OP_IN_FIFO_FULL BIT(7) |
| 72 | #define QUP_OP_OUT_FIFO_FULL BIT(6) |
| 73 | #define QUP_OP_IN_FIFO_NOT_EMPTY BIT(5) |
| 74 | #define QUP_OP_OUT_FIFO_NOT_EMPTY BIT(4) |
| 75 | |
| 76 | /* QUP_IO_MODES fields */ |
| 77 | #define QUP_IO_MODES_FIFO 0 |
| 78 | #define QUP_IO_MODES_BLOCK 1 |
| 79 | #define QUP_IO_MODES_DMOV 2 |
| 80 | #define QUP_IO_MODES_BAM 3 |
| 81 | |
| 82 | /* QUP_CONFIG fields */ |
| 83 | #define QUP_CONFIG_SPI_MODE (1 << 8) |
| 84 | #define QUP_CONFIG_CLOCK_AUTO_GATE BIT(13) |
| 85 | #define QUP_CONFIG_NO_INPUT BIT(7) |
| 86 | #define QUP_CONFIG_NO_OUTPUT BIT(6) |
| 87 | #define QUP_CONFIG_N 0x001f |
| 88 | |
| 89 | /* QUP_MX_OUTPUT_CNT only supports |
| 90 | * 0:15 bits as Number of writes of |
| 91 | * size N to the mini-core per RUN state. |
| 92 | * And make the count be multiple of max bytes per word. |
| 93 | */ |
| 94 | #define MAX_QUP_MX_OUTPUT_COUNT 0xFFF8 |
Wenjun Zhang | e9647e2 | 2018-02-01 03:42:29 -0500 | [diff] [blame^] | 95 | #define MAX_QUP_MX_TRANSFER_COUNT 0xFFF8 |
Maria Yu | beabb33 | 2017-03-02 17:04:24 +0800 | [diff] [blame] | 96 | |
| 97 | /* QUP Registers */ |
| 98 | enum { |
| 99 | QUP_CONFIG = 0x0, |
| 100 | QUP_STATE = 0x4, |
| 101 | QUP_IO_MODES = 0x8, |
| 102 | QUP_SW_RESET = 0xC, |
| 103 | QUP_OPERATIONAL = 0x18, |
| 104 | QUP_ERROR_FLAGS = 0x1C, |
| 105 | QUP_ERROR_FLAGS_EN = 0x20, |
| 106 | QUP_TEST_CTRL = 0x24, |
| 107 | QUP_OPERATIONAL_MASK = 0x28, |
| 108 | QUP_HW_VERSION = 0x30, |
| 109 | QUP_MX_READ_CNT = 0x208, |
| 110 | QUP_MX_INPUT_CNT = 0x200, |
Wenjun Zhang | e9647e2 | 2018-02-01 03:42:29 -0500 | [diff] [blame^] | 111 | QUP_MX_INPUT_CNT_CURRENT = 0x204, |
Maria Yu | beabb33 | 2017-03-02 17:04:24 +0800 | [diff] [blame] | 112 | QUP_MX_OUTPUT_CNT = 0x100, |
| 113 | QUP_MX_OUTPUT_CNT_CURRENT = 0x104, |
| 114 | QUP_OUTPUT_DEBUG = 0x108, |
| 115 | QUP_OUTPUT_FIFO_WORD_CNT = 0x10C, |
| 116 | QUP_OUTPUT_FIFO_BASE = 0x110, |
| 117 | QUP_MX_WRITE_CNT = 0x150, |
| 118 | QUP_MX_WRITE_CNT_CURRENT = 0x154, |
| 119 | QUP_INPUT_READ_CUR = 0x20C, |
| 120 | QUP_INPUT_DEBUG = 0x210, |
| 121 | QUP_INPUT_FIFO_CNT = 0x214, |
| 122 | QUP_INPUT_FIFO_BASE = 0x218, |
| 123 | QUP_I2C_CLK_CTL = 0x400, |
| 124 | QUP_I2C_STATUS = 0x404, |
| 125 | }; |
| 126 | |
| 127 | /* QUP States and reset values */ |
| 128 | enum qup_state{ |
| 129 | QUP_RESET_STATE = 0, |
| 130 | QUP_RUN_STATE = 1U, |
| 131 | QUP_STATE_MASK = 3U, |
| 132 | QUP_PAUSE_STATE = 3U, |
| 133 | QUP_STATE_VALID = 1U << 2, |
| 134 | QUP_I2C_MAST_GEN = 1U << 4, |
| 135 | QUP_OPERATIONAL_RESET = 0xFF0, |
| 136 | QUP_I2C_STATUS_RESET = 0xFFFFFC, |
| 137 | }; |
| 138 | |
| 139 | /* QUP OPERATIONAL FLAGS */ |
| 140 | enum { |
| 141 | QUP_OUT_SVC_FLAG = 1U << 8, |
| 142 | QUP_IN_SVC_FLAG = 1U << 9, |
| 143 | QUP_MX_INPUT_DONE = 1U << 11, |
| 144 | }; |
| 145 | |
| 146 | #endif /* __QUP__ */ |