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