3535#include "pinconf.h"
3636
3737#define DRIVER_NAME "pinctrl-single"
38- #define PCS_MUX_BITS_NAME "pinctrl-single,bits"
3938#define PCS_OFF_DISABLED ~0U
4039
4140/**
@@ -1216,36 +1215,22 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs,
12161215 return res ;
12171216}
12181217
1219- #define PARAMS_FOR_BITS_PER_MUX 3
1220-
12211218static int pcs_parse_bits_in_pinctrl_entry (struct pcs_device * pcs ,
12221219 struct device_node * np ,
12231220 struct pinctrl_map * * map ,
12241221 unsigned * num_maps ,
12251222 const char * * pgnames )
12261223{
1224+ const char * name = "pinctrl-single,pins" ;
12271225 struct pcs_func_vals * vals ;
1228- const __be32 * mux ;
1229- int size , rows , * pins , index = 0 , found = 0 , res = - ENOMEM ;
1226+ int rows , * pins , found = 0 , res = - ENOMEM , i ;
12301227 int npins_in_row ;
12311228 struct pcs_function * function ;
12321229
1233- mux = of_get_property (np , PCS_MUX_BITS_NAME , & size );
1234-
1235- if (!mux ) {
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 );
1230+ rows = pinctrl_count_index_with_args (np , name );
1231+ if (rows == - EINVAL )
1232+ return rows ;
12471233
1248- rows = size / PARAMS_FOR_BITS_PER_MUX ;
12491234 npins_in_row = pcs -> width / pcs -> bits_per_pin ;
12501235
12511236 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,
12581243 if (!pins )
12591244 goto free_vals ;
12601245
1261- while (index < size ) {
1246+ for (i = 0 ; i < rows ; i ++ ) {
1247+ struct of_phandle_args pinctrl_spec ;
12621248 unsigned offset , val ;
12631249 unsigned mask , bit_pos , val_pos , mask_pos , submask ;
12641250 unsigned pin_num_from_lsb ;
12651251 int pin ;
12661252
1267- offset = be32_to_cpup (mux + index ++ );
1268- val = be32_to_cpup (mux + index ++ );
1269- mask = be32_to_cpup (mux + index ++ );
1253+ res = pinctrl_parse_index_with_args (np , name , i , & pinctrl_spec );
1254+ if (res )
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 );
12701270
12711271 /* Parse pins in each row from LSB */
12721272 while (mask ) {
0 commit comments