Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | // SPDX-License-Identifier: GPL-2.0-only /* * arch/arm/mach-pxa/pcm990-baseboard.c * Support for the Phytec phyCORE-PXA270 Development Platform (PCM-990). * * Refer * http://www.phytec.com/products/rdk/ARM-XScale/phyCORE-XScale-PXA270.html * for additional hardware info * * Author: Juergen Kilb * Created: April 05, 2005 * Copyright: Phytec Messtechnik GmbH * e-Mail: armlinux@phytec.de * * based on Intel Mainstone Board * * Copyright 2007 Juergen Beisert @ Pengutronix (j.beisert@pengutronix.de) */ #include <linux/gpio.h> #include <linux/irq.h> #include <linux/platform_device.h> #include <linux/i2c.h> #include <linux/platform_data/i2c-pxa.h> #include <linux/pwm.h> #include <linux/pwm_backlight.h> #include <asm/mach/map.h> #include "pxa27x.h" #include <linux/platform_data/asoc-pxa.h> #include <linux/platform_data/mmc-pxamci.h> #include <linux/platform_data/usb-ohci-pxa27x.h> #include "pcm990_baseboard.h" #include <linux/platform_data/video-pxafb.h> #include "devices.h" #include "generic.h" static unsigned long pcm990_pin_config[] __initdata = { /* MMC */ GPIO32_MMC_CLK, GPIO112_MMC_CMD, GPIO92_MMC_DAT_0, GPIO109_MMC_DAT_1, GPIO110_MMC_DAT_2, GPIO111_MMC_DAT_3, /* USB */ GPIO88_USBH1_PWR, GPIO89_USBH1_PEN, /* PWM0 */ GPIO16_PWM0_OUT, /* I2C */ GPIO117_I2C_SCL, GPIO118_I2C_SDA, /* AC97 */ GPIO28_AC97_BITCLK, GPIO29_AC97_SDATA_IN_0, GPIO30_AC97_SDATA_OUT, GPIO31_AC97_SYNC, }; static void __iomem *pcm990_cpld_base; static u8 pcm990_cpld_readb(unsigned int reg) { return readb(pcm990_cpld_base + reg); } static void pcm990_cpld_writeb(u8 value, unsigned int reg) { writeb(value, pcm990_cpld_base + reg); } /* * pcm990_lcd_power - control power supply to the LCD * @on: 0 = switch off, 1 = switch on * * Called by the pxafb driver */ #ifndef CONFIG_PCM990_DISPLAY_NONE static void pcm990_lcd_power(int on, struct fb_var_screeninfo *var) { if (on) { /* enable LCD-Latches * power on LCD */ pcm990_cpld_writeb(PCM990_CTRL_LCDPWR + PCM990_CTRL_LCDON, PCM990_CTRL_REG3); } else { /* disable LCD-Latches * power off LCD */ pcm990_cpld_writeb(0, PCM990_CTRL_REG3); } } #endif #if defined(CONFIG_PCM990_DISPLAY_SHARP) static struct pxafb_mode_info fb_info_sharp_lq084v1dg21 = { .pixclock = 28000, .xres = 640, .yres = 480, .bpp = 16, .hsync_len = 20, .left_margin = 103, .right_margin = 47, .vsync_len = 6, .upper_margin = 28, .lower_margin = 5, .sync = 0, .cmap_greyscale = 0, }; static struct pxafb_mach_info pcm990_fbinfo __initdata = { .modes = &fb_info_sharp_lq084v1dg21, .num_modes = 1, .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, .pxafb_lcd_power = pcm990_lcd_power, }; #elif defined(CONFIG_PCM990_DISPLAY_NEC) struct pxafb_mode_info fb_info_nec_nl6448bc20_18d = { .pixclock = 39720, .xres = 640, .yres = 480, .bpp = 16, .hsync_len = 32, .left_margin = 16, .right_margin = 48, .vsync_len = 2, .upper_margin = 12, .lower_margin = 17, .sync = 0, .cmap_greyscale = 0, }; static struct pxafb_mach_info pcm990_fbinfo __initdata = { .modes = &fb_info_nec_nl6448bc20_18d, .num_modes = 1, .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, .pxafb_lcd_power = pcm990_lcd_power, }; #endif static struct pwm_lookup pcm990_pwm_lookup[] = { PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight.0", NULL, 78770, PWM_POLARITY_NORMAL), }; static struct platform_pwm_backlight_data pcm990_backlight_data = { .max_brightness = 1023, .dft_brightness = 1023, }; static struct platform_device pcm990_backlight_device = { .name = "pwm-backlight", .dev = { .parent = &pxa27x_device_pwm0.dev, .platform_data = &pcm990_backlight_data, }, }; /* * The PCM-990 development baseboard uses PCM-027's hardware in the * following way: * * - LCD support is in use * - GPIO16 is output for back light on/off with PWM * - GPIO58 ... GPIO73 are outputs for display data * - GPIO74 is output output for LCDFCLK * - GPIO75 is output for LCDLCLK * - GPIO76 is output for LCDPCLK * - GPIO77 is output for LCDBIAS * - MMC support is in use * - GPIO32 is output for MMCCLK * - GPIO92 is MMDAT0 * - GPIO109 is MMDAT1 * - GPIO110 is MMCS0 * - GPIO111 is MMCS1 * - GPIO112 is MMCMD * - IDE/CF card is in use * - GPIO48 is output /POE * - GPIO49 is output /PWE * - GPIO50 is output /PIOR * - GPIO51 is output /PIOW * - GPIO54 is output /PCE2 * - GPIO55 is output /PREG * - GPIO56 is input /PWAIT * - GPIO57 is output /PIOS16 * - GPIO79 is output PSKTSEL * - GPIO85 is output /PCE1 * - FFUART is in use * - GPIO34 is input FFRXD * - GPIO35 is input FFCTS * - GPIO36 is input FFDCD * - GPIO37 is input FFDSR * - GPIO38 is input FFRI * - GPIO39 is output FFTXD * - GPIO40 is output FFDTR * - GPIO41 is output FFRTS * - BTUART is in use * - GPIO42 is input BTRXD * - GPIO43 is output BTTXD * - GPIO44 is input BTCTS * - GPIO45 is output BTRTS * - IRUART is in use * - GPIO46 is input STDRXD * - GPIO47 is output STDTXD * - AC97 is in use*) * - GPIO28 is input AC97CLK * - GPIO29 is input AC97DatIn * - GPIO30 is output AC97DatO * - GPIO31 is output AC97SYNC * - GPIO113 is output AC97_RESET * - SSP is in use * - GPIO23 is output SSPSCLK * - GPIO24 is output chip select to Max7301 * - GPIO25 is output SSPTXD * - GPIO26 is input SSPRXD * - GPIO27 is input for Max7301 IRQ * - GPIO53 is input SSPSYSCLK * - SSP3 is in use * - GPIO81 is output SSPTXD3 * - GPIO82 is input SSPRXD3 * - GPIO83 is output SSPSFRM * - GPIO84 is output SSPCLK3 * * Otherwise claimed GPIOs: * GPIO1 -> IRQ from user switch * GPIO9 -> IRQ from power management * GPIO10 -> IRQ from WML9712 AC97 controller * GPIO11 -> IRQ from IDE controller * GPIO12 -> IRQ from CF controller * GPIO13 -> IRQ from CF controller * GPIO14 -> GPIO free * GPIO15 -> /CS1 selects baseboard's Control CPLD (U7, 16 bit wide data path) * GPIO19 -> GPIO free * GPIO20 -> /SDCS2 * GPIO21 -> /CS3 PC card socket select * GPIO33 -> /CS5 network controller select * GPIO78 -> /CS2 (16 bit wide data path) * GPIO80 -> /CS4 (16 bit wide data path) * GPIO86 -> GPIO free * GPIO87 -> GPIO free * GPIO90 -> LED0 on CPU module * GPIO91 -> LED1 on CPI module * GPIO117 -> SCL * GPIO118 -> SDA */ static unsigned long pcm990_irq_enabled; static void pcm990_mask_ack_irq(struct irq_data *d) { int pcm990_irq = (d->irq - PCM027_IRQ(0)); pcm990_irq_enabled &= ~(1 << pcm990_irq); pcm990_cpld_writeb(pcm990_irq_enabled, PCM990_CTRL_INTMSKENA); } static void pcm990_unmask_irq(struct irq_data *d) { int pcm990_irq = (d->irq - PCM027_IRQ(0)); u8 val; /* the irq can be acknowledged only if deasserted, so it's done here */ pcm990_irq_enabled |= (1 << pcm990_irq); val = pcm990_cpld_readb(PCM990_CTRL_INTSETCLR); val |= 1 << pcm990_irq; pcm990_cpld_writeb(val, PCM990_CTRL_INTSETCLR); pcm990_cpld_writeb(pcm990_irq_enabled, PCM990_CTRL_INTMSKENA); } static struct irq_chip pcm990_irq_chip = { .irq_mask_ack = pcm990_mask_ack_irq, .irq_unmask = pcm990_unmask_irq, }; static void pcm990_irq_handler(struct irq_desc *desc) { unsigned int irq; unsigned long pending; pending = ~pcm990_cpld_readb(PCM990_CTRL_INTSETCLR); pending &= pcm990_irq_enabled; do { /* clear our parent IRQ */ desc->irq_data.chip->irq_ack(&desc->irq_data); if (likely(pending)) { irq = PCM027_IRQ(0) + __ffs(pending); generic_handle_irq(irq); } pending = ~pcm990_cpld_readb(PCM990_CTRL_INTSETCLR); pending &= pcm990_irq_enabled; } while (pending); } static void __init pcm990_init_irq(void) { int irq; /* setup extra PCM990 irqs */ for (irq = PCM027_IRQ(0); irq <= PCM027_IRQ(3); irq++) { irq_set_chip_and_handler(irq, &pcm990_irq_chip, handle_level_irq); irq_clear_status_flags(irq, IRQ_NOREQUEST | IRQ_NOPROBE); } /* disable all Interrupts */ pcm990_cpld_writeb(0x0, PCM990_CTRL_INTMSKENA); pcm990_cpld_writeb(0xff, PCM990_CTRL_INTSETCLR); irq_set_chained_handler(PCM990_CTRL_INT_IRQ, pcm990_irq_handler); irq_set_irq_type(PCM990_CTRL_INT_IRQ, PCM990_CTRL_INT_IRQ_EDGE); } static int pcm990_mci_init(struct device *dev, irq_handler_t mci_detect_int, void *data) { int err; err = request_irq(PCM027_MMCDET_IRQ, mci_detect_int, 0, "MMC card detect", data); if (err) printk(KERN_ERR "pcm990_mci_init: MMC/SD: can't request MMC " "card detect IRQ\n"); return err; } static int pcm990_mci_setpower(struct device *dev, unsigned int vdd) { struct pxamci_platform_data *p_d = dev->platform_data; u8 val; val = pcm990_cpld_readb(PCM990_CTRL_REG5); if ((1 << vdd) & p_d->ocr_mask) val |= PCM990_CTRL_MMC2PWR; else val &= ~PCM990_CTRL_MMC2PWR; pcm990_cpld_writeb(PCM990_CTRL_MMC2PWR, PCM990_CTRL_REG5); return 0; } static void pcm990_mci_exit(struct device *dev, void *data) { free_irq(PCM027_MMCDET_IRQ, data); } #define MSECS_PER_JIFFY (1000/HZ) static struct pxamci_platform_data pcm990_mci_platform_data = { .detect_delay_ms = 250, .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, .init = pcm990_mci_init, .setpower = pcm990_mci_setpower, .exit = pcm990_mci_exit, }; static struct pxaohci_platform_data pcm990_ohci_platform_data = { .port_mode = PMM_PERPORT_MODE, .flags = ENABLE_PORT1 | POWER_CONTROL_LOW | POWER_SENSE_LOW, .power_on_delay = 10, }; /* * system init for baseboard usage. Will be called by pcm027 init. * * Add platform devices present on this baseboard and init * them from CPU side as far as required to use them later on */ void __init pcm990_baseboard_init(void) { pxa2xx_mfp_config(ARRAY_AND_SIZE(pcm990_pin_config)); pcm990_cpld_base = ioremap(PCM990_CTRL_PHYS, PCM990_CTRL_SIZE); if (!pcm990_cpld_base) { pr_err("pcm990: failed to ioremap cpld\n"); return; } /* register CPLD's IRQ controller */ pcm990_init_irq(); #ifndef CONFIG_PCM990_DISPLAY_NONE pxa_set_fb_info(NULL, &pcm990_fbinfo); #endif pwm_add_table(pcm990_pwm_lookup, ARRAY_SIZE(pcm990_pwm_lookup)); platform_device_register(&pcm990_backlight_device); /* MMC */ pxa_set_mci_info(&pcm990_mci_platform_data); /* USB host */ pxa_set_ohci_info(&pcm990_ohci_platform_data); pxa_set_i2c_info(NULL); pxa_set_ac97_info(NULL); printk(KERN_INFO "PCM-990 Evaluation baseboard initialized\n"); } |