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