UPSTREAM: pinctrl: rockchip: Add input schmitt support for rk3328
authordavid.wu <david.wu@rock-chips.com>
Thu, 2 Mar 2017 07:11:24 +0000 (15:11 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 1 Jun 2017 06:23:58 +0000 (14:23 +0800)
Signed-off-by: David Wu <david.wu@rock-chips.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from git.kernel.org thierry.reding/linux-pwm.git for-next
 commit 728d3f5afd991a44b4ec9d019d8556d8cb68db3f)

Signed-off-by: David Wu <david.wu@rock-chips.com>
Change-Id: I15202d4fdd2fc35906d25e04cee63109d872405d

drivers/pinctrl/pinctrl-rockchip.c

index d4722320403c9a5f874503a0d100c04da7831494..227ce364627317c6ac81e342f1467e57373a45b3 100644 (file)
@@ -1636,6 +1636,28 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank,
        return ret;
 }
 
+#define RK3328_SCHMITT_BITS_PER_PIN            1
+#define RK3328_SCHMITT_PINS_PER_REG            16
+#define RK3328_SCHMITT_BANK_STRIDE             8
+#define RK3328_SCHMITT_GRF_OFFSET              0x380
+
+static int rk3328_calc_schmitt_reg_and_bit(struct rockchip_pin_bank *bank,
+                                          int pin_num,
+                                          struct regmap **regmap,
+                                          int *reg, u8 *bit)
+{
+       struct rockchip_pinctrl *info = bank->drvdata;
+
+       *regmap = info->regmap_base;
+       *reg = RK3328_SCHMITT_GRF_OFFSET;
+
+       *reg += bank->bank_num * RK3328_SCHMITT_BANK_STRIDE;
+       *reg += ((pin_num / RK3328_SCHMITT_PINS_PER_REG) * 4);
+       *bit = pin_num % RK3328_SCHMITT_PINS_PER_REG;
+
+       return 0;
+}
+
 static int rockchip_get_schmitt(struct rockchip_pin_bank *bank, int pin_num)
 {
        struct rockchip_pinctrl *info = bank->drvdata;
@@ -3107,6 +3129,7 @@ static struct rockchip_pin_ctrl rk3328_pin_ctrl = {
                .pull_calc_reg          = rk3228_calc_pull_reg_and_bit,
                .drv_calc_reg           = rk3228_calc_drv_reg_and_bit,
                .iomux_recalc           = rk3328_recalc_mux,
+               .schmitt_calc_reg       = rk3328_calc_schmitt_reg_and_bit,
 };
 
 static struct rockchip_pin_bank rk3366_pin_banks[] = {