KV Sujith | 118150f | 2013-08-18 10:48:58 +0530 | [diff] [blame] | 1 | /* |
| 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 Avinash | f1a4c52 | 2013-08-18 10:49:03 +0530 | [diff] [blame] | 19 | #include <linux/io.h> |
| 20 | #include <linux/spinlock.h> |
| 21 | |
| 22 | #include <asm-generic/gpio.h> |
| 23 | |
| 24 | enum davinci_gpio_type { |
| 25 | GPIO_TYPE_TNETV107X = 0, |
| 26 | }; |
| 27 | |
KV Sujith | 118150f | 2013-08-18 10:48:58 +0530 | [diff] [blame] | 28 | struct davinci_gpio_platform_data { |
| 29 | u32 ngpio; |
| 30 | u32 gpio_unbanked; |
KV Sujith | 118150f | 2013-08-18 10:48:58 +0530 | [diff] [blame] | 31 | }; |
| 32 | |
Philip Avinash | f1a4c52 | 2013-08-18 10:49:03 +0530 | [diff] [blame] | 33 | |
| 34 | struct davinci_gpio_controller { |
| 35 | struct gpio_chip chip; |
Lad, Prabhakar | 9211ff3 | 2013-11-21 23:45:27 +0530 | [diff] [blame] | 36 | struct irq_domain *irq_domain; |
Philip Avinash | f1a4c52 | 2013-08-18 10:49:03 +0530 | [diff] [blame] | 37 | /* Serialize access to GPIO registers */ |
| 38 | spinlock_t lock; |
| 39 | void __iomem *regs; |
| 40 | void __iomem *set_data; |
| 41 | void __iomem *clr_data; |
| 42 | void __iomem *in_data; |
| 43 | int gpio_unbanked; |
| 44 | unsigned gpio_irq; |
| 45 | }; |
| 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 | |
| 55 | static inline u32 __gpio_mask(unsigned gpio) |
| 56 | { |
| 57 | return 1 << (gpio % 32); |
| 58 | } |
KV Sujith | 118150f | 2013-08-18 10:48:58 +0530 | [diff] [blame] | 59 | #endif |