blob: 91803d28cb3433d0593e4f68c67fefbdfcda600e [file] [log] [blame]
Stefan Bosch48397f12020-07-10 19:07:25 +02001/* SPDX-License-Identifier: GPL-2.0+
2 *
3 * (C) Copyright 2016 Nexell
4 * Youngbok, Park <ybpark@nexell.co.kr>
5 */
6
7#include <linux/types.h>
8#include <asm/io.h>
9
10#ifndef __nx_gpio_h__
11#define __nx_gpio_h__
12
13struct nx_gpio_register_set {
14 u32 gpioxout;
15 u32 gpioxoutenb;
16 u32 gpioxdetmode[2];
17 u32 gpioxintenb;
18 u32 gpioxdet;
19 u32 gpioxpad;
20 u32 gpioxpuenb;
21 u32 gpioxaltfn[2];
22 u32 gpioxdetmodeex;
23 u32 __reserved[4];
24 u32 gpioxdetenb;
25 u32 gpiox_slew;
26 u32 gpiox_slew_disable_default;
27 u32 gpiox_drv1;
28 u32 gpiox_drv1_disable_default;
29 u32 gpiox_drv0;
30 u32 gpiox_drv0_disable_default;
31 u32 gpiox_pullsel;
32 u32 gpiox_pullsel_disable_default;
33 u32 gpiox_pullenb;
34 u32 gpiox_pullenb_disable_default;
35 u32 gpiox_input_mux_select0;
36 u32 gpiox_input_mux_select1;
37 u8 __reserved1[0x1000 - 0x70];
38};
39
40enum {
41 nx_gpio_padfunc_0 = 0ul,
42 nx_gpio_padfunc_1 = 1ul,
43 nx_gpio_padfunc_2 = 2ul,
44 nx_gpio_padfunc_3 = 3ul
45};
46
47enum {
48 nx_gpio_drvstrength_0 = 0ul,
49 nx_gpio_drvstrength_1 = 1ul,
50 nx_gpio_drvstrength_2 = 2ul,
51 nx_gpio_drvstrength_3 = 3ul
52};
53
54enum {
55 nx_gpio_pull_down = 0ul,
56 nx_gpio_pull_up = 1ul,
57 nx_gpio_pull_off = 2ul
58};
59
60int nx_gpio_initialize(void);
61u32 nx_gpio_get_number_of_module(void);
62u32 nx_gpio_get_size_of_register_set(void);
63void nx_gpio_set_base_address(u32 module_index, void *base_address);
64void *nx_gpio_get_base_address(u32 module_index);
65int nx_gpio_open_module(u32 module_index);
66int nx_gpio_close_module(u32 module_index);
67int nx_gpio_check_busy(u32 module_index);
68void nx_gpio_set_detect_enable(u32 module_index, u32 bit_number,
69 int detect_enb);
70void nx_gpio_set_pad_function(u32 module_index, u32 bit_number, u32 padfunc);
71void nx_gpio_set_pad_function32(u32 module_index, u32 msbvalue, u32 lsbvalue);
72int nx_gpio_get_pad_function(u32 module_index, u32 bit_number);
73void nx_gpio_set_output_enable(u32 module_index, u32 bit_number,
74 int output_enb);
75int nx_gpio_get_detect_enable(u32 module_index, u32 bit_number);
76u32 nx_gpio_get_detect_enable32(u32 module_index);
77void nx_gpio_set_detect_enable(u32 module_index, u32 bit_number,
78 int detect_enb);
79void nx_gpio_set_detect_enable32(u32 module_index, u32 enable_flag);
80int nx_gpio_get_output_enable(u32 module_index, u32 bit_number);
81void nx_gpio_set_output_enable32(u32 module_index, int output_enb);
82u32 nx_gpio_get_output_enable32(u32 module_index);
83void nx_gpio_set_output_value(u32 module_index, u32 bit_number, int value);
84int nx_gpio_get_output_value(u32 module_index, u32 bit_number);
85void nx_gpio_set_output_value32(u32 module_index, u32 value);
86u32 nx_gpio_get_output_value32(u32 module_index);
87int nx_gpio_get_input_value(u32 module_index, u32 bit_number);
88void nx_gpio_set_pull_select(u32 module_index, u32 bit_number, int enable);
89void nx_gpio_set_pull_select32(u32 module_index, u32 value);
90int nx_gpio_get_pull_select(u32 module_index, u32 bit_number);
91u32 nx_gpio_get_pull_select32(u32 module_index);
92void nx_gpio_set_pull_mode(u32 module_index, u32 bit_number, u32 mode);
93void nx_gpio_set_fast_slew(u32 module_index, u32 bit_number, int enable);
94void nx_gpio_set_drive_strength_disable_default(u32 module_index,
95 u32 bit_number, int enable);
96void nx_gpio_set_drive_strength_disable_default(u32 module_index,
97 u32 bit_number, int enable);
98void nx_gpio_set_drive_strength(u32 module_index, u32 bit_number,
99 u32 drvstrength);
100void nx_gpio_set_drive_strength_disable_default(u32 module_index,
101 u32 bit_number, int enable);
102u32 nx_gpio_get_drive_strength(u32 module_index, u32 bit_number);
103#endif