nxdb500.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /*
  2. * arch/arm/mach-netx/nxdb500.c
  3. *
  4. * Copyright (c) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2
  8. * as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include <linux/dma-mapping.h>
  20. #include <linux/init.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/mtd/plat-ram.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/amba/bus.h>
  25. #include <linux/amba/clcd.h>
  26. #include <mach/hardware.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/hardware/vic.h>
  30. #include <mach/netx-regs.h>
  31. #include <mach/eth.h>
  32. #include "generic.h"
  33. #include "fb.h"
  34. static struct clcd_panel qvga = {
  35. .mode = {
  36. .name = "QVGA",
  37. .refresh = 60,
  38. .xres = 240,
  39. .yres = 320,
  40. .pixclock = 187617,
  41. .left_margin = 6,
  42. .right_margin = 26,
  43. .upper_margin = 0,
  44. .lower_margin = 6,
  45. .hsync_len = 6,
  46. .vsync_len = 1,
  47. .sync = 0,
  48. .vmode = FB_VMODE_NONINTERLACED,
  49. },
  50. .width = -1,
  51. .height = -1,
  52. .tim2 = 16,
  53. .cntl = CNTL_LCDTFT | CNTL_BGR,
  54. .bpp = 16,
  55. .grayscale = 0,
  56. };
  57. static inline int nxdb500_check(struct clcd_fb *fb, struct fb_var_screeninfo *var)
  58. {
  59. var->green.length = 5;
  60. var->green.msb_right = 0;
  61. return clcdfb_check(fb, var);
  62. }
  63. static int nxdb500_clcd_setup(struct clcd_fb *fb)
  64. {
  65. unsigned int val;
  66. fb->fb.var.green.length = 5;
  67. fb->fb.var.green.msb_right = 0;
  68. /* enable asic control */
  69. val = readl(NETX_SYSTEM_IOC_ACCESS_KEY);
  70. writel(val, NETX_SYSTEM_IOC_ACCESS_KEY);
  71. writel(3, NETX_SYSTEM_IOC_CR);
  72. val = readl(NETX_PIO_OUTPIO);
  73. writel(val | 1, NETX_PIO_OUTPIO);
  74. val = readl(NETX_PIO_OEPIO);
  75. writel(val | 1, NETX_PIO_OEPIO);
  76. return netx_clcd_setup(fb);
  77. }
  78. static struct clcd_board clcd_data = {
  79. .name = "netX",
  80. .check = nxdb500_check,
  81. .decode = clcdfb_decode,
  82. .enable = netx_clcd_enable,
  83. .setup = nxdb500_clcd_setup,
  84. .mmap = netx_clcd_mmap,
  85. .remove = netx_clcd_remove,
  86. };
  87. static struct netxeth_platform_data eth0_platform_data = {
  88. .xcno = 0,
  89. };
  90. static struct platform_device netx_eth0_device = {
  91. .name = "netx-eth",
  92. .id = 0,
  93. .num_resources = 0,
  94. .resource = NULL,
  95. .dev = {
  96. .platform_data = &eth0_platform_data,
  97. }
  98. };
  99. static struct netxeth_platform_data eth1_platform_data = {
  100. .xcno = 1,
  101. };
  102. static struct platform_device netx_eth1_device = {
  103. .name = "netx-eth",
  104. .id = 1,
  105. .num_resources = 0,
  106. .resource = NULL,
  107. .dev = {
  108. .platform_data = &eth1_platform_data,
  109. }
  110. };
  111. static struct resource netx_uart0_resources[] = {
  112. [0] = {
  113. .start = 0x00100A00,
  114. .end = 0x00100A3F,
  115. .flags = IORESOURCE_MEM,
  116. },
  117. [1] = {
  118. .start = (NETX_IRQ_UART0),
  119. .end = (NETX_IRQ_UART0),
  120. .flags = IORESOURCE_IRQ,
  121. },
  122. };
  123. static struct platform_device netx_uart0_device = {
  124. .name = "netx-uart",
  125. .id = 0,
  126. .num_resources = ARRAY_SIZE(netx_uart0_resources),
  127. .resource = netx_uart0_resources,
  128. };
  129. static struct resource netx_uart1_resources[] = {
  130. [0] = {
  131. .start = 0x00100A40,
  132. .end = 0x00100A7F,
  133. .flags = IORESOURCE_MEM,
  134. },
  135. [1] = {
  136. .start = (NETX_IRQ_UART1),
  137. .end = (NETX_IRQ_UART1),
  138. .flags = IORESOURCE_IRQ,
  139. },
  140. };
  141. static struct platform_device netx_uart1_device = {
  142. .name = "netx-uart",
  143. .id = 1,
  144. .num_resources = ARRAY_SIZE(netx_uart1_resources),
  145. .resource = netx_uart1_resources,
  146. };
  147. static struct resource netx_uart2_resources[] = {
  148. [0] = {
  149. .start = 0x00100A80,
  150. .end = 0x00100ABF,
  151. .flags = IORESOURCE_MEM,
  152. },
  153. [1] = {
  154. .start = (NETX_IRQ_UART2),
  155. .end = (NETX_IRQ_UART2),
  156. .flags = IORESOURCE_IRQ,
  157. },
  158. };
  159. static struct platform_device netx_uart2_device = {
  160. .name = "netx-uart",
  161. .id = 2,
  162. .num_resources = ARRAY_SIZE(netx_uart2_resources),
  163. .resource = netx_uart2_resources,
  164. };
  165. static struct platform_device *devices[] __initdata = {
  166. &netx_eth0_device,
  167. &netx_eth1_device,
  168. &netx_uart0_device,
  169. &netx_uart1_device,
  170. &netx_uart2_device,
  171. };
  172. static void __init nxdb500_init(void)
  173. {
  174. netx_fb_init(&clcd_data, &qvga);
  175. platform_add_devices(devices, ARRAY_SIZE(devices));
  176. }
  177. MACHINE_START(NXDB500, "Hilscher nxdb500")
  178. .atag_offset = 0x100,
  179. .map_io = netx_map_io,
  180. .init_irq = netx_init_irq,
  181. .handle_irq = vic_handle_irq,
  182. .timer = &netx_timer,
  183. .init_machine = nxdb500_init,
  184. .restart = netx_restart,
  185. MACHINE_END