blob: 68972c780f44cd636610910d75fb229eb7ebba7f [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{
17 const struct dm_demo_pdata *pdata = dev_get_platdata(dev);
18
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
Heiko Schocherb74fcb42014-05-22 12:43:05 +020029static int demo_shape_ofdata_to_platdata(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,
44 .ofdata_to_platdata = demo_shape_ofdata_to_platdata,
45 .ops = &simple_ops,
46 .platdata_auto_alloc_size = sizeof(struct dm_demo_pdata),
47};