Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 63b1757 | 2014-02-26 15:59:23 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2013 Google, Inc |
| 4 | * |
| 5 | * (C) Copyright 2012 |
| 6 | * Pavel Herrmann <morpheus.ibis@gmail.com> |
Simon Glass | 63b1757 | 2014-02-26 15:59:23 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
Simon Glass | 63b1757 | 2014-02-26 15:59:23 -0700 | [diff] [blame] | 9 | #include <dm.h> |
| 10 | #include <dm-demo.h> |
Joe Hershberger | 65b905b | 2015-03-22 17:08:59 -0500 | [diff] [blame] | 11 | #include <mapmem.h> |
Simon Glass | 63b1757 | 2014-02-26 15:59:23 -0700 | [diff] [blame] | 12 | #include <asm/io.h> |
| 13 | |
Heiko Schocher | b74fcb4 | 2014-05-22 12:43:05 +0200 | [diff] [blame] | 14 | static int simple_hello(struct udevice *dev, int ch) |
Simon Glass | 63b1757 | 2014-02-26 15:59:23 -0700 | [diff] [blame] | 15 | { |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 16 | const struct dm_demo_pdata *pdata = dev_get_plat(dev); |
Simon Glass | 63b1757 | 2014-02-26 15:59:23 -0700 | [diff] [blame] | 17 | |
Mario Six | 61efece | 2018-02-12 08:05:57 +0100 | [diff] [blame] | 18 | printf("Hello from %08x: %s %d\n", (uint)map_to_sysmem(dev), pdata->colour, |
Simon Glass | 63b1757 | 2014-02-26 15:59:23 -0700 | [diff] [blame] | 19 | pdata->sides); |
| 20 | |
| 21 | return 0; |
| 22 | } |
| 23 | |
| 24 | static const struct demo_ops simple_ops = { |
| 25 | .hello = simple_hello, |
| 26 | }; |
| 27 | |
Simon Glass | aad29ae | 2020-12-03 16:55:21 -0700 | [diff] [blame] | 28 | static int demo_shape_of_to_plat(struct udevice *dev) |
Simon Glass | 63b1757 | 2014-02-26 15:59:23 -0700 | [diff] [blame] | 29 | { |
| 30 | /* Parse the data that is common with all demo devices */ |
| 31 | return demo_parse_dt(dev); |
| 32 | } |
| 33 | |
Simon Glass | 767827a | 2014-06-11 23:29:45 -0600 | [diff] [blame] | 34 | static const struct udevice_id demo_shape_id[] = { |
Simon Glass | 63b1757 | 2014-02-26 15:59:23 -0700 | [diff] [blame] | 35 | { "demo-simple", 0 }, |
| 36 | { }, |
| 37 | }; |
| 38 | |
| 39 | U_BOOT_DRIVER(demo_simple_drv) = { |
| 40 | .name = "demo_simple_drv", |
| 41 | .of_match = demo_shape_id, |
| 42 | .id = UCLASS_DEMO, |
Simon Glass | aad29ae | 2020-12-03 16:55:21 -0700 | [diff] [blame] | 43 | .of_to_plat = demo_shape_of_to_plat, |
Simon Glass | 63b1757 | 2014-02-26 15:59:23 -0700 | [diff] [blame] | 44 | .ops = &simple_ops, |
Simon Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 45 | .plat_auto = sizeof(struct dm_demo_pdata), |
Simon Glass | 63b1757 | 2014-02-26 15:59:23 -0700 | [diff] [blame] | 46 | }; |