aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinctrl-single.c
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2013-10-03 00:39:39 -0400
committerTony Lindgren <tony@atomide.com>2013-10-09 17:47:54 -0400
commit02e483f66deb6bd8df6af450726574614eb53be3 (patch)
tree7f232e549e241f739da4d02b23602bc2504ab5ee /drivers/pinctrl/pinctrl-single.c
parentd0e639c9e06d44e713170031fe05fb60ebe680af (diff)
pinctrl: single: Prepare for supporting SoC specific features
Let's replace is_pinconf with flags and add struct pcs_soc_data so we can support SoC specific features like pin wake-up events. Done in collaboration with Roger Quadros <rogerq@ti.com>. Cc: Peter Ujfalusi <peter.ujfalusi@ti.com> Cc: Grygorii Strashko <grygorii.strashko@ti.com> Cc: Prakash Manjunathappa <prakash.pm@ti.com> Cc: linux-kernel@vger.kernel.org Acked-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Haojian Zhuang <haojian.zhuang@gmail.com> Reviewed-by: Kevin Hilman <khilman@linaro.org> Tested-by: Kevin Hilman <khilman@linaro.org> Signed-off-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'drivers/pinctrl/pinctrl-single.c')
-rw-r--r--drivers/pinctrl/pinctrl-single.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index a82ace4d9a20..f88d3d1b2b99 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -150,19 +150,27 @@ struct pcs_name {
150}; 150};
151 151
152/** 152/**
153 * struct pcs_soc_data - SoC specific settings
154 * @flags: initial SoC specific PCS_FEAT_xxx values
155 */
156struct pcs_soc_data {
157 unsigned flags;
158};
159
160/**
153 * struct pcs_device - pinctrl device instance 161 * struct pcs_device - pinctrl device instance
154 * @res: resources 162 * @res: resources
155 * @base: virtual address of the controller 163 * @base: virtual address of the controller
156 * @size: size of the ioremapped area 164 * @size: size of the ioremapped area
157 * @dev: device entry 165 * @dev: device entry
158 * @pctl: pin controller device 166 * @pctl: pin controller device
167 * @flags: mask of PCS_FEAT_xxx values
159 * @mutex: mutex protecting the lists 168 * @mutex: mutex protecting the lists
160 * @width: bits per mux register 169 * @width: bits per mux register
161 * @fmask: function register mask 170 * @fmask: function register mask
162 * @fshift: function register shift 171 * @fshift: function register shift
163 * @foff: value to turn mux off 172 * @foff: value to turn mux off
164 * @fmax: max number of functions in fmask 173 * @fmax: max number of functions in fmask
165 * @is_pinconf: whether supports pinconf
166 * @bits_per_pin:number of bits per pin 174 * @bits_per_pin:number of bits per pin
167 * @names: array of register names for pins 175 * @names: array of register names for pins
168 * @pins: physical pins on the SoC 176 * @pins: physical pins on the SoC
@@ -183,6 +191,8 @@ struct pcs_device {
183 unsigned size; 191 unsigned size;
184 struct device *dev; 192 struct device *dev;
185 struct pinctrl_dev *pctl; 193 struct pinctrl_dev *pctl;
194 unsigned flags;
195#define PCS_FEAT_PINCONF (1 << 0)
186 struct mutex mutex; 196 struct mutex mutex;
187 unsigned width; 197 unsigned width;
188 unsigned fmask; 198 unsigned fmask;
@@ -190,7 +200,6 @@ struct pcs_device {
190 unsigned foff; 200 unsigned foff;
191 unsigned fmax; 201 unsigned fmax;
192 bool bits_per_mux; 202 bool bits_per_mux;
193 bool is_pinconf;
194 unsigned bits_per_pin; 203 unsigned bits_per_pin;
195 struct pcs_name *names; 204 struct pcs_name *names;
196 struct pcs_data pins; 205 struct pcs_data pins;
@@ -206,6 +215,8 @@ struct pcs_device {
206 void (*write)(unsigned val, void __iomem *reg); 215 void (*write)(unsigned val, void __iomem *reg);
207}; 216};
208 217
218#define PCS_HAS_PINCONF (pcs->flags & PCS_FEAT_PINCONF)
219
209static int pcs_pinconf_get(struct pinctrl_dev *pctldev, unsigned pin, 220static int pcs_pinconf_get(struct pinctrl_dev *pctldev, unsigned pin,
210 unsigned long *config); 221 unsigned long *config);
211static int pcs_pinconf_set(struct pinctrl_dev *pctldev, unsigned pin, 222static int pcs_pinconf_set(struct pinctrl_dev *pctldev, unsigned pin,
@@ -1060,7 +1071,7 @@ static int pcs_parse_pinconf(struct pcs_device *pcs, struct device_node *np,
1060 }; 1071 };
1061 1072
1062 /* If pinconf isn't supported, don't parse properties in below. */ 1073 /* If pinconf isn't supported, don't parse properties in below. */
1063 if (!pcs->is_pinconf) 1074 if (!PCS_HAS_PINCONF)
1064 return 0; 1075 return 0;
1065 1076
1066 /* cacluate how much properties are supported in current node */ 1077 /* cacluate how much properties are supported in current node */
@@ -1184,7 +1195,7 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs,
1184 (*map)->data.mux.group = np->name; 1195 (*map)->data.mux.group = np->name;
1185 (*map)->data.mux.function = np->name; 1196 (*map)->data.mux.function = np->name;
1186 1197
1187 if (pcs->is_pinconf) { 1198 if (PCS_HAS_PINCONF) {
1188 res = pcs_parse_pinconf(pcs, np, function, map); 1199 res = pcs_parse_pinconf(pcs, np, function, map);
1189 if (res) 1200 if (res)
1190 goto free_pingroups; 1201 goto free_pingroups;
@@ -1305,7 +1316,7 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
1305 (*map)->data.mux.group = np->name; 1316 (*map)->data.mux.group = np->name;
1306 (*map)->data.mux.function = np->name; 1317 (*map)->data.mux.function = np->name;
1307 1318
1308 if (pcs->is_pinconf) { 1319 if (PCS_HAS_PINCONF) {
1309 dev_err(pcs->dev, "pinconf not supported\n"); 1320 dev_err(pcs->dev, "pinconf not supported\n");
1310 goto free_pingroups; 1321 goto free_pingroups;
1311 } 1322 }
@@ -1525,6 +1536,7 @@ static int pcs_probe(struct platform_device *pdev)
1525 const struct of_device_id *match; 1536 const struct of_device_id *match;
1526 struct resource *res; 1537 struct resource *res;
1527 struct pcs_device *pcs; 1538 struct pcs_device *pcs;
1539 const struct pcs_soc_data *soc;
1528 int ret; 1540 int ret;
1529 1541
1530 match = of_match_device(pcs_of_match, &pdev->dev); 1542 match = of_match_device(pcs_of_match, &pdev->dev);
@@ -1541,7 +1553,8 @@ static int pcs_probe(struct platform_device *pdev)
1541 INIT_LIST_HEAD(&pcs->pingroups); 1553 INIT_LIST_HEAD(&pcs->pingroups);
1542 INIT_LIST_HEAD(&pcs->functions); 1554 INIT_LIST_HEAD(&pcs->functions);
1543 INIT_LIST_HEAD(&pcs->gpiofuncs); 1555 INIT_LIST_HEAD(&pcs->gpiofuncs);
1544 pcs->is_pinconf = match->data; 1556 soc = match->data;
1557 pcs->flags = soc->flags;
1545 1558
1546 PCS_GET_PROP_U32("pinctrl-single,register-width", &pcs->width, 1559 PCS_GET_PROP_U32("pinctrl-single,register-width", &pcs->width,
1547 "register width not specified\n"); 1560 "register width not specified\n");
@@ -1610,7 +1623,7 @@ static int pcs_probe(struct platform_device *pdev)
1610 pcs->desc.name = DRIVER_NAME; 1623 pcs->desc.name = DRIVER_NAME;
1611 pcs->desc.pctlops = &pcs_pinctrl_ops; 1624 pcs->desc.pctlops = &pcs_pinctrl_ops;
1612 pcs->desc.pmxops = &pcs_pinmux_ops; 1625 pcs->desc.pmxops = &pcs_pinmux_ops;
1613 if (pcs->is_pinconf) 1626 if (PCS_HAS_PINCONF)
1614 pcs->desc.confops = &pcs_pinconf_ops; 1627 pcs->desc.confops = &pcs_pinconf_ops;
1615 pcs->desc.owner = THIS_MODULE; 1628 pcs->desc.owner = THIS_MODULE;
1616 1629
@@ -1652,9 +1665,16 @@ static int pcs_remove(struct platform_device *pdev)
1652 return 0; 1665 return 0;
1653} 1666}
1654 1667
1668static const struct pcs_soc_data pinctrl_single = {
1669};
1670
1671static const struct pcs_soc_data pinconf_single = {
1672 .flags = PCS_FEAT_PINCONF,
1673};
1674
1655static struct of_device_id pcs_of_match[] = { 1675static struct of_device_id pcs_of_match[] = {
1656 { .compatible = "pinctrl-single", .data = (void *)false }, 1676 { .compatible = "pinctrl-single", .data = &pinctrl_single },
1657 { .compatible = "pinconf-single", .data = (void *)true }, 1677 { .compatible = "pinconf-single", .data = &pinconf_single },
1658 { }, 1678 { },
1659}; 1679};
1660MODULE_DEVICE_TABLE(of, pcs_of_match); 1680MODULE_DEVICE_TABLE(of, pcs_of_match);