w90p910.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * linux/arch/arm/mach-w90x900/w90p910.c
  3. *
  4. * Based on linux/arch/arm/plat-s3c24xx/s3c244x.c by Ben Dooks
  5. *
  6. * Copyright (c) 2008 Nuvoton technology corporation
  7. * All rights reserved.
  8. *
  9. * Wan ZongShun <mcuos.com@gmail.com>
  10. *
  11. * W90P910 cpu support
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. *
  18. */
  19. #include <linux/kernel.h>
  20. #include <linux/types.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/list.h>
  23. #include <linux/timer.h>
  24. #include <linux/init.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/io.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/map.h>
  29. #include <asm/mach/irq.h>
  30. #include <asm/irq.h>
  31. #include <mach/hardware.h>
  32. #include <mach/regs-serial.h>
  33. #include "cpu.h"
  34. /*W90P910 has five uarts*/
  35. #define MAX_UART_COUNT 5
  36. static int uart_count;
  37. static struct platform_device *uart_devs[MAX_UART_COUNT-1];
  38. /* Initial IO mappings */
  39. static struct map_desc w90p910_iodesc[] __initdata = {
  40. IODESC_ENT(IRQ),
  41. IODESC_ENT(GCR),
  42. IODESC_ENT(UART),
  43. IODESC_ENT(TIMER),
  44. IODESC_ENT(EBI),
  45. /*IODESC_ENT(LCD),*/
  46. };
  47. /*Init the dev resource*/
  48. static W90X900_RES(UART0);
  49. static W90X900_RES(UART1);
  50. static W90X900_RES(UART2);
  51. static W90X900_RES(UART3);
  52. static W90X900_RES(UART4);
  53. static W90X900_DEVICE(uart0, UART0, 0, "w90x900-uart");
  54. static W90X900_DEVICE(uart1, UART1, 1, "w90x900-uart");
  55. static W90X900_DEVICE(uart2, UART2, 2, "w90x900-uart");
  56. static W90X900_DEVICE(uart3, UART3, 3, "w90x900-uart");
  57. static W90X900_DEVICE(uart4, UART4, 4, "w90x900-uart");
  58. static struct platform_device *uart_devices[] __initdata = {
  59. &w90x900_uart0,
  60. &w90x900_uart1,
  61. &w90x900_uart2,
  62. &w90x900_uart3,
  63. &w90x900_uart4
  64. };
  65. /*Init W90P910 uart device*/
  66. void __init w90p910_init_uarts(struct w90x900_uartcfg *cfg, int no)
  67. {
  68. struct platform_device *platdev;
  69. int uart, uartdev;
  70. /*By min() to judge count of uart be used indeed*/
  71. uartdev = ARRAY_SIZE(uart_devices);
  72. no = min(uartdev, no);
  73. for (uart = 0; uart < no; uart++, cfg++) {
  74. if (cfg->hwport != uart)
  75. printk(KERN_ERR "w90x900_uartcfg[%d] error\n", uart);
  76. platdev = uart_devices[cfg->hwport];
  77. uart_devs[uart] = platdev;
  78. platdev->dev.platform_data = cfg;
  79. }
  80. uart_count = uart;
  81. }
  82. /*Init W90P910 evb io*/
  83. void __init w90p910_map_io(struct map_desc *mach_desc, int mach_size)
  84. {
  85. unsigned long idcode = 0x0;
  86. iotable_init(w90p910_iodesc, ARRAY_SIZE(w90p910_iodesc));
  87. idcode = __raw_readl(W90X900PDID);
  88. if (idcode != W90P910_CPUID)
  89. printk(KERN_ERR "CPU type 0x%08lx is not W90P910\n", idcode);
  90. }
  91. /*Init W90P910 clock*/
  92. void __init w90p910_init_clocks(int xtal)
  93. {
  94. }
  95. static int __init w90p910_init_cpu(void)
  96. {
  97. return 0;
  98. }
  99. static int __init w90x900_arch_init(void)
  100. {
  101. int ret;
  102. ret = w90p910_init_cpu();
  103. if (ret != 0)
  104. return ret;
  105. return platform_add_devices(uart_devs, uart_count);
  106. }
  107. arch_initcall(w90x900_arch_init);