demo-simple.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #include <common.h>
  10. #include <dm.h>
  11. #include <dm-demo.h>
  12. #include <mapmem.h>
  13. #include <asm/io.h>
  14. static int simple_hello(struct udevice *dev, int ch)
  15. {
  16. const struct dm_demo_pdata *pdata = dev_get_platdata(dev);
  17. printf("Hello from %08x: %s %d\n", map_to_sysmem(dev), pdata->colour,
  18. pdata->sides);
  19. return 0;
  20. }
  21. static const struct demo_ops simple_ops = {
  22. .hello = simple_hello,
  23. };
  24. static int demo_shape_ofdata_to_platdata(struct udevice *dev)
  25. {
  26. /* Parse the data that is common with all demo devices */
  27. return demo_parse_dt(dev);
  28. }
  29. static const struct udevice_id demo_shape_id[] = {
  30. { "demo-simple", 0 },
  31. { },
  32. };
  33. U_BOOT_DRIVER(demo_simple_drv) = {
  34. .name = "demo_simple_drv",
  35. .of_match = demo_shape_id,
  36. .id = UCLASS_DEMO,
  37. .ofdata_to_platdata = demo_shape_ofdata_to_platdata,
  38. .ops = &simple_ops,
  39. .platdata_auto_alloc_size = sizeof(struct dm_demo_pdata),
  40. };