blob: 0c3551bb671f8312ff00699f450b3bbc8ae087d0 [file] [log] [blame]
KV Sujith118150f2013-08-18 10:48:58 +05301/*
2 * DaVinci GPIO Platform Related Defines
3 *
4 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation version 2.
9 *
10 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11 * kind, whether express or implied; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef __DAVINCI_GPIO_PLATFORM_H
17#define __DAVINCI_GPIO_PLATFORM_H
18
Philip Avinashf1a4c522013-08-18 10:49:03 +053019#include <linux/io.h>
20#include <linux/spinlock.h>
21
22#include <asm-generic/gpio.h>
23
24enum davinci_gpio_type {
25 GPIO_TYPE_TNETV107X = 0,
26};
27
KV Sujith118150f2013-08-18 10:48:58 +053028struct davinci_gpio_platform_data {
29 u32 ngpio;
30 u32 gpio_unbanked;
31 u32 intc_irq_num;
32};
33
Philip Avinashf1a4c522013-08-18 10:49:03 +053034
35struct davinci_gpio_controller {
36 struct gpio_chip chip;
Lad, Prabhakar9211ff32013-11-21 23:45:27 +053037 struct irq_domain *irq_domain;
Philip Avinashf1a4c522013-08-18 10:49:03 +053038 /* Serialize access to GPIO registers */
39 spinlock_t lock;
40 void __iomem *regs;
41 void __iomem *set_data;
42 void __iomem *clr_data;
43 void __iomem *in_data;
44 int gpio_unbanked;
45 unsigned gpio_irq;
46};
47
48/*
49 * basic gpio routines
50 */
51#define GPIO(X) (X) /* 0 <= X <= (DAVINCI_N_GPIO - 1) */
52
53/* Convert GPIO signal to GPIO pin number */
54#define GPIO_TO_PIN(bank, gpio) (16 * (bank) + (gpio))
55
56static inline u32 __gpio_mask(unsigned gpio)
57{
58 return 1 << (gpio % 32);
59}
KV Sujith118150f2013-08-18 10:48:58 +053060#endif