static void mach_logger(struct machine_t * mach, const char * buf, int count) { virtual_addr_t virt = phys_to_virt(0x3f201000); static int initial = 0; int i; if(!initial) { u64_t clk = bcm2836_mbox_clock_get_rate(MBOX_CLOCK_ID_UART); u32_t div, rem, frac; div = clk / (16 * 115200); rem = clk % (16 * 115200); frac = (8 * rem / 115200) >> 1; frac += (8 * rem / 115200) & 1; write32(virt + 0x24, div); write32(virt + 0x28, frac); write32(virt + 0x2c, (0x3 << 5) | (0x0 << 3) | (0x0 << 1) | (0x1 << 4)); write32(virt + 0x30, (1 << 0) | (1 << 8) | (1 << 9)); }
static u64_t clk_mbox_get_rate(struct clk_t * clk, u64_t prate) { struct clk_mbox_t * mclk = (struct clk_mbox_t *)clk->priv; return bcm2836_mbox_clock_get_rate(mclk->id); }