blob: c491f59e7294806ee7c171d0a8a061295a642063 [file] [log] [blame]
Juergen Beisertff6552e2008-07-05 10:03:01 +02001/*
2 * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de)
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16 * MA 02110-1301, USA.
17 */
18
Sascha Hauer7c107dc2008-12-19 14:32:07 +010019#include <linux/gpio.h>
20#include <linux/irq.h>
Sascha Hauerbff0b532009-04-29 09:17:03 +020021#include <linux/platform_device.h>
Sascha Hauer61b032e2009-06-23 13:21:42 +020022#include <linux/can/platform/sja1000.h>
Sascha Hauer9db973a2009-01-15 12:44:45 +010023
Juergen Beisertff6552e2008-07-05 10:03:01 +020024#include <asm/mach/arch.h>
25
Sascha Hauerbff0b532009-04-29 09:17:03 +020026#include <mach/hardware.h>
Sascha Hauer9db973a2009-01-15 12:44:45 +010027
Shawn Guoe3372472012-09-13 21:01:00 +080028#include "common.h"
Uwe Kleine-Königad851bf2010-11-04 17:07:48 +010029#include "devices-imx27.h"
Shawn Guo267dd342012-09-13 13:26:00 +080030#include "iomux-mx27.h"
Sascha Hauer9db973a2009-01-15 12:44:45 +010031
Uwe Kleine-König6c80ee52010-09-28 21:53:31 +020032static const int pcm970_pins[] __initconst = {
Sascha Hauerf231ea42009-04-16 15:45:45 +020033 /* SDHC */
Sascha Hauer7c107dc2008-12-19 14:32:07 +010034 PB4_PF_SD2_D0,
35 PB5_PF_SD2_D1,
36 PB6_PF_SD2_D2,
37 PB7_PF_SD2_D3,
38 PB8_PF_SD2_CMD,
39 PB9_PF_SD2_CLK,
Sascha Hauerf231ea42009-04-16 15:45:45 +020040 /* display */
41 PA5_PF_LSCLK,
42 PA6_PF_LD0,
43 PA7_PF_LD1,
44 PA8_PF_LD2,
45 PA9_PF_LD3,
46 PA10_PF_LD4,
47 PA11_PF_LD5,
48 PA12_PF_LD6,
49 PA13_PF_LD7,
50 PA14_PF_LD8,
51 PA15_PF_LD9,
52 PA16_PF_LD10,
53 PA17_PF_LD11,
54 PA18_PF_LD12,
55 PA19_PF_LD13,
56 PA20_PF_LD14,
57 PA21_PF_LD15,
58 PA22_PF_LD16,
59 PA23_PF_LD17,
60 PA24_PF_REV,
61 PA25_PF_CLS,
62 PA26_PF_PS,
63 PA27_PF_SPL_SPR,
64 PA28_PF_HSYNC,
65 PA29_PF_VSYNC,
66 PA30_PF_CONTRAST,
67 PA31_PF_OE_ACD,
68 /*
69 * it seems the data line misses a pullup, so we must enable
70 * the internal pullup as a local workaround
71 */
72 PD17_PF_I2C_DATA | GPIO_PUEN,
73 PD18_PF_I2C_CLK,
74 /* Camera */
75 PB10_PF_CSI_D0,
76 PB11_PF_CSI_D1,
77 PB12_PF_CSI_D2,
78 PB13_PF_CSI_D3,
79 PB14_PF_CSI_D4,
80 PB15_PF_CSI_MCLK,
81 PB16_PF_CSI_PIXCLK,
82 PB17_PF_CSI_D5,
83 PB18_PF_CSI_D6,
84 PB19_PF_CSI_D7,
85 PB20_PF_CSI_VSYNC,
86 PB21_PF_CSI_HSYNC,
Sascha Hauer7c107dc2008-12-19 14:32:07 +010087};
88
Sascha Hauerf231ea42009-04-16 15:45:45 +020089static int pcm970_sdhc2_get_ro(struct device *dev)
90{
91 return gpio_get_value(GPIO_PORTC + 28);
92}
93
Sascha Hauer7c107dc2008-12-19 14:32:07 +010094static int pcm970_sdhc2_init(struct device *dev, irq_handler_t detect_irq, void *data)
95{
96 int ret;
97
Shawn Guo438196c2011-12-05 10:12:28 +080098 ret = request_irq(gpio_to_irq(IMX_GPIO_NR(3, 29)), detect_irq,
99 IRQF_TRIGGER_FALLING, "imx-mmc-detect", data);
Sascha Hauer7c107dc2008-12-19 14:32:07 +0100100 if (ret)
Sascha Hauerf231ea42009-04-16 15:45:45 +0200101 return ret;
Sascha Hauer7c107dc2008-12-19 14:32:07 +0100102
103 ret = gpio_request(GPIO_PORTC + 28, "imx-mmc-ro");
Sascha Hauerf231ea42009-04-16 15:45:45 +0200104 if (ret) {
Shawn Guo438196c2011-12-05 10:12:28 +0800105 free_irq(gpio_to_irq(IMX_GPIO_NR(3, 29)), data);
Sascha Hauerf231ea42009-04-16 15:45:45 +0200106 return ret;
107 }
Sascha Hauer7c107dc2008-12-19 14:32:07 +0100108
Sascha Hauer7c107dc2008-12-19 14:32:07 +0100109 gpio_direction_input(GPIO_PORTC + 28);
110
111 return 0;
Sascha Hauer7c107dc2008-12-19 14:32:07 +0100112}
113
114static void pcm970_sdhc2_exit(struct device *dev, void *data)
115{
Shawn Guo438196c2011-12-05 10:12:28 +0800116 free_irq(gpio_to_irq(IMX_GPIO_NR(3, 29)), data);
Sascha Hauer7c107dc2008-12-19 14:32:07 +0100117 gpio_free(GPIO_PORTC + 28);
Sascha Hauer7c107dc2008-12-19 14:32:07 +0100118}
119
Uwe Kleine-König9d3d9452010-11-05 17:26:09 +0100120static const struct imxmmc_platform_data sdhc_pdata __initconst = {
Sascha Hauer7c107dc2008-12-19 14:32:07 +0100121 .get_ro = pcm970_sdhc2_get_ro,
122 .init = pcm970_sdhc2_init,
123 .exit = pcm970_sdhc2_exit,
124};
125
Sascha Hauer343684f2009-03-19 08:25:41 +0100126static struct imx_fb_videomode pcm970_modes[] = {
127 {
128 .mode = {
129 .name = "Sharp-LQ035Q7",
130 .refresh = 60,
131 .xres = 240,
132 .yres = 320,
133 .pixclock = 188679, /* in ps (5.3MHz) */
134 .hsync_len = 7,
135 .left_margin = 5,
136 .right_margin = 16,
137 .vsync_len = 1,
138 .upper_margin = 7,
139 .lower_margin = 9,
140 },
141 /*
142 * - HSYNC active high
143 * - VSYNC active high
144 * - clk notenabled while idle
145 * - clock not inverted
146 * - data not inverted
147 * - data enable low active
148 * - enable sharp mode
149 */
150 .pcr = 0xF00080C0,
151 .bpp = 16,
152 }, {
153 .mode = {
154 .name = "TX090",
155 .refresh = 60,
156 .xres = 240,
157 .yres = 320,
158 .pixclock = 38255,
159 .left_margin = 144,
160 .right_margin = 0,
161 .upper_margin = 7,
162 .lower_margin = 40,
163 .hsync_len = 96,
164 .vsync_len = 1,
165 },
166 /*
167 * - HSYNC active low (1 << 22)
168 * - VSYNC active low (1 << 23)
169 * - clk notenabled while idle
170 * - clock not inverted
171 * - data not inverted
172 * - data enable low active
173 * - enable sharp mode
174 */
175 .pcr = 0xF0008080 | (1<<22) | (1<<23) | (1<<19),
176 .bpp = 32,
177 },
178};
179
Uwe Kleine-Königad851bf2010-11-04 17:07:48 +0100180static const struct imx_fb_platform_data pcm038_fb_data __initconst = {
Sascha Hauer343684f2009-03-19 08:25:41 +0100181 .mode = pcm970_modes,
182 .num_modes = ARRAY_SIZE(pcm970_modes),
Sascha Hauer9db973a2009-01-15 12:44:45 +0100183
Sascha Hauer9db973a2009-01-15 12:44:45 +0100184 .pwmr = 0x00A903FF,
185 .lscr1 = 0x00120300,
186 .dmacr = 0x00020010,
Sascha Hauer9db973a2009-01-15 12:44:45 +0100187};
188
Sascha Hauer61b032e2009-06-23 13:21:42 +0200189static struct resource pcm970_sja1000_resources[] = {
190 {
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100191 .start = MX27_CS4_BASE_ADDR,
192 .end = MX27_CS4_BASE_ADDR + 0x100 - 1,
Sascha Hauer61b032e2009-06-23 13:21:42 +0200193 .flags = IORESOURCE_MEM,
194 }, {
Shawn Guo438196c2011-12-05 10:12:28 +0800195 /* irq number is run-time assigned */
Sascha Hauer61b032e2009-06-23 13:21:42 +0200196 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
197 },
198};
199
Uwe Kleine-König214b4312010-09-28 21:55:22 +0200200static struct sja1000_platform_data pcm970_sja1000_platform_data = {
Wolfgang Grandegger56e6943b92010-05-17 22:39:48 -0700201 .osc_freq = 16000000,
202 .ocr = OCR_TX1_PULLDOWN | OCR_TX0_PUSHPULL,
203 .cdr = CDR_CBP,
Sascha Hauer61b032e2009-06-23 13:21:42 +0200204};
205
206static struct platform_device pcm970_sja1000 = {
207 .name = "sja1000_platform",
208 .dev = {
209 .platform_data = &pcm970_sja1000_platform_data,
210 },
211 .resource = pcm970_sja1000_resources,
212 .num_resources = ARRAY_SIZE(pcm970_sja1000_resources),
213};
214
Juergen Beisertff6552e2008-07-05 10:03:01 +0200215/*
216 * system init for baseboard usage. Will be called by pcm038 init.
217 *
218 * Add platform devices present on this baseboard and init
219 * them from CPU side as far as required to use them later on
220 */
221void __init pcm970_baseboard_init(void)
222{
Sascha Hauerf231ea42009-04-16 15:45:45 +0200223 mxc_gpio_setup_multiple_pins(pcm970_pins, ARRAY_SIZE(pcm970_pins),
224 "PCM970");
225
Uwe Kleine-Königad851bf2010-11-04 17:07:48 +0100226 imx27_add_imx_fb(&pcm038_fb_data);
Sascha Hauera90c31a2009-10-06 09:18:17 +0200227 mxc_gpio_mode(GPIO_PORTC | 28 | GPIO_GPIO | GPIO_IN);
Uwe Kleine-König9d3d9452010-11-05 17:26:09 +0100228 imx27_add_mxc_mmc(1, &sdhc_pdata);
Shawn Guo438196c2011-12-05 10:12:28 +0800229 pcm970_sja1000_resources[1].start = gpio_to_irq(IMX_GPIO_NR(5, 19));
230 pcm970_sja1000_resources[1].end = gpio_to_irq(IMX_GPIO_NR(5, 19));
Sascha Hauer61b032e2009-06-23 13:21:42 +0200231 platform_device_register(&pcm970_sja1000);
Juergen Beisertff6552e2008-07-05 10:03:01 +0200232}