Commit ec65aed9 authored by Jason Cooper's avatar Jason Cooper

Merge commit '06763c74' into orion/dt2

merge pinctrl/devel up to:

06763c74 pinctrl: mvebu: move to its own directory
parents f17073a3 06763c74
...@@ -1193,4 +1193,6 @@ foo_switch() ...@@ -1193,4 +1193,6 @@ foo_switch()
... ...
} }
The above has to be done from process context. The above has to be done from process context. The reservation of the pins
will be done when the state is activated, so in effect one specific pin
can be used by different functions at different times on a running system.
...@@ -188,27 +188,7 @@ config PINCTRL_EXYNOS4 ...@@ -188,27 +188,7 @@ config PINCTRL_EXYNOS4
depends on OF && GPIOLIB depends on OF && GPIOLIB
select PINCTRL_SAMSUNG select PINCTRL_SAMSUNG
config PINCTRL_MVEBU source "drivers/pinctrl/mvebu/Kconfig"
bool
depends on ARCH_MVEBU
select PINMUX
select PINCONF
config PINCTRL_DOVE
bool
select PINCTRL_MVEBU
config PINCTRL_KIRKWOOD
bool
select PINCTRL_MVEBU
config PINCTRL_ARMADA_370
bool
select PINCTRL_MVEBU
config PINCTRL_ARMADA_XP
bool
select PINCTRL_MVEBU
source "drivers/pinctrl/spear/Kconfig" source "drivers/pinctrl/spear/Kconfig"
......
...@@ -36,12 +36,8 @@ obj-$(CONFIG_PINCTRL_U300) += pinctrl-u300.o ...@@ -36,12 +36,8 @@ obj-$(CONFIG_PINCTRL_U300) += pinctrl-u300.o
obj-$(CONFIG_PINCTRL_COH901) += pinctrl-coh901.o obj-$(CONFIG_PINCTRL_COH901) += pinctrl-coh901.o
obj-$(CONFIG_PINCTRL_SAMSUNG) += pinctrl-samsung.o obj-$(CONFIG_PINCTRL_SAMSUNG) += pinctrl-samsung.o
obj-$(CONFIG_PINCTRL_EXYNOS4) += pinctrl-exynos.o obj-$(CONFIG_PINCTRL_EXYNOS4) += pinctrl-exynos.o
obj-$(CONFIG_PINCTRL_MVEBU) += pinctrl-mvebu.o
obj-$(CONFIG_PINCTRL_DOVE) += pinctrl-dove.o
obj-$(CONFIG_PINCTRL_KIRKWOOD) += pinctrl-kirkwood.o
obj-$(CONFIG_PINCTRL_ARMADA_370) += pinctrl-armada-370.o
obj-$(CONFIG_PINCTRL_ARMADA_XP) += pinctrl-armada-xp.o
obj-$(CONFIG_PINCTRL_XWAY) += pinctrl-xway.o obj-$(CONFIG_PINCTRL_XWAY) += pinctrl-xway.o
obj-$(CONFIG_PINCTRL_LANTIQ) += pinctrl-lantiq.o obj-$(CONFIG_PINCTRL_LANTIQ) += pinctrl-lantiq.o
obj-$(CONFIG_PLAT_ORION) += mvebu/
obj-$(CONFIG_PLAT_SPEAR) += spear/ obj-$(CONFIG_PLAT_SPEAR) += spear/
...@@ -563,6 +563,8 @@ static int add_setting(struct pinctrl *p, struct pinctrl_map const *map) ...@@ -563,6 +563,8 @@ static int add_setting(struct pinctrl *p, struct pinctrl_map const *map)
return -EPROBE_DEFER; return -EPROBE_DEFER;
} }
setting->dev_name = map->dev_name;
switch (map->type) { switch (map->type) {
case PIN_MAP_TYPE_MUX_GROUP: case PIN_MAP_TYPE_MUX_GROUP:
ret = pinmux_map_to_setting(map, setting); ret = pinmux_map_to_setting(map, setting);
......
...@@ -105,12 +105,14 @@ struct pinctrl_setting_configs { ...@@ -105,12 +105,14 @@ struct pinctrl_setting_configs {
* @type: the type of setting * @type: the type of setting
* @pctldev: pin control device handling to be programmed. Not used for * @pctldev: pin control device handling to be programmed. Not used for
* PIN_MAP_TYPE_DUMMY_STATE. * PIN_MAP_TYPE_DUMMY_STATE.
* @dev_name: the name of the device using this state
* @data: Data specific to the setting type * @data: Data specific to the setting type
*/ */
struct pinctrl_setting { struct pinctrl_setting {
struct list_head node; struct list_head node;
enum pinctrl_map_type type; enum pinctrl_map_type type;
struct pinctrl_dev *pctldev; struct pinctrl_dev *pctldev;
const char *dev_name;
union { union {
struct pinctrl_setting_mux mux; struct pinctrl_setting_mux mux;
struct pinctrl_setting_configs configs; struct pinctrl_setting_configs configs;
......
if PLAT_ORION
config PINCTRL_MVEBU
bool
select PINMUX
select PINCONF
config PINCTRL_DOVE
bool
select PINCTRL_MVEBU
config PINCTRL_KIRKWOOD
bool
select PINCTRL_MVEBU
config PINCTRL_ARMADA_370
bool
select PINCTRL_MVEBU
config PINCTRL_ARMADA_XP
bool
select PINCTRL_MVEBU
endif
obj-$(CONFIG_PINCTRL_MVEBU) += pinctrl-mvebu.o
obj-$(CONFIG_PINCTRL_DOVE) += pinctrl-dove.o
obj-$(CONFIG_PINCTRL_KIRKWOOD) += pinctrl-kirkwood.o
obj-$(CONFIG_PINCTRL_ARMADA_370) += pinctrl-armada-370.o
obj-$(CONFIG_PINCTRL_ARMADA_XP) += pinctrl-armada-xp.o
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include <linux/pinctrl/pinctrl.h> #include <linux/pinctrl/pinctrl.h>
#include <linux/pinctrl/pinmux.h> #include <linux/pinctrl/pinmux.h>
#include "core.h"
#include "pinctrl-mvebu.h" #include "pinctrl-mvebu.h"
#define MPPS_PER_REG 8 #define MPPS_PER_REG 8
......
...@@ -314,14 +314,11 @@ int pinmux_map_to_setting(struct pinctrl_map const *map, ...@@ -314,14 +314,11 @@ int pinmux_map_to_setting(struct pinctrl_map const *map,
{ {
struct pinctrl_dev *pctldev = setting->pctldev; struct pinctrl_dev *pctldev = setting->pctldev;
const struct pinmux_ops *pmxops = pctldev->desc->pmxops; const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
char const * const *groups; char const * const *groups;
unsigned num_groups; unsigned num_groups;
int ret; int ret;
const char *group; const char *group;
int i; int i;
const unsigned *pins;
unsigned num_pins;
if (!pmxops) { if (!pmxops) {
dev_err(pctldev->dev, "does not support mux function\n"); dev_err(pctldev->dev, "does not support mux function\n");
...@@ -376,53 +373,12 @@ int pinmux_map_to_setting(struct pinctrl_map const *map, ...@@ -376,53 +373,12 @@ int pinmux_map_to_setting(struct pinctrl_map const *map,
} }
setting->data.mux.group = ret; setting->data.mux.group = ret;
ret = pctlops->get_group_pins(pctldev, setting->data.mux.group, &pins,
&num_pins);
if (ret) {
dev_err(pctldev->dev,
"could not get pins for device %s group selector %d\n",
pinctrl_dev_get_name(pctldev), setting->data.mux.group);
return -ENODEV;
}
/* Try to allocate all pins in this group, one by one */
for (i = 0; i < num_pins; i++) {
ret = pin_request(pctldev, pins[i], map->dev_name, NULL);
if (ret) {
dev_err(pctldev->dev,
"could not request pin %d on device %s\n",
pins[i], pinctrl_dev_get_name(pctldev));
/* On error release all taken pins */
i--; /* this pin just failed */
for (; i >= 0; i--)
pin_free(pctldev, pins[i], NULL);
return -ENODEV;
}
}
return 0; return 0;
} }
void pinmux_free_setting(struct pinctrl_setting const *setting) void pinmux_free_setting(struct pinctrl_setting const *setting)
{ {
struct pinctrl_dev *pctldev = setting->pctldev; /* This function is currently unused */
const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
const unsigned *pins;
unsigned num_pins;
int ret;
int i;
ret = pctlops->get_group_pins(pctldev, setting->data.mux.group,
&pins, &num_pins);
if (ret) {
dev_err(pctldev->dev,
"could not get pins for device %s group selector %d\n",
pinctrl_dev_get_name(pctldev), setting->data.mux.group);
return;
}
for (i = 0; i < num_pins; i++)
pin_free(pctldev, pins[i], NULL);
} }
int pinmux_enable_setting(struct pinctrl_setting const *setting) int pinmux_enable_setting(struct pinctrl_setting const *setting)
...@@ -446,6 +402,22 @@ int pinmux_enable_setting(struct pinctrl_setting const *setting) ...@@ -446,6 +402,22 @@ int pinmux_enable_setting(struct pinctrl_setting const *setting)
num_pins = 0; num_pins = 0;
} }
/* Try to allocate all pins in this group, one by one */
for (i = 0; i < num_pins; i++) {
ret = pin_request(pctldev, pins[i], setting->dev_name, NULL);
if (ret) {
dev_err(pctldev->dev,
"could not request pin %d on device %s\n",
pins[i], pinctrl_dev_get_name(pctldev));
/* On error release all taken pins */
i--; /* this pin just failed */
for (; i >= 0; i--)
pin_free(pctldev, pins[i], NULL);
return -ENODEV;
}
}
/* Now that we have acquired the pins, encode the mux setting */
for (i = 0; i < num_pins; i++) { for (i = 0; i < num_pins; i++) {
desc = pin_desc_get(pctldev, pins[i]); desc = pin_desc_get(pctldev, pins[i]);
if (desc == NULL) { if (desc == NULL) {
...@@ -482,6 +454,7 @@ void pinmux_disable_setting(struct pinctrl_setting const *setting) ...@@ -482,6 +454,7 @@ void pinmux_disable_setting(struct pinctrl_setting const *setting)
num_pins = 0; num_pins = 0;
} }
/* Flag the descs that no setting is active */
for (i = 0; i < num_pins; i++) { for (i = 0; i < num_pins; i++) {
desc = pin_desc_get(pctldev, pins[i]); desc = pin_desc_get(pctldev, pins[i]);
if (desc == NULL) { if (desc == NULL) {
...@@ -493,6 +466,10 @@ void pinmux_disable_setting(struct pinctrl_setting const *setting) ...@@ -493,6 +466,10 @@ void pinmux_disable_setting(struct pinctrl_setting const *setting)
desc->mux_setting = NULL; desc->mux_setting = NULL;
} }
/* And release the pins */
for (i = 0; i < num_pins; i++)
pin_free(pctldev, pins[i], NULL);
if (ops->disable) if (ops->disable)
ops->disable(pctldev, setting->data.mux.func, setting->data.mux.group); ops->disable(pctldev, setting->data.mux.func, setting->data.mux.group);
} }
......
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