blob: a74999438de458d400a01ad8b059254936247b54 [file] [log] [blame]
Linus Walleij0f332862011-08-22 08:33:30 +01001/*
2 * Structures and registers for GPIO access in the Nomadik SoC
3 *
4 * Copyright (C) 2008 STMicroelectronics
5 * Author: Prafulla WADASKAR <prafulla.wadaskar@st.com>
6 * Copyright (C) 2009 Alessandro Rubini <rubini@unipv.it>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef __PLAT_NOMADIK_GPIO
14#define __PLAT_NOMADIK_GPIO
15
16/*
17 * "nmk_gpio" and "NMK_GPIO" stand for "Nomadik GPIO", leaving
18 * the "gpio" namespace for generic and cross-machine functions
19 */
20
Patrice Chotardf64228ee2012-10-08 16:35:09 +020021#define GPIO_BLOCK_SHIFT 5
22#define NMK_GPIO_PER_CHIP (1 << GPIO_BLOCK_SHIFT)
23
Linus Walleij0f332862011-08-22 08:33:30 +010024/* Register in the logic block */
25#define NMK_GPIO_DAT 0x00
26#define NMK_GPIO_DATS 0x04
27#define NMK_GPIO_DATC 0x08
28#define NMK_GPIO_PDIS 0x0c
29#define NMK_GPIO_DIR 0x10
30#define NMK_GPIO_DIRS 0x14
31#define NMK_GPIO_DIRC 0x18
32#define NMK_GPIO_SLPC 0x1c
33#define NMK_GPIO_AFSLA 0x20
34#define NMK_GPIO_AFSLB 0x24
Rabin Vincentebc61782011-09-28 15:49:11 +053035#define NMK_GPIO_LOWEMI 0x28
Linus Walleij0f332862011-08-22 08:33:30 +010036
37#define NMK_GPIO_RIMSC 0x40
38#define NMK_GPIO_FIMSC 0x44
39#define NMK_GPIO_IS 0x48
40#define NMK_GPIO_IC 0x4c
41#define NMK_GPIO_RWIMSC 0x50
42#define NMK_GPIO_FWIMSC 0x54
43#define NMK_GPIO_WKS 0x58
Maxime Coquelin748a2b72012-10-10 13:59:02 +020044/* These appear in DB8540 and later ASICs */
45#define NMK_GPIO_EDGELEVEL 0x5C
46#define NMK_GPIO_LEVEL 0x60
Linus Walleij0f332862011-08-22 08:33:30 +010047
48/* Alternate functions: function C is set in hw by setting both A and B */
49#define NMK_GPIO_ALT_GPIO 0
50#define NMK_GPIO_ALT_A 1
51#define NMK_GPIO_ALT_B 2
52#define NMK_GPIO_ALT_C (NMK_GPIO_ALT_A | NMK_GPIO_ALT_B)
53
Jean-Nicolas Grauxc22df082012-09-27 15:38:50 +020054#define NMK_GPIO_ALT_CX_SHIFT 2
55#define NMK_GPIO_ALT_C1 ((1<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
56#define NMK_GPIO_ALT_C2 ((2<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
57#define NMK_GPIO_ALT_C3 ((3<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
58#define NMK_GPIO_ALT_C4 ((4<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
59
Linus Walleij0f332862011-08-22 08:33:30 +010060/* Pull up/down values */
61enum nmk_gpio_pull {
62 NMK_GPIO_PULL_NONE,
63 NMK_GPIO_PULL_UP,
64 NMK_GPIO_PULL_DOWN,
65};
66
67/* Sleep mode */
68enum nmk_gpio_slpm {
69 NMK_GPIO_SLPM_INPUT,
70 NMK_GPIO_SLPM_WAKEUP_ENABLE = NMK_GPIO_SLPM_INPUT,
71 NMK_GPIO_SLPM_NOCHANGE,
72 NMK_GPIO_SLPM_WAKEUP_DISABLE = NMK_GPIO_SLPM_NOCHANGE,
73};
74
75extern int nmk_gpio_set_slpm(int gpio, enum nmk_gpio_slpm mode);
76extern int nmk_gpio_set_pull(int gpio, enum nmk_gpio_pull pull);
Arnd Bergmann0fa7be42012-05-15 11:24:34 +000077#ifdef CONFIG_PINCTRL_NOMADIK
Linus Walleij0f332862011-08-22 08:33:30 +010078extern int nmk_gpio_set_mode(int gpio, int gpio_mode);
Arnd Bergmann0fa7be42012-05-15 11:24:34 +000079#else
80static inline int nmk_gpio_set_mode(int gpio, int gpio_mode)
81{
82 return -ENODEV;
83}
84#endif
Linus Walleij0f332862011-08-22 08:33:30 +010085extern int nmk_gpio_get_mode(int gpio);
86
87extern void nmk_gpio_wakeups_suspend(void);
88extern void nmk_gpio_wakeups_resume(void);
89
Linus Torvalds41684f62011-10-29 07:27:45 -070090extern void nmk_gpio_clocks_enable(void);
91extern void nmk_gpio_clocks_disable(void);
92
Linus Walleij0f332862011-08-22 08:33:30 +010093extern void nmk_gpio_read_pull(int gpio_bank, u32 *pull_up);
94
95/*
96 * Platform data to register a block: only the initial gpio/irq number.
97 */
98struct nmk_gpio_platform_data {
99 char *name;
100 int first_gpio;
101 int first_irq;
102 int num_gpio;
103 u32 (*get_secondary_status)(unsigned int bank);
104 void (*set_ioforce)(bool enable);
105 bool supports_sleepmode;
106};
107
108#endif /* __PLAT_NOMADIK_GPIO */