9393#define PMC_PCR_DIV_SHIFT 13
9494#define PMC_PCR_DIV_MASK (0x3 << PMC_PCR_DIV_SHIFT)
9595
96-
97-
9896/* Specific configuration for 264/132/12 MHz */
9997
10098#define PLL_PCK (((CRYSTAL_FREQ * (PLLA_MULA + 1)) / 2))
110108
111109#define PLLICPR_CONFIG (0x0 << PMC_PLLICPR_ICPPLLA_SHIFT | 0x3 << PMC_PLLICPR_IPLLA_SHIFT)
112110
111+ /* DBGU
112+ *
113+ */
114+ #define DBGU_BASE 0xFFFFEE00
115+ #define DBGU_CR *(volatile uint32_t *)(DBGU_BASE + 0x00)
116+ #define DBGU_BRGR *(volatile uint32_t *)(DBGU_BASE + 0x20)
117+ #define DBGU_CR_RXEN (1 << 4)
118+ #define DBGU_CR_TXEN (1 << 6)
119+ #define DBGU_PMCID 0x02 /* dec: 2 for SAMA5D3 */
120+
121+ /* Associated pins : GPIOB 30 - 31*/
122+ #define DBGU_PIN_RX 30
123+ #define DBGU_PIN_TX 31
124+ #define DBGU_GPIO GPIOB
113125
114126/* PIT
115127 *
116128 */
117-
118129#define PIT_BASE 0xFFFFFE30
119130#define PIT_MR *(volatile uint32_t *)(PIT_BASE + 0x00)
120131#define PIT_SR *(volatile uint32_t *)(PIT_BASE + 0x04)
121132#define PIT_PIVR *(volatile uint32_t *)(PIT_BASE + 0x08)
122133#define PIT_PIIR *(volatile uint32_t *)(PIT_BASE + 0x0C)
123134
124-
125-
126-
127135/* DRAM setup
136+ *
128137 */
129-
130138#define MPDDRC_BASE 0xFFFFEA00
131139#define MPDDRC_MR *(volatile uint32_t *)(MPDDRC_BASE + 0x00) /* Mode Register */
132140#define MPDDRC_RTR *(volatile uint32_t *)(MPDDRC_BASE + 0x04) /* Refresh Timer Register */
159167#define MPDDRC_WPMR *(volatile uint32_t *)(MPDDRC_BASE + 0xE4) /* Write Protection Mode Register */
160168#define MPDDRC_WPSR *(volatile uint32_t *)(MPDDRC_BASE + 0xE8) /* Write Protection Status Register */
161169
162-
163170/* MPDDRC_CR: shift, mask, values */
164171#define MPDDRC_NC_SHIFT 0 /* Number of Column Bits */
165172#define MPDDRC_NC_MASK (0x3 << MPDDRC_NC_SHIFT)
278285#define MAX_PIV 0xfffff
279286#define PIT_MR_EN (1 << 24)
280287
288+ /* GPIO PMC IDs */
289+ #define GPIOA_PMCID 0x06
290+ #define GPIOB_PMCID 0x07
291+ #define GPIOC_PMCID 0x08
292+ #define GPIOD_PMCID 0x09
293+ #define GPIOE_PMCID 0x0A
281294
282295struct dram {
283296 struct dram_timing {
@@ -302,6 +315,7 @@ struct dram {
302315};
303316
304317/* Watchdog
318+ *
305319 */
306320#define WDT_BASE 0xFFFFFD40
307321#define WDT_CR *(volatile uint32_t *)(WDT_BASE + 0x00)
@@ -427,22 +441,36 @@ extern void *kernel_addr, *update_addr, *dts_addr;
427441#define MAX_ECC_BYTES 8
428442#endif
429443
430- #define GPIOE_BASE 0xFFFFFA00
431-
432- #define GPIOE_PER *(volatile uint32_t *)(GPIOE_BASE + 0x00)
433- #define GPIOE_PDR *(volatile uint32_t *)(GPIOE_BASE + 0x04)
434- #define GPIOE_PSR *(volatile uint32_t *)(GPIOE_BASE + 0x08)
435- #define GPIOE_OER *(volatile uint32_t *)(GPIOE_BASE + 0x10)
436- #define GPIOE_ODR *(volatile uint32_t *)(GPIOE_BASE + 0x14)
437- #define GPIOE_OSR *(volatile uint32_t *)(GPIOE_BASE + 0x18)
438- #define GPIOE_SODR *(volatile uint32_t *)(GPIOE_BASE + 0x30)
439- #define GPIOE_CODR *(volatile uint32_t *)(GPIOE_BASE + 0x34)
440- #define GPIOE_IER *(volatile uint32_t *)(GPIOE_BASE + 0x40)
441- #define GPIOE_IDR *(volatile uint32_t *)(GPIOE_BASE + 0x44)
442- #define GPIOE_MDER *(volatile uint32_t *)(GPIOE_BASE + 0x50)
443- #define GPIOE_MDDR *(volatile uint32_t *)(GPIOE_BASE + 0x54)
444- #define GPIOE_PPUDR *(volatile uint32_t *)(GPIOE_BASE + 0x60)
445- #define GPIOE_PPUER *(volatile uint32_t *)(GPIOE_BASE + 0x64)
444+ #define GPIOB 0xFFFFF400
445+ #define GPIOC 0xFFFFF600
446+ #define GPIOE 0xFFFFFA00
447+
448+ #define GPIO_PER (base ) *(volatile uint32_t *)(base + 0x00)
449+ #define GPIO_PDR (base ) *(volatile uint32_t *)(base + 0x04)
450+ #define GPIO_PSR (base ) *(volatile uint32_t *)(base + 0x08)
451+ #define GPIO_OER (base ) *(volatile uint32_t *)(base + 0x10)
452+ #define GPIO_ODR (base ) *(volatile uint32_t *)(base + 0x14)
453+ #define GPIO_OSR (base ) *(volatile uint32_t *)(base + 0x18)
454+ #define GPIO_SODR (base ) *(volatile uint32_t *)(base + 0x30)
455+ #define GPIO_CODR (base ) *(volatile uint32_t *)(base + 0x34)
456+ #define GPIO_IER (base ) *(volatile uint32_t *)(base + 0x40)
457+ #define GPIO_IDR (base ) *(volatile uint32_t *)(base + 0x44)
458+ #define GPIO_MDER (base ) *(volatile uint32_t *)(base + 0x50)
459+ #define GPIO_MDDR (base ) *(volatile uint32_t *)(base + 0x54)
460+ #define GPIO_PPUDR (base ) *(volatile uint32_t *)(base + 0x60)
461+ #define GPIO_PPUER (base ) *(volatile uint32_t *)(base + 0x64)
462+ #define GPIO_ASR (base ) *(volatile uint32_t *)(base + 0x70)
463+ #define GPIO_PPDDR (base ) *(volatile uint32_t *)(base + 0x90)
464+
465+
466+ /* PMC Macro to enable clock */
467+ #define PMC_CLOCK_EN (id ) { \
468+ register uint32_t pmc_pcr; \
469+ PMC_PCR = id; \
470+ pmc_pcr = PMC_PCR & (~PMC_PCR_DIV_MASK); \
471+ pmc_pcr |= PMC_PCR_CMD | PMC_PCR_EN; \
472+ PMC_PCR = pmc_pcr; \
473+ }
446474
447475
448476#endif
0 commit comments