platform.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #include <linux/clk-provider.h>
  18. static const struct of_device_id clk_match[] __initconst = {
  19. { .compatible = "fixed-clock", .data = of_fixed_clk_setup, },
  20. {}
  21. };
  22. static int __init nios2_soc_device_init(void)
  23. {
  24. struct soc_device *soc_dev;
  25. struct soc_device_attribute *soc_dev_attr;
  26. const char *machine;
  27. soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
  28. if (soc_dev_attr) {
  29. machine = of_flat_dt_get_machine_name();
  30. if (machine)
  31. soc_dev_attr->machine = kasprintf(GFP_KERNEL, "%s",
  32. machine);
  33. soc_dev_attr->family = "Nios II";
  34. soc_dev = soc_device_register(soc_dev_attr);
  35. if (IS_ERR(soc_dev)) {
  36. kfree(soc_dev_attr->machine);
  37. kfree(soc_dev_attr);
  38. }
  39. }
  40. of_clk_init(clk_match);
  41. return 0;
  42. }
  43. device_initcall(nios2_soc_device_init);