Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Gabe Black | eee6a7f | 2013-09-24 01:36:08 -0700 | [diff] [blame] | 2 | |
Sam Lewis | ad7b2e2 | 2020-08-03 20:18:29 +1000 | [diff] [blame] | 3 | #ifndef __SOC_TI_AM335X_GPIO_H__ |
| 4 | #define __SOC_TI_AM335X_GPIO_H__ |
Gabe Black | eee6a7f | 2013-09-24 01:36:08 -0700 | [diff] [blame] | 5 | |
| 6 | #include <stdint.h> |
| 7 | |
| 8 | enum { |
| 9 | AM335X_GPIO_BITS_PER_BANK = 32 |
| 10 | }; |
| 11 | |
| 12 | struct am335x_gpio_regs { |
| 13 | uint32_t revision; // 0x0 |
| 14 | uint8_t _rsv0[0xc]; // 0x4-0xf |
| 15 | uint32_t sysconfig; // 0x10 |
| 16 | uint8_t _rsv1[0xc]; // 0x14-0x1f |
| 17 | uint32_t eoi; // 0x20 |
| 18 | uint32_t irqstatus_raw_0; // 0x24 |
| 19 | uint32_t irqstatus_raw_1; // 0x28 |
| 20 | uint32_t irqstatus_0; // 0x2c |
| 21 | uint32_t irqstatus_1; // 0x30 |
| 22 | uint32_t irqstatus_set_0; // 0x34 |
| 23 | uint32_t irqstatus_set_1; // 0x38 |
| 24 | uint32_t irqstatus_clr_0; // 0x3c |
| 25 | uint32_t irqstatus_clk_1; // 0x40 |
| 26 | uint32_t irqwaken_0; // 0x44 |
| 27 | uint32_t irqwaken_1; // 0x48 |
| 28 | uint8_t _rsv2[0xc8]; // 0x4c-0x113 |
| 29 | uint32_t sysstatus; // 0x114 |
| 30 | uint8_t _rsv3[0x18]; // 0x118-0x12f |
| 31 | uint32_t ctrl; // 0x130 |
| 32 | uint32_t oe; // 0x134 |
| 33 | uint32_t datain; // 0x138 |
| 34 | uint32_t dataout; // 0x13c |
| 35 | uint32_t leveldetect0; // 0x140 |
| 36 | uint32_t leveldetect1; // 0x144 |
| 37 | uint32_t risingdetect; // 0x148 |
| 38 | uint32_t fallingdetect; // 0x14c |
| 39 | uint32_t debouncenable; // 0x150 |
| 40 | uint32_t debouncingtime; // 0x154 |
| 41 | uint8_t _rsv4[0x38]; // 0x158-0x18f |
| 42 | uint32_t cleardataout; // 0x190 |
| 43 | uint32_t setdataout; // 0x194 |
Stefan Reinauer | 6a00113 | 2017-07-13 02:20:27 +0200 | [diff] [blame] | 44 | } __packed; |
Gabe Black | eee6a7f | 2013-09-24 01:36:08 -0700 | [diff] [blame] | 45 | |
| 46 | static struct am335x_gpio_regs * const am335x_gpio_banks[] = { |
| 47 | (void *)0x44e07000, (void *)0x4804c000, |
| 48 | (void *)0x481ac000, (void *)0x481ae000 |
| 49 | }; |
| 50 | |
| 51 | void am335x_disable_gpio_irqs(void); |
| 52 | |
Daniel Lim Wee Soong | df2dbbc | 2019-03-29 19:21:35 +0800 | [diff] [blame] | 53 | int gpio_direction_input(unsigned int gpio); |
| 54 | int gpio_direction_output(unsigned int gpio, int value); |
| 55 | int gpio_get_value(unsigned int gpio); |
| 56 | int gpio_set_value(unsigned int gpio, int value); |
Gabe Black | eee6a7f | 2013-09-24 01:36:08 -0700 | [diff] [blame] | 57 | |
Sam Lewis | ad7b2e2 | 2020-08-03 20:18:29 +1000 | [diff] [blame] | 58 | #endif /* __SOC_TI_AM335X_CLOCK_H__ */ |