init.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * EcoNet setup code
  4. *
  5. * Copyright (C) 2025 Caleb James DeLisle <cjd@cjdns.fr>
  6. */
  7. #include <linux/init.h>
  8. #include <linux/of_clk.h>
  9. #include <linux/irqchip.h>
  10. #include <asm/addrspace.h>
  11. #include <asm/io.h>
  12. #include <asm/bootinfo.h>
  13. #include <asm/time.h>
  14. #include <asm/prom.h>
  15. #include <asm/smp-ops.h>
  16. #include <asm/reboot.h>
  17. #define CR_AHB_RSTCR ((void __iomem *)CKSEG1ADDR(0x1fb00040))
  18. #define RESET BIT(31)
  19. #define UART_BASE CKSEG1ADDR(0x1fbf0003)
  20. #define UART_REG_SHIFT 2
  21. static void hw_reset(char *command)
  22. {
  23. iowrite32(RESET, CR_AHB_RSTCR);
  24. }
  25. /* 1. Bring up early printk. */
  26. void __init prom_init(void)
  27. {
  28. setup_8250_early_printk_port(UART_BASE, UART_REG_SHIFT, 0);
  29. _machine_restart = hw_reset;
  30. }
  31. /* 2. Parse the DT and find memory */
  32. void __init plat_mem_setup(void)
  33. {
  34. void *dtb;
  35. set_io_port_base(KSEG1);
  36. dtb = get_fdt();
  37. if (!dtb)
  38. panic("no dtb found");
  39. __dt_setup_arch(dtb);
  40. early_init_dt_scan_memory();
  41. }
  42. /* 3. Overload __weak device_tree_init(), add SMP_UP ops */
  43. void __init device_tree_init(void)
  44. {
  45. unflatten_and_copy_device_tree();
  46. register_up_smp_ops();
  47. }
  48. const char *get_system_type(void)
  49. {
  50. return "EcoNet-EN75xx";
  51. }
  52. /* 4. Initialize the IRQ subsystem */
  53. void __init arch_init_irq(void)
  54. {
  55. irqchip_init();
  56. }
  57. /* 5. Timers */
  58. void __init plat_time_init(void)
  59. {
  60. of_clk_init(NULL);
  61. timer_probe();
  62. }