boot_mode.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // Copyright 2010-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef _SOC_BOOT_MODE_H_
  14. #define _SOC_BOOT_MODE_H_
  15. #include "soc.h"
  16. /*SPI Boot*/
  17. #define IS_1XXXX(v) (((v)&0x10)==0x10)
  18. /*HSPI Boot*/
  19. #define IS_010XX(v) (((v)&0x1c)==0x08)
  20. /*Download Boot, SDIO/UART0/UART1*/
  21. #define IS_00XXX(v) (((v)&0x18)==0x00)
  22. /*Download Boot, SDIO/UART0/UART1,FEI_FEO V2*/
  23. #define IS_00X00(v) (((v)&0x1b)==0x00)
  24. /*Download Boot, SDIO/UART0/UART1,FEI_REO V2*/
  25. #define IS_00X01(v) (((v)&0x1b)==0x01)
  26. /*Download Boot, SDIO/UART0/UART1,REI_FEO V2*/
  27. #define IS_00X10(v) (((v)&0x1b)==0x02)
  28. /*Download Boot, SDIO/UART0/UART1,REI_FEO V2*/
  29. #define IS_00X11(v) (((v)&0x1b)==0x03)
  30. /*ATE/ANALOG Mode*/
  31. #define IS_01110(v) (((v)&0x1f)==0x0e)
  32. /*Diagnostic Mode+UART0 download Mode*/
  33. #define IS_01111(v) (((v)&0x1f)==0x0f)
  34. /*legacy SPI Boot*/
  35. #define IS_01100(v) (((v)&0x1f)==0x0c)
  36. /*SDIO_Slave download Mode V1.1*/
  37. #define IS_01101(v) (((v)&0x1f)==0x0d)
  38. #define BOOT_MODE_GET() (GPIO_REG_READ(GPIO_STRAP))
  39. /*do not include download mode*/
  40. #define ETS_IS_UART_BOOT() IS_01111(BOOT_MODE_GET())
  41. /*all spi boot including spi/hspi/legacy*/
  42. #define ETS_IS_FLASH_BOOT() (IS_1XXXX(BOOT_MODE_GET()) || IS_010XX(BOOT_MODE_GET()) || IS_01100(BOOT_MODE_GET()))
  43. /*all faster spi boot including spi/hspi*/
  44. #define ETS_IS_FAST_FLASH_BOOT() (IS_1XXXX(BOOT_MODE_GET()) || IS_010XX(BOOT_MODE_GET()))
  45. /*all spi boot including spi/legacy*/
  46. #define ETS_IS_SPI_FLASH_BOOT() (IS_1XXXX(BOOT_MODE_GET()) || IS_01100(BOOT_MODE_GET()))
  47. /*all spi boot including hspi/legacy*/
  48. #define ETS_IS_HSPI_FLASH_BOOT() IS_010XX(BOOT_MODE_GET())
  49. /*all sdio V2 of failing edge input, failing edge output*/
  50. #define ETS_IS_SDIO_FEI_FEO_V2_BOOT() IS_00X00(BOOT_MODE_GET())
  51. /*all sdio V2 of failing edge input, raising edge output*/
  52. #define ETS_IS_SDIO_FEI_REO_V2_BOOT() IS_00X01(BOOT_MODE_GET())
  53. /*all sdio V2 of raising edge input, failing edge output*/
  54. #define ETS_IS_SDIO_REI_FEO_V2_BOOT() IS_00X10(BOOT_MODE_GET())
  55. /*all sdio V2 of raising edge input, raising edge output*/
  56. #define ETS_IS_SDIO_REI_REO_V2_BOOT() IS_00X11(BOOT_MODE_GET())
  57. /*all sdio V1 of raising edge input, failing edge output*/
  58. #define ETS_IS_SDIO_REI_FEO_V1_BOOT() IS_01101(BOOT_MODE_GET())
  59. /*do not include download mode*/
  60. #define ETS_IS_SDIO_BOOT() IS_01101(BOOT_MODE_GET())
  61. /*joint download boot*/
  62. #define ETS_IS_SDIO_UART_BOOT() IS_00XXX(BOOT_MODE_GET())
  63. /*ATE mode*/
  64. #define ETS_IS_ATE_BOOT() IS_01110(BOOT_MODE_GET())
  65. /*A bit to control flash boot print*/
  66. #define ETS_IS_PRINT_BOOT() (BOOT_MODE_GET() & 0x2)
  67. /*used by ETS_IS_SDIO_UART_BOOT*/
  68. #define SEL_NO_BOOT 0
  69. #define SEL_SDIO_BOOT BIT0
  70. #define SEL_UART_BOOT BIT1
  71. #endif /* _SOC_BOOT_MODE_H_ */