2 * This file is part of the coreboot project.
4 * Copyright 2014 Rockchip Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #include <arch/cache.h>
17 #include <arch/exception.h>
19 #include <arch/stages.h>
24 #include <console/console.h>
26 #include <program_loading.h>
27 #include <soc/sdram.h>
28 #include <soc/clock.h>
31 #include <soc/rk808.h>
32 #include <soc/tsadc.h>
35 #include <timestamp.h>
37 #include <vendorcode/google/chromeos/chromeos.h>
41 static void regulate_vdd_log(unsigned int mv
)
44 const u32 period_ns
= 2000; /* pwm period: 2000ns */
45 const u32 max_regulator_mv
= 1350; /* 1.35V */
46 const u32 min_regulator_mv
= 870; /* 0.87V */
48 write32(&rk3288_grf
->iomux_pwm1
, IOMUX_PWM1
);
50 assert((mv
>= min_regulator_mv
) && (mv
<= max_regulator_mv
));
52 duty_ns
= (max_regulator_mv
- mv
) * period_ns
/
53 (max_regulator_mv
- min_regulator_mv
);
55 pwm_init(1, period_ns
, duty_ns
);
58 static void configure_l2ctlr(void)
62 l2ctlr
= read_l2ctlr();
63 l2ctlr
&= 0xfffc0000; /* clear bit0~bit17 */
66 * Data RAM write latency: 2 cycles
67 * Data RAM read latency: 2 cycles
68 * Data RAM setup latency: 1 cycle
69 * Tag RAM write latency: 1 cycle
70 * Tag RAM read latency: 1 cycle
71 * Tag RAM setup latency: 1 cycle
73 l2ctlr
|= (1 << 3 | 1 << 0);
79 timestamp_add_now(TS_START_ROMSTAGE
);
85 /* Need to power cycle SD card to ensure it is properly reset. */
88 /* vdd_log 1200mv is enough for ddr run 666Mhz */
89 regulate_vdd_log(1200);
91 timestamp_add_now(TS_BEFORE_INITRAM
);
93 sdram_init(get_sdram_config());
95 timestamp_add_now(TS_AFTER_INITRAM
);
97 /* Now that DRAM is up, add mappings for it and DMA coherency buffer. */
98 mmu_config_range((uintptr_t)_dram
/MiB
,
99 sdram_size_mb(), DCACHE_WRITEBACK
);
100 mmu_config_range((uintptr_t)_dma_coherent
/MiB
,
101 _dma_coherent_size
/MiB
, DCACHE_OFF
);
103 cbmem_initialize_empty();