Prepare v2024.10
[platform/kernel/u-boot.git] / drivers / demo / demo-simple.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (c) 2013 Google, Inc
4  *
5  * (C) Copyright 2012
6  * Pavel Herrmann <morpheus.ibis@gmail.com>
7  */
8
9 #include <dm.h>
10 #include <dm-demo.h>
11 #include <mapmem.h>
12 #include <asm/io.h>
13
14 static int simple_hello(struct udevice *dev, int ch)
15 {
16         const struct dm_demo_pdata *pdata = dev_get_plat(dev);
17
18         printf("Hello from %08x: %s %d\n", (uint)map_to_sysmem(dev), pdata->colour,
19                pdata->sides);
20
21         return 0;
22 }
23
24 static const struct demo_ops simple_ops = {
25         .hello = simple_hello,
26 };
27
28 static int demo_shape_of_to_plat(struct udevice *dev)
29 {
30         /* Parse the data that is common with all demo devices */
31         return demo_parse_dt(dev);
32 }
33
34 static const struct udevice_id demo_shape_id[] = {
35         { "demo-simple", 0 },
36         { },
37 };
38
39 U_BOOT_DRIVER(demo_simple_drv) = {
40         .name   = "demo_simple_drv",
41         .of_match = demo_shape_id,
42         .id     = UCLASS_DEMO,
43         .of_to_plat = demo_shape_of_to_plat,
44         .ops    = &simple_ops,
45         .plat_auto      = sizeof(struct dm_demo_pdata),
46 };