blob: 944d58972224fd95f242c57d9a42b7b509f3ac06 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glass39f76112014-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 Glass39f76112014-02-26 15:59:23 -07007 */
8
Simon Glass39f76112014-02-26 15:59:23 -07009#include <dm.h>
10#include <dm-demo.h>
Joe Hershberger0eb25b62015-03-22 17:08:59 -050011#include <mapmem.h>
Simon Glass39f76112014-02-26 15:59:23 -070012#include <asm/io.h>
13
Heiko Schocher54c5d082014-05-22 12:43:05 +020014static int simple_hello(struct udevice *dev, int ch)
Simon Glass39f76112014-02-26 15:59:23 -070015{
Simon Glassc69cda22020-12-03 16:55:20 -070016 const struct dm_demo_pdata *pdata = dev_get_plat(dev);
Simon Glass39f76112014-02-26 15:59:23 -070017
Mario Sixc6b89f32018-02-12 08:05:57 +010018 printf("Hello from %08x: %s %d\n", (uint)map_to_sysmem(dev), pdata->colour,
Simon Glass39f76112014-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 Glassd1998a92020-12-03 16:55:21 -070028static int demo_shape_of_to_plat(struct udevice *dev)
Simon Glass39f76112014-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 Glassae7f4512014-06-11 23:29:45 -060034static const struct udevice_id demo_shape_id[] = {
Simon Glass39f76112014-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 Glassd1998a92020-12-03 16:55:21 -070043 .of_to_plat = demo_shape_of_to_plat,
Simon Glass39f76112014-02-26 15:59:23 -070044 .ops = &simple_ops,
Simon Glasscaa4daa2020-12-03 16:55:18 -070045 .plat_auto = sizeof(struct dm_demo_pdata),
Simon Glass39f76112014-02-26 15:59:23 -070046};