blob: e48cc06c2aec04855d91c500e1bfce0aa3a4a6d9 [file] [log] [blame]
Kevin Wells19d95e12010-07-27 08:44:37 -07001/*
Roland Stiggef5c42272012-04-22 12:01:19 +02002 * Platform support for LPC32xx SoC
Kevin Wells19d95e12010-07-27 08:44:37 -07003 *
4 * Author: Kevin Wells <kevin.wells@nxp.com>
5 *
Roland Stiggef5c42272012-04-22 12:01:19 +02006 * Copyright (C) 2012 Roland Stigge <stigge@antcom.de>
Kevin Wells19d95e12010-07-27 08:44:37 -07007 * 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
20#include <linux/init.h>
21#include <linux/platform_device.h>
Kay Sieversedbaa602011-12-21 16:26:03 -080022#include <linux/device.h>
Kevin Wells19d95e12010-07-27 08:44:37 -070023#include <linux/interrupt.h>
24#include <linux/irq.h>
25#include <linux/dma-mapping.h>
Kevin Wells19d95e12010-07-27 08:44:37 -070026#include <linux/gpio.h>
27#include <linux/amba/bus.h>
28#include <linux/amba/clcd.h>
Roland Stigge291dd712012-06-14 16:16:17 +020029#include <linux/amba/pl08x.h>
30#include <linux/amba/mmci.h>
Roland Stiggef5c42272012-04-22 12:01:19 +020031#include <linux/of.h>
32#include <linux/of_address.h>
33#include <linux/of_irq.h>
34#include <linux/of_platform.h>
35#include <linux/clk.h>
Roland Stigge5b941232012-09-06 11:39:18 +020036#include <linux/mtd/lpc32xx_slc.h>
37#include <linux/mtd/lpc32xx_mlc.h>
Kevin Wells19d95e12010-07-27 08:44:37 -070038
39#include <asm/setup.h>
40#include <asm/mach-types.h>
41#include <asm/mach/arch.h>
42
43#include <mach/hardware.h>
44#include <mach/platform.h>
Roland Stiggec20b9092012-03-12 22:27:28 +010045#include <mach/board.h>
Kevin Wells19d95e12010-07-27 08:44:37 -070046#include "common.h"
47
48/*
Kevin Wells19d95e12010-07-27 08:44:37 -070049 * AMBA LCD controller
50 */
51static struct clcd_panel conn_lcd_panel = {
52 .mode = {
53 .name = "QVGA portrait",
54 .refresh = 60,
55 .xres = 240,
56 .yres = 320,
57 .pixclock = 191828,
58 .left_margin = 22,
59 .right_margin = 11,
60 .upper_margin = 2,
61 .lower_margin = 1,
62 .hsync_len = 5,
63 .vsync_len = 2,
64 .sync = 0,
65 .vmode = FB_VMODE_NONINTERLACED,
66 },
67 .width = -1,
68 .height = -1,
69 .tim2 = (TIM2_IVS | TIM2_IHS),
70 .cntl = (CNTL_BGR | CNTL_LCDTFT | CNTL_LCDVCOMP(1) |
71 CNTL_LCDBPP16_565),
72 .bpp = 16,
73};
74#define PANEL_SIZE (3 * SZ_64K)
75
76static int lpc32xx_clcd_setup(struct clcd_fb *fb)
77{
78 dma_addr_t dma;
79
Luis R. Rodriguezf6e45662016-01-22 18:34:22 -080080 fb->fb.screen_base = dma_alloc_wc(&fb->dev->dev, PANEL_SIZE, &dma,
81 GFP_KERNEL);
Kevin Wells19d95e12010-07-27 08:44:37 -070082 if (!fb->fb.screen_base) {
83 printk(KERN_ERR "CLCD: unable to map framebuffer\n");
84 return -ENOMEM;
85 }
86
87 fb->fb.fix.smem_start = dma;
88 fb->fb.fix.smem_len = PANEL_SIZE;
89 fb->panel = &conn_lcd_panel;
90
Kevin Wells19d95e12010-07-27 08:44:37 -070091 return 0;
92}
93
94static int lpc32xx_clcd_mmap(struct clcd_fb *fb, struct vm_area_struct *vma)
95{
Luis R. Rodriguezf6e45662016-01-22 18:34:22 -080096 return dma_mmap_wc(&fb->dev->dev, vma, fb->fb.screen_base,
97 fb->fb.fix.smem_start, fb->fb.fix.smem_len);
Kevin Wells19d95e12010-07-27 08:44:37 -070098}
99
100static void lpc32xx_clcd_remove(struct clcd_fb *fb)
101{
Luis R. Rodriguezf6e45662016-01-22 18:34:22 -0800102 dma_free_wc(&fb->dev->dev, fb->fb.fix.smem_len, fb->fb.screen_base,
103 fb->fb.fix.smem_start);
Kevin Wells19d95e12010-07-27 08:44:37 -0700104}
105
Kevin Wells19d95e12010-07-27 08:44:37 -0700106static struct clcd_board lpc32xx_clcd_data = {
107 .name = "Phytec LCD",
108 .check = clcdfb_check,
109 .decode = clcdfb_decode,
Kevin Wells19d95e12010-07-27 08:44:37 -0700110 .setup = lpc32xx_clcd_setup,
111 .mmap = lpc32xx_clcd_mmap,
112 .remove = lpc32xx_clcd_remove,
113};
114
Roland Stigged807af42012-06-14 16:16:17 +0200115static struct pl08x_channel_data pl08x_slave_channels[] = {
116 {
117 .bus_id = "nand-slc",
118 .min_signal = 1, /* SLC NAND Flash */
119 .max_signal = 1,
120 .periph_buses = PL08X_AHB1,
121 },
122 {
123 .bus_id = "nand-mlc",
124 .min_signal = 12, /* MLC NAND Flash */
125 .max_signal = 12,
126 .periph_buses = PL08X_AHB1,
127 },
128};
129
Roland Stigge8ba85f82012-07-12 14:01:04 +0200130static int pl08x_get_signal(const struct pl08x_channel_data *cd)
Roland Stigged807af42012-06-14 16:16:17 +0200131{
Roland Stigge8ba85f82012-07-12 14:01:04 +0200132 return cd->min_signal;
Roland Stigged807af42012-06-14 16:16:17 +0200133}
134
Roland Stigge8ba85f82012-07-12 14:01:04 +0200135static void pl08x_put_signal(const struct pl08x_channel_data *cd, int ch)
Roland Stigged807af42012-06-14 16:16:17 +0200136{
137}
138
Roland Stiggef5c42272012-04-22 12:01:19 +0200139static struct pl08x_platform_data pl08x_pd = {
Linus Walleij4166a562017-05-20 23:42:50 +0200140 /* Some reasonable memcpy defaults */
141 .memcpy_burst_size = PL08X_BURST_SZ_256,
142 .memcpy_bus_width = PL08X_BUS_WIDTH_32_BITS,
Roland Stigged807af42012-06-14 16:16:17 +0200143 .slave_channels = &pl08x_slave_channels[0],
144 .num_slave_channels = ARRAY_SIZE(pl08x_slave_channels),
Mark Brownd7cabeed2013-06-19 20:38:28 +0100145 .get_xfer_signal = pl08x_get_signal,
146 .put_xfer_signal = pl08x_put_signal,
Roland Stigged807af42012-06-14 16:16:17 +0200147 .lli_buses = PL08X_AHB1,
148 .mem_buses = PL08X_AHB1,
Kevin Wells19d95e12010-07-27 08:44:37 -0700149};
150
Roland Stigge291dd712012-06-14 16:16:17 +0200151static struct mmci_platform_data lpc32xx_mmci_data = {
152 .ocr_mask = MMC_VDD_30_31 | MMC_VDD_31_32 |
153 MMC_VDD_32_33 | MMC_VDD_33_34,
Roland Stigge291dd712012-06-14 16:16:17 +0200154};
155
Roland Stigge5b941232012-09-06 11:39:18 +0200156static struct lpc32xx_slc_platform_data lpc32xx_slc_data = {
157 .dma_filter = pl08x_filter_id,
158};
159
160static struct lpc32xx_mlc_platform_data lpc32xx_mlc_data = {
161 .dma_filter = pl08x_filter_id,
162};
163
Vladimir Zapolskiy71d42e92016-04-18 04:37:38 +0300164static const struct of_dev_auxdata lpc32xx_auxdata_lookup[] __initconst = {
Roland Stiggea4bc7872012-09-25 10:15:49 +0200165 OF_DEV_AUXDATA("arm,pl022", 0x20084000, "dev:ssp0", NULL),
166 OF_DEV_AUXDATA("arm,pl022", 0x2008C000, "dev:ssp1", NULL),
Roland Stiggef5c42272012-04-22 12:01:19 +0200167 OF_DEV_AUXDATA("arm,pl110", 0x31040000, "dev:clcd", &lpc32xx_clcd_data),
168 OF_DEV_AUXDATA("arm,pl080", 0x31000000, "pl08xdmac", &pl08x_pd),
Roland Stigge291dd712012-06-14 16:16:17 +0200169 OF_DEV_AUXDATA("arm,pl18x", 0x20098000, "20098000.sd",
170 &lpc32xx_mmci_data),
Roland Stigge5b941232012-09-06 11:39:18 +0200171 OF_DEV_AUXDATA("nxp,lpc3220-slc", 0x20020000, "20020000.flash",
172 &lpc32xx_slc_data),
173 OF_DEV_AUXDATA("nxp,lpc3220-mlc", 0x200a8000, "200a8000.flash",
174 &lpc32xx_mlc_data),
Roland Stiggef5c42272012-04-22 12:01:19 +0200175 { }
Kevin Wells19d95e12010-07-27 08:44:37 -0700176};
177
Roland Stiggef5c42272012-04-22 12:01:19 +0200178static void __init lpc3250_machine_init(void)
Kevin Wells19d95e12010-07-27 08:44:37 -0700179{
180 u32 tmp;
Kevin Wells19d95e12010-07-27 08:44:37 -0700181
Kevin Wells19d95e12010-07-27 08:44:37 -0700182 /* Setup LCD muxing to RGB565 */
183 tmp = __raw_readl(LPC32XX_CLKPWR_LCDCLK_CTRL) &
184 ~(LPC32XX_CLKPWR_LCDCTRL_LCDTYPE_MSK |
185 LPC32XX_CLKPWR_LCDCTRL_PSCALE_MSK);
186 tmp |= LPC32XX_CLKPWR_LCDCTRL_LCDTYPE_TFT16;
187 __raw_writel(tmp, LPC32XX_CLKPWR_LCDCLK_CTRL);
188
Kevin Wells19d95e12010-07-27 08:44:37 -0700189 lpc32xx_serial_init();
190
Kevin Wells19d95e12010-07-27 08:44:37 -0700191 /* Test clock needed for UDA1380 initial init */
192 __raw_writel(LPC32XX_CLKPWR_TESTCLK2_SEL_MOSC |
193 LPC32XX_CLKPWR_TESTCLK_TESTCLK2_EN,
194 LPC32XX_CLKPWR_TEST_CLK_SEL);
195
Kefeng Wang435ebcb2016-06-01 14:53:05 +0800196 of_platform_default_populate(NULL, lpc32xx_auxdata_lookup, NULL);
Kevin Wells19d95e12010-07-27 08:44:37 -0700197}
198
Nicolas Pitre19c233b2015-07-27 18:27:52 -0400199static const char *const lpc32xx_dt_compat[] __initconst = {
Roland Stiggef5c42272012-04-22 12:01:19 +0200200 "nxp,lpc3220",
201 "nxp,lpc3230",
202 "nxp,lpc3240",
203 "nxp,lpc3250",
204 NULL
205};
206
207DT_MACHINE_START(LPC32XX_DT, "LPC32XX SoC (Flattened Device Tree)")
Nicolas Pitrebdec5dd2011-07-05 22:38:14 -0400208 .atag_offset = 0x100,
Kevin Wells19d95e12010-07-27 08:44:37 -0700209 .map_io = lpc32xx_map_io,
Roland Stiggef5c42272012-04-22 12:01:19 +0200210 .init_machine = lpc3250_machine_init,
211 .dt_compat = lpc32xx_dt_compat,
Kevin Wells19d95e12010-07-27 08:44:37 -0700212MACHINE_END