2017-12-27 01:09:42 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
//
|
|
|
|
// pin-controller/pin-mux/pin-config/gpio-driver for Samsung's SoC's.
|
|
|
|
//
|
|
|
|
// Copyright (c) 2012 Samsung Electronics Co., Ltd.
|
|
|
|
// http://www.samsung.com
|
|
|
|
// Copyright (c) 2012 Linaro Ltd
|
|
|
|
// http://www.linaro.org
|
|
|
|
//
|
|
|
|
// Author: Thomas Abraham <thomas.ab@samsung.com>
|
|
|
|
//
|
|
|
|
// This driver implements the Samsung pinctrl driver. It supports setting up of
|
|
|
|
// pinmux and pinconf configurations. The gpiolib interface is also included.
|
|
|
|
// External interrupt (gpio and wakeup) support are not included in this driver
|
|
|
|
// but provides extensions to which platform specific implementation of the gpio
|
|
|
|
// and wakeup interrupts can be hooked to.
|
2012-09-07 04:07:19 +07:00
|
|
|
|
2017-05-23 03:56:46 +07:00
|
|
|
#include <linux/init.h>
|
2012-09-07 04:07:19 +07:00
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/gpio.h>
|
2012-10-11 15:11:20 +07:00
|
|
|
#include <linux/irqdomain.h>
|
2017-01-26 16:29:23 +07:00
|
|
|
#include <linux/of_device.h>
|
2013-03-19 04:31:50 +07:00
|
|
|
#include <linux/spinlock.h>
|
2012-09-07 04:07:19 +07:00
|
|
|
|
2017-06-15 22:06:28 +07:00
|
|
|
#include <dt-bindings/pinctrl/samsung.h>
|
|
|
|
|
2014-07-10 19:03:27 +07:00
|
|
|
#include "../core.h"
|
2012-09-07 04:07:19 +07:00
|
|
|
#include "pinctrl-samsung.h"
|
|
|
|
|
2016-11-09 15:40:10 +07:00
|
|
|
/* maximum number of the memory resources */
|
|
|
|
#define SAMSUNG_PINCTRL_NUM_RESOURCES 2
|
|
|
|
|
2012-09-07 04:07:19 +07:00
|
|
|
/* list of all possible config options supported */
|
2012-12-10 07:54:03 +07:00
|
|
|
static struct pin_config {
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
const char *property;
|
|
|
|
enum pincfg_type param;
|
|
|
|
} cfg_params[] = {
|
2012-09-07 04:07:19 +07:00
|
|
|
{ "samsung,pin-pud", PINCFG_TYPE_PUD },
|
|
|
|
{ "samsung,pin-drv", PINCFG_TYPE_DRV },
|
|
|
|
{ "samsung,pin-con-pdn", PINCFG_TYPE_CON_PDN },
|
|
|
|
{ "samsung,pin-pud-pdn", PINCFG_TYPE_PUD_PDN },
|
2014-07-02 22:41:04 +07:00
|
|
|
{ "samsung,pin-val", PINCFG_TYPE_DAT },
|
2012-09-07 04:07:19 +07:00
|
|
|
};
|
|
|
|
|
2012-11-24 09:20:51 +07:00
|
|
|
static unsigned int pin_base;
|
2012-10-11 15:11:09 +07:00
|
|
|
|
2012-09-07 04:07:19 +07:00
|
|
|
static int samsung_get_group_count(struct pinctrl_dev *pctldev)
|
|
|
|
{
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
struct samsung_pinctrl_drv_data *pmx = pinctrl_dev_get_drvdata(pctldev);
|
2012-09-07 04:07:19 +07:00
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
return pmx->nr_groups;
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static const char *samsung_get_group_name(struct pinctrl_dev *pctldev,
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
unsigned group)
|
2012-09-07 04:07:19 +07:00
|
|
|
{
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
struct samsung_pinctrl_drv_data *pmx = pinctrl_dev_get_drvdata(pctldev);
|
2012-09-07 04:07:19 +07:00
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
return pmx->pin_groups[group].name;
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int samsung_get_group_pins(struct pinctrl_dev *pctldev,
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
unsigned group,
|
|
|
|
const unsigned **pins,
|
|
|
|
unsigned *num_pins)
|
2012-09-07 04:07:19 +07:00
|
|
|
{
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
struct samsung_pinctrl_drv_data *pmx = pinctrl_dev_get_drvdata(pctldev);
|
|
|
|
|
|
|
|
*pins = pmx->pin_groups[group].pins;
|
|
|
|
*num_pins = pmx->pin_groups[group].num_pins;
|
2012-09-07 04:07:19 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
static int reserve_map(struct device *dev, struct pinctrl_map **map,
|
|
|
|
unsigned *reserved_maps, unsigned *num_maps,
|
|
|
|
unsigned reserve)
|
|
|
|
{
|
|
|
|
unsigned old_num = *reserved_maps;
|
|
|
|
unsigned new_num = *num_maps + reserve;
|
|
|
|
struct pinctrl_map *new_map;
|
2012-09-07 04:07:19 +07:00
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
if (old_num >= new_num)
|
|
|
|
return 0;
|
2012-09-07 04:07:19 +07:00
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
new_map = krealloc(*map, sizeof(*new_map) * new_num, GFP_KERNEL);
|
2017-01-19 20:48:45 +07:00
|
|
|
if (!new_map)
|
2012-09-07 04:07:19 +07:00
|
|
|
return -ENOMEM;
|
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
memset(new_map + old_num, 0, (new_num - old_num) * sizeof(*new_map));
|
|
|
|
|
|
|
|
*map = new_map;
|
|
|
|
*reserved_maps = new_num;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int add_map_mux(struct pinctrl_map **map, unsigned *reserved_maps,
|
|
|
|
unsigned *num_maps, const char *group,
|
|
|
|
const char *function)
|
|
|
|
{
|
|
|
|
if (WARN_ON(*num_maps == *reserved_maps))
|
|
|
|
return -ENOSPC;
|
|
|
|
|
|
|
|
(*map)[*num_maps].type = PIN_MAP_TYPE_MUX_GROUP;
|
|
|
|
(*map)[*num_maps].data.mux.group = group;
|
|
|
|
(*map)[*num_maps].data.mux.function = function;
|
|
|
|
(*num_maps)++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int add_map_configs(struct device *dev, struct pinctrl_map **map,
|
|
|
|
unsigned *reserved_maps, unsigned *num_maps,
|
|
|
|
const char *group, unsigned long *configs,
|
|
|
|
unsigned num_configs)
|
|
|
|
{
|
|
|
|
unsigned long *dup_configs;
|
|
|
|
|
|
|
|
if (WARN_ON(*num_maps == *reserved_maps))
|
|
|
|
return -ENOSPC;
|
|
|
|
|
|
|
|
dup_configs = kmemdup(configs, num_configs * sizeof(*dup_configs),
|
|
|
|
GFP_KERNEL);
|
2017-01-19 20:48:45 +07:00
|
|
|
if (!dup_configs)
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
return -ENOMEM;
|
2012-09-07 04:07:19 +07:00
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
(*map)[*num_maps].type = PIN_MAP_TYPE_CONFIGS_GROUP;
|
|
|
|
(*map)[*num_maps].data.configs.group_or_pin = group;
|
|
|
|
(*map)[*num_maps].data.configs.configs = dup_configs;
|
|
|
|
(*map)[*num_maps].data.configs.num_configs = num_configs;
|
|
|
|
(*num_maps)++;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int add_config(struct device *dev, unsigned long **configs,
|
|
|
|
unsigned *num_configs, unsigned long config)
|
|
|
|
{
|
|
|
|
unsigned old_num = *num_configs;
|
|
|
|
unsigned new_num = old_num + 1;
|
|
|
|
unsigned long *new_configs;
|
|
|
|
|
|
|
|
new_configs = krealloc(*configs, sizeof(*new_configs) * new_num,
|
|
|
|
GFP_KERNEL);
|
2017-01-19 20:48:45 +07:00
|
|
|
if (!new_configs)
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
return -ENOMEM;
|
2012-09-07 04:07:19 +07:00
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
new_configs[old_num] = config;
|
|
|
|
|
|
|
|
*configs = new_configs;
|
|
|
|
*num_configs = new_num;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void samsung_dt_free_map(struct pinctrl_dev *pctldev,
|
|
|
|
struct pinctrl_map *map,
|
|
|
|
unsigned num_maps)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < num_maps; i++)
|
|
|
|
if (map[i].type == PIN_MAP_TYPE_CONFIGS_GROUP)
|
|
|
|
kfree(map[i].data.configs.configs);
|
|
|
|
|
|
|
|
kfree(map);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int samsung_dt_subnode_to_map(struct samsung_pinctrl_drv_data *drvdata,
|
|
|
|
struct device *dev,
|
|
|
|
struct device_node *np,
|
|
|
|
struct pinctrl_map **map,
|
|
|
|
unsigned *reserved_maps,
|
|
|
|
unsigned *num_maps)
|
|
|
|
{
|
|
|
|
int ret, i;
|
|
|
|
u32 val;
|
|
|
|
unsigned long config;
|
|
|
|
unsigned long *configs = NULL;
|
|
|
|
unsigned num_configs = 0;
|
|
|
|
unsigned reserve;
|
|
|
|
struct property *prop;
|
|
|
|
const char *group;
|
|
|
|
bool has_func = false;
|
|
|
|
|
|
|
|
ret = of_property_read_u32(np, "samsung,pin-function", &val);
|
|
|
|
if (!ret)
|
|
|
|
has_func = true;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(cfg_params); i++) {
|
|
|
|
ret = of_property_read_u32(np, cfg_params[i].property, &val);
|
|
|
|
if (!ret) {
|
|
|
|
config = PINCFG_PACK(cfg_params[i].param, val);
|
|
|
|
ret = add_config(dev, &configs, &num_configs, config);
|
|
|
|
if (ret < 0)
|
|
|
|
goto exit;
|
|
|
|
/* EINVAL=missing, which is fine since it's optional */
|
|
|
|
} else if (ret != -EINVAL) {
|
|
|
|
dev_err(dev, "could not parse property %s\n",
|
|
|
|
cfg_params[i].property);
|
|
|
|
}
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
reserve = 0;
|
|
|
|
if (has_func)
|
|
|
|
reserve++;
|
|
|
|
if (num_configs)
|
|
|
|
reserve++;
|
|
|
|
ret = of_property_count_strings(np, "samsung,pins");
|
|
|
|
if (ret < 0) {
|
|
|
|
dev_err(dev, "could not parse property samsung,pins\n");
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
reserve *= ret;
|
|
|
|
|
|
|
|
ret = reserve_map(dev, map, reserved_maps, num_maps, reserve);
|
|
|
|
if (ret < 0)
|
|
|
|
goto exit;
|
|
|
|
|
|
|
|
of_property_for_each_string(np, "samsung,pins", prop, group) {
|
|
|
|
if (has_func) {
|
|
|
|
ret = add_map_mux(map, reserved_maps,
|
|
|
|
num_maps, group, np->full_name);
|
|
|
|
if (ret < 0)
|
|
|
|
goto exit;
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
if (num_configs) {
|
|
|
|
ret = add_map_configs(dev, map, reserved_maps,
|
|
|
|
num_maps, group, configs,
|
|
|
|
num_configs);
|
|
|
|
if (ret < 0)
|
|
|
|
goto exit;
|
|
|
|
}
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
ret = 0;
|
2012-09-07 04:07:19 +07:00
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
exit:
|
|
|
|
kfree(configs);
|
|
|
|
return ret;
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
static int samsung_dt_node_to_map(struct pinctrl_dev *pctldev,
|
|
|
|
struct device_node *np_config,
|
|
|
|
struct pinctrl_map **map,
|
|
|
|
unsigned *num_maps)
|
|
|
|
{
|
|
|
|
struct samsung_pinctrl_drv_data *drvdata;
|
|
|
|
unsigned reserved_maps;
|
|
|
|
struct device_node *np;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
drvdata = pinctrl_dev_get_drvdata(pctldev);
|
|
|
|
|
|
|
|
reserved_maps = 0;
|
|
|
|
*map = NULL;
|
|
|
|
*num_maps = 0;
|
|
|
|
|
|
|
|
if (!of_get_child_count(np_config))
|
|
|
|
return samsung_dt_subnode_to_map(drvdata, pctldev->dev,
|
|
|
|
np_config, map,
|
|
|
|
&reserved_maps,
|
|
|
|
num_maps);
|
|
|
|
|
|
|
|
for_each_child_of_node(np_config, np) {
|
|
|
|
ret = samsung_dt_subnode_to_map(drvdata, pctldev->dev, np, map,
|
|
|
|
&reserved_maps, num_maps);
|
|
|
|
if (ret < 0) {
|
|
|
|
samsung_dt_free_map(pctldev, *map, *num_maps);
|
|
|
|
return ret;
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
}
|
2012-09-07 04:07:19 +07:00
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
return 0;
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* list of pinctrl callbacks for the pinctrl core */
|
2013-02-16 16:25:07 +07:00
|
|
|
static const struct pinctrl_ops samsung_pctrl_ops = {
|
2012-09-07 04:07:19 +07:00
|
|
|
.get_groups_count = samsung_get_group_count,
|
|
|
|
.get_group_name = samsung_get_group_name,
|
|
|
|
.get_group_pins = samsung_get_group_pins,
|
|
|
|
.dt_node_to_map = samsung_dt_node_to_map,
|
|
|
|
.dt_free_map = samsung_dt_free_map,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* check if the selector is a valid pin function selector */
|
|
|
|
static int samsung_get_functions_count(struct pinctrl_dev *pctldev)
|
|
|
|
{
|
|
|
|
struct samsung_pinctrl_drv_data *drvdata;
|
|
|
|
|
|
|
|
drvdata = pinctrl_dev_get_drvdata(pctldev);
|
|
|
|
return drvdata->nr_functions;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return the name of the pin function specified */
|
|
|
|
static const char *samsung_pinmux_get_fname(struct pinctrl_dev *pctldev,
|
|
|
|
unsigned selector)
|
|
|
|
{
|
|
|
|
struct samsung_pinctrl_drv_data *drvdata;
|
|
|
|
|
|
|
|
drvdata = pinctrl_dev_get_drvdata(pctldev);
|
|
|
|
return drvdata->pmx_functions[selector].name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return the groups associated for the specified function selector */
|
|
|
|
static int samsung_pinmux_get_groups(struct pinctrl_dev *pctldev,
|
|
|
|
unsigned selector, const char * const **groups,
|
|
|
|
unsigned * const num_groups)
|
|
|
|
{
|
|
|
|
struct samsung_pinctrl_drv_data *drvdata;
|
|
|
|
|
|
|
|
drvdata = pinctrl_dev_get_drvdata(pctldev);
|
|
|
|
*groups = drvdata->pmx_functions[selector].groups;
|
|
|
|
*num_groups = drvdata->pmx_functions[selector].num_groups;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* given a pin number that is local to a pin controller, find out the pin bank
|
|
|
|
* and the register base of the pin bank.
|
|
|
|
*/
|
2012-10-11 15:11:08 +07:00
|
|
|
static void pin_to_reg_bank(struct samsung_pinctrl_drv_data *drvdata,
|
|
|
|
unsigned pin, void __iomem **reg, u32 *offset,
|
2012-09-07 04:07:19 +07:00
|
|
|
struct samsung_pin_bank **bank)
|
|
|
|
{
|
|
|
|
struct samsung_pin_bank *b;
|
|
|
|
|
2014-09-24 02:05:40 +07:00
|
|
|
b = drvdata->pin_banks;
|
2012-09-07 04:07:19 +07:00
|
|
|
|
|
|
|
while ((pin >= b->pin_base) &&
|
|
|
|
((b->pin_base + b->nr_pins - 1) < pin))
|
|
|
|
b++;
|
|
|
|
|
2016-11-09 15:40:10 +07:00
|
|
|
*reg = b->pctl_base + b->pctl_offset;
|
2012-09-07 04:07:19 +07:00
|
|
|
*offset = pin - b->pin_base;
|
|
|
|
if (bank)
|
|
|
|
*bank = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* enable or disable a pinmux function */
|
|
|
|
static void samsung_pinmux_setup(struct pinctrl_dev *pctldev, unsigned selector,
|
2017-01-26 16:29:22 +07:00
|
|
|
unsigned group)
|
2012-09-07 04:07:19 +07:00
|
|
|
{
|
|
|
|
struct samsung_pinctrl_drv_data *drvdata;
|
2014-09-24 02:05:39 +07:00
|
|
|
const struct samsung_pin_bank_type *type;
|
2012-09-07 04:07:19 +07:00
|
|
|
struct samsung_pin_bank *bank;
|
|
|
|
void __iomem *reg;
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
u32 mask, shift, data, pin_offset;
|
2013-03-19 04:31:50 +07:00
|
|
|
unsigned long flags;
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
const struct samsung_pmx_func *func;
|
|
|
|
const struct samsung_pin_group *grp;
|
2012-09-07 04:07:19 +07:00
|
|
|
|
|
|
|
drvdata = pinctrl_dev_get_drvdata(pctldev);
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
func = &drvdata->pmx_functions[selector];
|
|
|
|
grp = &drvdata->pin_groups[group];
|
2012-09-07 04:07:19 +07:00
|
|
|
|
2014-09-24 02:05:40 +07:00
|
|
|
pin_to_reg_bank(drvdata, grp->pins[0] - drvdata->pin_base,
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
®, &pin_offset, &bank);
|
|
|
|
type = bank->type;
|
|
|
|
mask = (1 << type->fld_width[PINCFG_TYPE_FUNC]) - 1;
|
|
|
|
shift = pin_offset * type->fld_width[PINCFG_TYPE_FUNC];
|
|
|
|
if (shift >= 32) {
|
|
|
|
/* Some banks have two config registers */
|
|
|
|
shift -= 32;
|
|
|
|
reg += 4;
|
|
|
|
}
|
2012-09-07 04:07:19 +07:00
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
spin_lock_irqsave(&bank->slock, flags);
|
2013-03-19 04:31:50 +07:00
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
data = readl(reg + type->reg_offset[PINCFG_TYPE_FUNC]);
|
|
|
|
data &= ~(mask << shift);
|
2017-01-26 16:29:22 +07:00
|
|
|
data |= func->val << shift;
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
writel(data, reg + type->reg_offset[PINCFG_TYPE_FUNC]);
|
2013-03-19 04:31:50 +07:00
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
spin_unlock_irqrestore(&bank->slock, flags);
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* enable a specified pinmux by writing to registers */
|
2014-09-03 18:02:56 +07:00
|
|
|
static int samsung_pinmux_set_mux(struct pinctrl_dev *pctldev,
|
|
|
|
unsigned selector,
|
|
|
|
unsigned group)
|
2012-09-07 04:07:19 +07:00
|
|
|
{
|
2017-01-26 16:29:22 +07:00
|
|
|
samsung_pinmux_setup(pctldev, selector, group);
|
2012-09-07 04:07:19 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* list of pinmux callbacks for the pinmux vertical in pinctrl core */
|
2013-02-16 16:25:07 +07:00
|
|
|
static const struct pinmux_ops samsung_pinmux_ops = {
|
2012-09-07 04:07:19 +07:00
|
|
|
.get_functions_count = samsung_get_functions_count,
|
|
|
|
.get_function_name = samsung_pinmux_get_fname,
|
|
|
|
.get_function_groups = samsung_pinmux_get_groups,
|
2014-09-03 18:02:56 +07:00
|
|
|
.set_mux = samsung_pinmux_set_mux,
|
2012-09-07 04:07:19 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
/* set or get the pin config settings for a specified pin */
|
|
|
|
static int samsung_pinconf_rw(struct pinctrl_dev *pctldev, unsigned int pin,
|
|
|
|
unsigned long *config, bool set)
|
|
|
|
{
|
|
|
|
struct samsung_pinctrl_drv_data *drvdata;
|
2014-09-24 02:05:39 +07:00
|
|
|
const struct samsung_pin_bank_type *type;
|
2012-09-07 04:07:19 +07:00
|
|
|
struct samsung_pin_bank *bank;
|
|
|
|
void __iomem *reg_base;
|
|
|
|
enum pincfg_type cfg_type = PINCFG_UNPACK_TYPE(*config);
|
|
|
|
u32 data, width, pin_offset, mask, shift;
|
|
|
|
u32 cfg_value, cfg_reg;
|
2013-03-19 04:31:50 +07:00
|
|
|
unsigned long flags;
|
2012-09-07 04:07:19 +07:00
|
|
|
|
|
|
|
drvdata = pinctrl_dev_get_drvdata(pctldev);
|
2014-09-24 02:05:40 +07:00
|
|
|
pin_to_reg_bank(drvdata, pin - drvdata->pin_base, ®_base,
|
2012-09-07 04:07:19 +07:00
|
|
|
&pin_offset, &bank);
|
2013-03-19 04:31:52 +07:00
|
|
|
type = bank->type;
|
2012-09-07 04:07:19 +07:00
|
|
|
|
2013-03-19 04:31:52 +07:00
|
|
|
if (cfg_type >= PINCFG_TYPE_NUM || !type->fld_width[cfg_type])
|
2012-10-11 15:11:07 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2013-03-19 04:31:52 +07:00
|
|
|
width = type->fld_width[cfg_type];
|
2013-03-19 04:31:53 +07:00
|
|
|
cfg_reg = type->reg_offset[cfg_type];
|
2013-03-19 04:31:52 +07:00
|
|
|
|
2013-03-19 04:31:50 +07:00
|
|
|
spin_lock_irqsave(&bank->slock, flags);
|
|
|
|
|
2012-09-07 04:07:19 +07:00
|
|
|
mask = (1 << width) - 1;
|
|
|
|
shift = pin_offset * width;
|
|
|
|
data = readl(reg_base + cfg_reg);
|
|
|
|
|
|
|
|
if (set) {
|
|
|
|
cfg_value = PINCFG_UNPACK_VALUE(*config);
|
|
|
|
data &= ~(mask << shift);
|
|
|
|
data |= (cfg_value << shift);
|
|
|
|
writel(data, reg_base + cfg_reg);
|
|
|
|
} else {
|
|
|
|
data >>= shift;
|
|
|
|
data &= mask;
|
|
|
|
*config = PINCFG_PACK(cfg_type, data);
|
|
|
|
}
|
2013-03-19 04:31:50 +07:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&bank->slock, flags);
|
|
|
|
|
2012-09-07 04:07:19 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the pin config settings for a specified pin */
|
|
|
|
static int samsung_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
|
2013-08-28 01:32:12 +07:00
|
|
|
unsigned long *configs, unsigned num_configs)
|
2012-09-07 04:07:19 +07:00
|
|
|
{
|
2013-08-28 01:32:12 +07:00
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
for (i = 0; i < num_configs; i++) {
|
|
|
|
ret = samsung_pinconf_rw(pctldev, pin, &configs[i], true);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
} /* for each config */
|
|
|
|
|
|
|
|
return 0;
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get the pin config settings for a specified pin */
|
|
|
|
static int samsung_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
|
|
|
|
unsigned long *config)
|
|
|
|
{
|
|
|
|
return samsung_pinconf_rw(pctldev, pin, config, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the pin config settings for a specified pin group */
|
|
|
|
static int samsung_pinconf_group_set(struct pinctrl_dev *pctldev,
|
2013-08-28 01:32:12 +07:00
|
|
|
unsigned group, unsigned long *configs,
|
|
|
|
unsigned num_configs)
|
2012-09-07 04:07:19 +07:00
|
|
|
{
|
|
|
|
struct samsung_pinctrl_drv_data *drvdata;
|
|
|
|
const unsigned int *pins;
|
|
|
|
unsigned int cnt;
|
|
|
|
|
|
|
|
drvdata = pinctrl_dev_get_drvdata(pctldev);
|
|
|
|
pins = drvdata->pin_groups[group].pins;
|
|
|
|
|
|
|
|
for (cnt = 0; cnt < drvdata->pin_groups[group].num_pins; cnt++)
|
2013-08-28 01:32:12 +07:00
|
|
|
samsung_pinconf_set(pctldev, pins[cnt], configs, num_configs);
|
2012-09-07 04:07:19 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get the pin config settings for a specified pin group */
|
|
|
|
static int samsung_pinconf_group_get(struct pinctrl_dev *pctldev,
|
|
|
|
unsigned int group, unsigned long *config)
|
|
|
|
{
|
|
|
|
struct samsung_pinctrl_drv_data *drvdata;
|
|
|
|
const unsigned int *pins;
|
|
|
|
|
|
|
|
drvdata = pinctrl_dev_get_drvdata(pctldev);
|
|
|
|
pins = drvdata->pin_groups[group].pins;
|
|
|
|
samsung_pinconf_get(pctldev, pins[0], config);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* list of pinconfig callbacks for pinconfig vertical in the pinctrl code */
|
2013-02-16 16:25:07 +07:00
|
|
|
static const struct pinconf_ops samsung_pinconf_ops = {
|
2012-09-07 04:07:19 +07:00
|
|
|
.pin_config_get = samsung_pinconf_get,
|
|
|
|
.pin_config_set = samsung_pinconf_set,
|
|
|
|
.pin_config_group_get = samsung_pinconf_group_get,
|
|
|
|
.pin_config_group_set = samsung_pinconf_group_set,
|
|
|
|
};
|
|
|
|
|
2016-02-08 22:49:28 +07:00
|
|
|
/*
|
|
|
|
* 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)
|
2012-09-07 04:07:19 +07:00
|
|
|
{
|
2015-12-08 16:18:50 +07:00
|
|
|
struct samsung_pin_bank *bank = gpiochip_get_data(gc);
|
2014-09-24 02:05:39 +07:00
|
|
|
const struct samsung_pin_bank_type *type = bank->type;
|
2012-09-07 04:07:19 +07:00
|
|
|
void __iomem *reg;
|
2012-10-11 15:11:17 +07:00
|
|
|
u32 data;
|
2012-09-07 04:07:19 +07:00
|
|
|
|
2016-11-09 15:40:10 +07:00
|
|
|
reg = bank->pctl_base + bank->pctl_offset;
|
2012-09-07 04:07:19 +07:00
|
|
|
|
2013-03-19 04:31:53 +07:00
|
|
|
data = readl(reg + type->reg_offset[PINCFG_TYPE_DAT]);
|
2012-10-11 15:11:17 +07:00
|
|
|
data &= ~(1 << offset);
|
2012-09-07 04:07:19 +07:00
|
|
|
if (value)
|
2012-10-11 15:11:17 +07:00
|
|
|
data |= 1 << offset;
|
2013-03-19 04:31:53 +07:00
|
|
|
writel(data, reg + type->reg_offset[PINCFG_TYPE_DAT]);
|
2016-02-08 22:49:28 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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;
|
2013-03-19 04:31:50 +07:00
|
|
|
|
2016-02-08 22:49:28 +07:00
|
|
|
spin_lock_irqsave(&bank->slock, flags);
|
|
|
|
samsung_gpio_set_value(gc, offset, value);
|
2013-03-19 04:31:50 +07:00
|
|
|
spin_unlock_irqrestore(&bank->slock, flags);
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* gpiolib gpio_get callback function */
|
|
|
|
static int samsung_gpio_get(struct gpio_chip *gc, unsigned offset)
|
|
|
|
{
|
|
|
|
void __iomem *reg;
|
2012-10-11 15:11:17 +07:00
|
|
|
u32 data;
|
2015-12-08 16:18:50 +07:00
|
|
|
struct samsung_pin_bank *bank = gpiochip_get_data(gc);
|
2014-09-24 02:05:39 +07:00
|
|
|
const struct samsung_pin_bank_type *type = bank->type;
|
2012-10-11 15:11:08 +07:00
|
|
|
|
2016-11-09 15:40:10 +07:00
|
|
|
reg = bank->pctl_base + bank->pctl_offset;
|
2012-09-07 04:07:19 +07:00
|
|
|
|
2013-03-19 04:31:53 +07:00
|
|
|
data = readl(reg + type->reg_offset[PINCFG_TYPE_DAT]);
|
2012-10-11 15:11:17 +07:00
|
|
|
data >>= offset;
|
2012-09-07 04:07:19 +07:00
|
|
|
data &= 1;
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2016-02-08 22:49:28 +07:00
|
|
|
* The samsung_gpio_set_direction() should be called with "bank->slock" held
|
|
|
|
* to avoid race condition.
|
2014-07-02 22:40:59 +07:00
|
|
|
* The calls to gpio_direction_output() and gpio_direction_input()
|
|
|
|
* leads to this function call.
|
2012-09-07 04:07:19 +07:00
|
|
|
*/
|
2014-07-02 22:40:59 +07:00
|
|
|
static int samsung_gpio_set_direction(struct gpio_chip *gc,
|
|
|
|
unsigned offset, bool input)
|
|
|
|
{
|
2014-09-24 02:05:39 +07:00
|
|
|
const struct samsung_pin_bank_type *type;
|
2014-07-02 22:40:59 +07:00
|
|
|
struct samsung_pin_bank *bank;
|
|
|
|
void __iomem *reg;
|
|
|
|
u32 data, mask, shift;
|
|
|
|
|
2015-12-08 16:18:50 +07:00
|
|
|
bank = gpiochip_get_data(gc);
|
2014-07-02 22:40:59 +07:00
|
|
|
type = bank->type;
|
|
|
|
|
2016-11-09 15:40:10 +07:00
|
|
|
reg = bank->pctl_base + bank->pctl_offset
|
|
|
|
+ type->reg_offset[PINCFG_TYPE_FUNC];
|
2014-07-02 22:40:59 +07:00
|
|
|
|
|
|
|
mask = (1 << type->fld_width[PINCFG_TYPE_FUNC]) - 1;
|
|
|
|
shift = offset * type->fld_width[PINCFG_TYPE_FUNC];
|
|
|
|
if (shift >= 32) {
|
|
|
|
/* Some banks have two config registers */
|
|
|
|
shift -= 32;
|
|
|
|
reg += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
data = readl(reg);
|
|
|
|
data &= ~(mask << shift);
|
|
|
|
if (!input)
|
2017-06-15 22:06:28 +07:00
|
|
|
data |= EXYNOS_PIN_FUNC_OUTPUT << shift;
|
2014-07-02 22:40:59 +07:00
|
|
|
writel(data, reg);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* gpiolib gpio_direction_input callback function. */
|
2012-09-07 04:07:19 +07:00
|
|
|
static int samsung_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
|
|
|
|
{
|
2016-02-08 22:49:28 +07:00
|
|
|
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;
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
|
|
|
|
2014-07-02 22:40:59 +07:00
|
|
|
/* gpiolib gpio_direction_output callback function. */
|
2012-09-07 04:07:19 +07:00
|
|
|
static int samsung_gpio_direction_output(struct gpio_chip *gc, unsigned offset,
|
|
|
|
int value)
|
|
|
|
{
|
2016-02-08 22:49:28 +07:00
|
|
|
struct samsung_pin_bank *bank = gpiochip_get_data(gc);
|
|
|
|
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;
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
|
|
|
|
2012-10-11 15:11:20 +07:00
|
|
|
/*
|
|
|
|
* gpiolib gpio_to_irq callback function. Creates a mapping between a GPIO pin
|
|
|
|
* and a virtual IRQ, if not already present.
|
|
|
|
*/
|
|
|
|
static int samsung_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
|
|
|
|
{
|
2015-12-08 16:18:50 +07:00
|
|
|
struct samsung_pin_bank *bank = gpiochip_get_data(gc);
|
2012-10-11 15:11:20 +07:00
|
|
|
unsigned int virq;
|
|
|
|
|
|
|
|
if (!bank->irq_domain)
|
|
|
|
return -ENXIO;
|
|
|
|
|
|
|
|
virq = irq_create_mapping(bank->irq_domain, offset);
|
|
|
|
|
|
|
|
return (virq) ? : -ENXIO;
|
|
|
|
}
|
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
static struct samsung_pin_group *samsung_pinctrl_create_groups(
|
|
|
|
struct device *dev,
|
|
|
|
struct samsung_pinctrl_drv_data *drvdata,
|
|
|
|
unsigned int *cnt)
|
2012-09-07 04:07:19 +07:00
|
|
|
{
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
struct pinctrl_desc *ctrldesc = &drvdata->pctl;
|
|
|
|
struct samsung_pin_group *groups, *grp;
|
|
|
|
const struct pinctrl_pin_desc *pdesc;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
groups = devm_kzalloc(dev, ctrldesc->npins * sizeof(*groups),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!groups)
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
grp = groups;
|
|
|
|
|
|
|
|
pdesc = ctrldesc->pins;
|
|
|
|
for (i = 0; i < ctrldesc->npins; ++i, ++pdesc, ++grp) {
|
|
|
|
grp->name = pdesc->name;
|
|
|
|
grp->pins = &pdesc->number;
|
|
|
|
grp->num_pins = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
*cnt = ctrldesc->npins;
|
|
|
|
return groups;
|
|
|
|
}
|
2012-09-07 04:07:19 +07:00
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
static int samsung_pinctrl_create_function(struct device *dev,
|
|
|
|
struct samsung_pinctrl_drv_data *drvdata,
|
|
|
|
struct device_node *func_np,
|
|
|
|
struct samsung_pmx_func *func)
|
|
|
|
{
|
|
|
|
int npins;
|
|
|
|
int ret;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (of_property_read_u32(func_np, "samsung,pin-function", &func->val))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
npins = of_property_count_strings(func_np, "samsung,pins");
|
|
|
|
if (npins < 1) {
|
2017-07-19 04:43:23 +07:00
|
|
|
dev_err(dev, "invalid pin list in %pOFn node", func_np);
|
2012-09-07 04:07:19 +07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
func->name = func_np->full_name;
|
|
|
|
|
|
|
|
func->groups = devm_kzalloc(dev, npins * sizeof(char *), GFP_KERNEL);
|
|
|
|
if (!func->groups)
|
2012-09-07 04:07:19 +07:00
|
|
|
return -ENOMEM;
|
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
for (i = 0; i < npins; ++i) {
|
|
|
|
const char *gname;
|
|
|
|
|
|
|
|
ret = of_property_read_string_index(func_np, "samsung,pins",
|
|
|
|
i, &gname);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(dev,
|
2017-07-19 04:43:23 +07:00
|
|
|
"failed to read pin name %d from %pOFn node\n",
|
|
|
|
i, func_np);
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
return ret;
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
|
|
|
|
func->groups[i] = gname;
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
func->num_groups = npins;
|
|
|
|
return 1;
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
static struct samsung_pmx_func *samsung_pinctrl_create_functions(
|
|
|
|
struct device *dev,
|
|
|
|
struct samsung_pinctrl_drv_data *drvdata,
|
|
|
|
unsigned int *cnt)
|
2012-09-07 04:07:19 +07:00
|
|
|
{
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
struct samsung_pmx_func *functions, *func;
|
2012-09-07 04:07:19 +07:00
|
|
|
struct device_node *dev_np = dev->of_node;
|
|
|
|
struct device_node *cfg_np;
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
unsigned int func_cnt = 0;
|
2012-09-07 04:07:19 +07:00
|
|
|
int ret;
|
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
/*
|
|
|
|
* Iterate over all the child nodes of the pin controller node
|
|
|
|
* and create pin groups and pin function lists.
|
|
|
|
*/
|
|
|
|
for_each_child_of_node(dev_np, cfg_np) {
|
|
|
|
struct device_node *func_np;
|
2012-09-07 04:07:19 +07:00
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
if (!of_get_child_count(cfg_np)) {
|
|
|
|
if (!of_find_property(cfg_np,
|
|
|
|
"samsung,pin-function", NULL))
|
|
|
|
continue;
|
|
|
|
++func_cnt;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
for_each_child_of_node(cfg_np, func_np) {
|
|
|
|
if (!of_find_property(func_np,
|
|
|
|
"samsung,pin-function", NULL))
|
|
|
|
continue;
|
|
|
|
++func_cnt;
|
|
|
|
}
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
functions = devm_kzalloc(dev, func_cnt * sizeof(*functions),
|
|
|
|
GFP_KERNEL);
|
2017-01-19 20:48:45 +07:00
|
|
|
if (!functions)
|
2017-01-19 20:48:46 +07:00
|
|
|
return ERR_PTR(-ENOMEM);
|
2012-09-07 04:07:19 +07:00
|
|
|
func = functions;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Iterate over all the child nodes of the pin controller node
|
|
|
|
* and create pin groups and pin function lists.
|
|
|
|
*/
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
func_cnt = 0;
|
2012-09-07 04:07:19 +07:00
|
|
|
for_each_child_of_node(dev_np, cfg_np) {
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
struct device_node *func_np;
|
|
|
|
|
|
|
|
if (!of_get_child_count(cfg_np)) {
|
|
|
|
ret = samsung_pinctrl_create_function(dev, drvdata,
|
|
|
|
cfg_np, func);
|
|
|
|
if (ret < 0)
|
|
|
|
return ERR_PTR(ret);
|
|
|
|
if (ret > 0) {
|
|
|
|
++func;
|
|
|
|
++func_cnt;
|
|
|
|
}
|
2012-09-07 04:07:19 +07:00
|
|
|
continue;
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
}
|
2012-09-07 04:07:19 +07:00
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
for_each_child_of_node(cfg_np, func_np) {
|
|
|
|
ret = samsung_pinctrl_create_function(dev, drvdata,
|
|
|
|
func_np, func);
|
|
|
|
if (ret < 0)
|
|
|
|
return ERR_PTR(ret);
|
|
|
|
if (ret > 0) {
|
|
|
|
++func;
|
|
|
|
++func_cnt;
|
|
|
|
}
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
}
|
2012-09-07 04:07:19 +07:00
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
*cnt = func_cnt;
|
|
|
|
return functions;
|
|
|
|
}
|
2012-09-07 04:07:19 +07:00
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
/*
|
|
|
|
* Parse the information about all the available pin groups and pin functions
|
|
|
|
* from device node of the pin-controller. A pin group is formed with all
|
|
|
|
* the pins listed in the "samsung,pins" property.
|
|
|
|
*/
|
2012-09-07 04:07:19 +07:00
|
|
|
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
static int samsung_pinctrl_parse_dt(struct platform_device *pdev,
|
|
|
|
struct samsung_pinctrl_drv_data *drvdata)
|
|
|
|
{
|
|
|
|
struct device *dev = &pdev->dev;
|
|
|
|
struct samsung_pin_group *groups;
|
|
|
|
struct samsung_pmx_func *functions;
|
|
|
|
unsigned int grp_cnt = 0, func_cnt = 0;
|
|
|
|
|
|
|
|
groups = samsung_pinctrl_create_groups(dev, drvdata, &grp_cnt);
|
|
|
|
if (IS_ERR(groups)) {
|
|
|
|
dev_err(dev, "failed to parse pin groups\n");
|
|
|
|
return PTR_ERR(groups);
|
|
|
|
}
|
|
|
|
|
|
|
|
functions = samsung_pinctrl_create_functions(dev, drvdata, &func_cnt);
|
|
|
|
if (IS_ERR(functions)) {
|
|
|
|
dev_err(dev, "failed to parse pin functions\n");
|
2015-06-01 19:57:04 +07:00
|
|
|
return PTR_ERR(functions);
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
drvdata->pin_groups = groups;
|
|
|
|
drvdata->nr_groups = grp_cnt;
|
|
|
|
drvdata->pmx_functions = functions;
|
pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
One of remaining limitations of current pinctrl-samsung driver was
the inability to parse multiple pinmux/pinconf group nodes grouped
inside a single device tree node. It made defining groups of pins for
single purpose, but with different parameters very inconvenient.
This patch implements Tegra-like support for grouping multiple pinctrl
groups inside one device tree node, by completely changing the way
pin groups and functions are parsed from device tree. The code creating
pinctrl maps from DT nodes has been borrowed from pinctrl-tegra, while
the initial creation of groups and functions has been completely
rewritten with following assumptions:
- each group consists of just one pin and does not depend on data
from device tree,
- each function is represented by a device tree child node of the
pin controller, which in turn can contain multiple child nodes
for pins that need to have different configuration values.
Device Tree bindings are fully backwards compatible. New functionality
can be used by defining a new pinctrl group consisting of several child
nodes, as on following example:
sd4_bus8: sd4-bus-width8 {
part-1 {
samsung,pins = "gpk0-3", "gpk0-4",
"gpk0-5", "gpk0-6";
samsung,pin-function = <3>;
samsung,pin-pud = <3>;
samsung,pin-drv = <3>;
};
part-2 {
samsung,pins = "gpk1-3", "gpk1-4",
"gpk1-5", "gpk1-6";
samsung,pin-function = <4>;
samsung,pin-pud = <4>;
samsung,pin-drv = <3>;
};
};
Tested on Exynos4210-Trats board and a custom Exynos4212-based one.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Cc: devicetree@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-02 22:41:03 +07:00
|
|
|
drvdata->nr_functions = func_cnt;
|
2012-09-07 04:07:19 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* register the pinctrl interface with the pinctrl subsystem */
|
2012-12-22 04:10:23 +07:00
|
|
|
static int samsung_pinctrl_register(struct platform_device *pdev,
|
|
|
|
struct samsung_pinctrl_drv_data *drvdata)
|
2012-09-07 04:07:19 +07:00
|
|
|
{
|
|
|
|
struct pinctrl_desc *ctrldesc = &drvdata->pctl;
|
|
|
|
struct pinctrl_pin_desc *pindesc, *pdesc;
|
|
|
|
struct samsung_pin_bank *pin_bank;
|
|
|
|
char *pin_names;
|
|
|
|
int pin, bank, ret;
|
|
|
|
|
|
|
|
ctrldesc->name = "samsung-pinctrl";
|
|
|
|
ctrldesc->owner = THIS_MODULE;
|
|
|
|
ctrldesc->pctlops = &samsung_pctrl_ops;
|
|
|
|
ctrldesc->pmxops = &samsung_pinmux_ops;
|
|
|
|
ctrldesc->confops = &samsung_pinconf_ops;
|
|
|
|
|
|
|
|
pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) *
|
2014-09-24 02:05:40 +07:00
|
|
|
drvdata->nr_pins, GFP_KERNEL);
|
2017-01-19 20:48:45 +07:00
|
|
|
if (!pindesc)
|
2012-09-07 04:07:19 +07:00
|
|
|
return -ENOMEM;
|
|
|
|
ctrldesc->pins = pindesc;
|
2014-09-24 02:05:40 +07:00
|
|
|
ctrldesc->npins = drvdata->nr_pins;
|
2012-09-07 04:07:19 +07:00
|
|
|
|
|
|
|
/* dynamically populate the pin number and pin name for pindesc */
|
|
|
|
for (pin = 0, pdesc = pindesc; pin < ctrldesc->npins; pin++, pdesc++)
|
2014-09-24 02:05:40 +07:00
|
|
|
pdesc->number = pin + drvdata->pin_base;
|
2012-09-07 04:07:19 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* allocate space for storing the dynamically generated names for all
|
|
|
|
* the pins which belong to this pin-controller.
|
|
|
|
*/
|
|
|
|
pin_names = devm_kzalloc(&pdev->dev, sizeof(char) * PIN_NAME_LENGTH *
|
2014-09-24 02:05:40 +07:00
|
|
|
drvdata->nr_pins, GFP_KERNEL);
|
2017-01-19 20:48:45 +07:00
|
|
|
if (!pin_names)
|
2012-09-07 04:07:19 +07:00
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
/* for each pin, the name of the pin is pin-bank name + pin number */
|
2014-09-24 02:05:40 +07:00
|
|
|
for (bank = 0; bank < drvdata->nr_banks; bank++) {
|
|
|
|
pin_bank = &drvdata->pin_banks[bank];
|
2012-09-07 04:07:19 +07:00
|
|
|
for (pin = 0; pin < pin_bank->nr_pins; pin++) {
|
|
|
|
sprintf(pin_names, "%s-%d", pin_bank->name, pin);
|
|
|
|
pdesc = pindesc + pin_bank->pin_base + pin;
|
|
|
|
pdesc->name = pin_names;
|
|
|
|
pin_names += PIN_NAME_LENGTH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-20 23:16:21 +07:00
|
|
|
ret = samsung_pinctrl_parse_dt(pdev, drvdata);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2016-02-28 16:06:42 +07:00
|
|
|
drvdata->pctl_dev = devm_pinctrl_register(&pdev->dev, ctrldesc,
|
|
|
|
drvdata);
|
2015-06-09 11:01:16 +07:00
|
|
|
if (IS_ERR(drvdata->pctl_dev)) {
|
2012-09-07 04:07:19 +07:00
|
|
|
dev_err(&pdev->dev, "could not register pinctrl driver\n");
|
2015-06-09 11:01:16 +07:00
|
|
|
return PTR_ERR(drvdata->pctl_dev);
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
|
|
|
|
2014-09-24 02:05:40 +07:00
|
|
|
for (bank = 0; bank < drvdata->nr_banks; ++bank) {
|
|
|
|
pin_bank = &drvdata->pin_banks[bank];
|
2012-10-11 15:11:17 +07:00
|
|
|
pin_bank->grange.name = pin_bank->name;
|
|
|
|
pin_bank->grange.id = bank;
|
2014-09-24 02:05:40 +07:00
|
|
|
pin_bank->grange.pin_base = drvdata->pin_base
|
2014-07-02 22:41:00 +07:00
|
|
|
+ pin_bank->pin_base;
|
2017-03-23 00:15:34 +07:00
|
|
|
pin_bank->grange.base = pin_bank->grange.pin_base;
|
2012-10-11 15:11:17 +07:00
|
|
|
pin_bank->grange.npins = pin_bank->gpio_chip.ngpio;
|
|
|
|
pin_bank->grange.gc = &pin_bank->gpio_chip;
|
|
|
|
pinctrl_add_gpio_range(drvdata->pctl_dev, &pin_bank->grange);
|
|
|
|
}
|
2012-09-07 04:07:19 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-23 00:15:34 +07:00
|
|
|
/* unregister the pinctrl interface with the pinctrl subsystem */
|
|
|
|
static int samsung_pinctrl_unregister(struct platform_device *pdev,
|
|
|
|
struct samsung_pinctrl_drv_data *drvdata)
|
|
|
|
{
|
|
|
|
struct samsung_pin_bank *bank = drvdata->pin_banks;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < drvdata->nr_banks; ++i, ++bank)
|
|
|
|
pinctrl_remove_gpio_range(drvdata->pctl_dev, &bank->grange);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-11 15:11:17 +07:00
|
|
|
static const struct gpio_chip samsung_gpiolib_chip = {
|
2015-10-11 22:34:19 +07:00
|
|
|
.request = gpiochip_generic_request,
|
|
|
|
.free = gpiochip_generic_free,
|
2012-10-11 15:11:17 +07:00
|
|
|
.set = samsung_gpio_set,
|
|
|
|
.get = samsung_gpio_get,
|
|
|
|
.direction_input = samsung_gpio_direction_input,
|
|
|
|
.direction_output = samsung_gpio_direction_output,
|
2012-10-11 15:11:20 +07:00
|
|
|
.to_irq = samsung_gpio_to_irq,
|
2012-10-11 15:11:17 +07:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
};
|
|
|
|
|
2012-09-07 04:07:19 +07:00
|
|
|
/* register the gpiolib interface with the gpiolib subsystem */
|
2012-12-22 04:10:23 +07:00
|
|
|
static int samsung_gpiolib_register(struct platform_device *pdev,
|
|
|
|
struct samsung_pinctrl_drv_data *drvdata)
|
2012-09-07 04:07:19 +07:00
|
|
|
{
|
2014-09-24 02:05:40 +07:00
|
|
|
struct samsung_pin_bank *bank = drvdata->pin_banks;
|
2012-09-07 04:07:19 +07:00
|
|
|
struct gpio_chip *gc;
|
|
|
|
int ret;
|
2012-10-11 15:11:17 +07:00
|
|
|
int i;
|
|
|
|
|
2014-09-24 02:05:40 +07:00
|
|
|
for (i = 0; i < drvdata->nr_banks; ++i, ++bank) {
|
2012-10-11 15:11:17 +07:00
|
|
|
bank->gpio_chip = samsung_gpiolib_chip;
|
|
|
|
|
|
|
|
gc = &bank->gpio_chip;
|
2017-03-23 00:15:34 +07:00
|
|
|
gc->base = bank->grange.base;
|
2012-10-11 15:11:17 +07:00
|
|
|
gc->ngpio = bank->nr_pins;
|
2015-11-04 15:56:26 +07:00
|
|
|
gc->parent = &pdev->dev;
|
2012-10-11 15:11:17 +07:00
|
|
|
gc->of_node = bank->of_node;
|
|
|
|
gc->label = bank->name;
|
|
|
|
|
2017-03-23 00:15:35 +07:00
|
|
|
ret = devm_gpiochip_add_data(&pdev->dev, gc, bank);
|
2012-10-11 15:11:17 +07:00
|
|
|
if (ret) {
|
|
|
|
dev_err(&pdev->dev, "failed to register gpio_chip %s, error code: %d\n",
|
|
|
|
gc->label, ret);
|
2017-03-23 00:15:35 +07:00
|
|
|
return ret;
|
2012-10-11 15:11:17 +07:00
|
|
|
}
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* retrieve the soc specific data */
|
2014-09-24 02:05:40 +07:00
|
|
|
static const struct samsung_pin_ctrl *
|
|
|
|
samsung_pinctrl_get_soc_data(struct samsung_pinctrl_drv_data *d,
|
|
|
|
struct platform_device *pdev)
|
2012-09-07 04:07:19 +07:00
|
|
|
{
|
|
|
|
int id;
|
2012-10-11 15:11:14 +07:00
|
|
|
struct device_node *node = pdev->dev.of_node;
|
2012-10-11 15:11:13 +07:00
|
|
|
struct device_node *np;
|
2014-09-24 02:05:41 +07:00
|
|
|
const struct samsung_pin_bank_data *bdata;
|
2014-09-24 02:05:40 +07:00
|
|
|
const struct samsung_pin_ctrl *ctrl;
|
2012-10-11 15:11:09 +07:00
|
|
|
struct samsung_pin_bank *bank;
|
2016-11-09 15:40:10 +07:00
|
|
|
struct resource *res;
|
|
|
|
void __iomem *virt_base[SAMSUNG_PINCTRL_NUM_RESOURCES];
|
2017-06-15 23:33:15 +07:00
|
|
|
unsigned int i;
|
2012-09-07 04:07:19 +07:00
|
|
|
|
2012-10-11 15:11:14 +07:00
|
|
|
id = of_alias_get_id(node, "pinctrl");
|
2012-09-07 04:07:19 +07:00
|
|
|
if (id < 0) {
|
|
|
|
dev_err(&pdev->dev, "failed to get alias id\n");
|
2014-09-24 02:05:37 +07:00
|
|
|
return ERR_PTR(-ENOENT);
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
2017-01-26 16:29:23 +07:00
|
|
|
ctrl = of_device_get_match_data(&pdev->dev);
|
|
|
|
ctrl += id;
|
2012-10-11 15:11:09 +07:00
|
|
|
|
2014-09-24 02:05:40 +07:00
|
|
|
d->suspend = ctrl->suspend;
|
|
|
|
d->resume = ctrl->resume;
|
|
|
|
d->nr_banks = ctrl->nr_banks;
|
2014-09-24 02:05:41 +07:00
|
|
|
d->pin_banks = devm_kcalloc(&pdev->dev, d->nr_banks,
|
|
|
|
sizeof(*d->pin_banks), GFP_KERNEL);
|
|
|
|
if (!d->pin_banks)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
2014-09-24 02:05:40 +07:00
|
|
|
|
2016-11-09 15:40:10 +07:00
|
|
|
if (ctrl->nr_ext_resources + 1 > SAMSUNG_PINCTRL_NUM_RESOURCES)
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
|
|
|
|
for (i = 0; i < ctrl->nr_ext_resources + 1; i++) {
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, i);
|
2017-02-23 17:12:40 +07:00
|
|
|
if (!res) {
|
|
|
|
dev_err(&pdev->dev, "failed to get mem%d resource\n", i);
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
}
|
|
|
|
virt_base[i] = devm_ioremap(&pdev->dev, res->start,
|
|
|
|
resource_size(res));
|
|
|
|
if (!virt_base[i]) {
|
|
|
|
dev_err(&pdev->dev, "failed to ioremap %pR\n", res);
|
|
|
|
return ERR_PTR(-EIO);
|
|
|
|
}
|
2016-11-09 15:40:10 +07:00
|
|
|
}
|
|
|
|
|
2014-09-24 02:05:40 +07:00
|
|
|
bank = d->pin_banks;
|
2014-09-24 02:05:41 +07:00
|
|
|
bdata = ctrl->pin_banks;
|
|
|
|
for (i = 0; i < ctrl->nr_banks; ++i, ++bdata, ++bank) {
|
|
|
|
bank->type = bdata->type;
|
|
|
|
bank->pctl_offset = bdata->pctl_offset;
|
|
|
|
bank->nr_pins = bdata->nr_pins;
|
|
|
|
bank->eint_func = bdata->eint_func;
|
|
|
|
bank->eint_type = bdata->eint_type;
|
|
|
|
bank->eint_mask = bdata->eint_mask;
|
|
|
|
bank->eint_offset = bdata->eint_offset;
|
|
|
|
bank->name = bdata->name;
|
|
|
|
|
2013-03-19 04:31:50 +07:00
|
|
|
spin_lock_init(&bank->slock);
|
2012-10-11 15:11:14 +07:00
|
|
|
bank->drvdata = d;
|
2014-09-24 02:05:40 +07:00
|
|
|
bank->pin_base = d->nr_pins;
|
|
|
|
d->nr_pins += bank->nr_pins;
|
2016-11-09 15:40:10 +07:00
|
|
|
|
|
|
|
bank->eint_base = virt_base[0];
|
|
|
|
bank->pctl_base = virt_base[bdata->pctl_res_idx];
|
2012-10-11 15:11:09 +07:00
|
|
|
}
|
2017-06-15 22:46:37 +07:00
|
|
|
/*
|
|
|
|
* Legacy platforms should provide only one resource with IO memory.
|
|
|
|
* Store it as virt_base because legacy driver needs to access it
|
|
|
|
* through samsung_pinctrl_drv_data.
|
|
|
|
*/
|
|
|
|
d->virt_base = virt_base[0];
|
2012-10-11 15:11:09 +07:00
|
|
|
|
2012-10-11 15:11:13 +07:00
|
|
|
for_each_child_of_node(node, np) {
|
|
|
|
if (!of_find_property(np, "gpio-controller", NULL))
|
|
|
|
continue;
|
2014-09-24 02:05:40 +07:00
|
|
|
bank = d->pin_banks;
|
|
|
|
for (i = 0; i < d->nr_banks; ++i, ++bank) {
|
2012-10-11 15:11:13 +07:00
|
|
|
if (!strcmp(bank->name, np->name)) {
|
|
|
|
bank->of_node = np;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-24 02:05:40 +07:00
|
|
|
d->pin_base = pin_base;
|
|
|
|
pin_base += d->nr_pins;
|
2012-10-11 15:11:09 +07:00
|
|
|
|
|
|
|
return ctrl;
|
2012-09-07 04:07:19 +07:00
|
|
|
}
|
|
|
|
|
2012-12-22 04:10:23 +07:00
|
|
|
static int samsung_pinctrl_probe(struct platform_device *pdev)
|
2012-09-07 04:07:19 +07:00
|
|
|
{
|
|
|
|
struct samsung_pinctrl_drv_data *drvdata;
|
2014-09-24 02:05:40 +07:00
|
|
|
const struct samsung_pin_ctrl *ctrl;
|
2012-09-07 04:07:19 +07:00
|
|
|
struct device *dev = &pdev->dev;
|
|
|
|
struct resource *res;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
|
2016-09-01 18:59:00 +07:00
|
|
|
if (!drvdata)
|
2012-09-07 04:07:19 +07:00
|
|
|
return -ENOMEM;
|
2012-10-11 15:11:14 +07:00
|
|
|
|
|
|
|
ctrl = samsung_pinctrl_get_soc_data(drvdata, pdev);
|
2014-09-24 02:05:37 +07:00
|
|
|
if (IS_ERR(ctrl)) {
|
2012-10-11 15:11:14 +07:00
|
|
|
dev_err(&pdev->dev, "driver data not available\n");
|
2014-09-24 02:05:37 +07:00
|
|
|
return PTR_ERR(ctrl);
|
2012-10-11 15:11:14 +07:00
|
|
|
}
|
2012-09-07 04:07:19 +07:00
|
|
|
drvdata->dev = dev;
|
|
|
|
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
|
|
|
|
if (res)
|
|
|
|
drvdata->irq = res->start;
|
|
|
|
|
2017-01-26 16:29:24 +07:00
|
|
|
if (ctrl->retention_data) {
|
|
|
|
drvdata->retention_ctrl = ctrl->retention_data->init(drvdata,
|
|
|
|
ctrl->retention_data);
|
|
|
|
if (IS_ERR(drvdata->retention_ctrl))
|
|
|
|
return PTR_ERR(drvdata->retention_ctrl);
|
|
|
|
}
|
|
|
|
|
2017-03-23 00:15:34 +07:00
|
|
|
ret = samsung_pinctrl_register(pdev, drvdata);
|
2012-09-07 04:07:19 +07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2017-03-23 00:15:34 +07:00
|
|
|
ret = samsung_gpiolib_register(pdev, drvdata);
|
2012-09-07 04:07:19 +07:00
|
|
|
if (ret) {
|
2017-03-23 00:15:34 +07:00
|
|
|
samsung_pinctrl_unregister(pdev, drvdata);
|
2012-09-07 04:07:19 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ctrl->eint_gpio_init)
|
|
|
|
ctrl->eint_gpio_init(drvdata);
|
|
|
|
if (ctrl->eint_wkup_init)
|
|
|
|
ctrl->eint_wkup_init(drvdata);
|
|
|
|
|
|
|
|
platform_set_drvdata(pdev, drvdata);
|
2013-05-17 11:33:18 +07:00
|
|
|
|
2012-09-07 04:07:19 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-05-17 11:33:18 +07:00
|
|
|
/**
|
2017-01-26 16:29:27 +07:00
|
|
|
* samsung_pinctrl_suspend - save pinctrl state for suspend
|
2013-05-17 11:33:18 +07:00
|
|
|
*
|
|
|
|
* Save data for all banks handled by this device.
|
|
|
|
*/
|
2017-02-01 23:16:24 +07:00
|
|
|
static int __maybe_unused samsung_pinctrl_suspend(struct device *dev)
|
2013-05-17 11:33:18 +07:00
|
|
|
{
|
2017-01-26 16:29:27 +07:00
|
|
|
struct samsung_pinctrl_drv_data *drvdata = dev_get_drvdata(dev);
|
2013-05-17 11:33:18 +07:00
|
|
|
int i;
|
|
|
|
|
2014-09-24 02:05:40 +07:00
|
|
|
for (i = 0; i < drvdata->nr_banks; i++) {
|
|
|
|
struct samsung_pin_bank *bank = &drvdata->pin_banks[i];
|
2016-11-09 15:40:10 +07:00
|
|
|
void __iomem *reg = bank->pctl_base + bank->pctl_offset;
|
2014-09-24 02:05:39 +07:00
|
|
|
const u8 *offs = bank->type->reg_offset;
|
|
|
|
const u8 *widths = bank->type->fld_width;
|
2013-05-17 11:33:18 +07:00
|
|
|
enum pincfg_type type;
|
|
|
|
|
|
|
|
/* Registers without a powerdown config aren't lost */
|
|
|
|
if (!widths[PINCFG_TYPE_CON_PDN])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (type = 0; type < PINCFG_TYPE_NUM; type++)
|
|
|
|
if (widths[type])
|
|
|
|
bank->pm_save[type] = readl(reg + offs[type]);
|
|
|
|
|
|
|
|
if (widths[PINCFG_TYPE_FUNC] * bank->nr_pins > 32) {
|
|
|
|
/* Some banks have two config registers */
|
|
|
|
bank->pm_save[PINCFG_TYPE_NUM] =
|
|
|
|
readl(reg + offs[PINCFG_TYPE_FUNC] + 4);
|
|
|
|
pr_debug("Save %s @ %p (con %#010x %08x)\n",
|
|
|
|
bank->name, reg,
|
|
|
|
bank->pm_save[PINCFG_TYPE_FUNC],
|
|
|
|
bank->pm_save[PINCFG_TYPE_NUM]);
|
|
|
|
} else {
|
|
|
|
pr_debug("Save %s @ %p (con %#010x)\n", bank->name,
|
|
|
|
reg, bank->pm_save[PINCFG_TYPE_FUNC]);
|
|
|
|
}
|
|
|
|
}
|
2013-05-17 23:24:30 +07:00
|
|
|
|
2014-09-24 02:05:40 +07:00
|
|
|
if (drvdata->suspend)
|
|
|
|
drvdata->suspend(drvdata);
|
2017-01-26 16:29:24 +07:00
|
|
|
if (drvdata->retention_ctrl && drvdata->retention_ctrl->enable)
|
|
|
|
drvdata->retention_ctrl->enable(drvdata);
|
2017-01-26 16:29:27 +07:00
|
|
|
|
|
|
|
return 0;
|
2013-05-17 11:33:18 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-01-26 16:29:27 +07:00
|
|
|
* samsung_pinctrl_resume - restore pinctrl state from suspend
|
2013-05-17 11:33:18 +07:00
|
|
|
*
|
|
|
|
* Restore one of the banks that was saved during suspend.
|
|
|
|
*
|
|
|
|
* We don't bother doing anything complicated to avoid glitching lines since
|
|
|
|
* we're called before pad retention is turned off.
|
|
|
|
*/
|
2017-02-01 23:16:24 +07:00
|
|
|
static int __maybe_unused samsung_pinctrl_resume(struct device *dev)
|
2013-05-17 11:33:18 +07:00
|
|
|
{
|
2017-01-26 16:29:27 +07:00
|
|
|
struct samsung_pinctrl_drv_data *drvdata = dev_get_drvdata(dev);
|
2013-05-17 11:33:18 +07:00
|
|
|
int i;
|
|
|
|
|
2014-09-24 02:05:40 +07:00
|
|
|
if (drvdata->resume)
|
|
|
|
drvdata->resume(drvdata);
|
2013-05-17 23:24:30 +07:00
|
|
|
|
2014-09-24 02:05:40 +07:00
|
|
|
for (i = 0; i < drvdata->nr_banks; i++) {
|
|
|
|
struct samsung_pin_bank *bank = &drvdata->pin_banks[i];
|
2016-11-09 15:40:10 +07:00
|
|
|
void __iomem *reg = bank->pctl_base + bank->pctl_offset;
|
2014-09-24 02:05:39 +07:00
|
|
|
const u8 *offs = bank->type->reg_offset;
|
|
|
|
const u8 *widths = bank->type->fld_width;
|
2013-05-17 11:33:18 +07:00
|
|
|
enum pincfg_type type;
|
|
|
|
|
|
|
|
/* Registers without a powerdown config aren't lost */
|
|
|
|
if (!widths[PINCFG_TYPE_CON_PDN])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (widths[PINCFG_TYPE_FUNC] * bank->nr_pins > 32) {
|
|
|
|
/* Some banks have two config registers */
|
|
|
|
pr_debug("%s @ %p (con %#010x %08x => %#010x %08x)\n",
|
|
|
|
bank->name, reg,
|
|
|
|
readl(reg + offs[PINCFG_TYPE_FUNC]),
|
|
|
|
readl(reg + offs[PINCFG_TYPE_FUNC] + 4),
|
|
|
|
bank->pm_save[PINCFG_TYPE_FUNC],
|
|
|
|
bank->pm_save[PINCFG_TYPE_NUM]);
|
|
|
|
writel(bank->pm_save[PINCFG_TYPE_NUM],
|
|
|
|
reg + offs[PINCFG_TYPE_FUNC] + 4);
|
|
|
|
} else {
|
|
|
|
pr_debug("%s @ %p (con %#010x => %#010x)\n", bank->name,
|
|
|
|
reg, readl(reg + offs[PINCFG_TYPE_FUNC]),
|
|
|
|
bank->pm_save[PINCFG_TYPE_FUNC]);
|
|
|
|
}
|
|
|
|
for (type = 0; type < PINCFG_TYPE_NUM; type++)
|
|
|
|
if (widths[type])
|
|
|
|
writel(bank->pm_save[type], reg + offs[type]);
|
|
|
|
}
|
2017-01-26 16:29:24 +07:00
|
|
|
|
|
|
|
if (drvdata->retention_ctrl && drvdata->retention_ctrl->disable)
|
|
|
|
drvdata->retention_ctrl->disable(drvdata);
|
2013-05-17 11:33:18 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-07 04:07:19 +07:00
|
|
|
static const struct of_device_id samsung_pinctrl_dt_match[] = {
|
2017-05-17 01:56:27 +07:00
|
|
|
#ifdef CONFIG_PINCTRL_EXYNOS_ARM
|
2014-04-14 08:45:47 +07:00
|
|
|
{ .compatible = "samsung,exynos3250-pinctrl",
|
2017-04-26 04:34:23 +07:00
|
|
|
.data = exynos3250_pin_ctrl },
|
2013-01-03 07:05:42 +07:00
|
|
|
{ .compatible = "samsung,exynos4210-pinctrl",
|
2017-04-26 04:34:23 +07:00
|
|
|
.data = exynos4210_pin_ctrl },
|
2013-01-03 07:05:42 +07:00
|
|
|
{ .compatible = "samsung,exynos4x12-pinctrl",
|
2017-04-26 04:34:23 +07:00
|
|
|
.data = exynos4x12_pin_ctrl },
|
2012-12-29 01:37:27 +07:00
|
|
|
{ .compatible = "samsung,exynos5250-pinctrl",
|
2017-04-26 04:34:23 +07:00
|
|
|
.data = exynos5250_pin_ctrl },
|
2014-02-05 13:21:28 +07:00
|
|
|
{ .compatible = "samsung,exynos5260-pinctrl",
|
2017-04-26 04:34:23 +07:00
|
|
|
.data = exynos5260_pin_ctrl },
|
2015-03-16 05:00:32 +07:00
|
|
|
{ .compatible = "samsung,exynos5410-pinctrl",
|
2017-04-26 04:34:23 +07:00
|
|
|
.data = exynos5410_pin_ctrl },
|
2013-06-19 20:16:26 +07:00
|
|
|
{ .compatible = "samsung,exynos5420-pinctrl",
|
2017-04-26 04:34:23 +07:00
|
|
|
.data = exynos5420_pin_ctrl },
|
2013-08-27 20:08:10 +07:00
|
|
|
{ .compatible = "samsung,s5pv210-pinctrl",
|
2017-04-26 04:34:23 +07:00
|
|
|
.data = s5pv210_pin_ctrl },
|
2017-05-17 01:56:27 +07:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_PINCTRL_EXYNOS_ARM64
|
|
|
|
{ .compatible = "samsung,exynos5433-pinctrl",
|
|
|
|
.data = exynos5433_pin_ctrl },
|
2014-10-09 20:54:32 +07:00
|
|
|
{ .compatible = "samsung,exynos7-pinctrl",
|
2017-04-26 04:34:23 +07:00
|
|
|
.data = exynos7_pin_ctrl },
|
2013-03-19 04:31:55 +07:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_PINCTRL_S3C64XX
|
|
|
|
{ .compatible = "samsung,s3c64xx-pinctrl",
|
|
|
|
.data = s3c64xx_pin_ctrl },
|
2013-05-20 22:56:13 +07:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_PINCTRL_S3C24XX
|
|
|
|
{ .compatible = "samsung,s3c2412-pinctrl",
|
|
|
|
.data = s3c2412_pin_ctrl },
|
|
|
|
{ .compatible = "samsung,s3c2416-pinctrl",
|
|
|
|
.data = s3c2416_pin_ctrl },
|
|
|
|
{ .compatible = "samsung,s3c2440-pinctrl",
|
|
|
|
.data = s3c2440_pin_ctrl },
|
|
|
|
{ .compatible = "samsung,s3c2450-pinctrl",
|
|
|
|
.data = s3c2450_pin_ctrl },
|
2013-03-19 04:31:51 +07:00
|
|
|
#endif
|
2012-09-07 04:07:19 +07:00
|
|
|
{},
|
|
|
|
};
|
|
|
|
|
2017-01-26 16:29:27 +07:00
|
|
|
static const struct dev_pm_ops samsung_pinctrl_pm_ops = {
|
|
|
|
SET_LATE_SYSTEM_SLEEP_PM_OPS(samsung_pinctrl_suspend,
|
|
|
|
samsung_pinctrl_resume)
|
|
|
|
};
|
|
|
|
|
2012-09-07 04:07:19 +07:00
|
|
|
static struct platform_driver samsung_pinctrl_driver = {
|
|
|
|
.probe = samsung_pinctrl_probe,
|
|
|
|
.driver = {
|
|
|
|
.name = "samsung-pinctrl",
|
2013-09-28 19:08:48 +07:00
|
|
|
.of_match_table = samsung_pinctrl_dt_match,
|
2016-05-17 13:02:06 +07:00
|
|
|
.suppress_bind_attrs = true,
|
2017-01-26 16:29:27 +07:00
|
|
|
.pm = &samsung_pinctrl_pm_ops,
|
2012-09-07 04:07:19 +07:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init samsung_pinctrl_drv_register(void)
|
|
|
|
{
|
|
|
|
return platform_driver_register(&samsung_pinctrl_driver);
|
|
|
|
}
|
|
|
|
postcore_initcall(samsung_pinctrl_drv_register);
|