pinctrl: Widen the generic pinconf argument from 16 to 24 bits
authorMika Westerberg <mika.westerberg@linux.intel.com>
Mon, 23 Jan 2017 12:34:32 +0000 (15:34 +0300)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 26 Jan 2017 14:22:32 +0000 (15:22 +0100)
The current pinconf packed format allows only 16-bit argument limiting
the maximum value 65535. For most types this is enough. However,
debounce time can be in range of hundreths of milliseconds in case of
mechanical switches so we cannot represent the worst case using the
current format.

In order to support larger values change the packed format so that the
lower 8 bits are used as type which leaves 24 bits for the argument.
This allows representing values up to 16777215 and debounce times up to
16 seconds.

We also convert the existing users to use 32-bit integer when extracting
argument from the packed configuration value.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
18 files changed:
drivers/pinctrl/bcm/pinctrl-bcm281xx.c
drivers/pinctrl/bcm/pinctrl-iproc-gpio.c
drivers/pinctrl/bcm/pinctrl-ns2-mux.c
drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
drivers/pinctrl/intel/pinctrl-cherryview.c
drivers/pinctrl/meson/pinctrl-meson.c
drivers/pinctrl/pinctrl-da850-pupd.c
drivers/pinctrl/pinctrl-lpc18xx.c
drivers/pinctrl/pinctrl-max77620.c
drivers/pinctrl/pinctrl-palmas.c
drivers/pinctrl/pinctrl-rockchip.c
drivers/pinctrl/pinctrl-single.c
drivers/pinctrl/sirf/pinctrl-atlas7.c
drivers/pinctrl/sunxi/pinctrl-sunxi.c
drivers/pinctrl/uniphier/pinctrl-uniphier-core.c
drivers/pinctrl/vt8500/pinctrl-wmt.c
drivers/rtc/rtc-omap.c
include/linux/pinctrl/pinconf-generic.h

index a5331fdfc795edfa57dff3f4677dcf41eef4fd61..810a81786f62d4013cde819099eaee231ae056c1 100644 (file)
@@ -1106,7 +1106,7 @@ static int bcm281xx_std_pin_update(struct pinctrl_dev *pctldev,
        struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev);
        int i;
        enum pin_config_param param;
