x86/xen: resume timer irqs early
[linux/fpc-iii.git] / arch / arm / mach-davinci / include / mach / gpio-davinci.h
blob1fdd1fd35448f9f0e49450be5624112a2b5111ec
1 /*
2 * TI DaVinci GPIO Support
4 * Copyright (c) 2006 David Brownell
5 * Copyright (c) 2007, MontaVista Software, Inc. <source@mvista.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
13 #ifndef __DAVINCI_DAVINCI_GPIO_H
14 #define __DAVINCI_DAVINCI_GPIO_H
16 #include <linux/io.h>
17 #include <linux/spinlock.h>
19 #include <asm-generic/gpio.h>
21 #include <mach/irqs.h>
22 #include <mach/common.h>
24 #define DAVINCI_GPIO_BASE 0x01C67000
26 enum davinci_gpio_type {
27 GPIO_TYPE_DAVINCI = 0,
28 GPIO_TYPE_TNETV107X,
32 * basic gpio routines
34 * board-specific init should be done by arch/.../.../board-XXX.c (maybe
35 * initializing banks together) rather than boot loaders; kexec() won't
36 * go through boot loaders.
38 * the gpio clock will be turned on when gpios are used, and you may also
39 * need to pay attention to PINMUX registers to be sure those pins are
40 * used as gpios, not with other peripherals.
42 * On-chip GPIOs are numbered 0..(DAVINCI_N_GPIO-1). For documentation,
43 * and maybe for later updates, code may write GPIO(N). These may be
44 * all 1.8V signals, all 3.3V ones, or a mix of the two. A given chip
45 * may not support all the GPIOs in that range.
47 * GPIOs can also be on external chips, numbered after the ones built-in
48 * to the DaVinci chip. For now, they won't be usable as IRQ sources.
50 #define GPIO(X) (X) /* 0 <= X <= (DAVINCI_N_GPIO - 1) */
52 /* Convert GPIO signal to GPIO pin number */
53 #define GPIO_TO_PIN(bank, gpio) (16 * (bank) + (gpio))
55 struct davinci_gpio_controller {
56 struct gpio_chip chip;
57 int irq_base;
58 spinlock_t lock;
59 void __iomem *regs;
60 void __iomem *set_data;
61 void __iomem *clr_data;
62 void __iomem *in_data;
65 /* The __gpio_to_controller() and __gpio_mask() functions inline to constants
66 * with constant parameters; or in outlined code they execute at runtime.
68 * You'd access the controller directly when reading or writing more than
69 * one gpio value at a time, and to support wired logic where the value
70 * being driven by the cpu need not match the value read back.
72 * These are NOT part of the cross-platform GPIO interface
74 static inline struct davinci_gpio_controller *
75 __gpio_to_controller(unsigned gpio)
77 struct davinci_gpio_controller *ctlrs = davinci_soc_info.gpio_ctlrs;
78 int index = gpio / 32;
80 if (!ctlrs || index >= davinci_soc_info.gpio_ctlrs_num)
81 return NULL;
83 return ctlrs + index;
86 static inline u32 __gpio_mask(unsigned gpio)
88 return 1 << (gpio % 32);
91 #endif /* __DAVINCI_DAVINCI_GPIO_H */