aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinctrl-tegra114.c
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2014-04-15 13:00:50 -0400
committerLinus Walleij <linus.walleij@linaro.org>2014-04-22 10:48:39 -0400
commite53b797474ac61debd6e7c186285c8cc24a3a166 (patch)
treeeda64dc694dc9c840b555b7a5b20b19f144f6e0b /drivers/pinctrl/pinctrl-tegra114.c
parenta16b81dcbfc5889c37dac5f8e836136e4740fc18 (diff)
pinctrl: tegra: remove redundant data table fields
Any SoC which supports the einput, odrain, lock, ioreset, or rcv_sel options has the relevant HW register fields in the same register as the mux function selection. Similarly, the drvtype option is always in the drive register, if it is supported at all. Hence, we don't need to have struct *_reg fields in the pin group table to define which register and bank to use for those options. Delete this to save space in the driver's data tables. However, many of those options are not supported on all SoCs, or not supported on some pingroups. We need a way to detect when they are supported. Previously, this was indicated by setting the struct *_reg field to -1. With the struct *_reg fields removed, we use the struct *_bit fields for this purpose instead. The struct *_bit fields need to be expanded from 5 to 6 bits in order to store a value outside the valid HW bit range of 0..31. Even without removing the struct *_reg fields, we still need to add code to validate the struct *_bit fields, since some struct *_bit fields were already being set to -1, without an option-specific struct *_reg field to "guard" them. In other words, before this change, the pinmux driver might allow some unsupported options to be written to HW. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-tegra114.c')
-rw-r--r--drivers/pinctrl/pinctrl-tegra114.c53
1 files changed, 20 insertions, 33 deletions
diff --git a/drivers/pinctrl/pinctrl-tegra114.c b/drivers/pinctrl/pinctrl-tegra114.c
index 63fe7619d3ff..6766873669e8 100644
--- a/drivers/pinctrl/pinctrl-tegra114.c
+++ b/drivers/pinctrl/pinctrl-tegra114.c
@@ -1547,8 +1547,10 @@ static struct tegra_function tegra114_functions[] = {
1547#define DRV_PINGROUP_REG_A 0x868 /* bank 0 */ 1547#define DRV_PINGROUP_REG_A 0x868 /* bank 0 */
1548#define PINGROUP_REG_A 0x3000 /* bank 1 */ 1548#define PINGROUP_REG_A 0x3000 /* bank 1 */
1549 1549
1550#define PINGROUP_REG_Y(r) ((r) - PINGROUP_REG_A) 1550#define PINGROUP_REG(r) ((r) - PINGROUP_REG_A)
1551#define PINGROUP_REG_N(r) -1 1551
1552#define PINGROUP_BIT_Y(b) (b)
1553#define PINGROUP_BIT_N(b) (-1)
1552 1554
1553#define PINGROUP(pg_name, f0, f1, f2, f3, f_safe, r, od, ior, rcv_sel) \ 1555#define PINGROUP(pg_name, f0, f1, f2, f3, f_safe, r, od, ior, rcv_sel) \
1554 { \ 1556 { \
@@ -1562,37 +1564,24 @@ static struct tegra_function tegra114_functions[] = {
1562 TEGRA_MUX_##f3, \ 1564 TEGRA_MUX_##f3, \
1563 }, \ 1565 }, \
1564 .func_safe = TEGRA_MUX_##f_safe, \ 1566 .func_safe = TEGRA_MUX_##f_safe, \
1565 .mux_reg = PINGROUP_REG_Y(r), \ 1567 .mux_reg = PINGROUP_REG(r), \
1566 .mux_bank = 1, \ 1568 .mux_bank = 1, \
1567 .mux_bit = 0, \ 1569 .mux_bit = 0, \
1568 .pupd_reg = PINGROUP_REG_Y(r), \ 1570 .pupd_reg = PINGROUP_REG(r), \
1569 .pupd_bank = 1, \ 1571 .pupd_bank = 1, \
1570 .pupd_bit = 2, \ 1572 .pupd_bit = 2, \
1571 .tri_reg = PINGROUP_REG_Y(r), \ 1573 .tri_reg = PINGROUP_REG(r), \
1572 .tri_bank = 1, \ 1574 .tri_bank = 1, \
1573 .tri_bit = 4, \ 1575 .tri_bit = 4, \
1574 .einput_reg = PINGROUP_REG_Y(r), \ 1576 .einput_bit = PINGROUP_BIT_Y(5), \
1575 .einput_bank = 1, \ 1577 .odrain_bit = PINGROUP_BIT_##od(6), \
1576 .einput_bit = 5, \ 1578 .lock_bit = PINGROUP_BIT_Y(7), \
1577 .odrain_reg = PINGROUP_REG_##od(r), \ 1579 .ioreset_bit = PINGROUP_BIT_##ior(8), \
1578 .odrain_bank = 1, \ 1580 .rcv_sel_bit = PINGROUP_BIT_##rcv_sel(9), \
1579 .odrain_bit = 6, \
1580 .lock_reg = PINGROUP_REG_Y(r), \
1581 .lock_bank = 1, \
1582 .lock_bit = 7, \
1583 .ioreset_reg = PINGROUP_REG_##ior(r), \
1584 .ioreset_bank = 1, \
1585 .ioreset_bit = 8, \
1586 .rcv_sel_reg = PINGROUP_REG_##rcv_sel(r), \
1587 .rcv_sel_bank = 1, \
1588 .rcv_sel_bit = 9, \
1589 .drv_reg = -1, \ 1581 .drv_reg = -1, \
1590 .drvtype_reg = -1, \
1591 } 1582 }
1592 1583
1593#define DRV_PINGROUP_REG_Y(r) ((r) - DRV_PINGROUP_REG_A) 1584#define DRV_PINGROUP_REG(r) ((r) - DRV_PINGROUP_REG_A)
1594#define DRV_PINGROUP_REG_N(r) -1
1595
1596 1585
1597#define DRV_PINGROUP(pg_name, r, hsm_b, schmitt_b, lpmd_b, \ 1586#define DRV_PINGROUP(pg_name, r, hsm_b, schmitt_b, lpmd_b, \
1598 drvdn_b, drvdn_w, drvup_b, drvup_w, \ 1587 drvdn_b, drvdn_w, drvup_b, drvup_w, \
@@ -1605,12 +1594,12 @@ static struct tegra_function tegra114_functions[] = {
1605 .mux_reg = -1, \ 1594 .mux_reg = -1, \
1606 .pupd_reg = -1, \ 1595 .pupd_reg = -1, \
1607 .tri_reg = -1, \ 1596 .tri_reg = -1, \
1608 .einput_reg = -1, \ 1597 .einput_bit = -1, \
1609 .odrain_reg = -1, \ 1598 .odrain_bit = -1, \
1610 .lock_reg = -1, \ 1599 .lock_bit = -1, \
1611 .ioreset_reg = -1, \ 1600 .ioreset_bit = -1, \
1612 .rcv_sel_reg = -1, \ 1601 .rcv_sel_bit = -1, \
1613 .drv_reg = DRV_PINGROUP_REG_Y(r), \ 1602 .drv_reg = DRV_PINGROUP_REG(r), \
1614 .drv_bank = 0, \ 1603 .drv_bank = 0, \
1615 .hsm_bit = hsm_b, \ 1604 .hsm_bit = hsm_b, \
1616 .schmitt_bit = schmitt_b, \ 1605 .schmitt_bit = schmitt_b, \
@@ -1623,9 +1612,7 @@ static struct tegra_function tegra114_functions[] = {
1623 .slwr_width = slwr_w, \ 1612 .slwr_width = slwr_w, \
1624 .slwf_bit = slwf_b, \ 1613 .slwf_bit = slwf_b, \
1625 .slwf_width = slwf_w, \ 1614 .slwf_width = slwf_w, \
1626 .drvtype_reg = DRV_PINGROUP_REG_##drvtype(r), \ 1615 .drvtype_bit = PINGROUP_BIT_##drvtype(6), \
1627 .drvtype_bank = 0, \
1628 .drvtype_bit = 6, \
1629 } 1616 }
1630 1617
1631static const struct tegra_pingroup tegra114_groups[] = { 1618static const struct tegra_pingroup tegra114_groups[] = {