msm: add gpiomux api for gpio multiplex & configuration.
PATCH v3 1/5 msm: add gpiomux api for gpio multiplex & configuration.
Add the 'gpiomux' api, which addresses the following shortcomings of existing tlmm api:
- gpio power-collapse, which is managed by a peripheral processor on other targets, must be managed by the application processor on the 8x60.
- The enable/disable flag of the legacy gpio_tlmm_config api is not applicable on the 8x60, and causes confusion.
- The gpio 'direction' bits are meaningless for all func_sel configurations except for generic-gpio mode (func_sel 0), in which case the gpio_direction_* functions should be used. Having these bits in the tlmm api leads to confusion and misuse of the gpiolib api, and they have been removed in gpiomux.
- The functional api of the legacy system ran contrary to the typical use-case, which is a single massive configuration at boot. Rather than forcing hundreds of 'config' function calls, the new api allows data to be configured with a single table.
gpiomux_get and gpiomux_put are meant to be called automatically when gpio_request and gpio_free are called, giving automatic gpiomux/tlmm control to those drivers/lines with simple power profiles - in the simplest cases, an entry in the gpiomux table and the correct usage of gpiolib is all that is required to get proper gpio power control.
--- arch/arm/mach-msm/Kconfig | 2 + arch/arm/mach-msm/Makefile | 4 + arch/arm/mach-msm/gpiomux-7x00.c | 33 ++++++++ arch/arm/mach-msm/gpiomux-7x30.c | 19 +++++ arch/arm/mach-msm/gpiomux-8x50.c | 19 +++++ arch/arm/mach-msm/gpiomux-8x60.c | 27 +++++++ arch/arm/mach-msm/gpiomux-v1.h | 67 ++++++++++++++++ arch/arm/mach-msm/gpiomux-v2.h | 61 ++++++++++++++ arch/arm/mach-msm/gpiomux.c | 96 +++++++++++++++++++++++ arch/arm/mach-msm/gpiomux.h | 94 ++++++++++++++++++++++ arch/arm/mach-msm/include/mach/msm_iomap-8x60.h | 42 ++++++++++ arch/arm/mach-msm/include/mach/msm_iomap.h | 2 + 12 files changed, 466 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-msm/gpiomux-7x00.c create mode 100644 arch/arm/mach-msm/gpiomux-7x30.c create mode 100644 arch/arm/mach-msm/gpiomux-8x50.c create mode 100644 arch/arm/mach-msm/gpiomux-8x60.c create mode 100644 arch/arm/mach-msm/gpiomux-v1.h create mode 100644 arch/arm/mach-msm/gpiomux-v2.h create mode 100644 arch/arm/mach-msm/gpiomux.c create mode 100644 arch/arm/mach-msm/gpiomux.h create mode 100644 arch/arm/mach-msm/include/mach/msm_iomap-8x60.h
arch/arm/mach-msm/Kconfig +2 -0
@@ -106,4 +106,6 @@ config MSM_SMD_PKG3 config MSM_SMD bool +config MSM_V2_TLMM + bool endif
arch/arm/mach-msm/Makefile +4 -0
@@ -20,3 +20,7 @@ obj-$(CONFIG_MACH_HALIBUT) += board-halibut.o devices-msm7x00.o obj-$(CONFIG_ARCH_MSM7X30) += board-msm7x30.o devices-msm7x30.o obj-$(CONFIG_ARCH_QSD8X50) += board-qsd8x50.o devices-qsd8x50.o +obj-y += gpiomux.o +obj-$(CONFIG_ARCH_MSM7X30) += gpiomux-7x30.o gpiomux-7x00.o +obj-$(CONFIG_ARCH_QSD8X50) += gpiomux-8x50.o gpiomux-7x00.o +obj-$(CONFIG_ARCH_MSM8X60) += gpiomux-8x60.o
arch/arm/mach-msm/gpiomux-7x00.c new file +33 -0
@@ -0,0 +1,33 @@ +/* Copyright (c) 2010, Code Aurora Forum. 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 +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ +#include <linux/kernel.h> +#include "gpiomux.h" +#include "proc_comm.h" + +void __msm_gpiomux_write (unsigned gpio,gpiomux_config_t val) +{ +unsigned tlmm_config = (val & ~GPIOMUX_CTL_MASK ) | + ((gpio &0x3ff ) <<4 ); +unsigned tlmm_disable =0 ; +int rc; + + rc =msm_proc_comm (PCOM_RPC_GPIO_TLMM_CONFIG_EX , + &tlmm_config, &tlmm_disable); +if (rc) +pr_err ("%s: unexpected proc_comm failure %d: %08x %08x\n" , + __func__, rc, tlmm_config, tlmm_disable); +}
arch/arm/mach-msm/gpiomux-7x30.c new file +19 -0
@@ -0,0 +1,19 @@ +/* Copyright (c) 2010, Code Aurora Forum. 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 +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ +#include "gpiomux.h" + +struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS ] = {};
arch/arm/mach-msm/gpiomux-8x50.c new file +19 -0
@@ -0,0 +1,19 @@ +/* Copyright (c) 2010, Code Aurora Forum. 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 +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ +#include "gpiomux.h" + +struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS ] = {};
arch/arm/mach-msm/gpiomux-8x60.c new file +27 -0
@@ -0,0 +1,27 @@ +/* Copyright (c) 2010, Code Aurora Forum. 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 +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ +#include <linux/io.h> +#include <mach/msm_iomap.h> +#include "gpiomux.h" + +struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS ] = {}; + +void __msm_gpiomux_write (unsigned gpio,gpiomux_config_t val) +{ +writel (val & ~GPIOMUX_CTL_MASK , +MSM_TLMM_BASE +0x1000 + (0x10 * gpio)); +}
arch/arm/mach-msm/gpiomux-v1.h new file +67 -0
67 lines not on this page · raw message
arch/arm/mach-msm/gpiomux-v2.h new file +61 -0
61 lines not on this page · raw message
arch/arm/mach-msm/gpiomux.c new file +96 -0
96 lines not on this page · raw message
arch/arm/mach-msm/gpiomux.h new file +94 -0
94 lines not on this page · raw message
arch/arm/mach-msm/include/mach/msm_iomap-8x60.h new file +42 -0
42 lines not on this page · raw message
arch/arm/mach-msm/include/mach/msm_iomap.h +2 -0
@@ -47,6 +47,8 @@#include "msm_iomap-7x30.h" #elif defined(CONFIG_ARCH_QSD8X50 )#include "msm_iomap-8x50.h" +#elif defined(CONFIG_ARCH_MSM8X60 ) +#include "msm_iomap-8x60.h" #else #include "msm_iomap-7x00.h" #endif
Signature · 3 lines
1.7.0.4 /usr2/gbean/.signature.codeaurora.org
PATCH v3 2/5 msm: documentation: add gpiomux documentation.
--- Documentation/arm/00-INDEX | 2 + Documentation/arm/msm/gpiomux.txt | 179 +++++++++++++++++++++++++++++++++++++ 2 files changed, 181 insertions(+), 0 deletions(-) create mode 100644 Documentation/arm/msm/gpiomux.txt
Documentation/arm/00-INDEX +2 -0
@@ -6,6 +6,8 @@ Interrupts - ARM Interrupt subsystem documentation IXP2000 - Release Notes for Linux on Intel's IXP2000 Network Processor +msm + - MSM specific documentation Netwinder - Netwinder specific documentation Porting
Documentation/arm/msm/gpiomux.txt new file +179 -0
179 lines not on this page · raw message
Signature · 3 lines
1.7.0.4 /usr2/gbean/.signature.codeaurora.org
PATCH v3 3/5 msm: convert 8x50 to gpiomux.
In reply to Gregory BeanChange the gpio-init code from deprecated gpio_tlmm_config to the new gpiomux api.
--- arch/arm/mach-msm/board-qsd8x50.c | 12 ------------ arch/arm/mach-msm/gpiomux-8x50.c | 11 ++++++++++- 2 files changed, 10 insertions(+), 13 deletions(-)
arch/arm/mach-msm/board-qsd8x50.c +0 -12
@@ -35,21 +35,10 @@extern struct sys_timer msm_timer; -static struct msm_gpio uart3_config_data[] = { - {GPIO_CFG (86 ,1 ,GPIO_INPUT ,GPIO_PULL_DOWN ,GPIO_2MA ),"UART2_Rx" }, - {GPIO_CFG (87 ,1 ,GPIO_OUTPUT ,GPIO_PULL_DOWN ,GPIO_2MA ),"UART2_Tx" }, -}; -static struct platform_device *devices[]__initdata = { &msm_device_uart3, }; -static void msm8x50_init_uart3 (void ) -{ -msm_gpios_request_enable (uart3_config_data, -ARRAY_SIZE (uart3_config_data)); -} -static void __init qsd8x50_map_io (void ) {msm_map_qsd8x50_io ();
@@ -64,7 +53,6 @@ static void __init qsd8x50_init_irq(void)static void __init qsd8x50_init (void ) { -msm8x50_init_uart3 ();platform_add_devices (devices,ARRAY_SIZE (devices)); }
arch/arm/mach-msm/gpiomux-8x50.c +10 -1
@@ -16,4 +16,13 @@*/ #include "gpiomux.h" -struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS ] = {}; +struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS ] = { + [86 ] = {/* UART3 RX */ + .suspended =GPIOMUX_DRV_2MA |GPIOMUX_PULL_DOWN | +GPIOMUX_FUNC_1 |GPIOMUX_VALID , + }, + [87 ] = {/* UART3 TX */ + .suspended =GPIOMUX_DRV_2MA |GPIOMUX_PULL_DOWN | +GPIOMUX_FUNC_1 |GPIOMUX_VALID , + }, +};
Signature · 3 lines
1.7.0.4 /usr2/gbean/.signature.codeaurora.org
PATCH v3 4/5 msm: convert 7x30 to gpiomux.
In reply to Gregory BeanChange deprecated gpio_tlmm_config calls to gpiomux calls.
--- arch/arm/mach-msm/board-msm7x30.c | 20 -------------------- arch/arm/mach-msm/gpiomux-7x30.c | 21 ++++++++++++++++++++- 2 files changed, 20 insertions(+), 21 deletions(-)
arch/arm/mach-msm/board-msm7x30.c +0 -20
@@ -39,22 +39,6 @@extern struct sys_timer msm_timer; -#ifdef CONFIG_SERIAL_MSM_CONSOLE -static struct msm_gpio uart2_config_data[] = { - {GPIO_CFG (49 ,2 ,GPIO_OUTPUT ,GPIO_PULL_DOWN ,GPIO_2MA ),"UART2_RFR" }, - {GPIO_CFG (50 ,2 ,GPIO_INPUT ,GPIO_PULL_DOWN ,GPIO_2MA ),"UART2_CTS" }, - {GPIO_CFG (51 ,2 ,GPIO_INPUT ,GPIO_PULL_DOWN ,GPIO_2MA ),"UART2_Rx" }, - {GPIO_CFG (52 ,2 ,GPIO_OUTPUT ,GPIO_PULL_DOWN ,GPIO_2MA ),"UART2_Tx" }, -}; - -static void msm7x30_init_uart2 (void ) -{ -msm_gpios_request_enable (uart2_config_data, -ARRAY_SIZE (uart2_config_data)); - -} -#endif - static struct platform_device *devices[] __initdata = {#if defined(CONFIG_SERIAL_MSM ) || defined(CONFIG_MSM_SERIAL_DEBUGGER ) &msm_device_uart2,
@@ -70,10 +54,6 @@ static void __init msm7x30_init_irq(void)static void __init msm7x30_init (void ) {platform_add_devices (devices,ARRAY_SIZE (devices)); -#ifdef CONFIG_SERIAL_MSM_CONSOLE -msm7x30_init_uart2 (); -#endif - }static void __init msm7x30_map_io (void )
arch/arm/mach-msm/gpiomux-7x30.c +20 -1
@@ -16,4 +16,23 @@*/ #include "gpiomux.h" -struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS ] = {}; +struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS ] = { +#ifdef CONFIG_SERIAL_MSM_CONSOLE + [49] = { /* UART2 RFR */ + .suspended =GPIOMUX_DRV_2MA |GPIOMUX_PULL_DOWN | +GPIOMUX_FUNC_2 |GPIOMUX_VALID , + }, + [50 ] = {/* UART2 CTS */ + .suspended =GPIOMUX_DRV_2MA |GPIOMUX_PULL_DOWN | +GPIOMUX_FUNC_2 |GPIOMUX_VALID , + }, + [51 ] = {/* UART2 RX */ + .suspended =GPIOMUX_DRV_2MA |GPIOMUX_PULL_DOWN | +GPIOMUX_FUNC_2 |GPIOMUX_VALID , + }, + [52 ] = {/* UART2 TX */ + .suspended =GPIOMUX_DRV_2MA |GPIOMUX_PULL_DOWN | +GPIOMUX_FUNC_2 |GPIOMUX_VALID , + }, +#endif +};
Signature · 3 lines
1.7.0.4 /usr2/gbean/.signature.codeaurora.org
PATCH v3 5/5 msm: gpio: Remove tlmm routines obsoleted by gpiomux.
In reply to Gregory BeanNow that all supported gpio_tlmm_config-using boards are using gpiomux, remove the deprecated code.
--- arch/arm/mach-msm/Makefile | 1 - arch/arm/mach-msm/gpio.c | 85 ----------------------- arch/arm/mach-msm/include/mach/gpio.h | 123 --------------------------------- 3 files changed, 0 insertions(+), 209 deletions(-) delete mode 100644 arch/arm/mach-msm/gpio.c
arch/arm/mach-msm/Makefile +0 -1
@@ -3,7 +3,6 @@ obj-y += io.o idle.o timer.o dma.o obj-y += vreg.o obj-y += acpuclock-arm11.o obj-y += clock.o clock-pcom.o -obj-y += gpio.o ifdef CONFIG_MSM_VIC obj-y += irq-vic.o
arch/arm/mach-msm/gpio.c deleted +0 -85
85 lines not on this page · raw message
arch/arm/mach-msm/include/mach/gpio.h +0 -123
127 lines not on this page · raw message
Signature · 3 lines
1.7.0.4 /usr2/gbean/.signature.codeaurora.org
arch/arm/mach-msm/Makefile obj-$(CONFIG_MACH_HALIBUT) += board-halibut.o devices-msm7x00.o · line 26
Quoted 4 lines · Gregory Bean
arch/arm/mach-msm/Makefile +4
-0+obj-y += gpiomux.o +obj-$(CONFIG_ARCH_MSM7X30) += gpiomux-7x30.o gpiomux-7x00.o +obj-$(CONFIG_ARCH_QSD8X50) += gpiomux-8x50.o gpiomux-7x00.o +obj-$(CONFIG_ARCH_MSM8X60) += gpiomux-8x60.o
Is this right? I got a built failure before 7x00 isn't in the list..
Daniel
Signature · 3 lines
Sent by an consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.