blob: b5808c5d456a14d07376f619f5deacde5551601e [file] [log] [blame]
Haavard Skinnemoendf548d32006-11-19 18:06:53 +01001/*
Haavard Skinnemoenab0df362008-08-29 21:09:49 +02002 * Copyright (C) 2006, 2008 Atmel Corporation
Haavard Skinnemoendf548d32006-11-19 18:06:53 +01003 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Haavard Skinnemoendf548d32006-11-19 18:06:53 +01005 */
6#ifndef __ASM_AVR32_ARCH_GPIO_H__
7#define __ASM_AVR32_ARCH_GPIO_H__
8
Haavard Skinnemoen5fee84a2007-10-29 13:23:33 +01009#include <asm/arch/chip-features.h>
Andreas Bießmann5d73bc72010-11-04 23:15:30 +000010#include <asm/arch/hardware.h>
Haavard Skinnemoendf548d32006-11-19 18:06:53 +010011
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 Skinnemoendf548d32006-11-19 18:06:53 +010018#define GPIO_PIOB_BASE (GPIO_PIOA_BASE + 32)
Haavard Skinnemoendf548d32006-11-19 18:06:53 +010019#define GPIO_PIOC_BASE (GPIO_PIOB_BASE + 32)
Haavard Skinnemoendf548d32006-11-19 18:06:53 +010020#define GPIO_PIOD_BASE (GPIO_PIOC_BASE + 32)
Haavard Skinnemoendf548d32006-11-19 18:06:53 +010021#define GPIO_PIOE_BASE (GPIO_PIOD_BASE + 32)
Haavard Skinnemoenab0df362008-08-29 21:09:49 +020022#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 Skinnemoendf548d32006-11-19 18:06:53 +010027
Haavard Skinnemoenab0df362008-08-29 21:09:49 +020028static inline void *pio_pin_to_port(unsigned int pin)
Haavard Skinnemoendf548d32006-11-19 18:06:53 +010029{
30 switch (pin >> 5) {
31 case 0:
Andreas Bießmannf4278b72010-11-04 23:15:31 +000032 return (void *)ATMEL_BASE_PIOA;
Haavard Skinnemoendf548d32006-11-19 18:06:53 +010033 case 1:
Andreas Bießmannf4278b72010-11-04 23:15:31 +000034 return (void *)ATMEL_BASE_PIOB;
Haavard Skinnemoendf548d32006-11-19 18:06:53 +010035 case 2:
Andreas Bießmannf4278b72010-11-04 23:15:31 +000036 return (void *)ATMEL_BASE_PIOC;
Haavard Skinnemoendf548d32006-11-19 18:06:53 +010037 case 3:
Andreas Bießmannf4278b72010-11-04 23:15:31 +000038 return (void *)ATMEL_BASE_PIOD;
Haavard Skinnemoendf548d32006-11-19 18:06:53 +010039 case 4:
Andreas Bießmannf4278b72010-11-04 23:15:31 +000040 return (void *)ATMEL_BASE_PIOE;
Haavard Skinnemoendf548d32006-11-19 18:06:53 +010041 default:
42 return NULL;
43 }
44}
45
Haavard Skinnemoenab0df362008-08-29 21:09:49 +020046#include <asm/arch-common/portmux-pio.h>
Haavard Skinnemoendf548d32006-11-19 18:06:53 +010047
48#endif /* __ASM_AVR32_ARCH_GPIO_H__ */