85 lines · c
1/* SPDX-License-Identifier: GPL-2.0+ */2/*3 * Copyright 2012 Freescale Semiconductor, Inc.4 */5 6#ifndef __PINCTRL_MXS_H7#define __PINCTRL_MXS_H8 9#include <linux/platform_device.h>10#include <linux/pinctrl/pinctrl.h>11 12#define SET 0x413#define CLR 0x814#define TOG 0xc15 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 definitions21 *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 definitions34 *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 543#define VOL_PRESENT (1 << 4)44#define VOL_SHIFT 345#define MA_PRESENT (1 << 2)46#define MA_SHIFT 047#define PIN_CONFIG_TO_PULL(c) ((c) >> PULL_SHIFT & 0x1)48#define PIN_CONFIG_TO_VOL(c) ((c) >> VOL_SHIFT & 0x1)49#define PIN_CONFIG_TO_MA(c) ((c) >> MA_SHIFT & 0x3)50 51struct mxs_function {52 const char *name;53 const char **groups;54 unsigned ngroups;55};56 57struct mxs_group {58 const char *name;59 unsigned int *pins;60 unsigned npins;61 u8 *muxsel;62 u8 config;63};64 65struct mxs_regs {66 u16 muxsel;67 u16 drive;68 u16 pull;69};70 71struct 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 81int mxs_pinctrl_probe(struct platform_device *pdev,82 struct mxs_pinctrl_soc_data *soc);83 84#endif /* __PINCTRL_MXS_H */85