blob: 944d58972224fd95f242c57d9a42b7b509f3ac06 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glass63b17572014-02-26 15:59:23 -07002/*
3 * Copyright (c) 2013 Google, Inc
4 *
5 * (C) Copyright 2012
6 * Pavel Herrmann <morpheus.ibis@gmail.com>
Simon Glass63b17572014-02-26 15:59:23 -07007 */
8
Simon Glass63b17572014-02-26 15:59:23 -07009#include <dm.h>
10#include <dm-demo.h>
Joe Hershberger65b905b2015-03-22 17:08:59 -050011#include <mapmem.h>
Simon Glass63b17572014-02-26 15:59:23 -070012#include <asm/io.h>
13
Heiko Schocherb74fcb42014-05-22 12:43:05 +020014static int simple_hello(struct udevice *dev, int ch)
Simon Glass63b17572014-02-26 15:59:23 -070015{
Simon Glassfa20e932020-12-03 16:55:20 -070016 const struct dm_demo_pdata *pdata = dev_get_plat(dev);
Simon Glass63b17572014-02-26 15:59:23 -070017
Mario Six61efece2018-02-12 08:05:57 +010018 printf("Hello from %08x: %s %d\n", (uint)map_to_sysmem(dev), pdata->colour,
Simon Glass63b17572014-02-26 15:59:23 -070019 pdata->sides);
20
21 return 0;
22}
23
24static const struct demo_ops simple_ops = {
25 .hello = simple_hello,
26};
27
Simon Glassaad29ae2020-12-03 16:55:21 -070028static int demo_shape_of_to_plat(struct udevice *dev)
Simon Glass63b17572014-02-26 15:59:23 -070029{
30 /* Parse the data that is common with all demo devices */
31 return demo_parse_dt(dev);
32}
33
Simon Glass767827a2014-06-11 23:29:45 -060034static const struct udevice_id demo_shape_id[] = {
Simon Glass63b17572014-02-26 15:59:23 -070035 { "demo-simple", 0 },
36 { },
37};
38
39U_BOOT_DRIVER(demo_simple_drv) = {
40 .name = "demo_simple_drv",
41 .of_match = demo_shape_id,
42 .id = UCLASS_DEMO,
Simon Glassaad29ae2020-12-03 16:55:21 -070043 .of_to_plat = demo_shape_of_to_plat,
Simon Glass63b17572014-02-26 15:59:23 -070044 .ops = &simple_ops,
Simon Glass71fa5b42020-12-03 16:55:18 -070045 .plat_auto = sizeof(struct dm_demo_pdata),
Simon Glass63b17572014-02-26 15:59:23 -070046};