board-ocelot.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // SPDX-License-Identifier: (GPL-2.0 OR MIT)
  2. /*
  3. * Microsemi MIPS SoC support
  4. *
  5. * Copyright (c) 2017 Microsemi Corporation
  6. */
  7. #include <asm/machine.h>
  8. #include <asm/prom.h>
  9. #define DEVCPU_GCB_CHIP_REGS_CHIP_ID 0x71070000
  10. #define CHIP_ID_PART_ID GENMASK(27, 12)
  11. #define OCELOT_PART_ID (0x7514 << 12)
  12. #define UART_UART 0x70100000
  13. static __init bool ocelot_detect(void)
  14. {
  15. u32 rev;
  16. int idx;
  17. /* Look for the TLB entry set up by redboot before trying to use it */
  18. write_c0_entryhi(DEVCPU_GCB_CHIP_REGS_CHIP_ID);
  19. mtc0_tlbw_hazard();
  20. tlb_probe();
  21. tlb_probe_hazard();
  22. idx = read_c0_index();
  23. if (idx < 0)
  24. return false;
  25. /* A TLB entry exists, lets assume its usable and check the CHIP ID */
  26. rev = __raw_readl((void __iomem *)DEVCPU_GCB_CHIP_REGS_CHIP_ID);
  27. if ((rev & CHIP_ID_PART_ID) != OCELOT_PART_ID)
  28. return false;
  29. /* Copy command line from bootloader early for Initrd detection */
  30. if (fw_arg0 < 10 && (fw_arg1 & 0xFFF00000) == 0x80000000) {
  31. unsigned int prom_argc = fw_arg0;
  32. const char **prom_argv = (const char **)fw_arg1;
  33. if (prom_argc > 1 && strlen(prom_argv[1]) > 0)
  34. /* ignore all built-in args if any f/w args given */
  35. strcpy(arcs_cmdline, prom_argv[1]);
  36. }
  37. return true;
  38. }
  39. static void __init ocelot_earlyprintk_init(void)
  40. {
  41. void __iomem *uart_base;
  42. uart_base = ioremap(UART_UART, 0x20);
  43. setup_8250_early_printk_port((unsigned long)uart_base, 2, 50000);
  44. }
  45. static void __init ocelot_late_init(void)
  46. {
  47. ocelot_earlyprintk_init();
  48. }
  49. static __init const void *ocelot_fixup_fdt(const void *fdt,
  50. const void *match_data)
  51. {
  52. /* This has to be done so late because ioremap needs to work */
  53. late_time_init = ocelot_late_init;
  54. return fdt;
  55. }
  56. extern char __dtb_ocelot_pcb123_begin[];
  57. MIPS_MACHINE(ocelot) = {
  58. .fdt = __dtb_ocelot_pcb123_begin,
  59. .fixup_fdt = ocelot_fixup_fdt,
  60. .detect = ocelot_detect,
  61. };