setup.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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/mpc52xx.h>
  31. #include "efika.h"
  32. static void efika_show_cpuinfo(struct seq_file *m)
  33. {
  34. struct device_node *root;
  35. const char *revision = NULL;
  36. const char *codegendescription = NULL;
  37. const char *codegenvendor = NULL;
  38. root = of_find_node_by_path("/");
  39. if (root) {
  40. revision = get_property(root, "revision", NULL);
  41. codegendescription =
  42. get_property(root, "CODEGEN,description", NULL);
  43. codegenvendor = get_property(root, "CODEGEN,vendor", NULL);
  44. of_node_put(root);
  45. }
  46. if (codegendescription)
  47. seq_printf(m, "machine\t\t: %s\n", codegendescription);
  48. else
  49. seq_printf(m, "machine\t\t: Efika\n");
  50. if (revision)
  51. seq_printf(m, "revision\t: %s\n", revision);
  52. if (codegenvendor)
  53. seq_printf(m, "vendor\t\t: %s\n", codegenvendor);
  54. of_node_put(root);
  55. }
  56. static void __init efika_setup_arch(void)
  57. {
  58. rtas_initialize();
  59. #ifdef CONFIG_BLK_DEV_INITRD
  60. initrd_below_start_ok = 1;
  61. if (initrd_start)
  62. ROOT_DEV = Root_RAM0;
  63. else
  64. #endif
  65. ROOT_DEV = Root_SDA2; /* sda2 (sda1 is for the kernel) */
  66. efika_pcisetup();
  67. if (ppc_md.progress)
  68. ppc_md.progress("Linux/PPC " UTS_RELEASE " runnung on Efika ;-)\n", 0x0);
  69. }
  70. static void __init efika_init(void)
  71. {
  72. struct device_node *np;
  73. struct device_node *cnp = NULL;
  74. const u32 *base;
  75. /* Find every child of the SOC node and add it to of_platform */
  76. np = of_find_node_by_name(NULL, "builtin");
  77. if (np) {
  78. char name[BUS_ID_SIZE];
  79. while ((cnp = of_get_next_child(np, cnp))) {
  80. strcpy(name, cnp->name);
  81. base = get_property(cnp, "reg", NULL);
  82. if (base == NULL)
  83. continue;
  84. snprintf(name+strlen(name), BUS_ID_SIZE, "@%x", *base);
  85. of_platform_device_create(cnp, name, NULL);
  86. printk(KERN_INFO EFIKA_PLATFORM_NAME" : Added %s (type '%s' at '%s') to the known devices\n", name, cnp->type, cnp->full_name);
  87. }
  88. }
  89. if (ppc_md.progress)
  90. ppc_md.progress(" Have fun with your Efika! ", 0x7777);
  91. }
  92. static int __init efika_probe(void)
  93. {
  94. char *model = of_get_flat_dt_prop(of_get_flat_dt_root(),
  95. "model", NULL);
  96. if (model == NULL)
  97. return 0;
  98. if (strcmp(model, "EFIKA5K2"))
  99. return 0;
  100. ISA_DMA_THRESHOLD = ~0L;
  101. DMA_MODE_READ = 0x44;
  102. DMA_MODE_WRITE = 0x48;
  103. return 1;
  104. }
  105. define_machine(efika)
  106. {
  107. .name = EFIKA_PLATFORM_NAME,
  108. .probe = efika_probe,
  109. .setup_arch = efika_setup_arch,
  110. .init = efika_init,
  111. .show_cpuinfo = efika_show_cpuinfo,
  112. .init_IRQ = mpc52xx_init_irq,
  113. .get_irq = mpc52xx_get_irq,
  114. .restart = rtas_restart,
  115. .power_off = rtas_power_off,
  116. .halt = rtas_halt,
  117. .set_rtc_time = rtas_set_rtc_time,
  118. .get_rtc_time = rtas_get_rtc_time,
  119. .progress = rtas_progress,
  120. .get_boot_time = rtas_get_boot_time,
  121. .calibrate_decr = generic_calibrate_decr,
  122. .phys_mem_access_prot = pci_phys_mem_access_prot,
  123. };