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 19#include <linux/gpio.h> 20#include <linux/irq.h> 21#include <linux/platform_device.h> 22#include <linux/can/platform/sja1000.h> 23 24#include <asm/mach/arch.h> 25 26#include <mach/common.h> 27#include <mach/iomux-mx27.h> 28#include <mach/imxfb.h> 29#include <mach/hardware.h> 30#include <mach/mmc.h> 31 32#include "devices.h" 33 34static int pcm970_pins[] = { 35 /* SDHC */ 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, 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 PD17_PF_I2C_DATA | GPIO_PUEN, 71 PD18_PF_I2C_CLK, 72 /* Camera */ 73 PB10_PF_CSI_D0, 74 PB11_PF_CSI_D1, 75 PB12_PF_CSI_D2, 76 PB13_PF_CSI_D3, 77 PB14_PF_CSI_D4, 78 PB15_PF_CSI_MCLK, 79 PB16_PF_CSI_PIXCLK, 80 PB17_PF_CSI_D5, 81 PB18_PF_CSI_D6, 82 PB19_PF_CSI_D7, 83 PB20_PF_CSI_VSYNC, 84 PB21_PF_CSI_HSYNC, 85}; 86 87static int pcm970_sdhc2_get_ro(struct device *dev) 88{ 89 return gpio_get_value(GPIO_PORTC + 28); 90} 91 92static int pcm970_sdhc2_init(struct device *dev, irq_handler_t detect_irq, void *data) 93{ 94 int ret; 95 96 ret = request_irq(IRQ_GPIOC(29), detect_irq, IRQF_TRIGGER_FALLING, 97 "imx-mmc-detect", data); 98 if (ret) 99 return ret; 100 101 ret = gpio_request(GPIO_PORTC + 28, "imx-mmc-ro"); 102 if (ret) { 103 free_irq(IRQ_GPIOC(29), data); 104 return ret; 105 } 106 107 gpio_direction_input(GPIO_PORTC + 28); 108 109 return 0; 110} 111 112static void pcm970_sdhc2_exit(struct device *dev, void *data) 113{ 114 free_irq(IRQ_GPIOC(29), data); 115 gpio_free(GPIO_PORTC + 28); 116} 117 118static struct imxmmc_platform_data sdhc_pdata = { 119 .get_ro = pcm970_sdhc2_get_ro, 120 .init = pcm970_sdhc2_init, 121 .exit = pcm970_sdhc2_exit, 122}; 123 124static struct imx_fb_videomode pcm970_modes[] = { 125 { 126 .mode = { 127 .name = "Sharp-LQ035Q7", 128 .refresh = 60, 129 .xres = 240, 130 .yres = 320, 131 .pixclock = 188679, /* in ps (5.3MHz) */ 132 .hsync_len = 7, 133 .left_margin = 5, 134 .right_margin = 16, 135 .vsync_len = 1, 136 .upper_margin = 7, 137 .lower_margin = 9, 138 }, 139 /* 140 * - HSYNC active high 141 * - VSYNC active high 142 * - clk notenabled while idle 143 * - clock not inverted 144 * - data not inverted 145 * - data enable low active 146 * - enable sharp mode 147 */ 148 .pcr = 0xF00080C0, 149 .bpp = 16, 150 }, { 151 .mode = { 152 .name = "TX090", 153 .refresh = 60, 154 .xres = 240, 155 .yres = 320, 156 .pixclock = 38255, 157 .left_margin = 144, 158 .right_margin = 0, 159 .upper_margin = 7, 160 .lower_margin = 40, 161 .hsync_len = 96, 162 .vsync_len = 1, 163 }, 164 /* 165 * - HSYNC active low (1 << 22) 166 * - VSYNC active low (1 << 23) 167 * - clk notenabled while idle 168 * - clock not inverted 169 * - data not inverted 170 * - data enable low active 171 * - enable sharp mode 172 */ 173 .pcr = 0xF0008080 | (1<<22) | (1<<23) | (1<<19), 174 .bpp = 32, 175 }, 176}; 177 178static struct imx_fb_platform_data pcm038_fb_data = { 179 .mode = pcm970_modes, 180 .num_modes = ARRAY_SIZE(pcm970_modes), 181 182 .pwmr = 0x00A903FF, 183 .lscr1 = 0x00120300, 184 .dmacr = 0x00020010, 185}; 186 187static struct resource pcm970_sja1000_resources[] = { 188 { 189 .start = MX27_CS4_BASE_ADDR, 190 .end = MX27_CS4_BASE_ADDR + 0x100 - 1, 191 .flags = IORESOURCE_MEM, 192 }, { 193 .start = IRQ_GPIOE(19), 194 .end = IRQ_GPIOE(19), 195 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE, 196 }, 197}; 198 199struct sja1000_platform_data pcm970_sja1000_platform_data = { 200 .osc_freq = 16000000, 201 .ocr = OCR_TX1_PULLDOWN | OCR_TX0_PUSHPULL, 202 .cdr = CDR_CBP, 203}; 204 205static struct platform_device pcm970_sja1000 = { 206 .name = "sja1000_platform", 207 .dev = { 208 .platform_data = &pcm970_sja1000_platform_data, 209 }, 210 .resource = pcm970_sja1000_resources, 211 .num_resources = ARRAY_SIZE(pcm970_sja1000_resources), 212}; 213 214/* 215 * system init for baseboard usage. Will be called by pcm038 init. 216 * 217 * Add platform devices present on this baseboard and init 218 * them from CPU side as far as required to use them later on 219 */ 220void __init pcm970_baseboard_init(void) 221{ 222 mxc_gpio_setup_multiple_pins(pcm970_pins, ARRAY_SIZE(pcm970_pins), 223 "PCM970"); 224 225 mxc_register_device(&mxc_fb_device, &pcm038_fb_data); 226 mxc_gpio_mode(GPIO_PORTC | 28 | GPIO_GPIO | GPIO_IN); 227 mxc_register_device(&mxc_sdhc_device1, &sdhc_pdata); 228 platform_device_register(&pcm970_sja1000); 229} 230