coreboot_table-of.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * coreboot_table-of.c
  3. *
  4. * Coreboot table access through open firmware.
  5. *
  6. * Copyright 2017 Google Inc.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License v2.0 as published by
  10. * the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. */
  17. #include <linux/device.h>
  18. #include <linux/io.h>
  19. #include <linux/module.h>
  20. #include <linux/of_address.h>
  21. #include <linux/platform_device.h>
  22. #include "coreboot_table.h"
  23. static int coreboot_table_of_probe(struct platform_device *pdev)
  24. {
  25. struct device_node *fw_dn = pdev->dev.of_node;
  26. void __iomem *ptr;
  27. ptr = of_iomap(fw_dn, 0);
  28. if (!ptr)
  29. return -ENOMEM;
  30. return coreboot_table_init(&pdev->dev, ptr);
  31. }
  32. static int coreboot_table_of_remove(struct platform_device *pdev)
  33. {
  34. return coreboot_table_exit();
  35. }
  36. static const struct of_device_id coreboot_of_match[] = {
  37. { .compatible = "coreboot" },
  38. {}
  39. };
  40. MODULE_DEVICE_TABLE(of, coreboot_of_match);
  41. static struct platform_driver coreboot_table_of_driver = {
  42. .probe = coreboot_table_of_probe,
  43. .remove = coreboot_table_of_remove,
  44. .driver = {
  45. .name = "coreboot_table_of",
  46. .of_match_table = coreboot_of_match,
  47. },
  48. };
  49. module_platform_driver(coreboot_table_of_driver);
  50. MODULE_AUTHOR("Google, Inc.");
  51. MODULE_LICENSE("GPL");