demo-simple.c 992 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (c) 2013 Google, Inc
  4. *
  5. * (C) Copyright 2012
  6. * Pavel Herrmann <morpheus.ibis@gmail.com>
  7. */
  8. #include <common.h>
  9. #include <dm.h>
  10. #include <dm-demo.h>
  11. #include <mapmem.h>
  12. #include <asm/io.h>
  13. static int simple_hello(struct udevice *dev, int ch)
  14. {
  15. const struct dm_demo_pdata *pdata = dev_get_plat(dev);
  16. printf("Hello from %08x: %s %d\n", (uint)map_to_sysmem(dev), pdata->colour,
  17. pdata->sides);
  18. return 0;
  19. }
  20. static const struct demo_ops simple_ops = {
  21. .hello = simple_hello,
  22. };
  23. static int demo_shape_of_to_plat(struct udevice *dev)
  24. {
  25. /* Parse the data that is common with all demo devices */
  26. return demo_parse_dt(dev);
  27. }
  28. static const struct udevice_id demo_shape_id[] = {
  29. { "demo-simple", 0 },
  30. { },
  31. };
  32. U_BOOT_DRIVER(demo_simple_drv) = {
  33. .name = "demo_simple_drv",
  34. .of_match = demo_shape_id,
  35. .id = UCLASS_DEMO,
  36. .of_to_plat = demo_shape_of_to_plat,
  37. .ops = &simple_ops,
  38. .plat_auto = sizeof(struct dm_demo_pdata),
  39. };