blob: f51e47e55d53a7b08e59f1e565dac0698c1f9cbc [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Stelian Pop048bcfb2008-03-26 19:52:30 +01002/*
Stelian Popd57846e2008-05-08 22:52:10 +02003 * [origin: Linux kernel include/asm-arm/arch-at91/at91_pio.h]
Stelian Pop048bcfb2008-03-26 19:52:30 +01004 *
5 * Copyright (C) 2005 Ivan Kokshaysky
6 * Copyright (C) SAN People
Jens Scharsig698ad062010-02-03 22:46:01 +01007 * Copyright (C) 2009 Jens Scharsig (js_at_ng@scharsoft.de)
Stelian Pop048bcfb2008-03-26 19:52:30 +01008 *
9 * Parallel I/O Controller (PIO) - System peripherals registers.
10 * Based on AT91RM9200 datasheet revision E.
Stelian Pop048bcfb2008-03-26 19:52:30 +010011 */
12
13#ifndef AT91_PIO_H
14#define AT91_PIO_H
15
Jens Scharsig698ad062010-02-03 22:46:01 +010016
17#define AT91_ASM_PIO_RANGE 0x200
Jens Scharsig9bbaae32010-02-03 22:47:35 +010018#define AT91_ASM_PIOC_ASR \
Eric Benard470a57b2011-06-06 22:48:27 +000019 (ATMEL_BASE_PIO + AT91_PIO_PORTC * AT91_ASM_PIO_RANGE + 0x70)
Jens Scharsig9bbaae32010-02-03 22:47:35 +010020#define AT91_ASM_PIOC_BSR \
Eric Benard470a57b2011-06-06 22:48:27 +000021 (ATMEL_BASE_PIO + AT91_PIO_PORTC * AT91_ASM_PIO_RANGE + 0x74)
Jens Scharsig698ad062010-02-03 22:46:01 +010022#define AT91_ASM_PIOC_PDR \
Eric Benard470a57b2011-06-06 22:48:27 +000023 (ATMEL_BASE_PIO + AT91_PIO_PORTC * AT91_ASM_PIO_RANGE + 0x04)
Jens Scharsig698ad062010-02-03 22:46:01 +010024#define AT91_ASM_PIOC_PUDR \
Eric Benard470a57b2011-06-06 22:48:27 +000025 (ATMEL_BASE_PIO + AT91_PIO_PORTC * AT91_ASM_PIO_RANGE + 0x60)
Jens Scharsig698ad062010-02-03 22:46:01 +010026
27#define AT91_ASM_PIOD_PDR \
Eric Benard470a57b2011-06-06 22:48:27 +000028 (ATMEL_BASE_PIO + AT91_PIO_PORTD * AT91_ASM_PIO_RANGE + 0x04)
Jens Scharsig698ad062010-02-03 22:46:01 +010029#define AT91_ASM_PIOD_PUDR \
Eric Benard470a57b2011-06-06 22:48:27 +000030 (ATMEL_BASE_PIO + AT91_PIO_PORTD * AT91_ASM_PIO_RANGE + 0x60)
Jens Scharsig698ad062010-02-03 22:46:01 +010031#define AT91_ASM_PIOD_ASR \
Eric Benard470a57b2011-06-06 22:48:27 +000032 (ATMEL_BASE_PIO + AT91_PIO_PORTD * AT91_ASM_PIO_RANGE + 0x70)
Jens Scharsig698ad062010-02-03 22:46:01 +010033
Wenyou Yang4a92a3e2017-03-23 12:44:36 +080034#define PIO_SCDR_DIV 0x3fff /* Slow Clock Divider Selection for Debouncing Mask */
35
Jens Scharsig698ad062010-02-03 22:46:01 +010036#ifndef __ASSEMBLY__
37
38typedef struct at91_port {
39 u32 per; /* 0x00 PIO Enable Register */
40 u32 pdr; /* 0x04 PIO Disable Register */
41 u32 psr; /* 0x08 PIO Status Register */
42 u32 reserved0;
43 u32 oer; /* 0x10 Output Enable Register */
44 u32 odr; /* 0x14 Output Disable Registerr */
45 u32 osr; /* 0x18 Output Status Register */
46 u32 reserved1;
47 u32 ifer; /* 0x20 Input Filter Enable Register */
48 u32 ifdr; /* 0x24 Input Filter Disable Register */
49 u32 ifsr; /* 0x28 Input Filter Status Register */
50 u32 reserved2;
51 u32 sodr; /* 0x30 Set Output Data Register */
52 u32 codr; /* 0x34 Clear Output Data Register */
53 u32 odsr; /* 0x38 Output Data Status Register */
54 u32 pdsr; /* 0x3C Pin Data Status Register */
55 u32 ier; /* 0x40 Interrupt Enable Register */
56 u32 idr; /* 0x44 Interrupt Disable Register */
57 u32 imr; /* 0x48 Interrupt Mask Register */
58 u32 isr; /* 0x4C Interrupt Status Register */
59 u32 mder; /* 0x50 Multi-driver Enable Register */
60 u32 mddr; /* 0x54 Multi-driver Disable Register */
61 u32 mdsr; /* 0x58 Multi-driver Status Register */
62 u32 reserved3;
63 u32 pudr; /* 0x60 Pull-up Disable Register */
64 u32 puer; /* 0x64 Pull-up Enable Register */
65 u32 pusr; /* 0x68 Pad Pull-up Status Register */
66 u32 reserved4;
Wenyou Yang4a92a3e2017-03-23 12:44:36 +080067 union {
68 struct {
69 u32 abcdsr1; /* 0x70 Peripheral ABCD Select Register 1 */
70 u32 abcdsr2; /* 0x74 Peripheral ABCD Select Register 2 */
71 u32 reserved5[2];
72 u32 ifscdr; /* 0x80 Input Filter SCLK Disable Register */
73 u32 ifscer; /* 0x84 Input Filter SCLK Enable Register */
74 u32 ifscsr; /* 0x88 Input Filter SCLK Status Register */
75 u32 scdr; /* 0x8C SCLK Divider Debouncing Register */
76 u32 ppddr; /* 0x90 Pad Pull-down Disable Register */
77 u32 ppder; /* 0x94 Pad Pull-down Enable Register */
78 u32 ppdsr; /* 0x98 Pad Pull-down Status Register */
79 u32 reserved6; /* */
80 } pio3;
81
82 struct {
83 u32 asr; /* 0x70 Select A Register */
84 u32 bsr; /* 0x74 Select B Register */
85 u32 absr; /* 0x78 AB Select Status Register */
86 u32 reserved5[9]; /* */
87 } pio2;
88 } mux;
89
Jens Scharsig698ad062010-02-03 22:46:01 +010090 u32 ower; /* 0xA0 Output Write Enable Register */
91 u32 owdr; /* 0xA4 Output Write Disable Register */
Bo Shen0ac13452012-05-20 15:50:00 +000092 u32 owsr; /* OxA8 Output Write Status Register */
Bo Shen0ac13452012-05-20 15:50:00 +000093 u32 reserved7; /* */
94 u32 aimer; /* 0xB0 Additional INT Modes Enable Register */
95 u32 aimdr; /* 0xB4 Additional INT Modes Disable Register */
96 u32 aimmr; /* 0xB8 Additional INT Modes Mask Register */
97 u32 reserved8; /* */
98 u32 esr; /* 0xC0 Edge Select Register */
99 u32 lsr; /* 0xC4 Level Select Register */
100 u32 elsr; /* 0xC8 Edge/Level Status Register */
101 u32 reserved9; /* 0xCC */
102 u32 fellsr; /* 0xD0 Falling /Low Level Select Register */
103 u32 rehlsr; /* 0xD4 Rising /High Level Select Register */
104 u32 frlhsr; /* 0xD8 Fall/Rise - Low/High Status Register */
105 u32 reserved10; /* */
106 u32 locksr; /* 0xE0 Lock Status */
107 u32 wpmr; /* 0xE4 Write Protect Mode Register */
108 u32 wpsr; /* 0xE8 Write Protect Status Register */
109 u32 reserved11[5]; /* */
110 u32 schmitt; /* 0x100 Schmitt Trigger Register */
Wenyou Yangc24e0132017-03-23 12:44:37 +0800111 u32 reserved12[4]; /* 0x104 ~ 0x110 */
112 u32 driver1; /* 0x114 I/O Driver Register1(AT91SAM9x5's driver1) */
113 u32 driver12; /* 0x118 I/O Driver Register12(AT91SAM9x5's driver2 or SAMA5D3x's driver1 ) */
114 u32 driver2; /* 0x11C I/O Driver Register2(SAMA5D3x's driver2) */
115 u32 reserved13[12]; /* 0x120 ~ 0x14C */
Jens Scharsig698ad062010-02-03 22:46:01 +0100116} at91_port_t;
117
Jens Scharsig698ad062010-02-03 22:46:01 +0100118typedef union at91_pio {
119 struct {
120 at91_port_t pioa;
121 at91_port_t piob;
122 at91_port_t pioc;
Simon Glass1c9baf82015-02-11 16:32:57 -0700123 at91_port_t piod; /* not present in all hardware */
124 at91_port_t pioe;/* not present in all hardware */
125 };
126 at91_port_t port[5];
Jens Scharsig698ad062010-02-03 22:46:01 +0100127} at91_pio_t;
128
Jens Scharsig8d065462010-02-03 22:46:16 +0100129#ifdef CONFIG_AT91_GPIO
130int at91_set_a_periph(unsigned port, unsigned pin, int use_pullup);
131int at91_set_b_periph(unsigned port, unsigned pin, int use_pullup);
132int at91_set_pio_input(unsigned port, unsigned pin, int use_pullup);
133int at91_set_pio_multi_drive(unsigned port, unsigned pin, int is_on);
134int at91_set_pio_output(unsigned port, unsigned pin, int value);
135int at91_set_pio_periph(unsigned port, unsigned pin, int use_pullup);
136int at91_set_pio_pullup(unsigned port, unsigned pin, int use_pullup);
137int at91_set_pio_deglitch(unsigned port, unsigned pin, int is_on);
138int at91_set_pio_value(unsigned port, unsigned pin, int value);
139int at91_get_pio_value(unsigned port, unsigned pin);
Wenyou Yang4a92a3e2017-03-23 12:44:36 +0800140
141int at91_pio3_set_a_periph(unsigned port, unsigned pin, int use_pullup);
142int at91_pio3_set_b_periph(unsigned port, unsigned pin, int use_pullup);
143int at91_pio3_set_c_periph(unsigned port, unsigned pin, int use_pullup);
144int at91_pio3_set_d_periph(unsigned port, unsigned pin, int use_pullup);
145int at91_pio3_set_pio_debounce(unsigned port, unsigned pin, int is_on, int div);
146int at91_pio3_set_pio_pullup(unsigned port, unsigned pin, int use_pullup);
147int at91_pio3_set_pio_pulldown(unsigned port, unsigned pin, int is_on);
148int at91_pio3_set_pio_disable_schmitt_trig(unsigned port, unsigned pin);
Jens Scharsig8d065462010-02-03 22:46:16 +0100149#endif
Jens Scharsig698ad062010-02-03 22:46:01 +0100150#endif
151
Jens Scharsig698ad062010-02-03 22:46:01 +0100152#define AT91_PIO_PORTA 0x0
153#define AT91_PIO_PORTB 0x1
154#define AT91_PIO_PORTC 0x2
155#define AT91_PIO_PORTD 0x3
156#define AT91_PIO_PORTE 0x4
157
Stelian Pop048bcfb2008-03-26 19:52:30 +0100158#endif