gpio-mmio.c (c95baf12f5077419db01313ab61c2aac007d40cd) | gpio-mmio.c (d19d2de61fb131abcd29f7c61d3f168f687bfd6e) |
---|---|
1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * Generic driver for memory-mapped GPIO controllers. 4 * 5 * Copyright 2008 MontaVista Software, Inc. 6 * Copyright 2008,2010 Anton Vorontsov <cbouatmailru@gmail.com> 7 * 8 * ....``.```~~~~````.`.`.`.`.```````'',,,.........`````......`....... --- 375 unchanged lines hidden (view full) --- 384 385 if (gc->reg_dir_in) 386 if (!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio))) 387 return GPIO_LINE_DIRECTION_OUT; 388 389 return GPIO_LINE_DIRECTION_IN; 390} 391 | 1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * Generic driver for memory-mapped GPIO controllers. 4 * 5 * Copyright 2008 MontaVista Software, Inc. 6 * Copyright 2008,2010 Anton Vorontsov <cbouatmailru@gmail.com> 7 * 8 * ....``.```~~~~````.`.`.`.`.```````'',,,.........`````......`....... --- 375 unchanged lines hidden (view full) --- 384 385 if (gc->reg_dir_in) 386 if (!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio))) 387 return GPIO_LINE_DIRECTION_OUT; 388 389 return GPIO_LINE_DIRECTION_IN; 390} 391 |
392static int bgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) | 392static void bgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) |
393{ 394 unsigned long flags; 395 | 393{ 394 unsigned long flags; 395 |
396 gc->set(gc, gpio, val); 397 | |
398 spin_lock_irqsave(&gc->bgpio_lock, flags); 399 400 gc->bgpio_dir |= bgpio_line2mask(gc, gpio); 401 402 if (gc->reg_dir_in) 403 gc->write_reg(gc->reg_dir_in, ~gc->bgpio_dir); 404 if (gc->reg_dir_out) 405 gc->write_reg(gc->reg_dir_out, gc->bgpio_dir); 406 407 spin_unlock_irqrestore(&gc->bgpio_lock, flags); | 396 spin_lock_irqsave(&gc->bgpio_lock, flags); 397 398 gc->bgpio_dir |= bgpio_line2mask(gc, gpio); 399 400 if (gc->reg_dir_in) 401 gc->write_reg(gc->reg_dir_in, ~gc->bgpio_dir); 402 if (gc->reg_dir_out) 403 gc->write_reg(gc->reg_dir_out, gc->bgpio_dir); 404 405 spin_unlock_irqrestore(&gc->bgpio_lock, flags); |
406} |
|
408 | 407 |
408static int bgpio_dir_out_dir_first(struct gpio_chip *gc, unsigned int gpio, 409 int val) 410{ 411 bgpio_dir_out(gc, gpio, val); 412 gc->set(gc, gpio, val); |
|
409 return 0; 410} 411 | 413 return 0; 414} 415 |
416static int bgpio_dir_out_val_first(struct gpio_chip *gc, unsigned int gpio, 417 int val) 418{ 419 gc->set(gc, gpio, val); 420 bgpio_dir_out(gc, gpio, val); 421 return 0; 422} 423 |
|
412static int bgpio_setup_accessors(struct device *dev, 413 struct gpio_chip *gc, 414 bool byte_be) 415{ 416 417 switch (gc->bgpio_bits) { 418 case 8: 419 gc->read_reg = bgpio_read8; --- 113 unchanged lines hidden (view full) --- 533static int bgpio_setup_direction(struct gpio_chip *gc, 534 void __iomem *dirout, 535 void __iomem *dirin, 536 unsigned long flags) 537{ 538 if (dirout || dirin) { 539 gc->reg_dir_out = dirout; 540 gc->reg_dir_in = dirin; | 424static int bgpio_setup_accessors(struct device *dev, 425 struct gpio_chip *gc, 426 bool byte_be) 427{ 428 429 switch (gc->bgpio_bits) { 430 case 8: 431 gc->read_reg = bgpio_read8; --- 113 unchanged lines hidden (view full) --- 545static int bgpio_setup_direction(struct gpio_chip *gc, 546 void __iomem *dirout, 547 void __iomem *dirin, 548 unsigned long flags) 549{ 550 if (dirout || dirin) { 551 gc->reg_dir_out = dirout; 552 gc->reg_dir_in = dirin; |
541 gc->direction_output = bgpio_dir_out; | 553 if (flags & BGPIOF_NO_SET_ON_INPUT) 554 gc->direction_output = bgpio_dir_out_dir_first; 555 else 556 gc->direction_output = bgpio_dir_out_val_first; |
542 gc->direction_input = bgpio_dir_in; 543 gc->get_direction = bgpio_get_dir; 544 } else { 545 if (flags & BGPIOF_NO_OUTPUT) 546 gc->direction_output = bgpio_dir_out_err; 547 else 548 gc->direction_output = bgpio_simple_dir_out; 549 gc->direction_input = bgpio_simple_dir_in; --- 264 unchanged lines hidden --- | 557 gc->direction_input = bgpio_dir_in; 558 gc->get_direction = bgpio_get_dir; 559 } else { 560 if (flags & BGPIOF_NO_OUTPUT) 561 gc->direction_output = bgpio_dir_out_err; 562 else 563 gc->direction_output = bgpio_simple_dir_out; 564 gc->direction_input = bgpio_simple_dir_in; --- 264 unchanged lines hidden --- |