18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright 2012 Freescale Semiconductor, Inc. 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef __PINCTRL_MXS_H 78c2ecf20Sopenharmony_ci#define __PINCTRL_MXS_H 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 108c2ecf20Sopenharmony_ci#include <linux/pinctrl/pinctrl.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#define SET 0x4 138c2ecf20Sopenharmony_ci#define CLR 0x8 148c2ecf20Sopenharmony_ci#define TOG 0xc 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#define MXS_PINCTRL_PIN(pin) PINCTRL_PIN(pin, #pin) 178c2ecf20Sopenharmony_ci#define PINID(bank, pin) ((bank) * 32 + (pin)) 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/* 208c2ecf20Sopenharmony_ci * pinmux-id bit field definitions 218c2ecf20Sopenharmony_ci * 228c2ecf20Sopenharmony_ci * bank: 15..12 (4) 238c2ecf20Sopenharmony_ci * pin: 11..4 (8) 248c2ecf20Sopenharmony_ci * muxsel: 3..0 (4) 258c2ecf20Sopenharmony_ci */ 268c2ecf20Sopenharmony_ci#define MUXID_TO_PINID(m) PINID((m) >> 12 & 0xf, (m) >> 4 & 0xff) 278c2ecf20Sopenharmony_ci#define MUXID_TO_MUXSEL(m) ((m) & 0xf) 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#define PINID_TO_BANK(p) ((p) >> 5) 308c2ecf20Sopenharmony_ci#define PINID_TO_PIN(p) ((p) % 32) 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci/* 338c2ecf20Sopenharmony_ci * pin config bit field definitions 348c2ecf20Sopenharmony_ci * 358c2ecf20Sopenharmony_ci * pull-up: 6..5 (2) 368c2ecf20Sopenharmony_ci * voltage: 4..3 (2) 378c2ecf20Sopenharmony_ci * mA: 2..0 (3) 388c2ecf20Sopenharmony_ci * 398c2ecf20Sopenharmony_ci * MSB of each field is presence bit for the config. 408c2ecf20Sopenharmony_ci */ 418c2ecf20Sopenharmony_ci#define PULL_PRESENT (1 << 6) 428c2ecf20Sopenharmony_ci#define PULL_SHIFT 5 438c2ecf20Sopenharmony_ci#define VOL_PRESENT (1 << 4) 448c2ecf20Sopenharmony_ci#define VOL_SHIFT 3 458c2ecf20Sopenharmony_ci#define MA_PRESENT (1 << 2) 468c2ecf20Sopenharmony_ci#define MA_SHIFT 0 478c2ecf20Sopenharmony_ci#define CONFIG_TO_PULL(c) ((c) >> PULL_SHIFT & 0x1) 488c2ecf20Sopenharmony_ci#define CONFIG_TO_VOL(c) ((c) >> VOL_SHIFT & 0x1) 498c2ecf20Sopenharmony_ci#define CONFIG_TO_MA(c) ((c) >> MA_SHIFT & 0x3) 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_cistruct mxs_function { 528c2ecf20Sopenharmony_ci const char *name; 538c2ecf20Sopenharmony_ci const char **groups; 548c2ecf20Sopenharmony_ci unsigned ngroups; 558c2ecf20Sopenharmony_ci}; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_cistruct mxs_group { 588c2ecf20Sopenharmony_ci const char *name; 598c2ecf20Sopenharmony_ci unsigned int *pins; 608c2ecf20Sopenharmony_ci unsigned npins; 618c2ecf20Sopenharmony_ci u8 *muxsel; 628c2ecf20Sopenharmony_ci u8 config; 638c2ecf20Sopenharmony_ci}; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistruct mxs_regs { 668c2ecf20Sopenharmony_ci u16 muxsel; 678c2ecf20Sopenharmony_ci u16 drive; 688c2ecf20Sopenharmony_ci u16 pull; 698c2ecf20Sopenharmony_ci}; 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_cistruct mxs_pinctrl_soc_data { 728c2ecf20Sopenharmony_ci const struct mxs_regs *regs; 738c2ecf20Sopenharmony_ci const struct pinctrl_pin_desc *pins; 748c2ecf20Sopenharmony_ci unsigned npins; 758c2ecf20Sopenharmony_ci struct mxs_function *functions; 768c2ecf20Sopenharmony_ci unsigned nfunctions; 778c2ecf20Sopenharmony_ci struct mxs_group *groups; 788c2ecf20Sopenharmony_ci unsigned ngroups; 798c2ecf20Sopenharmony_ci}; 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ciint mxs_pinctrl_probe(struct platform_device *pdev, 828c2ecf20Sopenharmony_ci struct mxs_pinctrl_soc_data *soc); 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#endif /* __PINCTRL_MXS_H */ 85