1 /*
2 * Copyright (C) 2006, 2008 Atmel Corporation
3 *
4 * See file CREDITS for list of people who contributed to this
5 * project.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22 #ifndef __ASM_AVR32_ARCH_PORTMUX_H__
23 #define __ASM_AVR32_ARCH_PORTMUX_H__
24
25 #include <asm/arch/gpio.h>
26
27 #define PORTMUX_PORT_A ((void *)PIOA_BASE)
28 #define PORTMUX_PORT_B ((void *)PIOB_BASE)
29 #define PORTMUX_PORT_C ((void *)PIOC_BASE)
30 #define PORTMUX_PORT_D ((void *)PIOD_BASE)
31 #define PORTMUX_PORT_E ((void *)PIOE_BASE)
32
33 void portmux_enable_ebi(unsigned int bus_width, unsigned int addr_width,
34 unsigned long flags, unsigned long drive_strength);
35
36 #define PORTMUX_EBI_CS(x) (1 << (x))
37 #define PORTMUX_EBI_NAND (1 << 6)
38 #define PORTMUX_EBI_CF(x) (1 << ((x) + 7))
39 #define PORTMUX_EBI_NWAIT (1 << 9)
40
41 #ifdef AT32AP700x_CHIP_HAS_USART
portmux_enable_usart0(unsigned long drive_strength)42 static inline void portmux_enable_usart0(unsigned long drive_strength)
43 {
44 portmux_select_peripheral(PORTMUX_PORT_A, (1 << 8) | (1 << 9),
45 PORTMUX_FUNC_B, 0);
46 }
47
portmux_enable_usart1(unsigned long drive_strength)48 static inline void portmux_enable_usart1(unsigned long drive_strength)
49 {
50 portmux_select_peripheral(PORTMUX_PORT_A, (1 << 17) | (1 << 18),
51 PORTMUX_FUNC_A, 0);
52 }
53
portmux_enable_usart2(unsigned long drive_strength)54 static inline void portmux_enable_usart2(unsigned long drive_strength)
55 {
56 portmux_select_peripheral(PORTMUX_PORT_B, (1 << 26) | (1 << 27),
57 PORTMUX_FUNC_B, 0);
58 }
59
portmux_enable_usart3(unsigned long drive_strength)60 static inline void portmux_enable_usart3(unsigned long drive_strength)
61 {
62 portmux_select_peripheral(PORTMUX_PORT_B, (1 << 17) | (1 << 18),
63 PORTMUX_FUNC_B, 0);
64 }
65 #endif
66 #ifdef AT32AP700x_CHIP_HAS_MACB
67 void portmux_enable_macb0(unsigned long flags, unsigned long drive_strength);
68 void portmux_enable_macb1(unsigned long flags, unsigned long drive_strength);
69
70 #define PORTMUX_MACB_RMII (0)
71 #define PORTMUX_MACB_MII (1 << 0)
72 #define PORTMUX_MACB_SPEED (1 << 1)
73
74 #endif
75 #ifdef AT32AP700x_CHIP_HAS_MMCI
76 void portmux_enable_mmci(unsigned int slot, unsigned long flags,
77 unsigned long drive_strength);
78
79 #define PORTMUX_MMCI_4BIT (1 << 0)
80 #define PORTMUX_MMCI_8BIT (PORTMUX_MMCI_4BIT | (1 << 1))
81 #define PORTMUX_MMCI_EXT_PULLUP (1 << 2)
82
83 #endif
84 #ifdef AT32AP700x_CHIP_HAS_SPI
85 void portmux_enable_spi0(unsigned long cs_mask, unsigned long drive_strength);
86 void portmux_enable_spi1(unsigned long cs_mask, unsigned long drive_strength);
87 #endif
88 #ifdef AT32AP700x_CHIP_HAS_LCDC
89 void portmux_enable_lcdc(int pin_config);
90 #endif
91
92 #endif /* __ASM_AVR32_ARCH_PORTMUX_H__ */
93