blob: 28b271f7791cb24279e0a7aa33abf3f0975f4519 [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
9#include <common.h>
10#include <dm.h>
11#include <dm-demo.h>
Joe Hershberger0eb25b62015-03-22 17:08:59 -050012#include <mapmem.h>
Simon Glass39f76112014-02-26 15:59:23 -070013#include <asm/io.h>
14
Heiko Schocher54c5d082014-05-22 12:43:05 +020015static int simple_hello(struct udevice *dev, int ch)
Simon Glass39f76112014-02-26 15:59:23 -070016{
Simon Glassc69cda22020-12-03 16:55:20 -070017 const struct dm_demo_pdata *pdata = dev_get_plat(dev);
Simon Glass39f76112014-02-26 15:59:23 -070018
Mario Sixc6b89f32018-02-12 08:05:57 +010019 printf("Hello from %08x: %s %d\n", (uint)map_to_sysmem(dev), pdata->colour,
Simon Glass39f76112014-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 Glassd1998a92020-12-03 16:55:21 -070029static int demo_shape_of_to_plat(struct udevice *dev)
Simon Glass39f76112014-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 Glassae7f4512014-06-11 23:29:45 -060035static const struct udevice_id demo_shape_id[] = {
Simon Glass39f76112014-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 Glassd1998a92020-12-03 16:55:21 -070044 .of_to_plat = demo_shape_of_to_plat,
Simon Glass39f76112014-02-26 15:59:23 -070045 .ops = &simple_ops,
Simon Glasscaa4daa2020-12-03 16:55:18 -070046 .plat_auto = sizeof(struct dm_demo_pdata),
Simon Glass39f76112014-02-26 15:59:23 -070047};