mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-24 21:54:01 +00:00
bd9ff681bd
The baudrate configured in .config is taken by default by serial. If
change of baudrate is required then the .config needs to changed and
u-boot recompilation is required or the u-boot environment needs to be
updated.
To avoid this, support is added to fetch the baudrate directly from the
device tree file and update.
The serial, prints the log with the configured baudrate in the dtb.
The commit c4df0f6f31
("arm: mvebu: Espressobin: Set default value for
$fdtfile env variable") is taken as reference for changing the default
environment variable.
The default environment stores the default baudrate value, When default
baudrate and dtb baudrate are not same glitches are seen on the serial.
So, the environment also needs to be updated with the dtb baudrate to
avoid the glitches on the serial.
Also add test to cover this new function.
Signed-off-by: Algapally Santosh Sagar <santoshsagar.algapally@amd.com>
Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu@amd.com>
Link: https://lore.kernel.org/r/20230921112043.3144726-3-venkatesh.abbarapu@amd.com
Signed-off-by: Michal Simek <michal.simek@amd.com>
92 lines
2.6 KiB
C
92 lines
2.6 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright (c) 2018, STMicroelectronics
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <log.h>
|
|
#include <serial.h>
|
|
#include <dm.h>
|
|
#include <asm/serial.h>
|
|
#include <dm/test.h>
|
|
#include <test/test.h>
|
|
#include <test/ut.h>
|
|
|
|
static const char test_message[] =
|
|
"This is a test message\n"
|
|
"consisting of multiple lines\n";
|
|
|
|
static int dm_test_serial(struct unit_test_state *uts)
|
|
{
|
|
int i;
|
|
struct serial_device_info info_serial = {0};
|
|
struct udevice *dev_serial;
|
|
size_t start, putc_written;
|
|
|
|
uint value_serial;
|
|
|
|
ut_assertok(uclass_get_device_by_name(UCLASS_SERIAL, "serial",
|
|
&dev_serial));
|
|
|
|
ut_assertok(serial_tstc());
|
|
ut_asserteq(115200, fetch_baud_from_dtb());
|
|
/*
|
|
* test with default config which is the only one supported by
|
|
* sandbox_serial driver
|
|
*/
|
|
ut_assertok(serial_setconfig(dev_serial, SERIAL_DEFAULT_CONFIG));
|
|
ut_assertok(serial_getconfig(dev_serial, &value_serial));
|
|
ut_assert(value_serial == SERIAL_DEFAULT_CONFIG);
|
|
ut_assertok(serial_getinfo(dev_serial, &info_serial));
|
|
ut_assert(info_serial.type == SERIAL_CHIP_UNKNOWN);
|
|
ut_assert(info_serial.addr == SERIAL_DEFAULT_ADDRESS);
|
|
ut_assert(info_serial.clock == SERIAL_DEFAULT_CLOCK);
|
|
/*
|
|
* test with a parameter which is NULL pointer
|
|
*/
|
|
ut_asserteq(-EINVAL, serial_getconfig(dev_serial, NULL));
|
|
ut_asserteq(-EINVAL, serial_getinfo(dev_serial, NULL));
|
|
/*
|
|
* test with a serial config which is not supported by
|
|
* sandbox_serial driver: test with wrong parity
|
|
*/
|
|
ut_asserteq(-ENOTSUPP,
|
|
serial_setconfig(dev_serial,
|
|
SERIAL_CONFIG(SERIAL_PAR_ODD,
|
|
SERIAL_8_BITS,
|
|
SERIAL_ONE_STOP)));
|
|
/*
|
|
* test with a serial config which is not supported by
|
|
* sandbox_serial driver: test with wrong bits number
|
|
*/
|
|
ut_asserteq(-ENOTSUPP,
|
|
serial_setconfig(dev_serial,
|
|
SERIAL_CONFIG(SERIAL_PAR_NONE,
|
|
SERIAL_6_BITS,
|
|
SERIAL_ONE_STOP)));
|
|
|
|
/*
|
|
* test with a serial config which is not supported by
|
|
* sandbox_serial driver: test with wrong stop bits number
|
|
*/
|
|
ut_asserteq(-ENOTSUPP,
|
|
serial_setconfig(dev_serial,
|
|
SERIAL_CONFIG(SERIAL_PAR_NONE,
|
|
SERIAL_8_BITS,
|
|
SERIAL_TWO_STOP)));
|
|
|
|
/* Verify that putc and puts print the same number of characters */
|
|
sandbox_serial_endisable(false);
|
|
start = sandbox_serial_written();
|
|
for (i = 0; i < sizeof(test_message) - 1; i++)
|
|
serial_putc(test_message[i]);
|
|
putc_written = sandbox_serial_written();
|
|
serial_puts(test_message);
|
|
sandbox_serial_endisable(true);
|
|
ut_asserteq(putc_written - start,
|
|
sandbox_serial_written() - putc_written);
|
|
|
|
return 0;
|
|
}
|
|
|
|
DM_TEST(dm_test_serial, UT_TESTF_SCAN_FDT);
|