Merge tag 'driver-core-3.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git...
[firefly-linux-kernel-4.4.55.git] / drivers / pinctrl / spear / pinctrl-spear1340.c
index ed6c25694c89aa5f4bdb1c88cb71150f238bc943..8deaaff3156ca00cd92a5d3fc950d8919a57894a 100644 (file)
@@ -1971,6 +1971,32 @@ static struct spear_function *spear1340_functions[] = {
        &sata_function,
 };
 
+static void gpio_request_endisable(struct spear_pmx *pmx, int pin,
+               bool enable)
+{
+       unsigned int regoffset, regindex, bitoffset;
+       unsigned int val;
+
+       /* pin++ as gpio configuration starts from 2nd bit of base register */
+       pin++;
+
+       regindex = pin / 32;
+       bitoffset = pin % 32;
+
+       if (regindex <= 3)
+               regoffset = PAD_FUNCTION_EN_1 + regindex * sizeof(int *);
+       else
+               regoffset = PAD_FUNCTION_EN_5 + (regindex - 4) * sizeof(int *);
+
+       val = pmx_readl(pmx, regoffset);
+       if (enable)
+               val &= ~(0x1 << bitoffset);
+       else
+               val |= 0x1 << bitoffset;
+
+       pmx_writel(pmx, val, regoffset);
+}
+
 static struct spear_pinctrl_machdata spear1340_machdata = {
        .pins = spear1340_pins,
        .npins = ARRAY_SIZE(spear1340_pins),
@@ -1978,6 +2004,7 @@ static struct spear_pinctrl_machdata spear1340_machdata = {
        .ngroups = ARRAY_SIZE(spear1340_pingroups),
        .functions = spear1340_functions,
        .nfunctions = ARRAY_SIZE(spear1340_functions),
+       .gpio_request_endisable = gpio_request_endisable,
        .modes_supported = false,
 };