diff options
author | Russell King <rmk+kernel@armlinux.org.uk> | 2016-08-31 03:49:52 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@armlinux.org.uk> | 2019-06-04 07:56:36 -0400 |
commit | 59f06d674f380644fb85b14a1eb7259ef291eb7b (patch) | |
tree | 2a810370dd2e08a517c2b23f51f2cd98748cf1ed /arch/arm/mach-sa1100 | |
parent | 0faf70ca948a506b7fbd1a245b46b0eeae628702 (diff) |
ARM: sa1100/assabet: convert serial to gpiod APIs
Convert the Assabet serial modem control signals to use the gpiod APIs
rather than custom callbacks into platform code.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Diffstat (limited to 'arch/arm/mach-sa1100')
-rw-r--r-- | arch/arm/mach-sa1100/assabet.c | 91 |
1 files changed, 28 insertions, 63 deletions
diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c index d09c3f236186..bc035821a42b 100644 --- a/arch/arm/mach-sa1100/assabet.c +++ b/arch/arm/mach-sa1100/assabet.c | |||
@@ -522,6 +522,29 @@ static const struct gpio_keys_platform_data assabet_keys_pdata = { | |||
522 | .rep = 0, | 522 | .rep = 0, |
523 | }; | 523 | }; |
524 | 524 | ||
525 | static struct gpiod_lookup_table assabet_uart1_gpio_table = { | ||
526 | .dev_id = "sa11x0-uart.1", | ||
527 | .table = { | ||
528 | GPIO_LOOKUP("assabet", 16, "dtr", GPIO_ACTIVE_LOW), | ||
529 | GPIO_LOOKUP("assabet", 17, "rts", GPIO_ACTIVE_LOW), | ||
530 | GPIO_LOOKUP("assabet", 25, "dcd", GPIO_ACTIVE_LOW), | ||
531 | GPIO_LOOKUP("assabet", 26, "cts", GPIO_ACTIVE_LOW), | ||
532 | GPIO_LOOKUP("assabet", 27, "dsr", GPIO_ACTIVE_LOW), | ||
533 | { }, | ||
534 | }, | ||
535 | }; | ||
536 | |||
537 | static struct gpiod_lookup_table assabet_uart3_gpio_table = { | ||
538 | .dev_id = "sa11x0-uart.3", | ||
539 | .table = { | ||
540 | GPIO_LOOKUP("assabet", 28, "cts", GPIO_ACTIVE_LOW), | ||
541 | GPIO_LOOKUP("assabet", 29, "dsr", GPIO_ACTIVE_LOW), | ||
542 | GPIO_LOOKUP("assabet", 30, "dcd", GPIO_ACTIVE_LOW), | ||
543 | GPIO_LOOKUP("assabet", 31, "rng", GPIO_ACTIVE_LOW), | ||
544 | { }, | ||
545 | }, | ||
546 | }; | ||
547 | |||
525 | static void __init assabet_init(void) | 548 | static void __init assabet_init(void) |
526 | { | 549 | { |
527 | /* | 550 | /* |
@@ -568,7 +591,10 @@ static void __init assabet_init(void) | |||
568 | neponset_resources, ARRAY_SIZE(neponset_resources)); | 591 | neponset_resources, ARRAY_SIZE(neponset_resources)); |
569 | #endif | 592 | #endif |
570 | } else { | 593 | } else { |
594 | gpiod_add_lookup_table(&assabet_uart1_gpio_table); | ||
595 | gpiod_add_lookup_table(&assabet_uart3_gpio_table); | ||
571 | gpiod_add_lookup_table(&assabet_cf_vcc_gpio_table); | 596 | gpiod_add_lookup_table(&assabet_cf_vcc_gpio_table); |
597 | |||
572 | sa11x0_register_fixed_regulator(0, &assabet_cf_vcc_pdata, | 598 | sa11x0_register_fixed_regulator(0, &assabet_cf_vcc_pdata, |
573 | assabet_cf_vcc_consumers, | 599 | assabet_cf_vcc_consumers, |
574 | ARRAY_SIZE(assabet_cf_vcc_consumers), | 600 | ARRAY_SIZE(assabet_cf_vcc_consumers), |
@@ -658,74 +684,13 @@ static void assabet_uart_pm(struct uart_port *port, u_int state, u_int oldstate) | |||
658 | { | 684 | { |
659 | if (port->mapbase == _Ser1UTCR0) { | 685 | if (port->mapbase == _Ser1UTCR0) { |
660 | if (state) | 686 | if (state) |
661 | ASSABET_BCR_clear(ASSABET_BCR_RS232EN | | 687 | ASSABET_BCR_clear(ASSABET_BCR_RS232EN); |
662 | ASSABET_BCR_COM_RTS | | ||
663 | ASSABET_BCR_COM_DTR); | ||
664 | else | ||
665 | ASSABET_BCR_set(ASSABET_BCR_RS232EN | | ||
666 | ASSABET_BCR_COM_RTS | | ||
667 | ASSABET_BCR_COM_DTR); | ||
668 | } | ||
669 | } | ||
670 | |||
671 | /* | ||
672 | * Assabet uses COM_RTS and COM_DTR for both UART1 (com port) | ||
673 | * and UART3 (radio module). We only handle them for UART1 here. | ||
674 | */ | ||
675 | static void assabet_set_mctrl(struct uart_port *port, u_int mctrl) | ||
676 | { | ||
677 | if (port->mapbase == _Ser1UTCR0) { | ||
678 | u_int set = 0, clear = 0; | ||
679 | |||
680 | if (mctrl & TIOCM_RTS) | ||
681 | clear |= ASSABET_BCR_COM_RTS; | ||
682 | else | 688 | else |
683 | set |= ASSABET_BCR_COM_RTS; | 689 | ASSABET_BCR_set(ASSABET_BCR_RS232EN); |
684 | |||
685 | if (mctrl & TIOCM_DTR) | ||
686 | clear |= ASSABET_BCR_COM_DTR; | ||
687 | else | ||
688 | set |= ASSABET_BCR_COM_DTR; | ||
689 | |||
690 | ASSABET_BCR_clear(clear); | ||
691 | ASSABET_BCR_set(set); | ||
692 | } | ||
693 | } | ||
694 | |||
695 | static u_int assabet_get_mctrl(struct uart_port *port) | ||
696 | { | ||
697 | u_int ret = 0; | ||
698 | u_int bsr = ASSABET_BSR; | ||
699 | |||
700 | /* need 2 reads to read current value */ | ||
701 | bsr = ASSABET_BSR; | ||
702 | |||
703 | if (port->mapbase == _Ser1UTCR0) { | ||
704 | if (bsr & ASSABET_BSR_COM_DCD) | ||
705 | ret |= TIOCM_CD; | ||
706 | if (bsr & ASSABET_BSR_COM_CTS) | ||
707 | ret |= TIOCM_CTS; | ||
708 | if (bsr & ASSABET_BSR_COM_DSR) | ||
709 | ret |= TIOCM_DSR; | ||
710 | } else if (port->mapbase == _Ser3UTCR0) { | ||
711 | if (bsr & ASSABET_BSR_RAD_DCD) | ||
712 | ret |= TIOCM_CD; | ||
713 | if (bsr & ASSABET_BSR_RAD_CTS) | ||
714 | ret |= TIOCM_CTS; | ||
715 | if (bsr & ASSABET_BSR_RAD_DSR) | ||
716 | ret |= TIOCM_DSR; | ||
717 | if (bsr & ASSABET_BSR_RAD_RI) | ||
718 | ret |= TIOCM_RI; | ||
719 | } else { | ||
720 | ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR; | ||
721 | } | 690 | } |
722 | |||
723 | return ret; | ||
724 | } | 691 | } |
725 | 692 | ||
726 | static struct sa1100_port_fns assabet_port_fns __initdata = { | 693 | static struct sa1100_port_fns assabet_port_fns __initdata = { |
727 | .set_mctrl = assabet_set_mctrl, | ||
728 | .get_mctrl = assabet_get_mctrl, | ||
729 | .pm = assabet_uart_pm, | 694 | .pm = assabet_uart_pm, |
730 | }; | 695 | }; |
731 | 696 | ||