blob: 28b271f7791cb24279e0a7aa33abf3f0975f4519 [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
9#include <common.h>
10#include <dm.h>
11#include <dm-demo.h>
Joe Hershberger65b905b2015-03-22 17:08:59 -050012#include <mapmem.h>
Simon Glass63b17572014-02-26 15:59:23 -070013#include <asm/io.h>
14
Heiko Schocherb74fcb42014-05-22 12:43:05 +020015static int simple_hello(struct udevice *dev, int ch)
Simon Glass63b17572014-02-26 15:59:23 -070016{
Simon Glassfa20e932020-12-03 16:55:20 -070017 const struct dm_demo_pdata *pdata = dev_get_plat(dev);
Simon Glass63b17572014-02-26 15:59:23 -070018
Mario Six61efece2018-02-12 08:05:57 +010019 printf("Hello from %08x: %s %d\n", (uint)map_to_sysmem(dev), pdata->colour,
Simon Glass63b17572014-02-26 15:59:23 -070020 pdata->sides);
21
22 return 0;
23}
24
25static const struct demo_ops simple_ops = {
26 .hello = simple_hello,
27};
28
Simon Glassaad29ae2020-12-03 16:55:21 -070029static int demo_shape_of_to_plat(struct udevice *dev)
Simon Glass63b17572014-02-26 15:59:23 -070030{
31 /* Parse the data that is common with all demo devices */
32 return demo_parse_dt(dev);
33}
34
Simon Glass767827a2014-06-11 23:29:45 -060035static const struct udevice_id demo_shape_id[] = {
Simon Glass63b17572014-02-26 15:59:23 -070036 { "demo-simple", 0 },
37 { },
38};
39
40U_BOOT_DRIVER(demo_simple_drv) = {
41 .name = "demo_simple_drv",
42 .of_match = demo_shape_id,
43 .id = UCLASS_DEMO,
Simon Glassaad29ae2020-12-03 16:55:21 -070044 .of_to_plat = demo_shape_of_to_plat,
Simon Glass63b17572014-02-26 15:59:23 -070045 .ops = &simple_ops,
Simon Glass71fa5b42020-12-03 16:55:18 -070046 .plat_auto = sizeof(struct dm_demo_pdata),
Simon Glass63b17572014-02-26 15:59:23 -070047};