Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pcm970-baseboard.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008 Juergen Beisert ([email protected])
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 
19 #include <linux/gpio.h>
20 #include <linux/irq.h>
21 #include <linux/platform_device.h>
23 
24 #include <asm/mach/arch.h>
25 
26 #include <mach/common.h>
27 #include <mach/iomux-mx27.h>
28 #include <mach/hardware.h>
29 
30 #include "devices-imx27.h"
31 
32 static const int pcm970_pins[] __initconst = {
33  /* SDHC */
40  /* display */
42  PA6_PF_LD0,
43  PA7_PF_LD1,
44  PA8_PF_LD2,
45  PA9_PF_LD3,
62  PA26_PF_PS,
68  /*
69  * it seems the data line misses a pullup, so we must enable
70  * the internal pullup as a local workaround
71  */
74  /* Camera */
87 };
88 
89 static int pcm970_sdhc2_get_ro(struct device *dev)
90 {
91  return gpio_get_value(GPIO_PORTC + 28);
92 }
93 
94 static int pcm970_sdhc2_init(struct device *dev, irq_handler_t detect_irq, void *data)
95 {
96  int ret;
97 
98  ret = request_irq(gpio_to_irq(IMX_GPIO_NR(3, 29)), detect_irq,
99  IRQF_TRIGGER_FALLING, "imx-mmc-detect", data);
100  if (ret)
101  return ret;
102 
103  ret = gpio_request(GPIO_PORTC + 28, "imx-mmc-ro");
104  if (ret) {
105  free_irq(gpio_to_irq(IMX_GPIO_NR(3, 29)), data);
106  return ret;
107  }
108 
110 
111  return 0;
112 }
113 
114 static void pcm970_sdhc2_exit(struct device *dev, void *data)
115 {
116  free_irq(gpio_to_irq(IMX_GPIO_NR(3, 29)), data);
117  gpio_free(GPIO_PORTC + 28);
118 }
119 
120 static const struct imxmmc_platform_data sdhc_pdata __initconst = {
121  .get_ro = pcm970_sdhc2_get_ro,
122  .init = pcm970_sdhc2_init,
123  .exit = pcm970_sdhc2_exit,
124 };
125 
126 static 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 
180 static const struct imx_fb_platform_data pcm038_fb_data __initconst = {
181  .mode = pcm970_modes,
182  .num_modes = ARRAY_SIZE(pcm970_modes),
183 
184  .pwmr = 0x00A903FF,
185  .lscr1 = 0x00120300,
186  .dmacr = 0x00020010,
187 };
188 
189 static struct resource pcm970_sja1000_resources[] = {
190  {
191  .start = MX27_CS4_BASE_ADDR,
192  .end = MX27_CS4_BASE_ADDR + 0x100 - 1,
193  .flags = IORESOURCE_MEM,
194  }, {
195  /* irq number is run-time assigned */
197  },
198 };
199 
201  .osc_freq = 16000000,
203  .cdr = CDR_CBP,
204 };
205 
206 static 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 
215 /*
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  */
222 {
223  mxc_gpio_setup_multiple_pins(pcm970_pins, ARRAY_SIZE(pcm970_pins),
224  "PCM970");
225 
226  imx27_add_imx_fb(&pcm038_fb_data);
228  imx27_add_mxc_mmc(1, &sdhc_pdata);
229  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));
231  platform_device_register(&pcm970_sja1000);
232 }