summaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinctrl-single.c
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2016-11-03 12:35:49 -0400
committerLinus Walleij <linus.walleij@linaro.org>2016-11-04 17:53:06 -0400
commit22d5127ec916e8eac607eebbbafc026ef59afb36 (patch)
tree9b950ff03b9bec31fd21ff153c46b29b684c11ca /drivers/pinctrl/pinctrl-single.c
parent4622215fb1dda40bcebab31553765ee9cacb476d (diff)
pinctrl: single: Use generic parser and #pinctrl-cells for pinctrl-single,bits
We can now use generic parser and keep things compatible with the old binding. Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-single.c')
-rw-r--r--drivers/pinctrl/pinctrl-single.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 07c427367237..539f31cd8e00 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -35,7 +35,6 @@
35#include "pinconf.h" 35#include "pinconf.h"
36 36
37#define DRIVER_NAME "pinctrl-single" 37#define DRIVER_NAME "pinctrl-single"
38#define PCS_MUX_BITS_NAME "pinctrl-single,bits"
39#define PCS_OFF_DISABLED ~0U 38#define PCS_OFF_DISABLED ~0U
40 39
41/** 40/**
@@ -1216,36 +1215,22 @@ free_vals:
1216 return res; 1215 return res;
1217} 1216}
1218 1217
1219#define PARAMS_FOR_BITS_PER_MUX 3
1220
1221static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs, 1218static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
1222 struct device_node *np, 1219 struct device_node *np,
1223 struct pinctrl_map **map, 1220 struct pinctrl_map **map,
1224 unsigned *num_maps, 1221 unsigned *num_maps,
1225 const char **pgnames) 1222 const char **pgnames)
1226{ 1223{
1224 const char *name = "pinctrl-single,pins";
1227 struct pcs_func_vals *vals; 1225 struct pcs_func_vals *vals;
1228 const __be32 *mux; 1226 int rows, *pins, found = 0, res = -ENOMEM, i;
1229 int size, rows, *pins, index = 0, found = 0, res = -ENOMEM;
1230 int npins_in_row; 1227 int npins_in_row;
1231 struct pcs_function *function; 1228 struct pcs_function *function;
1232 1229
1233 mux = of_get_property(np, PCS_MUX_BITS_NAME, &size); 1230 rows = pinctrl_count_index_with_args(np, name);
1234 1231 if (rows == -EINVAL)
1235 if (!mux) { 1232 return rows;
1236 dev_err(pcs->dev, "no valid property for %s\n", np->name);
1237 return -EINVAL;
1238 }
1239
1240 if (size < (sizeof(*mux) * PARAMS_FOR_BITS_PER_MUX)) {
1241 dev_err(pcs->dev, "bad data for %s\n", np->name);
1242 return -EINVAL;
1243 }
1244
1245 /* Number of elements in array */
1246 size /= sizeof(*mux);
1247 1233
1248 rows = size / PARAMS_FOR_BITS_PER_MUX;
1249 npins_in_row = pcs->width / pcs->bits_per_pin; 1234 npins_in_row = pcs->width / pcs->bits_per_pin;
1250 1235
1251 vals = devm_kzalloc(pcs->dev, sizeof(*vals) * rows * npins_in_row, 1236 vals = devm_kzalloc(pcs->dev, sizeof(*vals) * rows * npins_in_row,
@@ -1258,15 +1243,30 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
1258 if (!pins) 1243 if (!pins)
1259 goto free_vals; 1244 goto free_vals;
1260 1245
1261 while (index < size) { 1246 for (i = 0; i < rows; i++) {
1247 struct of_phandle_args pinctrl_spec;
1262 unsigned offset, val; 1248 unsigned offset, val;
1263 unsigned mask, bit_pos, val_pos, mask_pos, submask; 1249 unsigned mask, bit_pos, val_pos, mask_pos, submask;
1264 unsigned pin_num_from_lsb; 1250 unsigned pin_num_from_lsb;
1265 int pin; 1251 int pin;
1266 1252
1267 offset = be32_to_cpup(mux + index++); 1253 res = pinctrl_parse_index_with_args(np, name, i, &pinctrl_spec);
1268 val = be32_to_cpup(mux + index++); 1254 if (res)
1269 mask = be32_to_cpup(mux + index++); 1255 return res;
1256
1257 if (pinctrl_spec.args_count < 3) {
1258 dev_err(pcs->dev, "invalid args_count for spec: %i\n",
1259 pinctrl_spec.args_count);
1260 break;
1261 }
1262
1263 /* Index plus two value cells */
1264 offset = pinctrl_spec.args[0];
1265 val = pinctrl_spec.args[1];
1266 mask = pinctrl_spec.args[2];
1267
1268 dev_dbg(pcs->dev, "%s index: 0x%x value: 0x%x mask: 0x%x\n",
1269 pinctrl_spec.np->name, offset, val, mask);
1270 1270
1271 /* Parse pins in each row from LSB */ 1271 /* Parse pins in each row from LSB */
1272 while (mask) { 1272 while (mask) {