blob: c62a9438976dd2f31a006449bd33bf6a800ed289 [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
Keerthyb5cf3fd2017-01-13 09:50:12 +053024#define MAX_REGS_BANKS 5
25
KV Sujith118150f2013-08-18 10:48:58 +053026struct davinci_gpio_platform_data {
27 u32 ngpio;
28 u32 gpio_unbanked;
KV Sujith118150f2013-08-18 10:48:58 +053029};
30
Keerthyb5cf3fd2017-01-13 09:50:12 +053031struct davinci_gpio_irq_data {
32 void __iomem *regs;
33 struct davinci_gpio_controller *chip;
34 int bank_num;
35};
36
Philip Avinashf1a4c522013-08-18 10:49:03 +053037struct davinci_gpio_controller {
38 struct gpio_chip chip;
Lad, Prabhakar9211ff32013-11-21 23:45:27 +053039 struct irq_domain *irq_domain;
Philip Avinashf1a4c522013-08-18 10:49:03 +053040 /* Serialize access to GPIO registers */
41 spinlock_t lock;
Keerthyb5cf3fd2017-01-13 09:50:12 +053042 void __iomem *regs[MAX_REGS_BANKS];
Philip Avinashf1a4c522013-08-18 10:49:03 +053043 int gpio_unbanked;
Keerthyb5cf3fd2017-01-13 09:50:12 +053044 unsigned int base_irq;
Philip Avinashf1a4c522013-08-18 10:49:03 +053045};
46
47/*
48 * basic gpio routines
49 */
50#define GPIO(X) (X) /* 0 <= X <= (DAVINCI_N_GPIO - 1) */
51
52/* Convert GPIO signal to GPIO pin number */
53#define GPIO_TO_PIN(bank, gpio) (16 * (bank) + (gpio))
54
55static inline u32 __gpio_mask(unsigned gpio)
56{
57 return 1 << (gpio % 32);
58}
KV Sujith118150f2013-08-18 10:48:58 +053059#endif