platform.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (C) 2013 Altera Corporation
  3. * Copyright (C) 2011 Thomas Chou
  4. * Copyright (C) 2011 Walter Goossens
  5. *
  6. * This file is subject to the terms and conditions of the GNU General
  7. * Public License. See the file COPYING in the main directory of this
  8. * archive for more details.
  9. */
  10. #include <linux/init.h>
  11. #include <linux/of_address.h>
  12. #include <linux/of_fdt.h>
  13. #include <linux/err.h>
  14. #include <linux/slab.h>
  15. #include <linux/sys_soc.h>
  16. #include <linux/io.h>
  17. static int __init nios2_soc_device_init(void)
  18. {
  19. struct soc_device *soc_dev;
  20. struct soc_device_attribute *soc_dev_attr;
  21. const char *machine;
  22. soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
  23. if (soc_dev_attr) {
  24. machine = of_flat_dt_get_machine_name();
  25. if (machine)
  26. soc_dev_attr->machine = kasprintf(GFP_KERNEL, "%s",
  27. machine);
  28. soc_dev_attr->family = "Nios II";
  29. soc_dev = soc_device_register(soc_dev_attr);
  30. if (IS_ERR(soc_dev)) {
  31. kfree(soc_dev_attr->machine);
  32. kfree(soc_dev_attr);
  33. }
  34. }
  35. return 0;
  36. }
  37. device_initcall(nios2_soc_device_init);