1237742Simp/*- 2237742Simp * Copyright (c) 2009 Sylvestre Gallon. All rights reserved. 3237742Simp * Copyright (c) 2010 Greg Ansley. All rights reserved. 4237742Simp * Copyright (c) 2012 M. Warener Losh. All rights reserved. 5237742Simp * 6237742Simp * Redistribution and use in source and binary forms, with or without 7237742Simp * modification, are permitted provided that the following conditions 8237742Simp * are met: 9237742Simp * 1. Redistributions of source code must retain the above copyright 10237742Simp * notice, this list of conditions and the following disclaimer. 11237742Simp * 2. Redistributions in binary form must reproduce the above copyright 12237742Simp * notice, this list of conditions and the following disclaimer in the 13237742Simp * documentation and/or other materials provided with the distribution. 14237742Simp * 15237742Simp * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16237742Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17237742Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18237742Simp * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 19237742Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20237742Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21237742Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22237742Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23237742Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24237742Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25237742Simp * SUCH DAMAGE. 26237742Simp */ 27237742Simp 28237742Simp/* $FreeBSD: releng/10.2/sys/arm/at91/at91sam9x5reg.h 238922 2012-07-30 21:30:43Z imp $ */ 29237742Simp 30238922Simp#ifndef AT91SAM9X5REG_H_ 31238922Simp#define AT91SAM9X5REG_H_ 32237742Simp 33237742Simp#ifndef AT91SAM9X25_MASTER_CLOCK 34237742Simp#define AT91SAM9X25_MASTER_CLOCK ((18432000 * 43)/6) 35237742Simp#endif 36237742Simp 37237742Simp/* Chip Specific limits */ 38237742Simp#define SAM9X25_PLL_A_MIN_IN_FREQ 2000000 /* 2 Mhz */ 39237742Simp#define SAM9X25_PLL_A_MAX_IN_FREQ 32000000 /* 32 Mhz */ 40237742Simp#define SAM9X25_PLL_A_MIN_OUT_FREQ 400000000 /* 400 Mhz */ 41237742Simp#define SAM9X25_PLL_A_MAX_OUT_FREQ 800000000 /* 800 Mhz */ 42237742Simp#define SAM9X25_PLL_A_MUL_SHIFT 16 43237742Simp#define SAM9X25_PLL_A_MUL_MASK 0xFF 44237742Simp#define SAM9X25_PLL_A_DIV_SHIFT 0 45237742Simp#define SAM9X25_PLL_A_DIV_MASK 0xFF 46237742Simp 47237742Simp#define SAM9X25_PLL_B_MIN_IN_FREQ 2000000 /* 2 Mhz */ 48237742Simp#define SAM9X25_PLL_B_MAX_IN_FREQ 32000000 /* 32 Mhz */ 49237742Simp#define SAM9X25_PLL_B_MIN_OUT_FREQ 30000000 /* 30 Mhz */ 50237742Simp#define SAM9X25_PLL_B_MAX_OUT_FREQ 100000000 /* 100 Mhz */ 51237742Simp#define SAM9X25_PLL_B_MUL_SHIFT 16 52237742Simp#define SAM9X25_PLL_B_MUL_MASK 0x3F 53237742Simp#define SAM9X25_PLL_B_DIV_SHIFT 0 54237742Simp#define SAM9X25_PLL_B_DIV_MASK 0xFF 55237742Simp 56237742Simp/* 57237742Simp * Memory map, from datasheet : 58237742Simp * 0x00000000 - 0x0ffffffff : Internal Memories 59237742Simp * 0x10000000 - 0x1ffffffff : Chip Select 0 60237742Simp * 0x20000000 - 0x2ffffffff : Chip Select 1 DDR2/LPDDR/SDR/LPSDR 61237742Simp * 0x30000000 - 0x3ffffffff : Chip Select 2 62237742Simp * 0x40000000 - 0x4ffffffff : Chip Select 3 NAND Flash 63237742Simp * 0x50000000 - 0x5ffffffff : Chip Select 4 64237742Simp * 0x60000000 - 0x6ffffffff : Chip Select 5 65237742Simp * 0x70000000 - 0xeffffffff : Undefined (Abort) 66237742Simp * 0xf0000000 - 0xfffffffff : Peripherals 67237742Simp */ 68237742Simp 69237742Simp#define AT91_CHIPSELECT_0 0x10000000 70237742Simp#define AT91_CHIPSELECT_1 0x20000000 71237742Simp#define AT91_CHIPSELECT_2 0x30000000 72237742Simp#define AT91_CHIPSELECT_3 0x40000000 73237742Simp#define AT91_CHIPSELECT_4 0x50000000 74237742Simp#define AT91_CHIPSELECT_5 0x60000000 75237742Simp 76237742Simp#define AT91SAM9X25_EMAC_SIZE 0x4000 77237742Simp#define AT91SAM9X25_EMAC0_BASE 0x802c000 78237742Simp#define AT91SAM9X25_EMAC0_SIZE AT91SAM9X25_EMAC_SIZE 79237742Simp#define AT91SAM9X25_EMAC1_BASE 0x8030000 80237742Simp#define AT91SAM9X25_EMAC1_SIZE AT91SAM9X25_EMAC_SIZE 81237742Simp 82237742Simp#define AT91SAM9X25_RSTC_BASE 0xffffe00 83237742Simp#define AT91SAM9X25_RSTC_SIZE 0x10 84237742Simp 85237742Simp/* USART*/ 86237742Simp 87237742Simp#define AT91SAM9X25_USART_SIZE 0x4000 88237742Simp#define AT91SAM9X25_USART0_BASE 0x801c000 89237742Simp#define AT91SAM9X25_USART0_PDC 0x801c100 90237742Simp#define AT91SAM9X25_USART0_SIZE AT91SAM9X25_USART_SIZE 91237742Simp#define AT91SAM9X25_USART1_BASE 0x8020000 92237742Simp#define AT91SAM9X25_USART1_PDC 0x8020100 93237742Simp#define AT91SAM9X25_USART1_SIZE AT91SAM9X25_USART_SIZE 94237742Simp#define AT91SAM9X25_USART2_BASE 0x8024000 95237742Simp#define AT91SAM9X25_USART2_PDC 0x8024100 96237742Simp#define AT91SAM9X25_USART2_SIZE AT91SAM9X25_USART_SIZE 97237742Simp#define AT91SAM9X25_USART3_BASE 0x8028000 98237742Simp#define AT91SAM9X25_USART3_PDC 0x8028100 99237742Simp#define AT91SAM9X25_USART3_SIZE AT91SAM9X25_USART_SIZE 100237742Simp 101237742Simp/*TC*/ 102237742Simp#define AT91SAM9X25_TC0_BASE 0x8008000 103237742Simp#define AT91SAM9X25_TC0_SIZE 0x4000 104237742Simp#define AT91SAM9X25_TC0C0_BASE 0x8008000 105237742Simp#define AT91SAM9X25_TC0C1_BASE 0x8008040 106237742Simp#define AT91SAM9X25_TC0C2_BASE 0x8008080 107237742Simp 108237742Simp#define AT91SAM9X25_TC1_BASE 0x800c000 109237742Simp#define AT91SAM9X25_TC1_SIZE 0x4000 110237742Simp 111237742Simp/*SPI*/ 112237742Simp 113237742Simp#define AT91SAM9X25_SPI0_BASE 0x0000000 114237742Simp 115237742Simp#define AT91SAM9X25_SPI0_SIZE 0x4000 116237742Simp 117237742Simp#define AT91SAM9X25_SPI1_BASE 0x0004000 118237742Simp#define AT91SAM9X25_SPI1_SIZE 0x4000 119237742Simp 120237742Simp/* System Registers */ 121237742Simp#define AT91SAM9X25_SYS_BASE 0xffff000 122237742Simp#define AT91SAM9X25_SYS_SIZE 0x1000 123237742Simp 124237742Simp#define AT91SAM9X25_MATRIX_BASE 0xfffde00 125237742Simp#define AT91SAM9X25_MATRIX_SIZE 0x200 126237742Simp 127237742Simp#define AT91SAM9X25_DBGU_BASE 0xffff200 128237742Simp#define AT91SAM9X25_DBGU_SIZE 0x200 129237742Simp 130237742Simp/* 131237742Simp * PIO 132237742Simp */ 133237742Simp#define AT91SAM9X25_PIOA_BASE 0xffff400 134237742Simp#define AT91SAM9X25_PIOA_SIZE 0x200 135237742Simp#define AT91SAM9X25_PIOB_BASE 0xffff600 136237742Simp#define AT91SAM9X25_PIOB_SIZE 0x200 137237742Simp#define AT91SAM9X25_PIOC_BASE 0xffff800 138237742Simp#define AT91SAM9X25_PIOC_SIZE 0x200 139237744Simp#define AT91SAM9X25_PIOD_BASE 0xffffa00 140237744Simp#define AT91SAM9X25_PIOD_SIZE 0x200 141237742Simp 142237742Simp#define AT91RM92_PMC_BASE 0xffffc00 143237742Simp#define AT91RM92_PMC_SIZE 0x100 144237744Simp/* IRQs : 145237742Simp * 0: AIC 146237742Simp * 1: System peripheral (System timer, RTC, DBGU) 147237742Simp * 2: PIO Controller A,B 148237742Simp * 3: PIO Controller C,D 149237742Simp * 4: SMD Soft Modem 150237742Simp * 5: USART 0 151237742Simp * 6: USART 1 152237742Simp * 7: USART 2 153237742Simp * 8: USART 3 154237742Simp * 9: Two-wirte interface 155237742Simp * 10: Two-wirte interface 156237742Simp * 11: Two-wirte interface 157237742Simp * 12: HSMCI Interface 158237742Simp * 13: SPI 0 159237742Simp * 14: SPI 1 160237742Simp * 15: UART0 161237742Simp * 16: UART1 162237742Simp * 17: Timer Counter 0,1 163237742Simp * 18: PWM 164237742Simp * 19: ADC 165237742Simp * 20: DMAC 0 166237742Simp * 21: DMAC 1 167237742Simp * 22: UHPHS - USB Host controller 168237742Simp * 23: UDPHS - USB Device Controller 169237742Simp * 24: EMAC0 170237744Simp * 25: LCD controller or Image Sensor Interface 171237742Simp * 26: HSMCI1 172237742Simp * 27: EMAC1 173237742Simp * 28: SSC 174237742Simp * 29: CAN0 175237742Simp * 30: CAN1 176237744Simp * 31: AIC IRQ0 177237742Simp */ 178237742Simp 179237742Simp#define AT91SAM9X25_IRQ_AIC 0 180237742Simp#define AT91SAM9X25_IRQ_SYSTEM 1 181237742Simp#define AT91SAM9X25_IRQ_PIOAB 2 182237742Simp#define AT91SAM9X25_IRQ_PIOCD 3 183237742Simp#define AT91SAM9X25_IRQ_SMD 4 184237742Simp#define AT91SAM9X25_IRQ_USART0 5 185237742Simp#define AT91SAM9X25_IRQ_USART1 6 186237742Simp#define AT91SAM9X25_IRQ_USART2 7 187237742Simp#define AT91SAM9X25_IRQ_USART3 8 188237742Simp#define AT91SAM9X25_IRQ_TWI0 9 189237742Simp#define AT91SAM9X25_IRQ_TWI1 10 190237742Simp#define AT91SAM9X25_IRQ_TWI2 11 191237742Simp#define AT91SAM9X25_IRQ_HSMCI0 12 192237742Simp#define AT91SAM9X25_IRQ_SPI0 13 193237742Simp#define AT91SAM9X25_IRQ_SPI1 14 194237742Simp#define AT91SAM9X25_IRQ_UART0 15 195237742Simp#define AT91SAM9X25_IRQ_UART1 16 196237742Simp#define AT91SAM9X25_IRQ_TC01 17 197237742Simp#define AT91SAM9X25_IRQ_PWM 18 198237742Simp#define AT91SAM9X25_IRQ_ADC 19 199237742Simp#define AT91SAM9X25_IRQ_DMAC0 20 200237742Simp#define AT91SAM9X25_IRQ_DMAC1 21 201237742Simp#define AT91SAM9X25_IRQ_UHPHS 22 202237742Simp#define AT91SAM9X25_IRQ_UDPHS 23 203237742Simp#define AT91SAM9X25_IRQ_EMAC0 24 204237742Simp#define AT91SAM9X25_IRQ_HSMCI1 26 205237742Simp#define AT91SAM9X25_IRQ_EMAC1 27 206237742Simp#define AT91SAM9X25_IRQ_SSC 28 207237742Simp#define AT91SAM9X25_IRQ_CAN0 29 208237742Simp#define AT91SAM9X25_IRQ_CAN1 30 209237742Simp#define AT91SAM9X25_IRQ_AICBASE 31 210237742Simp 211237742Simp/* Alias */ 212237742Simp#define AT91SAM9X25_IRQ_DBGU AT91SAM9X25_IRQ_SYSTEM 213237742Simp#define AT91SAM9X25_IRQ_PMC AT91SAM9X25_IRQ_SYSTEM 214237742Simp#define AT91SAM9X25_IRQ_WDT AT91SAM9X25_IRQ_SYSTEM 215237742Simp#define AT91SAM9X25_IRQ_PIT AT91SAM9X25_IRQ_SYSTEM 216237742Simp#define AT91SAM9X25_IRQ_RSTC AT91SAM9X25_IRQ_SYSTEM 217237742Simp#define AT91SAM9X25_IRQ_OHCI AT91SAM9X25_IRQ_UHPHS 218237742Simp#define AT91SAM9X25_IRQ_EHCI AT91SAM9X25_IRQ_UHPHS 219237742Simp#define AT91SAM9X25_IRQ_PIOA AT91SAM9X25_IRQ_PIOAB 220237742Simp#define AT91SAM9X25_IRQ_PIOB AT91SAM9X25_IRQ_PIOAB 221237742Simp#define AT91SAM9X25_IRQ_PIOC AT91SAM9X25_IRQ_PIOCD 222237744Simp#define AT91SAM9X25_IRQ_PIOD AT91SAM9X25_IRQ_PIOCD 223237742Simp#define AT91SAM9X25_IRQ_NAND (-1) 224237742Simp 225237742Simp#define AT91SAM9X25_AIC_BASE 0xffff000 226237742Simp#define AT91SAM9X25_AIC_SIZE 0x200 227237742Simp 228237742Simp/* Timer */ 229237742Simp 230237742Simp#define AT91SAM9X25_WDT_BASE 0xffffd40 231237742Simp#define AT91SAM9X25_WDT_SIZE 0x10 232237742Simp 233237742Simp#define AT91SAM9X25_PIT_BASE 0xffffd30 234237742Simp#define AT91SAM9X25_PIT_SIZE 0x10 235237742Simp 236237742Simp#define AT91SAM9X25_SMC_BASE 0xfffea00 237237742Simp#define AT91SAM9X25_SMC_SIZE 0x200 238237742Simp 239237742Simp#define AT91SAM9X25_PMC_BASE 0xffffc00 240237742Simp#define AT91SAM9X25_PMC_SIZE 0x100 241237742Simp 242237742Simp#define AT91SAM9X25_UDPHS_BASE 0x803c000 243237742Simp#define AT91SAM9X25_UDPHS_SIZE 0x4000 244237742Simp 245237742Simp#define AT91SAM9X25_HSMCI_SIZE 0x4000 246237742Simp#define AT91SAM9X25_HSMCI0_BASE 0x0008000 247237742Simp#define AT91SAM9X25_HSMCI0_SIZE AT91SAM9X25_HSMCI_SIZE 248237742Simp#define AT91SAM9X25_HSMCI1_BASE 0x000c000 249237742Simp#define AT91SAM9X25_HSMCI1_SIZE AT91SAM9X25_HSMCI_SIZE 250237742Simp 251237742Simp#define AT91SAM9X25_TWI_SIZE 0x4000 252237742Simp#define AT91SAM9X25_TWI0_BASE 0xffaC000 253237742Simp#define AT91SAM9X25_TWI0_SIZE AT91SAM9X25_TWI_SIZE 254237742Simp#define AT91SAM9X25_TWI1_BASE 0xffaC000 255237742Simp#define AT91SAM9X25_TWI1_SIZE AT91SAM9X25_TWI_SIZE 256237742Simp#define AT91SAM9X25_TWI2_BASE 0xffaC000 257237742Simp#define AT91SAM9X25_TWI2_SIZE AT91SAM9X25_TWI_SIZE 258237742Simp 259237742Simp/* XXX Needs to be carfully coordinated with 260237742Simp * other * soc's so phyical and vm address 261237742Simp * mapping are unique. XXX 262237742Simp */ 263237742Simp#define AT91SAM9X25_OHCI_BASE 0xdfc00000 /* SAME as 9c40 */ 264237742Simp#define AT91SAM9X25_OHCI_PA_BASE 0x00600000 265237742Simp#define AT91SAM9X25_OHCI_SIZE 0x00100000 266237742Simp 267237742Simp#define AT91SAM9X25_EHCI_BASE 0xdfd00000 268237742Simp#define AT91SAM9X25_EHCI_PA_BASE 0x00700000 269237742Simp#define AT91SAM9X25_EHCI_SIZE 0x00100000 270237742Simp 271237742Simp#define AT91SAM9X25_NAND_BASE 0xe0000000 272237742Simp#define AT91SAM9X25_NAND_PA_BASE 0x40000000 273237742Simp#define AT91SAM9X25_NAND_SIZE 0x10000000 274237742Simp 275237742Simp 276237742Simp/* SDRAMC */ 277237742Simp#define AT91SAM9X25_SDRAMC_BASE 0xfffea00 /* SAME as SMC? */ 278237742Simp#define AT91SAM9X25_SDRAMC_MR 0x00 279237742Simp#define AT91SAM9X25_SDRAMC_MR_MODE_NORMAL 0 280237742Simp#define AT91SAM9X25_SDRAMC_MR_MODE_NOP 1 281237742Simp#define AT91SAM9X25_SDRAMC_MR_MODE_PRECHARGE 2 282237742Simp#define AT91SAM9X25_SDRAMC_MR_MODE_LOAD_MODE_REGISTER 3 283237742Simp#define AT91SAM9X25_SDRAMC_MR_MODE_REFRESH 4 284237742Simp#define AT91SAM9X25_SDRAMC_TR 0x04 285237742Simp#define AT91SAM9X25_SDRAMC_CR 0x08 286237742Simp#define AT91SAM9X25_SDRAMC_CR_NC_8 0x0 287237742Simp#define AT91SAM9X25_SDRAMC_CR_NC_9 0x1 288237742Simp#define AT91SAM9X25_SDRAMC_CR_NC_10 0x2 289237742Simp#define AT91SAM9X25_SDRAMC_CR_NC_11 0x3 290237742Simp#define AT91SAM9X25_SDRAMC_CR_NC_MASK 0x00000003 291237742Simp#define AT91SAM9X25_SDRAMC_CR_NR_11 0x0 292237742Simp#define AT91SAM9X25_SDRAMC_CR_NR_12 0x4 293237742Simp#define AT91SAM9X25_SDRAMC_CR_NR_13 0x8 294237742Simp#define AT91SAM9X25_SDRAMC_CR_NR_RES 0xc 295237742Simp#define AT91SAM9X25_SDRAMC_CR_NR_MASK 0x0000000c 296237742Simp#define AT91SAM9X25_SDRAMC_CR_NB_2 0x00 297237742Simp#define AT91SAM9X25_SDRAMC_CR_NB_4 0x10 298237742Simp#define AT91SAM9X25_SDRAMC_CR_DBW_16 0x80 299237742Simp#define AT91SAM9X25_SDRAMC_CR_NB_MASK 0x00000010 300237742Simp#define AT91SAM9X25_SDRAMC_CR_NCAS_MASK 0x00000060 301237742Simp#define AT91SAM9X25_SDRAMC_CR_TWR_MASK 0x00000780 302237742Simp#define AT91SAM9X25_SDRAMC_CR_TRC_MASK 0x00007800 303237742Simp#define AT91SAM9X25_SDRAMC_CR_TRP_MASK 0x00078000 304237742Simp#define AT91SAM9X25_SDRAMC_CR_TRCD_MASK 0x00780000 305237742Simp#define AT91SAM9X25_SDRAMC_CR_TRAS_MASK 0x07800000 306237742Simp#define AT91SAM9X25_SDRAMC_CR_TXSR_MASK 0x78000000 307237742Simp#define AT91SAM9X25_SDRAMC_HSR 0x0c 308237742Simp#define AT91SAM9X25_SDRAMC_LPR 0x10 309237742Simp#define AT91SAM9X25_SDRAMC_IER 0x14 310237742Simp#define AT91SAM9X25_SDRAMC_IDR 0x18 311237742Simp#define AT91SAM9X25_SDRAMC_IMR 0x1c 312237742Simp#define AT91SAM9X25_SDRAMC_ISR 0x20 313237742Simp#define AT91SAM9X25_SDRAMC_MDR 0x24 314237742Simp 315238922Simp#endif /* AT91SAM9X5REG_H_*/ 316