msm_serial_hs: Cleanup code to configure/unconfigure UART GPIOs
With current approach UART GPIOs are configure/unconfigure from
board files by using GPIOLib APIs. UART driver uses gpio_config
pdata based function pointer to call per uart device related API
from board file for the same. Hence correct this approach and
pass only UART GPIOs numbers to UART driver using pdata and
configure/unconfigure those GPIOs using GPIOLib APIs once UART
port is being opened and closed respectively.
CRs-Fixed: 460961
Change-Id: I4bb007b2b476525cb50dd2eb5788c735aae0e32d
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
diff --git a/arch/arm/mach-msm/board-8064.c b/arch/arm/mach-msm/board-8064.c
index 9b127ba..81aac6e 100644
--- a/arch/arm/mach-msm/board-8064.c
+++ b/arch/arm/mach-msm/board-8064.c
@@ -2617,34 +2617,14 @@
late_initcall(rf4ce_gpio_init);
#ifdef CONFIG_SERIAL_MSM_HS
-static int configure_uart_gpios(int on)
-{
- int ret = 0, i;
- int uart_gpios[] = {14, 15, 16, 17};
-
- for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
- if (on) {
- ret = gpio_request(uart_gpios[i], NULL);
- if (ret) {
- pr_err("%s:unable to request uart gpio[%d]\n",
- __func__, uart_gpios[i]);
- break;
- }
- } else {
- gpio_free(uart_gpios[i]);
- }
- }
-
- if (ret && on && i)
- for (; i >= 0; i--)
- gpio_free(uart_gpios[i]);
- return ret;
-}
-
static struct msm_serial_hs_platform_data mpq8064_gsbi6_uartdm_pdata = {
+ .config_gpio = 4,
+ .uart_tx_gpio = 14,
+ .uart_rx_gpio = 15,
+ .uart_cts_gpio = 16,
+ .uart_rfr_gpio = 17,
.inject_rx_on_wakeup = 1,
.rx_to_inject = 0xFD,
- .gpio_config = configure_uart_gpios,
};
#else
static struct msm_serial_hs_platform_data msm_uart_dm9_pdata;
@@ -3214,32 +3194,12 @@
}
#ifdef CONFIG_SERIAL_MSM_HS
-static int configure_uartdm_gsbi4_gpios(int on)
-{
- int ret = 0, i;
- int uart_gpios[] = {10, 11, 12, 13};
-
- for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
- if (on) {
- ret = gpio_request(uart_gpios[i], NULL);
- if (ret) {
- pr_err("%s: unable to request uart gpio[%d]\n",
- __func__, uart_gpios[i]);
- break;
- }
- } else {
- gpio_free(uart_gpios[i]);
- }
- }
-
- if (ret && on && i)
- for (; i >= 0; i--)
- gpio_free(uart_gpios[i]);
- return ret;
-}
-
static struct msm_serial_hs_platform_data apq8064_uartdm_gsbi4_pdata = {
- .gpio_config = configure_uartdm_gsbi4_gpios,
+ .config_gpio = 4,
+ .uart_tx_gpio = 10,
+ .uart_rx_gpio = 11,
+ .uart_cts_gpio = 12,
+ .uart_rfr_gpio = 13,
};
#else
static struct msm_serial_hs_platform_data apq8064_uartdm_gsbi4_pdata;
diff --git a/arch/arm/mach-msm/board-8930.c b/arch/arm/mach-msm/board-8930.c
index 4f01ba9..b729e62 100644
--- a/arch/arm/mach-msm/board-8930.c
+++ b/arch/arm/mach-msm/board-8930.c
@@ -2891,32 +2891,12 @@
}
#ifdef CONFIG_SERIAL_MSM_HS
-static int configure_uart_gpios(int on)
-{
- int ret = 0, i;
- int uart_gpios[] = {93, 94, 95, 96};
-
- for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
- if (on) {
- ret = gpio_request(uart_gpios[i], NULL);
- if (ret) {
- pr_err("%s: unable to request uart gpio[%d]\n",
- __func__, uart_gpios[i]);
- break;
- }
- } else {
- gpio_free(uart_gpios[i]);
- }
- }
-
- if (ret && on && i)
- for (; i >= 0; i--)
- gpio_free(uart_gpios[i]);
- return ret;
-}
-
static struct msm_serial_hs_platform_data msm_uart_dm9_pdata = {
- .gpio_config = configure_uart_gpios,
+ .config_gpio = 4,
+ .uart_tx_gpio = 93,
+ .uart_rx_gpio = 94,
+ .uart_cts_gpio = 95,
+ .uart_rfr_gpio = 96,
};
#else
static struct msm_serial_hs_platform_data msm_uart_dm9_pdata;
diff --git a/arch/arm/mach-msm/board-8960.c b/arch/arm/mach-msm/board-8960.c
index ac3e9f1..69a91c9 100644
--- a/arch/arm/mach-msm/board-8960.c
+++ b/arch/arm/mach-msm/board-8960.c
@@ -2589,60 +2589,20 @@
},
};
#ifdef CONFIG_SERIAL_MSM_HS
-static int configure_uart_gpios(int on)
-{
- int ret = 0, i;
- int uart_gpios[] = {93, 94, 95, 96};
-
- for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
- if (on) {
- ret = gpio_request(uart_gpios[i], NULL);
- if (ret) {
- pr_err("%s: unable to request uart gpio[%d]\n",
- __func__, uart_gpios[i]);
- break;
- }
- } else {
- gpio_free(uart_gpios[i]);
- }
- }
-
- if (ret && on && i)
- for (; i >= 0; i--)
- gpio_free(uart_gpios[i]);
- return ret;
-}
-
static struct msm_serial_hs_platform_data msm_uart_dm9_pdata = {
- .gpio_config = configure_uart_gpios,
+ .config_gpio = 4,
+ .uart_tx_gpio = 93,
+ .uart_rx_gpio = 94,
+ .uart_cts_gpio = 95,
+ .uart_rfr_gpio = 96,
};
-static int configure_gsbi8_uart_gpios(int on)
-{
- int ret = 0, i;
- int uart_gpios[] = {34, 35, 36, 37};
-
- for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
- if (on) {
- ret = gpio_request(uart_gpios[i], NULL);
- if (ret) {
- pr_err("%s: unable to request uart gpio[%d]\n",
- __func__, uart_gpios[i]);
- break;
- }
- } else {
- gpio_free(uart_gpios[i]);
- }
- }
-
- if (ret && on && i)
- for (; i >= 0; i--)
- gpio_free(uart_gpios[i]);
- return ret;
-}
-
static struct msm_serial_hs_platform_data msm_uart_dm8_pdata = {
- .gpio_config = configure_gsbi8_uart_gpios,
+ .config_gpio = 4,
+ .uart_tx_gpio = 34,
+ .uart_rx_gpio = 35,
+ .uart_cts_gpio = 36,
+ .uart_rfr_gpio = 37,
};
#else
static struct msm_serial_hs_platform_data msm_uart_dm8_pdata;
diff --git a/arch/arm/mach-msm/board-msm8x60.c b/arch/arm/mach-msm/board-msm8x60.c
index 7c502d9..f2f41cf 100644
--- a/arch/arm/mach-msm/board-msm8x60.c
+++ b/arch/arm/mach-msm/board-msm8x60.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -3600,30 +3600,14 @@
};
#ifdef CONFIG_SERIAL_MSM_HS
-static int configure_uart_gpios(int on)
-{
- int ret = 0, i;
- int uart_gpios[] = {53, 54, 55, 56};
- for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
- if (on) {
- ret = msm_gpiomux_get(uart_gpios[i]);
- if (unlikely(ret))
- break;
- } else {
- ret = msm_gpiomux_put(uart_gpios[i]);
- if (unlikely(ret))
- return ret;
- }
- }
- if (ret)
- for (; i >= 0; i--)
- msm_gpiomux_put(uart_gpios[i]);
- return ret;
-}
static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
- .inject_rx_on_wakeup = 1,
- .rx_to_inject = 0xFD,
- .gpio_config = configure_uart_gpios,
+ .inject_rx_on_wakeup = 1,
+ .rx_to_inject = 0xFD,
+ .config_gpio = 4,
+ .uart_tx_gpio = 53,
+ .uart_rx_gpio = 54,
+ .uart_cts_gpio = 55,
+ .uart_rfr_gpio = 56,
};
#endif
diff --git a/arch/arm/mach-msm/include/mach/msm_serial_hs.h b/arch/arm/mach-msm/include/mach/msm_serial_hs.h
index d2905d4..d4223d1 100644
--- a/arch/arm/mach-msm/include/mach/msm_serial_hs.h
+++ b/arch/arm/mach-msm/include/mach/msm_serial_hs.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2008 Google, Inc.
+ * Copyright (C) 2010-2013, The Linux Foundation. All rights reserved.
* Author: Nick Pelly <npelly@google.com>
*
* This software is licensed under the terms of the GNU General Public
@@ -17,14 +18,32 @@
#include<linux/serial_core.h>
-/* Optional platform device data for msm_serial_hs driver.
- * Used to configure low power wakeup */
+/**
+ * struct msm_serial_hs_platform_data - platform device data
+ * for msm hsuart device
+ * @wakeup_irq : IRQ line to be configured as Wakeup source.
+ * @inject_rx_on_wakeup : Set 1 if specific character to be inserted on wakeup
+ * @rx_to_inject : Character to be inserted on wakeup
+ * @config_gpio : Pass number of GPIOs to configure
+ (2 for 2-wire UART, 4 for 4-wire UART)
+ * @userid : User-defined number to be used to enumerate device as tty<userid>
+ * @uart_tx_gpio: GPIO number for UART Tx Line.
+ * @uart_rx_gpio: GPIO number for UART Rx Line.
+ * @uart_cts_gpio: GPIO number for UART CTS Line.
+ * @uart_rfr_gpio: GPIO number for UART RFR Line.
+ * @userid: Number to be used as ttyHS<userid> instead of ttyHS<id>
+*/
+
struct msm_serial_hs_platform_data {
int wakeup_irq; /* wakeup irq */
/* bool: inject char into rx tty on wakeup */
unsigned char inject_rx_on_wakeup;
char rx_to_inject;
- int (*gpio_config)(int);
+ unsigned config_gpio;
+ int uart_tx_gpio;
+ int uart_rx_gpio;
+ int uart_cts_gpio;
+ int uart_rfr_gpio;
int userid;
};