msm: Install the Google-Android gpio driver.
Subsystems (3)
PATCH v2 1/2 msm: Install the Google-Android gpio driver.
As part of the ongoing effort to converge on a common code base, adopt the Google-Android msmgpio driver, as it has a stronger pedigree than the previous submission from codeaurora.
Based on work by folks at Google, including Brian Swetland and Arve Hj?nnev?g.
--- arch/arm/mach-msm/Makefile | 3 + arch/arm/mach-msm/gpio.c | 479 +++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-msm/gpio_hw.h | 278 +++++++++++++++++++++++++ 3 files changed, 760 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-msm/gpio.c create mode 100644 arch/arm/mach-msm/gpio_hw.h
arch/arm/mach-msm/Makefile +3 -0
@@ -22,3 +22,6 @@ obj-$(CONFIG_ARCH_QSD8X50) += board-qsd8x50.o devices-qsd8x50.o obj-$(CONFIG_ARCH_MSM7X30) += gpiomux-7x30.o gpiomux-v1.o gpiomux.o obj-$(CONFIG_ARCH_QSD8X50) += gpiomux-8x50.o gpiomux-v1.o gpiomux.o obj-$(CONFIG_ARCH_MSM8X60) += gpiomux-8x60.o gpiomux-v2.o gpiomux.o +ifndef CONFIG_MSM_V2_TLMM +obj-y += gpio.o +endif
arch/arm/mach-msm/gpio.c new file +479 -0
479 lines not on this page · raw message
arch/arm/mach-msm/gpio_hw.h new file +278 -0
278 lines not on this page · raw message
Signature · 5 lines
1.7.0.4 -- Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v2 2/2 msm: gpio: Add gpiomux calls to request and free.
Add gpiomux get and put calls to msmgpio request and free, in order to allow gpio lines to be properly reference-counted and power-managed.
--- arch/arm/mach-msm/gpio.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-)
arch/arm/mach-msm/gpio.c +18 -0
@@ -21,6 +21,7 @@#include <linux/irq.h> #include <linux/module.h> #include "gpio_hw.h" +#include "gpiomux.h" #include "proc_comm.h" #include "smd_private.h"
@@ -46,6 +47,8 @@ .direction_input = msm_gpio_direction_input, \ .direction_output = msm_gpio_direction_output, \ .to_irq = msm_gpio_to_irq, \ + .request = msm_gpio_request, \ + .free = msm_gpio_free, \ } \ }
@@ -180,6 +183,21 @@ static int msm_gpio_to_irq(struct gpio_chip *chip, unsigned offset)return MSM_GPIO_TO_INT (chip->base + offset); } +#ifdef CONFIG_MSM_GPIOMUX +static int msm_gpio_request (struct gpio_chip *chip,unsigned offset) +{ +return msm_gpiomux_get (chip->base + offset); +} + +static void msm_gpio_free (struct gpio_chip *chip,unsigned offset) +{ +msm_gpiomux_put (chip->base + offset); +} +#else +#define msm_gpio_request NULL +#define msm_gpio_free NULL +#endif + struct msm_gpio_chip msm_gpio_chips[] = {#if defined(CONFIG_ARCH_MSM7X00A ) MSM_GPIO_BANK(0, 0, 15),
Signature · 5 lines
1.7.0.4 -- Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Quoted 5 lines · Gregory Bean
arch/arm/mach-msm/gpio.c new file +5
-0+void msm_gpio_enter_sleep (int from_idle) +{ +int i; +struct tramp_gpio_smem *smem_gpio; +
arch/arm/mach-msm/gpio.c line 389
Quoted 10 lines
arch/arm/mach-msm/gpio.c new file +10
-0+ smem_gpio =smem_alloc (SMEM_GPIO_INT ,sizeof (*smem_gpio)); + +if (smem_gpio) { +for (i =0 ; i <ARRAY_SIZE (smem_gpio->enabled); i++) { + smem_gpio->enabled[i] =0 ; + smem_gpio->detection[i] =0 ; + smem_gpio->polarity[i] =0 ; + } + } +
Can you not drop these for some reason ?
Daniel
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Quoted 70 lines · Gregory Bean
As part of the ongoing effort to converge on a common code base, adopt the Google-Android msmgpio driver, as it has a stronger pedigree than the previous submission from codeaurora.
Based on work by folks at Google, including Brian Swetland and Arve Hj?nnev?g.Cc Arve Hj?nnev?g <[email protected]>Signed-off-by Gregory Bean <[email protected]>--- arch/arm/mach-msm/Makefile | 3 + arch/arm/mach-msm/gpio.c | 479 +++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-msm/gpio_hw.h | 278 +++++++++++++++++++++++++ 3 files changed, 760 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-msm/gpio.c create mode 100644 arch/arm/mach-msm/gpio_hw.harch/arm/mach-msm/Makefile +3
-0@@ -22,3 +22,6 @@ obj-$(CONFIG_ARCH_QSD8X50) += board-qsd8x50.o devices-qsd8x50.o obj-$(CONFIG_ARCH_MSM7X30) += gpiomux-7x30.o gpiomux-v1.o gpiomux.o obj-$(CONFIG_ARCH_QSD8X50) += gpiomux-8x50.o gpiomux-v1.o gpiomux.o obj-$(CONFIG_ARCH_MSM8X60) += gpiomux-8x60.o gpiomux-v2.o gpiomux.o +ifndef CONFIG_MSM_V2_TLMM +obj-y += gpio.o +endifarch/arm/mach-msm/gpio.c new file +38
-0@@ -0,0 +1,479 @@ +/* linux/arch/arm/mach-msm/gpio.c +* +* Copyright (C) 2007 Google, Inc. +* Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved. +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +* +*/ + +#include <linux/bitops.h> +#include <linux/gpio.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/irq.h> +#include <linux/module.h> +#include "gpio_hw.h" +#include "proc_comm.h" +#include "smd_private.h" + +#define FIRST_GPIO_IRQ MSM_GPIO_TO_INT(0) + +#define MSM_GPIO_BANK (bank, first, last) \ + { \ + .regs = { \ + .out = MSM_GPIO_OUT_##bank, \ + .in = MSM_GPIO_IN_##bank, \ + .int_status = MSM_GPIO_INT_STATUS_##bank, \ + .int_clear = MSM_GPIO_INT_CLEAR_##bank, \ + .int_en = MSM_GPIO_INT_EN_##bank, \ + .int_edge = MSM_GPIO_INT_EDGE_##bank, \ + .int_pos = MSM_GPIO_INT_POS_##bank, \
arch/arm/mach-msm/gpio.c line 48
Quoted 10 lines
arch/arm/mach-msm/gpio.c new file +10
-0+ .oe = MSM_GPIO_OE_##bank, \ + }, \ + .chip = { \ + .base = (first), \ + .ngpio = (last) - (first) + 1, \ + .get = msm_gpio_get, \ + .set = msm_gpio_set, \ + .direction_input = msm_gpio_direction_input, \ + .direction_output = msm_gpio_direction_output, \ + .to_irq = msm_gpio_to_irq, \
if you're stuffing things like this into macros, maybe you should just set them at initialisation time, it will make the macro smaller.
[snip]
arch/arm/mach-msm/gpio.c line 87
Quoted 5 lines
arch/arm/mach-msm/gpio.c new file +5
-0+static int msm_gpio_write (struct msm_gpio_chip *msm_chip, +unsigned offset,unsigned on) +{ +unsigned b =1U << offset; +unsigned v;
how about making these a bit more descrptive? change b for bit, and v for val?
Quoted 55 lines
arch/arm/mach-msm/gpio_hw.h new file +49
-0@@ -0,0 +1,278 @@ +/* arch/arm/mach-msm/gpio_hw.h +* +* Copyright (C) 2007 Google, Inc. +* Author: Brian Swetland <[email protected]> +* Copyright (c) 2008-2010, Code Aurora Forum. All rights reserved. +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +* +*/ + +#ifndef __ARCH_ARM_MACH_MSM_GPIO_HW_H +#define __ARCH_ARM_MACH_MSM_GPIO_HW_H + +#include <mach/msm_iomap.h> + +/* see 80-VA736-2 Rev C pp 695-751 +** +** These are actually the *shadow* gpio registers, since the +** real ones (which allow full access) are only available to the +** ARM9 side of the world. +** +** Since the _BASE need to be page-aligned when we're mapping them +** to virtual addresses, adjust for the additional offset in these +** macros. +*/ + +#if defined(CONFIG_ARCH_MSM7X30 ) +#define MSM_GPIO1_REG (off) (MSM_GPIO1_BASE + (off)) +#define MSM_GPIO2_REG (off) (MSM_GPIO2_BASE + 0x400 + (off)) +#else +#define MSM_GPIO1_REG (off) (MSM_GPIO1_BASE + 0x800 + (off)) +#define MSM_GPIO2_REG (off) (MSM_GPIO2_BASE + 0xC00 + (off)) +#endif + +#if defined(CONFIG_ARCH_MSM7X00A ) || defined(CONFIG_ARCH_MSM7X25 ) ||\ + defined(CONFIG_ARCH_MSM7X27 ) + +/* output value */ +#define MSM_GPIO_OUT_0 MSM_GPIO1_REG(0x00)/* gpio 15-0 */ +#define MSM_GPIO_OUT_1 MSM_GPIO2_REG(0x00)/* gpio 42-16 */ +#define MSM_GPIO_OUT_2 MSM_GPIO1_REG(0x04)/* gpio 67-43 */ +#define MSM_GPIO_OUT_3 MSM_GPIO1_REG(0x08)/* gpio 94-68 */
arch/arm/mach-msm/gpio_hw.h line 59
Quoted 10 lines
arch/arm/mach-msm/gpio_hw.h new file +10
-0+#define MSM_GPIO_OUT_4 MSM_GPIO1_REG(0x0C)/* gpio 106-95 */ +#define MSM_GPIO_OUT_5 MSM_GPIO1_REG(0x50)/* gpio 107-121 */ + +/* same pin map as above, output enable */ +#define MSM_GPIO_OE_0 MSM_GPIO1_REG(0x10) +#define MSM_GPIO_OE_1 MSM_GPIO2_REG(0x08) +#define MSM_GPIO_OE_2 MSM_GPIO1_REG(0x14) +#define MSM_GPIO_OE_3 MSM_GPIO1_REG(0x18) +#define MSM_GPIO_OE_4 MSM_GPIO1_REG(0x1C) +#define MSM_GPIO_OE_5 MSM_GPIO1_REG(0x54)
do we need each and every register defined in the header? would simply the base of each gpio bank make this header file much smaller? or turn it into MSM_GPIO_OE(x) ?
arch/arm/mach-msm/gpio_hw.h line 111
Quoted 1 line
arch/arm/mach-msm/gpio_hw.h new file +1
-0+#if defined(CONFIG_ARCH_QSD8X50 )
this sort of #ifdef makes me want to punch people repeatedly until they do a better job of designing these things in the first place. It makes it so hard to get multiple different SoCs compiling into the kernel.
Signature · 4 lines
Ben Q: What's a light-year? A: One-third less calories than a regular year.
Quoted 10 lines
Quoted 10 lines
arch/arm/mach-msm/gpio_hw.h new file +10
-0+#define MSM_GPIO_OUT_0 MSM_GPIO1_REG(0x00)/* gpio 15-0 */ +#define MSM_GPIO_OUT_1 MSM_GPIO2_REG(0x00)/* gpio 42-16 */ +#define MSM_GPIO_OUT_2 MSM_GPIO1_REG(0x04)/* gpio 67-43 */ +#define MSM_GPIO_OUT_3 MSM_GPIO1_REG(0x08)/* gpio 94-68 */ +#define MSM_GPIO_OUT_4 MSM_GPIO1_REG(0x0C)/* gpio 106-95 */ +#define MSM_GPIO_OUT_5 MSM_GPIO1_REG(0x50)/* gpio 107-121 */ + +/* same pin map as above, output enable */ +#define MSM_GPIO_OE_0 MSM_GPIO1_REG(0x10) +#define MSM_GPIO_OE_1 MSM_GPIO2_REG(0x08)
Quoted 8 lines
arch/arm/mach-msm/gpio_hw.h line 59
Quoted 4 lines
arch/arm/mach-msm/gpio_hw.h new file +4
-0+#define MSM_GPIO_OE_2 MSM_GPIO1_REG(0x14) +#define MSM_GPIO_OE_3 MSM_GPIO1_REG(0x18) +#define MSM_GPIO_OE_4 MSM_GPIO1_REG(0x1C) +#define MSM_GPIO_OE_5 MSM_GPIO1_REG(0x54)do we need each and every register defined in the header? would simply the base of each gpio bank make this header file much smaller? or turn it into
MSM_GPIO_OE(x)?
Unfortunately, the registers are not regularly spaced. There are small sections of regularity, but special cases abound. I could produce macros or functions to calculate them, but I fear that they'd be so full of conditionals that the net gain would be negligible, or worse.
Signature · 2 lines
Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.