2005-04-17 05:20:36 +07:00
|
|
|
/*
|
2008-08-05 22:14:15 +07:00
|
|
|
* arch/arm/plat-omap/include/mach/gpio.h
|
2005-04-17 05:20:36 +07:00
|
|
|
*
|
|
|
|
* OMAP GPIO handling defines and functions
|
|
|
|
*
|
2005-09-07 23:20:27 +07:00
|
|
|
* Copyright (C) 2003-2005 Nokia Corporation
|
2005-04-17 05:20:36 +07:00
|
|
|
*
|
2007-05-09 13:30:57 +07:00
|
|
|
* Written by Juha Yrjölä <juha.yrjola@nokia.com>
|
2005-04-17 05:20:36 +07:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
|
2008-08-05 22:14:15 +07:00
|
|
|
#include <mach/irqs.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <asm/io.h>
|
|
|
|
|
2005-09-07 23:20:27 +07:00
|
|
|
#define OMAP_MPUIO_BASE (void __iomem *)0xfffb5000
|
|
|
|
|
|
|
|
#ifdef CONFIG_ARCH_OMAP730
|
|
|
|
#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
|
2005-04-17 05:20:36 +07:00
|
|
|
#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
|
2005-09-07 23:20:27 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-11-30 07:15:11 +07:00
|
|
|
#define OMAP34XX_NR_GPIOS 6
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#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) : \
|
2005-11-10 21:26:53 +07:00
|
|
|
IH_GPIO_BASE + (nr))
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
extern int omap_gpio_init(void); /* Call from board init only */
|
|
|
|
extern int omap_request_gpio(int gpio);
|
|
|
|
extern void omap_free_gpio(int gpio);
|
|
|
|
extern void omap_set_gpio_direction(int gpio, int is_input);
|
|
|
|
extern void omap_set_gpio_dataout(int gpio, int enable);
|
|
|
|
extern int omap_get_gpio_datain(int gpio);
|
2007-05-06 01:40:29 +07:00
|
|
|
extern void omap_set_gpio_debounce(int gpio, int enable);
|
|
|
|
extern void omap_set_gpio_debounce_time(int gpio, int enable);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-02-12 15:53:12 +07:00
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
2008-03-04 03:43:23 +07:00
|
|
|
/* 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.
|
2007-02-12 15:53:12 +07:00
|
|
|
*/
|
|
|
|
|
2008-03-04 03:43:23 +07:00
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <asm-generic/gpio.h>
|
2007-02-12 15:53:12 +07:00
|
|
|
|
|
|
|
static inline int gpio_get_value(unsigned gpio)
|
|
|
|
{
|
2008-03-04 03:43:23 +07:00
|
|
|
return __gpio_get_value(gpio);
|
2007-02-12 15:53:12 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gpio_set_value(unsigned gpio, int value)
|
|
|
|
{
|
2008-03-04 03:43:23 +07:00
|
|
|
__gpio_set_value(gpio, value);
|
2007-02-12 15:53:12 +07:00
|
|
|
}
|
|
|
|
|
2008-03-04 03:43:23 +07:00
|
|
|
static inline int gpio_cansleep(unsigned gpio)
|
|
|
|
{
|
|
|
|
return __gpio_cansleep(gpio);
|
|
|
|
}
|
2007-02-12 15:53:12 +07:00
|
|
|
|
|
|
|
static inline int gpio_to_irq(unsigned gpio)
|
|
|
|
{
|
2008-03-04 03:43:23 +07:00
|
|
|
if (gpio < (OMAP_MAX_GPIO_LINES + 16))
|
|
|
|
return OMAP_GPIO_IRQ(gpio);
|
|
|
|
return -EINVAL;
|
2007-02-12 15:53:12 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int irq_to_gpio(unsigned irq)
|
|
|
|
{
|
|
|
|
if (cpu_class_is_omap1() && (irq < (IH_MPUIO_BASE + 16)))
|
|
|
|
return (irq - IH_MPUIO_BASE) + OMAP_MAX_GPIO_LINES;
|
|
|
|
return irq - IH_GPIO_BASE;
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#endif
|