ip32-setup.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * IP32 basic setup
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * Copyright (C) 2000 Harald Koerfgen
  9. * Copyright (C) 2002, 2003, 2005 Ilya A. Volynets
  10. * Copyright (C) 2006 Ralf Baechle <[email protected]>
  11. */
  12. #include <linux/console.h>
  13. #include <linux/init.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/param.h>
  16. #include <linux/sched.h>
  17. #include <asm/bootinfo.h>
  18. #include <asm/mipsregs.h>
  19. #include <asm/mmu_context.h>
  20. #include <asm/sgialib.h>
  21. #include <asm/time.h>
  22. #include <asm/traps.h>
  23. #include <asm/io.h>
  24. #include <asm/ip32/crime.h>
  25. #include <asm/ip32/mace.h>
  26. #include <asm/ip32/ip32_ints.h>
  27. extern void ip32_be_init(void);
  28. extern void crime_init(void);
  29. #ifdef CONFIG_SGI_O2MACE_ETH
  30. /*
  31. * This is taken care of in here 'cause they say using Arc later on is
  32. * problematic
  33. */
  34. extern char o2meth_eaddr[8];
  35. static inline unsigned char str2hexnum(unsigned char c)
  36. {
  37. if (c >= '0' && c <= '9')
  38. return c - '0';
  39. if (c >= 'a' && c <= 'f')
  40. return c - 'a' + 10;
  41. return 0; /* foo */
  42. }
  43. static inline void str2eaddr(unsigned char *ea, unsigned char *str)
  44. {
  45. int i;
  46. for (i = 0; i < 6; i++) {
  47. unsigned char num;
  48. if(*str == ':')
  49. str++;
  50. num = str2hexnum(*str++) << 4;
  51. num |= (str2hexnum(*str++));
  52. ea[i] = num;
  53. }
  54. }
  55. #endif
  56. /* An arbitrary time; this can be decreased if reliability looks good */
  57. #define WAIT_MS 10
  58. void __init plat_time_init(void)
  59. {
  60. printk(KERN_INFO "Calibrating system timer... ");
  61. write_c0_count(0);
  62. crime->timer = 0;
  63. while (crime->timer < CRIME_MASTER_FREQ * WAIT_MS / 1000) ;
  64. mips_hpt_frequency = read_c0_count() * 1000 / WAIT_MS;
  65. printk("%d MHz CPU detected\n", mips_hpt_frequency * 2 / 1000000);
  66. }
  67. void __init plat_mem_setup(void)
  68. {
  69. board_be_init = ip32_be_init;
  70. #ifdef CONFIG_SGI_O2MACE_ETH
  71. {
  72. char *mac = ArcGetEnvironmentVariable("eaddr");
  73. str2eaddr(o2meth_eaddr, mac);
  74. }
  75. #endif
  76. #if defined(CONFIG_SERIAL_CORE_CONSOLE)
  77. {
  78. char* con = ArcGetEnvironmentVariable("console");
  79. if (con && *con == 'd') {
  80. static char options[8] __initdata;
  81. char *baud = ArcGetEnvironmentVariable("dbaud");
  82. if (baud)
  83. strcpy(options, baud);
  84. add_preferred_console("ttyS", *(con + 1) == '2' ? 1 : 0,
  85. baud ? options : NULL);
  86. }
  87. }
  88. #endif
  89. }