Fabio Estevam | c2b39de | 2018-05-19 15:43:54 -0300 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Shawn Guo | 1772311 | 2012-04-28 13:00:50 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2012 Freescale Semiconductor, Inc. |
Shawn Guo | 1772311 | 2012-04-28 13:00:50 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef __PINCTRL_MXS_H |
| 7 | #define __PINCTRL_MXS_H |
| 8 | |
| 9 | #include <linux/platform_device.h> |
| 10 | #include <linux/pinctrl/pinctrl.h> |
| 11 | |
| 12 | #define SET 0x4 |
| 13 | #define CLR 0x8 |
| 14 | #define TOG 0xc |
| 15 | |
| 16 | #define MXS_PINCTRL_PIN(pin) PINCTRL_PIN(pin, #pin) |
| 17 | #define PINID(bank, pin) ((bank) * 32 + (pin)) |
| 18 | |
| 19 | /* |
| 20 | * pinmux-id bit field definitions |
| 21 | * |
| 22 | * bank: 15..12 (4) |
| 23 | * pin: 11..4 (8) |
| 24 | * muxsel: 3..0 (4) |
| 25 | */ |
| 26 | #define MUXID_TO_PINID(m) PINID((m) >> 12 & 0xf, (m) >> 4 & 0xff) |
| 27 | #define MUXID_TO_MUXSEL(m) ((m) & 0xf) |
| 28 | |
| 29 | #define PINID_TO_BANK(p) ((p) >> 5) |
| 30 | #define PINID_TO_PIN(p) ((p) % 32) |
| 31 | |
| 32 | /* |
| 33 | * pin config bit field definitions |
| 34 | * |
| 35 | * pull-up: 6..5 (2) |
| 36 | * voltage: 4..3 (2) |
| 37 | * mA: 2..0 (3) |
| 38 | * |
| 39 | * MSB of each field is presence bit for the config. |
| 40 | */ |
| 41 | #define PULL_PRESENT (1 << 6) |
| 42 | #define PULL_SHIFT 5 |
| 43 | #define VOL_PRESENT (1 << 4) |
| 44 | #define VOL_SHIFT 3 |
| 45 | #define MA_PRESENT (1 << 2) |
| 46 | #define MA_SHIFT 0 |
| 47 | #define CONFIG_TO_PULL(c) ((c) >> PULL_SHIFT & 0x1) |
| 48 | #define CONFIG_TO_VOL(c) ((c) >> VOL_SHIFT & 0x1) |
| 49 | #define CONFIG_TO_MA(c) ((c) >> MA_SHIFT & 0x3) |
| 50 | |
| 51 | struct mxs_function { |
| 52 | const char *name; |
| 53 | const char **groups; |
| 54 | unsigned ngroups; |
| 55 | }; |
| 56 | |
| 57 | struct mxs_group { |
| 58 | const char *name; |
| 59 | unsigned int *pins; |
| 60 | unsigned npins; |
| 61 | u8 *muxsel; |
| 62 | u8 config; |
| 63 | }; |
| 64 | |
| 65 | struct mxs_regs { |
| 66 | u16 muxsel; |
| 67 | u16 drive; |
| 68 | u16 pull; |
| 69 | }; |
| 70 | |
| 71 | struct mxs_pinctrl_soc_data { |
| 72 | const struct mxs_regs *regs; |
| 73 | const struct pinctrl_pin_desc *pins; |
| 74 | unsigned npins; |
| 75 | struct mxs_function *functions; |
| 76 | unsigned nfunctions; |
| 77 | struct mxs_group *groups; |
| 78 | unsigned ngroups; |
| 79 | }; |
| 80 | |
| 81 | int mxs_pinctrl_probe(struct platform_device *pdev, |
| 82 | struct mxs_pinctrl_soc_data *soc); |
Shawn Guo | 1772311 | 2012-04-28 13:00:50 +0800 | [diff] [blame] | 83 | |
| 84 | #endif /* __PINCTRL_MXS_H */ |