board-xxs1500.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * BRIEF MODULE DESCRIPTION
  3. * MyCable XXS1500 board support
  4. *
  5. * Copyright 2003, 2008 MontaVista Software Inc.
  6. * Author: MontaVista Software, Inc. <source@mvista.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #include <linux/kernel.h>
  23. #include <linux/init.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/gpio.h>
  27. #include <linux/delay.h>
  28. #include <linux/pm.h>
  29. #include <asm/bootinfo.h>
  30. #include <asm/reboot.h>
  31. #include <asm/setup.h>
  32. #include <asm/mach-au1x00/au1000.h>
  33. #include <prom.h>
  34. const char *get_system_type(void)
  35. {
  36. return "XXS1500";
  37. }
  38. void __init prom_init(void)
  39. {
  40. unsigned char *memsize_str;
  41. unsigned long memsize;
  42. prom_argc = fw_arg0;
  43. prom_argv = (char **)fw_arg1;
  44. prom_envp = (char **)fw_arg2;
  45. prom_init_cmdline();
  46. memsize_str = prom_getenv("memsize");
  47. if (!memsize_str || kstrtoul(memsize_str, 0, &memsize))
  48. memsize = 0x04000000;
  49. add_memory_region(0, memsize, BOOT_MEM_RAM);
  50. }
  51. void prom_putchar(char c)
  52. {
  53. alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c);
  54. }
  55. static void xxs1500_reset(char *c)
  56. {
  57. /* Jump to the reset vector */
  58. __asm__ __volatile__("jr\t%0" : : "r"(0xbfc00000));
  59. }
  60. static void xxs1500_power_off(void)
  61. {
  62. while (1)
  63. asm volatile (
  64. " .set mips32 \n"
  65. " wait \n"
  66. " .set mips0 \n");
  67. }
  68. void __init board_setup(void)
  69. {
  70. u32 pin_func;
  71. pm_power_off = xxs1500_power_off;
  72. _machine_halt = xxs1500_power_off;
  73. _machine_restart = xxs1500_reset;
  74. alchemy_gpio1_input_enable();
  75. alchemy_gpio2_enable();
  76. /* Set multiple use pins (UART3/GPIO) to UART (it's used as UART too) */
  77. pin_func = alchemy_rdsys(AU1000_SYS_PINFUNC) & ~SYS_PF_UR3;
  78. pin_func |= SYS_PF_UR3;
  79. alchemy_wrsys(pin_func, AU1000_SYS_PINFUNC);
  80. /* Enable UART */
  81. alchemy_uart_enable(AU1000_UART3_PHYS_ADDR);
  82. /* Enable DTR (MCR bit 0) = USB power up */
  83. __raw_writel(1, (void __iomem *)KSEG1ADDR(AU1000_UART3_PHYS_ADDR + 0x18));
  84. wmb();
  85. }
  86. /******************************************************************************/
  87. static struct resource xxs1500_pcmcia_res[] = {
  88. {
  89. .name = "pcmcia-io",
  90. .flags = IORESOURCE_MEM,
  91. .start = AU1000_PCMCIA_IO_PHYS_ADDR,
  92. .end = AU1000_PCMCIA_IO_PHYS_ADDR + 0x000400000 - 1,
  93. },
  94. {
  95. .name = "pcmcia-attr",
  96. .flags = IORESOURCE_MEM,
  97. .start = AU1000_PCMCIA_ATTR_PHYS_ADDR,
  98. .end = AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1,
  99. },
  100. {
  101. .name = "pcmcia-mem",
  102. .flags = IORESOURCE_MEM,
  103. .start = AU1000_PCMCIA_MEM_PHYS_ADDR,
  104. .end = AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1,
  105. },
  106. };
  107. static struct platform_device xxs1500_pcmcia_dev = {
  108. .name = "xxs1500_pcmcia",
  109. .id = -1,
  110. .num_resources = ARRAY_SIZE(xxs1500_pcmcia_res),
  111. .resource = xxs1500_pcmcia_res,
  112. };
  113. static struct platform_device *xxs1500_devs[] __initdata = {
  114. &xxs1500_pcmcia_dev,
  115. };
  116. static int __init xxs1500_dev_init(void)
  117. {
  118. irq_set_irq_type(AU1500_GPIO204_INT, IRQ_TYPE_LEVEL_HIGH);
  119. irq_set_irq_type(AU1500_GPIO201_INT, IRQ_TYPE_LEVEL_LOW);
  120. irq_set_irq_type(AU1500_GPIO202_INT, IRQ_TYPE_LEVEL_LOW);
  121. irq_set_irq_type(AU1500_GPIO203_INT, IRQ_TYPE_LEVEL_LOW);
  122. irq_set_irq_type(AU1500_GPIO205_INT, IRQ_TYPE_LEVEL_LOW);
  123. irq_set_irq_type(AU1500_GPIO207_INT, IRQ_TYPE_LEVEL_LOW);
  124. irq_set_irq_type(AU1500_GPIO0_INT, IRQ_TYPE_LEVEL_LOW);
  125. irq_set_irq_type(AU1500_GPIO1_INT, IRQ_TYPE_LEVEL_LOW);
  126. irq_set_irq_type(AU1500_GPIO2_INT, IRQ_TYPE_LEVEL_LOW);
  127. irq_set_irq_type(AU1500_GPIO3_INT, IRQ_TYPE_LEVEL_LOW);
  128. irq_set_irq_type(AU1500_GPIO4_INT, IRQ_TYPE_LEVEL_LOW); /* CF irq */
  129. irq_set_irq_type(AU1500_GPIO5_INT, IRQ_TYPE_LEVEL_LOW);
  130. return platform_add_devices(xxs1500_devs,
  131. ARRAY_SIZE(xxs1500_devs));
  132. }
  133. device_initcall(xxs1500_dev_init);