Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ */
0002 /*
0003  * Copyright 2012 Freescale Semiconductor, Inc.
0004  */
0005 
0006 #ifndef __PINCTRL_MXS_H
0007 #define __PINCTRL_MXS_H
0008 
0009 #include <linux/platform_device.h>
0010 #include <linux/pinctrl/pinctrl.h>
0011 
0012 #define SET 0x4
0013 #define CLR 0x8
0014 #define TOG 0xc
0015 
0016 #define MXS_PINCTRL_PIN(pin)    PINCTRL_PIN(pin, #pin)
0017 #define PINID(bank, pin)    ((bank) * 32 + (pin))
0018 
0019 /*
0020  * pinmux-id bit field definitions
0021  *
0022  * bank:    15..12  (4)
0023  * pin:     11..4   (8)
0024  * muxsel:  3..0    (4)
0025  */
0026 #define MUXID_TO_PINID(m)   PINID((m) >> 12 & 0xf, (m) >> 4 & 0xff)
0027 #define MUXID_TO_MUXSEL(m)  ((m) & 0xf)
0028 
0029 #define PINID_TO_BANK(p)    ((p) >> 5)
0030 #define PINID_TO_PIN(p)     ((p) % 32)
0031 
0032 /*
0033  * pin config bit field definitions
0034  *
0035  * pull-up: 6..5    (2)
0036  * voltage: 4..3    (2)
0037  * mA:      2..0    (3)
0038  *
0039  * MSB of each field is presence bit for the config.
0040  */
0041 #define PULL_PRESENT        (1 << 6)
0042 #define PULL_SHIFT      5
0043 #define VOL_PRESENT     (1 << 4)
0044 #define VOL_SHIFT       3
0045 #define MA_PRESENT      (1 << 2)
0046 #define MA_SHIFT        0
0047 #define CONFIG_TO_PULL(c)   ((c) >> PULL_SHIFT & 0x1)
0048 #define CONFIG_TO_VOL(c)    ((c) >> VOL_SHIFT & 0x1)
0049 #define CONFIG_TO_MA(c)     ((c) >> MA_SHIFT & 0x3)
0050 
0051 struct mxs_function {
0052     const char *name;
0053     const char **groups;
0054     unsigned ngroups;
0055 };
0056 
0057 struct mxs_group {
0058     const char *name;
0059     unsigned int *pins;
0060     unsigned npins;
0061     u8 *muxsel;
0062     u8 config;
0063 };
0064 
0065 struct mxs_regs {
0066     u16 muxsel;
0067     u16 drive;
0068     u16 pull;
0069 };
0070 
0071 struct mxs_pinctrl_soc_data {
0072     const struct mxs_regs *regs;
0073     const struct pinctrl_pin_desc *pins;
0074     unsigned npins;
0075     struct mxs_function *functions;
0076     unsigned nfunctions;
0077     struct mxs_group *groups;
0078     unsigned ngroups;
0079 };
0080 
0081 int mxs_pinctrl_probe(struct platform_device *pdev,
0082               struct mxs_pinctrl_soc_data *soc);
0083 
0084 #endif /* __PINCTRL_MXS_H */