// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2025 MediaTek Inc.
* Alice Chao <alice.chao@mediatek.com>
* Copyright (c) 2026 Jolla Mobile Ltd
* Nikolai Burov <nikolai.burov@jolla.com>
*/
#include <linux/module.h>
#include "pinctrl-mtk-mt6858.h"
#include "pinctrl-paris.h"
/* MT6858 have multiple bases to program pin configuration listed as the below:
* GPIO_BASE: 0x10005000
* IOCFG_LM_BASE: 0x11B20000
* IOCFG_RB_BASE: 0x11C10000
* IOCFG_BM2_BASE: 0x11D10000
* IOCFG_BM_BASE: 0x11D30000
* IOCFG_BM1_BASE: 0x11D40000
* IOCFG_LT_BASE: 0x11E20000
* IOCFG_LT1_BASE: 0x11E30000
* IOCFG_RT_BASE: 0x11ED0000
* IOCFG_RT1_BASE: 0x11EE0000
* _i_based could be used to indicate what base the pin should be mapped into.
*/
#define PIN_FIELD_BASE(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits) \
PIN_FIELD_CALC(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits, \
32, 0)
static const struct mtk_pin_field_calc mt6858_pin_mode_range[] = {
/* Pin mode field is 5 bits with 8 bit stride */
PIN_FIELD(0, 196, 0x0300, 0x10, 0, 8),
};
static const struct mtk_pin_field_calc mt6858_pin_dir_range[] = {
PIN_FIELD(0, 196, 0x0000, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6858_pin_di_range[] = {
PIN_FIELD(0, 196, 0x0200, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6858_pin_do_range[] = {
PIN_FIELD(0, 196, 0x0100, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6858_pin_ies_range[] = {
PIN_FIELD_BASE(0, 0, 8, 0x0060, 0x10, 4, 1),
PIN_FIELD_BASE(1, 1, 8, 0x0060, 0x10, 5, 1),
PIN_FIELD_BASE