blob: 49ebc3523c005870a708ad5fc25277ae05126b38 [file] [log] [blame]
Simon Glasse96fa6c2018-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
7#include <common.h>
8#include <dm.h>
9#include <i2s.h>
10#include <dm/test.h>
11#include <test/ut.h>
12#include <asm/test.h>
13
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}
32DM_TEST(dm_test_i2s, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);