bfrom.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* Blackfin on-chip ROM API
  2. *
  3. * Copyright 2008 Analog Devices Inc.
  4. *
  5. * Licensed under the GPL-2 or later.
  6. */
  7. #ifndef __BFROM_H__
  8. #define __BFROM_H__
  9. #include <linux/types.h>
  10. /* Possible syscontrol action flags */
  11. #define SYSCTRL_READ 0x00000000 /* read registers */
  12. #define SYSCTRL_WRITE 0x00000001 /* write registers */
  13. #define SYSCTRL_SYSRESET 0x00000002 /* perform system reset */
  14. #define SYSCTRL_CORERESET 0x00000004 /* perform core reset */
  15. #define SYSCTRL_SOFTRESET 0x00000006 /* perform core and system reset */
  16. #define SYSCTRL_VRCTL 0x00000010 /* read/write VR_CTL register */
  17. #define SYSCTRL_EXTVOLTAGE 0x00000020 /* VDDINT supplied externally */
  18. #define SYSCTRL_INTVOLTAGE 0x00000000 /* VDDINT generated by on-chip regulator */
  19. #define SYSCTRL_OTPVOLTAGE 0x00000040 /* For Factory Purposes Only */
  20. #define SYSCTRL_PLLCTL 0x00000100 /* read/write PLL_CTL register */
  21. #define SYSCTRL_PLLDIV 0x00000200 /* read/write PLL_DIV register */
  22. #define SYSCTRL_LOCKCNT 0x00000400 /* read/write PLL_LOCKCNT register */
  23. #define SYSCTRL_PLLSTAT 0x00000800 /* read/write PLL_STAT register */
  24. typedef struct ADI_SYSCTRL_VALUES {
  25. uint16_t uwVrCtl;
  26. uint16_t uwPllCtl;
  27. uint16_t uwPllDiv;
  28. uint16_t uwPllLockCnt;
  29. uint16_t uwPllStat;
  30. } ADI_SYSCTRL_VALUES;
  31. static uint32_t (* const bfrom_SysControl)(uint32_t action_flags, ADI_SYSCTRL_VALUES *power_settings, void *reserved) = (void *)0xEF000038;
  32. /* We need a dedicated function since we need to screw with the stack pointer
  33. * when resetting. The on-chip ROM will save/restore registers on the stack
  34. * when doing a system reset, so the stack cannot be outside of the chip.
  35. */
  36. __attribute__((__noreturn__))
  37. static inline void bfrom_SoftReset(void *new_stack)
  38. {
  39. while (1)
  40. /*
  41. * We don't declare the SP as clobbered on purpose, since
  42. * it confuses the heck out of the compiler, and this function
  43. * never returns
  44. */
  45. __asm__ __volatile__(
  46. "sp = %[stack];"
  47. "jump (%[bfrom_syscontrol]);"
  48. : : [bfrom_syscontrol] "p"(bfrom_SysControl),
  49. "q0"(SYSCTRL_SOFTRESET),
  50. "q1"(0),
  51. "q2"(NULL),
  52. [stack] "p"(new_stack)
  53. );
  54. }
  55. /* OTP Functions */
  56. static uint32_t (* const bfrom_OtpCommand)(uint32_t command, uint32_t value) = (void *)0xEF000018;
  57. static uint32_t (* const bfrom_OtpRead)(uint32_t page, uint32_t flags, uint64_t *page_content) = (void *)0xEF00001A;
  58. static uint32_t (* const bfrom_OtpWrite)(uint32_t page, uint32_t flags, uint64_t *page_content) = (void *)0xEF00001C;
  59. /* otp command: defines for "command" */
  60. #define OTP_INIT 0x00000001
  61. #define OTP_CLOSE 0x00000002
  62. /* otp read/write: defines for "flags" */
  63. #define OTP_LOWER_HALF 0x00000000 /* select upper/lower 64-bit half (bit 0) */
  64. #define OTP_UPPER_HALF 0x00000001
  65. #define OTP_NO_ECC 0x00000010 /* do not use ECC */
  66. #define OTP_LOCK 0x00000020 /* sets page protection bit for page */
  67. #define OTP_CHECK_FOR_PREV_WRITE 0x00000080
  68. /* Return values for all functions */
  69. #define OTP_SUCCESS 0x00000000
  70. #define OTP_MASTER_ERROR 0x001
  71. #define OTP_WRITE_ERROR 0x003
  72. #define OTP_READ_ERROR 0x005
  73. #define OTP_ACC_VIO_ERROR 0x009
  74. #define OTP_DATA_MULT_ERROR 0x011
  75. #define OTP_ECC_MULT_ERROR 0x021
  76. #define OTP_PREV_WR_ERROR 0x041
  77. #define OTP_DATA_SB_WARN 0x100
  78. #define OTP_ECC_SB_WARN 0x200
  79. #endif