tegra132: break out clock config in funit library
In order to prepare for USB initialization move the clock configuration into a separate routine in the funit library. BUG=chrome-os-partner:31251 BRANCH=None TEST=Built and booted into recovery mode. Change-Id: I090b5d12c5805f0179c29cfc62499fad2f245c01 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: f7adaf969762b8296034f4373f550a902d1ed06b Original-Change-Id: Iea6cd2fbe8369a91c06b15d94b63c409ae83124f Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/212167 Original-Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: http://review.coreboot.org/8932 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
parent
662d3bb982
commit
33f92e0d4b
|
@ -100,18 +100,39 @@ static inline uint32_t get_clk_src_freq(uint32_t clk_src)
|
||||||
return freq;
|
return freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
void soc_configure_funits(const struct funit_cfg * const entries, size_t num)
|
static void configure_clock(const struct funit_cfg * const entry,
|
||||||
|
const struct funit_cfg_data * const funit)
|
||||||
{
|
{
|
||||||
size_t i;
|
|
||||||
const char *funit_i2c = "i2c";
|
const char *funit_i2c = "i2c";
|
||||||
uint32_t clk_div;
|
uint32_t clk_div;
|
||||||
uint32_t clk_div_mask;
|
uint32_t clk_div_mask;
|
||||||
|
uint32_t clk_src_freq;
|
||||||
|
|
||||||
|
clk_src_freq = get_clk_src_freq(entry->clk_src_id);
|
||||||
|
|
||||||
|
if (strncmp(funit->name, funit_i2c, strlen(funit_i2c)) == 0) {
|
||||||
|
/* I2C funit */
|
||||||
|
clk_div = get_i2c_clk_div(clk_src_freq,
|
||||||
|
entry->clk_dev_freq_khz);
|
||||||
|
clk_div_mask = CLK_DIV_MASK_I2C;
|
||||||
|
} else {
|
||||||
|
/* Non I2C */
|
||||||
|
clk_div = get_clk_div(clk_src_freq, entry->clk_dev_freq_khz);
|
||||||
|
clk_div_mask = CLK_DIV_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
_clock_set_div(funit->clk_src_reg, funit->name, clk_div,
|
||||||
|
clk_div_mask, entry->clk_src_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void soc_configure_funits(const struct funit_cfg * const entries, size_t num)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
const struct funit_cfg * const entry = &entries[i];
|
const struct funit_cfg * const entry = &entries[i];
|
||||||
const struct funit_cfg_data *funit;
|
const struct funit_cfg_data *funit;
|
||||||
const struct clk_dev_control *dev_control;
|
const struct clk_dev_control *dev_control;
|
||||||
uint32_t clk_src_freq;
|
|
||||||
|
|
||||||
if (entry->funit_index >= FUNIT_INDEX_MAX) {
|
if (entry->funit_index >= FUNIT_INDEX_MAX) {
|
||||||
printk(BIOS_ERR, "Error: Index out of bounds\n");
|
printk(BIOS_ERR, "Error: Index out of bounds\n");
|
||||||
|
@ -121,22 +142,7 @@ void soc_configure_funits(const struct funit_cfg * const entries, size_t num)
|
||||||
funit = &funit_data[entry->funit_index];
|
funit = &funit_data[entry->funit_index];
|
||||||
dev_control = funit->dev_control;
|
dev_control = funit->dev_control;
|
||||||
|
|
||||||
clk_src_freq = get_clk_src_freq(entry->clk_src_id);
|
configure_clock(entry, funit);
|
||||||
|
|
||||||
if (strncmp(funit->name,funit_i2c,strlen(funit_i2c)) == 0) {
|
|
||||||
/* I2C funit */
|
|
||||||
clk_div = get_i2c_clk_div(clk_src_freq,
|
|
||||||
entry->clk_dev_freq_khz);
|
|
||||||
clk_div_mask = CLK_DIV_MASK_I2C;
|
|
||||||
} else {
|
|
||||||
/* Non I2C */
|
|
||||||
clk_div = get_clk_div(clk_src_freq,
|
|
||||||
entry->clk_dev_freq_khz);
|
|
||||||
clk_div_mask = CLK_DIV_MASK;
|
|
||||||
}
|
|
||||||
|
|
||||||
_clock_set_div(funit->clk_src_reg, funit->name, clk_div,
|
|
||||||
clk_div_mask, entry->clk_src_id);
|
|
||||||
|
|
||||||
clock_grp_enable_clear_reset(funit->clk_enb_val,
|
clock_grp_enable_clear_reset(funit->clk_enb_val,
|
||||||
dev_control->clk_enb_set,
|
dev_control->clk_enb_set,
|
||||||
|
|
Loading…
Reference in New Issue