Commit fc78a566 authored by Masahiro Yamada's avatar Masahiro Yamada Committed by Linus Walleij

pinctrl: uniphier: allocate struct pinctrl_desc in probe function

Currently, every SoC driver defines struct pinctrl_desc statically,
i.e. it consumes memory footprint even if it is not probed.

In multi-platform, many pinctrl drivers are linked (generally as
built-in objects), although only one of them is actually used.
So, it is reasonable to allocate memory dynamically where possible.
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 4109508a
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "pinctrl-uniphier.h" #include "pinctrl-uniphier.h"
struct uniphier_pinctrl_priv { struct uniphier_pinctrl_priv {
struct pinctrl_desc pctldesc;
struct pinctrl_dev *pctldev; struct pinctrl_dev *pctldev;
struct regmap *regmap; struct regmap *regmap;
struct uniphier_pinctrl_socdata *socdata; struct uniphier_pinctrl_socdata *socdata;
...@@ -639,13 +640,13 @@ static const struct pinmux_ops uniphier_pmxops = { ...@@ -639,13 +640,13 @@ static const struct pinmux_ops uniphier_pmxops = {
}; };
int uniphier_pinctrl_probe(struct platform_device *pdev, int uniphier_pinctrl_probe(struct platform_device *pdev,
struct pinctrl_desc *desc,
struct uniphier_pinctrl_socdata *socdata) struct uniphier_pinctrl_socdata *socdata)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct uniphier_pinctrl_priv *priv; struct uniphier_pinctrl_priv *priv;
if (!socdata || if (!socdata ||
!socdata->pins || !socdata->npins ||
!socdata->groups || !socdata->groups ||
!socdata->groups_count || !socdata->groups_count ||
!socdata->functions || !socdata->functions ||
...@@ -667,13 +668,15 @@ int uniphier_pinctrl_probe(struct platform_device *pdev, ...@@ -667,13 +668,15 @@ int uniphier_pinctrl_probe(struct platform_device *pdev,
} }
priv->socdata = socdata; priv->socdata = socdata;
desc->name = dev->driver->name; priv->pctldesc.name = dev->driver->name;
desc->pctlops = &uniphier_pctlops; priv->pctldesc.pins = socdata->pins;
desc->pmxops = &uniphier_pmxops; priv->pctldesc.npins = socdata->npins;
desc->confops = &uniphier_confops; priv->pctldesc.pctlops = &uniphier_pctlops;
desc->owner = dev->driver->owner; priv->pctldesc.pmxops = &uniphier_pmxops;
priv->pctldesc.confops = &uniphier_confops;
priv->pctldev = devm_pinctrl_register(dev, desc, priv); priv->pctldesc.owner = dev->driver->owner;
priv->pctldev = devm_pinctrl_register(dev, &priv->pctldesc, priv);
if (IS_ERR(priv->pctldev)) { if (IS_ERR(priv->pctldev)) {
dev_err(dev, "failed to register UniPhier pinctrl driver\n"); dev_err(dev, "failed to register UniPhier pinctrl driver\n");
return PTR_ERR(priv->pctldev); return PTR_ERR(priv->pctldev);
......
...@@ -846,6 +846,8 @@ static const struct uniphier_pinmux_function uniphier_ld4_functions[] = { ...@@ -846,6 +846,8 @@ static const struct uniphier_pinmux_function uniphier_ld4_functions[] = {
}; };
static struct uniphier_pinctrl_socdata uniphier_ld4_pindata = { static struct uniphier_pinctrl_socdata uniphier_ld4_pindata = {
.pins = uniphier_ld4_pins,
.npins = ARRAY_SIZE(uniphier_ld4_pins),
.groups = uniphier_ld4_groups, .groups = uniphier_ld4_groups,
.groups_count = ARRAY_SIZE(uniphier_ld4_groups), .groups_count = ARRAY_SIZE(uniphier_ld4_groups),
.functions = uniphier_ld4_functions, .functions = uniphier_ld4_functions,
...@@ -855,15 +857,9 @@ static struct uniphier_pinctrl_socdata uniphier_ld4_pindata = { ...@@ -855,15 +857,9 @@ static struct uniphier_pinctrl_socdata uniphier_ld4_pindata = {
.load_pinctrl = false, .load_pinctrl = false,
}; };
static struct pinctrl_desc uniphier_ld4_pinctrl_desc = {
.pins = uniphier_ld4_pins,
.npins = ARRAY_SIZE(uniphier_ld4_pins),
};
static int uniphier_ld4_pinctrl_probe(struct platform_device *pdev) static int uniphier_ld4_pinctrl_probe(struct platform_device *pdev)
{ {
return uniphier_pinctrl_probe(pdev, &uniphier_ld4_pinctrl_desc, return uniphier_pinctrl_probe(pdev, &uniphier_ld4_pindata);
&uniphier_ld4_pindata);
} }
static const struct of_device_id uniphier_ld4_pinctrl_match[] = { static const struct of_device_id uniphier_ld4_pinctrl_match[] = {
......
...@@ -1234,6 +1234,8 @@ static const struct uniphier_pinmux_function uniphier_ld6b_functions[] = { ...@@ -1234,6 +1234,8 @@ static const struct uniphier_pinmux_function uniphier_ld6b_functions[] = {
}; };
static struct uniphier_pinctrl_socdata uniphier_ld6b_pindata = { static struct uniphier_pinctrl_socdata uniphier_ld6b_pindata = {
.pins = uniphier_ld6b_pins,
.npins = ARRAY_SIZE(uniphier_ld6b_pins),
.groups = uniphier_ld6b_groups, .groups = uniphier_ld6b_groups,
.groups_count = ARRAY_SIZE(uniphier_ld6b_groups), .groups_count = ARRAY_SIZE(uniphier_ld6b_groups),
.functions = uniphier_ld6b_functions, .functions = uniphier_ld6b_functions,
...@@ -1243,15 +1245,9 @@ static struct uniphier_pinctrl_socdata uniphier_ld6b_pindata = { ...@@ -1243,15 +1245,9 @@ static struct uniphier_pinctrl_socdata uniphier_ld6b_pindata = {
.load_pinctrl = false, .load_pinctrl = false,
}; };
static struct pinctrl_desc uniphier_ld6b_pinctrl_desc = {
.pins = uniphier_ld6b_pins,
.npins = ARRAY_SIZE(uniphier_ld6b_pins),
};
static int uniphier_ld6b_pinctrl_probe(struct platform_device *pdev) static int uniphier_ld6b_pinctrl_probe(struct platform_device *pdev)
{ {
return uniphier_pinctrl_probe(pdev, &uniphier_ld6b_pinctrl_desc, return uniphier_pinctrl_probe(pdev, &uniphier_ld6b_pindata);
&uniphier_ld6b_pindata);
} }
static const struct of_device_id uniphier_ld6b_pinctrl_match[] = { static const struct of_device_id uniphier_ld6b_pinctrl_match[] = {
......
...@@ -1520,6 +1520,8 @@ static const struct uniphier_pinmux_function uniphier_pro4_functions[] = { ...@@ -1520,6 +1520,8 @@ static const struct uniphier_pinmux_function uniphier_pro4_functions[] = {
}; };
static struct uniphier_pinctrl_socdata uniphier_pro4_pindata = { static struct uniphier_pinctrl_socdata uniphier_pro4_pindata = {
.pins = uniphier_pro4_pins,
.npins = ARRAY_SIZE(uniphier_pro4_pins),
.groups = uniphier_pro4_groups, .groups = uniphier_pro4_groups,
.groups_count = ARRAY_SIZE(uniphier_pro4_groups), .groups_count = ARRAY_SIZE(uniphier_pro4_groups),
.functions = uniphier_pro4_functions, .functions = uniphier_pro4_functions,
...@@ -1529,15 +1531,9 @@ static struct uniphier_pinctrl_socdata uniphier_pro4_pindata = { ...@@ -1529,15 +1531,9 @@ static struct uniphier_pinctrl_socdata uniphier_pro4_pindata = {
.load_pinctrl = true, .load_pinctrl = true,
}; };
static struct pinctrl_desc uniphier_pro4_pinctrl_desc = {
.pins = uniphier_pro4_pins,
.npins = ARRAY_SIZE(uniphier_pro4_pins),
};
static int uniphier_pro4_pinctrl_probe(struct platform_device *pdev) static int uniphier_pro4_pinctrl_probe(struct platform_device *pdev)
{ {
return uniphier_pinctrl_probe(pdev, &uniphier_pro4_pinctrl_desc, return uniphier_pinctrl_probe(pdev, &uniphier_pro4_pindata);
&uniphier_pro4_pindata);
} }
static const struct of_device_id uniphier_pro4_pinctrl_match[] = { static const struct of_device_id uniphier_pro4_pinctrl_match[] = {
......
...@@ -1311,6 +1311,8 @@ static const struct uniphier_pinmux_function uniphier_pro5_functions[] = { ...@@ -1311,6 +1311,8 @@ static const struct uniphier_pinmux_function uniphier_pro5_functions[] = {
}; };
static struct uniphier_pinctrl_socdata uniphier_pro5_pindata = { static struct uniphier_pinctrl_socdata uniphier_pro5_pindata = {
.pins = uniphier_pro5_pins,
.npins = ARRAY_SIZE(uniphier_pro5_pins),
.groups = uniphier_pro5_groups, .groups = uniphier_pro5_groups,
.groups_count = ARRAY_SIZE(uniphier_pro5_groups), .groups_count = ARRAY_SIZE(uniphier_pro5_groups),
.functions = uniphier_pro5_functions, .functions = uniphier_pro5_functions,
...@@ -1320,15 +1322,9 @@ static struct uniphier_pinctrl_socdata uniphier_pro5_pindata = { ...@@ -1320,15 +1322,9 @@ static struct uniphier_pinctrl_socdata uniphier_pro5_pindata = {
.load_pinctrl = true, .load_pinctrl = true,
}; };
static struct pinctrl_desc uniphier_pro5_pinctrl_desc = {
.pins = uniphier_pro5_pins,
.npins = ARRAY_SIZE(uniphier_pro5_pins),
};
static int uniphier_pro5_pinctrl_probe(struct platform_device *pdev) static int uniphier_pro5_pinctrl_probe(struct platform_device *pdev)
{ {
return uniphier_pinctrl_probe(pdev, &uniphier_pro5_pinctrl_desc, return uniphier_pinctrl_probe(pdev, &uniphier_pro5_pindata);
&uniphier_pro5_pindata);
} }
static const struct of_device_id uniphier_pro5_pinctrl_match[] = { static const struct of_device_id uniphier_pro5_pinctrl_match[] = {
......
...@@ -1229,6 +1229,8 @@ static const struct uniphier_pinmux_function uniphier_pxs2_functions[] = { ...@@ -1229,6 +1229,8 @@ static const struct uniphier_pinmux_function uniphier_pxs2_functions[] = {
}; };
static struct uniphier_pinctrl_socdata uniphier_pxs2_pindata = { static struct uniphier_pinctrl_socdata uniphier_pxs2_pindata = {
.pins = uniphier_pxs2_pins,
.npins = ARRAY_SIZE(uniphier_pxs2_pins),
.groups = uniphier_pxs2_groups, .groups = uniphier_pxs2_groups,
.groups_count = ARRAY_SIZE(uniphier_pxs2_groups), .groups_count = ARRAY_SIZE(uniphier_pxs2_groups),
.functions = uniphier_pxs2_functions, .functions = uniphier_pxs2_functions,
...@@ -1238,15 +1240,9 @@ static struct uniphier_pinctrl_socdata uniphier_pxs2_pindata = { ...@@ -1238,15 +1240,9 @@ static struct uniphier_pinctrl_socdata uniphier_pxs2_pindata = {
.load_pinctrl = false, .load_pinctrl = false,
}; };
static struct pinctrl_desc uniphier_pxs2_pinctrl_desc = {
.pins = uniphier_pxs2_pins,
.npins = ARRAY_SIZE(uniphier_pxs2_pins),
};
static int uniphier_pxs2_pinctrl_probe(struct platform_device *pdev) static int uniphier_pxs2_pinctrl_probe(struct platform_device *pdev)
{ {
return uniphier_pinctrl_probe(pdev, &uniphier_pxs2_pinctrl_desc, return uniphier_pinctrl_probe(pdev, &uniphier_pxs2_pindata);
&uniphier_pxs2_pindata);
} }
static const struct of_device_id uniphier_pxs2_pinctrl_match[] = { static const struct of_device_id uniphier_pxs2_pinctrl_match[] = {
......
...@@ -754,6 +754,8 @@ static const struct uniphier_pinmux_function uniphier_sld8_functions[] = { ...@@ -754,6 +754,8 @@ static const struct uniphier_pinmux_function uniphier_sld8_functions[] = {
}; };
static struct uniphier_pinctrl_socdata uniphier_sld8_pindata = { static struct uniphier_pinctrl_socdata uniphier_sld8_pindata = {
.pins = uniphier_sld8_pins,
.npins = ARRAY_SIZE(uniphier_sld8_pins),
.groups = uniphier_sld8_groups, .groups = uniphier_sld8_groups,
.groups_count = ARRAY_SIZE(uniphier_sld8_groups), .groups_count = ARRAY_SIZE(uniphier_sld8_groups),
.functions = uniphier_sld8_functions, .functions = uniphier_sld8_functions,
...@@ -763,15 +765,9 @@ static struct uniphier_pinctrl_socdata uniphier_sld8_pindata = { ...@@ -763,15 +765,9 @@ static struct uniphier_pinctrl_socdata uniphier_sld8_pindata = {
.load_pinctrl = false, .load_pinctrl = false,
}; };
static struct pinctrl_desc uniphier_sld8_pinctrl_desc = {
.pins = uniphier_sld8_pins,
.npins = ARRAY_SIZE(uniphier_sld8_pins),
};
static int uniphier_sld8_pinctrl_probe(struct platform_device *pdev) static int uniphier_sld8_pinctrl_probe(struct platform_device *pdev)
{ {
return uniphier_pinctrl_probe(pdev, &uniphier_sld8_pinctrl_desc, return uniphier_pinctrl_probe(pdev, &uniphier_sld8_pindata);
&uniphier_sld8_pindata);
} }
static const struct of_device_id uniphier_sld8_pinctrl_match[] = { static const struct of_device_id uniphier_sld8_pinctrl_match[] = {
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/types.h> #include <linux/types.h>
struct platform_device;
#define UNIPHIER_PINCTRL_PINMUX_BASE 0x0 #define UNIPHIER_PINCTRL_PINMUX_BASE 0x0
#define UNIPHIER_PINCTRL_LOAD_PINMUX 0x700 #define UNIPHIER_PINCTRL_LOAD_PINMUX 0x700
#define UNIPHIER_PINCTRL_DRVCTRL_BASE 0x800 #define UNIPHIER_PINCTRL_DRVCTRL_BASE 0x800
...@@ -154,6 +156,8 @@ struct uniphier_pinmux_function { ...@@ -154,6 +156,8 @@ struct uniphier_pinmux_function {
}; };
struct uniphier_pinctrl_socdata { struct uniphier_pinctrl_socdata {
const struct pinctrl_pin_desc *pins;
unsigned int npins;
const struct uniphier_pinctrl_group *groups; const struct uniphier_pinctrl_group *groups;
int groups_count; int groups_count;
const struct uniphier_pinmux_function *functions; const struct uniphier_pinmux_function *functions;
...@@ -205,11 +209,7 @@ struct uniphier_pinctrl_socdata { ...@@ -205,11 +209,7 @@ struct uniphier_pinctrl_socdata {
.num_groups = ARRAY_SIZE(func##_groups), \ .num_groups = ARRAY_SIZE(func##_groups), \
} }
struct platform_device;
struct pinctrl_desc;
int uniphier_pinctrl_probe(struct platform_device *pdev, int uniphier_pinctrl_probe(struct platform_device *pdev,
struct pinctrl_desc *desc,
struct uniphier_pinctrl_socdata *socdata); struct uniphier_pinctrl_socdata *socdata);
#endif /* __PINCTRL_UNIPHIER_H__ */ #endif /* __PINCTRL_UNIPHIER_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment