You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

119 lines
3.5 KiB

  1. /***************************************************************************
  2. * Copyright (C) 2006 by Magnus Lundin *
  3. * lundin@mlu.mine.nu *
  4. * *
  5. * Copyright (C) 2006 by Gheorghe Guran (atlas) *
  6. * *
  7. * This program is free software; you can redistribute it and/or modify *
  8. * it under the terms of the GNU General Public License as published by *
  9. * the Free Software Foundation; either version 2 of the License, or *
  10. * (at your option) any later version. *
  11. * *
  12. * This program is distributed in the hope that it will be useful, *
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  15. * GNU General Public License for more details. *
  16. * *
  17. * You should have received a copy of the GNU General Public License *
  18. * along with this program; if not, write to the *
  19. * Free Software Foundation, Inc., *
  20. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  21. ***************************************************************************/
  22. #ifndef AT91SAM7_H
  23. #define AT91SAM7_H
  24. #include "flash.h"
  25. typedef struct at91sam7_flash_bank_s
  26. {
  27. /* chip id register */
  28. uint32_t cidr;
  29. uint16_t cidr_ext;
  30. uint16_t cidr_nvptyp;
  31. uint16_t cidr_arch;
  32. uint16_t cidr_sramsiz;
  33. uint16_t cidr_nvpsiz;
  34. uint16_t cidr_nvpsiz2;
  35. uint16_t cidr_eproc;
  36. uint16_t cidr_version;
  37. char *target_name;
  38. /* flash auto-detection */
  39. uint8_t flash_autodetection;
  40. /* flash geometry */
  41. uint16_t pages_per_sector;
  42. uint16_t pagesize;
  43. uint16_t pages_in_lockregion;
  44. /* nv memory bits */
  45. uint16_t num_lockbits_on;
  46. uint16_t lockbits;
  47. uint16_t num_nvmbits;
  48. uint16_t num_nvmbits_on;
  49. uint16_t nvmbits;
  50. uint8_t securitybit;
  51. /* 0: not init
  52. * 1: fmcn for nvbits (1uS)
  53. * 2: fmcn for flash (1.5uS) */
  54. uint8_t flashmode;
  55. /* main clock status */
  56. uint8_t mck_valid;
  57. uint32_t mck_freq;
  58. /* external clock frequency */
  59. uint32_t ext_freq;
  60. } at91sam7_flash_bank_t;
  61. /* AT91SAM7 control registers */
  62. #define DBGU_CIDR 0xFFFFF240
  63. #define CKGR_MCFR 0xFFFFFC24
  64. #define CKGR_MOR 0xFFFFFC20
  65. #define CKGR_MCFR_MAINRDY 0x10000
  66. #define CKGR_PLLR 0xFFFFFC2c
  67. #define CKGR_PLLR_DIV 0xff
  68. #define CKGR_PLLR_MUL 0x07ff0000
  69. #define PMC_MCKR 0xFFFFFC30
  70. #define PMC_MCKR_CSS 0x03
  71. #define PMC_MCKR_PRES 0x1c
  72. /* Flash Controller Commands */
  73. #define WP 0x01
  74. #define SLB 0x02
  75. #define WPL 0x03
  76. #define CLB 0x04
  77. #define EA 0x08
  78. #define SGPB 0x0B
  79. #define CGPB 0x0D
  80. #define SSB 0x0F
  81. /* MC_FSR bit definitions */
  82. #define MC_FSR_FRDY 1
  83. #define MC_FSR_EOL 2
  84. /* AT91SAM7 constants */
  85. #define RC_FREQ 32000
  86. /* Flash timing modes */
  87. #define FMR_TIMING_NONE 0
  88. #define FMR_TIMING_NVBITS 1
  89. #define FMR_TIMING_FLASH 2
  90. /* Flash size constants */
  91. #define FLASH_SIZE_8KB 1
  92. #define FLASH_SIZE_16KB 2
  93. #define FLASH_SIZE_32KB 3
  94. #define FLASH_SIZE_64KB 5
  95. #define FLASH_SIZE_128KB 7
  96. #define FLASH_SIZE_256KB 9
  97. #define FLASH_SIZE_512KB 10
  98. #define FLASH_SIZE_1024KB 12
  99. #define FLASH_SIZE_2048KB 14
  100. #endif /* AT91SAM7_H */