1*d7c09684SPatrice Chotard // SPDX-License-Identifier: GPL-2.0 2*d7c09684SPatrice Chotard /* 3*d7c09684SPatrice Chotard * Copyright (c) 2018, STMicroelectronics 4*d7c09684SPatrice Chotard */ 5*d7c09684SPatrice Chotard 6*d7c09684SPatrice Chotard #include <common.h> 7*d7c09684SPatrice Chotard #include <serial.h> 8*d7c09684SPatrice Chotard #include <dm.h> 9*d7c09684SPatrice Chotard #include <dm/test.h> 10*d7c09684SPatrice Chotard #include <test/ut.h> 11*d7c09684SPatrice Chotard 12*d7c09684SPatrice Chotard static int dm_test_serial(struct unit_test_state *uts) 13*d7c09684SPatrice Chotard { 14*d7c09684SPatrice Chotard struct udevice *dev_serial; 15*d7c09684SPatrice Chotard 16*d7c09684SPatrice Chotard ut_assertok(uclass_get_device_by_name(UCLASS_SERIAL, "serial", 17*d7c09684SPatrice Chotard &dev_serial)); 18*d7c09684SPatrice Chotard 19*d7c09684SPatrice Chotard ut_assertok(serial_tstc()); 20*d7c09684SPatrice Chotard /* 21*d7c09684SPatrice Chotard * test with default config which is the only one supported by 22*d7c09684SPatrice Chotard * sandbox_serial driver 23*d7c09684SPatrice Chotard */ 24*d7c09684SPatrice Chotard ut_assertok(serial_setconfig(SERIAL_DEFAULT_CONFIG)); 25*d7c09684SPatrice Chotard /* 26*d7c09684SPatrice Chotard * test with a serial config which is not supported by 27*d7c09684SPatrice Chotard * sandbox_serial driver: test with wrong parity 28*d7c09684SPatrice Chotard */ 29*d7c09684SPatrice Chotard ut_asserteq(-ENOTSUPP, 30*d7c09684SPatrice Chotard serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_ODD, 31*d7c09684SPatrice Chotard SERIAL_8_BITS, 32*d7c09684SPatrice Chotard SERIAL_ONE_STOP))); 33*d7c09684SPatrice Chotard /* 34*d7c09684SPatrice Chotard * test with a serial config which is not supported by 35*d7c09684SPatrice Chotard * sandbox_serial driver: test with wrong bits number 36*d7c09684SPatrice Chotard */ 37*d7c09684SPatrice Chotard ut_asserteq(-ENOTSUPP, 38*d7c09684SPatrice Chotard serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_NONE, 39*d7c09684SPatrice Chotard SERIAL_6_BITS, 40*d7c09684SPatrice Chotard SERIAL_ONE_STOP))); 41*d7c09684SPatrice Chotard 42*d7c09684SPatrice Chotard /* 43*d7c09684SPatrice Chotard * test with a serial config which is not supported by 44*d7c09684SPatrice Chotard * sandbox_serial driver: test with wrong stop bits number 45*d7c09684SPatrice Chotard */ 46*d7c09684SPatrice Chotard ut_asserteq(-ENOTSUPP, 47*d7c09684SPatrice Chotard serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_NONE, 48*d7c09684SPatrice Chotard SERIAL_8_BITS, 49*d7c09684SPatrice Chotard SERIAL_TWO_STOP))); 50*d7c09684SPatrice Chotard 51*d7c09684SPatrice Chotard return 0; 52*d7c09684SPatrice Chotard } 53*d7c09684SPatrice Chotard 54*d7c09684SPatrice Chotard DM_TEST(dm_test_serial, DM_TESTF_SCAN_FDT); 55