src: Remove duplicated round up function

This removes CEIL_DIV and div_round_up() altogether and
replace it by DIV_ROUND_UP defined in commonlib/helpers.h.

Change-Id: I9aabc3fbe7834834c92d6ba59ff0005986622a34
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/c/29847
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-by: Marshall Dawson <marshalldawson3rd@gmail.com>
This commit is contained in:
Elyes HAOUAS
2018-11-26 22:53:49 +01:00
committed by Patrick Georgi
parent 1a5ce95815
commit 6df3b64c77
29 changed files with 79 additions and 89 deletions

View File

@@ -62,11 +62,11 @@ void mtk_spi_init(unsigned int bus, enum spi_pad_mask pad_select,
struct mtk_spi_regs *regs = slave->regs;
if (speed_hz < SPI_HZ / 2)
div = div_round_up(SPI_HZ, speed_hz);
div = DIV_ROUND_UP(SPI_HZ, speed_hz);
else
div = 1;
sck_ticks = div_round_up(div, 2);
sck_ticks = DIV_ROUND_UP(div, 2);
cs_ticks = sck_ticks * 2;
printk(BIOS_DEBUG, "SPI%u(PAD%u) initialized at %u Hz\n",
@@ -153,7 +153,7 @@ static int do_transfer(const struct spi_slave *slave, void *in, const void *out,
* therefore we need arbitrary data on MOSI which the slave
* must ignore.
*/
uint32_t word_count = div_round_up(size, sizeof(u32));
uint32_t word_count = DIV_ROUND_UP(size, sizeof(u32));
for (i = 0; i < word_count; i++)
write32(&regs->spi_tx_data_reg, MTK_ARBITRARY_VALUE);
}

View File

@@ -216,11 +216,11 @@ static void mtk_dsi_phy_timconfig(u32 data_rate)
timcon0 = (8 << 24) | (0xa << 16) | (0x6 << 8) | lpx;
timcon1 = (7 << 24) | (5 * lpx << 16) | ((3 * lpx) / 2) << 8 |
(4 * lpx);
timcon2 = ((div_round_up(0x64, cycle_time) + 0xa) << 24) |
(div_round_up(0x150, cycle_time) << 16);
timcon2 = ((DIV_ROUND_UP(0x64, cycle_time) + 0xa) << 24) |
(DIV_ROUND_UP(0x150, cycle_time) << 16);
timcon3 = (2 * lpx) << 16 |
div_round_up(80 + 52 * ui, cycle_time) << 8 |
div_round_up(0x40, cycle_time);
DIV_ROUND_UP(80 + 52 * ui, cycle_time) << 8 |
DIV_ROUND_UP(0x40, cycle_time);
dsi_write32(&dsi0->dsi_phy_timecon0, timcon0);
dsi_write32(&dsi0->dsi_phy_timecon1, timcon1);

View File

@@ -98,7 +98,7 @@ void mtk_i2c_bus_init(uint8_t bus)
/* Calculate i2c frequency */
sample_div = 1;
step_div = div_round_up(I2C_CLK_HZ, (400 * KHz * sample_div * 2));
step_div = DIV_ROUND_UP(I2C_CLK_HZ, (400 * KHz * sample_div * 2));
i2c_freq = I2C_CLK_HZ / (step_div * sample_div * 2);
assert(sample_div < 8 && step_div < 64 && i2c_freq < 400 * KHz &&
i2c_freq >= 380 * KHz);