Haavard Skinnemoen | df548d3 | 2006-11-19 18:06:53 +0100 | [diff] [blame] | 1 | /* |
Haavard Skinnemoen | ab0df36 | 2008-08-29 21:09:49 +0200 | [diff] [blame] | 2 | * Copyright (C) 2006, 2008 Atmel Corporation |
Haavard Skinnemoen | df548d3 | 2006-11-19 18:06:53 +0100 | [diff] [blame] | 3 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Haavard Skinnemoen | df548d3 | 2006-11-19 18:06:53 +0100 | [diff] [blame] | 5 | */ |
| 6 | #ifndef __ASM_AVR32_ARCH_GPIO_H__ |
| 7 | #define __ASM_AVR32_ARCH_GPIO_H__ |
| 8 | |
Haavard Skinnemoen | 5fee84a | 2007-10-29 13:23:33 +0100 | [diff] [blame] | 9 | #include <asm/arch/chip-features.h> |
Andreas Bießmann | 5d73bc7 | 2010-11-04 23:15:30 +0000 | [diff] [blame] | 10 | #include <asm/arch/hardware.h> |
Haavard Skinnemoen | df548d3 | 2006-11-19 18:06:53 +0100 | [diff] [blame] | 11 | |
| 12 | #define NR_GPIO_CONTROLLERS 5 |
| 13 | |
| 14 | /* |
| 15 | * Pin numbers identifying specific GPIO pins on the chip. |
| 16 | */ |
| 17 | #define GPIO_PIOA_BASE (0) |
Haavard Skinnemoen | df548d3 | 2006-11-19 18:06:53 +0100 | [diff] [blame] | 18 | #define GPIO_PIOB_BASE (GPIO_PIOA_BASE + 32) |
Haavard Skinnemoen | df548d3 | 2006-11-19 18:06:53 +0100 | [diff] [blame] | 19 | #define GPIO_PIOC_BASE (GPIO_PIOB_BASE + 32) |
Haavard Skinnemoen | df548d3 | 2006-11-19 18:06:53 +0100 | [diff] [blame] | 20 | #define GPIO_PIOD_BASE (GPIO_PIOC_BASE + 32) |
Haavard Skinnemoen | df548d3 | 2006-11-19 18:06:53 +0100 | [diff] [blame] | 21 | #define GPIO_PIOE_BASE (GPIO_PIOD_BASE + 32) |
Haavard Skinnemoen | ab0df36 | 2008-08-29 21:09:49 +0200 | [diff] [blame] | 22 | #define GPIO_PIN_PA(x) (GPIO_PIOA_BASE + (x)) |
| 23 | #define GPIO_PIN_PB(x) (GPIO_PIOB_BASE + (x)) |
| 24 | #define GPIO_PIN_PC(x) (GPIO_PIOC_BASE + (x)) |
| 25 | #define GPIO_PIN_PD(x) (GPIO_PIOD_BASE + (x)) |
| 26 | #define GPIO_PIN_PE(x) (GPIO_PIOE_BASE + (x)) |
Haavard Skinnemoen | df548d3 | 2006-11-19 18:06:53 +0100 | [diff] [blame] | 27 | |
Haavard Skinnemoen | ab0df36 | 2008-08-29 21:09:49 +0200 | [diff] [blame] | 28 | static inline void *pio_pin_to_port(unsigned int pin) |
Haavard Skinnemoen | df548d3 | 2006-11-19 18:06:53 +0100 | [diff] [blame] | 29 | { |
| 30 | switch (pin >> 5) { |
| 31 | case 0: |
Andreas Bießmann | f4278b7 | 2010-11-04 23:15:31 +0000 | [diff] [blame] | 32 | return (void *)ATMEL_BASE_PIOA; |
Haavard Skinnemoen | df548d3 | 2006-11-19 18:06:53 +0100 | [diff] [blame] | 33 | case 1: |
Andreas Bießmann | f4278b7 | 2010-11-04 23:15:31 +0000 | [diff] [blame] | 34 | return (void *)ATMEL_BASE_PIOB; |
Haavard Skinnemoen | df548d3 | 2006-11-19 18:06:53 +0100 | [diff] [blame] | 35 | case 2: |
Andreas Bießmann | f4278b7 | 2010-11-04 23:15:31 +0000 | [diff] [blame] | 36 | return (void *)ATMEL_BASE_PIOC; |
Haavard Skinnemoen | df548d3 | 2006-11-19 18:06:53 +0100 | [diff] [blame] | 37 | case 3: |
Andreas Bießmann | f4278b7 | 2010-11-04 23:15:31 +0000 | [diff] [blame] | 38 | return (void *)ATMEL_BASE_PIOD; |
Haavard Skinnemoen | df548d3 | 2006-11-19 18:06:53 +0100 | [diff] [blame] | 39 | case 4: |
Andreas Bießmann | f4278b7 | 2010-11-04 23:15:31 +0000 | [diff] [blame] | 40 | return (void *)ATMEL_BASE_PIOE; |
Haavard Skinnemoen | df548d3 | 2006-11-19 18:06:53 +0100 | [diff] [blame] | 41 | default: |
| 42 | return NULL; |
| 43 | } |
| 44 | } |
| 45 | |
Haavard Skinnemoen | ab0df36 | 2008-08-29 21:09:49 +0200 | [diff] [blame] | 46 | #include <asm/arch-common/portmux-pio.h> |
Haavard Skinnemoen | df548d3 | 2006-11-19 18:06:53 +0100 | [diff] [blame] | 47 | |
| 48 | #endif /* __ASM_AVR32_ARCH_GPIO_H__ */ |