aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrice Chotard <patrice.chotard@st.com>2016-08-10 03:39:06 -0400
committerLee Jones <lee.jones@linaro.org>2016-08-10 04:23:25 -0400
commit0f4be8cf637ea4637faba8a0e4bf2270287c6ba0 (patch)
treefd3f170ae3a01ed96a60e5a16393ef8cffa9abeb
parent29b4817d4018df78086157ea3a55c1d9424a7cfc (diff)
mfd: stmpe: Add STMPE_IDX_SYS_CTRL/2 enum
As STMPE1801/1601/24xx has a SYS_CTRL register and STMPE1601/2403 has even a SYS_CTRL2 register, add STMPE_IDX_SYS_CTRL/2 and update driver code accordingly This update prepares the ground for not yet supported STMPE1600 which share similar REG_SYS_CTRL register. Signed-off-by: Patrice Chotard <patrice.chotard@st.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r--drivers/mfd/stmpe.c21
-rw-r--r--drivers/mfd/stmpe.h2
-rw-r--r--include/linux/mfd/stmpe.h2
3 files changed, 18 insertions, 7 deletions
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index 94c7cc02fdab..c053b2b67bad 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -469,6 +469,8 @@ static const struct mfd_cell stmpe_ts_cell = {
469 469
470static const u8 stmpe811_regs[] = { 470static const u8 stmpe811_regs[] = {
471 [STMPE_IDX_CHIP_ID] = STMPE811_REG_CHIP_ID, 471 [STMPE_IDX_CHIP_ID] = STMPE811_REG_CHIP_ID,
472 [STMPE_IDX_SYS_CTRL] = STMPE811_REG_SYS_CTRL,
473 [STMPE_IDX_SYS_CTRL2] = STMPE811_REG_SYS_CTRL2,
472 [STMPE_IDX_ICR_LSB] = STMPE811_REG_INT_CTRL, 474 [STMPE_IDX_ICR_LSB] = STMPE811_REG_INT_CTRL,
473 [STMPE_IDX_IER_LSB] = STMPE811_REG_INT_EN, 475 [STMPE_IDX_IER_LSB] = STMPE811_REG_INT_EN,
474 [STMPE_IDX_ISR_MSB] = STMPE811_REG_INT_STA, 476 [STMPE_IDX_ISR_MSB] = STMPE811_REG_INT_STA,
@@ -511,7 +513,7 @@ static int stmpe811_enable(struct stmpe *stmpe, unsigned int blocks,
511 if (blocks & STMPE_BLOCK_TOUCHSCREEN) 513 if (blocks & STMPE_BLOCK_TOUCHSCREEN)
512 mask |= STMPE811_SYS_CTRL2_TSC_OFF; 514 mask |= STMPE811_SYS_CTRL2_TSC_OFF;
513 515
514 return __stmpe_set_bits(stmpe, STMPE811_REG_SYS_CTRL2, mask, 516 return __stmpe_set_bits(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL2], mask,
515 enable ? 0 : mask); 517 enable ? 0 : mask);
516} 518}
517 519
@@ -556,6 +558,8 @@ static struct stmpe_variant_info stmpe610 = {
556 558
557static const u8 stmpe1601_regs[] = { 559static const u8 stmpe1601_regs[] = {
558 [STMPE_IDX_CHIP_ID] = STMPE1601_REG_CHIP_ID, 560 [STMPE_IDX_CHIP_ID] = STMPE1601_REG_CHIP_ID,
561 [STMPE_IDX_SYS_CTRL] = STMPE1601_REG_SYS_CTRL,
562 [STMPE_IDX_SYS_CTRL2] = STMPE1601_REG_SYS_CTRL2,
559 [STMPE_IDX_ICR_LSB] = STMPE1601_REG_ICR_LSB, 563 [STMPE_IDX_ICR_LSB] = STMPE1601_REG_ICR_LSB,
560 [STMPE_IDX_IER_LSB] = STMPE1601_REG_IER_LSB, 564 [STMPE_IDX_IER_LSB] = STMPE1601_REG_IER_LSB,
561 [STMPE_IDX_ISR_MSB] = STMPE1601_REG_ISR_MSB, 565 [STMPE_IDX_ISR_MSB] = STMPE1601_REG_ISR_MSB,
@@ -640,13 +644,13 @@ static int stmpe1601_autosleep(struct stmpe *stmpe,
640 return timeout; 644 return timeout;
641 } 645 }
642 646
643 ret = __stmpe_set_bits(stmpe, STMPE1601_REG_SYS_CTRL2, 647 ret = __stmpe_set_bits(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL2],
644 STMPE1601_AUTOSLEEP_TIMEOUT_MASK, 648 STMPE1601_AUTOSLEEP_TIMEOUT_MASK,
645 timeout); 649 timeout);
646 if (ret < 0) 650 if (ret < 0)
647 return ret; 651 return ret;
648 652
649 return __stmpe_set_bits(stmpe, STMPE1601_REG_SYS_CTRL2, 653 return __stmpe_set_bits(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL2],
650 STPME1601_AUTOSLEEP_ENABLE, 654 STPME1601_AUTOSLEEP_ENABLE,
651 STPME1601_AUTOSLEEP_ENABLE); 655 STPME1601_AUTOSLEEP_ENABLE);
652} 656}
@@ -671,7 +675,7 @@ static int stmpe1601_enable(struct stmpe *stmpe, unsigned int blocks,
671 else 675 else
672 mask &= ~STMPE1601_SYS_CTRL_ENABLE_SPWM; 676 mask &= ~STMPE1601_SYS_CTRL_ENABLE_SPWM;
673 677
674 return __stmpe_set_bits(stmpe, STMPE1601_REG_SYS_CTRL, mask, 678 return __stmpe_set_bits(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL], mask,
675 enable ? mask : 0); 679 enable ? mask : 0);
676} 680}
677 681
@@ -710,6 +714,7 @@ static struct stmpe_variant_info stmpe1601 = {
710 */ 714 */
711static const u8 stmpe1801_regs[] = { 715static const u8 stmpe1801_regs[] = {
712 [STMPE_IDX_CHIP_ID] = STMPE1801_REG_CHIP_ID, 716 [STMPE_IDX_CHIP_ID] = STMPE1801_REG_CHIP_ID,
717 [STMPE_IDX_SYS_CTRL] = STMPE1801_REG_SYS_CTRL,
713 [STMPE_IDX_ICR_LSB] = STMPE1801_REG_INT_CTRL_LOW, 718 [STMPE_IDX_ICR_LSB] = STMPE1801_REG_INT_CTRL_LOW,
714 [STMPE_IDX_IER_LSB] = STMPE1801_REG_INT_EN_MASK_LOW, 719 [STMPE_IDX_IER_LSB] = STMPE1801_REG_INT_EN_MASK_LOW,
715 [STMPE_IDX_ISR_LSB] = STMPE1801_REG_INT_STA_LOW, 720 [STMPE_IDX_ISR_LSB] = STMPE1801_REG_INT_STA_LOW,
@@ -756,14 +761,14 @@ static int stmpe1801_reset(struct stmpe *stmpe)
756 unsigned long timeout; 761 unsigned long timeout;
757 int ret = 0; 762 int ret = 0;
758 763
759 ret = __stmpe_set_bits(stmpe, STMPE1801_REG_SYS_CTRL, 764 ret = __stmpe_set_bits(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL],
760 STMPE1801_MSK_SYS_CTRL_RESET, STMPE1801_MSK_SYS_CTRL_RESET); 765 STMPE1801_MSK_SYS_CTRL_RESET, STMPE1801_MSK_SYS_CTRL_RESET);
761 if (ret < 0) 766 if (ret < 0)
762 return ret; 767 return ret;
763 768
764 timeout = jiffies + msecs_to_jiffies(100); 769 timeout = jiffies + msecs_to_jiffies(100);
765 while (time_before(jiffies, timeout)) { 770 while (time_before(jiffies, timeout)) {
766 ret = __stmpe_reg_read(stmpe, STMPE1801_REG_SYS_CTRL); 771 ret = __stmpe_reg_read(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL]);
767 if (ret < 0) 772 if (ret < 0)
768 return ret; 773 return ret;
769 if (!(ret & STMPE1801_MSK_SYS_CTRL_RESET)) 774 if (!(ret & STMPE1801_MSK_SYS_CTRL_RESET))
@@ -794,6 +799,8 @@ static struct stmpe_variant_info stmpe1801 = {
794 799
795static const u8 stmpe24xx_regs[] = { 800static const u8 stmpe24xx_regs[] = {
796 [STMPE_IDX_CHIP_ID] = STMPE24XX_REG_CHIP_ID, 801 [STMPE_IDX_CHIP_ID] = STMPE24XX_REG_CHIP_ID,
802 [STMPE_IDX_SYS_CTRL] = STMPE24XX_REG_SYS_CTRL,
803 [STMPE_IDX_SYS_CTRL2] = STMPE24XX_REG_SYS_CTRL2,
797 [STMPE_IDX_ICR_LSB] = STMPE24XX_REG_ICR_LSB, 804 [STMPE_IDX_ICR_LSB] = STMPE24XX_REG_ICR_LSB,
798 [STMPE_IDX_IER_LSB] = STMPE24XX_REG_IER_LSB, 805 [STMPE_IDX_IER_LSB] = STMPE24XX_REG_IER_LSB,
799 [STMPE_IDX_ISR_MSB] = STMPE24XX_REG_ISR_MSB, 806 [STMPE_IDX_ISR_MSB] = STMPE24XX_REG_ISR_MSB,
@@ -840,7 +847,7 @@ static int stmpe24xx_enable(struct stmpe *stmpe, unsigned int blocks,
840 if (blocks & STMPE_BLOCK_KEYPAD) 847 if (blocks & STMPE_BLOCK_KEYPAD)
841 mask |= STMPE24XX_SYS_CTRL_ENABLE_KPC; 848 mask |= STMPE24XX_SYS_CTRL_ENABLE_KPC;
842 849
843 return __stmpe_set_bits(stmpe, STMPE24XX_REG_SYS_CTRL, mask, 850 return __stmpe_set_bits(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL], mask,
844 enable ? mask : 0); 851 enable ? mask : 0);
845} 852}
846 853
diff --git a/drivers/mfd/stmpe.h b/drivers/mfd/stmpe.h
index 84adb46b3e2f..406f9f2d8935 100644
--- a/drivers/mfd/stmpe.h
+++ b/drivers/mfd/stmpe.h
@@ -138,6 +138,7 @@ int stmpe_remove(struct stmpe *stmpe);
138#define STMPE811_NR_INTERNAL_IRQS 8 138#define STMPE811_NR_INTERNAL_IRQS 8
139 139
140#define STMPE811_REG_CHIP_ID 0x00 140#define STMPE811_REG_CHIP_ID 0x00
141#define STMPE811_REG_SYS_CTRL 0x03
141#define STMPE811_REG_SYS_CTRL2 0x04 142#define STMPE811_REG_SYS_CTRL2 0x04
142#define STMPE811_REG_SPI_CFG 0x08 143#define STMPE811_REG_SPI_CFG 0x08
143#define STMPE811_REG_INT_CTRL 0x09 144#define STMPE811_REG_INT_CTRL 0x09
@@ -264,6 +265,7 @@ int stmpe_remove(struct stmpe *stmpe);
264#define STMPE24XX_NR_INTERNAL_IRQS 9 265#define STMPE24XX_NR_INTERNAL_IRQS 9
265 266
266#define STMPE24XX_REG_SYS_CTRL 0x02 267#define STMPE24XX_REG_SYS_CTRL 0x02
268#define STMPE24XX_REG_SYS_CTRL2 0x03
267#define STMPE24XX_REG_ICR_LSB 0x11 269#define STMPE24XX_REG_ICR_LSB 0x11
268#define STMPE24XX_REG_IER_LSB 0x13 270#define STMPE24XX_REG_IER_LSB 0x13
269#define STMPE24XX_REG_ISR_MSB 0x14 271#define STMPE24XX_REG_ISR_MSB 0x14
diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h
index de748bc7525e..eb8b73bd139f 100644
--- a/include/linux/mfd/stmpe.h
+++ b/include/linux/mfd/stmpe.h
@@ -39,6 +39,8 @@ enum stmpe_partnum {
39 */ 39 */
40enum { 40enum {
41 STMPE_IDX_CHIP_ID, 41 STMPE_IDX_CHIP_ID,
42 STMPE_IDX_SYS_CTRL,
43 STMPE_IDX_SYS_CTRL2,
42 STMPE_IDX_ICR_LSB, 44 STMPE_IDX_ICR_LSB,
43 STMPE_IDX_IER_LSB, 45 STMPE_IDX_IER_LSB,
44 STMPE_IDX_ISR_LSB, 46 STMPE_IDX_ISR_LSB,