nxeb500hmi.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*
  2. * arch/arm/mach-netx/nxeb500hmi.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 nxeb500hmi_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 nxeb500hmi_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. /* GPIO 14 is used for display enable on newer boards */
  73. writel(9, NETX_GPIO_CFG(14));
  74. val = readl(NETX_PIO_OUTPIO);
  75. writel(val | 1, NETX_PIO_OUTPIO);
  76. val = readl(NETX_PIO_OEPIO);
  77. writel(val | 1, NETX_PIO_OEPIO);
  78. return netx_clcd_setup(fb);
  79. }
  80. static struct clcd_board clcd_data = {
  81. .name = "netX",
  82. .check = nxeb500hmi_check,
  83. .decode = clcdfb_decode,
  84. .enable = netx_clcd_enable,
  85. .setup = nxeb500hmi_clcd_setup,
  86. .mmap = netx_clcd_mmap,
  87. .remove = netx_clcd_remove,
  88. };
  89. static struct netxeth_platform_data eth0_platform_data = {
  90. .xcno = 0,
  91. };
  92. static struct platform_device netx_eth0_device = {
  93. .name = "netx-eth",
  94. .id = 0,
  95. .num_resources = 0,
  96. .resource = NULL,
  97. .dev = {
  98. .platform_data = &eth0_platform_data,
  99. }
  100. };
  101. static struct netxeth_platform_data eth1_platform_data = {
  102. .xcno = 1,
  103. };
  104. static struct platform_device netx_eth1_device = {
  105. .name = "netx-eth",
  106. .id = 1,
  107. .num_resources = 0,
  108. .resource = NULL,
  109. .dev = {
  110. .platform_data = &eth1_platform_data,
  111. }
  112. };
  113. static struct resource netx_cf_resources[] = {
  114. [0] = {
  115. .start = 0x20000000,
  116. .end = 0x25ffffff,
  117. .flags = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT,
  118. },
  119. };
  120. static struct platform_device netx_cf_device = {
  121. .name = "netx-cf",
  122. .id = 0,
  123. .resource = netx_cf_resources,
  124. .num_resources = ARRAY_SIZE(netx_cf_resources),
  125. };
  126. static struct resource netx_uart0_resources[] = {
  127. [0] = {
  128. .start = 0x00100A00,
  129. .end = 0x00100A3F,
  130. .flags = IORESOURCE_MEM,
  131. },
  132. [1] = {
  133. .start = (NETX_IRQ_UART0),
  134. .end = (NETX_IRQ_UART0),
  135. .flags = IORESOURCE_IRQ,
  136. },
  137. };
  138. static struct platform_device netx_uart0_device = {
  139. .name = "netx-uart",
  140. .id = 0,
  141. .num_resources = ARRAY_SIZE(netx_uart0_resources),
  142. .resource = netx_uart0_resources,
  143. };
  144. static struct platform_device *devices[] __initdata = {
  145. &netx_eth0_device,
  146. &netx_eth1_device,
  147. &netx_cf_device,
  148. &netx_uart0_device,
  149. };
  150. static void __init nxeb500hmi_init(void)
  151. {
  152. netx_fb_init(&clcd_data, &qvga);
  153. platform_add_devices(devices, ARRAY_SIZE(devices));
  154. }
  155. MACHINE_START(NXEB500HMI, "Hilscher nxeb500hmi")
  156. .atag_offset = 0x100,
  157. .map_io = netx_map_io,
  158. .init_irq = netx_init_irq,
  159. .handle_irq = vic_handle_irq,
  160. .timer = &netx_timer,
  161. .init_machine = nxeb500hmi_init,
  162. .restart = netx_restart,
  163. MACHINE_END