gpio.h 3.6 KB
Newer Older
L
Linus Torvalds 已提交
1
/*
2
 * arch/arm/plat-omap/include/mach/gpio.h
L
Linus Torvalds 已提交
3 4 5
 *
 * OMAP GPIO handling defines and functions
 *
6
 * Copyright (C) 2003-2005 Nokia Corporation
L
Linus Torvalds 已提交
7
 *
8
 * Written by Juha Yrjölä <juha.yrjola@nokia.com>
L
Linus Torvalds 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */

#ifndef __ASM_ARCH_OMAP_GPIO_H
#define __ASM_ARCH_OMAP_GPIO_H

29
#include <linux/io.h>
30
#include <mach/irqs.h>
L
Linus Torvalds 已提交
31

32
#define OMAP1_MPUIO_BASE			0xfffb5000
33

34 35
#if (defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850))

36 37 38 39 40 41 42 43 44 45 46 47 48 49
#define OMAP_MPUIO_INPUT_LATCH		0x00
#define OMAP_MPUIO_OUTPUT		0x02
#define OMAP_MPUIO_IO_CNTL		0x04
#define OMAP_MPUIO_KBR_LATCH		0x08
#define OMAP_MPUIO_KBC			0x0a
#define OMAP_MPUIO_GPIO_EVENT_MODE	0x0c
#define OMAP_MPUIO_GPIO_INT_EDGE	0x0e
#define OMAP_MPUIO_KBD_INT		0x10
#define OMAP_MPUIO_GPIO_INT		0x12
#define OMAP_MPUIO_KBD_MASKIT		0x14
#define OMAP_MPUIO_GPIO_MASKIT		0x16
#define OMAP_MPUIO_GPIO_DEBOUNCING	0x18
#define OMAP_MPUIO_LATCH		0x1a
#else
L
Linus Torvalds 已提交
50 51 52 53 54 55 56 57 58 59 60 61 62
#define OMAP_MPUIO_INPUT_LATCH		0x00
#define OMAP_MPUIO_OUTPUT		0x04
#define OMAP_MPUIO_IO_CNTL		0x08
#define OMAP_MPUIO_KBR_LATCH		0x10
#define OMAP_MPUIO_KBC			0x14
#define OMAP_MPUIO_GPIO_EVENT_MODE	0x18
#define OMAP_MPUIO_GPIO_INT_EDGE	0x1c
#define OMAP_MPUIO_KBD_INT		0x20
#define OMAP_MPUIO_GPIO_INT		0x24
#define OMAP_MPUIO_KBD_MASKIT		0x28
#define OMAP_MPUIO_GPIO_MASKIT		0x2c
#define OMAP_MPUIO_GPIO_DEBOUNCING	0x30
#define OMAP_MPUIO_LATCH		0x34
63
#endif
L
Linus Torvalds 已提交
64

65 66
#define OMAP34XX_NR_GPIOS		6

L
Linus Torvalds 已提交
67 68 69 70 71
#define OMAP_MPUIO(nr)		(OMAP_MAX_GPIO_LINES + (nr))
#define OMAP_GPIO_IS_MPUIO(nr)	((nr) >= OMAP_MAX_GPIO_LINES)

#define OMAP_GPIO_IRQ(nr)	(OMAP_GPIO_IS_MPUIO(nr) ? \
				 IH_MPUIO_BASE + ((nr) & 0x0f) : \
72
				 IH_GPIO_BASE + (nr))
L
Linus Torvalds 已提交
73 74

extern int omap_gpio_init(void);	/* Call from board init only */
75 76
extern void omap2_gpio_prepare_for_retention(void);
extern void omap2_gpio_resume_after_retention(void);
77 78
extern void omap_set_gpio_debounce(int gpio, int enable);
extern void omap_set_gpio_debounce_time(int gpio, int enable);
L
Linus Torvalds 已提交
79

D
David Brownell 已提交
80 81
/*-------------------------------------------------------------------------*/

D
David Brownell 已提交
82 83 84 85
/* Wrappers for "new style" GPIO calls, using the new infrastructure
 * which lets us plug in FPGA, I2C, and other implementations.
 * *
 * The original OMAP-specfic calls should eventually be removed.
D
David Brownell 已提交
86 87
 */

D
David Brownell 已提交
88 89
#include <linux/errno.h>
#include <asm-generic/gpio.h>
D
David Brownell 已提交
90 91 92

static inline int gpio_get_value(unsigned gpio)
{
D
David Brownell 已提交
93
	return __gpio_get_value(gpio);
D
David Brownell 已提交
94 95 96 97
}

static inline void gpio_set_value(unsigned gpio, int value)
{
D
David Brownell 已提交
98
	__gpio_set_value(gpio, value);
D
David Brownell 已提交
99 100
}

D
David Brownell 已提交
101 102 103 104
static inline int gpio_cansleep(unsigned gpio)
{
	return __gpio_cansleep(gpio);
}
D
David Brownell 已提交
105 106 107

static inline int gpio_to_irq(unsigned gpio)
{
108
	return __gpio_to_irq(gpio);
D
David Brownell 已提交
109 110 111 112
}

static inline int irq_to_gpio(unsigned irq)
{
113 114 115
	int tmp;

	/* omap1 SOC mpuio */
D
David Brownell 已提交
116 117
	if (cpu_class_is_omap1() && (irq < (IH_MPUIO_BASE + 16)))
		return (irq - IH_MPUIO_BASE) + OMAP_MAX_GPIO_LINES;
118 119 120 121 122 123 124 125

	/* SOC gpio */
	tmp = irq - IH_GPIO_BASE;
	if (tmp < OMAP_MAX_GPIO_LINES)
		return tmp;

	/* we don't supply reverse mappings for non-SOC gpios */
	return -EIO;
D
David Brownell 已提交
126 127
}

L
Linus Torvalds 已提交
128
#endif