4 #define IOREG(offs) (*(volatile uint32_t*)(rpi_iobase | offs))
7 #define STM_CTL_REG IOREG(0x3000)
8 #define STM_STAT_REG STM_CTL_REG
9 #define STM_LCNT_REG IOREG(0x3004)
10 #define STM_HCNT_REG IOREG(0x3008)
11 #define STM_CMP0_REG IOREG(0x300c)
12 #define STM_CMP1_REG IOREG(0x3010)
13 #define STM_CMP2_REG IOREG(0x3014)
14 #define STM_CMP3_REG IOREG(0x3018)
22 #define TM_LOAD_REG IOREG(0xb400)
23 #define TM_VALUE_REG IOREG(0xb404)
24 #define TM_CTL_REG IOREG(0xb408)
25 #define TM_ICLR_REG IOREG(0xb40c)
26 #define TM_IRAW_REG IOREG(0xb410)
27 #define TM_IMSK_REG IOREG(0xb414)
28 #define TM_RELOAD_REG IOREG(0xb418)
29 #define TM_PREDIV_REG IOREG(0xb41c)
30 #define TM_COUNT_REG IOREG(0xb420)
32 #define TMCTL_23BIT 0x000002
33 #define TMCTL_DIV16 0x000004
34 #define TMCTL_DIV256 0x000008
35 #define TMCTL_DIV1 0x00000c
36 #define TMCTL_IEN 0x000020
37 #define TMCTL_EN 0x000080
38 #define TMCTL_DBGHALT 0x000100
39 #define TMCTL_CNTEN 0x000200
41 #define TMCTL_PRESCALER(x) (((uint32_t)(x) & 0xff) << 16)
45 #define MBOX_READ_REG IOREG(0xb880)
46 #define MBOX_POLL_REG IOREG(0xb890)
47 #define MBOX_SENDER_REG IOREG(0xb894)
48 #define MBOX_STATUS_REG IOREG(0xb898)
49 #define MBOX_CFG_REG IOREG(0xb89c)
50 #define MBOX_WRITE_REG IOREG(0xb8a0)
52 /* the full bit is set when there's no space to append messages */
53 #define MBOX_STAT_FULL 0x80000000
54 /* the empty bit is set when there are no pending messages to be read */
55 #define MBOX_STAT_EMPTY 0x40000000
57 static int detect(void);
61 uint32_t rpi_memsize, rpi_vc_memsize;
65 if((rpi_model = detect()) == -1) {
72 static int detect(void)
76 static uint32_t base[] = {0x20000000, 0x3f000000, 0xfe000000};
81 for(j=0; j<256; j++) {
92 void rpi_mbox_send(int chan, uint32_t msg)
94 while(MBOX_STATUS_REG & MBOX_STAT_FULL);
95 MBOX_WRITE_REG = (msg & 0xfffffff0) | chan;
98 uint32_t rpi_mbox_recv(int chan)
102 while(MBOX_STATUS_REG & MBOX_STAT_EMPTY);
104 } while((msg & 0xf) != chan);
105 return msg & 0xfffffff0;
108 int rpi_mbox_pending(int chan)
110 return (MBOX_STATUS_REG & MBOX_STAT_EMPTY) == 0;