prom.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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) 2012 Thomas Langer <thomas.langer@lantiq.com>
  7. * Copyright (C) 2012 John Crispin <john@phrozen.org>
  8. */
  9. #include <linux/kernel.h>
  10. #include <asm/cacheflush.h>
  11. #include <asm/traps.h>
  12. #include <asm/io.h>
  13. #include <lantiq_soc.h>
  14. #include "../prom.h"
  15. #define SOC_FALCON "Falcon"
  16. #define SOC_FALCON_D "Falcon-D"
  17. #define SOC_FALCON_V "Falcon-V"
  18. #define SOC_FALCON_M "Falcon-M"
  19. #define COMP_FALCON "lantiq,falcon"
  20. #define PART_SHIFT 12
  21. #define PART_MASK 0x0FFFF000
  22. #define REV_SHIFT 28
  23. #define REV_MASK 0xF0000000
  24. #define SREV_SHIFT 22
  25. #define SREV_MASK 0x03C00000
  26. #define TYPE_SHIFT 26
  27. #define TYPE_MASK 0x3C000000
  28. /* reset, nmi and ejtag exception vectors */
  29. #define BOOT_REG_BASE (KSEG1 | 0x1F200000)
  30. #define BOOT_RVEC (BOOT_REG_BASE | 0x00)
  31. #define BOOT_NVEC (BOOT_REG_BASE | 0x04)
  32. #define BOOT_EVEC (BOOT_REG_BASE | 0x08)
  33. void __init ltq_soc_nmi_setup(void)
  34. {
  35. extern void (*nmi_handler)(void);
  36. ltq_w32((unsigned long)&nmi_handler, (void *)BOOT_NVEC);
  37. }
  38. void __init ltq_soc_ejtag_setup(void)
  39. {
  40. extern void (*ejtag_debug_handler)(void);
  41. ltq_w32((unsigned long)&ejtag_debug_handler, (void *)BOOT_EVEC);
  42. }
  43. void __init ltq_soc_detect(struct ltq_soc_info *i)
  44. {
  45. u32 type;
  46. i->partnum = (ltq_r32(FALCON_CHIPID) & PART_MASK) >> PART_SHIFT;
  47. i->rev = (ltq_r32(FALCON_CHIPID) & REV_MASK) >> REV_SHIFT;
  48. i->srev = ((ltq_r32(FALCON_CHIPCONF) & SREV_MASK) >> SREV_SHIFT);
  49. i->compatible = COMP_FALCON;
  50. i->type = SOC_TYPE_FALCON;
  51. sprintf(i->rev_type, "%c%d%d", (i->srev & 0x4) ? ('B') : ('A'),
  52. i->rev & 0x7, (i->srev & 0x3) + 1);
  53. switch (i->partnum) {
  54. case SOC_ID_FALCON:
  55. type = (ltq_r32(FALCON_CHIPTYPE) & TYPE_MASK) >> TYPE_SHIFT;
  56. switch (type) {
  57. case 0:
  58. i->name = SOC_FALCON_D;
  59. break;
  60. case 1:
  61. i->name = SOC_FALCON_V;
  62. break;
  63. case 2:
  64. i->name = SOC_FALCON_M;
  65. break;
  66. default:
  67. i->name = SOC_FALCON;
  68. break;
  69. }
  70. break;
  71. default:
  72. unreachable();
  73. break;
  74. }
  75. board_nmi_handler_setup = ltq_soc_nmi_setup;
  76. board_ejtag_handler_setup = ltq_soc_ejtag_setup;
  77. }