phy3250.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. * Platform support for LPC32xx SoC
  3. *
  4. * Author: Kevin Wells <kevin.wells@nxp.com>
  5. *
  6. * Copyright (C) 2012 Roland Stigge <stigge@antcom.de>
  7. * Copyright (C) 2010 NXP Semiconductors
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. */
  19. #include <linux/init.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/device.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/irq.h>
  24. #include <linux/dma-mapping.h>
  25. #include <linux/gpio.h>
  26. #include <linux/amba/bus.h>
  27. #include <linux/amba/clcd.h>
  28. #include <linux/amba/pl08x.h>
  29. #include <linux/amba/mmci.h>
  30. #include <linux/of.h>
  31. #include <linux/of_address.h>
  32. #include <linux/of_irq.h>
  33. #include <linux/of_platform.h>
  34. #include <linux/clk.h>
  35. #include <linux/mtd/lpc32xx_slc.h>
  36. #include <linux/mtd/lpc32xx_mlc.h>
  37. #include <asm/setup.h>
  38. #include <asm/mach-types.h>
  39. #include <asm/mach/arch.h>
  40. #include <mach/hardware.h>
  41. #include <mach/platform.h>
  42. #include <mach/board.h>
  43. #include "common.h"
  44. /*
  45. * AMBA LCD controller
  46. */
  47. static struct clcd_panel conn_lcd_panel = {
  48. .mode = {
  49. .name = "QVGA portrait",
  50. .refresh = 60,
  51. .xres = 240,
  52. .yres = 320,
  53. .pixclock = 191828,
  54. .left_margin = 22,
  55. .right_margin = 11,
  56. .upper_margin = 2,
  57. .lower_margin = 1,
  58. .hsync_len = 5,
  59. .vsync_len = 2,
  60. .sync = 0,
  61. .vmode = FB_VMODE_NONINTERLACED,
  62. },
  63. .width = -1,
  64. .height = -1,
  65. .tim2 = (TIM2_IVS | TIM2_IHS),
  66. .cntl = (CNTL_BGR | CNTL_LCDTFT | CNTL_LCDVCOMP(1) |
  67. CNTL_LCDBPP16_565),
  68. .bpp = 16,
  69. };
  70. #define PANEL_SIZE (3 * SZ_64K)
  71. static int lpc32xx_clcd_setup(struct clcd_fb *fb)
  72. {
  73. dma_addr_t dma;
  74. fb->fb.screen_base = dma_alloc_wc(&fb->dev->dev, PANEL_SIZE, &dma,
  75. GFP_KERNEL);
  76. if (!fb->fb.screen_base) {
  77. printk(KERN_ERR "CLCD: unable to map framebuffer\n");
  78. return -ENOMEM;
  79. }
  80. fb->fb.fix.smem_start = dma;
  81. fb->fb.fix.smem_len = PANEL_SIZE;
  82. fb->panel = &conn_lcd_panel;
  83. return 0;
  84. }
  85. static int lpc32xx_clcd_mmap(struct clcd_fb *fb, struct vm_area_struct *vma)
  86. {
  87. return dma_mmap_wc(&fb->dev->dev, vma, fb->fb.screen_base,
  88. fb->fb.fix.smem_start, fb->fb.fix.smem_len);
  89. }
  90. static void lpc32xx_clcd_remove(struct clcd_fb *fb)
  91. {
  92. dma_free_wc(&fb->dev->dev, fb->fb.fix.smem_len, fb->fb.screen_base,
  93. fb->fb.fix.smem_start);
  94. }
  95. static struct clcd_board lpc32xx_clcd_data = {
  96. .name = "Phytec LCD",
  97. .check = clcdfb_check,
  98. .decode = clcdfb_decode,
  99. .setup = lpc32xx_clcd_setup,
  100. .mmap = lpc32xx_clcd_mmap,
  101. .remove = lpc32xx_clcd_remove,
  102. };
  103. static struct pl08x_channel_data pl08x_slave_channels[] = {
  104. {
  105. .bus_id = "nand-slc",
  106. .min_signal = 1, /* SLC NAND Flash */
  107. .max_signal = 1,
  108. .periph_buses = PL08X_AHB1,
  109. },
  110. {
  111. .bus_id = "nand-mlc",
  112. .min_signal = 12, /* MLC NAND Flash */
  113. .max_signal = 12,
  114. .periph_buses = PL08X_AHB1,
  115. },
  116. };
  117. static int pl08x_get_signal(const struct pl08x_channel_data *cd)
  118. {
  119. return cd->min_signal;
  120. }
  121. static void pl08x_put_signal(const struct pl08x_channel_data *cd, int ch)
  122. {
  123. }
  124. static struct pl08x_platform_data pl08x_pd = {
  125. /* Some reasonable memcpy defaults */
  126. .memcpy_burst_size = PL08X_BURST_SZ_256,
  127. .memcpy_bus_width = PL08X_BUS_WIDTH_32_BITS,
  128. .slave_channels = &pl08x_slave_channels[0],
  129. .num_slave_channels = ARRAY_SIZE(pl08x_slave_channels),
  130. .get_xfer_signal = pl08x_get_signal,
  131. .put_xfer_signal = pl08x_put_signal,
  132. .lli_buses = PL08X_AHB1,
  133. .mem_buses = PL08X_AHB1,
  134. };
  135. static struct mmci_platform_data lpc32xx_mmci_data = {
  136. .ocr_mask = MMC_VDD_30_31 | MMC_VDD_31_32 |
  137. MMC_VDD_32_33 | MMC_VDD_33_34,
  138. };
  139. static struct lpc32xx_slc_platform_data lpc32xx_slc_data = {
  140. .dma_filter = pl08x_filter_id,
  141. };
  142. static struct lpc32xx_mlc_platform_data lpc32xx_mlc_data = {
  143. .dma_filter = pl08x_filter_id,
  144. };
  145. static const struct of_dev_auxdata lpc32xx_auxdata_lookup[] __initconst = {
  146. OF_DEV_AUXDATA("arm,pl022", 0x20084000, "dev:ssp0", NULL),
  147. OF_DEV_AUXDATA("arm,pl022", 0x2008C000, "dev:ssp1", NULL),
  148. OF_DEV_AUXDATA("arm,pl110", 0x31040000, "dev:clcd", &lpc32xx_clcd_data),
  149. OF_DEV_AUXDATA("arm,pl080", 0x31000000, "pl08xdmac", &pl08x_pd),
  150. OF_DEV_AUXDATA("arm,pl18x", 0x20098000, "20098000.sd",
  151. &lpc32xx_mmci_data),
  152. OF_DEV_AUXDATA("nxp,lpc3220-slc", 0x20020000, "20020000.flash",
  153. &lpc32xx_slc_data),
  154. OF_DEV_AUXDATA("nxp,lpc3220-mlc", 0x200a8000, "200a8000.flash",
  155. &lpc32xx_mlc_data),
  156. { }
  157. };
  158. static void __init lpc3250_machine_init(void)
  159. {
  160. u32 tmp;
  161. /* Setup LCD muxing to RGB565 */
  162. tmp = __raw_readl(LPC32XX_CLKPWR_LCDCLK_CTRL) &
  163. ~(LPC32XX_CLKPWR_LCDCTRL_LCDTYPE_MSK |
  164. LPC32XX_CLKPWR_LCDCTRL_PSCALE_MSK);
  165. tmp |= LPC32XX_CLKPWR_LCDCTRL_LCDTYPE_TFT16;
  166. __raw_writel(tmp, LPC32XX_CLKPWR_LCDCLK_CTRL);
  167. lpc32xx_serial_init();
  168. /* Test clock needed for UDA1380 initial init */
  169. __raw_writel(LPC32XX_CLKPWR_TESTCLK2_SEL_MOSC |
  170. LPC32XX_CLKPWR_TESTCLK_TESTCLK2_EN,
  171. LPC32XX_CLKPWR_TEST_CLK_SEL);
  172. of_platform_default_populate(NULL, lpc32xx_auxdata_lookup, NULL);
  173. }
  174. static const char *const lpc32xx_dt_compat[] __initconst = {
  175. "nxp,lpc3220",
  176. "nxp,lpc3230",
  177. "nxp,lpc3240",
  178. "nxp,lpc3250",
  179. NULL
  180. };
  181. DT_MACHINE_START(LPC32XX_DT, "LPC32XX SoC (Flattened Device Tree)")
  182. .atag_offset = 0x100,
  183. .map_io = lpc32xx_map_io,
  184. .init_machine = lpc3250_machine_init,
  185. .dt_compat = lpc32xx_dt_compat,
  186. MACHINE_END