mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-11-29 22:51:49 +01:00
drivers: serial_sifive: Skip baudrate config if no input clock
It is possible that input clock is not available because clk device was not available and 'clock-frequency' DT property is also not available. In this case, instead of failing we should just skip baudrate config by returning zero. Signed-off-by: Atish Patra <atish.patra@wdc.com> Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
parent
a3682008a0
commit
ee0633ef8b
@ -99,27 +99,27 @@ static int _sifive_serial_getc(struct uart_sifive *regs)
|
|||||||
|
|
||||||
static int sifive_serial_setbrg(struct udevice *dev, int baudrate)
|
static int sifive_serial_setbrg(struct udevice *dev, int baudrate)
|
||||||
{
|
{
|
||||||
int err;
|
int ret;
|
||||||
struct clk clk;
|
struct clk clk;
|
||||||
struct sifive_uart_platdata *platdata = dev_get_platdata(dev);
|
struct sifive_uart_platdata *platdata = dev_get_platdata(dev);
|
||||||
|
u32 clock = 0;
|
||||||
|
|
||||||
err = clk_get_by_index(dev, 0, &clk);
|
ret = clk_get_by_index(dev, 0, &clk);
|
||||||
if (!err) {
|
if (IS_ERR_VALUE(ret)) {
|
||||||
err = clk_get_rate(&clk);
|
|
||||||
if (!IS_ERR_VALUE(err))
|
|
||||||
platdata->clock = err;
|
|
||||||
} else if (err != -ENOENT && err != -ENODEV && err != -ENOSYS) {
|
|
||||||
debug("SiFive UART failed to get clock\n");
|
debug("SiFive UART failed to get clock\n");
|
||||||
return err;
|
ret = dev_read_u32(dev, "clock-frequency", &clock);
|
||||||
|
if (IS_ERR_VALUE(ret)) {
|
||||||
|
debug("SiFive UART clock not defined\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
clock = clk_get_rate(&clk);
|
||||||
|
if (IS_ERR_VALUE(clock)) {
|
||||||
|
debug("SiFive UART clock get rate failed\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
platdata->clock = clock;
|
||||||
if (!platdata->clock)
|
|
||||||
platdata->clock = dev_read_u32_default(dev, "clock-frequency", 0);
|
|
||||||
if (!platdata->clock) {
|
|
||||||
debug("SiFive UART clock not defined\n");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
_sifive_serial_setbrg(platdata->regs, platdata->clock, baudrate);
|
_sifive_serial_setbrg(platdata->regs, platdata->clock, baudrate);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user