1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+ 239f7611fSSimon Glass /* 339f7611fSSimon Glass * Copyright (c) 2013 Google, Inc 439f7611fSSimon Glass * 539f7611fSSimon Glass * (C) Copyright 2012 639f7611fSSimon Glass * Pavel Herrmann <morpheus.ibis@gmail.com> 739f7611fSSimon Glass */ 839f7611fSSimon Glass 939f7611fSSimon Glass #include <common.h> 1039f7611fSSimon Glass #include <dm.h> 1139f7611fSSimon Glass #include <dm-demo.h> 120eb25b61SJoe Hershberger #include <mapmem.h> 1339f7611fSSimon Glass #include <asm/io.h> 1439f7611fSSimon Glass 1554c5d08aSHeiko Schocher static int simple_hello(struct udevice *dev, int ch) 1639f7611fSSimon Glass { 1739f7611fSSimon Glass const struct dm_demo_pdata *pdata = dev_get_platdata(dev); 1839f7611fSSimon Glass 19c6b89f31SMario Six printf("Hello from %08x: %s %d\n", (uint)map_to_sysmem(dev), pdata->colour, 2039f7611fSSimon Glass pdata->sides); 2139f7611fSSimon Glass 2239f7611fSSimon Glass return 0; 2339f7611fSSimon Glass } 2439f7611fSSimon Glass 2539f7611fSSimon Glass static const struct demo_ops simple_ops = { 2639f7611fSSimon Glass .hello = simple_hello, 2739f7611fSSimon Glass }; 2839f7611fSSimon Glass 2954c5d08aSHeiko Schocher static int demo_shape_ofdata_to_platdata(struct udevice *dev) 3039f7611fSSimon Glass { 3139f7611fSSimon Glass /* Parse the data that is common with all demo devices */ 3239f7611fSSimon Glass return demo_parse_dt(dev); 3339f7611fSSimon Glass } 3439f7611fSSimon Glass 35ae7f4513SSimon Glass static const struct udevice_id demo_shape_id[] = { 3639f7611fSSimon Glass { "demo-simple", 0 }, 3739f7611fSSimon Glass { }, 3839f7611fSSimon Glass }; 3939f7611fSSimon Glass 4039f7611fSSimon Glass U_BOOT_DRIVER(demo_simple_drv) = { 4139f7611fSSimon Glass .name = "demo_simple_drv", 4239f7611fSSimon Glass .of_match = demo_shape_id, 4339f7611fSSimon Glass .id = UCLASS_DEMO, 4439f7611fSSimon Glass .ofdata_to_platdata = demo_shape_ofdata_to_platdata, 4539f7611fSSimon Glass .ops = &simple_ops, 4639f7611fSSimon Glass .platdata_auto_alloc_size = sizeof(struct dm_demo_pdata), 4739f7611fSSimon Glass }; 48