setup.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /*
  2. * linux/arch/mips/txx9/generic/setup.c
  3. *
  4. * Based on linux/arch/mips/txx9/rbtx4938/setup.c,
  5. * and RBTX49xx patch from CELF patch archive.
  6. *
  7. * 2003-2005 (c) MontaVista Software, Inc.
  8. * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007
  9. *
  10. * This file is subject to the terms and conditions of the GNU General Public
  11. * License. See the file "COPYING" in the main directory of this archive
  12. * for more details.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/kernel.h>
  16. #include <linux/types.h>
  17. #include <linux/interrupt.h>
  18. #include <linux/string.h>
  19. #include <linux/module.h>
  20. #include <linux/clk.h>
  21. #include <linux/err.h>
  22. #include <asm/bootinfo.h>
  23. #include <asm/txx9/generic.h>
  24. #ifdef CONFIG_CPU_TX49XX
  25. #include <asm/txx9/tx4938.h>
  26. #endif
  27. /* EBUSC settings of TX4927, etc. */
  28. struct resource txx9_ce_res[8];
  29. static char txx9_ce_res_name[8][4]; /* "CEn" */
  30. /* pcode, internal register */
  31. char txx9_pcode_str[8];
  32. static struct resource txx9_reg_res = {
  33. .name = txx9_pcode_str,
  34. .flags = IORESOURCE_MEM,
  35. };
  36. void __init
  37. txx9_reg_res_init(unsigned int pcode, unsigned long base, unsigned long size)
  38. {
  39. int i;
  40. for (i = 0; i < ARRAY_SIZE(txx9_ce_res); i++) {
  41. sprintf(txx9_ce_res_name[i], "CE%d", i);
  42. txx9_ce_res[i].flags = IORESOURCE_MEM;
  43. txx9_ce_res[i].name = txx9_ce_res_name[i];
  44. }
  45. sprintf(txx9_pcode_str, "TX%x", pcode);
  46. if (base) {
  47. txx9_reg_res.start = base & 0xfffffffffULL;
  48. txx9_reg_res.end = (base & 0xfffffffffULL) + (size - 1);
  49. request_resource(&iomem_resource, &txx9_reg_res);
  50. }
  51. }
  52. /* clocks */
  53. unsigned int txx9_master_clock;
  54. unsigned int txx9_cpu_clock;
  55. unsigned int txx9_gbus_clock;
  56. /* Minimum CLK support */
  57. struct clk *clk_get(struct device *dev, const char *id)
  58. {
  59. if (!strcmp(id, "spi-baseclk"))
  60. return (struct clk *)(txx9_gbus_clock / 2 / 4);
  61. if (!strcmp(id, "imbus_clk"))
  62. return (struct clk *)(txx9_gbus_clock / 2);
  63. return ERR_PTR(-ENOENT);
  64. }
  65. EXPORT_SYMBOL(clk_get);
  66. int clk_enable(struct clk *clk)
  67. {
  68. return 0;
  69. }
  70. EXPORT_SYMBOL(clk_enable);
  71. void clk_disable(struct clk *clk)
  72. {
  73. }
  74. EXPORT_SYMBOL(clk_disable);
  75. unsigned long clk_get_rate(struct clk *clk)
  76. {
  77. return (unsigned long)clk;
  78. }
  79. EXPORT_SYMBOL(clk_get_rate);
  80. void clk_put(struct clk *clk)
  81. {
  82. }
  83. EXPORT_SYMBOL(clk_put);
  84. extern struct txx9_board_vec jmr3927_vec;
  85. extern struct txx9_board_vec rbtx4927_vec;
  86. extern struct txx9_board_vec rbtx4937_vec;
  87. extern struct txx9_board_vec rbtx4938_vec;
  88. struct txx9_board_vec *txx9_board_vec __initdata;
  89. static char txx9_system_type[32];
  90. void __init prom_init_cmdline(void)
  91. {
  92. int argc = (int)fw_arg0;
  93. char **argv = (char **)fw_arg1;
  94. int i; /* Always ignore the "-c" at argv[0] */
  95. /* ignore all built-in args if any f/w args given */
  96. if (argc > 1)
  97. *arcs_cmdline = '\0';
  98. for (i = 1; i < argc; i++) {
  99. if (i != 1)
  100. strcat(arcs_cmdline, " ");
  101. strcat(arcs_cmdline, argv[i]);
  102. }
  103. }
  104. void __init prom_init(void)
  105. {
  106. #ifdef CONFIG_CPU_TX39XX
  107. txx9_board_vec = &jmr3927_vec;
  108. #endif
  109. #ifdef CONFIG_CPU_TX49XX
  110. switch (TX4938_REV_PCODE()) {
  111. case 0x4927:
  112. txx9_board_vec = &rbtx4927_vec;
  113. break;
  114. case 0x4937:
  115. txx9_board_vec = &rbtx4937_vec;
  116. break;
  117. case 0x4938:
  118. txx9_board_vec = &rbtx4938_vec;
  119. break;
  120. }
  121. #endif
  122. strcpy(txx9_system_type, txx9_board_vec->system);
  123. return txx9_board_vec->prom_init();
  124. }
  125. void __init prom_free_prom_memory(void)
  126. {
  127. }
  128. const char *get_system_type(void)
  129. {
  130. return txx9_system_type;
  131. }
  132. char * __init prom_getcmdline(void)
  133. {
  134. return &(arcs_cmdline[0]);
  135. }
  136. /* wrappers */
  137. void __init plat_mem_setup(void)
  138. {
  139. txx9_board_vec->mem_setup();
  140. }
  141. void __init arch_init_irq(void)
  142. {
  143. txx9_board_vec->irq_setup();
  144. }
  145. void __init plat_time_init(void)
  146. {
  147. txx9_board_vec->time_init();
  148. }
  149. static int __init _txx9_arch_init(void)
  150. {
  151. if (txx9_board_vec->arch_init)
  152. txx9_board_vec->arch_init();
  153. return 0;
  154. }
  155. arch_initcall(_txx9_arch_init);
  156. static int __init _txx9_device_init(void)
  157. {
  158. if (txx9_board_vec->device_init)
  159. txx9_board_vec->device_init();
  160. return 0;
  161. }
  162. device_initcall(_txx9_device_init);
  163. int (*txx9_irq_dispatch)(int pending);
  164. asmlinkage void plat_irq_dispatch(void)
  165. {
  166. int pending = read_c0_status() & read_c0_cause() & ST0_IM;
  167. int irq = txx9_irq_dispatch(pending);
  168. if (likely(irq >= 0))
  169. do_IRQ(irq);
  170. else
  171. spurious_interrupt();
  172. }
  173. /* see include/asm-mips/mach-tx39xx/mangle-port.h, for example. */
  174. #ifdef NEEDS_TXX9_SWIZZLE_ADDR_B
  175. static unsigned long __swizzle_addr_none(unsigned long port)
  176. {
  177. return port;
  178. }
  179. unsigned long (*__swizzle_addr_b)(unsigned long port) = __swizzle_addr_none;
  180. EXPORT_SYMBOL(__swizzle_addr_b);
  181. #endif