platform.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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_platform.h>
  12. #include <linux/of_address.h>
  13. #include <linux/of_fdt.h>
  14. #include <linux/err.h>
  15. #include <linux/slab.h>
  16. #include <linux/sys_soc.h>
  17. #include <linux/io.h>
  18. static int __init nios2_soc_device_init(void)
  19. {
  20. struct soc_device *soc_dev;
  21. struct soc_device_attribute *soc_dev_attr;
  22. const char *machine;
  23. soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
  24. if (soc_dev_attr) {
  25. machine = of_flat_dt_get_machine_name();
  26. if (machine)
  27. soc_dev_attr->machine = kasprintf(GFP_KERNEL, "%s",
  28. machine);
  29. soc_dev_attr->family = "Nios II";
  30. soc_dev = soc_device_register(soc_dev_attr);
  31. if (IS_ERR(soc_dev)) {
  32. kfree(soc_dev_attr->machine);
  33. kfree(soc_dev_attr);
  34. }
  35. }
  36. return of_platform_populate(NULL, of_default_bus_match_table,
  37. NULL, NULL);
  38. }
  39. device_initcall(nios2_soc_device_init);