-       u16 arg;
+       u32 arg;
 
        for (i = 0; i < num_configs; i++) {
                param = pinconf_to_config_param(configs[i]);
@@ -1222,7 +1222,7 @@ static int bcm281xx_i2c_pin_update(struct pinctrl_dev *pctldev,
        struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev);
        int i, j;
        enum pin_config_param param;
-       u16 arg;
+       u32 arg;
 
        for (i = 0; i < num_configs; i++) {
                param = pinconf_to_config_param(configs[i]);
@@ -1292,7 +1292,7 @@ static int bcm281xx_hdmi_pin_update(struct pinctrl_dev *pctldev,
        struct bcm281xx_pinctrl_data *pdata = pinctrl_dev_get_drvdata(pctldev);
        int i;
        enum pin_config_param param;
-       u16 arg;
+       u32 arg;
 
        for (i = 0; i < num_configs; i++) {
                param = pinconf_to_config_param(configs[i]);
index 5d1e505c3c63d76a85af0dcb7051b9a3da15c2e5..3ca925dfefd14092c8bff6eaddc8d95a44591bca 100644 (file)
@@ -619,7 +619,7 @@ static int iproc_pin_config_set(struct pinctrl_dev *pctldev, unsigned pin,
 {
        struct iproc_gpio *chip = pinctrl_dev_get_drvdata(pctldev);
        enum pin_config_param param;
-       u16 arg;
+       u32 arg;
        unsigned i, gpio = iproc_pin_to_gpio(pin);
        int ret = -ENOTSUPP;
 
index 13a4c27741572e04fb03532cfc0820dd1623ff6b..4b5cf0e0f16e2dbfcea320414f1aa8c9e8a56179 100644 (file)
@@ -703,7 +703,7 @@ static int ns2_pin_get_enable(struct pinctrl_dev *pctrldev, unsigned int pin)
 }
 
 static int ns2_pin_set_slew(struct pinctrl_dev *pctrldev, unsigned int pin,
-                           u16 slew)
+                           u32 slew)
 {
        struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrldev);
        struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data;
@@ -793,7 +793,7 @@ static void ns2_pin_get_pull(struct pinctrl_dev *pctrldev,
 }
 
 static int ns2_pin_set_strength(struct pinctrl_dev *pctrldev, unsigned int pin,
-                               u16 strength)
+                               u32 strength)
 {
        struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrldev);
        struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data;
@@ -904,7 +904,7 @@ static int ns2_pin_config_set(struct pinctrl_dev *pctrldev, unsigned int pin,
        struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data;
        enum pin_config_param param;
        unsigned int i;
-       u16 arg;
+       u32 arg;
        int ret = -ENOTSUPP;
 
        if (pin_data->pin_conf.base == -1)
index c8deb8be1da785fd15d8f5182b3b19143ca3c33f..91ea32dc1e7f2f292c5c6dc5a0d39044feeb7d0a 100644 (file)
@@ -366,7 +366,7 @@ static const struct pinctrl_ops nsp_pctrl_ops = {
        .dt_free_map = pinctrl_utils_free_map,
 };
 
-static int nsp_gpio_set_slew(struct nsp_gpio *chip, unsigned gpio, u16 slew)
+static int nsp_gpio_set_slew(struct nsp_gpio *chip, unsigned gpio, u32 slew)
 {
        if (slew)
                nsp_set_bit(chip, IO_CTRL, NSP_GPIO_SLEW_RATE_EN, gpio, true);
@@ -403,7 +403,7 @@ static void nsp_gpio_get_pull(struct nsp_gpio *chip, unsigned gpio,
 }
 
 static int nsp_gpio_set_strength(struct nsp_gpio *chip, unsigned gpio,
-                                u16 strength)
+                                u32 strength)
 {
        u32 offset, shift, i;
        u32 val;
@@ -522,7 +522,7 @@ static int nsp_pin_config_set(struct pinctrl_dev *pctldev, unsigned pin,
 {
        struct nsp_gpio *chip = pinctrl_dev_get_drvdata(pctldev);
        enum pin_config_param param;
-       u16 arg;
+       u32 arg;
        unsigned int i, gpio;
        int ret = -ENOTSUPP;
 
index 5e66860a5e677290a0c649728cc48f852cc408b9..f80134e3e0b68aba9f8b94771702cdd3df83a678 100644 (file)
@@ -1059,7 +1059,7 @@ static int chv_config_get(struct pinctrl_dev *pctldev, unsigned pin,
 }
 
 static int chv_config_set_pull(struct chv_pinctrl *pctrl, unsigned pin,
-                              enum pin_config_param param, u16 arg)
+                              enum pin_config_param param, u32 arg)
 {
        void __iomem *reg = chv_padreg(pctrl, pin, CHV_PADCTRL0);
        unsigned long flags;
@@ -1151,7 +1151,7 @@ static int chv_config_set(struct pinctrl_dev *pctldev, unsigned pin,
        struct chv_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
        enum pin_config_param param;
        int i, ret;
-       u16 arg;
+       u32 arg;
 
        if (chv_pad_locked(pctrl, pin))
                return -EBUSY;
index a579126832afde2d758d629f58338af2d9e9378f..8fbb571f50de013bf7844d70a3500022ff2178f5 100644 (file)
@@ -260,7 +260,6 @@ static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin,
        enum pin_config_param param;
        unsigned int reg, bit;
        int i, ret;
-       u16 arg;
 
        ret = meson_get_bank(pc, pin, &bank);
        if (ret)
@@ -268,7 +267,6 @@ static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin,
 
        for (i = 0; i < num_configs; i++) {
                param = pinconf_to_config_param(configs[i]);
-               arg = pinconf_to_config_argument(configs[i]);
 
                switch (param) {
                case PIN_CONFIG_BIAS_DISABLE:
index b36a90a3f3e492493b41c5c61c61582e7d35a091..44d5f5f5b07fd4f69231f0dcc1dfb106fb6d804a 100644 (file)
@@ -113,7 +113,6 @@ static int da850_pupd_pin_config_group_set(struct pinctrl_dev *pctldev,
        struct da850_pupd_data *data = pinctrl_dev_get_drvdata(pctldev);
        u32 ena, sel;
        enum pin_config_param param;
-       u16 arg;
        int i;
 
        ena = readl(data->base + DA850_PUPD_ENA);
@@ -121,7 +120,6 @@ static int da850_pupd_pin_config_group_set(struct pinctrl_dev *pctldev,
 
        for (i = 0; i < num_configs; i++) {
                param = pinconf_to_config_param(configs[i]);
-               arg = pinconf_to_config_argument(configs[i]);
 
                switch (param) {
                case PIN_CONFIG_BIAS_DISABLE:
index e053f1fa551203cdf6e2fdeb2e3d8b78e75bdc0f..d090f37ca4a114683d69e203532b20dc653c1d35 100644 (file)
@@ -904,7 +904,7 @@ static int lpc18xx_pconf_get(struct pinctrl_dev *pctldev, unsigned pin,
 
 static int lpc18xx_pconf_set_usb1(struct pinctrl_dev *pctldev,
                                  enum pin_config_param param,
-                                 u16 param_val, u32 *reg)
+                                 u32 param_val, u32 *reg)
 {
        switch (param) {
        case PIN_CONFIG_LOW_POWER_MODE:
@@ -932,7 +932,7 @@ static int lpc18xx_pconf_set_usb1(struct pinctrl_dev *pctldev,
 
 static int lpc18xx_pconf_set_i2c0(struct pinctrl_dev *pctldev,
                                  enum pin_config_param param,
-                                 u16 param_val, u32 *reg,
+                                 u32 param_val, u32 *reg,
                                  unsigned pin)
 {
        u8 shift;
@@ -982,7 +982,7 @@ static int lpc18xx_pconf_set_i2c0(struct pinctrl_dev *pctldev,
 }
 
 static int lpc18xx_pconf_set_gpio_pin_int(struct pinctrl_dev *pctldev,
-                                         u16 param_val, unsigned pin)
+                                         u32 param_val, unsigned pin)
 {
        struct lpc18xx_scu_data *scu = pinctrl_dev_get_drvdata(pctldev);
        u32 val, reg_val, reg_offset = LPC18XX_SCU_PINTSEL0;
@@ -1008,7 +1008,7 @@ static int lpc18xx_pconf_set_gpio_pin_int(struct pinctrl_dev *pctldev,
 }
 
 static int lpc18xx_pconf_set_pin(struct pinctrl_dev *pctldev, unsigned param,
-                                u16 param_val, u32 *reg, unsigned pin,
+                                u32 param_val, u32 *reg, unsigned pin,
                                 struct lpc18xx_pin_caps *pin_cap)
 {
        switch (param) {
@@ -1088,7 +1088,7 @@ static int lpc18xx_pconf_set(struct pinctrl_dev *pctldev, unsigned pin,
        struct lpc18xx_scu_data *scu = pinctrl_dev_get_drvdata(pctldev);
        struct lpc18xx_pin_caps *pin_cap;
        enum pin_config_param param;
-       u16 param_val;
+       u32 param_val;
        u32 reg;
        int ret;
        int i;
index d9ff53e8f715a425ae563bccfe6a7fb85bcd9679..b8d2180a2bea44426b940745c5030f60073e214e 100644 (file)
@@ -402,7 +402,7 @@ static int max77620_pinconf_set(struct pinctrl_dev *pctldev,
        struct device *dev = mpci->dev;
        struct max77620_fps_config *fps_config;
        int param;
-       u16 param_val;
+       u32 param_val;
        unsigned int val;
        unsigned int pu_val;
        unsigned int pd_val;
index a30146da7ffdcb6a72513b87d692a49527a5d16c..4d6a5015b9272f335d8738c072e27cd0eec56f9b 100644 (file)
@@ -860,7 +860,7 @@ static int palmas_pinconf_set(struct pinctrl_dev *pctldev,
 {
        struct palmas_pctrl_chip_info *pci = pinctrl_dev_get_drvdata(pctldev);
        enum pin_config_param param;
-       u16 param_val;
+       u32 param_val;
        const struct palmas_pingroup *g;
        const struct palmas_pin_info *opt;
        int ret;
index 08765f58253c206b2c3d6692d19a504a7de4fbfa..7813599e43fac80634061b00d0dbb32f5ea829f6 100644 (file)
@@ -1441,7 +1441,7 @@ static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
        struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
        struct rockchip_pin_bank *bank = pin_to_bank(info, pin);
        enum pin_config_param param;
-       u16 arg;
+       u32 arg;
        int i;
        int rc;
 
index a5a0392ab8175da62001816e3f7eb7a2600f1b08..f71f2e813ea653c415d602aa49c56d6e02b6ca97 100644 (file)
@@ -622,7 +622,7 @@ static int pcs_pinconf_set(struct pinctrl_dev *pctldev,
        struct pcs_device *pcs = pinctrl_dev_get_drvdata(pctldev);
        struct pcs_function *func;
        unsigned offset = 0, shift = 0, i, data, ret;
-       u16 arg;
+       u32 arg;
        int j;
 
        ret = pcs_get_function(pctldev, pin, &func);
index 7f3041697813ebc73bd031454dbb5df3ca30bb2d..82b8a429743dd84f25e9d2f53fcbb2f4a93336e7 100644 (file)
@@ -5322,7 +5322,8 @@ static int atlas7_pin_config_set(struct pinctrl_dev *pctldev,
                                unsigned pin, unsigned long *configs,
                                unsigned num_configs)
 {
-       u16 param, arg;
+       u16 param;
+       u32 arg;
        int idx, err;
 
        for (idx = 0; idx < num_configs; idx++) {
index 0eb51e33cb1be5412ab11d10e7cdb474a2faa061..28bfa5f413e40fef2b3ce0ba1a806ecc4386079a 100644 (file)
@@ -540,7 +540,7 @@ static int sunxi_pconf_group_set(struct pinctrl_dev *pctldev,
                enum pin_config_param param;
                unsigned long flags;
                u32 offset, shift, mask, reg;
-               u16 arg, val;
+               u32 arg, val;
                int ret;
 
                param = pinconf_to_config_param(configs[i]);
index 9b2ee717bcccb99fb1ca773806b09afa75f62077..546f23c9040c2f27721f9db2d7a1c646cfe95785 100644 (file)
@@ -297,7 +297,7 @@ static int uniphier_conf_pin_config_get(struct pinctrl_dev *pctldev,
 
 static int uniphier_conf_pin_bias_set(struct pinctrl_dev *pctldev,
                                      const struct pin_desc *desc,
-                                     enum pin_config_param param, u16 arg)
+                                     enum pin_config_param param, u32 arg)
 {
        struct uniphier_pinctrl_priv *priv = pinctrl_dev_get_drvdata(pctldev);
        enum uniphier_pin_pull_dir pull_dir =
@@ -468,7 +468,7 @@ static int uniphier_conf_pin_config_set(struct pinctrl_dev *pctldev,
        for (i = 0; i < num_configs; i++) {
                enum pin_config_param param =
                                        pinconf_to_config_param(configs[i]);
-               u16 arg = pinconf_to_config_argument(configs[i]);
+               u32 arg = pinconf_to_config_argument(configs[i]);
 
                switch (param) {
                case PIN_CONFIG_BIAS_DISABLE:
index 270ca2a47a8c9a8237921800d64c46192f3e3437..c207e60b734f85ab921b0fa98479f7c4b7405a03 100644 (file)
@@ -428,7 +428,7 @@ static int wmt_pinconf_set(struct pinctrl_dev *pctldev, unsigned pin,
 {
        struct wmt_pinctrl_data *data = pinctrl_dev_get_drvdata(pctldev);
        enum pin_config_param param;
-       u16 arg;
+       u32 arg;
        u32 bank = WMT_BANK_FROM_PIN(pin);
        u32 bit = WMT_BIT_FROM_PIN(pin);
        u32 reg_pull_en = data->banks[bank].reg_pull_en;
index 51e52446eacb8f4d1e32821fd9c2d6da019825f3..73594f38c453e3cbfe4d301b4a18404520a7d8ef 100644 (file)
@@ -610,7 +610,7 @@ static int rtc_pinconf_set(struct pinctrl_dev *pctldev,
        struct omap_rtc *rtc = pinctrl_dev_get_drvdata(pctldev);
        u32 val;
        unsigned int param;
-       u16 param_val;
+       u32 param_val;
        int i;
 
        rtc->type->unlock(rtc);
index 12343caa114ef3ec27a5ab5a3caaf5320cbe6508..9a09107c890eb00f22d1b7964016ae4af3bcb8fe 100644 (file)
@@ -92,6 +92,8 @@
  * @PIN_CONFIG_END: this is the last enumerator for pin configurations, if
  *     you need to pass in custom configurations to the pin controller, use
  *     PIN_CONFIG_END+1 as the base offset.
+ * @PIN_CONFIG_MAX: this is the maximum configuration value that can be
+ *     presented using the packed format.
  */
 enum pin_config_param {
        PIN_CONFIG_BIAS_BUS_HOLD,
@@ -112,7 +114,8 @@ enum pin_config_param {
        PIN_CONFIG_OUTPUT,
        PIN_CONFIG_POWER_SOURCE,
        PIN_CONFIG_SLEW_RATE,
-       PIN_CONFIG_END = 0x7FFF,
+       PIN_CONFIG_END = 0x7F,
+       PIN_CONFIG_MAX = 0xFF,
 };
 
 #ifdef CONFIG_DEBUG_FS
@@ -130,27 +133,27 @@ struct pin_config_item {
 /*
  * Helpful configuration macro to be used in tables etc.
  */
-#define PIN_CONF_PACKED(p, a) ((a << 16) | ((unsigned long) p & 0xffffUL))
+#define PIN_CONF_PACKED(p, a) ((a << 8) | ((unsigned long) p & 0xffUL))
 
 /*
  * The following inlines stuffs a configuration parameter and data value
  * into and out of an unsigned long argument, as used by the generic pin config
- * system. We put the parameter in the lower 16 bits and the argument in the
- * upper 16 bits.
+ * system. We put the parameter in the lower 8 bits and the argument in the
+ * upper 24 bits.
  */
 
 static inline enum pin_config_param pinconf_to_config_param(unsigned long config)
 {
-       return (enum pin_config_param) (config & 0xffffUL);
+       return (enum pin_config_param) (config & 0xffUL);
 }
 
-static inline u16 pinconf_to_config_argument(unsigned long config)
+static inline u32 pinconf_to_config_argument(unsigned long config)
 {
-       return (enum pin_config_param) ((config >> 16) & 0xffffUL);
+       return (u32) ((config >> 8) & 0xffffffUL);
 }
 
 static inline unsigned long pinconf_to_config_packed(enum pin_config_param param,
-                                                    u16 argument)
+                                                    u32 argument)
 {
        return PIN_CONF_PACKED(param, argument);
 }