rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | /***************************************************************************** |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 2005 |
| 8 | * |
| 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 21 | * |
| 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 27 | * |
| 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 33 | * |
| 34 | *****************************************************************************/ |
| 35 | |
| 36 | /***************************************************************************** |
| 37 | * |
| 38 | * Filename: |
| 39 | * --------- |
| 40 | * spi_internal.h |
| 41 | * |
| 42 | * Project: |
| 43 | * -------- |
| 44 | * Maui_Software |
| 45 | * |
| 46 | * Description: |
| 47 | * ------------ |
| 48 | * This Module defines the SPI driver. |
| 49 | * |
| 50 | * Author: |
| 51 | * ------- |
| 52 | * ------- |
| 53 | * |
| 54 | *============================================================================ |
| 55 | * HISTORY |
| 56 | * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 57 | *------------------------------------------------------------------------------ |
| 58 | * removed! |
| 59 | * |
| 60 | * removed! |
| 61 | * removed! |
| 62 | * removed! |
| 63 | * |
| 64 | * removed! |
| 65 | * removed! |
| 66 | * removed! |
| 67 | * |
| 68 | * removed! |
| 69 | * removed! |
| 70 | * removed! |
| 71 | * |
| 72 | * removed! |
| 73 | * removed! |
| 74 | * removed! |
| 75 | * |
| 76 | * removed! |
| 77 | * removed! |
| 78 | * removed! |
| 79 | * |
| 80 | * removed! |
| 81 | * removed! |
| 82 | * removed! |
| 83 | * |
| 84 | * removed! |
| 85 | * removed! |
| 86 | * removed! |
| 87 | * |
| 88 | * removed! |
| 89 | * removed! |
| 90 | * removed! |
| 91 | * |
| 92 | * removed! |
| 93 | * removed! |
| 94 | * removed! |
| 95 | * |
| 96 | *------------------------------------------------------------------------------ |
| 97 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 98 | *============================================================================ |
| 99 | ****************************************************************************/ |
| 100 | |
| 101 | #ifndef __spi_internal_h__ |
| 102 | #define __spi_internal_h__ |
| 103 | |
| 104 | //////////////////RHR-ADD////////////////////// |
| 105 | #include "reg_base.h" |
| 106 | //////////////////RHR-ADD////////////////////// |
| 107 | |
| 108 | //////////////////RHR-REMOVE////////////////////// |
| 109 | //#include <spi_define.h> |
| 110 | ////////////////////////////////////////////////// |
| 111 | |
| 112 | |
| 113 | /** |
| 114 | * \def SPI_CONF0_REG |
| 115 | * \ingroup spi |
| 116 | * Defines the SPI configuration 0 register. |
| 117 | */ |
| 118 | #define SPI_CONF0_REG (*((kal_uint32 volatile *)((SPI_base) + 0x0))) |
| 119 | |
| 120 | /** |
| 121 | * \def SPI_CONF1_REG |
| 122 | * \ingroup spi |
| 123 | * Defines the SPI configuration 1 register. |
| 124 | */ |
| 125 | #define SPI_CONF1_REG (*((kal_uint32 volatile *)((SPI_base) + 0x4))) |
| 126 | |
| 127 | /** |
| 128 | * \def SPI_TX_ADDR_REG |
| 129 | * \ingroup spi |
| 130 | * Defines the SPI TX source address register. |
| 131 | */ |
| 132 | #define SPI_TX_ADDR_REG (*((kal_uint32 volatile *)((SPI_base) + 0x8))) |
| 133 | |
| 134 | /** |
| 135 | * \def SPI_RX_ADDR_REG |
| 136 | * \ingroup spi |
| 137 | * Defines the SPI RX destination address register. |
| 138 | */ |
| 139 | #define SPI_RX_ADDR_REG (*((kal_uint32 volatile *)((SPI_base) + 0xC))) |
| 140 | |
| 141 | #define SPI_TX_FIFO_REG_ADDR ((kal_uint32 volatile *)((SPI_base) + 0x10)) |
| 142 | /** |
| 143 | * \def SPI_TX_FIFO_REG |
| 144 | * \ingroup spi |
| 145 | * Defines the SPI TX data FIFO register. |
| 146 | */ |
| 147 | #define SPI_TX_FIFO_REG (*SPI_TX_FIFO_REG_ADDR) |
| 148 | |
| 149 | #define SPI_RX_FIFO_REG_ADDR ((kal_uint32 volatile *)((SPI_base) + 0x14)) |
| 150 | /** |
| 151 | * \def SPI_RX_FIFO_REG |
| 152 | * \ingroup spi |
| 153 | * Defines the SPI RX data FIFO register. |
| 154 | */ |
| 155 | #define SPI_RX_FIFO_REG (*SPI_RX_FIFO_REG_ADDR) |
| 156 | |
| 157 | /** |
| 158 | * \def SPI_COMM_REG |
| 159 | * \ingroup spi |
| 160 | * Defines the SPI command register. |
| 161 | */ |
| 162 | #define SPI_COMM_REG (*((kal_uint32 volatile *)((SPI_base) + 0x18))) |
| 163 | |
| 164 | /** |
| 165 | * \def SPI_STATUS1_REG |
| 166 | * \ingroup spi |
| 167 | * Defines the SPI status register 1. |
| 168 | */ |
| 169 | #define SPI_STATUS1_REG (*((kal_uint32 volatile *)((SPI_base) + 0x1C))) |
| 170 | |
| 171 | /** |
| 172 | * \def SPI_STATUS2_REG |
| 173 | * \ingroup spi |
| 174 | * Defines the SPI status register 2. |
| 175 | */ |
| 176 | #define SPI_STATUS2_REG (*((kal_uint32 volatile *)((SPI_base) + 0x20))) |
| 177 | |
| 178 | #if defined (DRV_SPI_GMC_ARBITRATE ) |
| 179 | #define SPI_GMC_SLOW_DOWN_REG (*((kal_uint32 volatile *)((SPI_base) + 0x24))) |
| 180 | #define SPI_ULTRA_HIGH_PRIORITY_REG (*((kal_uint32 volatile *)((SPI_base) + 0x28))) |
| 181 | #endif |
| 182 | #if defined (DRV_SPI_PAD_MACRO_SELECT ) |
| 183 | #define SPI_PAD_MACRO_SELECT_REG (*((kal_uint32 volatile *)((SPI_base) + 0x2C))) |
| 184 | #endif |
| 185 | |
| 186 | /** \enum SPI_COMM_REG_BIT_POS |
| 187 | * \ingroup spi |
| 188 | * |
| 189 | * @brief |
| 190 | * Specify the bit position in the SPI command register. |
| 191 | */ |
| 192 | enum SPI_COMM_REG_BIT_POS |
| 193 | { |
| 194 | SPI_COMM_BIT_ACT = 0, |
| 195 | /**< |
| 196 | * \ingroup spi |
| 197 | * The activate bit. |
| 198 | */ |
| 199 | SPI_COMM_BIT_RESUME = 1, |
| 200 | /**< |
| 201 | * \ingroup spi |
| 202 | * The resume bit. |
| 203 | */ |
| 204 | SPI_COMM_BIT_RESET = 2, |
| 205 | /**< |
| 206 | * \ingroup spi |
| 207 | * The reset bit. |
| 208 | */ |
| 209 | SPI_COMM_BIT_PAUSE_EN = 4, |
| 210 | /**< |
| 211 | * \ingroup spi |
| 212 | * The pause enable bit. |
| 213 | */ |
| 214 | SPI_COMM_BIT_CS_DEASSERT_EN = 5, |
| 215 | /**< |
| 216 | * \ingroup spi |
| 217 | * The deassert enable bit. |
| 218 | */ |
| 219 | SPI_COMM_BIT_CPHA = 8, |
| 220 | /**< |
| 221 | * \ingroup spi |
| 222 | * The clock format bit. |
| 223 | */ |
| 224 | SPI_COMM_BIT_CPOL = 9, |
| 225 | /**< |
| 226 | * \ingroup spi |
| 227 | * The clock polarity bit. |
| 228 | */ |
| 229 | SPI_COMM_BIT_RX_DMA_EN = 10, |
| 230 | /**< |
| 231 | * \ingroup spi |
| 232 | * The RX DMA enable/disable bit. |
| 233 | */ |
| 234 | SPI_COMM_BIT_TX_DMA_EN = 11, |
| 235 | /**< |
| 236 | * \ingroup spi |
| 237 | * The TX DMA enable/disable bit. |
| 238 | */ |
| 239 | SPI_COMM_BIT_TX_MSBF = 12, |
| 240 | /**< |
| 241 | * \ingroup spi |
| 242 | * The TX MSB/LSB select bit. |
| 243 | */ |
| 244 | SPI_COMM_BIT_RX_MSBF = 13, |
| 245 | /**< |
| 246 | * \ingroup spi |
| 247 | * The RX MSB/LSB select bit. |
| 248 | */ |
| 249 | SPI_COMM_BIT_RX_ENDIAN = 14, |
| 250 | /**< |
| 251 | * \ingroup spi |
| 252 | * The RX big/little endian select bit. |
| 253 | */ |
| 254 | SPI_COMM_BIT_TX_ENDIAN = 15, |
| 255 | /**< |
| 256 | * \ingroup spi |
| 257 | * The TX big/little endian select bit. |
| 258 | */ |
| 259 | SPI_COMM_BIT_FINISH_IE = 16, |
| 260 | /**< |
| 261 | * \ingroup spi |
| 262 | * The finish mode enable/disable bit. |
| 263 | */ |
| 264 | SPI_COMM_BIT_PAUSE_IE = 17 |
| 265 | /**< |
| 266 | * \ingroup spi |
| 267 | * The pause mode enable/disable bit. |
| 268 | */ |
| 269 | }; |
| 270 | typedef enum SPI_COMM_REG_BIT_POS SPI_COMM_REG_BIT_POS; |
| 271 | |
| 272 | /** \enum SPI_STATUS1_BIT |
| 273 | * \ingroup spi |
| 274 | * |
| 275 | * @brief |
| 276 | * Specify the bit position in the SPI status register 1. |
| 277 | */ |
| 278 | enum SPI_STATUS1_BIT |
| 279 | { |
| 280 | SPI_STATUS1_BIT_FINISH = (1 << 0), |
| 281 | /**< |
| 282 | * \ingroup spi |
| 283 | * The finish bit in the SPI status register 1. |
| 284 | */ |
| 285 | SPI_STATUS1_BIT_PAUSE = (1 << 1) |
| 286 | /**< |
| 287 | * \ingroup spi |
| 288 | * The pause bit in the SPI status register 1. |
| 289 | */ |
| 290 | }; |
| 291 | typedef enum SPI_STATUS1_BIT SPI_STATUS1_BIT; |
| 292 | |
| 293 | /** \enum SPI_STATUS2_BIT |
| 294 | * \ingroup spi |
| 295 | * |
| 296 | * @brief |
| 297 | * Specify the bit position in the SPI status register 2. |
| 298 | */ |
| 299 | enum SPI_STATUS2_BIT |
| 300 | { |
| 301 | SPI_STATUS2_BIT_BUSY = (1 << 0) |
| 302 | /**< |
| 303 | * \ingroup spi |
| 304 | * The busy bit in the SPI status register 2. |
| 305 | */ |
| 306 | }; |
| 307 | typedef enum SPI_STATUS2_BIT SPI_STATUS2_BIT; |
| 308 | |
| 309 | /** \enum SPI_STATUS_REG |
| 310 | * \ingroup spi |
| 311 | * |
| 312 | * @brief Choose the supported status registers. |
| 313 | */ |
| 314 | enum SPI_STATUS_REG |
| 315 | { |
| 316 | SPI_STATUS_REG_1, |
| 317 | /**< |
| 318 | * \ingroup spi |
| 319 | * status register 1 |
| 320 | */ |
| 321 | SPI_STATUS_REG_2 |
| 322 | /**< |
| 323 | * \ingroup spi |
| 324 | * status register 2 |
| 325 | */ |
| 326 | }; |
| 327 | typedef enum SPI_STATUS_REG SPI_STATUS_REG; |
| 328 | |
| 329 | typedef enum |
| 330 | { |
| 331 | SPI_GMC_SLOW_DOWN_ENABLE = 0, |
| 332 | SPI_GMC_SPLIT_BURST_ENABLE = 4 |
| 333 | } SPI_GMC_SLOW_DOWN_REG_BIT_POS; |
| 334 | |
| 335 | typedef enum |
| 336 | { |
| 337 | SPI_ULTRA_HIGH_ENABLE = 0 |
| 338 | } SPI_ULTRA_HIGH_PRIORITY_REG_BIT_POS; |
| 339 | |
| 340 | #endif |