Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 39f7611 | 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 | 39f7611 | 2014-02-26 15:59:23 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <dm.h> |
| 11 | #include <dm-demo.h> |
Joe Hershberger | 0eb25b6 | 2015-03-22 17:08:59 -0500 | [diff] [blame] | 12 | #include <mapmem.h> |
Simon Glass | 39f7611 | 2014-02-26 15:59:23 -0700 | [diff] [blame] | 13 | #include <asm/io.h> |
| 14 | |
Heiko Schocher | 54c5d08 | 2014-05-22 12:43:05 +0200 | [diff] [blame] | 15 | static int simple_hello(struct udevice *dev, int ch) |
Simon Glass | 39f7611 | 2014-02-26 15:59:23 -0700 | [diff] [blame] | 16 | { |
| 17 | const struct dm_demo_pdata *pdata = dev_get_platdata(dev); |
| 18 | |
Mario Six | c6b89f3 | 2018-02-12 08:05:57 +0100 | [diff] [blame] | 19 | printf("Hello from %08x: %s %d\n", (uint)map_to_sysmem(dev), pdata->colour, |
Simon Glass | 39f7611 | 2014-02-26 15:59:23 -0700 | [diff] [blame] | 20 | pdata->sides); |
| 21 | |
| 22 | return 0; |
| 23 | } |
| 24 | |
| 25 | static const struct demo_ops simple_ops = { |
| 26 | .hello = simple_hello, |
| 27 | }; |
| 28 | |
Heiko Schocher | 54c5d08 | 2014-05-22 12:43:05 +0200 | [diff] [blame] | 29 | static int demo_shape_ofdata_to_platdata(struct udevice *dev) |
Simon Glass | 39f7611 | 2014-02-26 15:59:23 -0700 | [diff] [blame] | 30 | { |
| 31 | /* Parse the data that is common with all demo devices */ |
| 32 | return demo_parse_dt(dev); |
| 33 | } |
| 34 | |
Simon Glass | ae7f451 | 2014-06-11 23:29:45 -0600 | [diff] [blame] | 35 | static const struct udevice_id demo_shape_id[] = { |
Simon Glass | 39f7611 | 2014-02-26 15:59:23 -0700 | [diff] [blame] | 36 | { "demo-simple", 0 }, |
| 37 | { }, |
| 38 | }; |
| 39 | |
| 40 | U_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 | }; |