setup.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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 <linux/gpio.h>
  23. #include <asm/bootinfo.h>
  24. #include <asm/time.h>
  25. #include <asm/txx9/generic.h>
  26. #ifdef CONFIG_CPU_TX49XX
  27. #include <asm/txx9/tx4938.h>
  28. #endif
  29. /* EBUSC settings of TX4927, etc. */
  30. struct resource txx9_ce_res[8];
  31. static char txx9_ce_res_name[8][4]; /* "CEn" */
  32. /* pcode, internal register */
  33. unsigned int txx9_pcode;
  34. char txx9_pcode_str[8];
  35. static struct resource txx9_reg_res = {
  36. .name = txx9_pcode_str,
  37. .flags = IORESOURCE_MEM,
  38. };
  39. void __init
  40. txx9_reg_res_init(unsigned int pcode, unsigned long base, unsigned long size)
  41. {
  42. int i;
  43. for (i = 0; i < ARRAY_SIZE(txx9_ce_res); i++) {
  44. sprintf(txx9_ce_res_name[i], "CE%d", i);
  45. txx9_ce_res[i].flags = IORESOURCE_MEM;
  46. txx9_ce_res[i].name = txx9_ce_res_name[i];
  47. }
  48. sprintf(txx9_pcode_str, "TX%x", pcode);
  49. if (base) {
  50. txx9_reg_res.start = base & 0xfffffffffULL;
  51. txx9_reg_res.end = (base & 0xfffffffffULL) + (size - 1);
  52. request_resource(&iomem_resource, &txx9_reg_res);
  53. }
  54. }
  55. /* clocks */
  56. unsigned int txx9_master_clock;
  57. unsigned int txx9_cpu_clock;
  58. unsigned int txx9_gbus_clock;
  59. int txx9_ccfg_toeon __initdata = 1;
  60. /* Minimum CLK support */
  61. struct clk *clk_get(struct device *dev, const char *id)
  62. {
  63. if (!strcmp(id, "spi-baseclk"))
  64. return (struct clk *)((unsigned long)txx9_gbus_clock / 2 / 4);
  65. if (!strcmp(id, "imbus_clk"))
  66. return (struct clk *)((unsigned long)txx9_gbus_clock / 2);
  67. return ERR_PTR(-ENOENT);
  68. }
  69. EXPORT_SYMBOL(clk_get);
  70. int clk_enable(struct clk *clk)
  71. {
  72. return 0;
  73. }
  74. EXPORT_SYMBOL(clk_enable);
  75. void clk_disable(struct clk *clk)
  76. {
  77. }
  78. EXPORT_SYMBOL(clk_disable);
  79. unsigned long clk_get_rate(struct clk *clk)
  80. {
  81. return (unsigned long)clk;
  82. }
  83. EXPORT_SYMBOL(clk_get_rate);
  84. void clk_put(struct clk *clk)
  85. {
  86. }
  87. EXPORT_SYMBOL(clk_put);
  88. /* GPIO support */
  89. #ifdef CONFIG_GENERIC_GPIO
  90. int gpio_to_irq(unsigned gpio)
  91. {
  92. return -EINVAL;
  93. }
  94. EXPORT_SYMBOL(gpio_to_irq);
  95. int irq_to_gpio(unsigned irq)
  96. {
  97. return -EINVAL;
  98. }
  99. EXPORT_SYMBOL(irq_to_gpio);
  100. #endif
  101. extern struct txx9_board_vec jmr3927_vec;
  102. extern struct txx9_board_vec rbtx4927_vec;
  103. extern struct txx9_board_vec rbtx4937_vec;
  104. extern struct txx9_board_vec rbtx4938_vec;
  105. struct txx9_board_vec *txx9_board_vec __initdata;
  106. static char txx9_system_type[32];
  107. void __init prom_init_cmdline(void)
  108. {
  109. int argc = (int)fw_arg0;
  110. char **argv = (char **)fw_arg1;
  111. int i; /* Always ignore the "-c" at argv[0] */
  112. #ifdef CONFIG_64BIT
  113. char *fixed_argv[32];
  114. for (i = 0; i < argc; i++)
  115. fixed_argv[i] = (char *)(long)(*((__s32 *)argv + i));
  116. argv = fixed_argv;
  117. #endif
  118. /* ignore all built-in args if any f/w args given */
  119. if (argc > 1)
  120. *arcs_cmdline = '\0';
  121. for (i = 1; i < argc; i++) {
  122. if (i != 1)
  123. strcat(arcs_cmdline, " ");
  124. strcat(arcs_cmdline, argv[i]);
  125. }
  126. }
  127. void __init prom_init(void)
  128. {
  129. #ifdef CONFIG_CPU_TX39XX
  130. txx9_board_vec = &jmr3927_vec;
  131. #endif
  132. #ifdef CONFIG_CPU_TX49XX
  133. switch (TX4938_REV_PCODE()) {
  134. #ifdef CONFIG_TOSHIBA_RBTX4927
  135. case 0x4927:
  136. txx9_board_vec = &rbtx4927_vec;
  137. break;
  138. case 0x4937:
  139. txx9_board_vec = &rbtx4937_vec;
  140. break;
  141. #endif
  142. #ifdef CONFIG_TOSHIBA_RBTX4938
  143. case 0x4938:
  144. txx9_board_vec = &rbtx4938_vec;
  145. break;
  146. #endif
  147. }
  148. #endif
  149. strcpy(txx9_system_type, txx9_board_vec->system);
  150. txx9_board_vec->prom_init();
  151. }
  152. void __init prom_free_prom_memory(void)
  153. {
  154. }
  155. const char *get_system_type(void)
  156. {
  157. return txx9_system_type;
  158. }
  159. char * __init prom_getcmdline(void)
  160. {
  161. return &(arcs_cmdline[0]);
  162. }
  163. /* wrappers */
  164. void __init plat_mem_setup(void)
  165. {
  166. ioport_resource.start = 0;
  167. ioport_resource.end = ~0UL; /* no limit */
  168. iomem_resource.start = 0;
  169. iomem_resource.end = ~0UL; /* no limit */
  170. txx9_board_vec->mem_setup();
  171. }
  172. void __init arch_init_irq(void)
  173. {
  174. txx9_board_vec->irq_setup();
  175. }
  176. void __init plat_time_init(void)
  177. {
  178. txx9_board_vec->time_init();
  179. }
  180. static int __init _txx9_arch_init(void)
  181. {
  182. if (txx9_board_vec->arch_init)
  183. txx9_board_vec->arch_init();
  184. return 0;
  185. }
  186. arch_initcall(_txx9_arch_init);
  187. static int __init _txx9_device_init(void)
  188. {
  189. if (txx9_board_vec->device_init)
  190. txx9_board_vec->device_init();
  191. return 0;
  192. }
  193. device_initcall(_txx9_device_init);
  194. int (*txx9_irq_dispatch)(int pending);
  195. asmlinkage void plat_irq_dispatch(void)
  196. {
  197. int pending = read_c0_status() & read_c0_cause() & ST0_IM;
  198. int irq = txx9_irq_dispatch(pending);
  199. if (likely(irq >= 0))
  200. do_IRQ(irq);
  201. else
  202. spurious_interrupt();
  203. }
  204. /* see include/asm-mips/mach-tx39xx/mangle-port.h, for example. */
  205. #ifdef NEEDS_TXX9_SWIZZLE_ADDR_B
  206. static unsigned long __swizzle_addr_none(unsigned long port)
  207. {
  208. return port;
  209. }
  210. unsigned long (*__swizzle_addr_b)(unsigned long port) = __swizzle_addr_none;
  211. EXPORT_SYMBOL(__swizzle_addr_b);
  212. #endif