Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
awilliam
GitHub Repository: awilliam/linux-vfio
Path: blob/master/arch/arm/mach-mmp/include/mach/gpio.h
15162 views
1
#ifndef __ASM_MACH_GPIO_H
2
#define __ASM_MACH_GPIO_H
3
4
#include <mach/addr-map.h>
5
#include <mach/irqs.h>
6
#include <asm-generic/gpio.h>
7
8
#define GPIO_REGS_VIRT (APB_VIRT_BASE + 0x19000)
9
10
#define BANK_OFF(n) (((n) < 3) ? (n) << 2 : 0x100 + (((n) - 3) << 2))
11
#define GPIO_REG(x) (*((volatile u32 *)(GPIO_REGS_VIRT + (x))))
12
13
#define NR_BUILTIN_GPIO IRQ_GPIO_NUM
14
15
#define gpio_to_bank(gpio) ((gpio) >> 5)
16
#define gpio_to_irq(gpio) (IRQ_GPIO_START + (gpio))
17
#define irq_to_gpio(irq) ((irq) - IRQ_GPIO_START)
18
19
20
#define __gpio_is_inverted(gpio) (0)
21
#define __gpio_is_occupied(gpio) (0)
22
23
/* NOTE: these macros are defined here to make optimization of
24
* gpio_{get,set}_value() to work when 'gpio' is a constant.
25
* Usage of these macros otherwise is no longer recommended,
26
* use generic GPIO API whenever possible.
27
*/
28
#define GPIO_bit(gpio) (1 << ((gpio) & 0x1f))
29
30
#define GPLR(x) GPIO_REG(BANK_OFF(gpio_to_bank(x)) + 0x00)
31
#define GPDR(x) GPIO_REG(BANK_OFF(gpio_to_bank(x)) + 0x0c)
32
#define GPSR(x) GPIO_REG(BANK_OFF(gpio_to_bank(x)) + 0x18)
33
#define GPCR(x) GPIO_REG(BANK_OFF(gpio_to_bank(x)) + 0x24)
34
35
#include <plat/gpio.h>
36
#endif /* __ASM_MACH_GPIO_H */
37
38