summaryrefslogtreecommitdiff
path: root/drivers/misc/spltest_sandbox.c
blob: 999031625b54e25792944cbd30aabe29bcd36cff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright (c) 2016 Google, Inc
 * Written by Simon Glass <sjg@chromium.org>
 */

#include <common.h>
#include <dm.h>
#include <dt-structs.h>

static int sandbox_spl_probe(struct udevice *dev)
{
	struct dtd_sandbox_spl_test *plat = dev_get_platdata(dev);
	int i;

	printf("of-platdata probe:\n");
	printf("bool %d\n", plat->boolval);

	printf("byte %02x\n", plat->byteval);
	printf("bytearray");
	for (i = 0; i < sizeof(plat->bytearray); i++)
		printf(" %02x", plat->bytearray[i]);
	printf("\n");

	printf("int %d\n", plat->intval);
	printf("intarray");
	for (i = 0; i < ARRAY_SIZE(plat->intarray); i++)
		printf(" %d", plat->intarray[i]);
	printf("\n");

	printf("longbytearray");
	for (i = 0; i < sizeof(plat->longbytearray); i++)
		printf(" %02x", plat->longbytearray[i]);
	printf("\n");

	printf("string %s\n", plat->stringval);
	printf("stringarray");
	for (i = 0; i < ARRAY_SIZE(plat->stringarray); i++)
		printf(" \"%s\"", plat->stringarray[i]);
	printf("\n");

	return 0;
}

U_BOOT_DRIVER(sandbox_spl_test) = {
	.name	= "sandbox_spl_test",
	.id	= UCLASS_MISC,
	.flags	= DM_FLAG_PRE_RELOC,
	.probe	= sandbox_spl_probe,
};