Commit 409ee136 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'pinctrl-v4.5-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl

Pull Pin control fixes from Linus Walleij:
 "Pin control fixes for the v4.5 series, all are individual driver
  fixes:

   - Fix the PXA2xx driver to export its init function so we do not
     break modular compiles.
   - Hide unused functions in the Nomadik driver.
   - Fix up direction control in the Mediatek driver.
   - Toggle the sunxi GPIO lines to input when you read them on the H3
     GPIO controller, lest you only get garbage.
   - Fix up the number of settings in the MVEBU driver.
   - Fix a serious SMP race condition in the Samsung driver"

* tag 'pinctrl-v4.5-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl:
  pinctrl: samsung: fix SMP race condition
  pinctrl: mvebu: fix num_settings in mpp group assignment
  pinctrl: sunxi: H3 requires irq_read_needs_mux
  pinctrl: mediatek: fix direction control issue
  pinctrl: nomadik: hide unused functions
  pinctrl: pxa: export pxa2xx_pinctrl_init()
parents 9001b8e4 d9ff0eb9
...@@ -347,6 +347,7 @@ static int mtk_pconf_parse_conf(struct pinctrl_dev *pctldev, ...@@ -347,6 +347,7 @@ static int mtk_pconf_parse_conf(struct pinctrl_dev *pctldev,
ret = mtk_pconf_set_pull_select(pctl, pin, true, false, arg); ret = mtk_pconf_set_pull_select(pctl, pin, true, false, arg);
break; break;
case PIN_CONFIG_INPUT_ENABLE: case PIN_CONFIG_INPUT_ENABLE:
mtk_pmx_gpio_set_direction(pctldev, NULL, pin, true);
ret = mtk_pconf_set_ies_smt(pctl, pin, arg, param); ret = mtk_pconf_set_ies_smt(pctl, pin, arg, param);
break; break;
case PIN_CONFIG_OUTPUT: case PIN_CONFIG_OUTPUT:
...@@ -354,6 +355,7 @@ static int mtk_pconf_parse_conf(struct pinctrl_dev *pctldev, ...@@ -354,6 +355,7 @@ static int mtk_pconf_parse_conf(struct pinctrl_dev *pctldev,
ret = mtk_pmx_gpio_set_direction(pctldev, NULL, pin, false); ret = mtk_pmx_gpio_set_direction(pctldev, NULL, pin, false);
break; break;
case PIN_CONFIG_INPUT_SCHMITT_ENABLE: case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
mtk_pmx_gpio_set_direction(pctldev, NULL, pin, true);
ret = mtk_pconf_set_ies_smt(pctl, pin, arg, param); ret = mtk_pconf_set_ies_smt(pctl, pin, arg, param);
break; break;
case PIN_CONFIG_DRIVE_STRENGTH: case PIN_CONFIG_DRIVE_STRENGTH:
......
...@@ -666,16 +666,19 @@ int mvebu_pinctrl_probe(struct platform_device *pdev) ...@@ -666,16 +666,19 @@ int mvebu_pinctrl_probe(struct platform_device *pdev)
struct mvebu_mpp_ctrl_setting *set = &mode->settings[0]; struct mvebu_mpp_ctrl_setting *set = &mode->settings[0];
struct mvebu_pinctrl_group *grp; struct mvebu_pinctrl_group *grp;
unsigned num_settings; unsigned num_settings;
unsigned supp_settings;
for (num_settings = 0; ; set++) { for (num_settings = 0, supp_settings = 0; ; set++) {
if (!set->name) if (!set->name)
break; break;
num_settings++;
/* skip unsupported settings for this variant */ /* skip unsupported settings for this variant */
if (pctl->variant && !(pctl->variant & set->variant)) if (pctl->variant && !(pctl->variant & set->variant))
continue; continue;
num_settings++; supp_settings++;
/* find gpio/gpo/gpi settings */ /* find gpio/gpo/gpi settings */
if (strcmp(set->name, "gpio") == 0) if (strcmp(set->name, "gpio") == 0)
...@@ -688,7 +691,7 @@ int mvebu_pinctrl_probe(struct platform_device *pdev) ...@@ -688,7 +691,7 @@ int mvebu_pinctrl_probe(struct platform_device *pdev)
} }
/* skip modes with no settings for this variant */ /* skip modes with no settings for this variant */
if (!num_settings) if (!supp_settings)
continue; continue;
grp = mvebu_pinctrl_find_group_by_pid(pctl, mode->pid); grp = mvebu_pinctrl_find_group_by_pid(pctl, mode->pid);
......
...@@ -191,6 +191,7 @@ static void abx500_gpio_set(struct gpio_chip *chip, unsigned offset, int val) ...@@ -191,6 +191,7 @@ static void abx500_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
dev_err(pct->dev, "%s write failed (%d)\n", __func__, ret); dev_err(pct->dev, "%s write failed (%d)\n", __func__, ret);
} }
#ifdef CONFIG_DEBUG_FS
static int abx500_get_pull_updown(struct abx500_pinctrl *pct, int offset, static int abx500_get_pull_updown(struct abx500_pinctrl *pct, int offset,
enum abx500_gpio_pull_updown *pull_updown) enum abx500_gpio_pull_updown *pull_updown)
{ {
...@@ -226,6 +227,7 @@ static int abx500_get_pull_updown(struct abx500_pinctrl *pct, int offset, ...@@ -226,6 +227,7 @@ static int abx500_get_pull_updown(struct abx500_pinctrl *pct, int offset,
return ret; return ret;
} }
#endif
static int abx500_set_pull_updown(struct abx500_pinctrl *pct, static int abx500_set_pull_updown(struct abx500_pinctrl *pct,
int offset, enum abx500_gpio_pull_updown val) int offset, enum abx500_gpio_pull_updown val)
...@@ -468,6 +470,7 @@ static int abx500_set_mode(struct pinctrl_dev *pctldev, struct gpio_chip *chip, ...@@ -468,6 +470,7 @@ static int abx500_set_mode(struct pinctrl_dev *pctldev, struct gpio_chip *chip,
return ret; return ret;
} }
#ifdef CONFIG_DEBUG_FS
static int abx500_get_mode(struct pinctrl_dev *pctldev, struct gpio_chip *chip, static int abx500_get_mode(struct pinctrl_dev *pctldev, struct gpio_chip *chip,
unsigned gpio) unsigned gpio)
{ {
...@@ -553,8 +556,6 @@ static int abx500_get_mode(struct pinctrl_dev *pctldev, struct gpio_chip *chip, ...@@ -553,8 +556,6 @@ static int abx500_get_mode(struct pinctrl_dev *pctldev, struct gpio_chip *chip,
return ret; return ret;
} }
#ifdef CONFIG_DEBUG_FS
#include <linux/seq_file.h> #include <linux/seq_file.h>
static void abx500_gpio_dbg_show_one(struct seq_file *s, static void abx500_gpio_dbg_show_one(struct seq_file *s,
......
...@@ -426,6 +426,7 @@ int pxa2xx_pinctrl_init(struct platform_device *pdev, ...@@ -426,6 +426,7 @@ int pxa2xx_pinctrl_init(struct platform_device *pdev,
return 0; return 0;
} }
EXPORT_SYMBOL(pxa2xx_pinctrl_init);
int pxa2xx_pinctrl_exit(struct platform_device *pdev) int pxa2xx_pinctrl_exit(struct platform_device *pdev)
{ {
......
...@@ -514,25 +514,35 @@ static const struct pinconf_ops samsung_pinconf_ops = { ...@@ -514,25 +514,35 @@ static const struct pinconf_ops samsung_pinconf_ops = {
.pin_config_group_set = samsung_pinconf_group_set, .pin_config_group_set = samsung_pinconf_group_set,
}; };
/* gpiolib gpio_set callback function */ /*
static void samsung_gpio_set(struct gpio_chip *gc, unsigned offset, int value) * The samsung_gpio_set_vlaue() should be called with "bank->slock" held
* to avoid race condition.
*/
static void samsung_gpio_set_value(struct gpio_chip *gc,
unsigned offset, int value)
{ {
struct samsung_pin_bank *bank = gpiochip_get_data(gc); struct samsung_pin_bank *bank = gpiochip_get_data(gc);
const struct samsung_pin_bank_type *type = bank->type; const struct samsung_pin_bank_type *type = bank->type;
unsigned long flags;
void __iomem *reg; void __iomem *reg;
u32 data; u32 data;
reg = bank->drvdata->virt_base + bank->pctl_offset; reg = bank->drvdata->virt_base + bank->pctl_offset;
spin_lock_irqsave(&bank->slock, flags);
data = readl(reg + type->reg_offset[PINCFG_TYPE_DAT]); data = readl(reg + type->reg_offset[PINCFG_TYPE_DAT]);
data &= ~(1 << offset); data &= ~(1 << offset);
if (value) if (value)
data |= 1 << offset; data |= 1 << offset;
writel(data, reg + type->reg_offset[PINCFG_TYPE_DAT]); writel(data, reg + type->reg_offset[PINCFG_TYPE_DAT]);
}
/* gpiolib gpio_set callback function */
static void samsung_gpio_set(struct gpio_chip *gc, unsigned offset, int value)
{
struct samsung_pin_bank *bank = gpiochip_get_data(gc);
unsigned long flags;
spin_lock_irqsave(&bank->slock, flags);
samsung_gpio_set_value(gc, offset, value);
spin_unlock_irqrestore(&bank->slock, flags); spin_unlock_irqrestore(&bank->slock, flags);
} }
...@@ -553,6 +563,8 @@ static int samsung_gpio_get(struct gpio_chip *gc, unsigned offset) ...@@ -553,6 +563,8 @@ static int samsung_gpio_get(struct gpio_chip *gc, unsigned offset)
} }
/* /*
* The samsung_gpio_set_direction() should be called with "bank->slock" held
* to avoid race condition.
* The calls to gpio_direction_output() and gpio_direction_input() * The calls to gpio_direction_output() and gpio_direction_input()
* leads to this function call. * leads to this function call.
*/ */
...@@ -564,7 +576,6 @@ static int samsung_gpio_set_direction(struct gpio_chip *gc, ...@@ -564,7 +576,6 @@ static int samsung_gpio_set_direction(struct gpio_chip *gc,
struct samsung_pinctrl_drv_data *drvdata; struct samsung_pinctrl_drv_data *drvdata;
void __iomem *reg; void __iomem *reg;
u32 data, mask, shift; u32 data, mask, shift;
unsigned long flags;
bank = gpiochip_get_data(gc); bank = gpiochip_get_data(gc);
type = bank->type; type = bank->type;
...@@ -581,31 +592,42 @@ static int samsung_gpio_set_direction(struct gpio_chip *gc, ...@@ -581,31 +592,42 @@ static int samsung_gpio_set_direction(struct gpio_chip *gc,
reg += 4; reg += 4;
} }
spin_lock_irqsave(&bank->slock, flags);
data = readl(reg); data = readl(reg);
data &= ~(mask << shift); data &= ~(mask << shift);
if (!input) if (!input)
data |= FUNC_OUTPUT << shift; data |= FUNC_OUTPUT << shift;
writel(data, reg); writel(data, reg);
spin_unlock_irqrestore(&bank->slock, flags);
return 0; return 0;
} }
/* gpiolib gpio_direction_input callback function. */ /* gpiolib gpio_direction_input callback function. */
static int samsung_gpio_direction_input(struct gpio_chip *gc, unsigned offset) static int samsung_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
{ {
return samsung_gpio_set_direction(gc, offset, true); struct samsung_pin_bank *bank = gpiochip_get_data(gc);
unsigned long flags;
int ret;
spin_lock_irqsave(&bank->slock, flags);
ret = samsung_gpio_set_direction(gc, offset, true);
spin_unlock_irqrestore(&bank->slock, flags);
return ret;
} }
/* gpiolib gpio_direction_output callback function. */ /* gpiolib gpio_direction_output callback function. */
static int samsung_gpio_direction_output(struct gpio_chip *gc, unsigned offset, static int samsung_gpio_direction_output(struct gpio_chip *gc, unsigned offset,
int value) int value)
{ {
samsung_gpio_set(gc, offset, value); struct samsung_pin_bank *bank = gpiochip_get_data(gc);
return samsung_gpio_set_direction(gc, offset, false); unsigned long flags;
int ret;
spin_lock_irqsave(&bank->slock, flags);
samsung_gpio_set_value(gc, offset, value);
ret = samsung_gpio_set_direction(gc, offset, false);
spin_unlock_irqrestore(&bank->slock, flags);
return ret;
} }
/* /*
......
...@@ -492,6 +492,7 @@ static const struct sunxi_pinctrl_desc sun8i_h3_pinctrl_data = { ...@@ -492,6 +492,7 @@ static const struct sunxi_pinctrl_desc sun8i_h3_pinctrl_data = {
.pins = sun8i_h3_pins, .pins = sun8i_h3_pins,
.npins = ARRAY_SIZE(sun8i_h3_pins), .npins = ARRAY_SIZE(sun8i_h3_pins),
.irq_banks = 2, .irq_banks = 2,
.irq_read_needs_mux = true
}; };
static int sun8i_h3_pinctrl_probe(struct platform_device *pdev) static int sun8i_h3_pinctrl_probe(struct platform_device *pdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment