prom.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * This program is free software; you can redistribute it and/or modify it
  3. * under the terms of the GNU General Public License version 2 as published
  4. * by the Free Software Foundation.
  5. *
  6. * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
  7. */
  8. #include <linux/module.h>
  9. #include <linux/clk.h>
  10. #include <asm/bootinfo.h>
  11. #include <asm/time.h>
  12. #include <lantiq.h>
  13. #include "prom.h"
  14. #include "clk.h"
  15. static struct ltq_soc_info soc_info;
  16. unsigned int ltq_get_cpu_ver(void)
  17. {
  18. return soc_info.rev;
  19. }
  20. EXPORT_SYMBOL(ltq_get_cpu_ver);
  21. unsigned int ltq_get_soc_type(void)
  22. {
  23. return soc_info.type;
  24. }
  25. EXPORT_SYMBOL(ltq_get_soc_type);
  26. const char *get_system_type(void)
  27. {
  28. return soc_info.sys_type;
  29. }
  30. void prom_free_prom_memory(void)
  31. {
  32. }
  33. static void __init prom_init_cmdline(void)
  34. {
  35. int argc = fw_arg0;
  36. char **argv = (char **) KSEG1ADDR(fw_arg1);
  37. int i;
  38. for (i = 0; i < argc; i++) {
  39. char *p = (char *) KSEG1ADDR(argv[i]);
  40. if (p && *p) {
  41. strlcat(arcs_cmdline, p, sizeof(arcs_cmdline));
  42. strlcat(arcs_cmdline, " ", sizeof(arcs_cmdline));
  43. }
  44. }
  45. }
  46. void __init prom_init(void)
  47. {
  48. struct clk *clk;
  49. ltq_soc_detect(&soc_info);
  50. clk_init();
  51. clk = clk_get(0, "cpu");
  52. snprintf(soc_info.sys_type, LTQ_SYS_TYPE_LEN - 1, "%s rev1.%d",
  53. soc_info.name, soc_info.rev);
  54. clk_put(clk);
  55. soc_info.sys_type[LTQ_SYS_TYPE_LEN - 1] = '\0';
  56. pr_info("SoC: %s\n", soc_info.sys_type);
  57. prom_init_cmdline();
  58. }