| 1 | #ifndef _AR7240_H |
|---|
| 2 | #define _AR7240_H |
|---|
| 3 | |
|---|
| 4 | #include <asm/addrspace.h> |
|---|
| 5 | |
|---|
| 6 | typedef unsigned int ar7240_reg_t; |
|---|
| 7 | |
|---|
| 8 | #define ar7240_reg_rd(_phys) (*(volatile ar7240_reg_t *)KSEG1ADDR(_phys)) |
|---|
| 9 | #define ar7240_reg_wr_nf(_phys, _val) \ |
|---|
| 10 | ((*(volatile ar7240_reg_t *)KSEG1ADDR(_phys)) = (_val)) |
|---|
| 11 | |
|---|
| 12 | #define ar7240_reg_wr(_phys, _val) do { \ |
|---|
| 13 | ar7240_reg_wr_nf(_phys, _val); \ |
|---|
| 14 | ar7240_reg_rd(_phys); \ |
|---|
| 15 | }while(0); |
|---|
| 16 | |
|---|
| 17 | #define ar7240_reg_rmw_set(_reg, _mask) do { \ |
|---|
| 18 | ar7240_reg_wr((_reg), (ar7240_reg_rd((_reg)) | (_mask))); \ |
|---|
| 19 | ar7240_reg_rd((_reg)); \ |
|---|
| 20 | }while(0); |
|---|
| 21 | |
|---|
| 22 | #define ar7240_reg_rmw_clear(_reg, _mask) do { \ |
|---|
| 23 | ar7240_reg_wr((_reg), (ar7240_reg_rd((_reg)) & ~(_mask))); \ |
|---|
| 24 | ar7240_reg_rd((_reg)); \ |
|---|
| 25 | }while(0); |
|---|
| 26 | |
|---|
| 27 | /* |
|---|
| 28 | * Address map |
|---|
| 29 | */ |
|---|
| 30 | #define AR7240_PCI_MEM_BASE 0x10000000 /* 128M */ |
|---|
| 31 | #define AR7240_APB_BASE 0x18000000 /* 384M */ |
|---|
| 32 | #define AR7240_GE0_BASE 0x19000000 /* 16M */ |
|---|
| 33 | #define AR7240_GE1_BASE 0x1a000000 /* 16M */ |
|---|
| 34 | #define AR7240_USB_OHCI_BASE 0x1b000000 |
|---|
| 35 | #define AR7240_USB_EHCI_BASE 0x1b000000 |
|---|
| 36 | #define AR7240_SPI_BASE 0x1f000000 |
|---|
| 37 | |
|---|
| 38 | /* |
|---|
| 39 | * Added the PCI LCL RESET register from u-boot |
|---|
| 40 | * ar7240_soc.h so that we can query the PCI LCL RESET |
|---|
| 41 | * register for the presence of WLAN H/W. |
|---|
| 42 | */ |
|---|
| 43 | #define AR7240_PCI_LCL_BASE (AR7240_APB_BASE+0x000f0000) |
|---|
| 44 | #define AR7240_PCI_LCL_APP (AR7240_PCI_LCL_BASE+0x00) |
|---|
| 45 | #define AR7240_PCI_LCL_RESET (AR7240_PCI_LCL_BASE+0x18) |
|---|
| 46 | |
|---|
| 47 | /* |
|---|
| 48 | * APB block |
|---|
| 49 | */ |
|---|
| 50 | #define AR7240_DDR_CTL_BASE AR7240_APB_BASE+0x00000000 |
|---|
| 51 | #define AR7240_CPU_BASE AR7240_APB_BASE+0x00010000 |
|---|
| 52 | #define AR7240_UART_BASE AR7240_APB_BASE+0x00020000 |
|---|
| 53 | #define AR7240_USB_CONFIG_BASE AR7240_APB_BASE+0x00030000 |
|---|
| 54 | #define AR7240_GPIO_BASE AR7240_APB_BASE+0x00040000 |
|---|
| 55 | #define AR7240_PLL_BASE AR7240_APB_BASE+0x00050000 |
|---|
| 56 | #define AR7240_RESET_BASE AR7240_APB_BASE+0x00060000 |
|---|
| 57 | #define AR7240_SLIC_BASE AR7240_APB_BASE+0x00090000 |
|---|
| 58 | #define AR7240_DMA_BASE AR7240_APB_BASE+0x000A0000 |
|---|
| 59 | #define AR7240_STEREO_BASE AR7240_APB_BASE+0x000B0000 |
|---|
| 60 | #define AR7240_PCI_CTLR_BASE AR7240_APB_BASE+0x000F0000 |
|---|
| 61 | |
|---|
| 62 | /* |
|---|
| 63 | * DDR block |
|---|
| 64 | */ |
|---|
| 65 | #define AR7240_DDR_CONFIG AR7240_DDR_CTL_BASE+0 |
|---|
| 66 | #define AR7240_DDR_CONFIG2 AR7240_DDR_CTL_BASE+4 |
|---|
| 67 | #define AR7240_DDR_MODE AR7240_DDR_CTL_BASE+0x08 |
|---|
| 68 | #define AR7240_DDR_EXT_MODE AR7240_DDR_CTL_BASE+0x0c |
|---|
| 69 | #define AR7240_DDR_CONTROL AR7240_DDR_CTL_BASE+0x10 |
|---|
| 70 | #define AR7240_DDR_REFRESH AR7240_DDR_CTL_BASE+0x14 |
|---|
| 71 | #define AR7240_DDR_RD_DATA_THIS_CYCLE AR7240_DDR_CTL_BASE+0x18 |
|---|
| 72 | #define AR7240_DDR_TAP_CONTROL0 AR7240_DDR_CTL_BASE+0x1c |
|---|
| 73 | #define AR7240_DDR_TAP_CONTROL1 AR7240_DDR_CTL_BASE+0x20 |
|---|
| 74 | #define AR7240_DDR_TAP_CONTROL2 AR7240_DDR_CTL_BASE+0x24 |
|---|
| 75 | #define AR7240_DDR_TAP_CONTROL3 AR7240_DDR_CTL_BASE+0x28 |
|---|
| 76 | |
|---|
| 77 | /* |
|---|
| 78 | * DDR Config values |
|---|
| 79 | */ |
|---|
| 80 | #define AR7240_DDR_CONFIG_16BIT (1 << 31) |
|---|
| 81 | #define AR7240_DDR_CONFIG_PAGE_OPEN (1 << 30) |
|---|
| 82 | #define AR7240_DDR_CONFIG_CAS_LAT_SHIFT 27 |
|---|
| 83 | #define AR7240_DDR_CONFIG_TMRD_SHIFT 23 |
|---|
| 84 | #define AR7240_DDR_CONFIG_TRFC_SHIFT 17 |
|---|
| 85 | #define AR7240_DDR_CONFIG_TRRD_SHIFT 13 |
|---|
| 86 | #define AR7240_DDR_CONFIG_TRP_SHIFT 9 |
|---|
| 87 | #define AR7240_DDR_CONFIG_TRCD_SHIFT 5 |
|---|
| 88 | #define AR7240_DDR_CONFIG_TRAS_SHIFT 0 |
|---|
| 89 | |
|---|
| 90 | #define AR7240_DDR_CONFIG2_BL2 (2 << 0) |
|---|
| 91 | #define AR7240_DDR_CONFIG2_BL4 (4 << 0) |
|---|
| 92 | #define AR7240_DDR_CONFIG2_BL8 (8 << 0) |
|---|
| 93 | |
|---|
| 94 | #define AR7240_DDR_CONFIG2_BT_IL (1 << 4) |
|---|
| 95 | #define AR7240_DDR_CONFIG2_CNTL_OE_EN (1 << 5) |
|---|
| 96 | #define AR7240_DDR_CONFIG2_PHASE_SEL (1 << 6) |
|---|
| 97 | #define AR7240_DDR_CONFIG2_DRAM_CKE (1 << 7) |
|---|
| 98 | #define AR7240_DDR_CONFIG2_TWR_SHIFT 8 |
|---|
| 99 | #define AR7240_DDR_CONFIG2_TRTW_SHIFT 12 |
|---|
| 100 | #define AR7240_DDR_CONFIG2_TRTP_SHIFT 17 |
|---|
| 101 | #define AR7240_DDR_CONFIG2_TWTR_SHIFT 21 |
|---|
| 102 | #define AR7240_DDR_CONFIG2_HALF_WIDTH_L (1 << 31) |
|---|
| 103 | |
|---|
| 104 | #define AR7240_DDR_TAP_DEFAULT 0x18 |
|---|
| 105 | |
|---|
| 106 | /* |
|---|
| 107 | * DDR block, gmac flushing |
|---|
| 108 | */ |
|---|
| 109 | #define AR7240_DDR_GE0_FLUSH AR7240_DDR_CTL_BASE+0x7c |
|---|
| 110 | #define AR7240_DDR_GE1_FLUSH AR7240_DDR_CTL_BASE+0x80 |
|---|
| 111 | #define AR7240_DDR_USB_FLUSH AR7240_DDR_CTL_BASE+0xa4 |
|---|
| 112 | #define AR7240_DDR_PCIE_FLUSH AR7240_DDR_CTL_BASE+0x88 |
|---|
| 113 | |
|---|
| 114 | #define AR7240_EEPROM_GE0_MAC_ADDR 0xbfff1000 |
|---|
| 115 | #define AR7240_EEPROM_GE1_MAC_ADDR 0xbfff1006 |
|---|
| 116 | |
|---|
| 117 | /* |
|---|
| 118 | * PLL block/CPU |
|---|
| 119 | */ |
|---|
| 120 | |
|---|
| 121 | #define AR7240_PLL_CONFIG AR7240_PLL_BASE+0x0 |
|---|
| 122 | |
|---|
| 123 | |
|---|
| 124 | #define PLL_DIV_SHIFT 0 |
|---|
| 125 | #define PLL_DIV_MASK 0x3ff |
|---|
| 126 | #define REF_DIV_SHIFT 10 |
|---|
| 127 | #define REF_DIV_MASK 0xf |
|---|
| 128 | #define AHB_DIV_SHIFT 19 |
|---|
| 129 | #define AHB_DIV_MASK 0x1 |
|---|
| 130 | #define DDR_DIV_SHIFT 22 |
|---|
| 131 | #define DDR_DIV_MASK 0x1 |
|---|
| 132 | #define AR7240_ETH_PLL_CONFIG AR7240_PLL_BASE+0x4 |
|---|
| 133 | |
|---|
| 134 | #define AR7240_ETH_INT0_CLK AR7240_PLL_BASE+0x14 |
|---|
| 135 | #define AR7240_ETH_INT1_CLK AR7240_PLL_BASE+0x18 |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | /* |
|---|
| 139 | * USB block |
|---|
| 140 | */ |
|---|
| 141 | #define AR7240_USB_FLADJ_VAL AR7240_USB_CONFIG_BASE |
|---|
| 142 | #define AR7240_USB_CONFIG AR7240_USB_CONFIG_BASE+0x4 |
|---|
| 143 | #define AR7240_USB_WINDOW 0x1000000 |
|---|
| 144 | #define AR7240_USB_MODE AR7240_USB_EHCI_BASE+0x1a8 |
|---|
| 145 | |
|---|
| 146 | /* |
|---|
| 147 | * PCI block |
|---|
| 148 | */ |
|---|
| 149 | #define AR7240_PCI_WINDOW 0x8000000 /* 128MB */ |
|---|
| 150 | #define AR7240_PCI_WINDOW0_OFFSET AR7240_DDR_CTL_BASE+0x7c |
|---|
| 151 | #define AR7240_PCI_WINDOW1_OFFSET AR7240_DDR_CTL_BASE+0x80 |
|---|
| 152 | #define AR7240_PCI_WINDOW2_OFFSET AR7240_DDR_CTL_BASE+0x84 |
|---|
| 153 | #define AR7240_PCI_WINDOW3_OFFSET AR7240_DDR_CTL_BASE+0x88 |
|---|
| 154 | #define AR7240_PCI_WINDOW4_OFFSET AR7240_DDR_CTL_BASE+0x8c |
|---|
| 155 | #define AR7240_PCI_WINDOW5_OFFSET AR7240_DDR_CTL_BASE+0x90 |
|---|
| 156 | #define AR7240_PCI_WINDOW6_OFFSET AR7240_DDR_CTL_BASE+0x94 |
|---|
| 157 | #define AR7240_PCI_WINDOW7_OFFSET AR7240_DDR_CTL_BASE+0x98 |
|---|
| 158 | |
|---|
| 159 | #define AR7240_PCI_WINDOW0_VAL 0x10000000 |
|---|
| 160 | #define AR7240_PCI_WINDOW1_VAL 0x11000000 |
|---|
| 161 | #define AR7240_PCI_WINDOW2_VAL 0x12000000 |
|---|
| 162 | #define AR7240_PCI_WINDOW3_VAL 0x13000000 |
|---|
| 163 | #define AR7240_PCI_WINDOW4_VAL 0x14000000 |
|---|
| 164 | #define AR7240_PCI_WINDOW5_VAL 0x15000000 |
|---|
| 165 | #define AR7240_PCI_WINDOW6_VAL 0x16000000 |
|---|
| 166 | #define AR7240_PCI_WINDOW7_VAL 0x07000000 |
|---|
| 167 | |
|---|
| 168 | #define ar7240_write_pci_window(_no) \ |
|---|
| 169 | ar7240_reg_wr(AR7240_PCI_WINDOW##_no##_OFFSET, AR7240_PCI_WINDOW##_no##_VAL); |
|---|
| 170 | |
|---|
| 171 | /* |
|---|
| 172 | * CRP. To access the host controller config and status registers |
|---|
| 173 | */ |
|---|
| 174 | #define AR7240_PCI_CRP 0x180c0000 |
|---|
| 175 | #define AR7240_PCI_DEV_CFGBASE 0x14000000 |
|---|
| 176 | #define AR7240_PCI_CRP_AD_CBE AR7240_PCI_CRP |
|---|
| 177 | #define AR7240_PCI_CRP_WRDATA AR7240_PCI_CRP+0x4 |
|---|
| 178 | #define AR7240_PCI_CRP_RDDATA AR7240_PCI_CRP+0x8 |
|---|
| 179 | #define AR7240_PCI_ERROR AR7240_PCI_CRP+0x1c |
|---|
| 180 | #define AR7240_PCI_ERROR_ADDRESS AR7240_PCI_CRP+0x20 |
|---|
| 181 | #define AR7240_PCI_AHB_ERROR AR7240_PCI_CRP+0x24 |
|---|
| 182 | #define AR7240_PCI_AHB_ERROR_ADDRESS AR7240_PCI_CRP+0x28 |
|---|
| 183 | |
|---|
| 184 | #define AR7240_CRP_CMD_WRITE 0x00010000 |
|---|
| 185 | #define AR7240_CRP_CMD_READ 0x00000000 |
|---|
| 186 | |
|---|
| 187 | /* |
|---|
| 188 | * PCI CFG. To generate config cycles |
|---|
| 189 | */ |
|---|
| 190 | #define AR7240_PCI_CFG_AD AR7240_PCI_CRP+0xc |
|---|
| 191 | #define AR7240_PCI_CFG_CBE AR7240_PCI_CRP+0x10 |
|---|
| 192 | #define AR7240_PCI_CFG_WRDATA AR7240_PCI_CRP+0x14 |
|---|
| 193 | #define AR7240_PCI_CFG_RDDATA AR7240_PCI_CRP+0x18 |
|---|
| 194 | #define AR7240_CFG_CMD_READ 0x0000000a |
|---|
| 195 | #define AR7240_CFG_CMD_WRITE 0x0000000b |
|---|
| 196 | |
|---|
| 197 | #define AR7240_PCI_IDSEL_ADLINE_START 17 |
|---|
| 198 | |
|---|
| 199 | |
|---|
| 200 | /* |
|---|
| 201 | * gpio configs |
|---|
| 202 | */ |
|---|
| 203 | #define AR7240_GPIO_OE AR7240_GPIO_BASE+0x0 |
|---|
| 204 | #define AR7240_GPIO_IN AR7240_GPIO_BASE+0x4 |
|---|
| 205 | #define AR7240_GPIO_OUT AR7240_GPIO_BASE+0x8 |
|---|
| 206 | #define AR7240_GPIO_SET AR7240_GPIO_BASE+0xc |
|---|
| 207 | #define AR7240_GPIO_CLEAR AR7240_GPIO_BASE+0x10 |
|---|
| 208 | #define AR7240_GPIO_INT_ENABLE AR7240_GPIO_BASE+0x14 |
|---|
| 209 | #define AR7240_GPIO_INT_TYPE AR7240_GPIO_BASE+0x18 |
|---|
| 210 | #define AR7240_GPIO_INT_POLARITY AR7240_GPIO_BASE+0x1c |
|---|
| 211 | #define AR7240_GPIO_INT_PENDING AR7240_GPIO_BASE+0x20 |
|---|
| 212 | #define AR7240_GPIO_INT_MASK AR7240_GPIO_BASE+0x24 |
|---|
| 213 | #define AR7240_GPIO_FUNCTIONS AR7240_GPIO_BASE+0x28 |
|---|
| 214 | |
|---|
| 215 | /* |
|---|
| 216 | * IRQ Map. |
|---|
| 217 | * There are 4 conceptual ICs in the system. We generally give a block of 16 |
|---|
| 218 | * irqs to each IC. |
|---|
| 219 | * CPU: 0 - 0xf |
|---|
| 220 | * MISC: 0x10 - 0x1f |
|---|
| 221 | * GPIO: 0x20 - 0x2f |
|---|
| 222 | * PCI : 0x30 - 0x40 |
|---|
| 223 | * |
|---|
| 224 | */ |
|---|
| 225 | #define AR7240_CPU_IRQ_BASE 0x00 |
|---|
| 226 | #define AR7240_MISC_IRQ_BASE 0x10 |
|---|
| 227 | #define AR7240_GPIO_IRQ_BASE 0x20 |
|---|
| 228 | #define AR7240_PCI_IRQ_BASE 0x30 |
|---|
| 229 | |
|---|
| 230 | /* |
|---|
| 231 | * The IPs. Connected to CPU (hardware IP's; the first two are software) |
|---|
| 232 | */ |
|---|
| 233 | #define AR7240_CPU_IRQ_PCI AR7240_CPU_IRQ_BASE+2 |
|---|
| 234 | #define AR7240_CPU_IRQ_USB AR7240_CPU_IRQ_BASE+3 |
|---|
| 235 | #define AR7240_CPU_IRQ_GE0 AR7240_CPU_IRQ_BASE+4 |
|---|
| 236 | #define AR7240_CPU_IRQ_GE1 AR7240_CPU_IRQ_BASE+5 |
|---|
| 237 | #define AR7240_CPU_IRQ_MISC AR7240_CPU_IRQ_BASE+6 |
|---|
| 238 | #define AR7240_CPU_IRQ_TIMER AR7240_CPU_IRQ_BASE+7 |
|---|
| 239 | |
|---|
| 240 | /* |
|---|
| 241 | * Interrupts connected to the CPU->Misc line. |
|---|
| 242 | */ |
|---|
| 243 | #define AR7240_MISC_IRQ_TIMER AR7240_MISC_IRQ_BASE+0 |
|---|
| 244 | #define AR7240_MISC_IRQ_ERROR AR7240_MISC_IRQ_BASE+1 |
|---|
| 245 | #define AR7240_MISC_IRQ_GPIO AR7240_MISC_IRQ_BASE+2 |
|---|
| 246 | #define AR7240_MISC_IRQ_UART AR7240_MISC_IRQ_BASE+3 |
|---|
| 247 | #define AR7240_MISC_IRQ_WATCHDOG AR7240_MISC_IRQ_BASE+4 |
|---|
| 248 | #define AR7240_MISC_IRQ_PERF_COUNTER AR7240_MISC_IRQ_BASE+5 |
|---|
| 249 | #define AR7240_MISC_IRQ_USB_OHCI AR7240_MISC_IRQ_BASE+6 |
|---|
| 250 | #define AR7240_MISC_IRQ_DMA AR7240_MISC_IRQ_BASE+7 |
|---|
| 251 | #define AR7240_MISC_IRQ_ENET_LINK AR7240_MISC_IRQ_BASE+12 |
|---|
| 252 | |
|---|
| 253 | #define AR7240_MISC_IRQ_COUNT 13 |
|---|
| 254 | |
|---|
| 255 | #define MIMR_TIMER 0x01 |
|---|
| 256 | #define MIMR_ERROR 0x02 |
|---|
| 257 | #define MIMR_GPIO 0x04 |
|---|
| 258 | #define MIMR_UART 0x08 |
|---|
| 259 | #define MIMR_WATCHDOG 0x10 |
|---|
| 260 | #define MIMR_PERF_COUNTER 0x20 |
|---|
| 261 | #define MIMR_OHCI_USB 0x40 |
|---|
| 262 | #define MIMR_DMA 0x80 |
|---|
| 263 | #define MIMR_ENET_LINK 0x1000 |
|---|
| 264 | |
|---|
| 265 | #define MISR_TIMER MIMR_TIMER |
|---|
| 266 | #define MISR_ERROR MIMR_ERROR |
|---|
| 267 | #define MISR_GPIO MIMR_GPIO |
|---|
| 268 | #define MISR_UART MIMR_UART |
|---|
| 269 | #define MISR_WATCHDOG MIMR_WATCHDOG |
|---|
| 270 | #define MISR_PERF_COUNTER MIMR_PERF_COUNTER |
|---|
| 271 | #define MISR_OHCI_USB MIMR_OHCI_USB |
|---|
| 272 | #define MISR_DMA MIMR_DMA |
|---|
| 273 | |
|---|
| 274 | /* |
|---|
| 275 | * Interrupts connected to the Misc->GPIO line |
|---|
| 276 | */ |
|---|
| 277 | #define AR7240_GPIO_IRQn(_gpio) AR7240_GPIO_IRQ_BASE+(_gpio) |
|---|
| 278 | #define AR7240_GPIO_IRQ_COUNT 16 |
|---|
| 279 | |
|---|
| 280 | void ar7240_gpio_irq_init(int irq_base); |
|---|
| 281 | |
|---|
| 282 | void ar7240_misc_enable_irq (unsigned int mask); |
|---|
| 283 | void ar7240_misc_disable_irq (unsigned int mask); |
|---|
| 284 | |
|---|
| 285 | unsigned int ar7240_misc_get_irq_mask (void); |
|---|
| 286 | unsigned int ar7240_misc_get_irq_status (void); |
|---|
| 287 | |
|---|
| 288 | |
|---|
| 289 | /* Interrupts connected to CPU->PCI */ |
|---|
| 290 | #ifdef CONFIG_PERICOM |
|---|
| 291 | # define AR7240_PRI_BUS_NO 0u |
|---|
| 292 | # define AR7240_PORT0_BUS_NO 1u |
|---|
| 293 | # define AR7240_PORT1_BUS_NO 2u |
|---|
| 294 | # define AR7240_PCI_IRQ_DEV0 (AR7240_PCI_IRQ_BASE + 0) |
|---|
| 295 | # define AR7240_PCI_IRQ_DEV1 (AR7240_PCI_IRQ_BASE + 1) |
|---|
| 296 | # define AR7240_PCI_IRQ_COUNT 2 |
|---|
| 297 | #else |
|---|
| 298 | # define AR7240_PCI_IRQ_DEV0 AR7240_PCI_IRQ_BASE+0 |
|---|
| 299 | # define AR7240_PCI_IRQ_COUNT 1 |
|---|
| 300 | #endif /* CONFIG_PERICOM */ |
|---|
| 301 | |
|---|
| 302 | /* |
|---|
| 303 | * PCI interrupt mask and status |
|---|
| 304 | */ |
|---|
| 305 | #define PIMR_DEV0 0x01 |
|---|
| 306 | #define PIMR_DEV1 0x02 |
|---|
| 307 | #define PIMR_DEV2 0x04 |
|---|
| 308 | #define PIMR_CORE 0x10 |
|---|
| 309 | |
|---|
| 310 | #define PISR_DEV0 PIMR_DEV0 |
|---|
| 311 | #define PISR_DEV1 PIMR_DEV1 |
|---|
| 312 | #define PISR_DEV2 PIMR_DEV2 |
|---|
| 313 | #define PISR_CORE PIMR_CORE |
|---|
| 314 | |
|---|
| 315 | void ar7240_pci_irq_init(int irq_base); /* ??? */ |
|---|
| 316 | |
|---|
| 317 | |
|---|
| 318 | #define AR7240_GPIO_COUNT 64 |
|---|
| 319 | |
|---|
| 320 | /* |
|---|
| 321 | * GPIO Function Enables |
|---|
| 322 | */ |
|---|
| 323 | #define AR7240_GPIO_FUNCTION_STEREO_EN (1<<17) |
|---|
| 324 | #define AR7240_GPIO_FUNCTION_SLIC_EN (1<<16) |
|---|
| 325 | #define AR7240_GPIO_FUNCTION_SPI_CS_1_EN (1<<15) |
|---|
| 326 | #define AR7240_GPIO_FUNCTION_SPI_CS_0_EN (1<<14) |
|---|
| 327 | #define AR7240_GPIO_FUNCTION_UART_EN (1<< 8) |
|---|
| 328 | #define AR7240_GPIO_FUNCTION_OVERCURRENT_EN (1<< 4) |
|---|
| 329 | #define AR7240_GPIO_FUNCTION_USB_CLK_CORE_EN (1<< 0) |
|---|
| 330 | #define AR7240_GPIO_FUNCTION_WMAC_LED (1<<22) |
|---|
| 331 | |
|---|
| 332 | /* |
|---|
| 333 | * GPIO Access & Control |
|---|
| 334 | */ |
|---|
| 335 | void ar7240_gpio_init(void); |
|---|
| 336 | void ar7240_gpio_down(void); |
|---|
| 337 | void ar7240_gpio_up(void); |
|---|
| 338 | |
|---|
| 339 | /* |
|---|
| 340 | * GPIO Helper Functions |
|---|
| 341 | */ |
|---|
| 342 | void ar7240_gpio_enable_slic(void); |
|---|
| 343 | |
|---|
| 344 | /* enable UART block, takes away GPIO 10 and 9 */ |
|---|
| 345 | void ar7240_gpio_enable_uart(void); |
|---|
| 346 | |
|---|
| 347 | /* enable STEREO block, takes away GPIO 11,8,7, and 6 */ |
|---|
| 348 | void ar7240_gpio_enable_stereo(void); |
|---|
| 349 | |
|---|
| 350 | /* allow CS0/CS1 to be controlled via SPI register, takes away GPIO0/GPIO1 */ |
|---|
| 351 | void ar7240_gpio_enable_spi_cs1_cs0(void); |
|---|
| 352 | |
|---|
| 353 | /* allow GPIO0/GPIO1 to be used as SCL/SDA for software based i2c */ |
|---|
| 354 | void ar7240_gpio_enable_i2c_on_gpio_0_1(void); |
|---|
| 355 | |
|---|
| 356 | /* |
|---|
| 357 | * GPIO General Functions |
|---|
| 358 | */ |
|---|
| 359 | void ar7240_gpio_drive_low(unsigned int mask); |
|---|
| 360 | void ar7240_gpio_drive_high(unsigned int mask); |
|---|
| 361 | |
|---|
| 362 | unsigned int ar7240_gpio_float_high_test(unsigned int mask); |
|---|
| 363 | |
|---|
| 364 | /* |
|---|
| 365 | * Software support of i2c on gpio 0/1 |
|---|
| 366 | */ |
|---|
| 367 | int ar7240_i2c_raw_write_bytes_to_addr(int addr, unsigned char *buffer, int count); |
|---|
| 368 | int ar7240_i2c_raw_read_bytes_from_addr(int addr, unsigned char *buffer, int count); |
|---|
| 369 | |
|---|
| 370 | /* SPI, SLIC and GPIO are all multiplexed on gpio pins */ |
|---|
| 371 | #define AR7240_SPI_FS AR7240_SPI_BASE |
|---|
| 372 | #define AR7240_SPI_READ AR7240_SPI_BASE |
|---|
| 373 | #define AR7240_SPI_CLOCK AR7240_SPI_BASE+4 |
|---|
| 374 | #define AR7240_SPI_WRITE AR7240_SPI_BASE+8 |
|---|
| 375 | #define AR7240_SPI_RD_STATUS AR7240_SPI_BASE+12 |
|---|
| 376 | #define AR7240_SPI_D0_HIGH (1<<0) /* Pin spi_do */ |
|---|
| 377 | #define AR7240_SPI_CLK_HIGH (1<<8) /* Pin spi_clk */ |
|---|
| 378 | |
|---|
| 379 | #define AR7240_SPI_CS_ENABLE_0 (6<<16) /* Pin gpio/cs0 (active low) */ |
|---|
| 380 | #define AR7240_SPI_CS_ENABLE_1 (5<<16) /* Pin gpio/cs1 (active low) */ |
|---|
| 381 | #define AR7240_SPI_CS_ENABLE_2 (3<<16) /* Pin gpio/cs2 (active low) */ |
|---|
| 382 | //#define AR7240_SPI_CS_DIS (AR7240_SPI_CS_ENABLE_0|AR7240_SPI_CS_ENABLE_1|AR7240_SPI_CS_ENABLE_2) |
|---|
| 383 | #define AR7240_SPI_CS_DIS 0x70000 |
|---|
| 384 | |
|---|
| 385 | |
|---|
| 386 | #define AR7240_SPI_RD_STATUS AR7240_SPI_BASE+12 /* spi_di is clocked into register pos 0 every clock */ |
|---|
| 387 | /* |
|---|
| 388 | * SOC |
|---|
| 389 | */ |
|---|
| 390 | #define AR7240_SPI_CMD_WREN 0x06 |
|---|
| 391 | #define AR7240_SPI_CMD_RD_STATUS 0x05 |
|---|
| 392 | #define AR7240_SPI_CMD_FAST_READ 0x0b |
|---|
| 393 | #define AR7240_SPI_CMD_PAGE_PROG 0x02 |
|---|
| 394 | #define AR7240_SPI_CMD_SECTOR_ERASE 0xd8 |
|---|
| 395 | |
|---|
| 396 | /* Functions to access SPI through software. Example: |
|---|
| 397 | * |
|---|
| 398 | * ar7240_spi_down(); ---------------------- disable others from accessing SPI bus taking semaphore |
|---|
| 399 | * ar7240_spi_enable_soft_access(); -------- disable HW control of SPI |
|---|
| 400 | * |
|---|
| 401 | * <board specific chip select routine> |
|---|
| 402 | * |
|---|
| 403 | * <read/write SPI using using custom routine or general purposeflash routines |
|---|
| 404 | * Custom routine may use: |
|---|
| 405 | * |
|---|
| 406 | * ar7240_spi_raw_output_u8(unsigned char) |
|---|
| 407 | * ar7240_spi_raw_output_u32(unsigned int) |
|---|
| 408 | * ar7240_spi_raw_input_u32() |
|---|
| 409 | * |
|---|
| 410 | * General purpose flash routines: |
|---|
| 411 | * ar7240_spi_flash_read_page(unsigned int addr, unsigned char *data, int len); |
|---|
| 412 | * ar7240_spi_flash_write_page(unsigned int addr, unsigned char *data, int len); |
|---|
| 413 | * ar7240_spi_flash_sector_erase(unsigned int addr); |
|---|
| 414 | * > |
|---|
| 415 | * |
|---|
| 416 | * <board specific chip deselect routine> |
|---|
| 417 | * |
|---|
| 418 | * ar7240_spi_disable_soft_acess(); ------- enable HW control of SPI bus |
|---|
| 419 | * ar7240_spi_up(); ----------------------- enable others to access SPI bus releasing semaphore |
|---|
| 420 | */ |
|---|
| 421 | void ar7240_spi_init(void); |
|---|
| 422 | void ar7240_spi_down(void); |
|---|
| 423 | void ar7240_spi_up(void); |
|---|
| 424 | |
|---|
| 425 | static inline void |
|---|
| 426 | ar7240_spi_enable_soft_access(void) |
|---|
| 427 | { |
|---|
| 428 | ar7240_reg_wr_nf(AR7240_SPI_FS, 1); |
|---|
| 429 | } |
|---|
| 430 | |
|---|
| 431 | static inline void |
|---|
| 432 | ar7240_spi_disable_soft_access(void) |
|---|
| 433 | { |
|---|
| 434 | ar7240_reg_wr_nf(AR7240_SPI_WRITE, AR7240_SPI_CS_DIS); |
|---|
| 435 | ar7240_reg_wr_nf(AR7240_SPI_FS, 0); |
|---|
| 436 | } |
|---|
| 437 | |
|---|
| 438 | void ar7240_spi_raw_output_u8(unsigned char val); |
|---|
| 439 | void ar7240_spi_raw_output_u32(unsigned int val); |
|---|
| 440 | unsigned int ar7240_spi_raw_input_u32(void); |
|---|
| 441 | |
|---|
| 442 | #define AR7240_SPI_SECTOR_SIZE (1024*64) |
|---|
| 443 | |
|---|
| 444 | void ar7240_spi_flash_read_page(unsigned int addr, unsigned char *data, int len); |
|---|
| 445 | void ar7240_spi_flash_write_page(unsigned int addr, unsigned char *data, int len); |
|---|
| 446 | void ar7240_spi_flash_sector_erase(unsigned int addr); |
|---|
| 447 | |
|---|
| 448 | /* |
|---|
| 449 | * Allow access to cs0-2 when GPIO Function enables cs0-2 through SPI register. |
|---|
| 450 | */ |
|---|
| 451 | static inline void ar7240_spi_enable_cs0(void) |
|---|
| 452 | { |
|---|
| 453 | unsigned int cs; |
|---|
| 454 | ar7240_spi_down(); |
|---|
| 455 | ar7240_spi_enable_soft_access(); |
|---|
| 456 | cs = ar7240_reg_rd(AR7240_SPI_WRITE) & ~AR7240_SPI_CS_DIS; |
|---|
| 457 | ar7240_reg_wr_nf(AR7240_SPI_WRITE, AR7240_SPI_CS_ENABLE_0 | cs); |
|---|
| 458 | } |
|---|
| 459 | |
|---|
| 460 | static inline void ar7240_spi_enable_cs1(void) |
|---|
| 461 | { |
|---|
| 462 | unsigned int cs; |
|---|
| 463 | ar7240_spi_down(); |
|---|
| 464 | ar7240_spi_enable_soft_access(); |
|---|
| 465 | cs = ar7240_reg_rd(AR7240_SPI_WRITE) & ~AR7240_SPI_CS_DIS; |
|---|
| 466 | ar7240_reg_wr_nf(AR7240_SPI_WRITE, AR7240_SPI_CS_ENABLE_1 | cs); |
|---|
| 467 | } |
|---|
| 468 | |
|---|
| 469 | static inline void ar7240_spi_disable_cs(void) |
|---|
| 470 | { |
|---|
| 471 | unsigned int cs = ar7240_reg_rd(AR7240_SPI_WRITE) | AR7240_SPI_CS_DIS; |
|---|
| 472 | ar7240_reg_wr_nf(AR7240_SPI_WRITE, cs); |
|---|
| 473 | ar7240_spi_disable_soft_access(); |
|---|
| 474 | ar7240_spi_up(); |
|---|
| 475 | } |
|---|
| 476 | |
|---|
| 477 | /* |
|---|
| 478 | * Example usage to access BOOT flash |
|---|
| 479 | */ |
|---|
| 480 | static inline void ar7240_spi_flash_cs0_sector_erase(unsigned int addr) |
|---|
| 481 | { |
|---|
| 482 | ar7240_spi_enable_cs0(); |
|---|
| 483 | ar7240_spi_flash_sector_erase(addr); |
|---|
| 484 | ar7240_spi_disable_cs(); |
|---|
| 485 | } |
|---|
| 486 | |
|---|
| 487 | static inline void ar7240_spi_flash_cs0_write_page(unsigned int addr, unsigned char *data, int len) |
|---|
| 488 | { |
|---|
| 489 | ar7240_spi_enable_cs0(); |
|---|
| 490 | ar7240_spi_flash_write_page(addr, data, len); |
|---|
| 491 | ar7240_spi_disable_cs(); |
|---|
| 492 | } |
|---|
| 493 | |
|---|
| 494 | /* |
|---|
| 495 | * Reset block |
|---|
| 496 | */ |
|---|
| 497 | #define AR7240_GENERAL_TMR AR7240_RESET_BASE+0 |
|---|
| 498 | #define AR7240_GENERAL_TMR_RELOAD AR7240_RESET_BASE+4 |
|---|
| 499 | #define AR7240_WATCHDOG_TMR_CONTROL AR7240_RESET_BASE+8 |
|---|
| 500 | #define AR7240_WATCHDOG_TMR AR7240_RESET_BASE+0xc |
|---|
| 501 | #define AR7240_MISC_INT_STATUS AR7240_RESET_BASE+0x10 |
|---|
| 502 | #define AR7240_MISC_INT_MASK AR7240_RESET_BASE+0x14 |
|---|
| 503 | |
|---|
| 504 | #define AR7240_PCI_INT_STATUS AR7240_PCI_CTLR_BASE+0x4c |
|---|
| 505 | #define AR7240_PCI_INT_MASK AR7240_PCI_CTLR_BASE+0x50 |
|---|
| 506 | #define AR7240_PCI_INT_A_L (1 << 14) /* INTA Level Trigger */ |
|---|
| 507 | #define AR7240_PCI_INT_B_L (1 << 15) /* INTB Level Trigger */ |
|---|
| 508 | #define AR7240_PCI_INT_C_L (1 << 16) /* INTC Level Trigger */ |
|---|
| 509 | #define AR7240_GLOBAL_INT_STATUS AR7240_RESET_BASE+0x20 |
|---|
| 510 | #define AR7240_RESET AR7240_RESET_BASE+0x1c |
|---|
| 511 | #define AR7240_OBSERVATION_ENABLE AR7240_RESET_BASE+0x28 |
|---|
| 512 | |
|---|
| 513 | |
|---|
| 514 | #define AR7240_WD_ACT_MASK 3u |
|---|
| 515 | #define AR7240_WD_ACT_NONE 0u /* No Action */ |
|---|
| 516 | #define AR7240_WD_ACT_GP_INTR 1u /* General purpose intr */ |
|---|
| 517 | #define AR7240_WD_ACT_NMI 2u /* NMI */ |
|---|
| 518 | #define AR7240_WD_ACT_RESET 3u /* Full Chip Reset */ |
|---|
| 519 | |
|---|
| 520 | #define AR7240_WD_LAST_SHIFT 31 |
|---|
| 521 | #define AR7240_WD_LAST_MASK ((uint32_t)(1 << AR7240_WD_LAST_SHIFT)) |
|---|
| 522 | |
|---|
| 523 | |
|---|
| 524 | |
|---|
| 525 | /* |
|---|
| 526 | * Performace counters |
|---|
| 527 | */ |
|---|
| 528 | #define AR7240_PERF0_COUNTER AR7240_GE0_BASE+0xa0 |
|---|
| 529 | #define AR7240_PERF1_COUNTER AR7240_GE1_BASE+0xa0 |
|---|
| 530 | |
|---|
| 531 | /* |
|---|
| 532 | * SLIC/STEREO DMA Size Configurations |
|---|
| 533 | */ |
|---|
| 534 | #define AR7240_DMA_BUF_SIZE_4X2 0x00 |
|---|
| 535 | #define AR7240_DMA_BUF_SIZE_8X2 0x01 |
|---|
| 536 | #define AR7240_DMA_BUF_SIZE_16X2 0x02 |
|---|
| 537 | #define AR7240_DMA_BUF_SIZE_32X2 0x03 |
|---|
| 538 | #define AR7240_DMA_BUF_SIZE_64X2 0x04 |
|---|
| 539 | #define AR7240_DMA_BUF_SIZE_128X2 0x05 |
|---|
| 540 | #define AR7240_DMA_BUF_SIZE_256X2 0x06 |
|---|
| 541 | #define AR7240_DMA_BUF_SIZE_512X2 0x07 |
|---|
| 542 | |
|---|
| 543 | /* |
|---|
| 544 | * SLIC/STEREO DMA Assignments |
|---|
| 545 | */ |
|---|
| 546 | #define AR7240_DMA_CHAN_SLIC0_RX 0 |
|---|
| 547 | #define AR7240_DMA_CHAN_SLIC1_RX 1 |
|---|
| 548 | #define AR7240_DMA_CHAN_STEREO_RX 2 |
|---|
| 549 | #define AR7240_DMA_CHAN_SLIC0_TX 3 |
|---|
| 550 | #define AR7240_DMA_CHAN_SLIC1_TX 4 |
|---|
| 551 | #define AR7240_DMA_CHAN_STEREO_TX 5 |
|---|
| 552 | |
|---|
| 553 | /* Low-level routines */ |
|---|
| 554 | void ar7240_dma_addr_wr (int chan, unsigned int val); |
|---|
| 555 | void ar7240_dma_config_wr(int chan, unsigned int val); |
|---|
| 556 | void ar7240_dma_update_wr(int chan, unsigned int val); |
|---|
| 557 | |
|---|
| 558 | unsigned int ar7240_dma_addr_rd (int chan); |
|---|
| 559 | unsigned int ar7240_dma_config_rd(int chan); |
|---|
| 560 | |
|---|
| 561 | /* Use this routine to configure DMA access. Example: |
|---|
| 562 | * |
|---|
| 563 | * ar7240_dma_config_buffer( AR7240_DMA_CHAN_SLIC0_TX, |
|---|
| 564 | * < address of buffer >, |
|---|
| 565 | * AR7240_DMA_BUF_SIZE_512X2 |
|---|
| 566 | */ |
|---|
| 567 | void ar7240_dma_config_buffer(int chan, void *buffer, int sizeCfg); |
|---|
| 568 | |
|---|
| 569 | /* |
|---|
| 570 | * SLIC register definitions |
|---|
| 571 | */ |
|---|
| 572 | #define AR7240_SLIC_STATUS (AR7240_SLIC_BASE+0x00) |
|---|
| 573 | #define AR7240_SLIC_CNTRL (AR7240_SLIC_BASE+0x04) |
|---|
| 574 | #define AR7240_SLIC_SLOT0_NUM (AR7240_SLIC_BASE+0x08) |
|---|
| 575 | #define AR7240_SLIC_SLOT1_NUM (AR7240_SLIC_BASE+0x0c) |
|---|
| 576 | #define AR7240_SLIC_SAM_POS (AR7240_SLIC_BASE+0x2c) |
|---|
| 577 | #define AR7240_SLIC_FREQ_DIV (AR7240_SLIC_BASE+0x30) |
|---|
| 578 | |
|---|
| 579 | /* |
|---|
| 580 | * SLIC Control bits |
|---|
| 581 | */ |
|---|
| 582 | #define AR7240_SLIC_CNTRL_ENABLE (1<<0) |
|---|
| 583 | #define AR7240_SLIC_CNTRL_SLOT0_ENABLE (1<<1) |
|---|
| 584 | #define AR7240_SLIC_CNTRL_SLOT1_ENABLE (1<<2) |
|---|
| 585 | #define AR7240_SLIC_CNTRL_IRQ_ENABLE (1<<3) |
|---|
| 586 | |
|---|
| 587 | /* |
|---|
| 588 | * SLIC Helper Functions |
|---|
| 589 | */ |
|---|
| 590 | unsigned int ar7240_slic_status_rd(void); |
|---|
| 591 | unsigned int ar7240_slic_cntrl_rd(void); |
|---|
| 592 | |
|---|
| 593 | void ar7240_slic_cntrl_wr(unsigned int val); |
|---|
| 594 | void ar7240_slic_0_slot_pos_wr(unsigned int val); |
|---|
| 595 | void ar7240_slic_1_slot_pos_wr(unsigned int val); |
|---|
| 596 | void ar7240_slic_freq_div_wr(unsigned int val); |
|---|
| 597 | void ar7240_slic_sample_pos_wr(unsigned int val); |
|---|
| 598 | |
|---|
| 599 | void ar7240_slic_setup(int _sam, int _s0n, int _s1n); |
|---|
| 600 | |
|---|
| 601 | /* |
|---|
| 602 | * STEREO register definitions |
|---|
| 603 | */ |
|---|
| 604 | #define AR7240_STEREO_CONFIG (AR7240_STEREO_BASE+0x00) |
|---|
| 605 | #define AR7240_STEREO_VOLUME (AR7240_STEREO_BASE+0x04) |
|---|
| 606 | |
|---|
| 607 | /* |
|---|
| 608 | * Stereo Configuration Bits |
|---|
| 609 | */ |
|---|
| 610 | #define AR7240_STEREO_CONFIG_ENABLE (1<<24) |
|---|
| 611 | #define AR7240_STEREO_CONFIG_RESET (1<<23) |
|---|
| 612 | #define AR7240_STEREO_CONFIG_DELAY (1<<22) |
|---|
| 613 | #define AR7240_STEREO_CONFIG_MIC_WORD_SIZE (1<<20) |
|---|
| 614 | |
|---|
| 615 | #define AR7240_STEREO_CONFIG_MODE(x) ((3&x)<<18) |
|---|
| 616 | #define AR7240_STEREO_MODE_STEREO 0 |
|---|
| 617 | #define AR7240_STEREO_MODE_LEFT 1 |
|---|
| 618 | #define AR7240_STEREO_MODE_RIGHT 2 |
|---|
| 619 | |
|---|
| 620 | #define AR7240_STEREO_CONFIG_DATA_WORD_SIZE(x) ((3&x)<<16) |
|---|
| 621 | |
|---|
| 622 | #define AR7240_STEREO_CONFIG_I2S_32B_WORD (1<<15) |
|---|
| 623 | #define AR7240_STEREO_CONFIG_MASTER (1<<8) |
|---|
| 624 | #define AR7240_STEREO_CONFIG_PSEDGE(x) (0xff&x) |
|---|
| 625 | |
|---|
| 626 | /* |
|---|
| 627 | * Word sizes to use with common configurations: |
|---|
| 628 | */ |
|---|
| 629 | #define AR7240_STEREO_WS_8B 0 |
|---|
| 630 | #define AR7240_STEREO_WS_16B 1 |
|---|
| 631 | |
|---|
| 632 | /* |
|---|
| 633 | * Audio data is little endian so 16b values must be swapped in the DMA buffers. |
|---|
| 634 | */ |
|---|
| 635 | static inline int ar7240_stereo_sample_16b_cvt(unsigned int _v) { return (((_v<<8)&0xff00)|((_v>>8)&0xff)) & 0xffff; } |
|---|
| 636 | |
|---|
| 637 | /* Low level read/write of configuration */ |
|---|
| 638 | void ar7240_stereo_config_wr(unsigned int val); |
|---|
| 639 | void ar7240_stereo_volume_wr(unsigned int val); |
|---|
| 640 | |
|---|
| 641 | unsigned int ar7240_stereo_config_rd(void); |
|---|
| 642 | unsigned int ar7240_stereo_volume_rd(void); |
|---|
| 643 | |
|---|
| 644 | /* |
|---|
| 645 | * Common configurations for stereo block |
|---|
| 646 | */ |
|---|
| 647 | #define AR7240_STEREO_CFG_MASTER_STEREO_FS32_48KHZ(ws) ( \ |
|---|
| 648 | AR7240_STEREO_CONFIG_DELAY | \ |
|---|
| 649 | AR7240_STEREO_CONFIG_RESET | \ |
|---|
| 650 | AR7240_STEREO_CONFIG_DATA_WORD_SIZE(ws) | \ |
|---|
| 651 | AR7240_STEREO_CONFIG_MODE(AR7240_STEREO_MODE_LEFT) | \ |
|---|
| 652 | AR7240_STEREO_CONFIG_MASTER | \ |
|---|
| 653 | AR7240_STEREO_CONFIG_PSEDGE(26)) |
|---|
| 654 | |
|---|
| 655 | #define AR7240_STEREO_CFG_MASTER_STEREO_FS64_48KHZ(ws) ( \ |
|---|
| 656 | AR7240_STEREO_CONFIG_DELAY | \ |
|---|
| 657 | AR7240_STEREO_CONFIG_RESET | \ |
|---|
| 658 | AR7240_STEREO_CONFIG_DATA_WORD_SIZE(ws) | \ |
|---|
| 659 | AR7240_STEREO_CONFIG_MODE(AR7240_STEREO_MODE_STEREO) | \ |
|---|
| 660 | AR7240_STEREO_CONFIG_I2S_32B_WORD | \ |
|---|
| 661 | AR7240_STEREO_CONFIG_MASTER | \ |
|---|
| 662 | AR7240_STEREO_CONFIG_PSEDGE(13)) |
|---|
| 663 | |
|---|
| 664 | #define AR7240_STEREO_CFG_SLAVE_STEREO_FS32_48KHZ(ws) ( \ |
|---|
| 665 | AR7240_STEREO_CONFIG_RESET | \ |
|---|
| 666 | AR7240_STEREO_CONFIG_DATA_WORD_SIZE(ws) | \ |
|---|
| 667 | AR7240_STEREO_CONFIG_MODE(AR7240_STEREO_MODE_STEREO) | \ |
|---|
| 668 | AR7240_STEREO_CONFIG_PSEDGE(26)) |
|---|
| 669 | |
|---|
| 670 | #define AR7240_STEREO_CFG_SLAVE_STEREO_FS64_48KHZ(ws) ( \ |
|---|
| 671 | AR7240_STEREO_CONFIG_RESET | \ |
|---|
| 672 | AR7240_STEREO_CONFIG_I2S_32B_WORD | \ |
|---|
| 673 | AR7240_STEREO_CONFIG_DATA_WORD_SIZE(ws) | \ |
|---|
| 674 | AR7240_STEREO_CONFIG_MODE(AR7240_STEREO_MODE_STEREO) | \ |
|---|
| 675 | AR7240_STEREO_CONFIG_PSEDGE(13)) |
|---|
| 676 | |
|---|
| 677 | /* Routine sets up STEREO block for use. Use one of the predefined |
|---|
| 678 | * configurations. Example: |
|---|
| 679 | * |
|---|
| 680 | * ar7240_stereo_config_setup( |
|---|
| 681 | * AR7240_STEREO_CFG_MASTER_STEREO_FS32_48KHZ(AR7240_STEREO_WS_16B)) |
|---|
| 682 | * |
|---|
| 683 | */ |
|---|
| 684 | void ar7240_stereo_config_setup(unsigned int cfg); |
|---|
| 685 | |
|---|
| 686 | /* 48 kHz, 16 bit data & i2s 32fs */ |
|---|
| 687 | static inline void ar7240_setup_for_stereo_master(int ws) |
|---|
| 688 | { ar7240_stereo_config_setup(AR7240_STEREO_CFG_MASTER_STEREO_FS32_48KHZ(ws)); } |
|---|
| 689 | |
|---|
| 690 | /* 48 kHz, 16 bit data & 32fs i2s */ |
|---|
| 691 | static inline void ar7240_setup_for_stereo_slave(int ws) |
|---|
| 692 | { ar7240_stereo_config_setup(AR7240_STEREO_CFG_SLAVE_STEREO_FS32_48KHZ(ws)); } |
|---|
| 693 | |
|---|
| 694 | /* |
|---|
| 695 | * PERF CTL bits |
|---|
| 696 | */ |
|---|
| 697 | #define PERF_CTL_PCI_AHB_0 ( 0) |
|---|
| 698 | #define PERF_CTL_PCI_AHB_1 ( 1) |
|---|
| 699 | #define PERF_CTL_USB_0 ( 2) |
|---|
| 700 | #define PERF_CTL_USB_1 ( 3) |
|---|
| 701 | #define PERF_CTL_GE0_PKT_CNT ( 4) |
|---|
| 702 | #define PERF_CTL_GEO_AHB_1 ( 5) |
|---|
| 703 | #define PERF_CTL_GE1_PKT_CNT ( 6) |
|---|
| 704 | #define PERF_CTL_GE1_AHB_1 ( 7) |
|---|
| 705 | #define PERF_CTL_PCI_DEV_0_BUSY ( 8) |
|---|
| 706 | #define PERF_CTL_PCI_DEV_1_BUSY ( 9) |
|---|
| 707 | #define PERF_CTL_PCI_DEV_2_BUSY (10) |
|---|
| 708 | #define PERF_CTL_PCI_HOST_BUSY (11) |
|---|
| 709 | #define PERF_CTL_PCI_DEV_0_ARB (12) |
|---|
| 710 | #define PERF_CTL_PCI_DEV_1_ARB (13) |
|---|
| 711 | #define PERF_CTL_PCI_DEV_2_ARB (14) |
|---|
| 712 | #define PERF_CTL_PCI_HOST_ARB (15) |
|---|
| 713 | #define PERF_CTL_PCI_DEV_0_ACTIVE (16) |
|---|
| 714 | #define PERF_CTL_PCI_DEV_1_ACTIVE (17) |
|---|
| 715 | #define PERF_CTL_PCI_DEV_2_ACTIVE (18) |
|---|
| 716 | #define PERF_CTL_HOST_ACTIVE (19) |
|---|
| 717 | |
|---|
| 718 | #define ar7240_perf0_ctl(_val) ar7240_reg_wr(AR7240_PERF_CTL, (_val)) |
|---|
| 719 | #define ar7240_perf1_ctl(_val) ar7240_reg_rmw_set(AR7240_PERF_CTL, ((_val) << 8)) |
|---|
| 720 | |
|---|
| 721 | |
|---|
| 722 | /* These are values used in platform.inc to select PLL settings */ |
|---|
| 723 | |
|---|
| 724 | #define AR7240_REV_ID (AR7240_RESET_BASE + 0x90) |
|---|
| 725 | #define AR7240_REV_ID_MASK 0xffff |
|---|
| 726 | #define AR7240_REV_ID_AR7130 0xa0 |
|---|
| 727 | #define AR7240_REV_ID_AR7141 0xa1 |
|---|
| 728 | #define AR7240_REV_ID_AR7161 0xa2 |
|---|
| 729 | #define AR7240_REV_1_0 0xc0 |
|---|
| 730 | #define AR7240_REV_1_1 0xc1 |
|---|
| 731 | #define AR7240_REV_1_2 0xc2 |
|---|
| 732 | #define AR7241_REV_1_0 0x0100 |
|---|
| 733 | #define AR7242_REV_1_0 0x1100 |
|---|
| 734 | #define AR7241_REV_1_1 0x0101 |
|---|
| 735 | #define AR7242_REV_1_1 0x1101 |
|---|
| 736 | |
|---|
| 737 | #define is_ar7240() (((ar7240_reg_rd(AR7240_REV_ID) & AR7240_REV_ID_MASK) == AR7240_REV_1_2) || \ |
|---|
| 738 | ((ar7240_reg_rd(AR7240_REV_ID) & AR7240_REV_ID_MASK) == AR7240_REV_1_1) || \ |
|---|
| 739 | ((ar7240_reg_rd(AR7240_REV_ID) & AR7240_REV_ID_MASK) == AR7240_REV_1_0)) |
|---|
| 740 | |
|---|
| 741 | #define is_ar7241() (((ar7240_reg_rd(AR7240_REV_ID) & AR7240_REV_ID_MASK) == AR7241_REV_1_0) || \ |
|---|
| 742 | ((ar7240_reg_rd(AR7240_REV_ID) & AR7240_REV_ID_MASK) == AR7241_REV_1_1)) |
|---|
| 743 | |
|---|
| 744 | #define is_ar7242() (((ar7240_reg_rd(AR7240_REV_ID) & AR7240_REV_ID_MASK) == AR7242_REV_1_0) || \ |
|---|
| 745 | ((ar7240_reg_rd(AR7240_REV_ID) & AR7240_REV_ID_MASK) == AR7242_REV_1_1)) |
|---|
| 746 | |
|---|
| 747 | |
|---|
| 748 | #define AR7240_PLL_USE_REV_ID 0 |
|---|
| 749 | #define AR7240_PLL_200_200_100 1 |
|---|
| 750 | #define AR7240_PLL_300_300_150 2 |
|---|
| 751 | #define AR7240_PLL_333_333_166 3 |
|---|
| 752 | #define AR7240_PLL_266_266_133 4 |
|---|
| 753 | #define AR7240_PLL_266_266_66 5 |
|---|
| 754 | #define AR7240_PLL_400_400_200 6 |
|---|
| 755 | #define AR7240_PLL_600_400_150 7 |
|---|
| 756 | |
|---|
| 757 | |
|---|
| 758 | /* |
|---|
| 759 | * AR7240_RESET bit defines |
|---|
| 760 | */ |
|---|
| 761 | #define AR7240_RESET_EXTERNAL (1 << 28) |
|---|
| 762 | #define AR7240_RESET_FULL_CHIP (1 << 24) |
|---|
| 763 | #define AR7240_RESET_CPU_NMI (1 << 21) |
|---|
| 764 | #define AR7240_RESET_CPU_COLD_RESET_MASK (1 << 20) |
|---|
| 765 | #define AR7240_RESET_DMA (1 << 19) |
|---|
| 766 | #define AR7240_RESET_SLIC (1 << 18) |
|---|
| 767 | #define AR7240_RESET_STEREO (1 << 17) |
|---|
| 768 | #define AR7240_RESET_DDR (1 << 16) |
|---|
| 769 | #define AR7240_RESET_GE1_MAC (1 << 13) |
|---|
| 770 | #define AR7240_RESET_GE1_PHY (1 << 12) |
|---|
| 771 | #define AR7240_RESET_GE0_MAC (1 << 9) |
|---|
| 772 | #define AR7240_RESET_GE0_PHY (1 << 8) |
|---|
| 773 | #define AR7240_RESET_PCIE_PHY_SHIFT (1 << 10) |
|---|
| 774 | #define AR7240_RESET_USBSUS_OVRIDE (1 << 3) |
|---|
| 775 | #define AR7240_RESET_USB_OHCI_DLL (1 << 3) |
|---|
| 776 | #define AR7240_RESET_USB_HOST (1 << 5) |
|---|
| 777 | #define AR7240_RESET_USB_PHY (1 << 4) |
|---|
| 778 | #define AR7240_RESET_PCI_BUS (1 << 1) |
|---|
| 779 | #define AR7240_RESET_PCI_CORE (1 << 0) |
|---|
| 780 | |
|---|
| 781 | |
|---|
| 782 | void ar7240_reset(unsigned int mask); |
|---|
| 783 | |
|---|
| 784 | /* |
|---|
| 785 | * Mii block |
|---|
| 786 | */ |
|---|
| 787 | #define AR7240_MII0_CTRL 0x18070000 |
|---|
| 788 | #define AR7240_MII1_CTRL 0x18070004 |
|---|
| 789 | |
|---|
| 790 | #define BIT(_x) (1 << (_x)) |
|---|
| 791 | |
|---|
| 792 | #define ar7240_get_bit(_reg, _bit) (ar7240_reg_rd((_reg)) & (1 << (_bit))) |
|---|
| 793 | |
|---|
| 794 | #define ar7240_flush_ge(_unit) do { \ |
|---|
| 795 | u32 reg = (_unit) ? AR7240_DDR_GE1_FLUSH : AR7240_DDR_GE0_FLUSH; \ |
|---|
| 796 | ar7240_reg_wr(reg, 1); \ |
|---|
| 797 | while((ar7240_reg_rd(reg) & 0x1)); \ |
|---|
| 798 | ar7240_reg_wr(reg, 1); \ |
|---|
| 799 | while((ar7240_reg_rd(reg) & 0x1)); \ |
|---|
| 800 | }while(0); |
|---|
| 801 | |
|---|
| 802 | #define ar7240_flush_pcie() do { \ |
|---|
| 803 | ar7240_reg_wr(AR7240_DDR_PCIE_FLUSH, 1); \ |
|---|
| 804 | while((ar7240_reg_rd(AR7240_DDR_PCIE_FLUSH) & 0x1)); \ |
|---|
| 805 | ar7240_reg_wr(AR7240_DDR_PCIE_FLUSH, 1); \ |
|---|
| 806 | while((ar7240_reg_rd(AR7240_DDR_PCIE_FLUSH) & 0x1)); \ |
|---|
| 807 | }while(0); |
|---|
| 808 | |
|---|
| 809 | #define ar7240_flush_USB() do { \ |
|---|
| 810 | ar7240_reg_wr(AR7240_DDR_USB_FLUSH, 1); \ |
|---|
| 811 | while((ar7240_reg_rd(AR7240_DDR_USB_FLUSH) & 0x1)); \ |
|---|
| 812 | ar7240_reg_wr(AR7240_DDR_USB_FLUSH, 1); \ |
|---|
| 813 | while((ar7240_reg_rd(AR7240_DDR_USB_FLUSH) & 0x1)); \ |
|---|
| 814 | }while(0); |
|---|
| 815 | |
|---|
| 816 | int ar7240_local_read_config(int where, int size, u32 *value); |
|---|
| 817 | int ar7240_local_write_config(int where, int size, u32 value); |
|---|
| 818 | int ar7240_check_error(int verbose); |
|---|
| 819 | unsigned char __ar7240_readb(const volatile void __iomem *p); |
|---|
| 820 | unsigned short __ar7240_readw(const volatile void __iomem *p); |
|---|
| 821 | void ap_usb_led_on(void); |
|---|
| 822 | void ap_usb_led_off(void); |
|---|
| 823 | |
|---|
| 824 | #endif |
|---|