efika-setup.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. *
  3. * Efika 5K2 platform setup
  4. * Some code really inspired from the lite5200b platform.
  5. *
  6. * Copyright (C) 2006 bplan GmbH
  7. *
  8. * This file is licensed under the terms of the GNU General Public License
  9. * version 2. This program is licensed "as is" without any warranty of any
  10. * kind, whether express or implied.
  11. *
  12. */
  13. #include <linux/errno.h>
  14. #include <linux/kernel.h>
  15. #include <linux/slab.h>
  16. #include <linux/reboot.h>
  17. #include <linux/init.h>
  18. #include <linux/utsrelease.h>
  19. #include <linux/seq_file.h>
  20. #include <linux/root_dev.h>
  21. #include <linux/initrd.h>
  22. #include <linux/timer.h>
  23. #include <linux/pci.h>
  24. #include <asm/pgtable.h>
  25. #include <asm/prom.h>
  26. #include <asm/time.h>
  27. #include <asm/machdep.h>
  28. #include <asm/rtas.h>
  29. #include <asm/of_device.h>
  30. #include <asm/of_platform.h>
  31. #include <asm/mpc52xx.h>
  32. #include "efika.h"
  33. static void efika_show_cpuinfo(struct seq_file *m)
  34. {
  35. struct device_node *root;
  36. const char *revision = NULL;
  37. const char *codegendescription = NULL;
  38. const char *codegenvendor = NULL;
  39. root = of_find_node_by_path("/");
  40. if (root) {
  41. revision = get_property(root, "revision", NULL);
  42. codegendescription =
  43. get_property(root, "CODEGEN,description", NULL);
  44. codegenvendor = get_property(root, "CODEGEN,vendor", NULL);
  45. of_node_put(root);
  46. }
  47. if (codegendescription)
  48. seq_printf(m, "machine\t\t: %s\n", codegendescription);
  49. else
  50. seq_printf(m, "machine\t\t: Efika\n");
  51. if (revision)
  52. seq_printf(m, "revision\t: %s\n", revision);
  53. if (codegenvendor)
  54. seq_printf(m, "vendor\t\t: %s\n", codegenvendor);
  55. of_node_put(root);
  56. }
  57. static void __init efika_setup_arch(void)
  58. {
  59. rtas_initialize();
  60. #ifdef CONFIG_BLK_DEV_INITRD
  61. initrd_below_start_ok = 1;
  62. if (initrd_start)
  63. ROOT_DEV = Root_RAM0;
  64. else
  65. #endif
  66. ROOT_DEV = Root_SDA2; /* sda2 (sda1 is for the kernel) */
  67. efika_pcisetup();
  68. if (ppc_md.progress)
  69. ppc_md.progress("Linux/PPC " UTS_RELEASE " runnung on Efika ;-)\n", 0x0);
  70. }
  71. static void __init efika_init(void)
  72. {
  73. struct device_node *np;
  74. struct device_node *cnp = NULL;
  75. const u32 *base;
  76. /* Find every child of the SOC node and add it to of_platform */
  77. np = of_find_node_by_name(NULL, "builtin");
  78. if (np) {
  79. char name[BUS_ID_SIZE];
  80. while ((cnp = of_get_next_child(np, cnp))) {
  81. strcpy(name, cnp->name);
  82. base = get_property(cnp, "reg", NULL);
  83. if (base == NULL)
  84. continue;
  85. snprintf(name+strlen(name), BUS_ID_SIZE, "@%x", *base);
  86. of_platform_device_create(cnp, name, NULL);
  87. printk(KERN_INFO EFIKA_PLATFORM_NAME" : Added %s (type '%s' at '%s') to the known devices\n", name, cnp->type, cnp->full_name);
  88. }
  89. }
  90. if (ppc_md.progress)
  91. ppc_md.progress(" Have fun with your Efika! ", 0x7777);
  92. }
  93. static int __init efika_probe(void)
  94. {
  95. char *model = of_get_flat_dt_prop(of_get_flat_dt_root(),
  96. "model", NULL);
  97. if (model == NULL)
  98. return 0;
  99. if (strcmp(model, "EFIKA5K2"))
  100. return 0;
  101. ISA_DMA_THRESHOLD = ~0L;
  102. DMA_MODE_READ = 0x44;
  103. DMA_MODE_WRITE = 0x48;
  104. return 1;
  105. }
  106. define_machine(efika)
  107. {
  108. .name = EFIKA_PLATFORM_NAME,
  109. .probe = efika_probe,
  110. .setup_arch = efika_setup_arch,
  111. .init = efika_init,
  112. .show_cpuinfo = efika_show_cpuinfo,
  113. .init_IRQ = mpc52xx_init_irq,
  114. .get_irq = mpc52xx_get_irq,
  115. .restart = rtas_restart,
  116. .power_off = rtas_power_off,
  117. .halt = rtas_halt,
  118. .set_rtc_time = rtas_set_rtc_time,
  119. .get_rtc_time = rtas_get_rtc_time,
  120. .progress = rtas_progress,
  121. .get_boot_time = rtas_get_boot_time,
  122. .calibrate_decr = generic_calibrate_decr,
  123. .phys_mem_access_prot = pci_phys_mem_access_prot,
  124. };