117 #define AUX_OFFSET 0x215000
147 #define UART1_OFFSET 0x215040
171 uint32_t reserved_0x18[2];
172 uint32_t maybe_IO[4];
173 uint32_t maybe_TXHOLD[4];
176 #define SPI1_OFFSET 0x215080
196 #define SPI2_OFFSET 0x2150c0
220 #define BSC0_OFFSET 0x205000
235 #define BSC1_OFFSET 0x804000
245 #define BSC2_OFFSET 0x805000
262 uint32_t reserved_0x1c;
275 uint32_t reserved_0x28[54];
278 #define DMA15_OFFSET 0xe05000
288 #define DMA_OFFSET 0x007000
298 uint32_t reserved_0x04[3];
302 #define DMA_GLOBAL_OFFSET 0x007fe0
313 struct raspi_RNG_CTRL_reg {
318 uint32_t reserved:30;
323 struct raspi_RNG_STATUS_reg {
325 uint32_t WARM_CNT:20;
334 struct raspi_RNG_FF_THRES_reg {
336 uint32_t FF_THRESH:8;
337 uint32_t reserved:24;
342 struct raspi_RNG_INT_MASK_reg {
345 uint32_t reserved:31;
350 #define RNG_OFFSET 0x104000
382 uint32_t reserved_0x40[4];
384 uint32_t reserved_0x54[7];
385 uint32_t BOOT_TIMEOUT;
387 uint32_t reserved_0x78[2];
388 uint32_t EXRDFIFO_CFG;
389 uint32_t EXRDFIFO_EN;
391 uint32_t TUNE_STEP_STD;
392 uint32_t TUNE_STEP_DDR;
393 uint32_t reserved_0x94[19];
394 uint32_t SPI_INT_SPT;
395 uint32_t reserved_0xf4[2];
396 uint32_t SLOTISR_VER;
399 #define EMMC_OFFSET 0x300000
461 uint32_t reserved_0x18;
463 uint32_t reserved_0x24;
465 uint32_t reserved_0x30;
467 uint32_t reserved_0x3c;
469 uint32_t reserved_0x48;
471 uint32_t reserved_0x54;
473 uint32_t reserved_0x60;
475 uint32_t reserved_0x6c;
477 uint32_t reserved_0x78;
479 uint32_t reserved_0x84;
481 uint32_t reserved_0x90;
484 uint32_t reserved_0xa0[4];
488 #define GPIO_OFFSET 0x200000
512 #define GPCLK_OFFSET 0x101070
521 uint32_t pending_basic;
525 uint32_t enable_basic;
527 uint32_t disable_basic;
530 #define IRQ_OFFSET 0x00b200
548 struct raspi_PCM_CS_reg {
557 uint32_t reserved0:3;
571 uint32_t reserved1:6;
577 struct raspi_PCM_MODE_reg {
594 struct raspi_PCM_RXC_reg {
607 struct raspi_PCM_TXC_reg {
620 struct raspi_PCM_DREQ_reg {
622 uint32_t reserved0:1;
624 uint32_t reserved1:1;
626 uint32_t reserved2:1;
628 uint32_t reserved3:1;
633 struct raspi_PCM_INTEN_reg {
638 uint32_t reserved:28;
643 struct raspi_PCM_INTSTC_reg {
648 uint32_t reserved:28;
653 struct raspi_PCM_GRAY_reg {
657 uint32_t reserved0:1;
660 uint32_t RXFIFOLEVEL:6;
661 uint32_t reserved1:10;
666 #define PCM_OFFSET 0x203000
690 #define PWM_OFFSET 0x20c000
709 struct raspi_SPI0_CS_reg {
740 struct raspi_SPI0_CLK_reg {
742 uint32_t reserved:16;
747 struct raspi_SPI0_DLEN_reg {
749 uint32_t reserved:16;
754 struct raspi_SPI0_LTOH_reg {
756 uint32_t reserved:16;
761 struct raspi_SPI0_DC_reg {
770 #define SPI0_OFFSET 0x204000
804 #define BSCSL_OFFSET 0x214000
815 struct raspi_ST_CS_reg {
820 uint32_t reserved:28;
828 #define ST_OFFSET 0x003000
846 struct raspi_UART0_DR_reg {
852 uint32_t reserved:20;
857 struct raspi_UART0_RSRECR_reg {
862 uint32_t reserved:28;
865 uint32_t reserved_0x08[4];
868 struct raspi_UART0_FR_reg {
878 uint32_t reserved:23;
881 uint32_t reserved_0x1c;
885 struct raspi_UART0_IBRD_reg {
887 uint32_t reserved:16;
892 struct raspi_UART0_FBRD_reg {
894 uint32_t reserved:26;
899 struct raspi_UART0_LCRH_reg {
907 uint32_t reserved:24;
912 struct raspi_UART0_CR_reg {
916 uint32_t reserved0:4;
926 uint32_t reserved1:16;
931 struct raspi_UART0_IFLS_reg {
936 uint32_t reserved:20;
941 struct raspi_UART0_IMSC_reg {
953 uint32_t reserved:21;
958 struct raspi_UART0_RIS_reg {
970 uint32_t reserved:21;
975 struct raspi_UART0_MIS_reg {
987 uint32_t reserved:21;
992 struct raspi_UART0_ICR_reg {
1004 uint32_t reserved:21;
1008 uint32_t reserved_0x4c[14];
1011 struct raspi_UART0_ITCR_reg {
1014 uint32_t reserved:30;
1019 struct raspi_UART0_ITIP_reg {
1021 uint32_t reserved0:2;
1023 uint32_t reserved1:28;
1028 struct raspi_UART0_ITOP_reg {
1030 uint32_t reserved0:2;
1032 uint32_t reserved1:2;
1039 uint32_t reserved2:20;
1044 struct raspi_UART0_TDR_reg {
1045 uint32_t TDR10_0:11;
1046 uint32_t reserved0:21;
1051 #define UART0_OFFSET 0x201000
1063 uint32_t IRQClearAck;
1067 uint32_t Predivider;
1068 uint32_t Freerunning;
1071 #define TIMER_OFFSET 0x00b400
1080 uint32_t unknown[32];
1086 #define USB_OFFSET 0x980000
1099 uint32_t Response[4];
1101 uint32_t Unknown_0x24[3];
1104 uint32_t HostConfig;
1107 uint32_t Unknown_0x44[3];
1111 #define MMC_OFFSET 0x202000
1122 struct raspi_CM_CTL_reg {
1126 uint32_t reserved0:1;
1130 uint32_t reserved1:13;
1136 struct raspi_CM_DIV_reg {
1180 #define CM_PASSWD (0x5a)
1184 #define CM_OFFSET 0x101000
1193 uint32_t unknown_0x00[0x1c];
1196 struct raspi_PM_RSTC_reg {
1197 uint32_t reserved0:1;
1199 uint32_t reserved1:2;
1201 uint32_t reserved2:2;
1203 uint32_t reserved3:15;
1209 struct raspi_PM_RSTS_reg {
1213 uint32_t reserved0:1;
1217 uint32_t reserved1:1;
1221 uint32_t reserved2:1;
1223 uint32_t reserved3:19;
1228 struct raspi_PM_WDOG_reg {
1229 uint32_t TIME_SET:20;
1230 uint32_t reserved:4;
1242 #define PM_PASSWD (0x5a)
1244 #define PM_OFFSET 0x100000
1249 #define reg(src) raspi_##src##_regs src;
1250 #define pad(src,dest) uint8_t reserved_##src##_##dest[((dest##_OFFSET)-(src##_OFFSET)-sizeof(raspi_##src##_regs))]
1251 #define HW_END_OFFSET 0xf00000
1260 typedef volatile struct {
1272 pad(DMA, DMA_GLOBAL);
1274 pad(DMA_GLOBAL, IRQ);
1369 #define CORE_CLOCK 250000000
1378 #define memory_barrier() asm volatile ("mcr p15, #0, %[zero], c7, c10, #5" :: [zero] "r" (0))
1381 #define synchronization_barrier() asm volatile ("mcr p15, #0, %[zero], c7, c10, #4" :: [zero] "r" (0))
1384 #define memory_barrier()
1385 #define synchronization_barrier()
1391 #define ARM(x) ((x)+0x20000000ul)
1395 #define BUS(x) ((x)+0x7e000000ul)
1424 uint32_t tmp =
HW.GPIO.FSEL[gpio/10] & ~(7 << ((gpio%10)*3));
1425 HW.GPIO.FSEL[gpio/10] = tmp | (
function&7) << ((gpio%10)*3);
1432 HW.GPIO.SET[gpio/32] = 1<<(gpio%32);
1439 HW.GPIO.CLR[gpio/32] = 1<<(gpio%32);
1446 return HW.GPIO.LEV[gpio/32] & (1<<(gpio%32));
1469 #define ST_NOW ((st_time_t)HW.ST.CLO)
1473 #define ST_1s ((st_delta_t)1000000)
1477 #define ST_1ms (ST_1s/1000)
1481 #define ST_1us (ST_1s/1000000)
1488 return ((after) - (before) >= (diff));