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