stmpe.c (1cda2394e95415f1469ab8eaffd081395e112551) | stmpe.c (7f7f4ea15ef4645f3888310a7a761fc2c4f689c9) |
---|---|
1/* 2 * ST Microelectronics MFD: stmpe's driver 3 * 4 * Copyright (C) ST-Ericsson SA 2010 5 * 6 * License Terms: GNU General Public License, version 2 7 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson 8 */ --- 227 unchanged lines hidden (view full) --- 236 * order to perform the change. 237 */ 238int stmpe_set_altfunc(struct stmpe *stmpe, u32 pins, enum stmpe_block block) 239{ 240 struct stmpe_variant_info *variant = stmpe->variant; 241 u8 regaddr = stmpe->regs[STMPE_IDX_GPAFR_U_MSB]; 242 int af_bits = variant->af_bits; 243 int numregs = DIV_ROUND_UP(stmpe->num_gpios * af_bits, 8); | 1/* 2 * ST Microelectronics MFD: stmpe's driver 3 * 4 * Copyright (C) ST-Ericsson SA 2010 5 * 6 * License Terms: GNU General Public License, version 2 7 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson 8 */ --- 227 unchanged lines hidden (view full) --- 236 * order to perform the change. 237 */ 238int stmpe_set_altfunc(struct stmpe *stmpe, u32 pins, enum stmpe_block block) 239{ 240 struct stmpe_variant_info *variant = stmpe->variant; 241 u8 regaddr = stmpe->regs[STMPE_IDX_GPAFR_U_MSB]; 242 int af_bits = variant->af_bits; 243 int numregs = DIV_ROUND_UP(stmpe->num_gpios * af_bits, 8); |
244 int afperreg = 8 / af_bits; | |
245 int mask = (1 << af_bits) - 1; 246 u8 regs[numregs]; | 244 int mask = (1 << af_bits) - 1; 245 u8 regs[numregs]; |
247 int af; 248 int ret; | 246 int af, afperreg, ret; |
249 | 247 |
248 if (!variant->get_altfunc) 249 return 0; 250 251 afperreg = 8 / af_bits; |
|
250 mutex_lock(&stmpe->lock); 251 252 ret = __stmpe_enable(stmpe, STMPE_BLOCK_GPIO); 253 if (ret < 0) 254 goto out; 255 256 ret = __stmpe_block_read(stmpe, regaddr, numregs, regs); 257 if (ret < 0) --- 58 unchanged lines hidden (view full) --- 316 317static struct mfd_cell stmpe_keypad_cell = { 318 .name = "stmpe-keypad", 319 .resources = stmpe_keypad_resources, 320 .num_resources = ARRAY_SIZE(stmpe_keypad_resources), 321}; 322 323/* | 252 mutex_lock(&stmpe->lock); 253 254 ret = __stmpe_enable(stmpe, STMPE_BLOCK_GPIO); 255 if (ret < 0) 256 goto out; 257 258 ret = __stmpe_block_read(stmpe, regaddr, numregs, regs); 259 if (ret < 0) --- 58 unchanged lines hidden (view full) --- 318 319static struct mfd_cell stmpe_keypad_cell = { 320 .name = "stmpe-keypad", 321 .resources = stmpe_keypad_resources, 322 .num_resources = ARRAY_SIZE(stmpe_keypad_resources), 323}; 324 325/* |
326 * STMPE801 327 */ 328static const u8 stmpe801_regs[] = { 329 [STMPE_IDX_CHIP_ID] = STMPE801_REG_CHIP_ID, 330 [STMPE_IDX_ICR_LSB] = STMPE801_REG_SYS_CTRL, 331 [STMPE_IDX_GPMR_LSB] = STMPE801_REG_GPIO_MP_STA, 332 [STMPE_IDX_GPSR_LSB] = STMPE801_REG_GPIO_SET_PIN, 333 [STMPE_IDX_GPCR_LSB] = STMPE801_REG_GPIO_SET_PIN, 334 [STMPE_IDX_GPDR_LSB] = STMPE801_REG_GPIO_DIR, 335 [STMPE_IDX_IEGPIOR_LSB] = STMPE801_REG_GPIO_INT_EN, 336 [STMPE_IDX_ISGPIOR_MSB] = STMPE801_REG_GPIO_INT_STA, 337 338}; 339 340static struct stmpe_variant_block stmpe801_blocks[] = { 341 { 342 .cell = &stmpe_gpio_cell, 343 .irq = 0, 344 .block = STMPE_BLOCK_GPIO, 345 }, 346}; 347 348static int stmpe801_enable(struct stmpe *stmpe, unsigned int blocks, 349 bool enable) 350{ 351 if (blocks & STMPE_BLOCK_GPIO) 352 return 0; 353 else 354 return -EINVAL; 355} 356 357static struct stmpe_variant_info stmpe801 = { 358 .name = "stmpe801", 359 .id_val = STMPE801_ID, 360 .id_mask = 0xffff, 361 .num_gpios = 8, 362 .regs = stmpe801_regs, 363 .blocks = stmpe801_blocks, 364 .num_blocks = ARRAY_SIZE(stmpe801_blocks), 365 .num_irqs = STMPE801_NR_INTERNAL_IRQS, 366 .enable = stmpe801_enable, 367}; 368 369/* |
|
324 * Touchscreen (STMPE811 or STMPE610) 325 */ 326 327static struct resource stmpe_ts_resources[] = { 328 { 329 .name = "TOUCH_DET", 330 .start = 0, 331 .end = 0, --- 330 unchanged lines hidden (view full) --- 662 .num_irqs = STMPE24XX_NR_INTERNAL_IRQS, 663 .enable = stmpe24xx_enable, 664 .get_altfunc = stmpe24xx_get_altfunc, 665 .enable_autosleep = stmpe1601_autosleep, /* same as stmpe1601 */ 666}; 667 668static struct stmpe_variant_info *stmpe_variant_info[] = { 669 [STMPE610] = &stmpe610, | 370 * Touchscreen (STMPE811 or STMPE610) 371 */ 372 373static struct resource stmpe_ts_resources[] = { 374 { 375 .name = "TOUCH_DET", 376 .start = 0, 377 .end = 0, --- 330 unchanged lines hidden (view full) --- 708 .num_irqs = STMPE24XX_NR_INTERNAL_IRQS, 709 .enable = stmpe24xx_enable, 710 .get_altfunc = stmpe24xx_get_altfunc, 711 .enable_autosleep = stmpe1601_autosleep, /* same as stmpe1601 */ 712}; 713 714static struct stmpe_variant_info *stmpe_variant_info[] = { 715 [STMPE610] = &stmpe610, |
716 [STMPE801] = &stmpe801, |
|
670 [STMPE811] = &stmpe811, 671 [STMPE1601] = &stmpe1601, 672 [STMPE2401] = &stmpe2401, 673 [STMPE2403] = &stmpe2403, 674}; 675 676static irqreturn_t stmpe_irq(int irq, void *data) 677{ 678 struct stmpe *stmpe = data; 679 struct stmpe_variant_info *variant = stmpe->variant; 680 int num = DIV_ROUND_UP(variant->num_irqs, 8); 681 u8 israddr = stmpe->regs[STMPE_IDX_ISR_MSB]; 682 u8 isr[num]; 683 int ret; 684 int i; 685 | 717 [STMPE811] = &stmpe811, 718 [STMPE1601] = &stmpe1601, 719 [STMPE2401] = &stmpe2401, 720 [STMPE2403] = &stmpe2403, 721}; 722 723static irqreturn_t stmpe_irq(int irq, void *data) 724{ 725 struct stmpe *stmpe = data; 726 struct stmpe_variant_info *variant = stmpe->variant; 727 int num = DIV_ROUND_UP(variant->num_irqs, 8); 728 u8 israddr = stmpe->regs[STMPE_IDX_ISR_MSB]; 729 u8 isr[num]; 730 int ret; 731 int i; 732 |
733 if (variant->id_val == STMPE801_ID) { 734 handle_nested_irq(stmpe->irq_base); 735 return IRQ_HANDLED; 736 } 737 |
|
686 ret = stmpe_block_read(stmpe, israddr, num, isr); 687 if (ret < 0) 688 return IRQ_NONE; 689 690 for (i = 0; i < num; i++) { 691 int bank = num - i - 1; 692 u8 status = isr[i]; 693 u8 clear; --- 70 unchanged lines hidden (view full) --- 764 .irq_bus_lock = stmpe_irq_lock, 765 .irq_bus_sync_unlock = stmpe_irq_sync_unlock, 766 .irq_mask = stmpe_irq_mask, 767 .irq_unmask = stmpe_irq_unmask, 768}; 769 770static int __devinit stmpe_irq_init(struct stmpe *stmpe) 771{ | 738 ret = stmpe_block_read(stmpe, israddr, num, isr); 739 if (ret < 0) 740 return IRQ_NONE; 741 742 for (i = 0; i < num; i++) { 743 int bank = num - i - 1; 744 u8 status = isr[i]; 745 u8 clear; --- 70 unchanged lines hidden (view full) --- 816 .irq_bus_lock = stmpe_irq_lock, 817 .irq_bus_sync_unlock = stmpe_irq_sync_unlock, 818 .irq_mask = stmpe_irq_mask, 819 .irq_unmask = stmpe_irq_unmask, 820}; 821 822static int __devinit stmpe_irq_init(struct stmpe *stmpe) 823{ |
824 struct irq_chip *chip = NULL; |
|
772 int num_irqs = stmpe->variant->num_irqs; 773 int base = stmpe->irq_base; 774 int irq; 775 | 825 int num_irqs = stmpe->variant->num_irqs; 826 int base = stmpe->irq_base; 827 int irq; 828 |
829 if (stmpe->variant->id_val != STMPE801_ID) 830 chip = &stmpe_irq_chip; 831 |
|
776 for (irq = base; irq < base + num_irqs; irq++) { 777 irq_set_chip_data(irq, stmpe); | 832 for (irq = base; irq < base + num_irqs; irq++) { 833 irq_set_chip_data(irq, stmpe); |
778 irq_set_chip_and_handler(irq, &stmpe_irq_chip, 779 handle_edge_irq); | 834 irq_set_chip_and_handler(irq, chip, handle_edge_irq); |
780 irq_set_nested_thread(irq, 1); 781#ifdef CONFIG_ARM 782 set_irq_flags(irq, IRQF_VALID); 783#else 784 irq_set_noprobe(irq); 785#endif 786 } 787 --- 15 unchanged lines hidden (view full) --- 803 } 804} 805 806static int __devinit stmpe_chip_init(struct stmpe *stmpe) 807{ 808 unsigned int irq_trigger = stmpe->pdata->irq_trigger; 809 int autosleep_timeout = stmpe->pdata->autosleep_timeout; 810 struct stmpe_variant_info *variant = stmpe->variant; | 835 irq_set_nested_thread(irq, 1); 836#ifdef CONFIG_ARM 837 set_irq_flags(irq, IRQF_VALID); 838#else 839 irq_set_noprobe(irq); 840#endif 841 } 842 --- 15 unchanged lines hidden (view full) --- 858 } 859} 860 861static int __devinit stmpe_chip_init(struct stmpe *stmpe) 862{ 863 unsigned int irq_trigger = stmpe->pdata->irq_trigger; 864 int autosleep_timeout = stmpe->pdata->autosleep_timeout; 865 struct stmpe_variant_info *variant = stmpe->variant; |
811 u8 icr = STMPE_ICR_LSB_GIM; | 866 u8 icr; |
812 unsigned int id; 813 u8 data[2]; 814 int ret; 815 816 ret = stmpe_block_read(stmpe, stmpe->regs[STMPE_IDX_CHIP_ID], 817 ARRAY_SIZE(data), data); 818 if (ret < 0) 819 return ret; --- 6 unchanged lines hidden (view full) --- 826 827 dev_info(stmpe->dev, "%s detected, chip id: %#x\n", variant->name, id); 828 829 /* Disable all modules -- subdrivers should enable what they need. */ 830 ret = stmpe_disable(stmpe, ~0); 831 if (ret) 832 return ret; 833 | 867 unsigned int id; 868 u8 data[2]; 869 int ret; 870 871 ret = stmpe_block_read(stmpe, stmpe->regs[STMPE_IDX_CHIP_ID], 872 ARRAY_SIZE(data), data); 873 if (ret < 0) 874 return ret; --- 6 unchanged lines hidden (view full) --- 881 882 dev_info(stmpe->dev, "%s detected, chip id: %#x\n", variant->name, id); 883 884 /* Disable all modules -- subdrivers should enable what they need. */ 885 ret = stmpe_disable(stmpe, ~0); 886 if (ret) 887 return ret; 888 |
834 if (irq_trigger == IRQF_TRIGGER_FALLING || 835 irq_trigger == IRQF_TRIGGER_RISING) 836 icr |= STMPE_ICR_LSB_EDGE; | 889 if (id == STMPE801_ID) 890 icr = STMPE801_REG_SYS_CTRL_INT_EN; 891 else 892 icr = STMPE_ICR_LSB_GIM; |
837 | 893 |
894 /* STMPE801 doesn't support Edge interrupts */ 895 if (id != STMPE801_ID) { 896 if (irq_trigger == IRQF_TRIGGER_FALLING || 897 irq_trigger == IRQF_TRIGGER_RISING) 898 icr |= STMPE_ICR_LSB_EDGE; 899 } 900 |
|
838 if (irq_trigger == IRQF_TRIGGER_RISING || | 901 if (irq_trigger == IRQF_TRIGGER_RISING || |
839 irq_trigger == IRQF_TRIGGER_HIGH) 840 icr |= STMPE_ICR_LSB_HIGH; | 902 irq_trigger == IRQF_TRIGGER_HIGH) { 903 if (id == STMPE801_ID) 904 icr |= STMPE801_REG_SYS_CTRL_INT_HI; 905 else 906 icr |= STMPE_ICR_LSB_HIGH; 907 } |
841 | 908 |
842 if (stmpe->pdata->irq_invert_polarity) 843 icr ^= STMPE_ICR_LSB_HIGH; | 909 if (stmpe->pdata->irq_invert_polarity) { 910 if (id == STMPE801_ID) 911 icr ^= STMPE801_REG_SYS_CTRL_INT_HI; 912 else 913 icr ^= STMPE_ICR_LSB_HIGH; 914 } |
844 845 if (stmpe->pdata->autosleep) { 846 ret = stmpe_autosleep(stmpe, autosleep_timeout); 847 if (ret) 848 return ret; 849 } 850 851 return stmpe_reg_write(stmpe, stmpe->regs[STMPE_IDX_ICR_LSB], icr); --- 157 unchanged lines hidden --- | 915 916 if (stmpe->pdata->autosleep) { 917 ret = stmpe_autosleep(stmpe, autosleep_timeout); 918 if (ret) 919 return ret; 920 } 921 922 return stmpe_reg_write(stmpe, stmpe->regs[STMPE_IDX_ICR_LSB], icr); --- 157 unchanged lines hidden --- |