reginfo.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. /*
  2. *(C) Copyright 2005-2009 Netstal Maschinen AG
  3. * Bruno Hars (Bruno.Hars@netstal.com)
  4. * Niklaus Giger (Niklaus.Giger@netstal.com)
  5. *
  6. * This source code is free software; you can redistribute it
  7. * and/or modify it in source code form under the terms of the GNU
  8. * General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  20. */
  21. /*
  22. * reginfo.c - register dump of HW-configuratin register for PPC4xx based board
  23. */
  24. #include <common.h>
  25. #include <command.h>
  26. #include <asm/processor.h>
  27. #include <asm/io.h>
  28. #include <asm/ppc4xx-uic.h>
  29. #include <asm/ppc4xx-emac.h>
  30. enum REGISTER_TYPE {
  31. IDCR1, /* Indirectly Accessed DCR via SDRAM0_CFGADDR/SDRAM0_CFGDATA */
  32. IDCR2, /* Indirectly Accessed DCR via EBC0_CFGADDR/EBC0_CFGDATA */
  33. IDCR3, /* Indirectly Accessed DCR via EBM0_CFGADDR/EBM0_CFGDATA */
  34. IDCR4, /* Indirectly Accessed DCR via PPM0_CFGADDR/PPM0_CFGDATA */
  35. IDCR5, /* Indirectly Accessed DCR via CPR0_CFGADDR/CPR0_CFGDATA */
  36. IDCR6, /* Indirectly Accessed DCR via SDR0_CFGADDR/SDR0_CFGDATA */
  37. MM /* Directly Accessed MMIO Register */
  38. };
  39. struct cpu_register {
  40. char *name;
  41. enum REGISTER_TYPE type;
  42. u32 address;
  43. };
  44. /*
  45. * PPC440EPx registers ordered for output
  46. * name type addr size
  47. * -------------------------------------------
  48. */
  49. const struct cpu_register ppc4xx_reg[] = {
  50. {"PB0CR", IDCR2, PB0CR},
  51. {"PB0AP", IDCR2, PB0AP},
  52. {"PB1CR", IDCR2, PB1CR},
  53. {"PB1AP", IDCR2, PB1AP},
  54. {"PB2CR", IDCR2, PB2CR},
  55. {"PB2AP", IDCR2, PB2AP},
  56. {"PB3CR", IDCR2, PB3CR},
  57. {"PB3AP", IDCR2, PB3AP},
  58. {"PB4CR", IDCR2, PB4CR},
  59. {"PB4AP", IDCR2, PB4AP},
  60. #if !defined(CONFIG_405EP)
  61. {"PB5CR", IDCR2, PB5CR},
  62. {"PB5AP", IDCR2, PB5AP},
  63. {"PB6CR", IDCR2, PB6CR},
  64. {"PB6AP", IDCR2, PB6AP},
  65. {"PB7CR", IDCR2, PB7CR},
  66. {"PB7AP", IDCR2, PB7AP},
  67. #endif
  68. {"PBEAR", IDCR2, PBEAR},
  69. #if defined(CONFIG_405EP) || defined (CONFIG_405GP)
  70. {"PBESR0", IDCR2, PBESR0},
  71. {"PBESR1", IDCR2, PBESR1},
  72. #endif
  73. {"EBC0_CFG", IDCR2, EBC0_CFG},
  74. #ifdef CONFIG_405GP
  75. {"SDRAM0_BESR0", IDCR1, SDRAM0_BESR0},
  76. {"SDRAM0_BESRS0", IDCR1, SDRAM0_BESRS0},
  77. {"SDRAM0_BESR1", IDCR1, SDRAM0_BESR1},
  78. {"SDRAM0_BESRS1", IDCR1, SDRAM0_BESRS1},
  79. {"SDRAM0_BEAR", IDCR1, SDRAM0_BEAR},
  80. {"SDRAM0_CFG", IDCR1, SDRAM0_CFG},
  81. {"SDRAM0_RTR", IDCR1, SDRAM0_RTR},
  82. {"SDRAM0_PMIT", IDCR1, SDRAM0_PMIT},
  83. {"SDRAM0_B0CR", IDCR1, SDRAM0_B0CR},
  84. {"SDRAM0_B1CR", IDCR1, SDRAM0_B1CR},
  85. {"SDRAM0_B2CR", IDCR1, SDRAM0_B2CR},
  86. {"SDRAM0_B3CR", IDCR1, SDRAM0_B1CR},
  87. {"SDRAM0_TR", IDCR1, SDRAM0_TR},
  88. {"SDRAM0_ECCCFG", IDCR1, SDRAM0_B1CR},
  89. {"SDRAM0_ECCESR", IDCR1, SDRAM0_ECCESR},
  90. #endif
  91. #ifdef CONFIG_440EPX
  92. {"SDR0_SDSTP0", IDCR6, SDR0_SDSTP0},
  93. {"SDR0_SDSTP1", IDCR6, SDR0_SDSTP1},
  94. {"SDR0_SDSTP2", IDCR6, SDR0_SDSTP2},
  95. {"SDR0_SDSTP3", IDCR6, SDR0_SDSTP3},
  96. {"SDR0_CUST0", IDCR6, SDR0_CUST0},
  97. {"SDR0_CUST1", IDCR6, SDR0_CUST1},
  98. {"SDR0_EBC", IDCR6, SDR0_EBC},
  99. {"SDR0_AMP0", IDCR6, SDR0_AMP0},
  100. {"SDR0_AMP1", IDCR6, SDR0_AMP1},
  101. {"SDR0_CP440", IDCR6, SDR0_CP440},
  102. {"SDR0_CRYP0", IDCR6, SDR0_CRYP0},
  103. {"SDR0_DDRCFG", IDCR6, SDR0_DDRCFG},
  104. {"SDR0_EMAC0RXST", IDCR6, SDR0_EMAC0RXST},
  105. {"SDR0_EMAC0TXST", IDCR6, SDR0_EMAC0TXST},
  106. {"SDR0_MFR", IDCR6, SDR0_MFR},
  107. {"SDR0_PCI0", IDCR6, SDR0_PCI0},
  108. {"SDR0_PFC0", IDCR6, SDR0_PFC0},
  109. {"SDR0_PFC1", IDCR6, SDR0_PFC1},
  110. {"SDR0_PFC2", IDCR6, SDR0_PFC2},
  111. {"SDR0_PFC4", IDCR6, SDR0_PFC4},
  112. {"SDR0_UART0", IDCR6, SDR0_UART0},
  113. {"SDR0_UART1", IDCR6, SDR0_UART1},
  114. {"SDR0_UART2", IDCR6, SDR0_UART2},
  115. {"SDR0_UART3", IDCR6, SDR0_UART3},
  116. {"DDR0_02", IDCR1, DDR0_02},
  117. {"DDR0_00", IDCR1, DDR0_00},
  118. {"DDR0_01", IDCR1, DDR0_01},
  119. {"DDR0_03", IDCR1, DDR0_03},
  120. {"DDR0_04", IDCR1, DDR0_04},
  121. {"DDR0_05", IDCR1, DDR0_05},
  122. {"DDR0_06", IDCR1, DDR0_06},
  123. {"DDR0_07", IDCR1, DDR0_07},
  124. {"DDR0_08", IDCR1, DDR0_08},
  125. {"DDR0_09", IDCR1, DDR0_09},
  126. {"DDR0_10", IDCR1, DDR0_10},
  127. {"DDR0_11", IDCR1, DDR0_11},
  128. {"DDR0_12", IDCR1, DDR0_12},
  129. {"DDR0_14", IDCR1, DDR0_14},
  130. {"DDR0_17", IDCR1, DDR0_17},
  131. {"DDR0_18", IDCR1, DDR0_18},
  132. {"DDR0_19", IDCR1, DDR0_19},
  133. {"DDR0_20", IDCR1, DDR0_20},
  134. {"DDR0_21", IDCR1, DDR0_21},
  135. {"DDR0_22", IDCR1, DDR0_22},
  136. {"DDR0_23", IDCR1, DDR0_23},
  137. {"DDR0_24", IDCR1, DDR0_24},
  138. {"DDR0_25", IDCR1, DDR0_25},
  139. {"DDR0_26", IDCR1, DDR0_26},
  140. {"DDR0_27", IDCR1, DDR0_27},
  141. {"DDR0_28", IDCR1, DDR0_28},
  142. {"DDR0_31", IDCR1, DDR0_31},
  143. {"DDR0_32", IDCR1, DDR0_32},
  144. {"DDR0_33", IDCR1, DDR0_33},
  145. {"DDR0_34", IDCR1, DDR0_34},
  146. {"DDR0_35", IDCR1, DDR0_35},
  147. {"DDR0_36", IDCR1, DDR0_36},
  148. {"DDR0_37", IDCR1, DDR0_37},
  149. {"DDR0_38", IDCR1, DDR0_38},
  150. {"DDR0_39", IDCR1, DDR0_39},
  151. {"DDR0_40", IDCR1, DDR0_40},
  152. {"DDR0_41", IDCR1, DDR0_41},
  153. {"DDR0_42", IDCR1, DDR0_42},
  154. {"DDR0_43", IDCR1, DDR0_43},
  155. {"DDR0_44", IDCR1, DDR0_44},
  156. {"CPR0_ICFG", IDCR5, CPR0_ICFG},
  157. {"CPR0_MALD", IDCR5, CPR0_MALD},
  158. {"CPR0_OPBD00", IDCR5, CPR0_OPBD0},
  159. {"CPR0_PERD0", IDCR5, CPR0_PERD},
  160. {"CPR0_PLLC0", IDCR5, CPR0_PLLC},
  161. {"CPR0_PLLD0", IDCR5, CPR0_PLLD},
  162. {"CPR0_PRIMAD0", IDCR5, CPR0_PRIMAD0},
  163. {"CPR0_PRIMBD0", IDCR5, CPR0_PRIMBD0},
  164. {"CPR0_SPCID", IDCR5, CPR0_SPCID},
  165. {"SPI0_MODE", MM, SPI0_MODE},
  166. {"IIC0_CLKDIV", MM, PCIL0_PMM1MA},
  167. {"PCIL0_PMM0MA", MM, PCIL0_PMM0MA},
  168. {"PCIL0_PMM1MA", MM, PCIL0_PMM1MA},
  169. {"PCIL0_PTM1LA", MM, PCIL0_PMM1MA},
  170. {"PCIL0_PTM1MS", MM, PCIL0_PTM1MS},
  171. {"PCIL0_PTM2LA", MM, PCIL0_PMM1MA},
  172. {"PCIL0_PTM2MS", MM, PCIL0_PTM2MS},
  173. {"ZMII0_FER", MM, ZMII0_FER},
  174. {"ZMII0_SSR", MM, ZMII0_SSR},
  175. {"EMAC0_IPGVR", MM, EMAC0_IPGVR},
  176. {"EMAC0_MR1", MM, EMAC0_MR1},
  177. {"EMAC0_PTR", MM, EMAC0_PTR},
  178. {"EMAC0_RWMR", MM, EMAC0_RWMR},
  179. {"EMAC0_STACR", MM, EMAC0_STACR},
  180. {"EMAC0_TMR0", MM, EMAC0_TMR0},
  181. {"EMAC0_TMR1", MM, EMAC0_TMR1},
  182. {"EMAC0_TRTR", MM, EMAC0_TRTR},
  183. {"EMAC1_MR1", MM, EMAC1_MR1},
  184. {"GPIO0_OR", MM, GPIO0_OR},
  185. {"GPIO1_OR", MM, GPIO1_OR},
  186. {"GPIO0_TCR", MM, GPIO0_TCR},
  187. {"GPIO1_TCR", MM, GPIO1_TCR},
  188. {"GPIO0_ODR", MM, GPIO0_ODR},
  189. {"GPIO1_ODR", MM, GPIO1_ODR},
  190. {"GPIO0_OSRL", MM, GPIO0_OSRL},
  191. {"GPIO0_OSRH", MM, GPIO0_OSRH},
  192. {"GPIO1_OSRL", MM, GPIO1_OSRL},
  193. {"GPIO1_OSRH", MM, GPIO1_OSRH},
  194. {"GPIO0_TSRL", MM, GPIO0_TSRL},
  195. {"GPIO0_TSRH", MM, GPIO0_TSRH},
  196. {"GPIO1_TSRL", MM, GPIO1_TSRL},
  197. {"GPIO1_TSRH", MM, GPIO1_TSRH},
  198. {"GPIO0_IR", MM, GPIO0_IR},
  199. {"GPIO1_IR", MM, GPIO1_IR},
  200. {"GPIO0_ISR1L", MM, GPIO0_ISR1L},
  201. {"GPIO0_ISR1H", MM, GPIO0_ISR1H},
  202. {"GPIO1_ISR1L", MM, GPIO1_ISR1L},
  203. {"GPIO1_ISR1H", MM, GPIO1_ISR1H},
  204. {"GPIO0_ISR2L", MM, GPIO0_ISR2L},
  205. {"GPIO0_ISR2H", MM, GPIO0_ISR2H},
  206. {"GPIO1_ISR2L", MM, GPIO1_ISR2L},
  207. {"GPIO1_ISR2H", MM, GPIO1_ISR2H},
  208. {"GPIO0_ISR3L", MM, GPIO0_ISR3L},
  209. {"GPIO0_ISR3H", MM, GPIO0_ISR3H},
  210. {"GPIO1_ISR3L", MM, GPIO1_ISR3L},
  211. {"GPIO1_ISR3H", MM, GPIO1_ISR3H},
  212. {"SDR0_USB2PHY0CR", IDCR6, SDR0_USB2PHY0CR},
  213. {"SDR0_USB2H0CR", IDCR6, SDR0_USB2H0CR},
  214. {"SDR0_USB2D0CR", IDCR6, SDR0_USB2D0CR},
  215. #endif
  216. };
  217. /*
  218. * CPU Register dump of PPC4xx HW configuration registers
  219. * Output: first all DCR-registers, then in order of struct ppc4xx_reg
  220. */
  221. #define PRINT_DCR(dcr) printf("0x%08x %-16s: 0x%08x\n", dcr,#dcr, mfdcr(dcr));
  222. void ppc4xx_reginfo(void)
  223. {
  224. unsigned int i;
  225. unsigned int n;
  226. u32 value;
  227. enum REGISTER_TYPE type;
  228. #if defined (CONFIG_405EP)
  229. printf("Dump PPC405EP HW configuration registers\n\n");
  230. #elif CONFIG_405GP
  231. printf ("Dump 405GP HW configuration registers\n\n");
  232. #elif CONFIG_440EPX
  233. printf("Dump PPC440EPx HW configuration registers\n\n");
  234. #endif
  235. printf("MSR: 0x%08x\n", mfmsr());
  236. printf ("\nUniversal Interrupt Controller Regs\n");
  237. PRINT_DCR(UIC0SR);
  238. PRINT_DCR(UIC0ER);
  239. PRINT_DCR(UIC0CR);
  240. PRINT_DCR(UIC0PR);
  241. PRINT_DCR(UIC0TR);
  242. PRINT_DCR(UIC0MSR);
  243. PRINT_DCR(UIC0VR);
  244. PRINT_DCR(UIC0VCR);
  245. #if (UIC_MAX > 1)
  246. PRINT_DCR(UIC2SR);
  247. PRINT_DCR(UIC2ER);
  248. PRINT_DCR(UIC2CR);
  249. PRINT_DCR(UIC2PR);
  250. PRINT_DCR(UIC2TR);
  251. PRINT_DCR(UIC2MSR);
  252. PRINT_DCR(UIC2VR);
  253. PRINT_DCR(UIC2VCR);
  254. #endif
  255. #if (UIC_MAX > 2)
  256. PRINT_DCR(UIC2SR);
  257. PRINT_DCR(UIC2ER);
  258. PRINT_DCR(UIC2CR);
  259. PRINT_DCR(UIC2PR);
  260. PRINT_DCR(UIC2TR);
  261. PRINT_DCR(UIC2MSR);
  262. PRINT_DCR(UIC2VR);
  263. PRINT_DCR(UIC2VCR);
  264. #endif
  265. #if (UIC_MAX > 3)
  266. PRINT_DCR(UIC3SR);
  267. PRINT_DCR(UIC3ER);
  268. PRINT_DCR(UIC3CR);
  269. PRINT_DCR(UIC3PR);
  270. PRINT_DCR(UIC3TR);
  271. PRINT_DCR(UIC3MSR);
  272. PRINT_DCR(UIC3VR);
  273. PRINT_DCR(UIC3VCR);
  274. #endif
  275. #if defined (CONFIG_405EP) || defined (CONFIG_405GP)
  276. printf ("\n\nDMA Channels\n");
  277. PRINT_DCR(DMASR);
  278. PRINT_DCR(DMASGC);
  279. PRINT_DCR(DMAADR);
  280. PRINT_DCR(DMACR0);
  281. PRINT_DCR(DMACT0);
  282. PRINT_DCR(DMADA0);
  283. PRINT_DCR(DMASA0);
  284. PRINT_DCR(DMASB0);
  285. PRINT_DCR(DMACR1);
  286. PRINT_DCR(DMACT1);
  287. PRINT_DCR(DMADA1);
  288. PRINT_DCR(DMASA1);
  289. PRINT_DCR(DMASB1);
  290. PRINT_DCR(DMACR2);
  291. PRINT_DCR(DMACT2);
  292. PRINT_DCR(DMADA2);
  293. PRINT_DCR(DMASA2);
  294. PRINT_DCR(DMASB2);
  295. PRINT_DCR(DMACR3);
  296. PRINT_DCR(DMACT3);
  297. PRINT_DCR(DMADA3);
  298. PRINT_DCR(DMASA3);
  299. PRINT_DCR(DMASB3);
  300. #endif
  301. printf ("\n\nVarious HW-Configuration registers\n");
  302. #if defined (CONFIG_440EPX)
  303. PRINT_DCR(MAL0_CFG);
  304. PRINT_DCR(CPM0_ER);
  305. PRINT_DCR(CPM1_ER);
  306. PRINT_DCR(PLB4A0_ACR);
  307. PRINT_DCR(PLB4A1_ACR);
  308. PRINT_DCR(PLB3A0_ACR);
  309. PRINT_DCR(OPB2PLB40_BCTRL);
  310. PRINT_DCR(P4P3BO0_CFG);
  311. #endif
  312. n = sizeof(ppc4xx_reg) / sizeof(ppc4xx_reg[0]);
  313. for (i = 0; i < n; i++) {
  314. value = 0;
  315. type = ppc4xx_reg[i].type;
  316. switch (type) {
  317. case IDCR1: /* Indirect via SDRAM0_CFGADDR/DDR0_CFGDATA */
  318. mtdcr(SDRAM0_CFGADDR, ppc4xx_reg[i].address);
  319. value = mfdcr(SDRAM0_CFGDATA);
  320. break;
  321. case IDCR2: /* Indirect via EBC0_CFGADDR/EBC0_CFGDATA */
  322. mtdcr(EBC0_CFGADDR, ppc4xx_reg[i].address);
  323. value = mfdcr(EBC0_CFGDATA);
  324. break;
  325. case IDCR5: /* Indirect via CPR0_CFGADDR/CPR0_CFGDATA */
  326. mtdcr(CPR0_CFGADDR, ppc4xx_reg[i].address);
  327. value = mfdcr(CPR0_CFGDATA);
  328. break;
  329. case IDCR6: /* Indirect via SDR0_CFGADDR/SDR0_CFGDATA */
  330. mtdcr(SDR0_CFGADDR, ppc4xx_reg[i].address);
  331. value = mfdcr(SDR0_CFGDATA);
  332. break;
  333. case MM: /* Directly Accessed MMIO Register */
  334. value = in_be32((const volatile unsigned __iomem *)
  335. ppc4xx_reg[i].address);
  336. break;
  337. default:
  338. printf("\nERROR: struct entry %d: unknown register"
  339. "type\n", i);
  340. break;
  341. }
  342. printf("0x%08x %-16s: 0x%08x\n",ppc4xx_reg[i].address,
  343. ppc4xx_reg[i].name, value);
  344. }
  345. }