@@ -153,6 +153,10 @@ static int bgpio_get(struct gpio_chip *gc, unsigned int gpio)
153
153
return !!(bgc -> read_reg (bgc -> reg_dat ) & bgc -> pin2mask (bgc , gpio ));
154
154
}
155
155
156
+ static void bgpio_set_none (struct gpio_chip * gc , unsigned int gpio , int val )
157
+ {
158
+ }
159
+
156
160
static void bgpio_set (struct gpio_chip * gc , unsigned int gpio , int val )
157
161
{
158
162
struct bgpio_chip * bgc = to_bgpio_chip (gc );
@@ -279,6 +283,12 @@ static int bgpio_simple_dir_in(struct gpio_chip *gc, unsigned int gpio)
279
283
return 0 ;
280
284
}
281
285
286
+ static int bgpio_dir_out_err (struct gpio_chip * gc , unsigned int gpio ,
287
+ int val )
288
+ {
289
+ return - EINVAL ;
290
+ }
291
+
282
292
static int bgpio_simple_dir_out (struct gpio_chip * gc , unsigned int gpio ,
283
293
int val )
284
294
{
@@ -460,6 +470,9 @@ static int bgpio_setup_io(struct bgpio_chip *bgc,
460
470
bgc -> reg_set = set ;
461
471
bgc -> gc .set = bgpio_set_set ;
462
472
bgc -> gc .set_multiple = bgpio_set_multiple_set ;
473
+ } else if (flags & BGPIOF_NO_OUTPUT ) {
474
+ bgc -> gc .set = bgpio_set_none ;
475
+ bgc -> gc .set_multiple = NULL ;
463
476
} else {
464
477
bgc -> gc .set = bgpio_set ;
465
478
bgc -> gc .set_multiple = bgpio_set_multiple ;
@@ -476,7 +489,8 @@ static int bgpio_setup_io(struct bgpio_chip *bgc,
476
489
477
490
static int bgpio_setup_direction (struct bgpio_chip * bgc ,
478
491
void __iomem * dirout ,
479
- void __iomem * dirin )
492
+ void __iomem * dirin ,
493
+ unsigned long flags )
480
494
{
481
495
if (dirout && dirin ) {
482
496
return - EINVAL ;
@@ -491,7 +505,10 @@ static int bgpio_setup_direction(struct bgpio_chip *bgc,
491
505
bgc -> gc .direction_input = bgpio_dir_in_inv ;
492
506
bgc -> gc .get_direction = bgpio_get_dir_inv ;
493
507
} else {
494
- bgc -> gc .direction_output = bgpio_simple_dir_out ;
508
+ if (flags & BGPIOF_NO_OUTPUT )
509
+ bgc -> gc .direction_output = bgpio_dir_out_err ;
510
+ else
511
+ bgc -> gc .direction_output = bgpio_simple_dir_out ;
495
512
bgc -> gc .direction_input = bgpio_simple_dir_in ;
496
513
}
497
514
@@ -543,7 +560,7 @@ int bgpio_init(struct bgpio_chip *bgc, struct device *dev,
543
560
if (ret )
544
561
return ret ;
545
562
546
- ret = bgpio_setup_direction (bgc , dirout , dirin );
563
+ ret = bgpio_setup_direction (bgc , dirout , dirin , flags );
547
564
if (ret )
548
565
return ret ;
549
566
0 commit comments