Blame view
drivers/pinctrl/samsung/pinctrl-samsung.h
8.1 KB
30574f0db
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
/* * pin-controller/pin-mux/pin-config/gpio-driver for Samsung's SoC's. * * Copyright (c) 2012 Samsung Electronics Co., Ltd. * http://www.samsung.com * Copyright (c) 2012 Linaro Ltd * http://www.linaro.org * * Author: Thomas Abraham <thomas.ab@samsung.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ #ifndef __PINCTRL_SAMSUNG_H #define __PINCTRL_SAMSUNG_H #include <linux/pinctrl/pinctrl.h> #include <linux/pinctrl/pinmux.h> #include <linux/pinctrl/pinconf.h> #include <linux/pinctrl/consumer.h> #include <linux/pinctrl/machine.h> |
d3a7b9e3a
|
25 |
#include <linux/gpio.h> |
30574f0db
|
26 |
/* pinmux function number for pin as gpio output line */ |
f6a8249f9
|
27 |
#define FUNC_INPUT 0x0 |
30574f0db
|
28 29 30 31 |
#define FUNC_OUTPUT 0x1 /** * enum pincfg_type - possible pin configuration types supported. |
499147c9d
|
32 33 |
* @PINCFG_TYPE_FUNC: Function configuration. * @PINCFG_TYPE_DAT: Pin value configuration. |
30574f0db
|
34 35 36 37 38 39 |
* @PINCFG_TYPE_PUD: Pull up/down configuration. * @PINCFG_TYPE_DRV: Drive strength configuration. * @PINCFG_TYPE_CON_PDN: Pin function in power down mode. * @PINCFG_TYPE_PUD_PDN: Pull up/down configuration in power down mode. */ enum pincfg_type { |
499147c9d
|
40 41 |
PINCFG_TYPE_FUNC, PINCFG_TYPE_DAT, |
30574f0db
|
42 43 44 45 |
PINCFG_TYPE_PUD, PINCFG_TYPE_DRV, PINCFG_TYPE_CON_PDN, PINCFG_TYPE_PUD_PDN, |
499147c9d
|
46 47 |
PINCFG_TYPE_NUM |
30574f0db
|
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
}; /* * pin configuration (pull up/down and drive strength) type and its value are * packed together into a 16-bits. The upper 8-bits represent the configuration * type and the lower 8-bits hold the value of the configuration type. */ #define PINCFG_TYPE_MASK 0xFF #define PINCFG_VALUE_SHIFT 8 #define PINCFG_VALUE_MASK (0xFF << PINCFG_VALUE_SHIFT) #define PINCFG_PACK(type, value) (((value) << PINCFG_VALUE_SHIFT) | type) #define PINCFG_UNPACK_TYPE(cfg) ((cfg) & PINCFG_TYPE_MASK) #define PINCFG_UNPACK_VALUE(cfg) (((cfg) & PINCFG_VALUE_MASK) >> \ PINCFG_VALUE_SHIFT) /** * enum eint_type - possible external interrupt types. * @EINT_TYPE_NONE: bank does not support external interrupts * @EINT_TYPE_GPIO: bank supportes external gpio interrupts * @EINT_TYPE_WKUP: bank supportes external wakeup interrupts |
a04b07c0f
|
67 |
* @EINT_TYPE_WKUP_MUX: bank supports multiplexed external wakeup interrupts |
30574f0db
|
68 69 70 71 72 73 74 75 76 77 78 79 |
* * Samsung GPIO controller groups all the available pins into banks. The pins * in a pin bank can support external gpio interrupts or external wakeup * interrupts or no interrupts at all. From a software perspective, the only * difference between external gpio and external wakeup interrupts is that * the wakeup interrupts can additionally wakeup the system if it is in * suspended state. */ enum eint_type { EINT_TYPE_NONE, EINT_TYPE_GPIO, EINT_TYPE_WKUP, |
a04b07c0f
|
80 |
EINT_TYPE_WKUP_MUX, |
30574f0db
|
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
}; /* maximum length of a pin in pin descriptor (example: "gpa0-0") */ #define PIN_NAME_LENGTH 10 #define PIN_GROUP(n, p, f) \ { \ .name = n, \ .pins = p, \ .num_pins = ARRAY_SIZE(p), \ .func = f \ } #define PMX_FUNC(n, g) \ { \ .name = n, \ .groups = g, \ .num_groups = ARRAY_SIZE(g), \ } struct samsung_pinctrl_drv_data; /** |
499147c9d
|
104 105 |
* struct samsung_pin_bank_type: pin bank type description * @fld_width: widths of configuration bitfields (0 if unavailable) |
43fc9e7fa
|
106 |
* @reg_offset: offsets of configuration registers (don't care of width is 0) |
499147c9d
|
107 108 109 |
*/ struct samsung_pin_bank_type { u8 fld_width[PINCFG_TYPE_NUM]; |
43fc9e7fa
|
110 |
u8 reg_offset[PINCFG_TYPE_NUM]; |
499147c9d
|
111 112 113 |
}; /** |
30574f0db
|
114 |
* struct samsung_pin_bank: represent a controller pin-bank. |
499147c9d
|
115 |
* @type: type of the bank (register offsets and bitfield widths) |
88f2324fa
|
116 |
* @pctl_offset: starting offset of the pin-bank registers. |
30574f0db
|
117 118 |
* @pin_base: starting pin number of the bank. * @nr_pins: number of pins included in this bank. |
61dd72613
|
119 |
* @eint_func: function to set in CON register to configure pin as EINT. |
30574f0db
|
120 |
* @eint_type: type of the external interrupt supported by the bank. |
61dd72613
|
121 |
* @eint_mask: bit mask of pins which support EINT function. |
30574f0db
|
122 |
* @name: name to be prefixed for each pin in this pin bank. |
ab663789d
|
123 |
* @of_node: OF node of the bank. |
6defe9a0d
|
124 |
* @drvdata: link to controller driver data |
595be7268
|
125 |
* @irq_domain: IRQ domain of the bank. |
d3a7b9e3a
|
126 127 |
* @gpio_chip: GPIO chip of the bank. * @grange: linux gpio pin range supported by this bank. |
198469504
|
128 |
* @slock: spinlock protecting bank registers |
d9f998639
|
129 |
* @pm_save: saved register values during suspend |
30574f0db
|
130 131 |
*/ struct samsung_pin_bank { |
499147c9d
|
132 |
struct samsung_pin_bank_type *type; |
30574f0db
|
133 134 135 |
u32 pctl_offset; u32 pin_base; u8 nr_pins; |
61dd72613
|
136 |
u8 eint_func; |
30574f0db
|
137 |
enum eint_type eint_type; |
61dd72613
|
138 |
u32 eint_mask; |
1b6056d6d
|
139 |
u32 eint_offset; |
30574f0db
|
140 |
char *name; |
3385474c3
|
141 |
void *soc_priv; |
ab663789d
|
142 |
struct device_node *of_node; |
6defe9a0d
|
143 |
struct samsung_pinctrl_drv_data *drvdata; |
595be7268
|
144 |
struct irq_domain *irq_domain; |
d3a7b9e3a
|
145 146 |
struct gpio_chip gpio_chip; struct pinctrl_gpio_range grange; |
198469504
|
147 |
spinlock_t slock; |
d9f998639
|
148 149 |
u32 pm_save[PINCFG_TYPE_NUM + 1]; /* +1 to handle double CON registers*/ |
30574f0db
|
150 151 152 153 154 155 156 157 |
}; /** * struct samsung_pin_ctrl: represent a pin controller. * @pin_banks: list of pin banks included in this controller. * @nr_banks: number of pin banks. * @base: starting system wide pin number. * @nr_pins: number of pins supported by the controller. |
30574f0db
|
158 159 160 161 162 163 164 165 166 167 168 169 |
* @eint_gpio_init: platform specific callback to setup the external gpio * interrupts for the controller. * @eint_wkup_init: platform specific callback to setup the external wakeup * interrupts for the controller. * @label: for debug information. */ struct samsung_pin_ctrl { struct samsung_pin_bank *pin_banks; u32 nr_banks; u32 base; u32 nr_pins; |
30574f0db
|
170 |
|
30574f0db
|
171 172 |
int (*eint_gpio_init)(struct samsung_pinctrl_drv_data *); int (*eint_wkup_init)(struct samsung_pinctrl_drv_data *); |
21c219933
|
173 174 |
void (*suspend)(struct samsung_pinctrl_drv_data *); void (*resume)(struct samsung_pinctrl_drv_data *); |
30574f0db
|
175 176 177 178 179 |
char *label; }; /** * struct samsung_pinctrl_drv_data: wrapper for holding driver data together. |
d9f998639
|
180 |
* @node: global list node |
30574f0db
|
181 182 183 184 185 186 187 188 189 190 |
* @virt_base: register base address of the controller. * @dev: device instance representing the controller. * @irq: interrpt number used by the controller to notify gpio interrupts. * @ctrl: pin controller instance managed by the driver. * @pctl: pin controller descriptor registered with the pinctrl subsystem. * @pctl_dev: cookie representing pinctrl device instance. * @pin_groups: list of pin groups available to the driver. * @nr_groups: number of such pin groups. * @pmx_functions: list of pin functions available to the driver. * @nr_function: number of such pin functions. |
30574f0db
|
191 192 |
*/ struct samsung_pinctrl_drv_data { |
d9f998639
|
193 |
struct list_head node; |
30574f0db
|
194 195 196 197 198 199 200 201 202 203 204 205 |
void __iomem *virt_base; struct device *dev; int irq; struct samsung_pin_ctrl *ctrl; struct pinctrl_desc pctl; struct pinctrl_dev *pctl_dev; const struct samsung_pin_group *pin_groups; unsigned int nr_groups; const struct samsung_pmx_func *pmx_functions; unsigned int nr_functions; |
30574f0db
|
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
}; /** * struct samsung_pin_group: represent group of pins of a pinmux function. * @name: name of the pin group, used to lookup the group. * @pins: the pins included in this group. * @num_pins: number of pins included in this group. * @func: the function number to be programmed when selected. */ struct samsung_pin_group { const char *name; const unsigned int *pins; u8 num_pins; u8 func; }; /** * struct samsung_pmx_func: represent a pin function. * @name: name of the pin function, used to lookup the function. * @groups: one or more names of pin groups that provide this function. * @num_groups: number of groups included in @groups. */ struct samsung_pmx_func { const char *name; const char **groups; u8 num_groups; |
9a2c1c3b9
|
232 |
u32 val; |
30574f0db
|
233 234 235 |
}; /* list of all exported SoC specific data */ |
d97f5b980
|
236 |
extern struct samsung_pin_ctrl exynos3250_pin_ctrl[]; |
30574f0db
|
237 |
extern struct samsung_pin_ctrl exynos4210_pin_ctrl[]; |
6edc794a5
|
238 |
extern struct samsung_pin_ctrl exynos4x12_pin_ctrl[]; |
f67faf487
|
239 |
extern struct samsung_pin_ctrl exynos5250_pin_ctrl[]; |
9a8b60797
|
240 |
extern struct samsung_pin_ctrl exynos5260_pin_ctrl[]; |
983dbeb35
|
241 |
extern struct samsung_pin_ctrl exynos5420_pin_ctrl[]; |
61dd72613
|
242 |
extern struct samsung_pin_ctrl s3c64xx_pin_ctrl[]; |
af99a7507
|
243 244 245 246 |
extern struct samsung_pin_ctrl s3c2412_pin_ctrl[]; extern struct samsung_pin_ctrl s3c2416_pin_ctrl[]; extern struct samsung_pin_ctrl s3c2440_pin_ctrl[]; extern struct samsung_pin_ctrl s3c2450_pin_ctrl[]; |
608a26a7b
|
247 |
extern struct samsung_pin_ctrl s5pv210_pin_ctrl[]; |
30574f0db
|
248 249 |
#endif /* __PINCTRL_SAMSUNG_H */ |