setup.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. * Copyright 2000 MontaVista Software Inc.
  3. * Author: MontaVista Software, Inc.
  4. * ppopov@mvista.com or source@mvista.com
  5. *
  6. * Updates to 2.6, Pete Popov, Embedded Alley Solutions, Inc.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  14. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  15. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  16. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  17. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  18. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  19. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  20. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  22. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. *
  24. * You should have received a copy of the GNU General Public License along
  25. * with this program; if not, write to the Free Software Foundation, Inc.,
  26. * 675 Mass Ave, Cambridge, MA 02139, USA.
  27. */
  28. #include <linux/config.h>
  29. #include <linux/init.h>
  30. #include <linux/sched.h>
  31. #include <linux/ioport.h>
  32. #include <linux/mm.h>
  33. #include <linux/delay.h>
  34. #include <linux/interrupt.h>
  35. #include <asm/cpu.h>
  36. #include <asm/bootinfo.h>
  37. #include <asm/irq.h>
  38. #include <asm/mipsregs.h>
  39. #include <asm/reboot.h>
  40. #include <asm/pgtable.h>
  41. #include <asm/mach-au1x00/au1000.h>
  42. #include <asm/time.h>
  43. extern char * __init prom_getcmdline(void);
  44. extern void __init board_setup(void);
  45. extern void au1000_restart(char *);
  46. extern void au1000_halt(void);
  47. extern void au1000_power_off(void);
  48. extern struct resource ioport_resource;
  49. extern struct resource iomem_resource;
  50. extern void (*board_time_init)(void);
  51. extern void au1x_time_init(void);
  52. extern void (*board_timer_setup)(struct irqaction *irq);
  53. extern void au1x_timer_setup(struct irqaction *irq);
  54. extern void au1xxx_time_init(void);
  55. extern void au1xxx_timer_setup(struct irqaction *irq);
  56. extern void set_cpuspec(void);
  57. static int __init au1x00_setup(void)
  58. {
  59. struct cpu_spec *sp;
  60. char *argptr;
  61. unsigned long prid, cpupll, bclk = 1;
  62. set_cpuspec();
  63. sp = cur_cpu_spec[0];
  64. board_setup(); /* board specific setup */
  65. prid = read_c0_prid();
  66. cpupll = (au_readl(0xB1900060) & 0x3F) * 12;
  67. printk("(PRId %08lx) @ %ldMHZ\n", prid, cpupll);
  68. bclk = sp->cpu_bclk;
  69. if (bclk)
  70. {
  71. /* Enable BCLK switching */
  72. bclk = au_readl(0xB190003C);
  73. au_writel(bclk | 0x60, 0xB190003C);
  74. printk("BCLK switching enabled!\n");
  75. }
  76. if (sp->cpu_od) {
  77. /* Various early Au1000 Errata corrected by this */
  78. set_c0_config(1<<19); /* Set Config[OD] */
  79. }
  80. else {
  81. /* Clear to obtain best system bus performance */
  82. clear_c0_config(1<<19); /* Clear Config[OD] */
  83. }
  84. argptr = prom_getcmdline();
  85. #ifdef CONFIG_SERIAL_AU1X00_CONSOLE
  86. if ((argptr = strstr(argptr, "console=")) == NULL) {
  87. argptr = prom_getcmdline();
  88. strcat(argptr, " console=ttyS0,115200");
  89. }
  90. #endif
  91. #ifdef CONFIG_FB_AU1100
  92. if ((argptr = strstr(argptr, "video=")) == NULL) {
  93. argptr = prom_getcmdline();
  94. /* default panel */
  95. /*strcat(argptr, " video=au1100fb:panel:Sharp_320x240_16");*/
  96. #ifdef CONFIG_MIPS_HYDROGEN3
  97. strcat(argptr, " video=au1100fb:panel:Hydrogen_3_NEC_panel_320x240,nohwcursor");
  98. #else
  99. strcat(argptr, " video=au1100fb:panel:s10,nohwcursor");
  100. #endif
  101. }
  102. #endif
  103. #ifdef CONFIG_FB_E1356
  104. if ((argptr = strstr(argptr, "video=")) == NULL) {
  105. argptr = prom_getcmdline();
  106. #ifdef CONFIG_MIPS_PB1000
  107. strcat(argptr, " video=e1356fb:system:pb1000,mmunalign:1");
  108. #else
  109. strcat(argptr, " video=e1356fb:system:pb1500");
  110. #endif
  111. }
  112. #endif
  113. #ifdef CONFIG_FB_XPERT98
  114. if ((argptr = strstr(argptr, "video=")) == NULL) {
  115. argptr = prom_getcmdline();
  116. strcat(argptr, " video=atyfb:1024x768-8@70");
  117. }
  118. #endif
  119. #if defined(CONFIG_SOUND_AU1X00) && !defined(CONFIG_SOC_AU1000)
  120. /* au1000 does not support vra, au1500 and au1100 do */
  121. strcat(argptr, " au1000_audio=vra");
  122. argptr = prom_getcmdline();
  123. #endif
  124. _machine_restart = au1000_restart;
  125. _machine_halt = au1000_halt;
  126. _machine_power_off = au1000_power_off;
  127. board_time_init = au1xxx_time_init;
  128. board_timer_setup = au1xxx_timer_setup;
  129. /* IO/MEM resources. */
  130. set_io_port_base(0);
  131. ioport_resource.start = IOPORT_RESOURCE_START;
  132. ioport_resource.end = IOPORT_RESOURCE_END;
  133. iomem_resource.start = IOMEM_RESOURCE_START;
  134. iomem_resource.end = IOMEM_RESOURCE_END;
  135. while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_E0S);
  136. au_writel(SYS_CNTRL_E0 | SYS_CNTRL_EN0, SYS_COUNTER_CNTRL);
  137. au_sync();
  138. while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T0S);
  139. au_writel(0, SYS_TOYTRIM);
  140. return 0;
  141. }
  142. early_initcall(au1x00_setup);
  143. #if defined(CONFIG_64BIT_PHYS_ADDR)
  144. /* This routine should be valid for all Au1x based boards */
  145. phys_t fixup_bigphys_addr(phys_t phys_addr, phys_t size)
  146. {
  147. u32 start, end;
  148. /* Don't fixup 36 bit addresses */
  149. if ((phys_addr >> 32) != 0) return phys_addr;
  150. #ifdef CONFIG_PCI
  151. start = (u32)Au1500_PCI_MEM_START;
  152. end = (u32)Au1500_PCI_MEM_END;
  153. /* check for pci memory window */
  154. if ((phys_addr >= start) && ((phys_addr + size) < end)) {
  155. return (phys_t)((phys_addr - start) + Au1500_PCI_MEM_START);
  156. }
  157. #endif
  158. /* All Au1x SOCs have a pcmcia controller */
  159. /* We setup our 32 bit pseudo addresses to be equal to the
  160. * 36 bit addr >> 4, to make it easier to check the address
  161. * and fix it.
  162. * The Au1x socket 0 phys attribute address is 0xF 4000 0000.
  163. * The pseudo address we use is 0xF400 0000. Any address over
  164. * 0xF400 0000 is a pcmcia pseudo address.
  165. */
  166. if ((phys_addr >= 0xF4000000) && (phys_addr < 0xFFFFFFFF)) {
  167. return (phys_t)(phys_addr << 4);
  168. }
  169. /* default nop */
  170. return phys_addr;
  171. }
  172. #endif