From: Lucas Stach <dev@lynxeye.de>
To: barebox@lists.infradead.org
Subject: [PATCH 21/30] pinctrl: tegra30: introduce drvdata
Date: Tue, 3 Jun 2014 22:35:08 +0200 [thread overview]
Message-ID: <1401827717-6420-22-git-send-email-dev@lynxeye.de> (raw)
In-Reply-To: <1401827717-6420-1-git-send-email-dev@lynxeye.de>
Access pin and drivegroups through a drvdata pointer.
This allows to insert other groups for SoCs with a
similar bit layout easily.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
drivers/pinctrl/pinctrl-tegra30.c | 48 +++++++++++++++++++++++++++------------
1 file changed, 34 insertions(+), 14 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-tegra30.c b/drivers/pinctrl/pinctrl-tegra30.c
index 888bf04..d1e87a7 100644
--- a/drivers/pinctrl/pinctrl-tegra30.c
+++ b/drivers/pinctrl/pinctrl-tegra30.c
@@ -23,21 +23,24 @@
#include <malloc.h>
#include <pinctrl.h>
+struct pinctrl_tegra30_drvdata;
+
struct pinctrl_tegra30 {
struct {
u32 __iomem *ctrl;
u32 __iomem *mux;
} regs;
struct pinctrl_device pinctrl;
+ struct pinctrl_tegra30_drvdata *drvdata;
};
-struct tegra30_pingroup {
+struct tegra_pingroup {
const char *name;
const char *funcs[4];
u16 reg;
};
-struct tegra30_drive_pingroup {
+struct tegra_drive_pingroup {
const char *name;
u16 reg;
u32 hsm_bit:5;
@@ -54,6 +57,13 @@ struct tegra30_drive_pingroup {
u32 slwf_width:6;
};
+struct pinctrl_tegra30_drvdata {
+ const struct tegra_pingroup *pingrps;
+ const unsigned int num_pingrps;
+ const struct tegra_drive_pingroup *drvgrps;
+ const unsigned int num_drvgrps;
+};
+
#define PG(pg_name, f0, f1, f2, f3, offset) \
{ \
.name = #pg_name, \
@@ -80,7 +90,7 @@ struct tegra30_drive_pingroup {
.slwf_width = slwf_w, \
}
-static const struct tegra30_pingroup tegra30_groups[] = {
+static const struct tegra_pingroup tegra30_pin_groups[] = {
/* name, f0, f1, f2, f3, reg */
PG(clk_32k_out_pa0, blink, rsvd2, rsvd3, rsvd4, 0x31c),
PG(uart3_cts_n_pa1, uartc, rsvd2, gmi, rsvd4, 0x17c),
@@ -333,7 +343,7 @@ static const struct tegra30_pingroup tegra30_groups[] = {
PG(pwr_int_n, pwr_int_n, rsvd2, rsvd3, rsvd4, 0x32c),
};
-static const struct tegra30_drive_pingroup tegra30_drive_groups[] = {
+static const struct tegra_drive_pingroup tegra30_drive_groups[] = {
DRV_PG(ao1, 0x868, 2, 3, 4, 12, 5, 20, 5, 28, 2, 30, 2),
DRV_PG(ao2, 0x86c, 2, 3, 4, 12, 5, 20, 5, 28, 2, 30, 2),
DRV_PG(at1, 0x870, 2, 3, 4, 14, 5, 19, 5, 24, 2, 28, 2),
@@ -377,11 +387,18 @@ static const struct tegra30_drive_pingroup tegra30_drive_groups[] = {
DRV_PG(vi1, 0x8c8, -1, -1, -1, 14, 5, 19, 5, 24, 4, 28, 4),
};
+static const struct pinctrl_tegra30_drvdata tegra30_drvdata = {
+ .pingrps = tegra30_pin_groups,
+ .num_pingrps = ARRAY_SIZE(tegra30_pin_groups),
+ .drvgrps = tegra30_drive_groups,
+ .num_drvgrps = ARRAY_SIZE(tegra30_drive_groups),
+};
+
static int pinctrl_tegra30_set_drvstate(struct pinctrl_tegra30 *ctrl,
struct device_node *np)
{
const char *pins = NULL;
- const struct tegra30_drive_pingroup *group = NULL;
+ const struct tegra_drive_pingroup *group = NULL;
int hsm = -1, schmitt = -1, pds = -1, pus = -1, srr = -1, srf = -1;
int i;
u32 __iomem *regaddr;
@@ -390,14 +407,14 @@ static int pinctrl_tegra30_set_drvstate(struct pinctrl_tegra30 *ctrl,
if (of_property_read_string(np, "nvidia,pins", &pins))
return 0;
- for (i = 0; i < ARRAY_SIZE(tegra30_drive_groups); i++) {
- if (!strcmp(pins, tegra30_drive_groups[i].name)) {
- group = &tegra30_drive_groups[i];
+ for (i = 0; i < ctrl->drvdata->num_drvgrps; i++) {
+ if (!strcmp(pins, ctrl->drvdata->drvgrps[i].name)) {
+ group = &ctrl->drvdata->drvgrps[i];
break;
}
}
/* if no matching drivegroup is found */
- if (i == ARRAY_SIZE(tegra30_groups))
+ if (i == ctrl->drvdata->num_drvgrps)
return 0;
regaddr = ctrl->regs.ctrl + (group->reg >> 2);
@@ -529,7 +546,7 @@ static int pinctrl_tegra30_set_state(struct pinctrl_device *pdev,
struct device_node *childnode;
int pull = -1, tri = -1, in = -1, od = -1, ior = -1, i, j, k;
const char *pins, *func = NULL;
- const struct tegra30_pingroup *group;
+ const struct tegra_pingroup *group = NULL;
/*
* At first look if the node we are pointed at has children,
@@ -551,14 +568,14 @@ static int pinctrl_tegra30_set_state(struct pinctrl_device *pdev,
if (of_property_read_string_index(np, "nvidia,pins", i, &pins))
break;
- for (j = 0; j < ARRAY_SIZE(tegra30_groups); j++) {
- if (!strcmp(pins, tegra30_groups[j].name)) {
- group = &tegra30_groups[j];
+ for (j = 0; j < ctrl->drvdata->num_pingrps; j++) {
+ if (!strcmp(pins, ctrl->drvdata->pingrps[j].name)) {
+ group = &ctrl->drvdata->pingrps[j];
break;
}
}
/* if no matching pingroup is found */
- if (j == ARRAY_SIZE(tegra30_groups)) {
+ if (j == ctrl->drvdata->num_pingrps) {
/* see if we can find a drivegroup */
if (pinctrl_tegra30_set_drvstate(ctrl, np))
continue;
@@ -629,6 +646,8 @@ static int pinctrl_tegra30_probe(struct device_d *dev)
}
}
+ dev_get_drvdata(dev, (unsigned long *)&ctrl->drvdata);
+
ctrl->pinctrl.dev = dev;
ctrl->pinctrl.ops = &pinctrl_tegra30_ops;
@@ -642,6 +661,7 @@ static int pinctrl_tegra30_probe(struct device_d *dev)
static __maybe_unused struct of_device_id pinctrl_tegra30_dt_ids[] = {
{
.compatible = "nvidia,tegra30-pinmux",
+ .data = (unsigned long)&tegra30_drvdata,
}, {
/* sentinel */
}
--
1.9.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-06-03 20:33 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-03 20:34 [PATCH 00/30] Tegra K1 support Lucas Stach
2014-06-03 20:34 ` [PATCH 01/30] mci: implement non-removable property Lucas Stach
2014-06-03 20:34 ` [PATCH 02/30] tegra: lowlevel-dvc: use __always_inline macro Lucas Stach
2014-06-03 20:34 ` [PATCH 03/30] tegra: pmc: add Tegra30 compatible Lucas Stach
2014-06-03 20:34 ` [PATCH 04/30] tegra: pmc: add command to get into RCM Lucas Stach
2014-06-03 20:34 ` [PATCH 05/30] tegra: lowlevel: setup an early stack Lucas Stach
2014-06-03 20:34 ` [PATCH 06/30] tegra: add Tegra124 id to lowlevel functions Lucas Stach
2014-06-03 20:34 ` [PATCH 07/30] tegra: lowlevel: fix ODMdata fetch on Tegra124 Lucas Stach
2014-06-03 20:34 ` [PATCH 08/30] tegra: recognize Tegra124 in maincomplex startup Lucas Stach
2014-06-03 20:34 ` [PATCH 09/30] tegra: recognize Tegra124 in common initcalls Lucas Stach
2014-06-03 20:34 ` [PATCH 10/30] tegra: add Tegra124 and AS3722 PMIC to lowlevel-dvc Lucas Stach
2014-06-03 20:34 ` [PATCH 11/30] tegra: disable IDDQ for PLL_X on Tegra124 Lucas Stach
2014-06-03 20:34 ` [PATCH 12/30] tegra: power up additional partitions " Lucas Stach
2014-06-03 20:35 ` [PATCH 13/30] tegra: fix MESLECT clock enable Lucas Stach
2014-06-03 20:35 ` [PATCH 14/30] tegra: change cpu internal reset layout for Tegra124 Lucas Stach
2014-06-03 20:35 ` [PATCH 15/30] tegra: add Tegra124 PLL_X rate setup Lucas Stach
2014-06-03 20:35 ` [PATCH 16/30] tegra: apply cluster switch logic to all SoCs >=T30 Lucas Stach
2014-06-03 20:35 ` [PATCH 17/30] tegra: hardcode entry address for main cluster Lucas Stach
2014-06-03 20:35 ` [PATCH 18/30] tegra: setup L2 cache on Tegra124 Lucas Stach
2014-06-03 20:35 ` [PATCH 19/30] tegra: add architectural timer init Lucas Stach
2014-06-03 20:35 ` [PATCH 20/30] tegra: add Tegra124 Kconfig symbol Lucas Stach
2014-06-03 20:35 ` Lucas Stach [this message]
2014-06-03 20:35 ` [PATCH 22/30] pinctrl: tegra: add Tegra124 support Lucas Stach
2014-06-03 20:35 ` [PATCH 23/30] clk: tegra: allow variable sized muxes Lucas Stach
2014-06-03 20:35 ` [PATCH 24/30] clk: tegra: don't bug out on zero PLL postdiv Lucas Stach
2014-06-03 20:35 ` [PATCH 25/30] clk: tegra: add Tegra124 driver Lucas Stach
2014-06-03 20:35 ` [PATCH 26/30] mci: tegra: add Tegra124 compatible Lucas Stach
2014-06-03 20:35 ` [PATCH 27/30] tegra: pmc: " Lucas Stach
2014-06-03 20:35 ` [PATCH 28/30] images: add Tegra124 image build rules Lucas Stach
2014-06-03 20:35 ` [PATCH 29/30] tegra: add NVIDIA Jetson-TK1 board support Lucas Stach
2014-06-03 20:35 ` [PATCH 30/30] tegra: refresh defconfig Lucas Stach
2014-06-04 5:22 ` [PATCH 00/30] Tegra K1 support Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1401827717-6420-22-git-send-email-dev@lynxeye.de \
--to=dev@lynxeye.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox