Juergen Beisert | ff6552e | 2008-07-05 10:03:01 +0200 | [diff] [blame] | 1 | /* |
| 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 Hauer | 7c107dc | 2008-12-19 14:32:07 +0100 | [diff] [blame] | 19 | #include <linux/gpio.h> |
| 20 | #include <linux/irq.h> |
Sascha Hauer | bff0b53 | 2009-04-29 09:17:03 +0200 | [diff] [blame] | 21 | #include <linux/platform_device.h> |
Sascha Hauer | 61b032e | 2009-06-23 13:21:42 +0200 | [diff] [blame] | 22 | #include <linux/can/platform/sja1000.h> |
Sascha Hauer | 9db973a | 2009-01-15 12:44:45 +0100 | [diff] [blame] | 23 | |
Juergen Beisert | ff6552e | 2008-07-05 10:03:01 +0200 | [diff] [blame] | 24 | #include <asm/mach/arch.h> |
| 25 | |
Sascha Hauer | 9db973a | 2009-01-15 12:44:45 +0100 | [diff] [blame] | 26 | #include <mach/common.h> |
Uwe Kleine-König | e835d88 | 2010-02-16 11:07:49 +0100 | [diff] [blame] | 27 | #include <mach/iomux-mx27.h> |
Sascha Hauer | bff0b53 | 2009-04-29 09:17:03 +0200 | [diff] [blame] | 28 | #include <mach/imxfb.h> |
| 29 | #include <mach/hardware.h> |
| 30 | #include <mach/mmc.h> |
Sascha Hauer | 9db973a | 2009-01-15 12:44:45 +0100 | [diff] [blame] | 31 | |
| 32 | #include "devices.h" |
| 33 | |
Uwe Kleine-König | 6c80ee5 | 2010-09-28 21:53:31 +0200 | [diff] [blame] | 34 | static const int pcm970_pins[] __initconst = { |
Sascha Hauer | f231ea4 | 2009-04-16 15:45:45 +0200 | [diff] [blame] | 35 | /* SDHC */ |
Sascha Hauer | 7c107dc | 2008-12-19 14:32:07 +0100 | [diff] [blame] | 36 | PB4_PF_SD2_D0, |
| 37 | PB5_PF_SD2_D1, |
| 38 | PB6_PF_SD2_D2, |
| 39 | PB7_PF_SD2_D3, |
| 40 | PB8_PF_SD2_CMD, |
| 41 | PB9_PF_SD2_CLK, |
Sascha Hauer | f231ea4 | 2009-04-16 15:45:45 +0200 | [diff] [blame] | 42 | /* display */ |
| 43 | PA5_PF_LSCLK, |
| 44 | PA6_PF_LD0, |
| 45 | PA7_PF_LD1, |
| 46 | PA8_PF_LD2, |
| 47 | PA9_PF_LD3, |
| 48 | PA10_PF_LD4, |
| 49 | PA11_PF_LD5, |
| 50 | PA12_PF_LD6, |
| 51 | PA13_PF_LD7, |
| 52 | PA14_PF_LD8, |
| 53 | PA15_PF_LD9, |
| 54 | PA16_PF_LD10, |
| 55 | PA17_PF_LD11, |
| 56 | PA18_PF_LD12, |
| 57 | PA19_PF_LD13, |
| 58 | PA20_PF_LD14, |
| 59 | PA21_PF_LD15, |
| 60 | PA22_PF_LD16, |
| 61 | PA23_PF_LD17, |
| 62 | PA24_PF_REV, |
| 63 | PA25_PF_CLS, |
| 64 | PA26_PF_PS, |
| 65 | PA27_PF_SPL_SPR, |
| 66 | PA28_PF_HSYNC, |
| 67 | PA29_PF_VSYNC, |
| 68 | PA30_PF_CONTRAST, |
| 69 | PA31_PF_OE_ACD, |
| 70 | /* |
| 71 | * it seems the data line misses a pullup, so we must enable |
| 72 | * the internal pullup as a local workaround |
| 73 | */ |
| 74 | PD17_PF_I2C_DATA | GPIO_PUEN, |
| 75 | PD18_PF_I2C_CLK, |
| 76 | /* Camera */ |
| 77 | PB10_PF_CSI_D0, |
| 78 | PB11_PF_CSI_D1, |
| 79 | PB12_PF_CSI_D2, |
| 80 | PB13_PF_CSI_D3, |
| 81 | PB14_PF_CSI_D4, |
| 82 | PB15_PF_CSI_MCLK, |
| 83 | PB16_PF_CSI_PIXCLK, |
| 84 | PB17_PF_CSI_D5, |
| 85 | PB18_PF_CSI_D6, |
| 86 | PB19_PF_CSI_D7, |
| 87 | PB20_PF_CSI_VSYNC, |
| 88 | PB21_PF_CSI_HSYNC, |
Sascha Hauer | 7c107dc | 2008-12-19 14:32:07 +0100 | [diff] [blame] | 89 | }; |
| 90 | |
Sascha Hauer | f231ea4 | 2009-04-16 15:45:45 +0200 | [diff] [blame] | 91 | static int pcm970_sdhc2_get_ro(struct device *dev) |
| 92 | { |
| 93 | return gpio_get_value(GPIO_PORTC + 28); |
| 94 | } |
| 95 | |
Sascha Hauer | 7c107dc | 2008-12-19 14:32:07 +0100 | [diff] [blame] | 96 | static int pcm970_sdhc2_init(struct device *dev, irq_handler_t detect_irq, void *data) |
| 97 | { |
| 98 | int ret; |
| 99 | |
Sascha Hauer | f231ea4 | 2009-04-16 15:45:45 +0200 | [diff] [blame] | 100 | ret = request_irq(IRQ_GPIOC(29), detect_irq, IRQF_TRIGGER_FALLING, |
Sascha Hauer | 7c107dc | 2008-12-19 14:32:07 +0100 | [diff] [blame] | 101 | "imx-mmc-detect", data); |
| 102 | if (ret) |
Sascha Hauer | f231ea4 | 2009-04-16 15:45:45 +0200 | [diff] [blame] | 103 | return ret; |
Sascha Hauer | 7c107dc | 2008-12-19 14:32:07 +0100 | [diff] [blame] | 104 | |
| 105 | ret = gpio_request(GPIO_PORTC + 28, "imx-mmc-ro"); |
Sascha Hauer | f231ea4 | 2009-04-16 15:45:45 +0200 | [diff] [blame] | 106 | if (ret) { |
| 107 | free_irq(IRQ_GPIOC(29), data); |
| 108 | return ret; |
| 109 | } |
Sascha Hauer | 7c107dc | 2008-12-19 14:32:07 +0100 | [diff] [blame] | 110 | |
Sascha Hauer | 7c107dc | 2008-12-19 14:32:07 +0100 | [diff] [blame] | 111 | gpio_direction_input(GPIO_PORTC + 28); |
| 112 | |
| 113 | return 0; |
Sascha Hauer | 7c107dc | 2008-12-19 14:32:07 +0100 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | static void pcm970_sdhc2_exit(struct device *dev, void *data) |
| 117 | { |
| 118 | free_irq(IRQ_GPIOC(29), data); |
| 119 | gpio_free(GPIO_PORTC + 28); |
Sascha Hauer | 7c107dc | 2008-12-19 14:32:07 +0100 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | static struct imxmmc_platform_data sdhc_pdata = { |
| 123 | .get_ro = pcm970_sdhc2_get_ro, |
| 124 | .init = pcm970_sdhc2_init, |
| 125 | .exit = pcm970_sdhc2_exit, |
| 126 | }; |
| 127 | |
Sascha Hauer | 343684f | 2009-03-19 08:25:41 +0100 | [diff] [blame] | 128 | static struct imx_fb_videomode pcm970_modes[] = { |
| 129 | { |
| 130 | .mode = { |
| 131 | .name = "Sharp-LQ035Q7", |
| 132 | .refresh = 60, |
| 133 | .xres = 240, |
| 134 | .yres = 320, |
| 135 | .pixclock = 188679, /* in ps (5.3MHz) */ |
| 136 | .hsync_len = 7, |
| 137 | .left_margin = 5, |
| 138 | .right_margin = 16, |
| 139 | .vsync_len = 1, |
| 140 | .upper_margin = 7, |
| 141 | .lower_margin = 9, |
| 142 | }, |
| 143 | /* |
| 144 | * - HSYNC active high |
| 145 | * - VSYNC active high |
| 146 | * - clk notenabled while idle |
| 147 | * - clock not inverted |
| 148 | * - data not inverted |
| 149 | * - data enable low active |
| 150 | * - enable sharp mode |
| 151 | */ |
| 152 | .pcr = 0xF00080C0, |
| 153 | .bpp = 16, |
| 154 | }, { |
| 155 | .mode = { |
| 156 | .name = "TX090", |
| 157 | .refresh = 60, |
| 158 | .xres = 240, |
| 159 | .yres = 320, |
| 160 | .pixclock = 38255, |
| 161 | .left_margin = 144, |
| 162 | .right_margin = 0, |
| 163 | .upper_margin = 7, |
| 164 | .lower_margin = 40, |
| 165 | .hsync_len = 96, |
| 166 | .vsync_len = 1, |
| 167 | }, |
| 168 | /* |
| 169 | * - HSYNC active low (1 << 22) |
| 170 | * - VSYNC active low (1 << 23) |
| 171 | * - clk notenabled while idle |
| 172 | * - clock not inverted |
| 173 | * - data not inverted |
| 174 | * - data enable low active |
| 175 | * - enable sharp mode |
| 176 | */ |
| 177 | .pcr = 0xF0008080 | (1<<22) | (1<<23) | (1<<19), |
| 178 | .bpp = 32, |
| 179 | }, |
| 180 | }; |
| 181 | |
Sascha Hauer | 9db973a | 2009-01-15 12:44:45 +0100 | [diff] [blame] | 182 | static struct imx_fb_platform_data pcm038_fb_data = { |
Sascha Hauer | 343684f | 2009-03-19 08:25:41 +0100 | [diff] [blame] | 183 | .mode = pcm970_modes, |
| 184 | .num_modes = ARRAY_SIZE(pcm970_modes), |
Sascha Hauer | 9db973a | 2009-01-15 12:44:45 +0100 | [diff] [blame] | 185 | |
Sascha Hauer | 9db973a | 2009-01-15 12:44:45 +0100 | [diff] [blame] | 186 | .pwmr = 0x00A903FF, |
| 187 | .lscr1 = 0x00120300, |
| 188 | .dmacr = 0x00020010, |
Sascha Hauer | 9db973a | 2009-01-15 12:44:45 +0100 | [diff] [blame] | 189 | }; |
| 190 | |
Sascha Hauer | 61b032e | 2009-06-23 13:21:42 +0200 | [diff] [blame] | 191 | static struct resource pcm970_sja1000_resources[] = { |
| 192 | { |
Uwe Kleine-König | 3f35d1f | 2009-12-09 11:32:11 +0100 | [diff] [blame] | 193 | .start = MX27_CS4_BASE_ADDR, |
| 194 | .end = MX27_CS4_BASE_ADDR + 0x100 - 1, |
Sascha Hauer | 61b032e | 2009-06-23 13:21:42 +0200 | [diff] [blame] | 195 | .flags = IORESOURCE_MEM, |
| 196 | }, { |
| 197 | .start = IRQ_GPIOE(19), |
| 198 | .end = IRQ_GPIOE(19), |
| 199 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE, |
| 200 | }, |
| 201 | }; |
| 202 | |
Uwe Kleine-König | 214b431 | 2010-09-28 21:55:22 +0200 | [diff] [blame^] | 203 | static struct sja1000_platform_data pcm970_sja1000_platform_data = { |
Wolfgang Grandegger | 56e6943b9 | 2010-05-17 22:39:48 -0700 | [diff] [blame] | 204 | .osc_freq = 16000000, |
| 205 | .ocr = OCR_TX1_PULLDOWN | OCR_TX0_PUSHPULL, |
| 206 | .cdr = CDR_CBP, |
Sascha Hauer | 61b032e | 2009-06-23 13:21:42 +0200 | [diff] [blame] | 207 | }; |
| 208 | |
| 209 | static struct platform_device pcm970_sja1000 = { |
| 210 | .name = "sja1000_platform", |
| 211 | .dev = { |
| 212 | .platform_data = &pcm970_sja1000_platform_data, |
| 213 | }, |
| 214 | .resource = pcm970_sja1000_resources, |
| 215 | .num_resources = ARRAY_SIZE(pcm970_sja1000_resources), |
| 216 | }; |
| 217 | |
Juergen Beisert | ff6552e | 2008-07-05 10:03:01 +0200 | [diff] [blame] | 218 | /* |
| 219 | * system init for baseboard usage. Will be called by pcm038 init. |
| 220 | * |
| 221 | * Add platform devices present on this baseboard and init |
| 222 | * them from CPU side as far as required to use them later on |
| 223 | */ |
| 224 | void __init pcm970_baseboard_init(void) |
| 225 | { |
Sascha Hauer | f231ea4 | 2009-04-16 15:45:45 +0200 | [diff] [blame] | 226 | mxc_gpio_setup_multiple_pins(pcm970_pins, ARRAY_SIZE(pcm970_pins), |
| 227 | "PCM970"); |
| 228 | |
Sascha Hauer | 9db973a | 2009-01-15 12:44:45 +0100 | [diff] [blame] | 229 | mxc_register_device(&mxc_fb_device, &pcm038_fb_data); |
Sascha Hauer | a90c31a | 2009-10-06 09:18:17 +0200 | [diff] [blame] | 230 | mxc_gpio_mode(GPIO_PORTC | 28 | GPIO_GPIO | GPIO_IN); |
Sascha Hauer | 7c107dc | 2008-12-19 14:32:07 +0100 | [diff] [blame] | 231 | mxc_register_device(&mxc_sdhc_device1, &sdhc_pdata); |
Sascha Hauer | 61b032e | 2009-06-23 13:21:42 +0200 | [diff] [blame] | 232 | platform_device_register(&pcm970_sja1000); |
Juergen Beisert | ff6552e | 2008-07-05 10:03:01 +0200 | [diff] [blame] | 233 | } |