blob: a3d3a31b6fbc38fc8577ab61edf0d43e608a125c [file] [log] [blame]
Simon Glassc953aaf2018-12-10 10:37:34 -07001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2018 Google LLC
4 * Written by Simon Glass <sjg@chromium.org>
5 */
6
Simon Glassc953aaf2018-12-10 10:37:34 -07007#include <dm.h>
8#include <i2s.h>
Simon Glass75c4d412020-07-19 10:15:37 -06009#include <asm/test.h>
Simon Glassc953aaf2018-12-10 10:37:34 -070010#include <dm/test.h>
Simon Glass75c4d412020-07-19 10:15:37 -060011#include <test/test.h>
Simon Glassc953aaf2018-12-10 10:37:34 -070012#include <test/ut.h>
Simon Glassc953aaf2018-12-10 10:37:34 -070013
14/* Basic test of the i2s codec uclass */
15static int dm_test_i2s(struct unit_test_state *uts)
16{
17 struct udevice *dev;
18 u8 data[3];
19
20 /* check probe success */
21 ut_assertok(uclass_first_device_err(UCLASS_I2S, &dev));
22 data[0] = 1;
23 data[1] = 4;
24 data[2] = 6;
25 ut_assertok(i2s_tx_data(dev, data, ARRAY_SIZE(data)));
26 ut_asserteq(11, sandbox_get_i2s_sum(dev));
27 ut_assertok(i2s_tx_data(dev, data, 1));
28 ut_asserteq(12, sandbox_get_i2s_sum(dev));
29
30 return 0;
31}
Simon Glass974dccd2020-07-28 19:41:12 -060032DM_TEST(dm_test_i2s, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);