ppc83xx_setup.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. * arch/ppc/syslib/ppc83xx_setup.c
  3. *
  4. * MPC83XX common board code
  5. *
  6. * Maintainer: Kumar Gala <kumar.gala@freescale.com>
  7. *
  8. * Copyright 2005 Freescale Semiconductor Inc.
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the
  12. * Free Software Foundation; either version 2 of the License, or (at your
  13. * option) any later version.
  14. */
  15. #include <linux/config.h>
  16. #include <linux/types.h>
  17. #include <linux/module.h>
  18. #include <linux/init.h>
  19. #include <linux/pci.h>
  20. #include <linux/serial.h>
  21. #include <linux/tty.h> /* for linux/serial_core.h */
  22. #include <linux/serial_core.h>
  23. #include <linux/serial_8250.h>
  24. #include <asm/time.h>
  25. #include <asm/mpc83xx.h>
  26. #include <asm/mmu.h>
  27. #include <asm/ppc_sys.h>
  28. #include <asm/kgdb.h>
  29. #include <asm/delay.h>
  30. #include <syslib/ppc83xx_setup.h>
  31. phys_addr_t immrbar;
  32. /* Return the amount of memory */
  33. unsigned long __init
  34. mpc83xx_find_end_of_memory(void)
  35. {
  36. bd_t *binfo;
  37. binfo = (bd_t *) __res;
  38. return binfo->bi_memsize;
  39. }
  40. long __init
  41. mpc83xx_time_init(void)
  42. {
  43. #define SPCR_OFFS 0x00000110
  44. #define SPCR_TBEN 0x00400000
  45. bd_t *binfo = (bd_t *)__res;
  46. u32 *spcr = ioremap(binfo->bi_immr_base + SPCR_OFFS, 4);
  47. *spcr |= SPCR_TBEN;
  48. iounmap(spcr);
  49. return 0;
  50. }
  51. /* The decrementer counts at the system (internal) clock freq divided by 4 */
  52. void __init
  53. mpc83xx_calibrate_decr(void)
  54. {
  55. bd_t *binfo = (bd_t *) __res;
  56. unsigned int freq, divisor;
  57. freq = binfo->bi_busfreq;
  58. divisor = 4;
  59. tb_ticks_per_jiffy = freq / HZ / divisor;
  60. tb_to_us = mulhwu_scale_factor(freq / divisor, 1000000);
  61. }
  62. #ifdef CONFIG_SERIAL_8250
  63. void __init
  64. mpc83xx_early_serial_map(void)
  65. {
  66. #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
  67. struct uart_port serial_req;
  68. #endif
  69. struct plat_serial8250_port *pdata;
  70. bd_t *binfo = (bd_t *) __res;
  71. pdata = (struct plat_serial8250_port *) ppc_sys_get_pdata(MPC83xx_DUART);
  72. /* Setup serial port access */
  73. pdata[0].uartclk = binfo->bi_busfreq;
  74. pdata[0].mapbase += binfo->bi_immr_base;
  75. pdata[0].membase = ioremap(pdata[0].mapbase, 0x100);
  76. #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
  77. memset(&serial_req, 0, sizeof (serial_req));
  78. serial_req.iotype = SERIAL_IO_MEM;
  79. serial_req.mapbase = pdata[0].mapbase;
  80. serial_req.membase = pdata[0].membase;
  81. serial_req.regshift = 0;
  82. gen550_init(0, &serial_req);
  83. #endif
  84. pdata[1].uartclk = binfo->bi_busfreq;
  85. pdata[1].mapbase += binfo->bi_immr_base;
  86. pdata[1].membase = ioremap(pdata[1].mapbase, 0x100);
  87. #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
  88. /* Assume gen550_init() doesn't modify serial_req */
  89. serial_req.mapbase = pdata[1].mapbase;
  90. serial_req.membase = pdata[1].membase;
  91. gen550_init(1, &serial_req);
  92. #endif
  93. }
  94. #endif
  95. void
  96. mpc83xx_restart(char *cmd)
  97. {
  98. volatile unsigned char __iomem *reg;
  99. unsigned char tmp;
  100. reg = ioremap(BCSR_PHYS_ADDR, BCSR_SIZE);
  101. local_irq_disable();
  102. /*
  103. * Unlock the BCSR bits so a PRST will update the contents.
  104. * Otherwise the reset asserts but doesn't clear.
  105. */
  106. tmp = in_8(reg + BCSR_MISC_REG3_OFF);
  107. tmp |= BCSR_MISC_REG3_CNFLOCK; /* low true, high false */
  108. out_8(reg + BCSR_MISC_REG3_OFF, tmp);
  109. /*
  110. * Trigger a reset via a low->high transition of the
  111. * PORESET bit.
  112. */
  113. tmp = in_8(reg + BCSR_MISC_REG2_OFF);
  114. tmp &= ~BCSR_MISC_REG2_PORESET;
  115. out_8(reg + BCSR_MISC_REG2_OFF, tmp);
  116. udelay(1);
  117. tmp |= BCSR_MISC_REG2_PORESET;
  118. out_8(reg + BCSR_MISC_REG2_OFF, tmp);
  119. for(;;);
  120. }
  121. void
  122. mpc83xx_power_off(void)
  123. {
  124. local_irq_disable();
  125. for(;;);
  126. }
  127. void
  128. mpc83xx_halt(void)
  129. {
  130. local_irq_disable();
  131. for(;;);
  132. }
  133. /* PCI SUPPORT DOES NOT EXIT, MODEL after ppc85xx_setup.c */