1*1e67465dSInochi Amaoto /* SPDX-License-Identifier: GPL-2.0 */ 2*1e67465dSInochi Amaoto /* 3*1e67465dSInochi Amaoto * Copyright (C) 2024 Inochi Amaoto <inochiama@outlook.com> 4*1e67465dSInochi Amaoto */ 5*1e67465dSInochi Amaoto 6*1e67465dSInochi Amaoto #ifndef _PINCTRL_SOPHGO_SG2042_H 7*1e67465dSInochi Amaoto #define _PINCTRL_SOPHGO_SG2042_H 8*1e67465dSInochi Amaoto 9*1e67465dSInochi Amaoto #include <linux/bits.h> 10*1e67465dSInochi Amaoto #include <linux/bitfield.h> 11*1e67465dSInochi Amaoto #include <linux/device.h> 12*1e67465dSInochi Amaoto #include <linux/mutex.h> 13*1e67465dSInochi Amaoto #include <linux/spinlock.h> 14*1e67465dSInochi Amaoto #include <linux/platform_device.h> 15*1e67465dSInochi Amaoto #include <linux/pinctrl/pinctrl.h> 16*1e67465dSInochi Amaoto #include <linux/pinctrl/pinconf.h> 17*1e67465dSInochi Amaoto 18*1e67465dSInochi Amaoto #include "pinctrl-sophgo.h" 19*1e67465dSInochi Amaoto 20*1e67465dSInochi Amaoto #define PIN_FLAG_DEFAULT 0 21*1e67465dSInochi Amaoto #define PIN_FLAG_WRITE_HIGH BIT(0) 22*1e67465dSInochi Amaoto #define PIN_FLAG_ONLY_ONE_PULL BIT(1) 23*1e67465dSInochi Amaoto #define PIN_FLAG_NO_PINMUX BIT(2) 24*1e67465dSInochi Amaoto #define PIN_FLAG_NO_OEX_EN BIT(3) 25*1e67465dSInochi Amaoto #define PIN_FLAG_IS_ETH BIT(4) 26*1e67465dSInochi Amaoto 27*1e67465dSInochi Amaoto struct sg2042_pin { 28*1e67465dSInochi Amaoto struct sophgo_pin pin; 29*1e67465dSInochi Amaoto u16 offset; 30*1e67465dSInochi Amaoto }; 31*1e67465dSInochi Amaoto 32*1e67465dSInochi Amaoto #define sophgo_to_sg2042_pin(_pin) \ 33*1e67465dSInochi Amaoto container_of((_pin), struct sg2042_pin, pin) 34*1e67465dSInochi Amaoto 35*1e67465dSInochi Amaoto extern const struct pinctrl_ops sg2042_pctrl_ops; 36*1e67465dSInochi Amaoto extern const struct pinmux_ops sg2042_pmx_ops; 37*1e67465dSInochi Amaoto extern const struct pinconf_ops sg2042_pconf_ops; 38*1e67465dSInochi Amaoto extern const struct sophgo_cfg_ops sg2042_cfg_ops; 39*1e67465dSInochi Amaoto 40*1e67465dSInochi Amaoto #define SG2042_GENERAL_PIN(_id, _offset, _flag) \ 41*1e67465dSInochi Amaoto { \ 42*1e67465dSInochi Amaoto .pin = { \ 43*1e67465dSInochi Amaoto .id = (_id), \ 44*1e67465dSInochi Amaoto .flags = (_flag), \ 45*1e67465dSInochi Amaoto }, \ 46*1e67465dSInochi Amaoto .offset = (_offset), \ 47*1e67465dSInochi Amaoto } 48*1e67465dSInochi Amaoto 49*1e67465dSInochi Amaoto #endif 50