Initial commit: Linux kernel 4.19 for Unplugged OS

This commit is contained in:
ziv committed 2025-10-06 13:52:42 +00:00
commit d30235b04c
80519 files changed
+35800681

No files matched your search

+200
View File
@@ -0,0 +1,200 @@
menu "MediaTek pinctrl drivers"
depends on ARCH_MEDIATEK || COMPILE_TEST
config EINT_MTK
tristate "MediaTek External Interrupt Support"
depends on PINCTRL_MTK || PINCTRL_MTK_MOORE || PINCTRL_MTK_PARIS || COMPILE_TEST
select GPIOLIB
select IRQ_DOMAIN
default y if PINCTRL_MTK || PINCTRL_MTK_MOORE
default PINCTRL_MTK_PARIS
config PINCTRL_MTK
bool
depends on OF
select PINMUX
select GENERIC_PINCONF
select GPIOLIB
select EINT_MTK
select OF_GPIO
config PINCTRL_MTK_V2
tristate
config PINCTRL_MTK_MOORE
bool
depends on OF
select GENERIC_PINCONF
select GENERIC_PINCTRL_GROUPS
select GENERIC_PINMUX_FUNCTIONS
select GPIOLIB
select EINT_MTK
select OF_GPIO
select PINCTRL_MTK_V2
config PINCTRL_MTK_PARIS
tristate
depends on OF
select PINMUX
select GENERIC_PINCONF
select GPIOLIB
select EINT_MTK
select OF_GPIO
select PINCTRL_MTK_V2
# For ARMv7 SoCs
config PINCTRL_MT2701
bool "Mediatek MT2701 pin control"
depends on MACH_MT7623 || MACH_MT2701 || COMPILE_TEST
depends on OF
default MACH_MT2701
select PINCTRL_MTK
config PINCTRL_MT7623
bool "Mediatek MT7623 pin control with generic binding"
depends on MACH_MT7623 || COMPILE_TEST
depends on OF
default MACH_MT7623
select PINCTRL_MTK_MOORE
config PINCTRL_MT7629
bool "Mediatek MT7629 pin control"
depends on MACH_MT7629 || COMPILE_TEST
depends on OF
default MACH_MT7629
select PINCTRL_MTK_MOORE
config PINCTRL_MT8135
bool "Mediatek MT8135 pin control"
depends on MACH_MT8135 || COMPILE_TEST
depends on OF
default MACH_MT8135
select PINCTRL_MTK
config PINCTRL_MT8127
bool "Mediatek MT8127 pin control"
depends on MACH_MT8127 || COMPILE_TEST
depends on OF
select PINCTRL_MTK
# For ARMv8 SoCs
config PINCTRL_MT2712
bool "MediaTek MT2712 pin control"
depends on OF
depends on ARM64 || COMPILE_TEST
select PINCTRL_MTK
config PINCTRL_MT6739
bool "Mediatek MT6739 pin control"
default n
depends on MACH_MT6739
select PINCTRL_MTK_PARIS
config PINCTRL_MT6761
tristate "Mediatek MT6761 pin control"
depends on OF || COMPILE_TEST
select PINCTRL_MTK_PARIS
config PINCTRL_MT6765
tristate "Mediatek MT6765 pin control"
depends on OF || COMPILE_TEST
select PINCTRL_MTK_PARIS
config PINCTRL_MT6771
bool "Mediatek MT6771 pin control"
default n
depends on MACH_MT6771
select PINCTRL_MTK_PARIS
config PINCTRL_MT6877
bool "Mediatek MT6877 pin control"
default n
depends on MACH_MT6877
select PINCTRL_MTK_PARIS
config PINCTRL_MT6833
bool "Mediatek MT6833 pin control"
default n
depends on MACH_MT6833
select PINCTRL_MTK_PARIS
config PINCTRL_MT6853
bool "Mediatek MT6853 pin control"
default n
depends on MACH_MT6853
select PINCTRL_MTK_PARIS
config PINCTRL_MT6873
bool "Mediatek MT6873 pin control"
default n
depends on MACH_MT6873
select PINCTRL_MTK_PARIS
config PINCTRL_MT6877
bool "Mediatek MT6877 pin control"
default n
depends on MACH_MT6877
select PINCTRL_MTK_PARIS
config PINCTRL_MT6779
tristate "Mediatek MT6779 pin control"
depends on OF || COMPILE_TEST
select PINCTRL_MTK_PARIS
config PINCTRL_MT6797
bool "Mediatek MT6797 pin control"
depends on OF
depends on ARM64 || COMPILE_TEST
select PINCTRL_MTK_PARIS
config PINCTRL_MT6885
bool "Mediatek MT6885 pin control"
default n
depends on MACH_MT6885 || MACH_MT6893
select PINCTRL_MTK_PARIS
config PINCTRL_MT7622
bool "MediaTek MT7622 pin control"
depends on OF
depends on ARM64 || COMPILE_TEST
select PINCTRL_MTK_MOORE
config PINCTRL_MT8173
bool "Mediatek MT8173 pin control"
depends on OF
depends on ARM64 || COMPILE_TEST
select PINCTRL_MTK
config PINCTRL_MT8183
bool "Mediatek MT8183 pin control"
depends on OF
depends on ARM64 || COMPILE_TEST
select PINCTRL_MTK_PARIS
# For PMIC
config PINCTRL_MT6397
bool "Mediatek MT6397 pin control"
depends on MFD_MT6397 || COMPILE_TEST
depends on OF
default MFD_MT6397
select PINCTRL_MTK
config PINCTRL_MT6768
bool "Mediatek MT6768 pin control"
default n
depends on MACH_MT6768
select PINCTRL_MTK_PARIS
config PINCTRL_MT6781
bool "Mediatek MT6781 pin control"
default n
depends on MACH_MT6781
select PINCTRL_MTK_PARIS
config PINCTRL_MT6785
bool "Mediatek MT6785 pin control"
default n
depends on MACH_MT6785
select PINCTRL_MTK_PARIS
endmenu
+33
View File
@@ -0,0 +1,33 @@
# SPDX-License-Identifier: GPL-2.0
# Core
obj-$(CONFIG_EINT_MTK) += mtk-eint.o
obj-$(CONFIG_PINCTRL_MTK) += pinctrl-mtk-common.o
obj-$(CONFIG_PINCTRL_MTK_V2) += pinctrl-mtk-common-v2.o
obj-$(CONFIG_PINCTRL_MTK_MOORE) += pinctrl-moore.o
obj-$(CONFIG_PINCTRL_MTK_PARIS) += pinctrl-paris.o pinctrl-mtk-common-v2_debug.o
# SoC Drivers
obj-$(CONFIG_PINCTRL_MT2701) += pinctrl-mt2701.o
obj-$(CONFIG_PINCTRL_MT2712) += pinctrl-mt2712.o
obj-$(CONFIG_PINCTRL_MT8135) += pinctrl-mt8135.o
obj-$(CONFIG_PINCTRL_MT8127) += pinctrl-mt8127.o
obj-$(CONFIG_PINCTRL_MT6761) += pinctrl-mt6761.o
obj-$(CONFIG_PINCTRL_MT6833) += pinctrl-mt6833.o
obj-$(CONFIG_PINCTRL_MT6739) += pinctrl-mt6739.o
obj-$(CONFIG_PINCTRL_MT6765) += pinctrl-mt6765.o
obj-$(CONFIG_PINCTRL_MT6771) += pinctrl-mt6771.o
obj-$(CONFIG_PINCTRL_MT6779) += pinctrl-mt6779.o
obj-$(CONFIG_PINCTRL_MT6797) += pinctrl-mt6797.o
obj-$(CONFIG_PINCTRL_MT7622) += pinctrl-mt7622.o
obj-$(CONFIG_PINCTRL_MT7623) += pinctrl-mt7623.o
obj-$(CONFIG_PINCTRL_MT7629) += pinctrl-mt7629.o
obj-$(CONFIG_PINCTRL_MT8173) += pinctrl-mt8173.o
obj-$(CONFIG_PINCTRL_MT8183) += pinctrl-mt8183.o
obj-$(CONFIG_PINCTRL_MT6397) += pinctrl-mt6397.o
obj-$(CONFIG_PINCTRL_MT6768) += pinctrl-mt6768.o
obj-$(CONFIG_PINCTRL_MT6781) += pinctrl-mt6781.o
obj-$(CONFIG_PINCTRL_MT6877) += pinctrl-mt6877.o
obj-$(CONFIG_PINCTRL_MT6885) += pinctrl-mt6885.o
obj-$(CONFIG_PINCTRL_MT6853) += pinctrl-mt6853.o
obj-$(CONFIG_PINCTRL_MT6873) += pinctrl-mt6873.o
obj-$(CONFIG_PINCTRL_MT6785) += pinctrl-mt6785.o
+506
View File
@@ -0,0 +1,506 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2014-2018 MediaTek Inc.
/*
* Library for MediaTek External Interrupt Support
*
* Author: Maoguang Meng <maoguang.meng@mediatek.com>
* Sean Wang <sean.wang@mediatek.com>
*
*/
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/gpio/driver.h>
#include <linux/io.h>
#include <linux/irqchip/chained_irq.h>
#include <linux/irqdomain.h>
#include <linux/module.h>
#include <linux/of_irq.h>
#include <linux/platform_device.h>
#include "mtk-eint.h"
#define MTK_EINT_EDGE_SENSITIVE 0
#define MTK_EINT_LEVEL_SENSITIVE 1
#define MTK_EINT_DBNC_SET_DBNC_BITS 4
#define MTK_EINT_DBNC_RST_BIT (0x1 << 1)
#define MTK_EINT_DBNC_SET_EN (0x1 << 0)
static const struct mtk_eint_regs mtk_generic_eint_regs = {
.stat = 0x000,
.ack = 0x040,
.mask = 0x080,
.mask_set = 0x0c0,
.mask_clr = 0x100,
.sens = 0x140,
.sens_set = 0x180,
.sens_clr = 0x1c0,
.soft = 0x200,
.soft_set = 0x240,
.soft_clr = 0x280,
.pol = 0x300,
.pol_set = 0x340,
.pol_clr = 0x380,
.dom_en = 0x400,
.dbnc_ctrl = 0x500,
.dbnc_set = 0x600,
.dbnc_clr = 0x700,
};
static void __iomem *mtk_eint_get_offset(struct mtk_eint *eint,
unsigned int eint_num,
unsigned int offset)
{
unsigned int eint_base = 0;
void __iomem *reg;
if (eint_num >= eint->hw->ap_num)
eint_base = eint->hw->ap_num;
reg = eint->base + offset + ((eint_num - eint_base) / 32) * 4;
return reg;
}
static unsigned int mtk_eint_can_en_debounce(struct mtk_eint *eint,
unsigned int eint_num)
{
unsigned int sens;
unsigned int bit = BIT(eint_num % 32);
void __iomem *reg = mtk_eint_get_offset(eint, eint_num,
eint->regs->sens);
if (readl(reg) & bit)
sens = MTK_EINT_LEVEL_SENSITIVE;
else
sens = MTK_EINT_EDGE_SENSITIVE;
if (eint_num < eint->hw->db_cnt && sens != MTK_EINT_EDGE_SENSITIVE)
return 1;
else
return 0;
}
static int mtk_eint_flip_edge(struct mtk_eint *eint, int hwirq)
{
int start_level, curr_level;
unsigned int reg_offset;
u32 mask = BIT(hwirq & 0x1f);
u32 port = (hwirq >> 5) & eint->hw->port_mask;
void __iomem *reg = eint->base + (port << 2);
curr_level = eint->gpio_xlate->get_gpio_state(eint->pctl, hwirq);
do {
start_level = curr_level;
if (start_level)
reg_offset = eint->regs->pol_clr;
else
reg_offset = eint->regs->pol_set;
writel(mask, reg + reg_offset);
curr_level = eint->gpio_xlate->get_gpio_state(eint->pctl,
hwirq);
} while (start_level != curr_level);
return start_level;
}
static void mtk_eint_mask(struct irq_data *d)
{
struct mtk_eint *eint = irq_data_get_irq_chip_data(d);
u32 mask = BIT(d->hwirq & 0x1f);
void __iomem *reg = mtk_eint_get_offset(eint, d->hwirq,
eint->regs->mask_set);
eint->cur_mask[d->hwirq >> 5] &= ~mask;
writel(mask, reg);
}
static void mtk_eint_unmask(struct irq_data *d)
{
struct mtk_eint *eint = irq_data_get_irq_chip_data(d);
u32 mask = BIT(d->hwirq & 0x1f);
void __iomem *reg = mtk_eint_get_offset(eint, d->hwirq,
eint->regs->mask_clr);
eint->cur_mask[d->hwirq >> 5] |= mask;
writel(mask, reg);
if (eint->dual_edge[d->hwirq])
mtk_eint_flip_edge(eint, d->hwirq);
}
static unsigned int mtk_eint_get_mask(struct mtk_eint *eint,
unsigned int eint_num)
{
unsigned int bit = BIT(eint_num % 32);
void __iomem *reg = mtk_eint_get_offset(eint, eint_num,
eint->regs->mask);
return !!(readl(reg) & bit);
}
static void mtk_eint_ack(struct irq_data *d)
{
struct mtk_eint *eint = irq_data_get_irq_chip_data(d);
u32 mask = BIT(d->hwirq & 0x1f);
void __iomem *reg = mtk_eint_get_offset(eint, d->hwirq,
eint->regs->ack);
writel(mask, reg);
}
static int mtk_eint_set_type(struct irq_data *d, unsigned int type)
{
struct mtk_eint *eint = irq_data_get_irq_chip_data(d);
u32 mask = BIT(d->hwirq & 0x1f);
void __iomem *reg;
if (((type & IRQ_TYPE_EDGE_BOTH) && (type & IRQ_TYPE_LEVEL_MASK)) ||
((type & IRQ_TYPE_LEVEL_MASK) == IRQ_TYPE_LEVEL_MASK)) {
dev_err(eint->dev,
"Can't configure IRQ%d (EINT%lu) for type 0x%X\n",
d->irq, d->hwirq, type);
return -EINVAL;
}
if ((type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH)
eint->dual_edge[d->hwirq] = 1;
else
eint->dual_edge[d->hwirq] = 0;
if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_EDGE_FALLING)) {
reg = mtk_eint_get_offset(eint, d->hwirq, eint->regs->pol_clr);
writel(mask, reg);
} else {
reg = mtk_eint_get_offset(eint, d->hwirq, eint->regs->pol_set);
writel(mask, reg);
}
if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) {
reg = mtk_eint_get_offset(eint, d->hwirq, eint->regs->sens_clr);
writel(mask, reg);
} else {
reg = mtk_eint_get_offset(eint, d->hwirq, eint->regs->sens_set);
writel(mask, reg);
}
if (eint->dual_edge[d->hwirq])
mtk_eint_flip_edge(eint, d->hwirq);
return 0;
}
static int mtk_eint_irq_set_wake(struct irq_data *d, unsigned int on)
{
struct mtk_eint *eint = irq_data_get_irq_chip_data(d);
int shift = d->hwirq & 0x1f;
int reg = d->hwirq >> 5;
if (on)
eint->wake_mask[reg] |= BIT(shift);
else
eint->wake_mask[reg] &= ~BIT(shift);
return 0;
}
static void mtk_eint_chip_write_mask(const struct mtk_eint *eint,
void __iomem *base, u32 *buf)
{
int port;
void __iomem *reg;
for (port = 0; port < eint->hw->ports; port++) {
reg = base + (port << 2);
writel_relaxed(~buf[port], reg + eint->regs->mask_set);
writel_relaxed(buf[port], reg + eint->regs->mask_clr);
}
}
static int mtk_eint_irq_request_resources(struct irq_data *d)
{
struct mtk_eint *eint = irq_data_get_irq_chip_data(d);
struct gpio_chip *gpio_c;
unsigned int gpio_n;
int err;
err = eint->gpio_xlate->get_gpio_n(eint->pctl, d->hwirq,
&gpio_n, &gpio_c);
if (err < 0) {
dev_err(eint->dev, "Can not find pin\n");
return err;
}
err = gpiochip_lock_as_irq(gpio_c, gpio_n);
if (err < 0) {
dev_err(eint->dev, "unable to lock HW IRQ %lu for IRQ\n",
irqd_to_hwirq(d));
return err;
}
err = eint->gpio_xlate->set_gpio_as_eint(eint->pctl, d->hwirq);
if (err < 0) {
dev_err(eint->dev, "Can not eint mode\n");
return err;
}
return 0;
}
static void mtk_eint_irq_release_resources(struct irq_data *d)
{
struct mtk_eint *eint = irq_data_get_irq_chip_data(d);
struct gpio_chip *gpio_c;
unsigned int gpio_n;
eint->gpio_xlate->get_gpio_n(eint->pctl, d->hwirq, &gpio_n,
&gpio_c);
gpiochip_unlock_as_irq(gpio_c, gpio_n);
}
static struct irq_chip mtk_eint_irq_chip = {
.name = "mt-eint",
.irq_disable = mtk_eint_mask,
.irq_mask = mtk_eint_mask,
.irq_unmask = mtk_eint_unmask,
.irq_ack = mtk_eint_ack,
.irq_set_type = mtk_eint_set_type,
.irq_set_wake = mtk_eint_irq_set_wake,
.irq_request_resources = mtk_eint_irq_request_resources,
.irq_release_resources = mtk_eint_irq_release_resources,
};
static unsigned int mtk_eint_hw_init(struct mtk_eint *eint)
{
void __iomem *reg = eint->base + eint->regs->dom_en;
unsigned int i;
for (i = 0; i < eint->hw->ap_num; i += 32) {
writel(0xffffffff, reg);
reg += 4;
}
return 0;
}
static inline void
mtk_eint_debounce_process(struct mtk_eint *eint, int index)
{
unsigned int rst, ctrl_offset;
unsigned int bit, dbnc;
ctrl_offset = (index / 4) * 4 + eint->regs->dbnc_ctrl;
dbnc = readl(eint->base + ctrl_offset);
bit = MTK_EINT_DBNC_SET_EN << ((index % 4) * 8);
if ((bit & dbnc) > 0) {
ctrl_offset = (index / 4) * 4 + eint->regs->dbnc_set;
rst = MTK_EINT_DBNC_RST_BIT << ((index % 4) * 8);
writel(rst, eint->base + ctrl_offset);
}
}
static void mtk_eint_irq_handler(struct irq_desc *desc)
{
struct irq_chip *chip = irq_desc_get_chip(desc);
struct mtk_eint *eint = irq_desc_get_handler_data(desc);
unsigned int status, eint_num;
int offset, mask_offset, index, virq;
void __iomem *reg = mtk_eint_get_offset(eint, 0, eint->regs->stat);
int dual_edge, start_level, curr_level;
chained_irq_enter(chip, desc);
for (eint_num = 0; eint_num < eint->hw->ap_num; eint_num += 32,
reg += 4) {
status = readl(reg);
while (status) {
offset = __ffs(status);
mask_offset = eint_num >> 5;
index = eint_num + offset;
virq = irq_find_mapping(eint->domain, index);
status &= ~BIT(offset);
/*
* If we get an interrupt on pin that was only required
* for wake (but no real interrupt requested), mask the
* interrupt (as would mtk_eint_resume do anyway later
* in the resume sequence).
*/
if (eint->wake_mask[mask_offset] & BIT(offset) &&
!(eint->cur_mask[mask_offset] & BIT(offset))) {
writel_relaxed(BIT(offset), reg -
eint->regs->stat +
eint->regs->mask_set);
}
dual_edge = eint->dual_edge[index];
if (dual_edge) {
/*
* Clear soft-irq in case we raised it last
* time.
*/
writel(BIT(offset), reg - eint->regs->stat +
eint->regs->soft_clr);
start_level =
eint->gpio_xlate->get_gpio_state(eint->pctl,
index);
}
generic_handle_irq(virq);
if (dual_edge) {
curr_level = mtk_eint_flip_edge(eint, index);
/*
* If level changed, we might lost one edge
* interrupt, raised it through soft-irq.
*/
if (start_level != curr_level)
writel(BIT(offset), reg -
eint->regs->stat +
eint->regs->soft_set);
}
if (index < eint->hw->db_cnt)
mtk_eint_debounce_process(eint, index);
}
}
chained_irq_exit(chip, desc);
}
int mtk_eint_do_suspend(struct mtk_eint *eint)
{
mtk_eint_chip_write_mask(eint, eint->base, eint->wake_mask);
return 0;
}
EXPORT_SYMBOL_GPL(mtk_eint_do_suspend);
int mtk_eint_do_resume(struct mtk_eint *eint)
{
mtk_eint_chip_write_mask(eint, eint->base, eint->cur_mask);
return 0;
}
EXPORT_SYMBOL_GPL(mtk_eint_do_resume);
int mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_num,
unsigned int debounce)
{
int virq, eint_offset;
unsigned int set_offset, bit, clr_bit, clr_offset, rst, i, unmask,
dbnc;
static const unsigned int debounce_time[] = {500, 1000, 16000, 32000,
64000, 128000, 256000};
struct irq_data *d;
virq = irq_find_mapping(eint->domain, eint_num);
eint_offset = (eint_num % 4) * 8;
d = irq_get_irq_data(virq);
set_offset = (eint_num / 4) * 4 + eint->regs->dbnc_set;
clr_offset = (eint_num / 4) * 4 + eint->regs->dbnc_clr;
if (!mtk_eint_can_en_debounce(eint, eint_num))
return -EINVAL;
dbnc = ARRAY_SIZE(debounce_time);
for (i = 0; i < ARRAY_SIZE(debounce_time); i++) {
if (debounce <= debounce_time[i]) {
dbnc = i;
break;
}
}
if (!mtk_eint_get_mask(eint, eint_num)) {
mtk_eint_mask(d);
unmask = 1;
} else {
unmask = 0;
}
clr_bit = 0xff << eint_offset;
writel(clr_bit, eint->base + clr_offset);
bit = ((dbnc << MTK_EINT_DBNC_SET_DBNC_BITS) | MTK_EINT_DBNC_SET_EN) <<
eint_offset;
rst = MTK_EINT_DBNC_RST_BIT << eint_offset;
writel(rst | bit, eint->base + set_offset);
/*
* Delay a while (more than 2T) to wait for hw debounce counter reset
* work correctly.
*/
udelay(1);
if (unmask == 1)
mtk_eint_unmask(d);
return 0;
}
EXPORT_SYMBOL_GPL(mtk_eint_set_debounce);
int mtk_eint_find_irq(struct mtk_eint *eint, unsigned long eint_n)
{
int irq;
irq = irq_find_mapping(eint->domain, eint_n);
if (!irq)
return -EINVAL;
return irq;
}
EXPORT_SYMBOL_GPL(mtk_eint_find_irq);
int mtk_eint_do_init(struct mtk_eint *eint)
{
int i;
/* If clients don't assign a specific regs, let's use generic one */
if (!eint->regs)
eint->regs = &mtk_generic_eint_regs;
eint->wake_mask = devm_kcalloc(eint->dev, eint->hw->ports,
sizeof(*eint->wake_mask), GFP_KERNEL);
if (!eint->wake_mask)
return -ENOMEM;
eint->cur_mask = devm_kcalloc(eint->dev, eint->hw->ports,
sizeof(*eint->cur_mask), GFP_KERNEL);
if (!eint->cur_mask)
return -ENOMEM;
eint->dual_edge = devm_kcalloc(eint->dev, eint->hw->ap_num,
sizeof(int), GFP_KERNEL);
if (!eint->dual_edge)
return -ENOMEM;
eint->domain = irq_domain_add_linear(eint->dev->of_node,
eint->hw->ap_num,
&irq_domain_simple_ops, NULL);
if (!eint->domain)
return -ENOMEM;
mtk_eint_hw_init(eint);
for (i = 0; i < eint->hw->ap_num; i++) {
int virq = irq_create_mapping(eint->domain, i);
irq_set_chip_and_handler(virq, &mtk_eint_irq_chip,
handle_level_irq);
irq_set_chip_data(virq, eint);
}
irq_set_chained_handler_and_data(eint->irq, mtk_eint_irq_handler,
eint);
return 0;
}
EXPORT_SYMBOL_GPL(mtk_eint_do_init);
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("MediaTek EINT Driver");
+106
View File
@@ -0,0 +1,106 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2014-2018 MediaTek Inc.
*
* Author: Maoguang Meng <maoguang.meng@mediatek.com>
* Sean Wang <sean.wang@mediatek.com>
*
*/
#ifndef __MTK_EINT_H
#define __MTK_EINT_H
#include <linux/irqdomain.h>
struct mtk_eint_regs {
unsigned int stat;
unsigned int ack;
unsigned int mask;
unsigned int mask_set;
unsigned int mask_clr;
unsigned int sens;
unsigned int sens_set;
unsigned int sens_clr;
unsigned int soft;
unsigned int soft_set;
unsigned int soft_clr;
unsigned int pol;
unsigned int pol_set;
unsigned int pol_clr;
unsigned int dom_en;
unsigned int dbnc_ctrl;
unsigned int dbnc_set;
unsigned int dbnc_clr;
};
struct mtk_eint_hw {
u8 port_mask;
u8 ports;
unsigned int ap_num;
unsigned int db_cnt;
};
struct mtk_eint;
struct mtk_eint_xt {
int (*get_gpio_n)(void *data, unsigned long eint_n,
unsigned int *gpio_n,
struct gpio_chip **gpio_chip);
int (*get_gpio_state)(void *data, unsigned long eint_n);
int (*set_gpio_as_eint)(void *data, unsigned long eint_n);
};
struct mtk_eint {
struct device *dev;
void __iomem *base;
struct irq_domain *domain;
int irq;
int *dual_edge;
u32 *wake_mask;
u32 *cur_mask;
/* Used to fit into various EINT device */
const struct mtk_eint_hw *hw;
const struct mtk_eint_regs *regs;
/* Used to fit into various pinctrl device */
void *pctl;
const struct mtk_eint_xt *gpio_xlate;
};
#if IS_ENABLED(CONFIG_EINT_MTK)
int mtk_eint_do_init(struct mtk_eint *eint);
int mtk_eint_do_suspend(struct mtk_eint *eint);
int mtk_eint_do_resume(struct mtk_eint *eint);
int mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_n,
unsigned int debounce);
int mtk_eint_find_irq(struct mtk_eint *eint, unsigned long eint_n);
#else
static inline int mtk_eint_do_init(struct mtk_eint *eint)
{
return -EOPNOTSUPP;
}
static inline int mtk_eint_do_suspend(struct mtk_eint *eint)
{
return -EOPNOTSUPP;
}
static inline int mtk_eint_do_resume(struct mtk_eint *eint)
{
return -EOPNOTSUPP;
}
static inline int mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_n,
unsigned int debounce)
{
return -EOPNOTSUPP;
}
static inline int mtk_eint_find_irq(struct mtk_eint *eint, unsigned long eint_n)
{
return -EOPNOTSUPP;
}
#endif
#endif /* __MTK_EINT_H */
+690
View File
@@ -0,0 +1,690 @@
// SPDX-License-Identifier: GPL-2.0
/*
* MediaTek Pinctrl Moore Driver, which implement the generic dt-binding
* pinctrl-bindings.txt for MediaTek SoC.
*
* Copyright (C) 2017-2018 MediaTek Inc.
* Author: Sean Wang <sean.wang@mediatek.com>
*
*/
#include <linux/gpio/driver.h>
#include "pinctrl-moore.h"
#define PINCTRL_PINCTRL_DEV KBUILD_MODNAME
/* Custom pinconf parameters */
#define MTK_PIN_CONFIG_TDSEL (PIN_CONFIG_END + 1)
#define MTK_PIN_CONFIG_RDSEL (PIN_CONFIG_END + 2)
#define MTK_PIN_CONFIG_PU_ADV (PIN_CONFIG_END + 3)
#define MTK_PIN_CONFIG_PD_ADV (PIN_CONFIG_END + 4)
static const struct pinconf_generic_params mtk_custom_bindings[] = {
{"mediatek,tdsel", MTK_PIN_CONFIG_TDSEL, 0},
{"mediatek,rdsel", MTK_PIN_CONFIG_RDSEL, 0},
{"mediatek,pull-up-adv", MTK_PIN_CONFIG_PU_ADV, 1},
{"mediatek,pull-down-adv", MTK_PIN_CONFIG_PD_ADV, 1},
};
#ifdef CONFIG_DEBUG_FS
static const struct pin_config_item mtk_conf_items[] = {
PCONFDUMP(MTK_PIN_CONFIG_TDSEL, "tdsel", NULL, true),
PCONFDUMP(MTK_PIN_CONFIG_RDSEL, "rdsel", NULL, true),
PCONFDUMP(MTK_PIN_CONFIG_PU_ADV, "pu-adv", NULL, true),
PCONFDUMP(MTK_PIN_CONFIG_PD_ADV, "pd-adv", NULL, true),
};
#endif
static int mtk_pinmux_set_mux(struct pinctrl_dev *pctldev,
unsigned int selector, unsigned int group)
{
struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
struct function_desc *func;
struct group_desc *grp;
int i;
func = pinmux_generic_get_function(pctldev, selector);
if (!func)
return -EINVAL;
grp = pinctrl_generic_get_group(pctldev, group);
if (!grp)
return -EINVAL;
dev_dbg(pctldev->dev, "enable function %s group %s\n",
func->name, grp->name);
for (i = 0; i < grp->num_pins; i++) {
const struct mtk_pin_desc *desc;
int *pin_modes = grp->data;
int pin = grp->pins[i];
desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];
mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_MODE,
pin_modes[i]);
}
return 0;
}
static int mtk_pinmux_gpio_request_enable(struct pinctrl_dev *pctldev,
struct pinctrl_gpio_range *range,
unsigned int pin)
{
struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
const struct mtk_pin_desc *desc;
desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];
return mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_MODE,
hw->soc->gpio_m);
}
static int mtk_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
struct pinctrl_gpio_range *range,
unsigned int pin, bool input)
{
struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
const struct mtk_pin_desc *desc;
desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];
/* hardware would take 0 as input direction */
return mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR, !input);
}
static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
unsigned int pin, unsigned long *config)
{
struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
u32 param = pinconf_to_config_param(*config);
int val, val2, err, reg, ret = 1;
const struct mtk_pin_desc *desc;
desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];
switch (param) {
case PIN_CONFIG_BIAS_DISABLE:
if (hw->soc->bias_disable_get) {
err = hw->soc->bias_disable_get(hw, desc, &ret);
if (err)
return err;
} else {
return -ENOTSUPP;
}
break;
case PIN_CONFIG_BIAS_PULL_UP:
if (hw->soc->bias_get) {
err = hw->soc->bias_get(hw, desc, 1, &ret);
if (err)
return err;
} else {
return -ENOTSUPP;
}
break;
case PIN_CONFIG_BIAS_PULL_DOWN:
if (hw->soc->bias_get) {
err = hw->soc->bias_get(hw, desc, 0, &ret);
if (err)
return err;
} else {
return -ENOTSUPP;
}
break;
case PIN_CONFIG_SLEW_RATE:
err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_SR, &val);
if (err)
return err;
if (!val)
return -EINVAL;
break;
case PIN_CONFIG_INPUT_ENABLE:
case PIN_CONFIG_OUTPUT_ENABLE:
err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &val);
if (err)
return err;
/* HW takes input mode as zero; output mode as non-zero */
if ((val && param == PIN_CONFIG_INPUT_ENABLE) ||
(!val && param == PIN_CONFIG_OUTPUT_ENABLE))
return -EINVAL;
break;
case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &val);
if (err)
return err;
err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_SMT, &val2);
if (err)
return err;
if (val || !val2)
return -EINVAL;
break;
case PIN_CONFIG_DRIVE_STRENGTH:
if (hw->soc->drive_get) {
err = hw->soc->drive_get(hw, desc, &ret);
if (err)
return err;
} else {
err = -ENOTSUPP;
}
break;
case MTK_PIN_CONFIG_TDSEL:
case MTK_PIN_CONFIG_RDSEL:
reg = (param == MTK_PIN_CONFIG_TDSEL) ?
PINCTRL_PIN_REG_TDSEL : PINCTRL_PIN_REG_RDSEL;
err = mtk_hw_get_value(hw, desc, reg, &val);
if (err)
return err;
ret = val;
break;
case MTK_PIN_CONFIG_PU_ADV:
case MTK_PIN_CONFIG_PD_ADV:
if (hw->soc->adv_pull_get) {
bool pullup;
pullup = param == MTK_PIN_CONFIG_PU_ADV;
err = hw->soc->adv_pull_get(hw, desc, pullup, &ret);
if (err)
return err;
} else {
return -ENOTSUPP;
}
break;
default:
return -ENOTSUPP;
}
*config = pinconf_to_config_packed(param, ret);
return 0;
}
static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
unsigned long *configs, unsigned int num_configs)
{
struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
const struct mtk_pin_desc *desc;
u32 reg, param, arg;
int cfg, err = 0;
desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];
for (cfg = 0; cfg < num_configs; cfg++) {
param = pinconf_to_config_param(configs[cfg]);
arg = pinconf_to_config_argument(configs[cfg]);
switch (param) {
case PIN_CONFIG_BIAS_DISABLE:
if (hw->soc->bias_disable_set) {
err = hw->soc->bias_disable_set(hw, desc);
if (err)
return err;
} else {
return -ENOTSUPP;
}
break;
case PIN_CONFIG_BIAS_PULL_UP:
if (hw->soc->bias_set) {
err = hw->soc->bias_set(hw, desc, 1);
if (err)
return err;
} else {
return -ENOTSUPP;
}
break;
case PIN_CONFIG_BIAS_PULL_DOWN:
if (hw->soc->bias_set) {
err = hw->soc->bias_set(hw, desc, 0);
if (err)
return err;
} else {
return -ENOTSUPP;
}
break;
case PIN_CONFIG_OUTPUT_ENABLE:
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_SMT,
MTK_DISABLE);
if (err)
goto err;
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR,
MTK_OUTPUT);
if (err)
goto err;
break;
case PIN_CONFIG_INPUT_ENABLE:
if (hw->soc->ies_present) {
mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_IES,
MTK_ENABLE);
}
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR,
MTK_INPUT);
if (err)
goto err;
break;
case PIN_CONFIG_SLEW_RATE:
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_SR,
arg);
if (err)
goto err;
break;
case PIN_CONFIG_OUTPUT:
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR,
MTK_OUTPUT);
if (err)
goto err;
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DO,
arg);
if (err)
goto err;
break;
case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
/* arg = 1: Input mode & SMT enable ;
* arg = 0: Output mode & SMT disable
*/
arg = arg ? 2 : 1;
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR,
arg & 1);
if (err)
goto err;
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_SMT,
!!(arg & 2));
if (err)
goto err;
break;
case PIN_CONFIG_DRIVE_STRENGTH:
if (hw->soc->drive_set) {
err = hw->soc->drive_set(hw, desc, arg);
if (err)
return err;
} else {
err = -ENOTSUPP;
}
break;
case MTK_PIN_CONFIG_TDSEL:
case MTK_PIN_CONFIG_RDSEL:
reg = (param == MTK_PIN_CONFIG_TDSEL) ?
PINCTRL_PIN_REG_TDSEL : PINCTRL_PIN_REG_RDSEL;
err = mtk_hw_set_value(hw, desc, reg, arg);
if (err)
goto err;
break;
case MTK_PIN_CONFIG_PU_ADV:
case MTK_PIN_CONFIG_PD_ADV:
if (hw->soc->adv_pull_set) {
bool pullup;
pullup = param == MTK_PIN_CONFIG_PU_ADV;
err = hw->soc->adv_pull_set(hw, desc, pullup,
arg);
if (err)
return err;
} else {
return -ENOTSUPP;
}
break;
default:
err = -ENOTSUPP;
}
}
err:
return err;
}
static int mtk_pinconf_group_get(struct pinctrl_dev *pctldev,
unsigned int group, unsigned long *config)
{
const unsigned int *pins;
unsigned int i, npins, old = 0;
int ret;
ret = pinctrl_generic_get_group_pins(pctldev, group, &pins, &npins);
if (ret)
return ret;
for (i = 0; i < npins; i++) {
if (mtk_pinconf_get(pctldev, pins[i], config))
return -ENOTSUPP;
/* configs do not match between two pins */
if (i && old != *config)
return -ENOTSUPP;
old = *config;
}
return 0;
}
static int mtk_pinconf_group_set(struct pinctrl_dev *pctldev,
unsigned int group, unsigned long *configs,
unsigned int num_configs)
{
const unsigned int *pins;
unsigned int i, npins;
int ret;
ret = pinctrl_generic_get_group_pins(pctldev, group, &pins, &npins);
if (ret)
return ret;
for (i = 0; i < npins; i++) {
ret = mtk_pinconf_set(pctldev, pins[i], configs, num_configs);
if (ret)
return ret;
}
return 0;
}
static const struct pinctrl_ops mtk_pctlops = {
.get_groups_count = pinctrl_generic_get_group_count,
.get_group_name = pinctrl_generic_get_group_name,
.get_group_pins = pinctrl_generic_get_group_pins,
.dt_node_to_map = pinconf_generic_dt_node_to_map_all,
.dt_free_map = pinconf_generic_dt_free_map,
};
static const struct pinmux_ops mtk_pmxops = {
.get_functions_count = pinmux_generic_get_function_count,
.get_function_name = pinmux_generic_get_function_name,
.get_function_groups = pinmux_generic_get_function_groups,
.set_mux = mtk_pinmux_set_mux,
.gpio_request_enable = mtk_pinmux_gpio_request_enable,
.gpio_set_direction = mtk_pinmux_gpio_set_direction,
.strict = true,
};
static const struct pinconf_ops mtk_confops = {
.is_generic = true,
.pin_config_get = mtk_pinconf_get,
.pin_config_set = mtk_pinconf_set,
.pin_config_group_get = mtk_pinconf_group_get,
.pin_config_group_set = mtk_pinconf_group_set,
.pin_config_config_dbg_show = pinconf_generic_dump_config,
};
static struct pinctrl_desc mtk_desc = {
.name = PINCTRL_PINCTRL_DEV,
.pctlops = &mtk_pctlops,
.pmxops = &mtk_pmxops,
.confops = &mtk_confops,
.owner = THIS_MODULE,
};
static int mtk_gpio_get(struct gpio_chip *chip, unsigned int gpio)
{
struct mtk_pinctrl *hw = gpiochip_get_data(chip);
const struct mtk_pin_desc *desc;
int value, err;
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DI, &value);
if (err)
return err;
return !!value;
}
static void mtk_gpio_set(struct gpio_chip *chip, unsigned int gpio, int value)
{
struct mtk_pinctrl *hw = gpiochip_get_data(chip);
const struct mtk_pin_desc *desc;
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DO, !!value);
}
static int mtk_gpio_direction_input(struct gpio_chip *chip, unsigned int gpio)
{
return pinctrl_gpio_direction_input(chip->base + gpio);
}
static int mtk_gpio_direction_output(struct gpio_chip *chip, unsigned int gpio,
int value)
{
mtk_gpio_set(chip, gpio, value);
return pinctrl_gpio_direction_output(chip->base + gpio);
}
static int mtk_gpio_to_irq(struct gpio_chip *chip, unsigned int offset)
{
struct mtk_pinctrl *hw = gpiochip_get_data(chip);
const struct mtk_pin_desc *desc;
if (!hw->eint)
return -ENOTSUPP;
desc = (const struct mtk_pin_desc *)&hw->soc->pins[offset];
if (desc->eint.eint_n == (u16)EINT_NA)
return -ENOTSUPP;
return mtk_eint_find_irq(hw->eint, desc->eint.eint_n);
}
static int mtk_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
unsigned long config)
{
struct mtk_pinctrl *hw = gpiochip_get_data(chip);
const struct mtk_pin_desc *desc;
u32 debounce;
desc = (const struct mtk_pin_desc *)&hw->soc->pins[offset];
if (!hw->eint ||
pinconf_to_config_param(config) != PIN_CONFIG_INPUT_DEBOUNCE ||
desc->eint.eint_n == (u16)EINT_NA)
return -ENOTSUPP;
debounce = pinconf_to_config_argument(config);
return mtk_eint_set_debounce(hw->eint, desc->eint.eint_n, debounce);
}
static int mtk_build_gpiochip(struct mtk_pinctrl *hw, struct device_node *np)
{
struct gpio_chip *chip = &hw->chip;
int ret;
chip->label = PINCTRL_PINCTRL_DEV;
chip->parent = hw->dev;
chip->request = gpiochip_generic_request;
chip->free = gpiochip_generic_free;
chip->direction_input = mtk_gpio_direction_input;
chip->direction_output = mtk_gpio_direction_output;
chip->get = mtk_gpio_get;
chip->set = mtk_gpio_set;
chip->to_irq = mtk_gpio_to_irq,
chip->set_config = mtk_gpio_set_config,
chip->base = -1;
chip->ngpio = hw->soc->npins;
chip->of_node = np;
chip->of_gpio_n_cells = 2;
ret = gpiochip_add_data(chip, hw);
if (ret < 0)
return ret;
/* Just for backward compatible for these old pinctrl nodes without
* "gpio-ranges" property. Otherwise, called directly from a
* DeviceTree-supported pinctrl driver is DEPRECATED.
* Please see Section 2.1 of
* Documentation/devicetree/bindings/gpio/gpio.txt on how to
* bind pinctrl and gpio drivers via the "gpio-ranges" property.
*/
if (!of_find_property(np, "gpio-ranges", NULL)) {
ret = gpiochip_add_pin_range(chip, dev_name(hw->dev), 0, 0,
chip->ngpio);
if (ret < 0) {
gpiochip_remove(chip);
return ret;
}
}
return 0;
}
static int mtk_build_groups(struct mtk_pinctrl *hw)
{
int err, i;
for (i = 0; i < hw->soc->ngrps; i++) {
const struct group_desc *group = hw->soc->grps + i;
err = pinctrl_generic_add_group(hw->pctrl, group->name,
group->pins, group->num_pins,
group->data);
if (err < 0) {
dev_err(hw->dev, "Failed to register group %s\n",
group->name);
return err;
}
}
return 0;
}
static int mtk_build_functions(struct mtk_pinctrl *hw)
{
int i, err;
for (i = 0; i < hw->soc->nfuncs ; i++) {
const struct function_desc *func = hw->soc->funcs + i;
err = pinmux_generic_add_function(hw->pctrl, func->name,
func->group_names,
func->num_group_names,
func->data);
if (err < 0) {
dev_err(hw->dev, "Failed to register function %s\n",
func->name);
return err;
}
}
return 0;
}
int mtk_moore_pinctrl_probe(struct platform_device *pdev,
const struct mtk_pin_soc *soc)
{
struct pinctrl_pin_desc *pins;
struct resource *res;
struct mtk_pinctrl *hw;
int err, i;
hw = devm_kzalloc(&pdev->dev, sizeof(*hw), GFP_KERNEL);
if (!hw)
return -ENOMEM;
hw->soc = soc;
hw->dev = &pdev->dev;
if (!hw->soc->nbase_names) {
dev_err(&pdev->dev,
"SoC should be assigned at least one register base\n");
return -EINVAL;
}
hw->base = devm_kmalloc_array(&pdev->dev, hw->soc->nbase_names,
sizeof(*hw->base), GFP_KERNEL);
if (!hw->base)
return -ENOMEM;
for (i = 0; i < hw->soc->nbase_names; i++) {
res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
hw->soc->base_names[i]);
if (!res) {
dev_err(&pdev->dev, "missing IO resource\n");
return -ENXIO;
}
hw->base[i] = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(hw->base[i]))
return PTR_ERR(hw->base[i]);
}
hw->nbase = hw->soc->nbase_names;
/* Copy from internal struct mtk_pin_desc to register to the core */
pins = devm_kmalloc_array(&pdev->dev, hw->soc->npins, sizeof(*pins),
GFP_KERNEL);
if (!pins)
return -ENOMEM;
for (i = 0; i < hw->soc->npins; i++) {
pins[i].number = hw->soc->pins[i].number;
pins[i].name = hw->soc->pins[i].name;
}
/* Setup pins descriptions per SoC types */
mtk_desc.pins = (const struct pinctrl_pin_desc *)pins;
mtk_desc.npins = hw->soc->npins;
mtk_desc.num_custom_params = ARRAY_SIZE(mtk_custom_bindings);
mtk_desc.custom_params = mtk_custom_bindings;
#ifdef CONFIG_DEBUG_FS
mtk_desc.custom_conf_items = mtk_conf_items;
#endif
err = devm_pinctrl_register_and_init(&pdev->dev, &mtk_desc, hw,
&hw->pctrl);
if (err)
return err;
/* Setup groups descriptions per SoC types */
err = mtk_build_groups(hw);
if (err) {
dev_err(&pdev->dev, "Failed to build groups\n");
return err;
}
/* Setup functions descriptions per SoC types */
err = mtk_build_functions(hw);
if (err) {
dev_err(&pdev->dev, "Failed to build functions\n");
return err;
}
/* For able to make pinctrl_claim_hogs, we must not enable pinctrl
* until all groups and functions are being added one.
*/
err = pinctrl_enable(hw->pctrl);
if (err)
return err;
err = mtk_build_eint(hw, pdev);
if (err)
dev_warn(&pdev->dev,
"Failed to add EINT, but pinctrl still can work\n");
/* Build gpiochip should be after pinctrl_enable is done */
err = mtk_build_gpiochip(hw, pdev->dev.of_node);
if (err) {
dev_err(&pdev->dev, "Failed to add gpio_chip\n");
return err;
}
platform_set_drvdata(pdev, hw);
return 0;
}
+51
View File
@@ -0,0 +1,51 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2017-2018 MediaTek Inc.
*
* Author: Sean Wang <sean.wang@mediatek.com>
*
*/
#ifndef __PINCTRL_MOORE_H
#define __PINCTRL_MOORE_H
#include <linux/io.h>
#include <linux/init.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/pinctrl/pinmux.h>
#include <linux/pinctrl/pinconf.h>
#include <linux/pinctrl/pinconf-generic.h>
#include "../core.h"
#include "../pinconf.h"
#include "../pinmux.h"
#include "mtk-eint.h"
#include "pinctrl-mtk-common-v2.h"
#define MTK_RANGE(_a) { .range = (_a), .nranges = ARRAY_SIZE(_a), }
#define MTK_PIN(_number, _name, _eint_m, _eint_n, _drv_n) { \
.number = _number, \
.name = _name, \
.eint = { \
.eint_m = _eint_m, \
.eint_n = _eint_n, \
}, \
.drv_n = _drv_n, \
.funcs = NULL, \
}
#define PINCTRL_PIN_GROUP(name, id) \
{ \
name, \
id##_pins, \
ARRAY_SIZE(id##_pins), \
id##_funcs, \
}
int mtk_moore_pinctrl_probe(struct platform_device *pdev,
const struct mtk_pin_soc *soc);
#endif /* __PINCTRL_MOORE_H */
+567
View File
@@ -0,0 +1,567 @@
/*
* Copyright (c) 2015 MediaTek Inc.
* Author: Biao Huang <biao.huang@mediatek.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <dt-bindings/pinctrl/mt65xx.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/regmap.h>
#include "pinctrl-mtk-common.h"
#include "pinctrl-mtk-mt2701.h"
/**
* struct mtk_spec_pinmux_set
* - For special pins' mode setting
* @pin: The pin number.
* @offset: The offset of extra setting register.
* @bit: The bit of extra setting register.
*/
struct mtk_spec_pinmux_set {
unsigned short pin;
unsigned short offset;
unsigned char bit;
};
#define MTK_PINMUX_SPEC(_pin, _offset, _bit) \
{ \
.pin = _pin, \
.offset = _offset, \
.bit = _bit, \
}
static const struct mtk_drv_group_desc mt2701_drv_grp[] = {
/* 0E4E8SR 4/8/12/16 */
MTK_DRV_GRP(4, 16, 1, 2, 4),
/* 0E2E4SR 2/4/6/8 */
MTK_DRV_GRP(2, 8, 1, 2, 2),
/* E8E4E2 2/4/6/8/10/12/14/16 */
MTK_DRV_GRP(2, 16, 0, 2, 2)
};
static const struct mtk_pin_drv_grp mt2701_pin_drv[] = {
MTK_PIN_DRV_GRP(0, 0xf50, 0, 1),
MTK_PIN_DRV_GRP(1, 0xf50, 0, 1),
MTK_PIN_DRV_GRP(2, 0xf50, 0, 1),
MTK_PIN_DRV_GRP(3, 0xf50, 0, 1),
MTK_PIN_DRV_GRP(4, 0xf50, 0, 1),
MTK_PIN_DRV_GRP(5, 0xf50, 0, 1),
MTK_PIN_DRV_GRP(6, 0xf50, 0, 1),
MTK_PIN_DRV_GRP(7, 0xf50, 4, 1),
MTK_PIN_DRV_GRP(8, 0xf50, 4, 1),
MTK_PIN_DRV_GRP(9, 0xf50, 4, 1),
MTK_PIN_DRV_GRP(10, 0xf50, 8, 1),
MTK_PIN_DRV_GRP(11, 0xf50, 8, 1),
MTK_PIN_DRV_GRP(12, 0xf50, 8, 1),
MTK_PIN_DRV_GRP(13, 0xf50, 8, 1),
MTK_PIN_DRV_GRP(14, 0xf50, 12, 0),
MTK_PIN_DRV_GRP(15, 0xf50, 12, 0),
MTK_PIN_DRV_GRP(16, 0xf60, 0, 0),
MTK_PIN_DRV_GRP(17, 0xf60, 0, 0),
MTK_PIN_DRV_GRP(18, 0xf60, 4, 0),
MTK_PIN_DRV_GRP(19, 0xf60, 4, 0),
MTK_PIN_DRV_GRP(20, 0xf60, 4, 0),
MTK_PIN_DRV_GRP(21, 0xf60, 4, 0),
MTK_PIN_DRV_GRP(22, 0xf60, 8, 0),
MTK_PIN_DRV_GRP(23, 0xf60, 8, 0),
MTK_PIN_DRV_GRP(24, 0xf60, 8, 0),
MTK_PIN_DRV_GRP(25, 0xf60, 8, 0),
MTK_PIN_DRV_GRP(26, 0xf60, 8, 0),
MTK_PIN_DRV_GRP(27, 0xf60, 12, 0),
MTK_PIN_DRV_GRP(28, 0xf60, 12, 0),
MTK_PIN_DRV_GRP(29, 0xf60, 12, 0),
MTK_PIN_DRV_GRP(30, 0xf60, 0, 0),
MTK_PIN_DRV_GRP(31, 0xf60, 0, 0),
MTK_PIN_DRV_GRP(32, 0xf60, 0, 0),
MTK_PIN_DRV_GRP(33, 0xf70, 0, 0),
MTK_PIN_DRV_GRP(34, 0xf70, 0, 0),
MTK_PIN_DRV_GRP(35, 0xf70, 0, 0),
MTK_PIN_DRV_GRP(36, 0xf70, 0, 0),
MTK_PIN_DRV_GRP(37, 0xf70, 0, 0),
MTK_PIN_DRV_GRP(38, 0xf70, 4, 0),
MTK_PIN_DRV_GRP(39, 0xf70, 8, 1),
MTK_PIN_DRV_GRP(40, 0xf70, 8, 1),
MTK_PIN_DRV_GRP(41, 0xf70, 8, 1),
MTK_PIN_DRV_GRP(42, 0xf70, 8, 1),
MTK_PIN_DRV_GRP(43, 0xf70, 12, 0),
MTK_PIN_DRV_GRP(44, 0xf70, 12, 0),
MTK_PIN_DRV_GRP(45, 0xf70, 12, 0),
MTK_PIN_DRV_GRP(47, 0xf80, 0, 0),
MTK_PIN_DRV_GRP(48, 0xf80, 0, 0),
MTK_PIN_DRV_GRP(49, 0xf80, 4, 0),
MTK_PIN_DRV_GRP(50, 0xf70, 4, 0),
MTK_PIN_DRV_GRP(51, 0xf70, 4, 0),
MTK_PIN_DRV_GRP(52, 0xf70, 4, 0),
MTK_PIN_DRV_GRP(53, 0xf80, 12, 0),
MTK_PIN_DRV_GRP(54, 0xf80, 12, 0),
MTK_PIN_DRV_GRP(55, 0xf80, 12, 0),
MTK_PIN_DRV_GRP(56, 0xf80, 12, 0),
MTK_PIN_DRV_GRP(60, 0xf90, 8, 1),
MTK_PIN_DRV_GRP(61, 0xf90, 8, 1),
MTK_PIN_DRV_GRP(62, 0xf90, 8, 1),
MTK_PIN_DRV_GRP(63, 0xf90, 12, 1),
MTK_PIN_DRV_GRP(64, 0xf90, 12, 1),
MTK_PIN_DRV_GRP(65, 0xf90, 12, 1),
MTK_PIN_DRV_GRP(66, 0xfa0, 0, 1),
MTK_PIN_DRV_GRP(67, 0xfa0, 0, 1),
MTK_PIN_DRV_GRP(68, 0xfa0, 0, 1),
MTK_PIN_DRV_GRP(69, 0xfa0, 0, 1),
MTK_PIN_DRV_GRP(70, 0xfa0, 0, 1),
MTK_PIN_DRV_GRP(71, 0xfa0, 0, 1),
MTK_PIN_DRV_GRP(72, 0xf80, 4, 0),
MTK_PIN_DRV_GRP(73, 0xf80, 4, 0),
MTK_PIN_DRV_GRP(74, 0xf80, 4, 0),
MTK_PIN_DRV_GRP(85, 0xda0, 0, 2),
MTK_PIN_DRV_GRP(86, 0xd90, 0, 2),
MTK_PIN_DRV_GRP(87, 0xdb0, 0, 2),
MTK_PIN_DRV_GRP(88, 0xdb0, 0, 2),
MTK_PIN_DRV_GRP(89, 0xdb0, 0, 2),
MTK_PIN_DRV_GRP(90, 0xdb0, 0, 2),
MTK_PIN_DRV_GRP(105, 0xd40, 0, 2),
MTK_PIN_DRV_GRP(106, 0xd30, 0, 2),
MTK_PIN_DRV_GRP(107, 0xd50, 0, 2),
MTK_PIN_DRV_GRP(108, 0xd50, 0, 2),
MTK_PIN_DRV_GRP(109, 0xd50, 0, 2),
MTK_PIN_DRV_GRP(110, 0xd50, 0, 2),
MTK_PIN_DRV_GRP(111, 0xce0, 0, 2),
MTK_PIN_DRV_GRP(112, 0xce0, 0, 2),
MTK_PIN_DRV_GRP(113, 0xce0, 0, 2),
MTK_PIN_DRV_GRP(114, 0xce0, 0, 2),
MTK_PIN_DRV_GRP(115, 0xce0, 0, 2),
MTK_PIN_DRV_GRP(116, 0xcd0, 0, 2),
MTK_PIN_DRV_GRP(117, 0xcc0, 0, 2),
MTK_PIN_DRV_GRP(118, 0xce0, 0, 2),
MTK_PIN_DRV_GRP(119, 0xce0, 0, 2),
MTK_PIN_DRV_GRP(120, 0xce0, 0, 2),
MTK_PIN_DRV_GRP(121, 0xce0, 0, 2),
MTK_PIN_DRV_GRP(126, 0xf80, 4, 0),
MTK_PIN_DRV_GRP(188, 0xf70, 4, 0),
MTK_PIN_DRV_GRP(189, 0xfe0, 8, 0),
MTK_PIN_DRV_GRP(190, 0xfe0, 8, 0),
MTK_PIN_DRV_GRP(191, 0xfe0, 8, 0),
MTK_PIN_DRV_GRP(192, 0xfe0, 8, 0),
MTK_PIN_DRV_GRP(193, 0xfe0, 8, 0),
MTK_PIN_DRV_GRP(194, 0xfe0, 12, 0),
MTK_PIN_DRV_GRP(195, 0xfe0, 12, 0),
MTK_PIN_DRV_GRP(196, 0xfe0, 12, 0),
MTK_PIN_DRV_GRP(197, 0xfe0, 12, 0),
MTK_PIN_DRV_GRP(198, 0xfe0, 12, 0),
MTK_PIN_DRV_GRP(199, 0xf50, 4, 1),
MTK_PIN_DRV_GRP(200, 0xfd0, 0, 0),
MTK_PIN_DRV_GRP(201, 0xfd0, 0, 0),
MTK_PIN_DRV_GRP(202, 0xfd0, 0, 0),
MTK_PIN_DRV_GRP(203, 0xfd0, 4, 0),
MTK_PIN_DRV_GRP(204, 0xfd0, 4, 0),
MTK_PIN_DRV_GRP(205, 0xfd0, 4, 0),
MTK_PIN_DRV_GRP(206, 0xfd0, 4, 0),
MTK_PIN_DRV_GRP(207, 0xfd0, 4, 0),
MTK_PIN_DRV_GRP(208, 0xfd0, 8, 0),
MTK_PIN_DRV_GRP(209, 0xfd0, 8, 0),
MTK_PIN_DRV_GRP(210, 0xfd0, 12, 1),
MTK_PIN_DRV_GRP(211, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(212, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(213, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(214, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(215, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(216, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(217, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(218, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(219, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(220, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(221, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(222, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(223, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(224, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(225, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(226, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(227, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(228, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(229, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(230, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(231, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(232, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(233, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(234, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(235, 0xff0, 0, 1),
MTK_PIN_DRV_GRP(236, 0xff0, 4, 0),
MTK_PIN_DRV_GRP(237, 0xff0, 4, 0),
MTK_PIN_DRV_GRP(238, 0xff0, 4, 0),
MTK_PIN_DRV_GRP(239, 0xff0, 4, 0),
MTK_PIN_DRV_GRP(240, 0xff0, 4, 0),
MTK_PIN_DRV_GRP(241, 0xff0, 4, 0),
MTK_PIN_DRV_GRP(242, 0xff0, 8, 0),
MTK_PIN_DRV_GRP(243, 0xff0, 8, 0),
MTK_PIN_DRV_GRP(248, 0xf00, 0, 0),
MTK_PIN_DRV_GRP(249, 0xfc0, 0, 2),
MTK_PIN_DRV_GRP(250, 0xfc0, 0, 2),
MTK_PIN_DRV_GRP(251, 0xfc0, 0, 2),
MTK_PIN_DRV_GRP(252, 0xfc0, 0, 2),
MTK_PIN_DRV_GRP(253, 0xfc0, 0, 2),
MTK_PIN_DRV_GRP(254, 0xfc0, 0, 2),
MTK_PIN_DRV_GRP(255, 0xfc0, 0, 2),
MTK_PIN_DRV_GRP(256, 0xfc0, 0, 2),
MTK_PIN_DRV_GRP(257, 0xce0, 0, 2),
MTK_PIN_DRV_GRP(258, 0xcb0, 0, 2),
MTK_PIN_DRV_GRP(259, 0xc90, 0, 2),
MTK_PIN_DRV_GRP(260, 0x3a0, 0, 2),
MTK_PIN_DRV_GRP(261, 0xd50, 0, 2),
MTK_PIN_DRV_GRP(262, 0xf00, 8, 0),
MTK_PIN_DRV_GRP(263, 0xf00, 8, 0),
MTK_PIN_DRV_GRP(264, 0xf00, 8, 0),
MTK_PIN_DRV_GRP(265, 0xf00, 8, 0),
MTK_PIN_DRV_GRP(266, 0xf00, 8, 0),
MTK_PIN_DRV_GRP(267, 0xf00, 8, 0),
MTK_PIN_DRV_GRP(268, 0xf00, 8, 0),
MTK_PIN_DRV_GRP(269, 0xf00, 8, 0),
MTK_PIN_DRV_GRP(270, 0xf00, 8, 0),
MTK_PIN_DRV_GRP(271, 0xf00, 8, 0),
MTK_PIN_DRV_GRP(272, 0xf00, 8, 0),
MTK_PIN_DRV_GRP(273, 0xf00, 8, 0),
MTK_PIN_DRV_GRP(274, 0xf00, 8, 0),
MTK_PIN_DRV_GRP(275, 0xf00, 8, 0),
MTK_PIN_DRV_GRP(276, 0xf00, 8, 0),
MTK_PIN_DRV_GRP(277, 0xf00, 8, 0),
MTK_PIN_DRV_GRP(278, 0xf70, 8, 1),
};
static const struct mtk_pin_spec_pupd_set_samereg mt2701_spec_pupd[] = {
MTK_PIN_PUPD_SPEC_SR(111, 0xd00, 12, 13, 14), /* ms0 data7 */
MTK_PIN_PUPD_SPEC_SR(112, 0xd00, 8, 9, 10), /* ms0 data6 */
MTK_PIN_PUPD_SPEC_SR(113, 0xd00, 4, 5, 6), /* ms0 data5 */
MTK_PIN_PUPD_SPEC_SR(114, 0xd00, 0, 1, 2), /* ms0 data4 */
MTK_PIN_PUPD_SPEC_SR(115, 0xd10, 0, 1, 2), /* ms0 rstb */
MTK_PIN_PUPD_SPEC_SR(116, 0xcd0, 8, 9, 10), /* ms0 cmd */
MTK_PIN_PUPD_SPEC_SR(117, 0xcc0, 8, 9, 10), /* ms0 clk */
MTK_PIN_PUPD_SPEC_SR(118, 0xcf0, 12, 13, 14), /* ms0 data3 */
MTK_PIN_PUPD_SPEC_SR(119, 0xcf0, 8, 9, 10), /* ms0 data2 */
MTK_PIN_PUPD_SPEC_SR(120, 0xcf0, 4, 5, 6), /* ms0 data1 */
MTK_PIN_PUPD_SPEC_SR(121, 0xcf0, 0, 1, 2), /* ms0 data0 */
MTK_PIN_PUPD_SPEC_SR(105, 0xd40, 8, 9, 10), /* ms1 cmd */
MTK_PIN_PUPD_SPEC_SR(106, 0xd30, 8, 9, 10), /* ms1 clk */
MTK_PIN_PUPD_SPEC_SR(107, 0xd60, 0, 1, 2), /* ms1 dat0 */
MTK_PIN_PUPD_SPEC_SR(108, 0xd60, 10, 9, 8), /* ms1 dat1 */
MTK_PIN_PUPD_SPEC_SR(109, 0xd60, 4, 5, 6), /* ms1 dat2 */
MTK_PIN_PUPD_SPEC_SR(110, 0xc60, 12, 13, 14), /* ms1 dat3 */
MTK_PIN_PUPD_SPEC_SR(85, 0xda0, 8, 9, 10), /* ms2 cmd */
MTK_PIN_PUPD_SPEC_SR(86, 0xd90, 8, 9, 10), /* ms2 clk */
MTK_PIN_PUPD_SPEC_SR(87, 0xdc0, 0, 1, 2), /* ms2 dat0 */
MTK_PIN_PUPD_SPEC_SR(88, 0xdc0, 10, 9, 8), /* ms2 dat1 */
MTK_PIN_PUPD_SPEC_SR(89, 0xdc0, 4, 5, 6), /* ms2 dat2 */
MTK_PIN_PUPD_SPEC_SR(90, 0xdc0, 12, 13, 14), /* ms2 dat3 */
MTK_PIN_PUPD_SPEC_SR(249, 0x140, 0, 1, 2), /* ms0e rstb */
MTK_PIN_PUPD_SPEC_SR(250, 0x130, 12, 13, 14), /* ms0e dat7 */
MTK_PIN_PUPD_SPEC_SR(251, 0x130, 8, 9, 10), /* ms0e dat6 */
MTK_PIN_PUPD_SPEC_SR(252, 0x130, 4, 5, 6), /* ms0e dat5 */
MTK_PIN_PUPD_SPEC_SR(253, 0x130, 0, 1, 2), /* ms0e dat4 */
MTK_PIN_PUPD_SPEC_SR(254, 0xf40, 12, 13, 14), /* ms0e dat3 */
MTK_PIN_PUPD_SPEC_SR(255, 0xf40, 8, 9, 10), /* ms0e dat2 */
MTK_PIN_PUPD_SPEC_SR(256, 0xf40, 4, 5, 6), /* ms0e dat1 */
MTK_PIN_PUPD_SPEC_SR(257, 0xf40, 0, 1, 2), /* ms0e dat0 */
MTK_PIN_PUPD_SPEC_SR(258, 0xcb0, 8, 9, 10), /* ms0e cmd */
MTK_PIN_PUPD_SPEC_SR(259, 0xc90, 8, 9, 10), /* ms0e clk */
MTK_PIN_PUPD_SPEC_SR(261, 0x140, 8, 9, 10), /* ms1 ins */
};
static int mt2701_spec_pull_set(struct regmap *regmap, unsigned int pin,
unsigned char align, bool isup, unsigned int r1r0)
{
return mtk_pctrl_spec_pull_set_samereg(regmap, mt2701_spec_pupd,
ARRAY_SIZE(mt2701_spec_pupd), pin, align, isup, r1r0);
}
static const struct mtk_pin_ies_smt_set mt2701_ies_set[] = {
MTK_PIN_IES_SMT_SPEC(0, 6, 0xb20, 0),
MTK_PIN_IES_SMT_SPEC(7, 9, 0xb20, 1),
MTK_PIN_IES_SMT_SPEC(10, 13, 0xb30, 3),
MTK_PIN_IES_SMT_SPEC(14, 15, 0xb30, 13),
MTK_PIN_IES_SMT_SPEC(16, 17, 0xb40, 7),
MTK_PIN_IES_SMT_SPEC(18, 21, 0xb40, 13),
MTK_PIN_IES_SMT_SPEC(22, 26, 0xb40, 13),
MTK_PIN_IES_SMT_SPEC(27, 29, 0xb40, 13),
MTK_PIN_IES_SMT_SPEC(30, 32, 0xb40, 7),
MTK_PIN_IES_SMT_SPEC(33, 37, 0xb40, 13),
MTK_PIN_IES_SMT_SPEC(38, 38, 0xb20, 13),
MTK_PIN_IES_SMT_SPEC(39, 42, 0xb40, 13),
MTK_PIN_IES_SMT_SPEC(43, 45, 0xb20, 10),
MTK_PIN_IES_SMT_SPEC(47, 48, 0xb20, 11),
MTK_PIN_IES_SMT_SPEC(49, 49, 0xb20, 12),
MTK_PIN_IES_SMT_SPEC(50, 52, 0xb20, 13),
MTK_PIN_IES_SMT_SPEC(53, 56, 0xb20, 14),
MTK_PIN_IES_SMT_SPEC(57, 58, 0xb20, 15),
MTK_PIN_IES_SMT_SPEC(59, 59, 0xb30, 10),
MTK_PIN_IES_SMT_SPEC(60, 62, 0xb30, 0),
MTK_PIN_IES_SMT_SPEC(63, 65, 0xb30, 1),
MTK_PIN_IES_SMT_SPEC(66, 71, 0xb30, 2),
MTK_PIN_IES_SMT_SPEC(72, 74, 0xb20, 12),
MTK_PIN_IES_SMT_SPEC(75, 76, 0xb30, 3),
MTK_PIN_IES_SMT_SPEC(77, 78, 0xb30, 4),
MTK_PIN_IES_SMT_SPEC(79, 82, 0xb30, 5),
MTK_PIN_IES_SMT_SPEC(83, 84, 0xb30, 2),
MTK_PIN_IES_SMT_SPEC(85, 85, 0xda0, 4),
MTK_PIN_IES_SMT_SPEC(86, 86, 0xd90, 4),
MTK_PIN_IES_SMT_SPEC(87, 90, 0xdb0, 4),
MTK_PIN_IES_SMT_SPEC(101, 104, 0xb30, 6),
MTK_PIN_IES_SMT_SPEC(105, 105, 0xd40, 4),
MTK_PIN_IES_SMT_SPEC(106, 106, 0xd30, 4),
MTK_PIN_IES_SMT_SPEC(107, 110, 0xd50, 4),
MTK_PIN_IES_SMT_SPEC(111, 115, 0xce0, 4),
MTK_PIN_IES_SMT_SPEC(116, 116, 0xcd0, 4),
MTK_PIN_IES_SMT_SPEC(117, 117, 0xcc0, 4),
MTK_PIN_IES_SMT_SPEC(118, 121, 0xce0, 4),
MTK_PIN_IES_SMT_SPEC(122, 125, 0xb30, 7),
MTK_PIN_IES_SMT_SPEC(126, 126, 0xb20, 12),
MTK_PIN_IES_SMT_SPEC(127, 142, 0xb30, 9),
MTK_PIN_IES_SMT_SPEC(143, 160, 0xb30, 10),
MTK_PIN_IES_SMT_SPEC(161, 168, 0xb30, 12),
MTK_PIN_IES_SMT_SPEC(169, 183, 0xb30, 10),
MTK_PIN_IES_SMT_SPEC(184, 186, 0xb30, 9),
MTK_PIN_IES_SMT_SPEC(187, 187, 0xb30, 14),
MTK_PIN_IES_SMT_SPEC(188, 188, 0xb20, 13),
MTK_PIN_IES_SMT_SPEC(189, 193, 0xb30, 15),
MTK_PIN_IES_SMT_SPEC(194, 198, 0xb40, 0),
MTK_PIN_IES_SMT_SPEC(199, 199, 0xb20, 1),
MTK_PIN_IES_SMT_SPEC(200, 202, 0xb40, 1),
MTK_PIN_IES_SMT_SPEC(203, 207, 0xb40, 2),
MTK_PIN_IES_SMT_SPEC(208, 209, 0xb40, 3),
MTK_PIN_IES_SMT_SPEC(210, 210, 0xb40, 4),
MTK_PIN_IES_SMT_SPEC(211, 235, 0xb40, 5),
MTK_PIN_IES_SMT_SPEC(236, 241, 0xb40, 6),
MTK_PIN_IES_SMT_SPEC(242, 243, 0xb40, 7),
MTK_PIN_IES_SMT_SPEC(244, 247, 0xb40, 8),
MTK_PIN_IES_SMT_SPEC(248, 248, 0xb40, 9),
MTK_PIN_IES_SMT_SPEC(249, 257, 0xfc0, 4),
MTK_PIN_IES_SMT_SPEC(258, 258, 0xcb0, 4),
MTK_PIN_IES_SMT_SPEC(259, 259, 0xc90, 4),
MTK_PIN_IES_SMT_SPEC(260, 260, 0x3a0, 4),
MTK_PIN_IES_SMT_SPEC(261, 261, 0xd50, 4),
MTK_PIN_IES_SMT_SPEC(262, 277, 0xb40, 12),
MTK_PIN_IES_SMT_SPEC(278, 278, 0xb40, 13),
};
static const struct mtk_pin_ies_smt_set mt2701_smt_set[] = {
MTK_PIN_IES_SMT_SPEC(0, 6, 0xb50, 0),
MTK_PIN_IES_SMT_SPEC(7, 9, 0xb50, 1),
MTK_PIN_IES_SMT_SPEC(10, 13, 0xb60, 3),
MTK_PIN_IES_SMT_SPEC(14, 15, 0xb60, 13),
MTK_PIN_IES_SMT_SPEC(16, 17, 0xb70, 7),
MTK_PIN_IES_SMT_SPEC(18, 21, 0xb70, 13),
MTK_PIN_IES_SMT_SPEC(22, 26, 0xb70, 13),
MTK_PIN_IES_SMT_SPEC(27, 29, 0xb70, 13),
MTK_PIN_IES_SMT_SPEC(30, 32, 0xb70, 7),
MTK_PIN_IES_SMT_SPEC(33, 37, 0xb70, 13),
MTK_PIN_IES_SMT_SPEC(38, 38, 0xb50, 13),
MTK_PIN_IES_SMT_SPEC(39, 42, 0xb70, 13),
MTK_PIN_IES_SMT_SPEC(43, 45, 0xb50, 10),
MTK_PIN_IES_SMT_SPEC(47, 48, 0xb50, 11),
MTK_PIN_IES_SMT_SPEC(49, 49, 0xb50, 12),
MTK_PIN_IES_SMT_SPEC(50, 52, 0xb50, 13),
MTK_PIN_IES_SMT_SPEC(53, 56, 0xb50, 14),
MTK_PIN_IES_SMT_SPEC(57, 58, 0xb50, 15),
MTK_PIN_IES_SMT_SPEC(59, 59, 0xb60, 10),
MTK_PIN_IES_SMT_SPEC(60, 62, 0xb60, 0),
MTK_PIN_IES_SMT_SPEC(63, 65, 0xb60, 1),
MTK_PIN_IES_SMT_SPEC(66, 71, 0xb60, 2),
MTK_PIN_IES_SMT_SPEC(72, 74, 0xb50, 12),
MTK_PIN_IES_SMT_SPEC(75, 76, 0xb60, 3),
MTK_PIN_IES_SMT_SPEC(77, 78, 0xb60, 4),
MTK_PIN_IES_SMT_SPEC(79, 82, 0xb60, 5),
MTK_PIN_IES_SMT_SPEC(83, 84, 0xb60, 2),
MTK_PIN_IES_SMT_SPEC(85, 85, 0xda0, 11),
MTK_PIN_IES_SMT_SPEC(86, 86, 0xd90, 11),
MTK_PIN_IES_SMT_SPEC(87, 87, 0xdc0, 3),
MTK_PIN_IES_SMT_SPEC(88, 88, 0xdc0, 7),
MTK_PIN_IES_SMT_SPEC(89, 89, 0xdc0, 11),
MTK_PIN_IES_SMT_SPEC(90, 90, 0xdc0, 15),
MTK_PIN_IES_SMT_SPEC(101, 104, 0xb60, 6),
MTK_PIN_IES_SMT_SPEC(105, 105, 0xd40, 11),
MTK_PIN_IES_SMT_SPEC(106, 106, 0xd30, 11),
MTK_PIN_IES_SMT_SPEC(107, 107, 0xd60, 3),
MTK_PIN_IES_SMT_SPEC(108, 108, 0xd60, 7),
MTK_PIN_IES_SMT_SPEC(109, 109, 0xd60, 11),
MTK_PIN_IES_SMT_SPEC(110, 110, 0xd60, 15),
MTK_PIN_IES_SMT_SPEC(111, 111, 0xd00, 15),
MTK_PIN_IES_SMT_SPEC(112, 112, 0xd00, 11),
MTK_PIN_IES_SMT_SPEC(113, 113, 0xd00, 7),
MTK_PIN_IES_SMT_SPEC(114, 114, 0xd00, 3),
MTK_PIN_IES_SMT_SPEC(115, 115, 0xd10, 3),
MTK_PIN_IES_SMT_SPEC(116, 116, 0xcd0, 11),
MTK_PIN_IES_SMT_SPEC(117, 117, 0xcc0, 11),
MTK_PIN_IES_SMT_SPEC(118, 118, 0xcf0, 15),
MTK_PIN_IES_SMT_SPEC(119, 119, 0xcf0, 11),
MTK_PIN_IES_SMT_SPEC(120, 120, 0xcf0, 7),
MTK_PIN_IES_SMT_SPEC(121, 121, 0xcf0, 3),
MTK_PIN_IES_SMT_SPEC(122, 125, 0xb60, 7),
MTK_PIN_IES_SMT_SPEC(126, 126, 0xb50, 12),
MTK_PIN_IES_SMT_SPEC(127, 142, 0xb60, 9),
MTK_PIN_IES_SMT_SPEC(143, 160, 0xb60, 10),
MTK_PIN_IES_SMT_SPEC(161, 168, 0xb60, 12),
MTK_PIN_IES_SMT_SPEC(169, 183, 0xb60, 10),
MTK_PIN_IES_SMT_SPEC(184, 186, 0xb60, 9),
MTK_PIN_IES_SMT_SPEC(187, 187, 0xb60, 14),
MTK_PIN_IES_SMT_SPEC(188, 188, 0xb50, 13),
MTK_PIN_IES_SMT_SPEC(189, 193, 0xb60, 15),
MTK_PIN_IES_SMT_SPEC(194, 198, 0xb70, 0),
MTK_PIN_IES_SMT_SPEC(199, 199, 0xb50, 1),
MTK_PIN_IES_SMT_SPEC(200, 202, 0xb70, 1),
MTK_PIN_IES_SMT_SPEC(203, 207, 0xb70, 2),
MTK_PIN_IES_SMT_SPEC(208, 209, 0xb70, 3),
MTK_PIN_IES_SMT_SPEC(210, 210, 0xb70, 4),
MTK_PIN_IES_SMT_SPEC(211, 235, 0xb70, 5),
MTK_PIN_IES_SMT_SPEC(236, 241, 0xb70, 6),
MTK_PIN_IES_SMT_SPEC(242, 243, 0xb70, 7),
MTK_PIN_IES_SMT_SPEC(244, 247, 0xb70, 8),
MTK_PIN_IES_SMT_SPEC(248, 248, 0xb70, 9),
MTK_PIN_IES_SMT_SPEC(249, 249, 0x140, 3),
MTK_PIN_IES_SMT_SPEC(250, 250, 0x130, 15),
MTK_PIN_IES_SMT_SPEC(251, 251, 0x130, 11),
MTK_PIN_IES_SMT_SPEC(252, 252, 0x130, 7),
MTK_PIN_IES_SMT_SPEC(253, 253, 0x130, 3),
MTK_PIN_IES_SMT_SPEC(254, 254, 0xf40, 15),
MTK_PIN_IES_SMT_SPEC(255, 255, 0xf40, 11),
MTK_PIN_IES_SMT_SPEC(256, 256, 0xf40, 7),
MTK_PIN_IES_SMT_SPEC(257, 257, 0xf40, 3),
MTK_PIN_IES_SMT_SPEC(258, 258, 0xcb0, 11),
MTK_PIN_IES_SMT_SPEC(259, 259, 0xc90, 11),
MTK_PIN_IES_SMT_SPEC(260, 260, 0x3a0, 11),
MTK_PIN_IES_SMT_SPEC(261, 261, 0x0b0, 3),
MTK_PIN_IES_SMT_SPEC(262, 277, 0xb70, 12),
MTK_PIN_IES_SMT_SPEC(278, 278, 0xb70, 13),
};
static int mt2701_ies_smt_set(struct regmap *regmap, unsigned int pin,
unsigned char align, int value, enum pin_config_param arg)
{
if (arg == PIN_CONFIG_INPUT_ENABLE)
return mtk_pconf_spec_set_ies_smt_range(regmap, mt2701_ies_set,
ARRAY_SIZE(mt2701_ies_set), pin, align, value);
else if (arg == PIN_CONFIG_INPUT_SCHMITT_ENABLE)
return mtk_pconf_spec_set_ies_smt_range(regmap, mt2701_smt_set,
ARRAY_SIZE(mt2701_smt_set), pin, align, value);
return -EINVAL;
}
static const struct mtk_spec_pinmux_set mt2701_spec_pinmux[] = {
MTK_PINMUX_SPEC(22, 0xb10, 3),
MTK_PINMUX_SPEC(23, 0xb10, 4),
MTK_PINMUX_SPEC(24, 0xb10, 5),
MTK_PINMUX_SPEC(29, 0xb10, 9),
MTK_PINMUX_SPEC(208, 0xb10, 7),
MTK_PINMUX_SPEC(209, 0xb10, 8),
MTK_PINMUX_SPEC(203, 0xf20, 0),
MTK_PINMUX_SPEC(204, 0xf20, 1),
MTK_PINMUX_SPEC(249, 0xef0, 0),
MTK_PINMUX_SPEC(250, 0xef0, 0),
MTK_PINMUX_SPEC(251, 0xef0, 0),
MTK_PINMUX_SPEC(252, 0xef0, 0),
MTK_PINMUX_SPEC(253, 0xef0, 0),
MTK_PINMUX_SPEC(254, 0xef0, 0),
MTK_PINMUX_SPEC(255, 0xef0, 0),
MTK_PINMUX_SPEC(256, 0xef0, 0),
MTK_PINMUX_SPEC(257, 0xef0, 0),
MTK_PINMUX_SPEC(258, 0xef0, 0),
MTK_PINMUX_SPEC(259, 0xef0, 0),
MTK_PINMUX_SPEC(260, 0xef0, 0),
};
static void mt2701_spec_pinmux_set(struct regmap *reg, unsigned int pin,
unsigned int mode)
{
unsigned int i, value, mask;
unsigned int info_num = ARRAY_SIZE(mt2701_spec_pinmux);
unsigned int spec_flag;
for (i = 0; i < info_num; i++) {
if (pin == mt2701_spec_pinmux[i].pin)
break;
}
if (i == info_num)
return;
spec_flag = (mode >> 3);
mask = BIT(mt2701_spec_pinmux[i].bit);
if (!spec_flag)
value = mask;
else
value = 0;
regmap_update_bits(reg, mt2701_spec_pinmux[i].offset, mask, value);
}
static void mt2701_spec_dir_set(unsigned int *reg_addr, unsigned int pin)
{
if (pin > 175)
*reg_addr += 0x10;
}
static const struct mtk_pinctrl_devdata mt2701_pinctrl_data = {
.pins = mtk_pins_mt2701,
.npins = ARRAY_SIZE(mtk_pins_mt2701),
.grp_desc = mt2701_drv_grp,
.n_grp_cls = ARRAY_SIZE(mt2701_drv_grp),
.pin_drv_grp = mt2701_pin_drv,
.n_pin_drv_grps = ARRAY_SIZE(mt2701_pin_drv),
.spec_pull_set = mt2701_spec_pull_set,
.spec_ies_smt_set = mt2701_ies_smt_set,
.spec_pinmux_set = mt2701_spec_pinmux_set,
.spec_dir_set = mt2701_spec_dir_set,
.dir_offset = 0x0000,
.pullen_offset = 0x0150,
.pullsel_offset = 0x0280,
.dout_offset = 0x0500,
.din_offset = 0x0630,
.pinmux_offset = 0x0760,
.type1_start = 280,
.type1_end = 280,
.port_shf = 4,
.port_mask = 0x1f,
.port_align = 4,
.eint_hw = {
.port_mask = 6,
.ports = 6,
.ap_num = 169,
.db_cnt = 16,
},
};
static int mt2701_pinctrl_probe(struct platform_device *pdev)
{
return mtk_pctrl_init(pdev, &mt2701_pinctrl_data, NULL);
}
static const struct of_device_id mt2701_pctrl_match[] = {
{ .compatible = "mediatek,mt2701-pinctrl", },
{ .compatible = "mediatek,mt7623-pinctrl", },
{}
};
MODULE_DEVICE_TABLE(of, mt2701_pctrl_match);
static struct platform_driver mtk_pinctrl_driver = {
.probe = mt2701_pinctrl_probe,
.driver = {
.name = "mediatek-mt2701-pinctrl",
.of_match_table = mt2701_pctrl_match,
.pm = &mtk_eint_pm_ops,
},
};
static int __init mtk_pinctrl_init(void)
{
return platform_driver_register(&mtk_pinctrl_driver);
}
arch_initcall(mtk_pinctrl_init);
+614
View File
@@ -0,0 +1,614 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2018 MediaTek Inc.
* Author: Zhiyong Tao <zhiyong.tao@mediatek.com>
*
*/
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/regmap.h>
#include <linux/pinctrl/pinconf-generic.h>
#include <dt-bindings/pinctrl/mt65xx.h>
#include "pinctrl-mtk-common.h"
#include "pinctrl-mtk-mt2712.h"
static const struct mtk_pin_spec_pupd_set_samereg mt2712_spec_pupd[] = {
MTK_PIN_PUPD_SPEC_SR(18, 0xe50, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(19, 0xe60, 12, 11, 10),
MTK_PIN_PUPD_SPEC_SR(20, 0xe50, 5, 4, 3),
MTK_PIN_PUPD_SPEC_SR(21, 0xe60, 15, 14, 13),
MTK_PIN_PUPD_SPEC_SR(22, 0xe50, 8, 7, 6),
MTK_PIN_PUPD_SPEC_SR(23, 0xe70, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(30, 0xf30, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(31, 0xf30, 6, 5, 4),
MTK_PIN_PUPD_SPEC_SR(32, 0xf30, 10, 9, 8),
MTK_PIN_PUPD_SPEC_SR(33, 0xf30, 14, 13, 12),
MTK_PIN_PUPD_SPEC_SR(34, 0xf40, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(35, 0xf40, 6, 5, 4),
MTK_PIN_PUPD_SPEC_SR(36, 0xf40, 10, 9, 8),
MTK_PIN_PUPD_SPEC_SR(37, 0xc40, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(38, 0xc60, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(39, 0xc60, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(40, 0xc60, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(41, 0xc60, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(42, 0xc60, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(43, 0xc60, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(44, 0xc60, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(45, 0xc60, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(46, 0xc50, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(47, 0xda0, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(48, 0xd90, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(49, 0xdf0, 14, 13, 12),
MTK_PIN_PUPD_SPEC_SR(50, 0xdf0, 10, 9, 8),
MTK_PIN_PUPD_SPEC_SR(51, 0xdf0, 6, 5, 4),
MTK_PIN_PUPD_SPEC_SR(52, 0xdf0, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(53, 0xd50, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(54, 0xd80, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(55, 0xe00, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(56, 0xd40, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(63, 0xc80, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(64, 0xdb0, 14, 13, 12),
MTK_PIN_PUPD_SPEC_SR(65, 0xdb0, 6, 5, 4),
MTK_PIN_PUPD_SPEC_SR(66, 0xdb0, 10, 9, 8),
MTK_PIN_PUPD_SPEC_SR(67, 0xcd0, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(68, 0xdb0, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(69, 0xc90, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(70, 0xcc0, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(89, 0xce0, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(90, 0xdd0, 14, 13, 12),
MTK_PIN_PUPD_SPEC_SR(91, 0xdd0, 10, 9, 8),
MTK_PIN_PUPD_SPEC_SR(92, 0xdd0, 6, 5, 4),
MTK_PIN_PUPD_SPEC_SR(93, 0xdd0, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(94, 0xd20, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(95, 0xcf0, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(96, 0xd30, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(135, 0xe50, 11, 10, 9),
MTK_PIN_PUPD_SPEC_SR(136, 0xe50, 14, 13, 12),
MTK_PIN_PUPD_SPEC_SR(137, 0xe70, 5, 4, 3),
MTK_PIN_PUPD_SPEC_SR(138, 0xe70, 8, 7, 6),
MTK_PIN_PUPD_SPEC_SR(139, 0xe70, 11, 10, 9),
MTK_PIN_PUPD_SPEC_SR(140, 0xe70, 14, 13, 12),
MTK_PIN_PUPD_SPEC_SR(141, 0xe60, 2, 1, 0),
MTK_PIN_PUPD_SPEC_SR(142, 0xe60, 5, 4, 3)
};
static int mt2712_spec_pull_set(struct regmap *regmap,
unsigned int pin,
unsigned char align,
bool isup,
unsigned int r1r0)
{
return mtk_pctrl_spec_pull_set_samereg(regmap, mt2712_spec_pupd,
ARRAY_SIZE(mt2712_spec_pupd), pin, align, isup, r1r0);
}
static const struct mtk_pin_ies_smt_set mt2712_smt_set[] = {
MTK_PIN_IES_SMT_SPEC(0, 3, 0x900, 2),
MTK_PIN_IES_SMT_SPEC(4, 7, 0x900, 0),
MTK_PIN_IES_SMT_SPEC(8, 11, 0x900, 1),
MTK_PIN_IES_SMT_SPEC(12, 12, 0x8d0, 6),
MTK_PIN_IES_SMT_SPEC(13, 13, 0x8d0, 7),
MTK_PIN_IES_SMT_SPEC(14, 14, 0x8d0, 6),
MTK_PIN_IES_SMT_SPEC(15, 15, 0x8d0, 7),
MTK_PIN_IES_SMT_SPEC(18, 23, 0x8d0, 1),
MTK_PIN_IES_SMT_SPEC(24, 25, 0x8d0, 2),
MTK_PIN_IES_SMT_SPEC(26, 26, 0x8d0, 3),
MTK_PIN_IES_SMT_SPEC(27, 27, 0x8d0, 4),
MTK_PIN_IES_SMT_SPEC(28, 29, 0x8d0, 3),
MTK_PIN_IES_SMT_SPEC(30, 36, 0xf50, 13),
MTK_PIN_IES_SMT_SPEC(37, 37, 0xc40, 13),
MTK_PIN_IES_SMT_SPEC(38, 45, 0xc60, 13),
MTK_PIN_IES_SMT_SPEC(46, 46, 0xc50, 13),
MTK_PIN_IES_SMT_SPEC(47, 47, 0xda0, 13),
MTK_PIN_IES_SMT_SPEC(48, 48, 0xd90, 13),
MTK_PIN_IES_SMT_SPEC(49, 52, 0xd60, 13),
MTK_PIN_IES_SMT_SPEC(53, 53, 0xd50, 13),
MTK_PIN_IES_SMT_SPEC(54, 54, 0xd80, 13),
MTK_PIN_IES_SMT_SPEC(55, 55, 0xe00, 13),
MTK_PIN_IES_SMT_SPEC(56, 56, 0xd40, 13),
MTK_PIN_IES_SMT_SPEC(57, 62, 0x900, 3),
MTK_PIN_IES_SMT_SPEC(63, 63, 0xc80, 13),
MTK_PIN_IES_SMT_SPEC(64, 66, 0xca0, 13),
MTK_PIN_IES_SMT_SPEC(67, 67, 0xc80, 13),
MTK_PIN_IES_SMT_SPEC(68, 68, 0xca0, 13),
MTK_PIN_IES_SMT_SPEC(69, 69, 0xc90, 13),
MTK_PIN_IES_SMT_SPEC(70, 70, 0xc80, 13),
MTK_PIN_IES_SMT_SPEC(71, 74, 0x8d0, 8),
MTK_PIN_IES_SMT_SPEC(75, 77, 0x8d0, 9),
MTK_PIN_IES_SMT_SPEC(78, 81, 0x8d0, 10),
MTK_PIN_IES_SMT_SPEC(82, 88, 0x8d0, 9),
MTK_PIN_IES_SMT_SPEC(89, 89, 0xce0, 13),
MTK_PIN_IES_SMT_SPEC(90, 93, 0xd00, 13),
MTK_PIN_IES_SMT_SPEC(94, 94, 0xce0, 13),
MTK_PIN_IES_SMT_SPEC(95, 96, 0xcf0, 13),
MTK_PIN_IES_SMT_SPEC(97, 100, 0x8d0, 11),
MTK_PIN_IES_SMT_SPEC(101, 104, 0x8d0, 12),
MTK_PIN_IES_SMT_SPEC(105, 105, 0x8d0, 13),
MTK_PIN_IES_SMT_SPEC(106, 106, 0x8d0, 14),
MTK_PIN_IES_SMT_SPEC(107, 107, 0x8d0, 15),
MTK_PIN_IES_SMT_SPEC(108, 108, 0x8e0, 0),
MTK_PIN_IES_SMT_SPEC(109, 109, 0x8e0, 1),
MTK_PIN_IES_SMT_SPEC(110, 110, 0x8e0, 2),
MTK_PIN_IES_SMT_SPEC(111, 111, 0x8d0, 13),
MTK_PIN_IES_SMT_SPEC(112, 112, 0x8d0, 14),
MTK_PIN_IES_SMT_SPEC(113, 113, 0x8d0, 15),
MTK_PIN_IES_SMT_SPEC(114, 114, 0x8e0, 0),
MTK_PIN_IES_SMT_SPEC(115, 115, 0x8e0, 1),
MTK_PIN_IES_SMT_SPEC(116, 116, 0x8e0, 2),
MTK_PIN_IES_SMT_SPEC(117, 117, 0x8e0, 3),
MTK_PIN_IES_SMT_SPEC(118, 118, 0x8e0, 4),
MTK_PIN_IES_SMT_SPEC(119, 119, 0x8e0, 5),
MTK_PIN_IES_SMT_SPEC(120, 120, 0x8e0, 3),
MTK_PIN_IES_SMT_SPEC(121, 121, 0x8e0, 4),
MTK_PIN_IES_SMT_SPEC(122, 122, 0x8e0, 5),
MTK_PIN_IES_SMT_SPEC(123, 126, 0x8e0, 6),
MTK_PIN_IES_SMT_SPEC(127, 130, 0x8e0, 7),
MTK_PIN_IES_SMT_SPEC(131, 134, 0x8e0, 8),
MTK_PIN_IES_SMT_SPEC(135, 142, 0x8d0, 1),
MTK_PIN_IES_SMT_SPEC(143, 147, 0x8e0, 9),
MTK_PIN_IES_SMT_SPEC(148, 152, 0x8e0, 10),
MTK_PIN_IES_SMT_SPEC(153, 156, 0x8e0, 11),
MTK_PIN_IES_SMT_SPEC(157, 160, 0x8e0, 12),
MTK_PIN_IES_SMT_SPEC(161, 164, 0x8e0, 13),
MTK_PIN_IES_SMT_SPEC(165, 168, 0x8e0, 14),
MTK_PIN_IES_SMT_SPEC(169, 170, 0x8e0, 15),
MTK_PIN_IES_SMT_SPEC(171, 172, 0x8f0, 0),
MTK_PIN_IES_SMT_SPEC(173, 173, 0x8f0, 1),
MTK_PIN_IES_SMT_SPEC(174, 175, 0x8f0, 2),
MTK_PIN_IES_SMT_SPEC(176, 176, 0x8f0, 1),
MTK_PIN_IES_SMT_SPEC(177, 177, 0x8f0, 3),
MTK_PIN_IES_SMT_SPEC(178, 178, 0x8f0, 4),
MTK_PIN_IES_SMT_SPEC(179, 179, 0x8f0, 3),
MTK_PIN_IES_SMT_SPEC(180, 180, 0x8f0, 4),
MTK_PIN_IES_SMT_SPEC(181, 181, 0x8f0, 5),
MTK_PIN_IES_SMT_SPEC(182, 182, 0x8f0, 6),
MTK_PIN_IES_SMT_SPEC(183, 183, 0x8f0, 5),
MTK_PIN_IES_SMT_SPEC(184, 184, 0x8f0, 6),
MTK_PIN_IES_SMT_SPEC(185, 186, 0x8f0, 7),
MTK_PIN_IES_SMT_SPEC(187, 187, 0x8f0, 8),
MTK_PIN_IES_SMT_SPEC(188, 188, 0x8f0, 9),
MTK_PIN_IES_SMT_SPEC(189, 189, 0x8f0, 8),
MTK_PIN_IES_SMT_SPEC(190, 190, 0x8f0, 9),
MTK_PIN_IES_SMT_SPEC(191, 191, 0x8f0, 10),
MTK_PIN_IES_SMT_SPEC(192, 192, 0x8f0, 11),
MTK_PIN_IES_SMT_SPEC(193, 194, 0x8f0, 10),
MTK_PIN_IES_SMT_SPEC(195, 195, 0x8f0, 11),
MTK_PIN_IES_SMT_SPEC(196, 199, 0x8f0, 12),
MTK_PIN_IES_SMT_SPEC(200, 203, 0x8f0, 13),
MTK_PIN_IES_SMT_SPEC(204, 206, 0x8f0, 14),
MTK_PIN_IES_SMT_SPEC(207, 209, 0x8f0, 15)
};
static const struct mtk_pin_ies_smt_set mt2712_ies_set[] = {
MTK_PIN_IES_SMT_SPEC(0, 3, 0x8c0, 2),
MTK_PIN_IES_SMT_SPEC(4, 7, 0x8c0, 0),
MTK_PIN_IES_SMT_SPEC(8, 9, 0x8c0, 1),
MTK_PIN_IES_SMT_SPEC(10, 11, 0x8c0, 4),
MTK_PIN_IES_SMT_SPEC(12, 12, 0x890, 6),
MTK_PIN_IES_SMT_SPEC(13, 13, 0x890, 7),
MTK_PIN_IES_SMT_SPEC(14, 14, 0x890, 6),
MTK_PIN_IES_SMT_SPEC(15, 15, 0x890, 7),
MTK_PIN_IES_SMT_SPEC(18, 23, 0x890, 1),
MTK_PIN_IES_SMT_SPEC(24, 25, 0x890, 2),
MTK_PIN_IES_SMT_SPEC(26, 26, 0x890, 3),
MTK_PIN_IES_SMT_SPEC(27, 27, 0x890, 4),
MTK_PIN_IES_SMT_SPEC(28, 29, 0x890, 3),
MTK_PIN_IES_SMT_SPEC(30, 36, 0xf50, 14),
MTK_PIN_IES_SMT_SPEC(37, 37, 0xc40, 14),
MTK_PIN_IES_SMT_SPEC(38, 45, 0xc60, 14),
MTK_PIN_IES_SMT_SPEC(46, 46, 0xc50, 14),
MTK_PIN_IES_SMT_SPEC(47, 47, 0xda0, 14),
MTK_PIN_IES_SMT_SPEC(48, 48, 0xd90, 14),
MTK_PIN_IES_SMT_SPEC(49, 52, 0xd60, 14),
MTK_PIN_IES_SMT_SPEC(53, 53, 0xd50, 14),
MTK_PIN_IES_SMT_SPEC(54, 54, 0xd80, 14),
MTK_PIN_IES_SMT_SPEC(55, 55, 0xe00, 14),
MTK_PIN_IES_SMT_SPEC(56, 56, 0xd40, 14),
MTK_PIN_IES_SMT_SPEC(57, 62, 0x8c0, 3),
MTK_PIN_IES_SMT_SPEC(63, 63, 0xc80, 14),
MTK_PIN_IES_SMT_SPEC(64, 66, 0xca0, 14),
MTK_PIN_IES_SMT_SPEC(67, 68, 0xc80, 14),
MTK_PIN_IES_SMT_SPEC(69, 69, 0xc90, 14),
MTK_PIN_IES_SMT_SPEC(70, 70, 0xc80, 14),
MTK_PIN_IES_SMT_SPEC(71, 74, 0x890, 8),
MTK_PIN_IES_SMT_SPEC(75, 77, 0x890, 9),
MTK_PIN_IES_SMT_SPEC(78, 81, 0x890, 10),
MTK_PIN_IES_SMT_SPEC(82, 88, 0x890, 9),
MTK_PIN_IES_SMT_SPEC(89, 89, 0xce0, 14),
MTK_PIN_IES_SMT_SPEC(90, 93, 0xd00, 14),
MTK_PIN_IES_SMT_SPEC(94, 94, 0xce0, 14),
MTK_PIN_IES_SMT_SPEC(95, 96, 0xcf0, 14),
MTK_PIN_IES_SMT_SPEC(97, 100, 0x890, 11),
MTK_PIN_IES_SMT_SPEC(101, 104, 0x890, 12),
MTK_PIN_IES_SMT_SPEC(105, 105, 0x890, 13),
MTK_PIN_IES_SMT_SPEC(106, 106, 0x890, 14),
MTK_PIN_IES_SMT_SPEC(107, 107, 0x890, 15),
MTK_PIN_IES_SMT_SPEC(108, 108, 0x8a0, 0),
MTK_PIN_IES_SMT_SPEC(109, 109, 0x8a0, 1),
MTK_PIN_IES_SMT_SPEC(110, 110, 0x8a0, 2),
MTK_PIN_IES_SMT_SPEC(111, 111, 0x890, 13),
MTK_PIN_IES_SMT_SPEC(112, 112, 0x890, 14),
MTK_PIN_IES_SMT_SPEC(113, 113, 0x890, 15),
MTK_PIN_IES_SMT_SPEC(114, 114, 0x8a0, 0),
MTK_PIN_IES_SMT_SPEC(115, 115, 0x8a0, 1),
MTK_PIN_IES_SMT_SPEC(116, 116, 0x8a0, 2),
MTK_PIN_IES_SMT_SPEC(117, 117, 0x8a0, 3),
MTK_PIN_IES_SMT_SPEC(118, 118, 0x8a0, 4),
MTK_PIN_IES_SMT_SPEC(119, 119, 0x8a0, 5),
MTK_PIN_IES_SMT_SPEC(120, 120, 0x8a0, 3),
MTK_PIN_IES_SMT_SPEC(121, 121, 0x8a0, 4),
MTK_PIN_IES_SMT_SPEC(122, 122, 0x8a0, 5),
MTK_PIN_IES_SMT_SPEC(123, 126, 0x8a0, 6),
MTK_PIN_IES_SMT_SPEC(127, 130, 0x8a0, 7),
MTK_PIN_IES_SMT_SPEC(131, 135, 0x8a0, 8),
MTK_PIN_IES_SMT_SPEC(136, 142, 0x890, 1),
MTK_PIN_IES_SMT_SPEC(143, 147, 0x8a0, 9),
MTK_PIN_IES_SMT_SPEC(148, 152, 0x8a0, 10),
MTK_PIN_IES_SMT_SPEC(153, 156, 0x8a0, 11),
MTK_PIN_IES_SMT_SPEC(157, 160, 0x8a0, 12),
MTK_PIN_IES_SMT_SPEC(161, 164, 0x8a0, 13),
MTK_PIN_IES_SMT_SPEC(165, 168, 0x8a0, 14),
MTK_PIN_IES_SMT_SPEC(169, 170, 0x8a0, 15),
MTK_PIN_IES_SMT_SPEC(171, 172, 0x8b0, 0),
MTK_PIN_IES_SMT_SPEC(173, 173, 0x8b0, 1),
MTK_PIN_IES_SMT_SPEC(174, 175, 0x8b0, 2),
MTK_PIN_IES_SMT_SPEC(176, 176, 0x8b0, 1),
MTK_PIN_IES_SMT_SPEC(177, 177, 0x8b0, 3),
MTK_PIN_IES_SMT_SPEC(178, 178, 0x8b0, 4),
MTK_PIN_IES_SMT_SPEC(179, 179, 0x8b0, 3),
MTK_PIN_IES_SMT_SPEC(180, 180, 0x8b0, 4),
MTK_PIN_IES_SMT_SPEC(181, 181, 0x8b0, 5),
MTK_PIN_IES_SMT_SPEC(182, 182, 0x8b0, 6),
MTK_PIN_IES_SMT_SPEC(183, 183, 0x8b0, 5),
MTK_PIN_IES_SMT_SPEC(184, 184, 0x8b0, 6),
MTK_PIN_IES_SMT_SPEC(185, 186, 0x8b0, 7),
MTK_PIN_IES_SMT_SPEC(187, 187, 0x8b0, 8),
MTK_PIN_IES_SMT_SPEC(188, 188, 0x8b0, 9),
MTK_PIN_IES_SMT_SPEC(189, 189, 0x8b0, 8),
MTK_PIN_IES_SMT_SPEC(190, 190, 0x8b0, 9),
MTK_PIN_IES_SMT_SPEC(191, 191, 0x8b0, 10),
MTK_PIN_IES_SMT_SPEC(192, 192, 0x8b0, 11),
MTK_PIN_IES_SMT_SPEC(193, 194, 0x8b0, 10),
MTK_PIN_IES_SMT_SPEC(195, 195, 0x8b0, 11),
MTK_PIN_IES_SMT_SPEC(196, 199, 0x8b0, 12),
MTK_PIN_IES_SMT_SPEC(200, 203, 0x8b0, 13),
MTK_PIN_IES_SMT_SPEC(204, 206, 0x8b0, 14),
MTK_PIN_IES_SMT_SPEC(207, 209, 0x8b0, 15)
};
static int mt2712_ies_smt_set(struct regmap *regmap, unsigned int pin,
unsigned char align,
int value, enum pin_config_param arg)
{
if (arg == PIN_CONFIG_INPUT_ENABLE)
return mtk_pconf_spec_set_ies_smt_range(regmap, mt2712_ies_set,
ARRAY_SIZE(mt2712_ies_set), pin, align, value);
if (arg == PIN_CONFIG_INPUT_SCHMITT_ENABLE)
return mtk_pconf_spec_set_ies_smt_range(regmap, mt2712_smt_set,
ARRAY_SIZE(mt2712_smt_set), pin, align, value);
return -EINVAL;
}
static const struct mtk_drv_group_desc mt2712_drv_grp[] = {
/* 0E4E8SR 4/8/12/16 */
MTK_DRV_GRP(4, 16, 1, 2, 4),
/* 0E2E4SR 2/4/6/8 */
MTK_DRV_GRP(2, 8, 1, 2, 2),
/* E8E4E2 2/4/6/8/10/12/14/16 */
MTK_DRV_GRP(2, 16, 0, 2, 2)
};
static const struct mtk_pin_drv_grp mt2712_pin_drv[] = {
MTK_PIN_DRV_GRP(0, 0xc10, 4, 0),
MTK_PIN_DRV_GRP(1, 0xc10, 4, 0),
MTK_PIN_DRV_GRP(2, 0xc10, 4, 0),
MTK_PIN_DRV_GRP(3, 0xc10, 4, 0),
MTK_PIN_DRV_GRP(4, 0xc00, 12, 0),
MTK_PIN_DRV_GRP(5, 0xc00, 12, 0),
MTK_PIN_DRV_GRP(6, 0xc00, 12, 0),
MTK_PIN_DRV_GRP(7, 0xc00, 12, 0),
MTK_PIN_DRV_GRP(8, 0xc10, 0, 0),
MTK_PIN_DRV_GRP(9, 0xc10, 0, 0),
MTK_PIN_DRV_GRP(10, 0xc10, 0, 0),
MTK_PIN_DRV_GRP(11, 0xc10, 0, 0),
MTK_PIN_DRV_GRP(12, 0xb60, 0, 0),
MTK_PIN_DRV_GRP(13, 0xb60, 4, 0),
MTK_PIN_DRV_GRP(14, 0xb60, 0, 0),
MTK_PIN_DRV_GRP(15, 0xb60, 4, 0),
MTK_PIN_DRV_GRP(18, 0xb40, 0, 1),
MTK_PIN_DRV_GRP(19, 0xb40, 0, 1),
MTK_PIN_DRV_GRP(20, 0xb40, 0, 1),
MTK_PIN_DRV_GRP(21, 0xb40, 0, 1),
MTK_PIN_DRV_GRP(22, 0xb40, 0, 1),
MTK_PIN_DRV_GRP(23, 0xb40, 0, 1),
MTK_PIN_DRV_GRP(24, 0xb40, 4, 0),
MTK_PIN_DRV_GRP(25, 0xb40, 8, 0),
MTK_PIN_DRV_GRP(26, 0xb40, 12, 0),
MTK_PIN_DRV_GRP(27, 0xb50, 0, 0),
MTK_PIN_DRV_GRP(28, 0xb40, 12, 0),
MTK_PIN_DRV_GRP(29, 0xb40, 12, 0),
MTK_PIN_DRV_GRP(30, 0xf50, 8, 2),
MTK_PIN_DRV_GRP(31, 0xf50, 8, 2),
MTK_PIN_DRV_GRP(32, 0xf50, 8, 2),
MTK_PIN_DRV_GRP(33, 0xf50, 8, 2),
MTK_PIN_DRV_GRP(34, 0xf50, 8, 2),
MTK_PIN_DRV_GRP(35, 0xf50, 8, 2),
MTK_PIN_DRV_GRP(36, 0xf50, 8, 2),
MTK_PIN_DRV_GRP(37, 0xc40, 8, 2),
MTK_PIN_DRV_GRP(38, 0xc60, 8, 2),
MTK_PIN_DRV_GRP(39, 0xc60, 8, 2),
MTK_PIN_DRV_GRP(40, 0xc60, 8, 2),
MTK_PIN_DRV_GRP(41, 0xc60, 8, 2),
MTK_PIN_DRV_GRP(42, 0xc60, 8, 2),
MTK_PIN_DRV_GRP(43, 0xc60, 8, 2),
MTK_PIN_DRV_GRP(44, 0xc60, 8, 2),
MTK_PIN_DRV_GRP(45, 0xc60, 8, 2),
MTK_PIN_DRV_GRP(46, 0xc50, 8, 2),
MTK_PIN_DRV_GRP(47, 0xda0, 8, 2),
MTK_PIN_DRV_GRP(48, 0xd90, 8, 2),
MTK_PIN_DRV_GRP(49, 0xd60, 8, 2),
MTK_PIN_DRV_GRP(50, 0xd60, 8, 2),
MTK_PIN_DRV_GRP(51, 0xd60, 8, 2),
MTK_PIN_DRV_GRP(52, 0xd60, 8, 2),
MTK_PIN_DRV_GRP(53, 0xd50, 8, 2),
MTK_PIN_DRV_GRP(54, 0xd80, 8, 2),
MTK_PIN_DRV_GRP(55, 0xe00, 8, 2),
MTK_PIN_DRV_GRP(56, 0xd40, 8, 2),
MTK_PIN_DRV_GRP(63, 0xc80, 8, 2),
MTK_PIN_DRV_GRP(64, 0xca0, 8, 2),
MTK_PIN_DRV_GRP(65, 0xca0, 8, 2),
MTK_PIN_DRV_GRP(66, 0xca0, 8, 2),
MTK_PIN_DRV_GRP(67, 0xcd0, 8, 2),
MTK_PIN_DRV_GRP(68, 0xca0, 8, 2),
MTK_PIN_DRV_GRP(69, 0xc90, 8, 2),
MTK_PIN_DRV_GRP(70, 0xcc0, 8, 2),
MTK_PIN_DRV_GRP(71, 0xb60, 8, 1),
MTK_PIN_DRV_GRP(72, 0xb60, 8, 1),
MTK_PIN_DRV_GRP(73, 0xb60, 8, 1),
MTK_PIN_DRV_GRP(74, 0xb60, 8, 1),
MTK_PIN_DRV_GRP(75, 0xb60, 12, 1),
MTK_PIN_DRV_GRP(76, 0xb60, 12, 1),
MTK_PIN_DRV_GRP(77, 0xb60, 12, 1),
MTK_PIN_DRV_GRP(78, 0xb70, 0, 1),
MTK_PIN_DRV_GRP(79, 0xb70, 0, 1),
MTK_PIN_DRV_GRP(80, 0xb70, 0, 1),
MTK_PIN_DRV_GRP(81, 0xb70, 0, 1),
MTK_PIN_DRV_GRP(82, 0xb60, 12, 1),
MTK_PIN_DRV_GRP(83, 0xb60, 12, 1),
MTK_PIN_DRV_GRP(84, 0xb60, 12, 1),
MTK_PIN_DRV_GRP(85, 0xb60, 12, 1),
MTK_PIN_DRV_GRP(86, 0xb60, 12, 1),
MTK_PIN_DRV_GRP(87, 0xb60, 12, 1),
MTK_PIN_DRV_GRP(88, 0xb60, 12, 1),
MTK_PIN_DRV_GRP(89, 0xce0, 8, 2),
MTK_PIN_DRV_GRP(90, 0xd00, 8, 2),
MTK_PIN_DRV_GRP(91, 0xd00, 8, 2),
MTK_PIN_DRV_GRP(92, 0xd00, 8, 2),
MTK_PIN_DRV_GRP(93, 0xd00, 8, 2),
MTK_PIN_DRV_GRP(94, 0xd20, 8, 2),
MTK_PIN_DRV_GRP(95, 0xcf0, 8, 2),
MTK_PIN_DRV_GRP(96, 0xd30, 8, 2),
MTK_PIN_DRV_GRP(97, 0xb70, 4, 0),
MTK_PIN_DRV_GRP(98, 0xb70, 4, 0),
MTK_PIN_DRV_GRP(99, 0xb70, 4, 0),
MTK_PIN_DRV_GRP(100, 0xb70, 4, 0),
MTK_PIN_DRV_GRP(101, 0xb70, 8, 0),
MTK_PIN_DRV_GRP(102, 0xb70, 8, 0),
MTK_PIN_DRV_GRP(103, 0xb70, 8, 0),
MTK_PIN_DRV_GRP(104, 0xb70, 8, 0),
MTK_PIN_DRV_GRP(135, 0xb40, 0, 1),
MTK_PIN_DRV_GRP(136, 0xb40, 0, 1),
MTK_PIN_DRV_GRP(137, 0xb40, 0, 1),
MTK_PIN_DRV_GRP(138, 0xb40, 0, 1),
MTK_PIN_DRV_GRP(139, 0xb40, 0, 1),
MTK_PIN_DRV_GRP(140, 0xb40, 0, 1),
MTK_PIN_DRV_GRP(141, 0xb40, 0, 1),
MTK_PIN_DRV_GRP(142, 0xb40, 0, 1),
MTK_PIN_DRV_GRP(143, 0xba0, 12, 0),
MTK_PIN_DRV_GRP(144, 0xba0, 12, 0),
MTK_PIN_DRV_GRP(145, 0xba0, 12, 0),
MTK_PIN_DRV_GRP(146, 0xba0, 12, 0),
MTK_PIN_DRV_GRP(147, 0xba0, 12, 0),
MTK_PIN_DRV_GRP(148, 0xbb0, 0, 0),
MTK_PIN_DRV_GRP(149, 0xbb0, 0, 0),
MTK_PIN_DRV_GRP(150, 0xbb0, 0, 0),
MTK_PIN_DRV_GRP(151, 0xbb0, 0, 0),
MTK_PIN_DRV_GRP(152, 0xbb0, 0, 0),
MTK_PIN_DRV_GRP(153, 0xbb0, 4, 0),
MTK_PIN_DRV_GRP(154, 0xbb0, 4, 0),
MTK_PIN_DRV_GRP(155, 0xbb0, 4, 0),
MTK_PIN_DRV_GRP(156, 0xbb0, 4, 0),
MTK_PIN_DRV_GRP(157, 0xbb0, 8, 0),
MTK_PIN_DRV_GRP(158, 0xbb0, 8, 0),
MTK_PIN_DRV_GRP(159, 0xbb0, 8, 0),
MTK_PIN_DRV_GRP(160, 0xbb0, 8, 0),
MTK_PIN_DRV_GRP(161, 0xbb0, 12, 0),
MTK_PIN_DRV_GRP(162, 0xbb0, 12, 0),
MTK_PIN_DRV_GRP(163, 0xbb0, 12, 0),
MTK_PIN_DRV_GRP(164, 0xbb0, 12, 0),
MTK_PIN_DRV_GRP(165, 0xbc0, 0, 0),
MTK_PIN_DRV_GRP(166, 0xbc0, 0, 0),
MTK_PIN_DRV_GRP(167, 0xbc0, 0, 0),
MTK_PIN_DRV_GRP(168, 0xbc0, 0, 0),
MTK_PIN_DRV_GRP(169, 0xbc0, 4, 0),
MTK_PIN_DRV_GRP(170, 0xbc0, 4, 0),
MTK_PIN_DRV_GRP(171, 0xbc0, 8, 0),
MTK_PIN_DRV_GRP(172, 0xbc0, 8, 0),
MTK_PIN_DRV_GRP(173, 0xbc0, 12, 0),
MTK_PIN_DRV_GRP(174, 0xbd0, 0, 0),
MTK_PIN_DRV_GRP(175, 0xbd0, 0, 0),
MTK_PIN_DRV_GRP(176, 0xbc0, 12, 0),
MTK_PIN_DRV_GRP(177, 0xbd0, 4, 0),
MTK_PIN_DRV_GRP(178, 0xbd0, 8, 0),
MTK_PIN_DRV_GRP(179, 0xbd0, 4, 0),
MTK_PIN_DRV_GRP(180, 0xbd0, 8, 0),
MTK_PIN_DRV_GRP(181, 0xbd0, 12, 0),
MTK_PIN_DRV_GRP(182, 0xbe0, 0, 0),
MTK_PIN_DRV_GRP(183, 0xbd0, 12, 0),
MTK_PIN_DRV_GRP(184, 0xbe0, 0, 0),
MTK_PIN_DRV_GRP(185, 0xbe0, 4, 0),
MTK_PIN_DRV_GRP(186, 0xbe0, 8, 0),
MTK_PIN_DRV_GRP(187, 0xbe0, 12, 0),
MTK_PIN_DRV_GRP(188, 0xbf0, 0, 0),
MTK_PIN_DRV_GRP(189, 0xbe0, 12, 0),
MTK_PIN_DRV_GRP(190, 0xbf0, 0, 0),
MTK_PIN_DRV_GRP(191, 0xbf0, 4, 0),
MTK_PIN_DRV_GRP(192, 0xbf0, 8, 0),
MTK_PIN_DRV_GRP(193, 0xbf0, 4, 0),
MTK_PIN_DRV_GRP(194, 0xbf0, 4, 0),
MTK_PIN_DRV_GRP(195, 0xbf0, 8, 0),
MTK_PIN_DRV_GRP(196, 0xbf0, 12, 0),
MTK_PIN_DRV_GRP(197, 0xbf0, 12, 0),
MTK_PIN_DRV_GRP(198, 0xbf0, 12, 0),
MTK_PIN_DRV_GRP(199, 0xbf0, 12, 0),
MTK_PIN_DRV_GRP(200, 0xc00, 0, 0),
MTK_PIN_DRV_GRP(201, 0xc00, 0, 0),
MTK_PIN_DRV_GRP(202, 0xc00, 0, 0),
MTK_PIN_DRV_GRP(203, 0xc00, 0, 0),
MTK_PIN_DRV_GRP(204, 0xc00, 4, 0),
MTK_PIN_DRV_GRP(205, 0xc00, 4, 0),
MTK_PIN_DRV_GRP(206, 0xc00, 4, 0),
MTK_PIN_DRV_GRP(207, 0xc00, 8, 0),
MTK_PIN_DRV_GRP(208, 0xc00, 8, 0),
MTK_PIN_DRV_GRP(209, 0xc00, 8, 0),
};
static const struct mtk_pinctrl_devdata mt2712_pinctrl_data = {
.pins = mtk_pins_mt2712,
.npins = ARRAY_SIZE(mtk_pins_mt2712),
.grp_desc = mt2712_drv_grp,
.n_grp_cls = ARRAY_SIZE(mt2712_drv_grp),
.pin_drv_grp = mt2712_pin_drv,
.n_pin_drv_grps = ARRAY_SIZE(mt2712_pin_drv),
.spec_pull_set = mt2712_spec_pull_set,
.spec_ies_smt_set = mt2712_ies_smt_set,
.dir_offset = 0x0000,
.pullen_offset = 0x0100,
.pullsel_offset = 0x0200,
.dout_offset = 0x0300,
.din_offset = 0x0400,
.pinmux_offset = 0x0500,
.type1_start = 210,
.type1_end = 210,
.port_shf = 4,
.port_mask = 0xf,
.port_align = 4,
.eint_hw = {
.port_mask = 0xf,
.ports = 8,
.ap_num = 229,
.db_cnt = 40,
},
};
static int mt2712_pinctrl_probe(struct platform_device *pdev)
{
return mtk_pctrl_init(pdev, &mt2712_pinctrl_data, NULL);
}
static const struct of_device_id mt2712_pctrl_match[] = {
{
.compatible = "mediatek,mt2712-pinctrl",
},
{ }
};
MODULE_DEVICE_TABLE(of, mt2712_pctrl_match);
static struct platform_driver mtk_pinctrl_driver = {
.probe = mt2712_pinctrl_probe,
.driver = {
.name = "mediatek-mt2712-pinctrl",
.of_match_table = mt2712_pctrl_match,
.pm = &mtk_eint_pm_ops,
},
};
static int __init mtk_pinctrl_init(void)
{
return platform_driver_register(&mtk_pinctrl_driver);
}
arch_initcall(mtk_pinctrl_init);
+67
View File
@@ -0,0 +1,67 @@
/*
* Copyright (c) 2015 MediaTek Inc.
* Author: Hongzhou.Yang <hongzhou.yang@mediatek.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/pinctrl/pinconf-generic.h>
#include <linux/mfd/mt6397/core.h>
#include "pinctrl-mtk-common.h"
#include "pinctrl-mtk-mt6397.h"
#define MT6397_PIN_REG_BASE 0xc000
static const struct mtk_pinctrl_devdata mt6397_pinctrl_data = {
.pins = mtk_pins_mt6397,
.npins = ARRAY_SIZE(mtk_pins_mt6397),
.dir_offset = (MT6397_PIN_REG_BASE + 0x000),
.ies_offset = MTK_PINCTRL_NOT_SUPPORT,
.smt_offset = MTK_PINCTRL_NOT_SUPPORT,
.pullen_offset = (MT6397_PIN_REG_BASE + 0x020),
.pullsel_offset = (MT6397_PIN_REG_BASE + 0x040),
.dout_offset = (MT6397_PIN_REG_BASE + 0x080),
.din_offset = (MT6397_PIN_REG_BASE + 0x0a0),
.pinmux_offset = (MT6397_PIN_REG_BASE + 0x0c0),
.type1_start = 41,
.type1_end = 41,
.port_shf = 3,
.port_mask = 0x3,
.port_align = 2,
};
static int mt6397_pinctrl_probe(struct platform_device *pdev)
{
struct mt6397_chip *mt6397;
mt6397 = dev_get_drvdata(pdev->dev.parent);
return mtk_pctrl_init(pdev, &mt6397_pinctrl_data, mt6397->regmap);
}
static const struct of_device_id mt6397_pctrl_match[] = {
{ .compatible = "mediatek,mt6397-pinctrl", },
{ }
};
static struct platform_driver mtk_pinctrl_driver = {
.probe = mt6397_pinctrl_probe,
.driver = {
.name = "mediatek-mt6397-pinctrl",
.of_match_table = mt6397_pctrl_match,
},
};
builtin_platform_driver(mtk_pinctrl_driver);
+614
View File
@@ -0,0 +1,614 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include "pinctrl-mtk-mt6739.h"
#include "pinctrl-paris.h"
/* MT6739 have multiple bases to program pin configuration listed as the below:
* gpio:0x10005000, io_cfg_lt:0x10002000, io_cfg_lm:0x10002200,
* io_cfg_lb:0x10002400, io_cfg_bl:0x10002600, io_cfg_bm:0x10002800,
* io_cfg_rb:0x10002A00, io_cfg_rt:0x10002C00
* _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)
#define PINS_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, 1)
static const struct mtk_pin_field_calc mt6739_pin_mode_range[] = {
PIN_FIELD_BASE(0, 7, 0, 0x0300, 0x10, 0, 4),
PIN_FIELD_BASE(8, 15, 0, 0x0310, 0x10, 0, 4),
PIN_FIELD_BASE(16, 23, 0, 0x0320, 0x10, 0, 4),
PIN_FIELD_BASE(24, 31, 0, 0x0330, 0x10, 0, 4),
PIN_FIELD_BASE(32, 39, 0, 0x0340, 0x10, 0, 4),
PIN_FIELD_BASE(40, 47, 0, 0x0350, 0x10, 0, 4),
PIN_FIELD_BASE(48, 55, 0, 0x0360, 0x10, 0, 4),
PIN_FIELD_BASE(56, 63, 0, 0x0370, 0x10, 0, 4),
PIN_FIELD_BASE(64, 71, 0, 0x0380, 0x10, 0, 4),
PIN_FIELD_BASE(72, 79, 0, 0x0390, 0x10, 0, 4),
PIN_FIELD_BASE(80, 87, 0, 0x03A0, 0x10, 0, 4),
PIN_FIELD_BASE(88, 95, 0, 0x03B0, 0x10, 0, 4),
PIN_FIELD_BASE(96, 103, 0, 0x03C0, 0x10, 0, 4),
PIN_FIELD_BASE(104, 111, 0, 0x03D0, 0x10, 0, 4),
PIN_FIELD_BASE(112, 119, 0, 0x03E0, 0x10, 0, 4),
PIN_FIELD_BASE(120, 127, 0, 0x03F0, 0x10, 0, 4),
PIN_FIELD_BASE(128, 135, 0, 0x0400, 0x10, 0, 4),
PIN_FIELD_BASE(136, 143, 0, 0x0410, 0x10, 0, 4),
PIN_FIELD_BASE(144, 151, 0, 0x0420, 0x10, 0, 4),
PIN_FIELD_BASE(152, 159, 0, 0x0430, 0x10, 0, 4),
PIN_FIELD_BASE(160, 163, 0, 0x0440, 0x10, 0, 4),
};
static const struct mtk_pin_field_calc mt6739_pin_dir_range[] = {
PIN_FIELD_BASE(0, 31, 0, 0x0000, 0x10, 0, 1),
PIN_FIELD_BASE(32, 63, 0, 0x0010, 0x10, 0, 1),
PIN_FIELD_BASE(64, 95, 0, 0x0020, 0x10, 0, 1),
PIN_FIELD_BASE(96, 127, 0, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(128, 153, 0, 0x0040, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6739_pin_di_range[] = {
PIN_FIELD_BASE(0, 31, 0, 0x0200, 0x10, 0, 1),
PIN_FIELD_BASE(32, 63, 0, 0x0210, 0x10, 0, 1),
PIN_FIELD_BASE(64, 95, 0, 0x0220, 0x10, 0, 1),
PIN_FIELD_BASE(96, 127, 0, 0x0230, 0x10, 0, 1),
PIN_FIELD_BASE(128, 153, 0, 0x0240, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6739_pin_do_range[] = {
PIN_FIELD_BASE(0, 31, 0, 0x0100, 0x10, 0, 1),
PIN_FIELD_BASE(32, 63, 0, 0x0110, 0x10, 0, 1),
PIN_FIELD_BASE(64, 95, 0, 0x0120, 0x10, 0, 1),
PIN_FIELD_BASE(96, 127, 0, 0x0130, 0x10, 0, 1),
PIN_FIELD_BASE(128, 153, 0, 0x0140, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6739_pin_ies_range[] = {
PIN_FIELD_BASE(0, 5, 1, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(6, 9, 4, 0x0020, 0x10, 9, 1),
PIN_FIELD_BASE(10, 11, 6, 0x0030, 0x10, 1, 1),
PIN_FIELD_BASE(12, 13, 5, 0x0030, 0x10, 11, 1),
PIN_FIELD_BASE(14, 15, 3, 0x0020, 0x10, 0, 1),
PIN_FIELD_BASE(16, 16, 5, 0x0030, 0x10, 28, 1),
PIN_FIELD_BASE(17, 17, 5, 0x0030, 0x10, 27, 1),
PIN_FIELD_BASE(18, 19, 5, 0x0030, 0x10, 29, 1),
PIN_FIELD_BASE(20, 21, 6, 0x0030, 0x10, 21, 1),
PIN_FIELD_BASE(22, 23, 4, 0x0020, 0x10, 26, 1),
PIN_FIELD_BASE(24, 25, 4, 0x0020, 0x10, 14, 1),
PIN_FIELD_BASE(26, 26, 4, 0x0020, 0x10, 13, 1),
PIN_FIELD_BASE(27, 30, 5, 0x0030, 0x10, 13, 1),
PIN_FIELD_BASE(31, 31, 6, 0x0030, 0x10, 17, 1),
PIN_FIELD_BASE(32, 32, 6, 0x0030, 0x10, 16, 1),
PIN_FIELD_BASE(33, 34, 6, 0x0030, 0x10, 18, 1),
PIN_FIELD_BASE(35, 37, 7, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(38, 38, 1, 0x0030, 0x10, 7, 1),
PIN_FIELD_BASE(39, 39, 1, 0x0030, 0x10, 16, 1),
PIN_FIELD_BASE(40, 40, 1, 0x0030, 0x10, 6, 1),
PIN_FIELD_BASE(41, 48, 1, 0x0030, 0x10, 8, 1),
PIN_FIELD_BASE(49, 49, 1, 0x0030, 0x10, 17, 1),
PIN_FIELD_BASE(50, 50, 1, 0x0030, 0x10, 20, 1),
PIN_FIELD_BASE(51, 51, 1, 0x0030, 0x10, 19, 1),
PIN_FIELD_BASE(52, 52, 1, 0x0030, 0x10, 22, 1),
PIN_FIELD_BASE(53, 53, 1, 0x0030, 0x10, 18, 1),
PIN_FIELD_BASE(54, 54, 1, 0x0030, 0x10, 21, 1),
PIN_FIELD_BASE(55, 55, 2, 0x0010, 0x10, 15, 1),
PIN_FIELD_BASE(56, 57, 2, 0x0010, 0x10, 13, 1),
PIN_FIELD_BASE(58, 59, 2, 0x0010, 0x10, 10, 1),
PIN_FIELD_BASE(60, 61, 2, 0x0010, 0x10, 8, 1),
PIN_FIELD_BASE(62, 62, 2, 0x0010, 0x10, 7, 1),
PIN_FIELD_BASE(63, 64, 2, 0x0010, 0x10, 4, 1),
PIN_FIELD_BASE(65, 65, 2, 0x0010, 0x10, 1, 1),
PIN_FIELD_BASE(66, 66, 2, 0x0010, 0x10, 6, 1),
PIN_FIELD_BASE(67, 68, 2, 0x0010, 0x10, 2, 1),
PIN_FIELD_BASE(69, 69, 2, 0x0010, 0x10, 0, 1),
PIN_FIELD_BASE(70, 70, 2, 0x0010, 0x10, 12, 1),
PIN_FIELD_BASE(71, 71, 3, 0x0020, 0x10, 3, 1),
PIN_FIELD_BASE(72, 72, 3, 0x0020, 0x10, 2, 1),
PIN_FIELD_BASE(73, 77, 3, 0x0020, 0x10, 4, 1),
PIN_FIELD_BASE(78, 78, 3, 0x0020, 0x10, 10, 1),
PIN_FIELD_BASE(79, 79, 3, 0x0020, 0x10, 9, 1),
PIN_FIELD_BASE(80, 80, 3, 0x0020, 0x10, 11, 1),
PIN_FIELD_BASE(81, 81, 3, 0x0020, 0x10, 13, 1),
PIN_FIELD_BASE(82, 82, 3, 0x0020, 0x10, 12, 1),
PIN_FIELD_BASE(83, 83, 4, 0x0020, 0x10, 16, 1),
PIN_FIELD_BASE(84, 84, 4, 0x0020, 0x10, 8, 1),
PIN_FIELD_BASE(85, 85, 4, 0x0020, 0x10, 7, 1),
PIN_FIELD_BASE(86, 87, 4, 0x0020, 0x10, 24, 1),
PIN_FIELD_BASE(88, 88, 4, 0x0020, 0x10, 23, 1),
PIN_FIELD_BASE(89, 89, 4, 0x0020, 0x10, 22, 1),
PIN_FIELD_BASE(90, 91, 4, 0x0020, 0x10, 5, 1),
PIN_FIELD_BASE(92, 96, 4, 0x0020, 0x10, 0, 1),
PIN_FIELD_BASE(97, 97, 4, 0x0020, 0x10, 21, 1),
PIN_FIELD_BASE(98, 98, 4, 0x0020, 0x10, 17, 1),
PIN_FIELD_BASE(99, 99, 4, 0x0020, 0x10, 20, 1),
PIN_FIELD_BASE(100, 100, 4, 0x0020, 0x10, 19, 1),
PIN_FIELD_BASE(101, 101, 4, 0x0020, 0x10, 18, 1),
PIN_FIELD_BASE(102, 109, 5, 0x0030, 0x10, 3, 1),
PIN_FIELD_BASE(110, 112, 5, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(113, 114, 5, 0x0030, 0x10, 25, 1),
PIN_FIELD_BASE(115, 116, 5, 0x0030, 0x10, 23, 1),
PIN_FIELD_BASE(117, 117, 5, 0x0030, 0x10, 18, 1),
PIN_FIELD_BASE(118, 118, 5, 0x0030, 0x10, 20, 1),
PIN_FIELD_BASE(119, 119, 5, 0x0030, 0x10, 22, 1),
PIN_FIELD_BASE(120, 120, 5, 0x0030, 0x10, 17, 1),
PIN_FIELD_BASE(121, 121, 5, 0x0030, 0x10, 19, 1),
PIN_FIELD_BASE(122, 122, 5, 0x0030, 0x10, 21, 1),
PIN_FIELD_BASE(123, 124, 7, 0x0030, 0x10, 3, 1),
PIN_FIELD_BASE(125, 125, 7, 0x0030, 0x10, 6, 1),
PIN_FIELD_BASE(126, 126, 6, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(127, 127, 7, 0x0030, 0x10, 5, 1),
PIN_FIELD_BASE(128, 128, 6, 0x0030, 0x10, 4, 1),
PIN_FIELD_BASE(129, 129, 6, 0x0030, 0x10, 3, 1),
PIN_FIELD_BASE(130, 130, 6, 0x0030, 0x10, 6, 1),
PIN_FIELD_BASE(131, 131, 6, 0x0030, 0x10, 5, 1),
PIN_FIELD_BASE(132, 132, 6, 0x0030, 0x10, 8, 1),
PIN_FIELD_BASE(133, 133, 6, 0x0030, 0x10, 7, 1),
PIN_FIELD_BASE(134, 134, 6, 0x0030, 0x10, 10, 1),
PIN_FIELD_BASE(135, 135, 6, 0x0030, 0x10, 9, 1),
PIN_FIELD_BASE(136, 136, 6, 0x0030, 0x10, 20, 1),
PIN_FIELD_BASE(137, 137, 6, 0x0030, 0x10, 15, 1),
PIN_FIELD_BASE(138, 140, 6, 0x0030, 0x10, 12, 1),
PIN_FIELD_BASE(141, 141, 6, 0x0030, 0x10, 11, 1),
PIN_FIELD_BASE(142, 142, 7, 0x0030, 0x10, 8, 1),
PIN_FIELD_BASE(143, 143, 7, 0x0030, 0x10, 7, 1),
PIN_FIELD_BASE(144, 147, 7, 0x0030, 0x10, 15, 1),
PIN_FIELD_BASE(148, 153, 7, 0x0030, 0x10, 9, 1),
};
static const struct mtk_pin_field_calc mt6739_pin_smt_range[] = {
PINS_FIELD_BASE(0, 5, 1, 0x0090, 0x10, 0, 1),
PINS_FIELD_BASE(6, 9, 4, 0x0060, 0x10, 4, 1),
PINS_FIELD_BASE(10, 11, 6, 0x0080, 0x10, 1, 1),
PINS_FIELD_BASE(12, 13, 5, 0x00b0, 0x10, 3, 1),
PINS_FIELD_BASE(14, 15, 3, 0x0090, 0x10, 0, 1),
PIN_FIELD_BASE(16, 17, 5, 0x00b0, 0x10, 12, 1),
PINS_FIELD_BASE(18, 19, 5, 0x00b0, 0x10, 12, 1),
PINS_FIELD_BASE(20, 21, 6, 0x0080, 0x10, 11, 1),
PINS_FIELD_BASE(22, 23, 4, 0x0060, 0x10, 13, 1),
PIN_FIELD_BASE(24, 25, 4, 0x0060, 0x10, 6, 1),
PIN_FIELD_BASE(26, 26, 4, 0x0060, 0x10, 5, 1),
PIN_FIELD_BASE(27, 30, 5, 0x00b0, 0x10, 4, 1),
PIN_FIELD_BASE(31, 32, 6, 0x0080, 0x10, 8, 1),
PINS_FIELD_BASE(33, 34, 6, 0x0080, 0x10, 8, 1),
PINS_FIELD_BASE(35, 36, 7, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(37, 37, 7, 0x0080, 0x10, 1, 1),
PIN_FIELD_BASE(38, 38, 1, 0x0090, 0x10, 2, 1),
PIN_FIELD_BASE(39, 39, 1, 0x0090, 0x10, 4, 1),
PIN_FIELD_BASE(40, 40, 1, 0x0090, 0x10, 1, 1),
PINS_FIELD_BASE(41, 48, 1, 0x0090, 0x10, 3, 1),
PIN_FIELD_BASE(49, 49, 1, 0x0090, 0x10, 5, 1),
PINS_FIELD_BASE(50, 54, 1, 0x0090, 0x10, 6, 1),
PIN_FIELD_BASE(55, 55, 2, 0x0050, 0x10, 10, 1),
PINS_FIELD_BASE(56, 57, 2, 0x0050, 0x10, 9, 1),
PINS_FIELD_BASE(58, 59, 2, 0x0050, 0x10, 6, 1),
PIN_FIELD_BASE(60, 60, 2, 0x0050, 0x10, 7, 1),
PIN_FIELD_BASE(61, 61, 2, 0x0050, 0x10, 6, 1),
PIN_FIELD_BASE(62, 62, 2, 0x0050, 0x10, 5, 1),
PINS_FIELD_BASE(63, 64, 2, 0x0050, 0x10, 3, 1),
PIN_FIELD_BASE(65, 65, 2, 0x0050, 0x10, 1, 1),
PIN_FIELD_BASE(66, 66, 2, 0x0050, 0x10, 4, 1),
PINS_FIELD_BASE(67, 68, 2, 0x0050, 0x10, 2, 1),
PIN_FIELD_BASE(69, 69, 2, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(70, 70, 2, 0x0050, 0x10, 8, 1),
PIN_FIELD_BASE(71, 71, 3, 0x0090, 0x10, 2, 1),
PIN_FIELD_BASE(72, 72, 3, 0x0090, 0x10, 1, 1),
PINS_FIELD_BASE(73, 76, 3, 0x0090, 0x10, 3, 1),
PIN_FIELD_BASE(77, 77, 3, 0x0090, 0x10, 5, 1),
PINS_FIELD_BASE(78, 79, 3, 0x0090, 0x10, 4, 1),
PIN_FIELD_BASE(80, 80, 3, 0x0090, 0x10, 7, 1),
PINS_FIELD_BASE(81, 82, 3, 0x0090, 0x10, 6, 1),
PIN_FIELD_BASE(83, 83, 4, 0x0060, 0x10, 8, 1),
PIN_FIELD_BASE(84, 84, 4, 0x0060, 0x10, 3, 1),
PIN_FIELD_BASE(85, 85, 4, 0x0060, 0x10, 2, 1),
PINS_FIELD_BASE(86, 87, 4, 0x0060, 0x10, 12, 1),
PINS_FIELD_BASE(88, 89, 4, 0x0060, 0x10, 11, 1),
PINS_FIELD_BASE(90, 93, 4, 0x0060, 0x10, 0, 1),
PINS_FIELD_BASE(94, 96, 4, 0x0060, 0x10, 1, 1),
PIN_FIELD_BASE(97, 97, 4, 0x0060, 0x10, 10, 1),
PIN_FIELD_BASE(98, 98, 4, 0x0060, 0x10, 9, 1),
PINS_FIELD_BASE(99, 101, 4, 0x0060, 0x10, 10, 1),
PINS_FIELD_BASE(102, 105, 5, 0x00b0, 0x10, 1, 1),
PINS_FIELD_BASE(106, 109, 5, 0x00b0, 0x10, 2, 1),
PINS_FIELD_BASE(110, 112, 5, 0x00b0, 0x10, 0, 1),
PINS_FIELD_BASE(113, 114, 5, 0x00b0, 0x10, 11, 1),
PINS_FIELD_BASE(115, 116, 5, 0x00b0, 0x10, 10, 1),
PINS_FIELD_BASE(117, 119, 5, 0x00b0, 0x10, 9, 1),
PINS_FIELD_BASE(120, 122, 5, 0x00b0, 0x10, 8, 1),
PINS_FIELD_BASE(123, 124, 7, 0x0080, 0x10, 2, 1),
PIN_FIELD_BASE(125, 125, 7, 0x0080, 0x10, 4, 1),
PIN_FIELD_BASE(126, 126, 6, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(127, 127, 7, 0x0080, 0x10, 3, 1),
PINS_FIELD_BASE(128, 129, 6, 0x0080, 0x10, 2, 1),
PINS_FIELD_BASE(130, 131, 6, 0x0080, 0x10, 3, 1),
PINS_FIELD_BASE(132, 133, 6, 0x0080, 0x10, 4, 1),
PINS_FIELD_BASE(134, 135, 6, 0x0080, 0x10, 5, 1),
PIN_FIELD_BASE(136, 136, 6, 0x0080, 0x10, 10, 1),
PIN_FIELD_BASE(137, 137, 6, 0x0080, 0x10, 7, 1),
PIN_FIELD_BASE(138, 138, 6, 0x0080, 0x10, 6, 1),
PINS_FIELD_BASE(139, 141, 6, 0x0080, 0x10, 7, 1),
PINS_FIELD_BASE(142, 143, 7, 0x0080, 0x10, 5, 1),
PIN_FIELD_BASE(144, 144, 7, 0x0080, 0x10, 8, 1),
PIN_FIELD_BASE(145, 145, 7, 0x0080, 0x10, 7, 1),
PINS_FIELD_BASE(146, 147, 7, 0x0080, 0x10, 8, 1),
PINS_FIELD_BASE(148, 153, 7, 0x0080, 0x10, 6, 1),
};
static const struct mtk_pin_field_calc mt6739_pin_pu_range[] = {
PIN_FIELD_BASE(6, 9, 4, 0x0040, 0x10, 9, 1),
PIN_FIELD_BASE(10, 11, 6, 0x0050, 0x10, 1, 1),
PIN_FIELD_BASE(12, 13, 5, 0x0060, 0x10, 11, 1),
PIN_FIELD_BASE(16, 16, 5, 0x0060, 0x10, 22, 1),
PIN_FIELD_BASE(17, 17, 5, 0x0060, 0x10, 21, 1),
PIN_FIELD_BASE(18, 19, 5, 0x0060, 0x10, 23, 1),
PIN_FIELD_BASE(20, 21, 6, 0x0050, 0x10, 22, 1),
PIN_FIELD_BASE(22, 23, 4, 0x0040, 0x10, 26, 1),
PIN_FIELD_BASE(24, 25, 4, 0x0040, 0x10, 14, 1),
PIN_FIELD_BASE(26, 26, 4, 0x0040, 0x10, 13, 1),
PIN_FIELD_BASE(27, 30, 5, 0x0060, 0x10, 13, 1),
PIN_FIELD_BASE(31, 31, 6, 0x0050, 0x10, 17, 1),
PIN_FIELD_BASE(32, 32, 6, 0x0050, 0x10, 16, 1),
PIN_FIELD_BASE(33, 34, 6, 0x0050, 0x10, 18, 1),
PIN_FIELD_BASE(35, 37, 7, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(55, 55, 2, 0x0030, 0x10, 16, 1),
PIN_FIELD_BASE(56, 57, 2, 0x0030, 0x10, 13, 1),
PIN_FIELD_BASE(58, 59, 2, 0x0030, 0x10, 10, 1),
PIN_FIELD_BASE(60, 61, 2, 0x0030, 0x10, 8, 1),
PIN_FIELD_BASE(62, 62, 2, 0x0030, 0x10, 7, 1),
PIN_FIELD_BASE(63, 64, 2, 0x0030, 0x10, 4, 1),
PIN_FIELD_BASE(65, 65, 2, 0x0030, 0x10, 1, 1),
PIN_FIELD_BASE(66, 66, 2, 0x0030, 0x10, 6, 1),
PIN_FIELD_BASE(67, 68, 2, 0x0030, 0x10, 2, 1),
PIN_FIELD_BASE(69, 69, 2, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(70, 70, 2, 0x0030, 0x10, 12, 1),
PIN_FIELD_BASE(83, 83, 4, 0x0040, 0x10, 16, 1),
PIN_FIELD_BASE(84, 84, 4, 0x0040, 0x10, 8, 1),
PIN_FIELD_BASE(85, 85, 4, 0x0040, 0x10, 7, 1),
PIN_FIELD_BASE(86, 87, 4, 0x0040, 0x10, 24, 1),
PIN_FIELD_BASE(88, 88, 4, 0x0040, 0x10, 23, 1),
PIN_FIELD_BASE(89, 89, 4, 0x0040, 0x10, 22, 1),
PIN_FIELD_BASE(90, 91, 4, 0x0040, 0x10, 5, 1),
PIN_FIELD_BASE(92, 96, 4, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(97, 97, 4, 0x0040, 0x10, 21, 1),
PIN_FIELD_BASE(98, 98, 4, 0x0040, 0x10, 17, 1),
PIN_FIELD_BASE(99, 99, 4, 0x0040, 0x10, 20, 1),
PIN_FIELD_BASE(100, 100, 4, 0x0040, 0x10, 19, 1),
PIN_FIELD_BASE(101, 101, 4, 0x0040, 0x10, 18, 1),
PIN_FIELD_BASE(102, 109, 5, 0x0060, 0x10, 3, 1),
PIN_FIELD_BASE(110, 112, 5, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(113, 114, 5, 0x0060, 0x10, 19, 1),
PIN_FIELD_BASE(115, 116, 5, 0x0060, 0x10, 17, 1),
PIN_FIELD_BASE(123, 124, 7, 0x0050, 0x10, 3, 1),
PIN_FIELD_BASE(125, 125, 7, 0x0050, 0x10, 6, 1),
PIN_FIELD_BASE(126, 126, 6, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(127, 127, 7, 0x0050, 0x10, 5, 1),
PIN_FIELD_BASE(128, 128, 6, 0x0050, 0x10, 4, 1),
PIN_FIELD_BASE(129, 129, 6, 0x0050, 0x10, 3, 1),
PIN_FIELD_BASE(130, 130, 6, 0x0050, 0x10, 6, 1),
PIN_FIELD_BASE(131, 131, 6, 0x0050, 0x10, 5, 1),
PIN_FIELD_BASE(132, 132, 6, 0x0050, 0x10, 8, 1),
PIN_FIELD_BASE(133, 133, 6, 0x0050, 0x10, 7, 1),
PIN_FIELD_BASE(134, 134, 6, 0x0050, 0x10, 10, 1),
PIN_FIELD_BASE(135, 135, 6, 0x0050, 0x10, 9, 1),
PIN_FIELD_BASE(136, 136, 6, 0x0050, 0x10, 20, 1),
PIN_FIELD_BASE(137, 137, 6, 0x0050, 0x10, 15, 1),
PIN_FIELD_BASE(138, 140, 6, 0x0050, 0x10, 12, 1),
PIN_FIELD_BASE(141, 141, 6, 0x0050, 0x10, 11, 1),
PIN_FIELD_BASE(142, 142, 7, 0x0050, 0x10, 8, 1),
PIN_FIELD_BASE(143, 143, 7, 0x0050, 0x10, 7, 1),
PIN_FIELD_BASE(144, 147, 7, 0x0050, 0x10, 15, 1),
PIN_FIELD_BASE(148, 153, 7, 0x0050, 0x10, 9, 1),
};
static const struct mtk_pin_field_calc mt6739_pin_pd_range[] = {
PIN_FIELD_BASE(6, 9, 4, 0x0030, 0x10, 9, 1),
PIN_FIELD_BASE(10, 11, 6, 0x0040, 0x10, 1, 1),
PIN_FIELD_BASE(12, 13, 5, 0x0040, 0x10, 11, 1),
PIN_FIELD_BASE(16, 16, 5, 0x0040, 0x10, 22, 1),
PIN_FIELD_BASE(17, 17, 5, 0x0040, 0x10, 21, 1),
PIN_FIELD_BASE(18, 19, 5, 0x0040, 0x10, 23, 1),
PIN_FIELD_BASE(20, 21, 6, 0x0040, 0x10, 22, 1),
PIN_FIELD_BASE(22, 23, 4, 0x0030, 0x10, 26, 1),
PIN_FIELD_BASE(24, 25, 4, 0x0030, 0x10, 14, 1),
PIN_FIELD_BASE(26, 26, 4, 0x0030, 0x10, 13, 1),
PIN_FIELD_BASE(27, 30, 5, 0x0040, 0x10, 13, 1),
PIN_FIELD_BASE(31, 31, 6, 0x0040, 0x10, 17, 1),
PIN_FIELD_BASE(32, 32, 6, 0x0040, 0x10, 16, 1),
PIN_FIELD_BASE(33, 34, 6, 0x0040, 0x10, 18, 1),
PIN_FIELD_BASE(35, 37, 7, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(55, 55, 2, 0x0020, 0x10, 16, 1),
PIN_FIELD_BASE(56, 57, 2, 0x0020, 0x10, 13, 1),
PIN_FIELD_BASE(58, 59, 2, 0x0020, 0x10, 10, 1),
PIN_FIELD_BASE(60, 61, 2, 0x0020, 0x10, 8, 1),
PIN_FIELD_BASE(62, 62, 2, 0x0020, 0x10, 7, 1),
PIN_FIELD_BASE(63, 64, 2, 0x0020, 0x10, 4, 1),
PIN_FIELD_BASE(65, 65, 2, 0x0020, 0x10, 1, 1),
PIN_FIELD_BASE(66, 66, 2, 0x0020, 0x10, 6, 1),
PIN_FIELD_BASE(67, 68, 2, 0x0020, 0x10, 2, 1),
PIN_FIELD_BASE(69, 69, 2, 0x0020, 0x10, 0, 1),
PIN_FIELD_BASE(70, 70, 2, 0x0020, 0x10, 12, 1),
PIN_FIELD_BASE(83, 83, 4, 0x0030, 0x10, 16, 1),
PIN_FIELD_BASE(84, 84, 4, 0x0030, 0x10, 8, 1),
PIN_FIELD_BASE(85, 85, 4, 0x0030, 0x10, 7, 1),
PIN_FIELD_BASE(86, 87, 4, 0x0030, 0x10, 24, 1),
PIN_FIELD_BASE(88, 88, 4, 0x0030, 0x10, 23, 1),
PIN_FIELD_BASE(89, 89, 4, 0x0030, 0x10, 22, 1),
PIN_FIELD_BASE(90, 91, 4, 0x0030, 0x10, 5, 1),
PIN_FIELD_BASE(92, 96, 4, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(97, 97, 4, 0x0030, 0x10, 21, 1),
PIN_FIELD_BASE(98, 98, 4, 0x0030, 0x10, 17, 1),
PIN_FIELD_BASE(99, 99, 4, 0x0030, 0x10, 20, 1),
PIN_FIELD_BASE(100, 100, 4, 0x0030, 0x10, 19, 1),
PIN_FIELD_BASE(101, 101, 4, 0x0030, 0x10, 18, 1),
PIN_FIELD_BASE(102, 109, 5, 0x0040, 0x10, 3, 1),
PIN_FIELD_BASE(110, 112, 5, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(113, 114, 5, 0x0040, 0x10, 19, 1),
PIN_FIELD_BASE(115, 116, 5, 0x0040, 0x10, 17, 1),
PIN_FIELD_BASE(123, 124, 7, 0x0040, 0x10, 3, 1),
PIN_FIELD_BASE(125, 125, 7, 0x0040, 0x10, 6, 1),
PIN_FIELD_BASE(126, 126, 6, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(127, 127, 7, 0x0040, 0x10, 5, 1),
PIN_FIELD_BASE(128, 128, 6, 0x0040, 0x10, 4, 1),
PIN_FIELD_BASE(129, 129, 6, 0x0040, 0x10, 3, 1),
PIN_FIELD_BASE(130, 130, 6, 0x0040, 0x10, 6, 1),
PIN_FIELD_BASE(131, 131, 6, 0x0040, 0x10, 5, 1),
PIN_FIELD_BASE(132, 132, 6, 0x0040, 0x10, 8, 1),
PIN_FIELD_BASE(133, 133, 6, 0x0040, 0x10, 7, 1),
PIN_FIELD_BASE(134, 134, 6, 0x0040, 0x10, 10, 1),
PIN_FIELD_BASE(135, 135, 6, 0x0040, 0x10, 9, 1),
PIN_FIELD_BASE(136, 136, 6, 0x0040, 0x10, 20, 1),
PIN_FIELD_BASE(137, 137, 6, 0x0040, 0x10, 15, 1),
PIN_FIELD_BASE(138, 140, 6, 0x0040, 0x10, 12, 1),
PIN_FIELD_BASE(141, 141, 6, 0x0040, 0x10, 11, 1),
PIN_FIELD_BASE(142, 142, 7, 0x0040, 0x10, 8, 1),
PIN_FIELD_BASE(143, 143, 7, 0x0040, 0x10, 7, 1),
PIN_FIELD_BASE(144, 147, 7, 0x0040, 0x10, 15, 1),
PIN_FIELD_BASE(148, 153, 7, 0x0040, 0x10, 9, 1),
};
static const struct mtk_pin_field_calc mt6739_pin_pupd_range[] = {
PIN_FIELD_BASE(0, 5, 1, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(14, 15, 3, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(38, 38, 1, 0x0040, 0x10, 7, 1),
PIN_FIELD_BASE(39, 39, 1, 0x0040, 0x10, 16, 1),
PIN_FIELD_BASE(40, 40, 1, 0x0040, 0x10, 6, 1),
PIN_FIELD_BASE(41, 48, 1, 0x0040, 0x10, 8, 1),
PIN_FIELD_BASE(49, 49, 1, 0x0040, 0x10, 17, 1),
PIN_FIELD_BASE(50, 50, 1, 0x0040, 0x10, 20, 1),
PIN_FIELD_BASE(51, 51, 1, 0x0040, 0x10, 19, 1),
PIN_FIELD_BASE(52, 52, 1, 0x0040, 0x10, 22, 1),
PIN_FIELD_BASE(53, 53, 1, 0x0040, 0x10, 18, 1),
PIN_FIELD_BASE(54, 54, 1, 0x0040, 0x10, 21, 1),
PIN_FIELD_BASE(71, 71, 3, 0x0030, 0x10, 3, 1),
PIN_FIELD_BASE(72, 72, 3, 0x0030, 0x10, 2, 1),
PIN_FIELD_BASE(73, 77, 3, 0x0030, 0x10, 4, 1),
PIN_FIELD_BASE(78, 78, 3, 0x0030, 0x10, 10, 1),
PIN_FIELD_BASE(79, 79, 3, 0x0030, 0x10, 9, 1),
PIN_FIELD_BASE(80, 80, 3, 0x0030, 0x10, 11, 1),
PIN_FIELD_BASE(81, 81, 3, 0x0030, 0x10, 13, 1),
PIN_FIELD_BASE(82, 82, 3, 0x0030, 0x10, 12, 1),
PIN_FIELD_BASE(117, 117, 5, 0x0050, 0x10, 1, 1),
PIN_FIELD_BASE(118, 118, 5, 0x0050, 0x10, 3, 1),
PIN_FIELD_BASE(119, 119, 5, 0x0050, 0x10, 5, 1),
PIN_FIELD_BASE(120, 120, 5, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(121, 121, 5, 0x0050, 0x10, 2, 1),
PIN_FIELD_BASE(122, 122, 5, 0x0050, 0x10, 4, 1),
};
static const struct mtk_pin_field_calc mt6739_pin_r0_range[] = {
PIN_FIELD_BASE(0, 5, 1, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(14, 15, 3, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(38, 38, 1, 0x0050, 0x10, 7, 1),
PIN_FIELD_BASE(39, 39, 1, 0x0050, 0x10, 16, 1),
PIN_FIELD_BASE(40, 40, 1, 0x0050, 0x10, 6, 1),
PIN_FIELD_BASE(41, 48, 1, 0x0050, 0x10, 8, 1),
PIN_FIELD_BASE(49, 49, 1, 0x0050, 0x10, 17, 1),
PIN_FIELD_BASE(50, 50, 1, 0x0050, 0x10, 20, 1),
PIN_FIELD_BASE(51, 51, 1, 0x0050, 0x10, 19, 1),
PIN_FIELD_BASE(52, 52, 1, 0x0050, 0x10, 22, 1),
PIN_FIELD_BASE(53, 53, 1, 0x0050, 0x10, 18, 1),
PIN_FIELD_BASE(54, 54, 1, 0x0050, 0x10, 21, 1),
PIN_FIELD_BASE(71, 71, 3, 0x0050, 0x10, 3, 1),
PIN_FIELD_BASE(72, 72, 3, 0x0050, 0x10, 2, 1),
PIN_FIELD_BASE(73, 77, 3, 0x0050, 0x10, 4, 1),
PIN_FIELD_BASE(78, 78, 3, 0x0050, 0x10, 10, 1),
PIN_FIELD_BASE(79, 79, 3, 0x0050, 0x10, 9, 1),
PIN_FIELD_BASE(80, 80, 3, 0x0050, 0x10, 11, 1),
PIN_FIELD_BASE(81, 81, 3, 0x0050, 0x10, 13, 1),
PIN_FIELD_BASE(82, 82, 3, 0x0050, 0x10, 12, 1),
PIN_FIELD_BASE(117, 117, 5, 0x0070, 0x10, 1, 1),
PIN_FIELD_BASE(118, 118, 5, 0x0070, 0x10, 3, 1),
PIN_FIELD_BASE(119, 119, 5, 0x0070, 0x10, 5, 1),
PIN_FIELD_BASE(120, 120, 5, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(121, 121, 5, 0x0070, 0x10, 2, 1),
PIN_FIELD_BASE(122, 122, 5, 0x0070, 0x10, 4, 1),
};
static const struct mtk_pin_field_calc mt6739_pin_r1_range[] = {
PIN_FIELD_BASE(0, 5, 1, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(14, 15, 3, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(38, 38, 1, 0x0060, 0x10, 7, 1),
PIN_FIELD_BASE(39, 39, 1, 0x0060, 0x10, 16, 1),
PIN_FIELD_BASE(40, 40, 1, 0x0060, 0x10, 6, 1),
PIN_FIELD_BASE(41, 48, 1, 0x0060, 0x10, 8, 1),
PIN_FIELD_BASE(49, 49, 1, 0x0060, 0x10, 17, 1),
PIN_FIELD_BASE(50, 50, 1, 0x0060, 0x10, 20, 1),
PIN_FIELD_BASE(51, 51, 1, 0x0060, 0x10, 19, 1),
PIN_FIELD_BASE(52, 52, 1, 0x0060, 0x10, 22, 1),
PIN_FIELD_BASE(53, 53, 1, 0x0060, 0x10, 18, 1),
PIN_FIELD_BASE(54, 54, 1, 0x0060, 0x10, 21, 1),
PIN_FIELD_BASE(71, 71, 3, 0x0060, 0x10, 3, 1),
PIN_FIELD_BASE(72, 72, 3, 0x0060, 0x10, 2, 1),
PIN_FIELD_BASE(73, 77, 3, 0x0060, 0x10, 4, 1),
PIN_FIELD_BASE(78, 78, 3, 0x0060, 0x10, 10, 1),
PIN_FIELD_BASE(79, 79, 3, 0x0060, 0x10, 9, 1),
PIN_FIELD_BASE(80, 80, 3, 0x0060, 0x10, 11, 1),
PIN_FIELD_BASE(81, 81, 3, 0x0060, 0x10, 13, 1),
PIN_FIELD_BASE(82, 82, 3, 0x0060, 0x10, 12, 1),
PIN_FIELD_BASE(117, 117, 5, 0x0080, 0x10, 1, 1),
PIN_FIELD_BASE(118, 118, 5, 0x0080, 0x10, 3, 1),
PIN_FIELD_BASE(119, 119, 5, 0x0080, 0x10, 5, 1),
PIN_FIELD_BASE(120, 120, 5, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(121, 121, 5, 0x0080, 0x10, 2, 1),
PIN_FIELD_BASE(122, 122, 5, 0x0080, 0x10, 4, 1),
};
static const struct mtk_pin_field_calc mt6739_pin_drv_range[] = {
PIN_FIELD_BASE(0, 5, 1, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(6, 9, 4, 0x0000, 0x10, 8, 2),
PINS_FIELD_BASE(10, 11, 6, 0x0000, 0x10, 2, 2),
PIN_FIELD_BASE(12, 13, 5, 0x0000, 0x10, 6, 5),
PINS_FIELD_BASE(14, 15, 3, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(16, 17, 5, 0x0010, 0x10, 8, 2),
PINS_FIELD_BASE(18, 19, 5, 0x0010, 0x10, 8, 2),
PINS_FIELD_BASE(20, 21, 6, 0x0010, 0x10, 25, 2),
PIN_FIELD_BASE(22, 23, 4, 0x0010, 0x10, 2, 2),
PIN_FIELD_BASE(24, 25, 4, 0x0000, 0x10, 18, 2),
PIN_FIELD_BASE(26, 26, 4, 0x0000, 0x10, 16, 2),
PIN_FIELD_BASE(27, 30, 5, 0x0000, 0x10, 16, 2),
PIN_FIELD_BASE(31, 32, 6, 0x0010, 0x10, 19, 2),
PINS_FIELD_BASE(33, 34, 6, 0x0010, 0x10, 19, 2),
PIN_FIELD_BASE(35, 36, 7, 0x0000, 0x10, 0, 5),
PIN_FIELD_BASE(37, 37, 7, 0x0000, 0x10, 10, 2),
PIN_FIELD_BASE(38, 38, 1, 0x0000, 0x10, 21, 3),
PIN_FIELD_BASE(39, 39, 1, 0x0010, 0x10, 18, 3),
PIN_FIELD_BASE(40, 40, 1, 0x0000, 0x10, 18, 3),
PIN_FIELD_BASE(41, 42, 1, 0x0000, 0x10, 24, 3),
PIN_FIELD_BASE(43, 48, 1, 0x0010, 0x10, 0, 3),
PIN_FIELD_BASE(49, 49, 1, 0x0010, 0x10, 21, 3),
PIN_FIELD_BASE(50, 50, 1, 0x0020, 0x10, 0, 3),
PIN_FIELD_BASE(51, 51, 1, 0x0010, 0x10, 27, 3),
PIN_FIELD_BASE(52, 52, 1, 0x0020, 0x10, 6, 3),
PIN_FIELD_BASE(53, 53, 1, 0x0010, 0x10, 24, 3),
PIN_FIELD_BASE(54, 54, 1, 0x0020, 0x10, 3, 3),
PIN_FIELD_BASE(55, 55, 2, 0x0000, 0x10, 24, 2),
PINS_FIELD_BASE(56, 57, 2, 0x0000, 0x10, 22, 2),
PINS_FIELD_BASE(58, 59, 2, 0x0000, 0x10, 16, 2),
PIN_FIELD_BASE(60, 60, 2, 0x0000, 0x10, 18, 2),
PIN_FIELD_BASE(61, 61, 2, 0x0000, 0x10, 16, 2),
PIN_FIELD_BASE(62, 62, 2, 0x0000, 0x10, 14, 2),
PIN_FIELD_BASE(63, 64, 2, 0x0000, 0x10, 8, 2),
PIN_FIELD_BASE(65, 65, 2, 0x0000, 0x10, 2, 2),
PIN_FIELD_BASE(66, 66, 2, 0x0000, 0x10, 12, 2),
PIN_FIELD_BASE(67, 68, 2, 0x0000, 0x10, 4, 2),
PIN_FIELD_BASE(69, 69, 2, 0x0000, 0x10, 0, 2),
PIN_FIELD_BASE(70, 70, 2, 0x0000, 0x10, 20, 2),
PIN_FIELD_BASE(71, 71, 3, 0x0000, 0x10, 6, 3),
PIN_FIELD_BASE(72, 72, 3, 0x0000, 0x10, 3, 3),
PINS_FIELD_BASE(73, 76, 3, 0x0000, 0x10, 9, 3),
PIN_FIELD_BASE(77, 77, 3, 0x0000, 0x10, 14, 2),
PINS_FIELD_BASE(78, 79, 3, 0x0000, 0x10, 12, 2),
PIN_FIELD_BASE(80, 80, 3, 0x0000, 0x10, 18, 2),
PINS_FIELD_BASE(81, 82, 3, 0x0000, 0x10, 16, 2),
PIN_FIELD_BASE(83, 83, 4, 0x0000, 0x10, 22, 2),
PIN_FIELD_BASE(84, 84, 4, 0x0000, 0x10, 6, 2),
PIN_FIELD_BASE(85, 85, 4, 0x0000, 0x10, 4, 2),
PINS_FIELD_BASE(86, 87, 4, 0x0010, 0x10, 0, 2),
PINS_FIELD_BASE(88, 89, 4, 0x0000, 0x10, 30, 2),
PINS_FIELD_BASE(90, 93, 4, 0x0000, 0x10, 0, 2),
PINS_FIELD_BASE(94, 96, 4, 0x0000, 0x10, 2, 2),
PIN_FIELD_BASE(97, 97, 4, 0x0000, 0x10, 28, 2),
PIN_FIELD_BASE(98, 98, 4, 0x0000, 0x10, 24, 2),
PINS_FIELD_BASE(99, 101, 4, 0x0000, 0x10, 26, 2),
PINS_FIELD_BASE(102, 105, 5, 0x0000, 0x10, 2, 2),
PINS_FIELD_BASE(106, 109, 5, 0x0000, 0x10, 4, 2),
PINS_FIELD_BASE(110, 112, 5, 0x0000, 0x10, 0, 2),
PINS_FIELD_BASE(113, 114, 5, 0x0010, 0x10, 6, 2),
PINS_FIELD_BASE(115, 116, 5, 0x0010, 0x10, 4, 2),
PIN_FIELD_BASE(117, 117, 5, 0x0000, 0x10, 26, 2),
PIN_FIELD_BASE(118, 118, 5, 0x0000, 0x10, 30, 2),
PIN_FIELD_BASE(119, 119, 5, 0x0010, 0x10, 2, 2),
PIN_FIELD_BASE(120, 120, 5, 0x0000, 0x10, 24, 2),
PIN_FIELD_BASE(121, 121, 5, 0x0000, 0x10, 28, 2),
PIN_FIELD_BASE(122, 122, 5, 0x0010, 0x10, 0, 2),
PIN_FIELD_BASE(123, 124, 7, 0x0000, 0x10, 12, 5),
PIN_FIELD_BASE(125, 125, 7, 0x0000, 0x10, 24, 2),
PIN_FIELD_BASE(126, 126, 6, 0x0000, 0x10, 0, 2),
PIN_FIELD_BASE(127, 127, 7, 0x0000, 0x10, 22, 2),
PIN_FIELD_BASE(128, 128, 6, 0x0000, 0x10, 9, 5),
PIN_FIELD_BASE(129, 129, 6, 0x0000, 0x10, 4, 5),
PIN_FIELD_BASE(130, 130, 6, 0x0000, 0x10, 19, 5),
PIN_FIELD_BASE(131, 131, 6, 0x0000, 0x10, 14, 5),
PIN_FIELD_BASE(132, 132, 6, 0x0010, 0x10, 0, 5),
PIN_FIELD_BASE(133, 133, 6, 0x0000, 0x10, 24, 5),
PIN_FIELD_BASE(134, 134, 6, 0x0010, 0x10, 10, 5),
PIN_FIELD_BASE(135, 135, 6, 0x0010, 0x10, 5, 5),
PIN_FIELD_BASE(136, 136, 6, 0x0010, 0x10, 23, 2),
PIN_FIELD_BASE(137, 137, 6, 0x0010, 0x10, 17, 2),
PIN_FIELD_BASE(138, 138, 6, 0x0010, 0x10, 15, 2),
PINS_FIELD_BASE(139, 141, 6, 0x0010, 0x10, 17, 2),
PINS_FIELD_BASE(142, 143, 7, 0x0000, 0x10, 26, 2),
PIN_FIELD_BASE(144, 144, 7, 0x0010, 0x10, 10, 2),
PIN_FIELD_BASE(145, 145, 7, 0x0010, 0x10, 8, 2),
PINS_FIELD_BASE(146, 147, 7, 0x0010, 0x10, 10, 2),
PIN_FIELD_BASE(148, 149, 7, 0x0000, 0x10, 28, 2),
PIN_FIELD_BASE(150, 153, 7, 0x0010, 0x10, 0, 2),
};
static const struct mtk_pin_reg_calc mt6739_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt6739_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt6739_pin_dir_range),
[PINCTRL_PIN_REG_DI] = MTK_RANGE(mt6739_pin_di_range),
[PINCTRL_PIN_REG_DO] = MTK_RANGE(mt6739_pin_do_range),
[PINCTRL_PIN_REG_SR] = MTK_RANGE(mt6739_pin_dir_range),
[PINCTRL_PIN_REG_SMT] = MTK_RANGE(mt6739_pin_smt_range),
[PINCTRL_PIN_REG_IES] = MTK_RANGE(mt6739_pin_ies_range),
[PINCTRL_PIN_REG_PU] = MTK_RANGE(mt6739_pin_pu_range),
[PINCTRL_PIN_REG_PD] = MTK_RANGE(mt6739_pin_pd_range),
[PINCTRL_PIN_REG_DRV] = MTK_RANGE(mt6739_pin_drv_range),
[PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt6739_pin_pupd_range),
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt6739_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt6739_pin_r1_range),
};
static const struct mtk_eint_hw mt6739_eint_hw = {
.port_mask = 7,
.ports = 6,
.ap_num = 192,
.db_cnt = 13,
};
static const struct mtk_pin_soc mt6739_data = {
.reg_cal = mt6739_reg_cals,
.pins = mtk_pins_mt6739,
.npins = ARRAY_SIZE(mtk_pins_mt6739),
.ngrps = ARRAY_SIZE(mtk_pins_mt6739),
.nfuncs = 8,
.eint_hw = &mt6739_eint_hw,
.gpio_m = 0,
.race_free_access = true,
.bias_set_combo = mtk_pinconf_bias_set_combo,
.bias_get_combo = mtk_pinconf_bias_get_combo,
.drive_set = mtk_pinconf_drive_set_raw,
.drive_get = mtk_pinconf_drive_get_raw,
};
static const struct of_device_id mt6739_pinctrl_of_match[] = {
{ .compatible = "mediatek,mt6739-pinctrl", },
{ }
};
static int mt6739_pinctrl_probe(struct platform_device *pdev)
{
return mtk_paris_pinctrl_probe(pdev, &mt6739_data);
}
static struct platform_driver mt6739_pinctrl_driver = {
.driver = {
.name = "mt6739-pinctrl",
.of_match_table = mt6739_pinctrl_of_match,
.pm = &mtk_eint_pm_ops_v2,
},
.probe = mt6739_pinctrl_probe,
};
static int __init mt6739_pinctrl_init(void)
{
return platform_driver_register(&mt6739_pinctrl_driver);
}
arch_initcall(mt6739_pinctrl_init);
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+88
View File
@@ -0,0 +1,88 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2018 MediaTek Inc.
*
* Author: Light Hsieh <light.hsieh@mediatek.com>
*
*/
#include "pinctrl-mtk-mt6768.h"
#include "pinctrl-paris.h"
/* MT6768 have multiple bases to program pin configuration listed as the below:
* gpio:0x10005000, iocfg_lt:0x10002000, iocfg_lm:0x10002200,
* iocfg_lb:0x10002400, iocfg_bl:0x10002600, iocfg_rm:0x10002800,
* iocfg_rb:0x10002A00, iocfg_rt:0x10002C00, iocfg_tl:0x10002E00
* _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)
#define PINS_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, 1)
static const struct mtk_pin_reg_calc mt6768_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt6768_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt6768_pin_dir_range),
[PINCTRL_PIN_REG_DI] = MTK_RANGE(mt6768_pin_di_range),
[PINCTRL_PIN_REG_DO] = MTK_RANGE(mt6768_pin_do_range),
[PINCTRL_PIN_REG_SR] = MTK_RANGE(mt6768_pin_dir_range),
[PINCTRL_PIN_REG_SMT] = MTK_RANGE(mt6768_pin_smt_range),
[PINCTRL_PIN_REG_IES] = MTK_RANGE(mt6768_pin_ies_range),
[PINCTRL_PIN_REG_PU] = MTK_RANGE(mt6768_pin_pu_range),
[PINCTRL_PIN_REG_PD] = MTK_RANGE(mt6768_pin_pd_range),
[PINCTRL_PIN_REG_DRV] = MTK_RANGE(mt6768_pin_drv_range),
[PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt6768_pin_pupd_range),
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt6768_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt6768_pin_r1_range),
};
static const struct mtk_eint_hw mt6768_eint_hw = {
.port_mask = 7,
.ports = 6,
.ap_num = 212,
.db_cnt = 13,
};
static const struct mtk_pin_soc mt6768_data = {
.reg_cal = mt6768_reg_cals,
.pins = mtk_pins_mt6768,
.npins = ARRAY_SIZE(mtk_pins_mt6768),
.ngrps = ARRAY_SIZE(mtk_pins_mt6768),
.nfuncs = 8,
.eint_hw = &mt6768_eint_hw,
.gpio_m = 0,
.race_free_access = true,
.bias_set_combo = mtk_pinconf_bias_set_combo,
.bias_get_combo = mtk_pinconf_bias_get_combo,
.drive_set = mtk_pinconf_drive_set_raw,
.drive_get = mtk_pinconf_drive_get_raw,
};
static const struct of_device_id mt6768_pinctrl_of_match[] = {
{ .compatible = "mediatek,mt6768-pinctrl", },
{ }
};
static int mt6768_pinctrl_probe(struct platform_device *pdev)
{
return mtk_paris_pinctrl_probe(pdev, &mt6768_data);
}
static struct platform_driver mt6768_pinctrl_driver = {
.driver = {
.name = "mt6768-pinctrl",
.of_match_table = mt6768_pinctrl_of_match,
.pm = &mtk_eint_pm_ops_v2,
},
.probe = mt6768_pinctrl_probe,
};
static int __init mt6768_pinctrl_init(void)
{
return platform_driver_register(&mt6768_pinctrl_driver);
}
arch_initcall(mt6768_pinctrl_init);
+786
View File
@@ -0,0 +1,786 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2019 MediaTek Inc.
* Author: Andy Teng <andy.teng@mediatek.com>
*
*/
#include <linux/module.h>
#include "pinctrl-mtk-mt6779.h"
#include "pinctrl-paris.h"
/* MT6779 have multiple bases to program pin configuration listed as the below:
* gpio:0x10005000, iocfg_rm:0x11C20000, iocfg_br:0x11D10000,
* iocfg_lm:0x11E20000, iocfg_lb:0x11E70000, iocfg_rt:0x11EA0000,
* iocfg_lt:0x11F20000, iocfg_tl:0x11F30000
* _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)
#define PINS_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, 1)
static const struct mtk_pin_field_calc mt6779_pin_mode_range[] = {
PIN_FIELD_BASE(0, 7, 0, 0x0300, 0x10, 0, 4),
PIN_FIELD_BASE(8, 15, 0, 0x0310, 0x10, 0, 4),
PIN_FIELD_BASE(16, 23, 0, 0x0320, 0x10, 0, 4),
PIN_FIELD_BASE(24, 31, 0, 0x0330, 0x10, 0, 4),
PIN_FIELD_BASE(32, 39, 0, 0x0340, 0x10, 0, 4),
PIN_FIELD_BASE(40, 47, 0, 0x0350, 0x10, 0, 4),
PIN_FIELD_BASE(48, 55, 0, 0x0360, 0x10, 0, 4),
PIN_FIELD_BASE(56, 63, 0, 0x0370, 0x10, 0, 4),
PIN_FIELD_BASE(64, 71, 0, 0x0380, 0x10, 0, 4),
PIN_FIELD_BASE(72, 79, 0, 0x0390, 0x10, 0, 4),
PIN_FIELD_BASE(80, 87, 0, 0x03A0, 0x10, 0, 4),
PIN_FIELD_BASE(88, 95, 0, 0x03B0, 0x10, 0, 4),
PIN_FIELD_BASE(96, 103, 0, 0x03C0, 0x10, 0, 4),
PIN_FIELD_BASE(104, 111, 0, 0x03D0, 0x10, 0, 4),
PIN_FIELD_BASE(112, 119, 0, 0x03E0, 0x10, 0, 4),
PIN_FIELD_BASE(120, 127, 0, 0x03F0, 0x10, 0, 4),
PIN_FIELD_BASE(128, 135, 0, 0x0400, 0x10, 0, 4),
PIN_FIELD_BASE(136, 143, 0, 0x0410, 0x10, 0, 4),
PIN_FIELD_BASE(144, 151, 0, 0x0420, 0x10, 0, 4),
PIN_FIELD_BASE(152, 159, 0, 0x0430, 0x10, 0, 4),
PIN_FIELD_BASE(160, 167, 0, 0x0440, 0x10, 0, 4),
PIN_FIELD_BASE(168, 175, 0, 0x0450, 0x10, 0, 4),
PIN_FIELD_BASE(176, 183, 0, 0x0460, 0x10, 0, 4),
PIN_FIELD_BASE(184, 191, 0, 0x0470, 0x10, 0, 4),
PIN_FIELD_BASE(192, 199, 0, 0x0480, 0x10, 0, 4),
PIN_FIELD_BASE(200, 202, 0, 0x0490, 0x10, 0, 4),
};
static const struct mtk_pin_field_calc mt6779_pin_dir_range[] = {
PIN_FIELD_BASE(0, 31, 0, 0x0000, 0x10, 0, 1),
PIN_FIELD_BASE(32, 63, 0, 0x0010, 0x10, 0, 1),
PIN_FIELD_BASE(64, 95, 0, 0x0020, 0x10, 0, 1),
PIN_FIELD_BASE(96, 127, 0, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(128, 159, 0, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(160, 191, 0, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(192, 202, 0, 0x0060, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6779_pin_di_range[] = {
PIN_FIELD_BASE(0, 31, 0, 0x0200, 0x10, 0, 1),
PIN_FIELD_BASE(32, 63, 0, 0x0210, 0x10, 0, 1),
PIN_FIELD_BASE(64, 95, 0, 0x0220, 0x10, 0, 1),
PIN_FIELD_BASE(96, 127, 0, 0x0230, 0x10, 0, 1),
PIN_FIELD_BASE(128, 159, 0, 0x0240, 0x10, 0, 1),
PIN_FIELD_BASE(160, 191, 0, 0x0250, 0x10, 0, 1),
PIN_FIELD_BASE(192, 202, 0, 0x0260, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6779_pin_do_range[] = {
PIN_FIELD_BASE(0, 31, 0, 0x0100, 0x10, 0, 1),
PIN_FIELD_BASE(32, 63, 0, 0x0110, 0x10, 0, 1),
PIN_FIELD_BASE(64, 95, 0, 0x0120, 0x10, 0, 1),
PIN_FIELD_BASE(96, 127, 0, 0x0130, 0x10, 0, 1),
PIN_FIELD_BASE(128, 159, 0, 0x0140, 0x10, 0, 1),
PIN_FIELD_BASE(160, 191, 0, 0x0150, 0x10, 0, 1),
PIN_FIELD_BASE(192, 202, 0, 0x0160, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6779_pin_ies_range[] = {
PIN_FIELD_BASE(0, 9, 6, 0x0030, 0x10, 3, 1),
PIN_FIELD_BASE(10, 16, 3, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(17, 18, 6, 0x0030, 0x10, 28, 1),
PIN_FIELD_BASE(19, 19, 6, 0x0030, 0x10, 27, 1),
PIN_FIELD_BASE(20, 20, 6, 0x0030, 0x10, 26, 1),
PIN_FIELD_BASE(21, 24, 6, 0x0030, 0x10, 19, 1),
PIN_FIELD_BASE(25, 25, 6, 0x0030, 0x10, 30, 1),
PIN_FIELD_BASE(26, 26, 6, 0x0030, 0x10, 23, 1),
PIN_FIELD_BASE(27, 27, 6, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(28, 29, 6, 0x0030, 0x10, 24, 1),
PIN_FIELD_BASE(30, 30, 6, 0x0030, 0x10, 16, 1),
PIN_FIELD_BASE(31, 31, 6, 0x0030, 0x10, 13, 1),
PIN_FIELD_BASE(32, 32, 6, 0x0030, 0x10, 15, 1),
PIN_FIELD_BASE(33, 33, 6, 0x0030, 0x10, 17, 1),
PIN_FIELD_BASE(34, 34, 6, 0x0030, 0x10, 14, 1),
PIN_FIELD_BASE(35, 35, 6, 0x0040, 0x10, 4, 1),
PIN_FIELD_BASE(36, 36, 6, 0x0030, 0x10, 31, 1),
PIN_FIELD_BASE(37, 37, 6, 0x0040, 0x10, 5, 1),
PIN_FIELD_BASE(38, 41, 6, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(42, 43, 6, 0x0030, 0x10, 1, 1),
PIN_FIELD_BASE(44, 44, 6, 0x0030, 0x10, 18, 1),
PIN_FIELD_BASE(45, 45, 3, 0x0050, 0x10, 14, 1),
PIN_FIELD_BASE(46, 46, 3, 0x0050, 0x10, 22, 1),
PIN_FIELD_BASE(47, 47, 3, 0x0050, 0x10, 25, 1),
PIN_FIELD_BASE(48, 48, 3, 0x0050, 0x10, 24, 1),
PIN_FIELD_BASE(49, 49, 3, 0x0050, 0x10, 26, 1),
PIN_FIELD_BASE(50, 50, 3, 0x0050, 0x10, 23, 1),
PIN_FIELD_BASE(51, 51, 3, 0x0050, 0x10, 11, 1),
PIN_FIELD_BASE(52, 52, 3, 0x0050, 0x10, 19, 1),
PIN_FIELD_BASE(53, 54, 3, 0x0050, 0x10, 27, 1),
PIN_FIELD_BASE(55, 55, 3, 0x0050, 0x10, 13, 1),
PIN_FIELD_BASE(56, 56, 3, 0x0050, 0x10, 21, 1),
PIN_FIELD_BASE(57, 57, 3, 0x0050, 0x10, 10, 1),
PIN_FIELD_BASE(58, 58, 3, 0x0050, 0x10, 9, 1),
PIN_FIELD_BASE(59, 60, 3, 0x0050, 0x10, 7, 1),
PIN_FIELD_BASE(61, 61, 3, 0x0050, 0x10, 12, 1),
PIN_FIELD_BASE(62, 62, 3, 0x0050, 0x10, 20, 1),
PIN_FIELD_BASE(63, 63, 3, 0x0050, 0x10, 17, 1),
PIN_FIELD_BASE(64, 64, 3, 0x0050, 0x10, 16, 1),
PIN_FIELD_BASE(65, 65, 3, 0x0050, 0x10, 18, 1),
PIN_FIELD_BASE(66, 66, 3, 0x0050, 0x10, 15, 1),
PIN_FIELD_BASE(67, 67, 2, 0x0060, 0x10, 7, 1),
PIN_FIELD_BASE(68, 68, 2, 0x0060, 0x10, 6, 1),
PIN_FIELD_BASE(69, 69, 2, 0x0060, 0x10, 8, 1),
PIN_FIELD_BASE(70, 71, 2, 0x0060, 0x10, 4, 1),
PIN_FIELD_BASE(72, 72, 4, 0x0020, 0x10, 3, 1),
PIN_FIELD_BASE(73, 73, 4, 0x0020, 0x10, 2, 1),
PIN_FIELD_BASE(74, 74, 4, 0x0020, 0x10, 1, 1),
PIN_FIELD_BASE(75, 75, 4, 0x0020, 0x10, 4, 1),
PIN_FIELD_BASE(76, 76, 4, 0x0020, 0x10, 12, 1),
PIN_FIELD_BASE(77, 77, 4, 0x0020, 0x10, 11, 1),
PIN_FIELD_BASE(78, 78, 2, 0x0050, 0x10, 18, 1),
PIN_FIELD_BASE(79, 79, 2, 0x0050, 0x10, 17, 1),
PIN_FIELD_BASE(80, 81, 2, 0x0050, 0x10, 19, 1),
PIN_FIELD_BASE(82, 88, 2, 0x0050, 0x10, 1, 1),
PIN_FIELD_BASE(89, 89, 2, 0x0050, 0x10, 16, 1),
PIN_FIELD_BASE(90, 90, 2, 0x0050, 0x10, 15, 1),
PIN_FIELD_BASE(91, 91, 2, 0x0050, 0x10, 14, 1),
PIN_FIELD_BASE(92, 92, 2, 0x0050, 0x10, 8, 1),
PIN_FIELD_BASE(93, 93, 4, 0x0020, 0x10, 0, 1),
PIN_FIELD_BASE(94, 94, 2, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(95, 95, 4, 0x0020, 0x10, 7, 1),
PIN_FIELD_BASE(96, 96, 4, 0x0020, 0x10, 5, 1),
PIN_FIELD_BASE(97, 97, 4, 0x0020, 0x10, 8, 1),
PIN_FIELD_BASE(98, 98, 4, 0x0020, 0x10, 6, 1),
PIN_FIELD_BASE(99, 99, 2, 0x0060, 0x10, 9, 1),
PIN_FIELD_BASE(100, 100, 2, 0x0060, 0x10, 12, 1),
PIN_FIELD_BASE(101, 101, 2, 0x0060, 0x10, 10, 1),
PIN_FIELD_BASE(102, 102, 2, 0x0060, 0x10, 13, 1),
PIN_FIELD_BASE(103, 103, 2, 0x0060, 0x10, 11, 1),
PIN_FIELD_BASE(104, 104, 2, 0x0060, 0x10, 14, 1),
PIN_FIELD_BASE(105, 105, 2, 0x0050, 0x10, 10, 1),
PIN_FIELD_BASE(106, 106, 2, 0x0050, 0x10, 9, 1),
PIN_FIELD_BASE(107, 108, 2, 0x0050, 0x10, 12, 1),
PIN_FIELD_BASE(109, 109, 2, 0x0050, 0x10, 11, 1),
PIN_FIELD_BASE(110, 110, 2, 0x0060, 0x10, 16, 1),
PIN_FIELD_BASE(111, 111, 2, 0x0060, 0x10, 18, 1),
PIN_FIELD_BASE(112, 112, 2, 0x0060, 0x10, 15, 1),
PIN_FIELD_BASE(113, 113, 2, 0x0060, 0x10, 17, 1),
PIN_FIELD_BASE(114, 115, 2, 0x0050, 0x10, 26, 1),
PIN_FIELD_BASE(116, 117, 2, 0x0050, 0x10, 21, 1),
PIN_FIELD_BASE(118, 118, 2, 0x0050, 0x10, 31, 1),
PIN_FIELD_BASE(119, 119, 2, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(120, 121, 2, 0x0050, 0x10, 23, 1),
PIN_FIELD_BASE(122, 123, 2, 0x0050, 0x10, 28, 1),
PIN_FIELD_BASE(124, 125, 2, 0x0060, 0x10, 1, 1),
PIN_FIELD_BASE(126, 127, 1, 0x0030, 0x10, 8, 1),
PIN_FIELD_BASE(128, 129, 1, 0x0030, 0x10, 17, 1),
PIN_FIELD_BASE(130, 130, 1, 0x0030, 0x10, 16, 1),
PIN_FIELD_BASE(131, 131, 1, 0x0030, 0x10, 19, 1),
PIN_FIELD_BASE(132, 132, 1, 0x0030, 0x10, 21, 1),
PIN_FIELD_BASE(133, 133, 1, 0x0030, 0x10, 20, 1),
PIN_FIELD_BASE(134, 135, 1, 0x0030, 0x10, 2, 1),
PIN_FIELD_BASE(136, 136, 1, 0x0030, 0x10, 7, 1),
PIN_FIELD_BASE(137, 137, 1, 0x0030, 0x10, 4, 1),
PIN_FIELD_BASE(138, 138, 1, 0x0030, 0x10, 6, 1),
PIN_FIELD_BASE(139, 139, 1, 0x0030, 0x10, 5, 1),
PIN_FIELD_BASE(140, 141, 1, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(142, 142, 1, 0x0030, 0x10, 15, 1),
PIN_FIELD_BASE(143, 143, 5, 0x0020, 0x10, 15, 1),
PIN_FIELD_BASE(144, 144, 5, 0x0020, 0x10, 17, 1),
PIN_FIELD_BASE(145, 145, 5, 0x0020, 0x10, 16, 1),
PIN_FIELD_BASE(146, 146, 5, 0x0020, 0x10, 12, 1),
PIN_FIELD_BASE(147, 155, 5, 0x0020, 0x10, 0, 1),
PIN_FIELD_BASE(156, 157, 5, 0x0020, 0x10, 22, 1),
PIN_FIELD_BASE(158, 158, 5, 0x0020, 0x10, 21, 1),
PIN_FIELD_BASE(159, 159, 5, 0x0020, 0x10, 24, 1),
PIN_FIELD_BASE(160, 161, 5, 0x0020, 0x10, 19, 1),
PIN_FIELD_BASE(162, 166, 5, 0x0020, 0x10, 25, 1),
PIN_FIELD_BASE(167, 168, 7, 0x0010, 0x10, 1, 1),
PIN_FIELD_BASE(169, 169, 7, 0x0010, 0x10, 4, 1),
PIN_FIELD_BASE(170, 170, 7, 0x0010, 0x10, 6, 1),
PIN_FIELD_BASE(171, 171, 7, 0x0010, 0x10, 8, 1),
PIN_FIELD_BASE(172, 172, 7, 0x0010, 0x10, 3, 1),
PIN_FIELD_BASE(173, 173, 7, 0x0010, 0x10, 7, 1),
PIN_FIELD_BASE(174, 175, 7, 0x0010, 0x10, 9, 1),
PIN_FIELD_BASE(176, 176, 7, 0x0010, 0x10, 0, 1),
PIN_FIELD_BASE(177, 177, 7, 0x0010, 0x10, 5, 1),
PIN_FIELD_BASE(178, 178, 7, 0x0010, 0x10, 11, 1),
PIN_FIELD_BASE(179, 179, 4, 0x0020, 0x10, 13, 1),
PIN_FIELD_BASE(180, 180, 4, 0x0020, 0x10, 10, 1),
PIN_FIELD_BASE(181, 183, 1, 0x0030, 0x10, 22, 1),
PIN_FIELD_BASE(184, 184, 1, 0x0030, 0x10, 12, 1),
PIN_FIELD_BASE(185, 185, 1, 0x0030, 0x10, 11, 1),
PIN_FIELD_BASE(186, 186, 1, 0x0030, 0x10, 13, 1),
PIN_FIELD_BASE(187, 187, 1, 0x0030, 0x10, 10, 1),
PIN_FIELD_BASE(188, 188, 1, 0x0030, 0x10, 14, 1),
PIN_FIELD_BASE(189, 189, 5, 0x0020, 0x10, 9, 1),
PIN_FIELD_BASE(190, 190, 5, 0x0020, 0x10, 18, 1),
PIN_FIELD_BASE(191, 192, 5, 0x0020, 0x10, 13, 1),
PIN_FIELD_BASE(193, 194, 5, 0x0020, 0x10, 10, 1),
PIN_FIELD_BASE(195, 195, 2, 0x0050, 0x10, 30, 1),
PIN_FIELD_BASE(196, 196, 2, 0x0050, 0x10, 25, 1),
PIN_FIELD_BASE(197, 197, 2, 0x0060, 0x10, 3, 1),
PIN_FIELD_BASE(198, 199, 4, 0x0020, 0x10, 14, 1),
PIN_FIELD_BASE(200, 201, 6, 0x0040, 0x10, 6, 1),
PIN_FIELD_BASE(202, 202, 4, 0x0020, 0x10, 9, 1),
};
static const struct mtk_pin_field_calc mt6779_pin_smt_range[] = {
PINS_FIELD_BASE(0, 9, 6, 0x00c0, 0x10, 3, 1),
PIN_FIELD_BASE(10, 11, 3, 0x00e0, 0x10, 0, 1),
PINS_FIELD_BASE(12, 15, 3, 0x00e0, 0x10, 2, 1),
PIN_FIELD_BASE(16, 16, 3, 0x00e0, 0x10, 3, 1),
PINS_FIELD_BASE(17, 20, 6, 0x00c0, 0x10, 11, 1),
PINS_FIELD_BASE(21, 24, 6, 0x00c0, 0x10, 7, 1),
PIN_FIELD_BASE(25, 25, 6, 0x00c0, 0x10, 12, 1),
PIN_FIELD_BASE(26, 26, 6, 0x00c0, 0x10, 8, 1),
PIN_FIELD_BASE(27, 27, 6, 0x00c0, 0x10, 0, 1),
PIN_FIELD_BASE(28, 29, 6, 0x00c0, 0x10, 9, 1),
PINS_FIELD_BASE(30, 32, 6, 0x00c0, 0x10, 4, 1),
PIN_FIELD_BASE(33, 33, 6, 0x00c0, 0x10, 5, 1),
PIN_FIELD_BASE(34, 34, 6, 0x00c0, 0x10, 4, 1),
PINS_FIELD_BASE(35, 41, 6, 0x00c0, 0x10, 13, 1),
PIN_FIELD_BASE(42, 43, 6, 0x00c0, 0x10, 1, 1),
PIN_FIELD_BASE(44, 44, 6, 0x00c0, 0x10, 6, 1),
PIN_FIELD_BASE(45, 45, 3, 0x00e0, 0x10, 8, 1),
PIN_FIELD_BASE(46, 46, 3, 0x00e0, 0x10, 13, 1),
PINS_FIELD_BASE(47, 50, 3, 0x00e0, 0x10, 14, 1),
PIN_FIELD_BASE(51, 51, 3, 0x00e0, 0x10, 5, 1),
PIN_FIELD_BASE(52, 52, 3, 0x00e0, 0x10, 10, 1),
PIN_FIELD_BASE(53, 54, 3, 0x00e0, 0x10, 15, 1),
PIN_FIELD_BASE(55, 55, 3, 0x00e0, 0x10, 7, 1),
PIN_FIELD_BASE(56, 56, 3, 0x00e0, 0x10, 12, 1),
PINS_FIELD_BASE(57, 60, 3, 0x00e0, 0x10, 4, 1),
PIN_FIELD_BASE(61, 61, 3, 0x00e0, 0x10, 6, 1),
PIN_FIELD_BASE(62, 62, 3, 0x00e0, 0x10, 11, 1),
PINS_FIELD_BASE(63, 66, 3, 0x00e0, 0x10, 9, 1),
PINS_FIELD_BASE(67, 69, 2, 0x00e0, 0x10, 11, 1),
PIN_FIELD_BASE(70, 71, 2, 0x00e0, 0x10, 10, 1),
PINS_FIELD_BASE(72, 75, 4, 0x0070, 0x10, 1, 1),
PINS_FIELD_BASE(76, 77, 4, 0x0070, 0x10, 4, 1),
PINS_FIELD_BASE(78, 86, 2, 0x00e0, 0x10, 1, 1),
PINS_FIELD_BASE(87, 92, 2, 0x00e0, 0x10, 2, 1),
PIN_FIELD_BASE(93, 93, 4, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(94, 94, 2, 0x00e0, 0x10, 2, 1),
PINS_FIELD_BASE(95, 98, 4, 0x0070, 0x10, 2, 1),
PINS_FIELD_BASE(99, 104, 2, 0x00e0, 0x10, 12, 1),
PINS_FIELD_BASE(105, 109, 2, 0x00e0, 0x10, 0, 1),
PIN_FIELD_BASE(110, 110, 2, 0x00e0, 0x10, 14, 1),
PIN_FIELD_BASE(111, 111, 2, 0x00e0, 0x10, 16, 1),
PIN_FIELD_BASE(112, 112, 2, 0x00e0, 0x10, 13, 1),
PIN_FIELD_BASE(113, 113, 2, 0x00e0, 0x10, 15, 1),
PINS_FIELD_BASE(114, 115, 2, 0x00e0, 0x10, 4, 1),
PIN_FIELD_BASE(116, 117, 2, 0x00e0, 0x10, 5, 1),
PINS_FIELD_BASE(118, 119, 2, 0x00e0, 0x10, 4, 1),
PIN_FIELD_BASE(120, 121, 2, 0x00e0, 0x10, 7, 1),
PINS_FIELD_BASE(122, 125, 2, 0x00e0, 0x10, 3, 1),
PINS_FIELD_BASE(126, 127, 1, 0x00c0, 0x10, 5, 1),
PINS_FIELD_BASE(128, 130, 1, 0x00c0, 0x10, 9, 1),
PINS_FIELD_BASE(131, 133, 1, 0x00c0, 0x10, 10, 1),
PIN_FIELD_BASE(134, 135, 1, 0x00c0, 0x10, 2, 1),
PINS_FIELD_BASE(136, 139, 1, 0x00c0, 0x10, 4, 1),
PIN_FIELD_BASE(140, 141, 1, 0x00c0, 0x10, 0, 1),
PIN_FIELD_BASE(142, 142, 1, 0x00c0, 0x10, 8, 1),
PINS_FIELD_BASE(143, 146, 5, 0x0060, 0x10, 1, 1),
PINS_FIELD_BASE(147, 155, 5, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(156, 157, 5, 0x0060, 0x10, 6, 1),
PIN_FIELD_BASE(158, 158, 5, 0x0060, 0x10, 5, 1),
PIN_FIELD_BASE(159, 159, 5, 0x0060, 0x10, 8, 1),
PIN_FIELD_BASE(160, 161, 5, 0x0060, 0x10, 3, 1),
PINS_FIELD_BASE(162, 166, 5, 0x0060, 0x10, 2, 1),
PIN_FIELD_BASE(167, 167, 7, 0x0060, 0x10, 1, 1),
PINS_FIELD_BASE(168, 174, 7, 0x0060, 0x10, 2, 1),
PIN_FIELD_BASE(175, 175, 7, 0x0060, 0x10, 3, 1),
PIN_FIELD_BASE(176, 176, 7, 0x0060, 0x10, 0, 1),
PINS_FIELD_BASE(177, 178, 7, 0x0060, 0x10, 2, 1),
PINS_FIELD_BASE(179, 180, 4, 0x0070, 0x10, 4, 1),
PIN_FIELD_BASE(181, 183, 1, 0x00c0, 0x10, 11, 1),
PINS_FIELD_BASE(184, 187, 1, 0x00c0, 0x10, 6, 1),
PIN_FIELD_BASE(188, 188, 1, 0x00c0, 0x10, 7, 1),
PINS_FIELD_BASE(189, 194, 5, 0x0060, 0x10, 1, 1),
PIN_FIELD_BASE(195, 195, 2, 0x00e0, 0x10, 3, 1),
PIN_FIELD_BASE(196, 196, 2, 0x00e0, 0x10, 9, 1),
PIN_FIELD_BASE(197, 197, 2, 0x00e0, 0x10, 3, 1),
PIN_FIELD_BASE(198, 199, 4, 0x0070, 0x10, 5, 1),
PIN_FIELD_BASE(200, 201, 6, 0x00c0, 0x10, 14, 1),
PIN_FIELD_BASE(202, 202, 4, 0x0070, 0x10, 3, 1),
};
static const struct mtk_pin_field_calc mt6779_pin_pu_range[] = {
PIN_FIELD_BASE(0, 9, 6, 0x0070, 0x10, 3, 1),
PIN_FIELD_BASE(16, 16, 3, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(17, 18, 6, 0x0070, 0x10, 28, 1),
PIN_FIELD_BASE(19, 19, 6, 0x0070, 0x10, 27, 1),
PIN_FIELD_BASE(20, 20, 6, 0x0070, 0x10, 26, 1),
PIN_FIELD_BASE(21, 24, 6, 0x0070, 0x10, 19, 1),
PIN_FIELD_BASE(25, 25, 6, 0x0070, 0x10, 30, 1),
PIN_FIELD_BASE(26, 26, 6, 0x0070, 0x10, 23, 1),
PIN_FIELD_BASE(27, 27, 6, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(28, 29, 6, 0x0070, 0x10, 24, 1),
PIN_FIELD_BASE(30, 30, 6, 0x0070, 0x10, 16, 1),
PIN_FIELD_BASE(31, 31, 6, 0x0070, 0x10, 13, 1),
PIN_FIELD_BASE(32, 32, 6, 0x0070, 0x10, 15, 1),
PIN_FIELD_BASE(33, 33, 6, 0x0070, 0x10, 17, 1),
PIN_FIELD_BASE(34, 34, 6, 0x0070, 0x10, 14, 1),
PIN_FIELD_BASE(35, 35, 6, 0x0080, 0x10, 5, 1),
PIN_FIELD_BASE(36, 36, 6, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(37, 37, 6, 0x0080, 0x10, 6, 1),
PIN_FIELD_BASE(38, 41, 6, 0x0080, 0x10, 1, 1),
PIN_FIELD_BASE(42, 43, 6, 0x0070, 0x10, 1, 1),
PIN_FIELD_BASE(44, 44, 6, 0x0070, 0x10, 18, 1),
PIN_FIELD_BASE(45, 45, 3, 0x0080, 0x10, 4, 1),
PIN_FIELD_BASE(46, 46, 3, 0x0080, 0x10, 12, 1),
PIN_FIELD_BASE(47, 47, 3, 0x0080, 0x10, 15, 1),
PIN_FIELD_BASE(48, 48, 3, 0x0080, 0x10, 14, 1),
PIN_FIELD_BASE(49, 49, 3, 0x0080, 0x10, 16, 1),
PIN_FIELD_BASE(50, 50, 3, 0x0080, 0x10, 13, 1),
PIN_FIELD_BASE(51, 51, 3, 0x0080, 0x10, 1, 1),
PIN_FIELD_BASE(52, 52, 3, 0x0080, 0x10, 9, 1),
PIN_FIELD_BASE(53, 54, 3, 0x0080, 0x10, 18, 1),
PIN_FIELD_BASE(55, 55, 3, 0x0080, 0x10, 3, 1),
PIN_FIELD_BASE(56, 56, 3, 0x0080, 0x10, 11, 1),
PIN_FIELD_BASE(61, 61, 3, 0x0080, 0x10, 2, 1),
PIN_FIELD_BASE(62, 62, 3, 0x0080, 0x10, 10, 1),
PIN_FIELD_BASE(63, 63, 3, 0x0080, 0x10, 7, 1),
PIN_FIELD_BASE(64, 64, 3, 0x0080, 0x10, 6, 1),
PIN_FIELD_BASE(65, 65, 3, 0x0080, 0x10, 8, 1),
PIN_FIELD_BASE(66, 66, 3, 0x0080, 0x10, 5, 1),
PIN_FIELD_BASE(67, 67, 2, 0x00a0, 0x10, 7, 1),
PIN_FIELD_BASE(68, 68, 2, 0x00a0, 0x10, 6, 1),
PIN_FIELD_BASE(69, 69, 2, 0x00a0, 0x10, 8, 1),
PIN_FIELD_BASE(70, 71, 2, 0x00a0, 0x10, 4, 1),
PIN_FIELD_BASE(72, 72, 4, 0x0040, 0x10, 3, 1),
PIN_FIELD_BASE(73, 73, 4, 0x0040, 0x10, 2, 1),
PIN_FIELD_BASE(74, 74, 4, 0x0040, 0x10, 1, 1),
PIN_FIELD_BASE(75, 75, 4, 0x0040, 0x10, 4, 1),
PIN_FIELD_BASE(76, 76, 4, 0x0040, 0x10, 12, 1),
PIN_FIELD_BASE(77, 77, 4, 0x0040, 0x10, 11, 1),
PIN_FIELD_BASE(78, 78, 2, 0x0090, 0x10, 18, 1),
PIN_FIELD_BASE(79, 79, 2, 0x0090, 0x10, 17, 1),
PIN_FIELD_BASE(80, 81, 2, 0x0090, 0x10, 19, 1),
PIN_FIELD_BASE(82, 88, 2, 0x0090, 0x10, 1, 1),
PIN_FIELD_BASE(89, 89, 2, 0x0090, 0x10, 16, 1),
PIN_FIELD_BASE(90, 90, 2, 0x0090, 0x10, 15, 1),
PIN_FIELD_BASE(91, 91, 2, 0x0090, 0x10, 14, 1),
PIN_FIELD_BASE(92, 92, 2, 0x0090, 0x10, 8, 1),
PIN_FIELD_BASE(93, 93, 4, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(94, 94, 2, 0x0090, 0x10, 0, 1),
PIN_FIELD_BASE(95, 95, 4, 0x0040, 0x10, 7, 1),
PIN_FIELD_BASE(96, 96, 4, 0x0040, 0x10, 5, 1),
PIN_FIELD_BASE(97, 97, 4, 0x0040, 0x10, 8, 1),
PIN_FIELD_BASE(98, 98, 4, 0x0040, 0x10, 6, 1),
PIN_FIELD_BASE(99, 99, 2, 0x00a0, 0x10, 9, 1),
PIN_FIELD_BASE(100, 100, 2, 0x00a0, 0x10, 12, 1),
PIN_FIELD_BASE(101, 101, 2, 0x00a0, 0x10, 10, 1),
PIN_FIELD_BASE(102, 102, 2, 0x00a0, 0x10, 13, 1),
PIN_FIELD_BASE(103, 103, 2, 0x00a0, 0x10, 11, 1),
PIN_FIELD_BASE(104, 104, 2, 0x00a0, 0x10, 14, 1),
PIN_FIELD_BASE(105, 105, 2, 0x0090, 0x10, 10, 1),
PIN_FIELD_BASE(106, 106, 2, 0x0090, 0x10, 9, 1),
PIN_FIELD_BASE(107, 108, 2, 0x0090, 0x10, 12, 1),
PIN_FIELD_BASE(109, 109, 2, 0x0090, 0x10, 11, 1),
PIN_FIELD_BASE(110, 110, 2, 0x00a0, 0x10, 16, 1),
PIN_FIELD_BASE(111, 111, 2, 0x00a0, 0x10, 18, 1),
PIN_FIELD_BASE(112, 112, 2, 0x00a0, 0x10, 15, 1),
PIN_FIELD_BASE(113, 113, 2, 0x00a0, 0x10, 17, 1),
PIN_FIELD_BASE(114, 115, 2, 0x0090, 0x10, 26, 1),
PIN_FIELD_BASE(116, 117, 2, 0x0090, 0x10, 21, 1),
PIN_FIELD_BASE(118, 118, 2, 0x0090, 0x10, 31, 1),
PIN_FIELD_BASE(119, 119, 2, 0x00a0, 0x10, 0, 1),
PIN_FIELD_BASE(120, 121, 2, 0x0090, 0x10, 23, 1),
PIN_FIELD_BASE(122, 123, 2, 0x0090, 0x10, 28, 1),
PIN_FIELD_BASE(124, 125, 2, 0x00a0, 0x10, 1, 1),
PIN_FIELD_BASE(126, 127, 1, 0x0070, 0x10, 2, 1),
PIN_FIELD_BASE(140, 141, 1, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(142, 142, 1, 0x0070, 0x10, 9, 1),
PIN_FIELD_BASE(143, 143, 5, 0x0040, 0x10, 15, 1),
PIN_FIELD_BASE(144, 144, 5, 0x0040, 0x10, 17, 1),
PIN_FIELD_BASE(145, 145, 5, 0x0040, 0x10, 16, 1),
PIN_FIELD_BASE(146, 146, 5, 0x0040, 0x10, 12, 1),
PIN_FIELD_BASE(147, 155, 5, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(156, 157, 5, 0x0040, 0x10, 22, 1),
PIN_FIELD_BASE(158, 158, 5, 0x0040, 0x10, 21, 1),
PIN_FIELD_BASE(159, 159, 5, 0x0040, 0x10, 24, 1),
PIN_FIELD_BASE(160, 161, 5, 0x0040, 0x10, 19, 1),
PIN_FIELD_BASE(162, 166, 5, 0x0040, 0x10, 25, 1),
PIN_FIELD_BASE(179, 179, 4, 0x0040, 0x10, 13, 1),
PIN_FIELD_BASE(180, 180, 4, 0x0040, 0x10, 10, 1),
PIN_FIELD_BASE(181, 183, 1, 0x0070, 0x10, 10, 1),
PIN_FIELD_BASE(184, 184, 1, 0x0070, 0x10, 6, 1),
PIN_FIELD_BASE(185, 185, 1, 0x0070, 0x10, 5, 1),
PIN_FIELD_BASE(186, 186, 1, 0x0070, 0x10, 7, 1),
PIN_FIELD_BASE(187, 187, 1, 0x0070, 0x10, 4, 1),
PIN_FIELD_BASE(188, 188, 1, 0x0070, 0x10, 8, 1),
PIN_FIELD_BASE(189, 189, 5, 0x0040, 0x10, 9, 1),
PIN_FIELD_BASE(190, 190, 5, 0x0040, 0x10, 18, 1),
PIN_FIELD_BASE(191, 192, 5, 0x0040, 0x10, 13, 1),
PIN_FIELD_BASE(193, 194, 5, 0x0040, 0x10, 10, 1),
PIN_FIELD_BASE(195, 195, 2, 0x0090, 0x10, 30, 1),
PIN_FIELD_BASE(196, 196, 2, 0x0090, 0x10, 25, 1),
PIN_FIELD_BASE(197, 197, 2, 0x00a0, 0x10, 3, 1),
PIN_FIELD_BASE(198, 199, 4, 0x0040, 0x10, 14, 1),
PIN_FIELD_BASE(200, 201, 6, 0x0080, 0x10, 7, 1),
PIN_FIELD_BASE(202, 202, 4, 0x0040, 0x10, 9, 1),
};
static const struct mtk_pin_field_calc mt6779_pin_pd_range[] = {
PIN_FIELD_BASE(0, 9, 6, 0x0050, 0x10, 3, 1),
PIN_FIELD_BASE(16, 16, 3, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(17, 18, 6, 0x0050, 0x10, 28, 1),
PIN_FIELD_BASE(19, 19, 6, 0x0050, 0x10, 27, 1),
PIN_FIELD_BASE(20, 20, 6, 0x0050, 0x10, 26, 1),
PIN_FIELD_BASE(21, 24, 6, 0x0050, 0x10, 19, 1),
PIN_FIELD_BASE(25, 25, 6, 0x0050, 0x10, 30, 1),
PIN_FIELD_BASE(26, 26, 6, 0x0050, 0x10, 23, 1),
PIN_FIELD_BASE(27, 27, 6, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(28, 29, 6, 0x0050, 0x10, 24, 1),
PIN_FIELD_BASE(30, 30, 6, 0x0050, 0x10, 16, 1),
PIN_FIELD_BASE(31, 31, 6, 0x0050, 0x10, 13, 1),
PIN_FIELD_BASE(32, 32, 6, 0x0050, 0x10, 15, 1),
PIN_FIELD_BASE(33, 33, 6, 0x0050, 0x10, 17, 1),
PIN_FIELD_BASE(34, 34, 6, 0x0050, 0x10, 14, 1),
PIN_FIELD_BASE(35, 35, 6, 0x0060, 0x10, 5, 1),
PIN_FIELD_BASE(36, 36, 6, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(37, 37, 6, 0x0060, 0x10, 6, 1),
PIN_FIELD_BASE(38, 41, 6, 0x0060, 0x10, 1, 1),
PIN_FIELD_BASE(42, 43, 6, 0x0050, 0x10, 1, 1),
PIN_FIELD_BASE(44, 44, 6, 0x0050, 0x10, 18, 1),
PIN_FIELD_BASE(45, 45, 3, 0x0060, 0x10, 4, 1),
PIN_FIELD_BASE(46, 46, 3, 0x0060, 0x10, 12, 1),
PIN_FIELD_BASE(47, 47, 3, 0x0060, 0x10, 15, 1),
PIN_FIELD_BASE(48, 48, 3, 0x0060, 0x10, 14, 1),
PIN_FIELD_BASE(49, 49, 3, 0x0060, 0x10, 16, 1),
PIN_FIELD_BASE(50, 50, 3, 0x0060, 0x10, 13, 1),
PIN_FIELD_BASE(51, 51, 3, 0x0060, 0x10, 1, 1),
PIN_FIELD_BASE(52, 52, 3, 0x0060, 0x10, 9, 1),
PIN_FIELD_BASE(53, 54, 3, 0x0060, 0x10, 18, 1),
PIN_FIELD_BASE(55, 55, 3, 0x0060, 0x10, 3, 1),
PIN_FIELD_BASE(56, 56, 3, 0x0060, 0x10, 11, 1),
PIN_FIELD_BASE(61, 61, 3, 0x0060, 0x10, 2, 1),
PIN_FIELD_BASE(62, 62, 3, 0x0060, 0x10, 10, 1),
PIN_FIELD_BASE(63, 63, 3, 0x0060, 0x10, 7, 1),
PIN_FIELD_BASE(64, 64, 3, 0x0060, 0x10, 6, 1),
PIN_FIELD_BASE(65, 65, 3, 0x0060, 0x10, 8, 1),
PIN_FIELD_BASE(66, 66, 3, 0x0060, 0x10, 5, 1),
PIN_FIELD_BASE(67, 67, 2, 0x0080, 0x10, 7, 1),
PIN_FIELD_BASE(68, 68, 2, 0x0080, 0x10, 6, 1),
PIN_FIELD_BASE(69, 69, 2, 0x0080, 0x10, 8, 1),
PIN_FIELD_BASE(70, 71, 2, 0x0080, 0x10, 4, 1),
PIN_FIELD_BASE(72, 72, 4, 0x0030, 0x10, 3, 1),
PIN_FIELD_BASE(73, 73, 4, 0x0030, 0x10, 2, 1),
PIN_FIELD_BASE(74, 74, 4, 0x0030, 0x10, 1, 1),
PIN_FIELD_BASE(75, 75, 4, 0x0030, 0x10, 4, 1),
PIN_FIELD_BASE(76, 76, 4, 0x0030, 0x10, 12, 1),
PIN_FIELD_BASE(77, 77, 4, 0x0030, 0x10, 11, 1),
PIN_FIELD_BASE(78, 78, 2, 0x0070, 0x10, 18, 1),
PIN_FIELD_BASE(79, 79, 2, 0x0070, 0x10, 17, 1),
PIN_FIELD_BASE(80, 81, 2, 0x0070, 0x10, 19, 1),
PIN_FIELD_BASE(82, 88, 2, 0x0070, 0x10, 1, 1),
PIN_FIELD_BASE(89, 89, 2, 0x0070, 0x10, 16, 1),
PIN_FIELD_BASE(90, 90, 2, 0x0070, 0x10, 15, 1),
PIN_FIELD_BASE(91, 91, 2, 0x0070, 0x10, 14, 1),
PIN_FIELD_BASE(92, 92, 2, 0x0070, 0x10, 8, 1),
PIN_FIELD_BASE(93, 93, 4, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(94, 94, 2, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(95, 95, 4, 0x0030, 0x10, 7, 1),
PIN_FIELD_BASE(96, 96, 4, 0x0030, 0x10, 5, 1),
PIN_FIELD_BASE(97, 97, 4, 0x0030, 0x10, 8, 1),
PIN_FIELD_BASE(98, 98, 4, 0x0030, 0x10, 6, 1),
PIN_FIELD_BASE(99, 99, 2, 0x0080, 0x10, 9, 1),
PIN_FIELD_BASE(100, 100, 2, 0x0080, 0x10, 12, 1),
PIN_FIELD_BASE(101, 101, 2, 0x0080, 0x10, 10, 1),
PIN_FIELD_BASE(102, 102, 2, 0x0080, 0x10, 13, 1),
PIN_FIELD_BASE(103, 103, 2, 0x0080, 0x10, 11, 1),
PIN_FIELD_BASE(104, 104, 2, 0x0080, 0x10, 14, 1),
PIN_FIELD_BASE(105, 105, 2, 0x0070, 0x10, 10, 1),
PIN_FIELD_BASE(106, 106, 2, 0x0070, 0x10, 9, 1),
PIN_FIELD_BASE(107, 108, 2, 0x0070, 0x10, 12, 1),
PIN_FIELD_BASE(109, 109, 2, 0x0070, 0x10, 11, 1),
PIN_FIELD_BASE(110, 110, 2, 0x0080, 0x10, 16, 1),
PIN_FIELD_BASE(111, 111, 2, 0x0080, 0x10, 18, 1),
PIN_FIELD_BASE(112, 112, 2, 0x0080, 0x10, 15, 1),
PIN_FIELD_BASE(113, 113, 2, 0x0080, 0x10, 17, 1),
PIN_FIELD_BASE(114, 115, 2, 0x0070, 0x10, 26, 1),
PIN_FIELD_BASE(116, 117, 2, 0x0070, 0x10, 21, 1),
PIN_FIELD_BASE(118, 118, 2, 0x0070, 0x10, 31, 1),
PIN_FIELD_BASE(119, 119, 2, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(120, 121, 2, 0x0070, 0x10, 23, 1),
PIN_FIELD_BASE(122, 123, 2, 0x0070, 0x10, 28, 1),
PIN_FIELD_BASE(124, 125, 2, 0x0080, 0x10, 1, 1),
PIN_FIELD_BASE(126, 127, 1, 0x0050, 0x10, 2, 1),
PIN_FIELD_BASE(140, 141, 1, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(142, 142, 1, 0x0050, 0x10, 9, 1),
PIN_FIELD_BASE(143, 143, 5, 0x0030, 0x10, 15, 1),
PIN_FIELD_BASE(144, 144, 5, 0x0030, 0x10, 17, 1),
PIN_FIELD_BASE(145, 145, 5, 0x0030, 0x10, 16, 1),
PIN_FIELD_BASE(146, 146, 5, 0x0030, 0x10, 12, 1),
PIN_FIELD_BASE(147, 155, 5, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(156, 157, 5, 0x0030, 0x10, 22, 1),
PIN_FIELD_BASE(158, 158, 5, 0x0030, 0x10, 21, 1),
PIN_FIELD_BASE(159, 159, 5, 0x0030, 0x10, 24, 1),
PIN_FIELD_BASE(160, 161, 5, 0x0030, 0x10, 19, 1),
PIN_FIELD_BASE(162, 166, 5, 0x0030, 0x10, 25, 1),
PIN_FIELD_BASE(179, 179, 4, 0x0030, 0x10, 13, 1),
PIN_FIELD_BASE(180, 180, 4, 0x0030, 0x10, 10, 1),
PIN_FIELD_BASE(181, 183, 1, 0x0050, 0x10, 10, 1),
PIN_FIELD_BASE(184, 184, 1, 0x0050, 0x10, 6, 1),
PIN_FIELD_BASE(185, 185, 1, 0x0050, 0x10, 5, 1),
PIN_FIELD_BASE(186, 186, 1, 0x0050, 0x10, 7, 1),
PIN_FIELD_BASE(187, 187, 1, 0x0050, 0x10, 4, 1),
PIN_FIELD_BASE(188, 188, 1, 0x0050, 0x10, 8, 1),
PIN_FIELD_BASE(189, 189, 5, 0x0030, 0x10, 9, 1),
PIN_FIELD_BASE(190, 190, 5, 0x0030, 0x10, 18, 1),
PIN_FIELD_BASE(191, 192, 5, 0x0030, 0x10, 13, 1),
PIN_FIELD_BASE(193, 194, 5, 0x0030, 0x10, 10, 1),
PIN_FIELD_BASE(195, 195, 2, 0x0070, 0x10, 30, 1),
PIN_FIELD_BASE(196, 196, 2, 0x0070, 0x10, 25, 1),
PIN_FIELD_BASE(197, 197, 2, 0x0080, 0x10, 3, 1),
PIN_FIELD_BASE(198, 199, 4, 0x0030, 0x10, 14, 1),
PIN_FIELD_BASE(200, 201, 6, 0x0060, 0x10, 7, 1),
PIN_FIELD_BASE(202, 202, 4, 0x0030, 0x10, 9, 1),
};
static const struct mtk_pin_field_calc mt6779_pin_drv_range[] = {
PINS_FIELD_BASE(0, 9, 6, 0x0000, 0x10, 9, 3),
PIN_FIELD_BASE(10, 16, 3, 0x0000, 0x10, 0, 3),
PINS_FIELD_BASE(17, 19, 6, 0x0010, 0x10, 3, 3),
PIN_FIELD_BASE(20, 20, 6, 0x0010, 0x10, 6, 3),
PINS_FIELD_BASE(21, 24, 6, 0x0000, 0x10, 21, 3),
PIN_FIELD_BASE(25, 25, 6, 0x0010, 0x10, 9, 3),
PIN_FIELD_BASE(26, 26, 6, 0x0000, 0x10, 24, 3),
PIN_FIELD_BASE(27, 27, 6, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(28, 28, 6, 0x0000, 0x10, 27, 3),
PIN_FIELD_BASE(29, 29, 6, 0x0010, 0x10, 0, 3),
PINS_FIELD_BASE(30, 32, 6, 0x0000, 0x10, 12, 3),
PIN_FIELD_BASE(33, 33, 6, 0x0000, 0x10, 15, 3),
PIN_FIELD_BASE(34, 34, 6, 0x0000, 0x10, 12, 3),
PINS_FIELD_BASE(35, 41, 6, 0x0010, 0x10, 12, 3),
PIN_FIELD_BASE(42, 43, 6, 0x0000, 0x10, 3, 3),
PIN_FIELD_BASE(44, 44, 6, 0x0000, 0x10, 18, 3),
PIN_FIELD_BASE(45, 45, 3, 0x0010, 0x10, 12, 3),
PIN_FIELD_BASE(46, 46, 3, 0x0020, 0x10, 0, 3),
PINS_FIELD_BASE(47, 49, 3, 0x0020, 0x10, 3, 3),
PIN_FIELD_BASE(50, 50, 3, 0x0020, 0x10, 6, 3),
PIN_FIELD_BASE(51, 51, 3, 0x0010, 0x10, 3, 3),
PIN_FIELD_BASE(52, 52, 3, 0x0010, 0x10, 21, 3),
PINS_FIELD_BASE(53, 54, 3, 0x0020, 0x10, 9, 3),
PIN_FIELD_BASE(55, 55, 3, 0x0010, 0x10, 9, 3),
PIN_FIELD_BASE(56, 56, 3, 0x0010, 0x10, 27, 3),
PIN_FIELD_BASE(57, 57, 3, 0x0010, 0x10, 0, 3),
PIN_FIELD_BASE(58, 58, 3, 0x0000, 0x10, 27, 3),
PIN_FIELD_BASE(59, 60, 3, 0x0000, 0x10, 21, 3),
PIN_FIELD_BASE(61, 61, 3, 0x0010, 0x10, 6, 3),
PIN_FIELD_BASE(62, 62, 3, 0x0010, 0x10, 24, 3),
PINS_FIELD_BASE(63, 65, 3, 0x0010, 0x10, 15, 3),
PIN_FIELD_BASE(66, 66, 3, 0x0010, 0x10, 18, 3),
PINS_FIELD_BASE(67, 69, 2, 0x0010, 0x10, 3, 3),
PIN_FIELD_BASE(70, 71, 2, 0x0010, 0x10, 0, 3),
PINS_FIELD_BASE(72, 75, 4, 0x0000, 0x10, 0, 3),
PINS_FIELD_BASE(76, 77, 4, 0x0000, 0x10, 15, 3),
PINS_FIELD_BASE(78, 86, 2, 0x0000, 0x10, 3, 3),
PINS_FIELD_BASE(87, 92, 2, 0x0000, 0x10, 6, 3),
PIN_FIELD_BASE(93, 93, 4, 0x0000, 0x10, 3, 3),
PIN_FIELD_BASE(94, 94, 2, 0x0000, 0x10, 6, 3),
PINS_FIELD_BASE(95, 96, 4, 0x0000, 0x10, 6, 3),
PINS_FIELD_BASE(97, 98, 4, 0x0000, 0x10, 9, 3),
PINS_FIELD_BASE(99, 100, 2, 0x0010, 0x10, 6, 3),
PINS_FIELD_BASE(101, 102, 2, 0x0010, 0x10, 9, 3),
PINS_FIELD_BASE(103, 104, 2, 0x0010, 0x10, 12, 3),
PINS_FIELD_BASE(105, 109, 2, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(110, 110, 2, 0x0010, 0x10, 18, 3),
PIN_FIELD_BASE(111, 111, 2, 0x0010, 0x10, 24, 3),
PIN_FIELD_BASE(112, 112, 2, 0x0010, 0x10, 15, 3),
PIN_FIELD_BASE(113, 113, 2, 0x0010, 0x10, 21, 3),
PINS_FIELD_BASE(114, 115, 2, 0x0000, 0x10, 12, 3),
PIN_FIELD_BASE(116, 117, 2, 0x0000, 0x10, 15, 3),
PINS_FIELD_BASE(118, 119, 2, 0x0000, 0x10, 12, 3),
PIN_FIELD_BASE(120, 121, 2, 0x0000, 0x10, 21, 3),
PINS_FIELD_BASE(122, 125, 2, 0x0000, 0x10, 9, 3),
PINS_FIELD_BASE(126, 127, 1, 0x0000, 0x10, 12, 3),
PIN_FIELD_BASE(128, 128, 1, 0x0000, 0x10, 29, 2),
PIN_FIELD_BASE(129, 129, 1, 0x0010, 0x10, 0, 2),
PIN_FIELD_BASE(130, 130, 1, 0x0000, 0x10, 27, 2),
PIN_FIELD_BASE(131, 131, 1, 0x0010, 0x10, 2, 2),
PIN_FIELD_BASE(132, 132, 1, 0x0010, 0x10, 6, 2),
PIN_FIELD_BASE(133, 133, 1, 0x0010, 0x10, 4, 2),
PIN_FIELD_BASE(134, 135, 1, 0x0000, 0x10, 3, 3),
PINS_FIELD_BASE(136, 139, 1, 0x0000, 0x10, 9, 3),
PINS_FIELD_BASE(140, 141, 1, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(142, 142, 1, 0x0000, 0x10, 24, 3),
PINS_FIELD_BASE(143, 146, 5, 0x0000, 0x10, 3, 3),
PINS_FIELD_BASE(147, 155, 5, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(156, 157, 5, 0x0000, 0x10, 21, 3),
PIN_FIELD_BASE(158, 158, 5, 0x0000, 0x10, 15, 3),
PIN_FIELD_BASE(159, 159, 5, 0x0000, 0x10, 27, 3),
PIN_FIELD_BASE(160, 161, 5, 0x0000, 0x10, 9, 3),
PINS_FIELD_BASE(162, 166, 5, 0x0000, 0x10, 18, 3),
PIN_FIELD_BASE(167, 167, 7, 0x0000, 0x10, 3, 3),
PINS_FIELD_BASE(168, 174, 7, 0x0000, 0x10, 6, 3),
PIN_FIELD_BASE(175, 175, 7, 0x0000, 0x10, 9, 3),
PIN_FIELD_BASE(176, 176, 7, 0x0000, 0x10, 0, 3),
PINS_FIELD_BASE(177, 178, 7, 0x0000, 0x10, 6, 3),
PIN_FIELD_BASE(179, 180, 4, 0x0000, 0x10, 15, 3),
PIN_FIELD_BASE(181, 183, 1, 0x0010, 0x10, 8, 3),
PINS_FIELD_BASE(184, 186, 1, 0x0000, 0x10, 15, 3),
PIN_FIELD_BASE(187, 188, 1, 0x0000, 0x10, 18, 3),
PIN_FIELD_BASE(189, 189, 5, 0x0000, 0x10, 6, 3),
PINS_FIELD_BASE(190, 194, 5, 0x0000, 0x10, 3, 3),
PIN_FIELD_BASE(195, 195, 2, 0x0000, 0x10, 9, 3),
PIN_FIELD_BASE(196, 196, 2, 0x0000, 0x10, 27, 3),
PIN_FIELD_BASE(197, 197, 2, 0x0000, 0x10, 9, 3),
PIN_FIELD_BASE(198, 199, 4, 0x0000, 0x10, 21, 3),
PINS_FIELD_BASE(200, 201, 6, 0x0010, 0x10, 15, 3),
PIN_FIELD_BASE(202, 202, 4, 0x0000, 0x10, 12, 3),
};
static const struct mtk_pin_field_calc mt6779_pin_pupd_range[] = {
PIN_FIELD_BASE(10, 15, 3, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(57, 57, 3, 0x0070, 0x10, 9, 1),
PIN_FIELD_BASE(58, 58, 3, 0x0070, 0x10, 8, 1),
PIN_FIELD_BASE(59, 60, 3, 0x0070, 0x10, 6, 1),
PIN_FIELD_BASE(128, 129, 1, 0x0060, 0x10, 7, 1),
PIN_FIELD_BASE(130, 130, 1, 0x0060, 0x10, 6, 1),
PIN_FIELD_BASE(131, 131, 1, 0x0060, 0x10, 9, 1),
PIN_FIELD_BASE(132, 132, 1, 0x0060, 0x10, 11, 1),
PIN_FIELD_BASE(133, 133, 1, 0x0060, 0x10, 10, 1),
PIN_FIELD_BASE(134, 135, 1, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(136, 136, 1, 0x0060, 0x10, 5, 1),
PIN_FIELD_BASE(137, 137, 1, 0x0060, 0x10, 2, 1),
PIN_FIELD_BASE(138, 138, 1, 0x0060, 0x10, 4, 1),
PIN_FIELD_BASE(139, 139, 1, 0x0060, 0x10, 3, 1),
PIN_FIELD_BASE(167, 168, 7, 0x0020, 0x10, 1, 1),
PIN_FIELD_BASE(169, 169, 7, 0x0020, 0x10, 4, 1),
PIN_FIELD_BASE(170, 170, 7, 0x0020, 0x10, 6, 1),
PIN_FIELD_BASE(171, 171, 7, 0x0020, 0x10, 8, 1),
PIN_FIELD_BASE(172, 172, 7, 0x0020, 0x10, 3, 1),
PIN_FIELD_BASE(173, 173, 7, 0x0020, 0x10, 7, 1),
PIN_FIELD_BASE(174, 175, 7, 0x0020, 0x10, 9, 1),
PIN_FIELD_BASE(176, 176, 7, 0x0020, 0x10, 0, 1),
PIN_FIELD_BASE(177, 177, 7, 0x0020, 0x10, 5, 1),
PIN_FIELD_BASE(178, 178, 7, 0x0020, 0x10, 11, 1),
};
static const struct mtk_pin_field_calc mt6779_pin_r0_range[] = {
PIN_FIELD_BASE(10, 15, 3, 0x0090, 0x10, 0, 1),
PIN_FIELD_BASE(57, 57, 3, 0x0090, 0x10, 9, 1),
PIN_FIELD_BASE(58, 58, 3, 0x0090, 0x10, 8, 1),
PIN_FIELD_BASE(59, 60, 3, 0x0090, 0x10, 6, 1),
PIN_FIELD_BASE(128, 129, 1, 0x0080, 0x10, 7, 1),
PIN_FIELD_BASE(130, 130, 1, 0x0080, 0x10, 6, 1),
PIN_FIELD_BASE(131, 131, 1, 0x0080, 0x10, 9, 1),
PIN_FIELD_BASE(132, 132, 1, 0x0080, 0x10, 11, 1),
PIN_FIELD_BASE(133, 133, 1, 0x0080, 0x10, 10, 1),
PIN_FIELD_BASE(134, 135, 1, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(136, 136, 1, 0x0080, 0x10, 5, 1),
PIN_FIELD_BASE(137, 137, 1, 0x0080, 0x10, 2, 1),
PIN_FIELD_BASE(138, 138, 1, 0x0080, 0x10, 4, 1),
PIN_FIELD_BASE(139, 139, 1, 0x0080, 0x10, 3, 1),
PIN_FIELD_BASE(167, 168, 7, 0x0030, 0x10, 1, 1),
PIN_FIELD_BASE(169, 169, 7, 0x0030, 0x10, 4, 1),
PIN_FIELD_BASE(170, 170, 7, 0x0030, 0x10, 6, 1),
PIN_FIELD_BASE(171, 171, 7, 0x0030, 0x10, 8, 1),
PIN_FIELD_BASE(172, 172, 7, 0x0030, 0x10, 3, 1),
PIN_FIELD_BASE(173, 173, 7, 0x0030, 0x10, 7, 1),
PIN_FIELD_BASE(174, 175, 7, 0x0030, 0x10, 9, 1),
PIN_FIELD_BASE(176, 176, 7, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(177, 177, 7, 0x0030, 0x10, 5, 1),
PIN_FIELD_BASE(178, 178, 7, 0x0030, 0x10, 11, 1),
};
static const struct mtk_pin_field_calc mt6779_pin_r1_range[] = {
PIN_FIELD_BASE(10, 15, 3, 0x00a0, 0x10, 0, 1),
PIN_FIELD_BASE(57, 57, 3, 0x00a0, 0x10, 9, 1),
PIN_FIELD_BASE(58, 58, 3, 0x00a0, 0x10, 8, 1),
PIN_FIELD_BASE(59, 60, 3, 0x00a0, 0x10, 6, 1),
PIN_FIELD_BASE(128, 129, 1, 0x0090, 0x10, 7, 1),
PIN_FIELD_BASE(130, 130, 1, 0x0090, 0x10, 6, 1),
PIN_FIELD_BASE(131, 131, 1, 0x0090, 0x10, 9, 1),
PIN_FIELD_BASE(132, 132, 1, 0x0090, 0x10, 11, 1),
PIN_FIELD_BASE(133, 133, 1, 0x0090, 0x10, 10, 1),
PIN_FIELD_BASE(134, 135, 1, 0x0090, 0x10, 0, 1),
PIN_FIELD_BASE(136, 136, 1, 0x0090, 0x10, 5, 1),
PIN_FIELD_BASE(137, 137, 1, 0x0090, 0x10, 2, 1),
PIN_FIELD_BASE(138, 138, 1, 0x0090, 0x10, 4, 1),
PIN_FIELD_BASE(139, 139, 1, 0x0090, 0x10, 3, 1),
PIN_FIELD_BASE(167, 168, 7, 0x0040, 0x10, 1, 1),
PIN_FIELD_BASE(169, 169, 7, 0x0040, 0x10, 4, 1),
PIN_FIELD_BASE(170, 170, 7, 0x0040, 0x10, 6, 1),
PIN_FIELD_BASE(171, 171, 7, 0x0040, 0x10, 8, 1),
PIN_FIELD_BASE(172, 172, 7, 0x0040, 0x10, 3, 1),
PIN_FIELD_BASE(173, 173, 7, 0x0040, 0x10, 7, 1),
PIN_FIELD_BASE(174, 175, 7, 0x0040, 0x10, 9, 1),
PIN_FIELD_BASE(176, 176, 7, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(177, 177, 7, 0x0040, 0x10, 5, 1),
PIN_FIELD_BASE(178, 178, 7, 0x0040, 0x10, 11, 1),
};
static const struct mtk_pin_reg_calc mt6779_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt6779_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt6779_pin_dir_range),
[PINCTRL_PIN_REG_DI] = MTK_RANGE(mt6779_pin_di_range),
[PINCTRL_PIN_REG_DO] = MTK_RANGE(mt6779_pin_do_range),
[PINCTRL_PIN_REG_SMT] = MTK_RANGE(mt6779_pin_smt_range),
[PINCTRL_PIN_REG_IES] = MTK_RANGE(mt6779_pin_ies_range),
[PINCTRL_PIN_REG_PU] = MTK_RANGE(mt6779_pin_pu_range),
[PINCTRL_PIN_REG_PD] = MTK_RANGE(mt6779_pin_pd_range),
[PINCTRL_PIN_REG_DRV] = MTK_RANGE(mt6779_pin_drv_range),
[PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt6779_pin_pupd_range),
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt6779_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt6779_pin_r1_range),
};
static const char * const mt6779_pinctrl_register_base_names[] = {
"gpio", "iocfg_rm", "iocfg_br", "iocfg_lm", "iocfg_lb",
"iocfg_rt", "iocfg_lt", "iocfg_tl",
};
static const struct mtk_eint_hw mt6779_eint_hw = {
.port_mask = 7,
.ports = 6,
.ap_num = 209,
.db_cnt = 16,
};
static const struct mtk_pin_soc mt6779_data = {
.reg_cal = mt6779_reg_cals,
.pins = mtk_pins_mt6779,
.npins = ARRAY_SIZE(mtk_pins_mt6779),
.ngrps = ARRAY_SIZE(mtk_pins_mt6779),
.nfuncs = 8,
.eint_hw = &mt6779_eint_hw,
.gpio_m = 0,
.base_names = mt6779_pinctrl_register_base_names,
.nbase_names = ARRAY_SIZE(mt6779_pinctrl_register_base_names),
.bias_set_combo = mtk_pinconf_bias_set_combo,
.bias_get_combo = mtk_pinconf_bias_get_combo,
.drive_set = mtk_pinconf_drive_set_raw,
.drive_get = mtk_pinconf_drive_get_raw,
.adv_pull_get = mtk_pinconf_adv_pull_get,
.adv_pull_set = mtk_pinconf_adv_pull_set,
};
static const struct of_device_id mt6779_pinctrl_of_match[] = {
{ .compatible = "mediatek,mt6779-pinctrl", },
{ }
};
static int mt6779_pinctrl_probe(struct platform_device *pdev)
{
return mtk_paris_pinctrl_probe(pdev, &mt6779_data);
}
static struct platform_driver mt6779_pinctrl_driver = {
.driver = {
.name = "mt6779-pinctrl",
.of_match_table = mt6779_pinctrl_of_match,
.pm = &mtk_eint_pm_ops_v2,
},
.probe = mt6779_pinctrl_probe,
};
static int __init mt6779_pinctrl_init(void)
{
return platform_driver_register(&mt6779_pinctrl_driver);
}
arch_initcall(mt6779_pinctrl_init);
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("MediaTek MT6779 Pinctrl Driver");
File diff suppressed because it is too large. Load diff
+820
View File
@@ -0,0 +1,820 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2019 MediaTek Inc.
*
* Author: Light Hsieh <light.hsieh@mediatek.com>
*
*/
#include <linux/module.h>
#include "pinctrl-mtk-mt6785.h"
#include "pinctrl-paris.h"
/* MT6785 have multiple bases to program pin configuration listed as the below:
* gpio:0x10005000, iocfg_rm:0x11C20000, iocfg_br:0x11D10000,
* iocfg_bl:0x11E20000, iocfg_lb:0x11E70000, iocfg_rt:0x11EA0000,
* iocfg_lt:0x11F20000, iocfg_tl:0x11F#0000
* _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)
#define PINS_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, 1)
static const struct mtk_pin_field_calc mt6785_pin_mode_range[] = {
PIN_FIELD_BASE(0, 7, 0, 0x0300, 0x10, 0, 4),
PIN_FIELD_BASE(8, 15, 0, 0x0310, 0x10, 0, 4),
PIN_FIELD_BASE(16, 23, 0, 0x0320, 0x10, 0, 4),
PIN_FIELD_BASE(24, 31, 0, 0x0330, 0x10, 0, 4),
PIN_FIELD_BASE(32, 39, 0, 0x0340, 0x10, 0, 4),
PIN_FIELD_BASE(40, 47, 0, 0x0350, 0x10, 0, 4),
PIN_FIELD_BASE(48, 55, 0, 0x0360, 0x10, 0, 4),
PIN_FIELD_BASE(56, 63, 0, 0x0370, 0x10, 0, 4),
PIN_FIELD_BASE(64, 71, 0, 0x0380, 0x10, 0, 4),
PIN_FIELD_BASE(72, 79, 0, 0x0390, 0x10, 0, 4),
PIN_FIELD_BASE(80, 87, 0, 0x03A0, 0x10, 0, 4),
PIN_FIELD_BASE(88, 95, 0, 0x03B0, 0x10, 0, 4),
PIN_FIELD_BASE(96, 103, 0, 0x03C0, 0x10, 0, 4),
PIN_FIELD_BASE(104, 111, 0, 0x03D0, 0x10, 0, 4),
PIN_FIELD_BASE(112, 119, 0, 0x03E0, 0x10, 0, 4),
PIN_FIELD_BASE(120, 127, 0, 0x03F0, 0x10, 0, 4),
PIN_FIELD_BASE(128, 135, 0, 0x0400, 0x10, 0, 4),
PIN_FIELD_BASE(136, 143, 0, 0x0410, 0x10, 0, 4),
PIN_FIELD_BASE(144, 151, 0, 0x0420, 0x10, 0, 4),
PIN_FIELD_BASE(152, 159, 0, 0x0430, 0x10, 0, 4),
PIN_FIELD_BASE(160, 167, 0, 0x0440, 0x10, 0, 4),
PIN_FIELD_BASE(168, 175, 0, 0x0450, 0x10, 0, 4),
PIN_FIELD_BASE(176, 183, 0, 0x0460, 0x10, 0, 4),
PIN_FIELD_BASE(184, 191, 0, 0x0470, 0x10, 0, 4),
PIN_FIELD_BASE(192, 199, 0, 0x0480, 0x10, 0, 4),
PIN_FIELD_BASE(200, 202, 0, 0x0490, 0x10, 0, 4),
};
static const struct mtk_pin_field_calc mt6785_pin_dir_range[] = {
PIN_FIELD_BASE(0, 31, 0, 0x0000, 0x10, 0, 1),
PIN_FIELD_BASE(32, 63, 0, 0x0010, 0x10, 0, 1),
PIN_FIELD_BASE(64, 95, 0, 0x0020, 0x10, 0, 1),
PIN_FIELD_BASE(96, 127, 0, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(128, 159, 0, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(160, 191, 0, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(192, 202, 0, 0x0060, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6785_pin_di_range[] = {
PIN_FIELD_BASE(0, 31, 0, 0x0200, 0x10, 0, 1),
PIN_FIELD_BASE(32, 63, 0, 0x0210, 0x10, 0, 1),
PIN_FIELD_BASE(64, 95, 0, 0x0220, 0x10, 0, 1),
PIN_FIELD_BASE(96, 127, 0, 0x0230, 0x10, 0, 1),
PIN_FIELD_BASE(128, 159, 0, 0x0240, 0x10, 0, 1),
PIN_FIELD_BASE(160, 191, 0, 0x0250, 0x10, 0, 1),
PIN_FIELD_BASE(192, 202, 0, 0x0260, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6785_pin_do_range[] = {
PIN_FIELD_BASE(0, 31, 0, 0x0100, 0x10, 0, 1),
PIN_FIELD_BASE(32, 63, 0, 0x0110, 0x10, 0, 1),
PIN_FIELD_BASE(64, 95, 0, 0x0120, 0x10, 0, 1),
PIN_FIELD_BASE(96, 127, 0, 0x0130, 0x10, 0, 1),
PIN_FIELD_BASE(128, 159, 0, 0x0140, 0x10, 0, 1),
PIN_FIELD_BASE(160, 191, 0, 0x0150, 0x10, 0, 1),
PIN_FIELD_BASE(192, 202, 0, 0x0160, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6785_pin_ies_range[] = {
PIN_FIELD_BASE(0, 9, 6, 0x0040, 0x10, 3, 1),
PIN_FIELD_BASE(10, 16, 4, 0x0030, 0x10, 10, 1),
PIN_FIELD_BASE(17, 18, 6, 0x0040, 0x10, 28, 1),
PIN_FIELD_BASE(19, 19, 6, 0x0040, 0x10, 27, 1),
PIN_FIELD_BASE(20, 20, 6, 0x0040, 0x10, 26, 1),
PIN_FIELD_BASE(21, 24, 6, 0x0040, 0x10, 19, 1),
PIN_FIELD_BASE(25, 25, 6, 0x0040, 0x10, 30, 1),
PIN_FIELD_BASE(26, 26, 6, 0x0040, 0x10, 23, 1),
PIN_FIELD_BASE(27, 27, 6, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(28, 29, 6, 0x0040, 0x10, 24, 1),
PIN_FIELD_BASE(30, 30, 6, 0x0040, 0x10, 16, 1),
PIN_FIELD_BASE(31, 31, 6, 0x0040, 0x10, 13, 1),
PIN_FIELD_BASE(32, 32, 6, 0x0040, 0x10, 15, 1),
PIN_FIELD_BASE(33, 33, 6, 0x0040, 0x10, 17, 1),
PIN_FIELD_BASE(34, 34, 6, 0x0040, 0x10, 14, 1),
PIN_FIELD_BASE(35, 35, 6, 0x0050, 0x10, 4, 1),
PIN_FIELD_BASE(36, 36, 6, 0x0040, 0x10, 31, 1),
PIN_FIELD_BASE(37, 37, 6, 0x0050, 0x10, 5, 1),
PIN_FIELD_BASE(38, 41, 6, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(42, 43, 6, 0x0040, 0x10, 1, 1),
PIN_FIELD_BASE(44, 44, 6, 0x0040, 0x10, 18, 1),
PIN_FIELD_BASE(45, 45, 5, 0x0050, 0x10, 21, 1),
PIN_FIELD_BASE(46, 46, 5, 0x0050, 0x10, 27, 1),
PIN_FIELD_BASE(47, 47, 5, 0x0060, 0x10, 1, 1),
PIN_FIELD_BASE(48, 48, 5, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(49, 49, 5, 0x0060, 0x10, 2, 1),
PIN_FIELD_BASE(50, 50, 5, 0x0050, 0x10, 31, 1),
PIN_FIELD_BASE(51, 51, 5, 0x0050, 0x10, 19, 1),
PIN_FIELD_BASE(52, 52, 5, 0x0050, 0x10, 25, 1),
PIN_FIELD_BASE(53, 54, 5, 0x0060, 0x10, 7, 1),
PIN_FIELD_BASE(55, 55, 5, 0x0050, 0x10, 20, 1),
PIN_FIELD_BASE(56, 56, 5, 0x0050, 0x10, 26, 1),
PIN_FIELD_BASE(57, 57, 5, 0x0050, 0x10, 17, 1),
PIN_FIELD_BASE(58, 58, 5, 0x0050, 0x10, 16, 1),
PIN_FIELD_BASE(59, 60, 5, 0x0050, 0x10, 14, 1),
PIN_FIELD_BASE(61, 62, 3, 0x0020, 0x10, 13, 1),
PIN_FIELD_BASE(63, 63, 4, 0x0030, 0x10, 24, 1),
PIN_FIELD_BASE(64, 64, 4, 0x0030, 0x10, 23, 1),
PIN_FIELD_BASE(65, 65, 4, 0x0030, 0x10, 25, 1),
PIN_FIELD_BASE(66, 66, 4, 0x0030, 0x10, 22, 1),
PIN_FIELD_BASE(67, 67, 2, 0x0060, 0x10, 7, 1),
PIN_FIELD_BASE(68, 68, 2, 0x0060, 0x10, 6, 1),
PIN_FIELD_BASE(69, 69, 2, 0x0060, 0x10, 8, 1),
PIN_FIELD_BASE(70, 71, 2, 0x0060, 0x10, 4, 1),
PIN_FIELD_BASE(72, 72, 3, 0x0020, 0x10, 3, 1),
PIN_FIELD_BASE(73, 73, 3, 0x0020, 0x10, 2, 1),
PIN_FIELD_BASE(74, 74, 3, 0x0020, 0x10, 1, 1),
PIN_FIELD_BASE(75, 75, 3, 0x0020, 0x10, 4, 1),
PIN_FIELD_BASE(76, 76, 3, 0x0020, 0x10, 11, 1),
PIN_FIELD_BASE(77, 77, 3, 0x0020, 0x10, 10, 1),
PIN_FIELD_BASE(78, 78, 2, 0x0050, 0x10, 18, 1),
PIN_FIELD_BASE(79, 79, 2, 0x0050, 0x10, 17, 1),
PIN_FIELD_BASE(80, 81, 2, 0x0050, 0x10, 19, 1),
PIN_FIELD_BASE(82, 88, 2, 0x0050, 0x10, 1, 1),
PIN_FIELD_BASE(89, 89, 2, 0x0050, 0x10, 16, 1),
PIN_FIELD_BASE(90, 90, 2, 0x0050, 0x10, 15, 1),
PIN_FIELD_BASE(91, 91, 2, 0x0050, 0x10, 14, 1),
PIN_FIELD_BASE(92, 92, 2, 0x0050, 0x10, 8, 1),
PIN_FIELD_BASE(93, 93, 3, 0x0020, 0x10, 0, 1),
PIN_FIELD_BASE(94, 94, 2, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(95, 95, 3, 0x0020, 0x10, 7, 1),
PIN_FIELD_BASE(96, 96, 3, 0x0020, 0x10, 5, 1),
PIN_FIELD_BASE(97, 97, 3, 0x0020, 0x10, 8, 1),
PIN_FIELD_BASE(98, 98, 3, 0x0020, 0x10, 6, 1),
PIN_FIELD_BASE(99, 99, 2, 0x0060, 0x10, 9, 1),
PIN_FIELD_BASE(100, 100, 2, 0x0060, 0x10, 12, 1),
PIN_FIELD_BASE(101, 101, 2, 0x0060, 0x10, 10, 1),
PIN_FIELD_BASE(102, 102, 2, 0x0060, 0x10, 13, 1),
PIN_FIELD_BASE(103, 103, 2, 0x0060, 0x10, 11, 1),
PIN_FIELD_BASE(104, 104, 2, 0x0060, 0x10, 14, 1),
PIN_FIELD_BASE(105, 105, 2, 0x0050, 0x10, 10, 1),
PIN_FIELD_BASE(106, 106, 2, 0x0050, 0x10, 9, 1),
PIN_FIELD_BASE(107, 108, 2, 0x0050, 0x10, 12, 1),
PIN_FIELD_BASE(109, 109, 2, 0x0050, 0x10, 11, 1),
PIN_FIELD_BASE(110, 110, 2, 0x0060, 0x10, 16, 1),
PIN_FIELD_BASE(111, 111, 2, 0x0060, 0x10, 18, 1),
PIN_FIELD_BASE(112, 112, 2, 0x0060, 0x10, 15, 1),
PIN_FIELD_BASE(113, 113, 2, 0x0060, 0x10, 17, 1),
PIN_FIELD_BASE(114, 115, 2, 0x0050, 0x10, 26, 1),
PIN_FIELD_BASE(116, 117, 2, 0x0050, 0x10, 21, 1),
PIN_FIELD_BASE(118, 118, 2, 0x0050, 0x10, 31, 1),
PIN_FIELD_BASE(119, 119, 2, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(120, 121, 2, 0x0050, 0x10, 23, 1),
PIN_FIELD_BASE(122, 123, 2, 0x0050, 0x10, 28, 1),
PIN_FIELD_BASE(124, 125, 2, 0x0060, 0x10, 1, 1),
PIN_FIELD_BASE(126, 127, 1, 0x0030, 0x10, 6, 1),
PIN_FIELD_BASE(128, 129, 1, 0x0030, 0x10, 9, 1),
PIN_FIELD_BASE(130, 130, 1, 0x0030, 0x10, 8, 1),
PIN_FIELD_BASE(131, 131, 1, 0x0030, 0x10, 11, 1),
PIN_FIELD_BASE(132, 132, 1, 0x0030, 0x10, 13, 1),
PIN_FIELD_BASE(133, 133, 1, 0x0030, 0x10, 12, 1),
PIN_FIELD_BASE(134, 135, 1, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(136, 136, 1, 0x0030, 0x10, 5, 1),
PIN_FIELD_BASE(137, 137, 1, 0x0030, 0x10, 2, 1),
PIN_FIELD_BASE(138, 138, 1, 0x0030, 0x10, 4, 1),
PIN_FIELD_BASE(139, 139, 1, 0x0030, 0x10, 3, 1),
PIN_FIELD_BASE(140, 141, 5, 0x0050, 0x10, 12, 1),
PIN_FIELD_BASE(142, 142, 4, 0x0030, 0x10, 26, 1),
PIN_FIELD_BASE(143, 143, 4, 0x0030, 0x10, 6, 1),
PIN_FIELD_BASE(144, 144, 4, 0x0030, 0x10, 8, 1),
PIN_FIELD_BASE(145, 145, 4, 0x0030, 0x10, 7, 1),
PIN_FIELD_BASE(146, 146, 4, 0x0030, 0x10, 3, 1),
PIN_FIELD_BASE(147, 149, 5, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(150, 150, 5, 0x0060, 0x10, 6, 1),
PIN_FIELD_BASE(151, 151, 5, 0x0050, 0x10, 30, 1),
PIN_FIELD_BASE(152, 152, 5, 0x0050, 0x10, 24, 1),
PIN_FIELD_BASE(153, 153, 5, 0x0060, 0x10, 4, 1),
PIN_FIELD_BASE(154, 154, 5, 0x0050, 0x10, 29, 1),
PIN_FIELD_BASE(155, 155, 5, 0x0050, 0x10, 23, 1),
PIN_FIELD_BASE(156, 157, 5, 0x0050, 0x10, 6, 1),
PIN_FIELD_BASE(158, 158, 5, 0x0050, 0x10, 5, 1),
PIN_FIELD_BASE(159, 159, 5, 0x0050, 0x10, 8, 1),
PIN_FIELD_BASE(160, 161, 5, 0x0050, 0x10, 3, 1),
PIN_FIELD_BASE(162, 164, 5, 0x0050, 0x10, 9, 1),
PIN_FIELD_BASE(165, 165, 5, 0x0060, 0x10, 3, 1),
PIN_FIELD_BASE(166, 166, 5, 0x0060, 0x10, 5, 1),
PIN_FIELD_BASE(167, 168, 7, 0x0010, 0x10, 1, 1),
PIN_FIELD_BASE(169, 169, 7, 0x0010, 0x10, 4, 1),
PIN_FIELD_BASE(170, 170, 7, 0x0010, 0x10, 6, 1),
PIN_FIELD_BASE(171, 171, 7, 0x0010, 0x10, 8, 1),
PIN_FIELD_BASE(172, 172, 7, 0x0010, 0x10, 3, 1),
PIN_FIELD_BASE(173, 173, 7, 0x0010, 0x10, 7, 1),
PIN_FIELD_BASE(174, 175, 7, 0x0010, 0x10, 9, 1),
PIN_FIELD_BASE(176, 176, 7, 0x0010, 0x10, 0, 1),
PIN_FIELD_BASE(177, 177, 7, 0x0010, 0x10, 5, 1),
PIN_FIELD_BASE(178, 178, 7, 0x0010, 0x10, 11, 1),
PIN_FIELD_BASE(179, 179, 3, 0x0020, 0x10, 12, 1),
PIN_FIELD_BASE(180, 180, 3, 0x0020, 0x10, 9, 1),
PIN_FIELD_BASE(181, 183, 4, 0x0030, 0x10, 27, 1),
PIN_FIELD_BASE(184, 184, 4, 0x0030, 0x10, 19, 1),
PIN_FIELD_BASE(185, 185, 4, 0x0030, 0x10, 18, 1),
PIN_FIELD_BASE(186, 186, 4, 0x0030, 0x10, 20, 1),
PIN_FIELD_BASE(187, 187, 4, 0x0030, 0x10, 17, 1),
PIN_FIELD_BASE(188, 188, 4, 0x0030, 0x10, 21, 1),
PIN_FIELD_BASE(189, 189, 4, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(190, 190, 4, 0x0030, 0x10, 9, 1),
PIN_FIELD_BASE(191, 192, 4, 0x0030, 0x10, 4, 1),
PIN_FIELD_BASE(193, 194, 4, 0x0030, 0x10, 1, 1),
PIN_FIELD_BASE(195, 195, 2, 0x0050, 0x10, 30, 1),
PIN_FIELD_BASE(196, 196, 2, 0x0050, 0x10, 25, 1),
PIN_FIELD_BASE(197, 197, 2, 0x0060, 0x10, 3, 1),
PIN_FIELD_BASE(198, 198, 5, 0x0050, 0x10, 22, 1),
PIN_FIELD_BASE(199, 199, 5, 0x0050, 0x10, 28, 1),
PIN_FIELD_BASE(200, 201, 6, 0x0050, 0x10, 6, 1),
PIN_FIELD_BASE(202, 202, 5, 0x0050, 0x10, 18, 1),
};
static const struct mtk_pin_field_calc mt6785_pin_smt_range[] = {
PINS_FIELD_BASE(0, 9, 6, 0x00d0, 0x10, 3, 1),
PIN_FIELD_BASE(10, 11, 4, 0x00b0, 0x10, 1, 1),
PINS_FIELD_BASE(12, 15, 4, 0x00b0, 0x10, 3, 1),
PIN_FIELD_BASE(16, 16, 4, 0x00b0, 0x10, 4, 1),
PINS_FIELD_BASE(17, 20, 6, 0x00d0, 0x10, 11, 1),
PINS_FIELD_BASE(21, 24, 6, 0x00d0, 0x10, 7, 1),
PIN_FIELD_BASE(25, 25, 6, 0x00d0, 0x10, 12, 1),
PIN_FIELD_BASE(26, 26, 6, 0x00d0, 0x10, 8, 1),
PIN_FIELD_BASE(27, 27, 6, 0x00d0, 0x10, 0, 1),
PIN_FIELD_BASE(28, 29, 6, 0x00d0, 0x10, 9, 1),
PINS_FIELD_BASE(30, 32, 6, 0x00d0, 0x10, 4, 1),
PIN_FIELD_BASE(33, 33, 6, 0x00d0, 0x10, 5, 1),
PIN_FIELD_BASE(34, 34, 6, 0x00d0, 0x10, 4, 1),
PINS_FIELD_BASE(35, 41, 6, 0x00d0, 0x10, 13, 1),
PIN_FIELD_BASE(42, 43, 6, 0x00d0, 0x10, 1, 1),
PIN_FIELD_BASE(44, 44, 6, 0x00d0, 0x10, 6, 1),
PIN_FIELD_BASE(45, 45, 5, 0x0110, 0x10, 14, 1),
PIN_FIELD_BASE(46, 46, 5, 0x0110, 0x10, 20, 1),
PINS_FIELD_BASE(47, 50, 5, 0x0110, 0x10, 24, 1),
PIN_FIELD_BASE(51, 51, 5, 0x0110, 0x10, 12, 1),
PIN_FIELD_BASE(52, 52, 5, 0x0110, 0x10, 18, 1),
PIN_FIELD_BASE(53, 54, 5, 0x0110, 0x10, 26, 1),
PIN_FIELD_BASE(55, 55, 5, 0x0110, 0x10, 13, 1),
PIN_FIELD_BASE(56, 56, 5, 0x0110, 0x10, 19, 1),
PINS_FIELD_BASE(57, 60, 5, 0x0110, 0x10, 10, 1),
PIN_FIELD_BASE(61, 62, 3, 0x0070, 0x10, 4, 1),
PINS_FIELD_BASE(63, 66, 4, 0x00b0, 0x10, 7, 1),
PINS_FIELD_BASE(67, 69, 2, 0x00e0, 0x10, 11, 1),
PIN_FIELD_BASE(70, 71, 2, 0x00e0, 0x10, 10, 1),
PINS_FIELD_BASE(72, 75, 3, 0x0070, 0x10, 1, 1),
PINS_FIELD_BASE(76, 77, 3, 0x0070, 0x10, 3, 1),
PINS_FIELD_BASE(78, 86, 2, 0x00e0, 0x10, 1, 1),
PINS_FIELD_BASE(87, 92, 2, 0x00e0, 0x10, 2, 1),
PIN_FIELD_BASE(93, 93, 3, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(94, 94, 2, 0x00e0, 0x10, 2, 1),
PINS_FIELD_BASE(95, 98, 3, 0x0070, 0x10, 2, 1),
PINS_FIELD_BASE(99, 104, 2, 0x00e0, 0x10, 12, 1),
PINS_FIELD_BASE(105, 109, 2, 0x00e0, 0x10, 0, 1),
PIN_FIELD_BASE(110, 110, 2, 0x00e0, 0x10, 14, 1),
PIN_FIELD_BASE(111, 111, 2, 0x00e0, 0x10, 16, 1),
PIN_FIELD_BASE(112, 112, 2, 0x00e0, 0x10, 13, 1),
PIN_FIELD_BASE(113, 113, 2, 0x00e0, 0x10, 15, 1),
PINS_FIELD_BASE(114, 115, 2, 0x00e0, 0x10, 4, 1),
PIN_FIELD_BASE(116, 117, 2, 0x00e0, 0x10, 5, 1),
PINS_FIELD_BASE(118, 119, 2, 0x00e0, 0x10, 4, 1),
PIN_FIELD_BASE(120, 121, 2, 0x00e0, 0x10, 7, 1),
PINS_FIELD_BASE(122, 125, 2, 0x00e0, 0x10, 3, 1),
PINS_FIELD_BASE(126, 127, 1, 0x00b0, 0x10, 3, 1),
PINS_FIELD_BASE(128, 130, 1, 0x00b0, 0x10, 4, 1),
PINS_FIELD_BASE(131, 133, 1, 0x00b0, 0x10, 5, 1),
PIN_FIELD_BASE(134, 135, 1, 0x00b0, 0x10, 0, 1),
PINS_FIELD_BASE(136, 139, 1, 0x00b0, 0x10, 2, 1),
PIN_FIELD_BASE(140, 141, 5, 0x0110, 0x10, 8, 1),
PIN_FIELD_BASE(142, 142, 4, 0x00b0, 0x10, 8, 1),
PINS_FIELD_BASE(143, 146, 4, 0x00b0, 0x10, 0, 1),
PINS_FIELD_BASE(147, 149, 5, 0x0110, 0x10, 0, 1),
PIN_FIELD_BASE(150, 150, 5, 0x0110, 0x10, 25, 1),
PIN_FIELD_BASE(151, 151, 5, 0x0110, 0x10, 23, 1),
PIN_FIELD_BASE(152, 152, 5, 0x0110, 0x10, 17, 1),
PIN_FIELD_BASE(153, 153, 5, 0x0110, 0x10, 25, 1),
PIN_FIELD_BASE(154, 154, 5, 0x0110, 0x10, 22, 1),
PIN_FIELD_BASE(155, 155, 5, 0x0110, 0x10, 16, 1),
PIN_FIELD_BASE(156, 157, 5, 0x0110, 0x10, 5, 1),
PIN_FIELD_BASE(158, 158, 5, 0x0110, 0x10, 4, 1),
PIN_FIELD_BASE(159, 159, 5, 0x0110, 0x10, 7, 1),
PIN_FIELD_BASE(160, 161, 5, 0x0110, 0x10, 2, 1),
PINS_FIELD_BASE(162, 164, 5, 0x0110, 0x10, 1, 1),
PINS_FIELD_BASE(165, 166, 5, 0x0110, 0x10, 25, 1),
PIN_FIELD_BASE(167, 167, 7, 0x0060, 0x10, 1, 1),
PINS_FIELD_BASE(168, 174, 7, 0x0060, 0x10, 2, 1),
PIN_FIELD_BASE(175, 175, 7, 0x0060, 0x10, 3, 1),
PIN_FIELD_BASE(176, 176, 7, 0x0060, 0x10, 0, 1),
PINS_FIELD_BASE(177, 178, 7, 0x0060, 0x10, 2, 1),
PINS_FIELD_BASE(179, 180, 3, 0x0070, 0x10, 3, 1),
PIN_FIELD_BASE(181, 183, 4, 0x00b0, 0x10, 9, 1),
PINS_FIELD_BASE(184, 187, 4, 0x00b0, 0x10, 5, 1),
PIN_FIELD_BASE(188, 188, 4, 0x00b0, 0x10, 6, 1),
PINS_FIELD_BASE(189, 194, 4, 0x00b0, 0x10, 0, 1),
PIN_FIELD_BASE(195, 195, 2, 0x00e0, 0x10, 3, 1),
PIN_FIELD_BASE(196, 196, 2, 0x00e0, 0x10, 9, 1),
PIN_FIELD_BASE(197, 197, 2, 0x00e0, 0x10, 3, 1),
PIN_FIELD_BASE(198, 198, 5, 0x0110, 0x10, 15, 1),
PIN_FIELD_BASE(199, 199, 5, 0x0110, 0x10, 21, 1),
PIN_FIELD_BASE(200, 201, 6, 0x00d0, 0x10, 14, 1),
PIN_FIELD_BASE(202, 202, 5, 0x0110, 0x10, 11, 1),
};
static const struct mtk_pin_field_calc mt6785_pin_pu_range[] = {
PIN_FIELD_BASE(0, 9, 6, 0x0080, 0x10, 3, 1),
PIN_FIELD_BASE(16, 16, 4, 0x0060, 0x10, 10, 1),
PIN_FIELD_BASE(17, 18, 6, 0x0080, 0x10, 28, 1),
PIN_FIELD_BASE(19, 19, 6, 0x0080, 0x10, 27, 1),
PIN_FIELD_BASE(20, 20, 6, 0x0080, 0x10, 26, 1),
PIN_FIELD_BASE(21, 24, 6, 0x0080, 0x10, 19, 1),
PIN_FIELD_BASE(25, 25, 6, 0x0080, 0x10, 30, 1),
PIN_FIELD_BASE(26, 26, 6, 0x0080, 0x10, 23, 1),
PIN_FIELD_BASE(27, 27, 6, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(28, 29, 6, 0x0080, 0x10, 24, 1),
PIN_FIELD_BASE(30, 30, 6, 0x0080, 0x10, 16, 1),
PIN_FIELD_BASE(31, 31, 6, 0x0080, 0x10, 13, 1),
PIN_FIELD_BASE(32, 32, 6, 0x0080, 0x10, 15, 1),
PIN_FIELD_BASE(33, 33, 6, 0x0080, 0x10, 17, 1),
PIN_FIELD_BASE(34, 34, 6, 0x0080, 0x10, 14, 1),
PIN_FIELD_BASE(35, 35, 6, 0x0090, 0x10, 5, 1),
PIN_FIELD_BASE(36, 36, 6, 0x0090, 0x10, 0, 1),
PIN_FIELD_BASE(37, 37, 6, 0x0090, 0x10, 6, 1),
PIN_FIELD_BASE(38, 41, 6, 0x0090, 0x10, 1, 1),
PIN_FIELD_BASE(42, 43, 6, 0x0080, 0x10, 1, 1),
PIN_FIELD_BASE(44, 44, 6, 0x0080, 0x10, 18, 1),
PIN_FIELD_BASE(45, 45, 5, 0x00a0, 0x10, 17, 1),
PIN_FIELD_BASE(46, 46, 5, 0x00a0, 0x10, 23, 1),
PIN_FIELD_BASE(47, 47, 5, 0x00a0, 0x10, 29, 1),
PIN_FIELD_BASE(48, 48, 5, 0x00a0, 0x10, 28, 1),
PIN_FIELD_BASE(49, 49, 5, 0x00a0, 0x10, 30, 1),
PIN_FIELD_BASE(50, 50, 5, 0x00a0, 0x10, 27, 1),
PIN_FIELD_BASE(51, 51, 5, 0x00a0, 0x10, 15, 1),
PIN_FIELD_BASE(52, 52, 5, 0x00a0, 0x10, 21, 1),
PIN_FIELD_BASE(53, 54, 5, 0x00b0, 0x10, 3, 1),
PIN_FIELD_BASE(55, 55, 5, 0x00a0, 0x10, 16, 1),
PIN_FIELD_BASE(56, 56, 5, 0x00a0, 0x10, 22, 1),
PIN_FIELD_BASE(61, 62, 3, 0x0040, 0x10, 13, 1),
PIN_FIELD_BASE(63, 63, 4, 0x0060, 0x10, 18, 1),
PIN_FIELD_BASE(64, 64, 4, 0x0060, 0x10, 17, 1),
PIN_FIELD_BASE(65, 65, 4, 0x0060, 0x10, 19, 1),
PIN_FIELD_BASE(66, 66, 4, 0x0060, 0x10, 16, 1),
PIN_FIELD_BASE(67, 67, 2, 0x00a0, 0x10, 7, 1),
PIN_FIELD_BASE(68, 68, 2, 0x00a0, 0x10, 6, 1),
PIN_FIELD_BASE(69, 69, 2, 0x00a0, 0x10, 8, 1),
PIN_FIELD_BASE(70, 71, 2, 0x00a0, 0x10, 4, 1),
PIN_FIELD_BASE(72, 72, 3, 0x0040, 0x10, 3, 1),
PIN_FIELD_BASE(73, 73, 3, 0x0040, 0x10, 2, 1),
PIN_FIELD_BASE(74, 74, 3, 0x0040, 0x10, 1, 1),
PIN_FIELD_BASE(75, 75, 3, 0x0040, 0x10, 4, 1),
PIN_FIELD_BASE(76, 76, 3, 0x0040, 0x10, 11, 1),
PIN_FIELD_BASE(77, 77, 3, 0x0040, 0x10, 10, 1),
PIN_FIELD_BASE(78, 78, 2, 0x0090, 0x10, 18, 1),
PIN_FIELD_BASE(79, 79, 2, 0x0090, 0x10, 17, 1),
PIN_FIELD_BASE(80, 81, 2, 0x0090, 0x10, 19, 1),
PIN_FIELD_BASE(82, 88, 2, 0x0090, 0x10, 1, 1),
PIN_FIELD_BASE(89, 89, 2, 0x0090, 0x10, 16, 1),
PIN_FIELD_BASE(90, 90, 2, 0x0090, 0x10, 15, 1),
PIN_FIELD_BASE(91, 91, 2, 0x0090, 0x10, 14, 1),
PIN_FIELD_BASE(92, 92, 2, 0x0090, 0x10, 8, 1),
PIN_FIELD_BASE(93, 93, 3, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(94, 94, 2, 0x0090, 0x10, 0, 1),
PIN_FIELD_BASE(95, 95, 3, 0x0040, 0x10, 7, 1),
PIN_FIELD_BASE(96, 96, 3, 0x0040, 0x10, 5, 1),
PIN_FIELD_BASE(97, 97, 3, 0x0040, 0x10, 8, 1),
PIN_FIELD_BASE(98, 98, 3, 0x0040, 0x10, 6, 1),
PIN_FIELD_BASE(99, 99, 2, 0x00a0, 0x10, 9, 1),
PIN_FIELD_BASE(100, 100, 2, 0x00a0, 0x10, 12, 1),
PIN_FIELD_BASE(101, 101, 2, 0x00a0, 0x10, 10, 1),
PIN_FIELD_BASE(102, 102, 2, 0x00a0, 0x10, 13, 1),
PIN_FIELD_BASE(103, 103, 2, 0x00a0, 0x10, 11, 1),
PIN_FIELD_BASE(104, 104, 2, 0x00a0, 0x10, 14, 1),
PIN_FIELD_BASE(105, 105, 2, 0x0090, 0x10, 10, 1),
PIN_FIELD_BASE(106, 106, 2, 0x0090, 0x10, 9, 1),
PIN_FIELD_BASE(107, 108, 2, 0x0090, 0x10, 12, 1),
PIN_FIELD_BASE(109, 109, 2, 0x0090, 0x10, 11, 1),
PIN_FIELD_BASE(110, 110, 2, 0x00a0, 0x10, 16, 1),
PIN_FIELD_BASE(111, 111, 2, 0x00a0, 0x10, 18, 1),
PIN_FIELD_BASE(112, 112, 2, 0x00a0, 0x10, 15, 1),
PIN_FIELD_BASE(113, 113, 2, 0x00a0, 0x10, 17, 1),
PIN_FIELD_BASE(114, 115, 2, 0x0090, 0x10, 26, 1),
PIN_FIELD_BASE(116, 117, 2, 0x0090, 0x10, 21, 1),
PIN_FIELD_BASE(118, 118, 2, 0x0090, 0x10, 31, 1),
PIN_FIELD_BASE(119, 119, 2, 0x00a0, 0x10, 0, 1),
PIN_FIELD_BASE(120, 121, 2, 0x0090, 0x10, 23, 1),
PIN_FIELD_BASE(122, 123, 2, 0x0090, 0x10, 28, 1),
PIN_FIELD_BASE(124, 125, 2, 0x00a0, 0x10, 1, 1),
PIN_FIELD_BASE(126, 127, 1, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(140, 141, 5, 0x00a0, 0x10, 12, 1),
PIN_FIELD_BASE(142, 142, 4, 0x0060, 0x10, 20, 1),
PIN_FIELD_BASE(143, 143, 4, 0x0060, 0x10, 6, 1),
PIN_FIELD_BASE(144, 144, 4, 0x0060, 0x10, 8, 1),
PIN_FIELD_BASE(145, 145, 4, 0x0060, 0x10, 7, 1),
PIN_FIELD_BASE(146, 146, 4, 0x0060, 0x10, 3, 1),
PIN_FIELD_BASE(147, 149, 5, 0x00a0, 0x10, 0, 1),
PIN_FIELD_BASE(150, 150, 5, 0x00b0, 0x10, 2, 1),
PIN_FIELD_BASE(151, 151, 5, 0x00a0, 0x10, 26, 1),
PIN_FIELD_BASE(152, 152, 5, 0x00a0, 0x10, 20, 1),
PIN_FIELD_BASE(153, 153, 5, 0x00b0, 0x10, 0, 1),
PIN_FIELD_BASE(154, 154, 5, 0x00a0, 0x10, 25, 1),
PIN_FIELD_BASE(155, 155, 5, 0x00a0, 0x10, 19, 1),
PIN_FIELD_BASE(156, 157, 5, 0x00a0, 0x10, 6, 1),
PIN_FIELD_BASE(158, 158, 5, 0x00a0, 0x10, 5, 1),
PIN_FIELD_BASE(159, 159, 5, 0x00a0, 0x10, 8, 1),
PIN_FIELD_BASE(160, 161, 5, 0x00a0, 0x10, 3, 1),
PIN_FIELD_BASE(162, 164, 5, 0x00a0, 0x10, 9, 1),
PIN_FIELD_BASE(165, 165, 5, 0x00a0, 0x10, 31, 1),
PIN_FIELD_BASE(166, 166, 5, 0x00b0, 0x10, 1, 1),
PIN_FIELD_BASE(179, 179, 3, 0x0040, 0x10, 12, 1),
PIN_FIELD_BASE(180, 180, 3, 0x0040, 0x10, 9, 1),
PIN_FIELD_BASE(181, 182, 4, 0x0060, 0x10, 21, 1),
PIN_FIELD_BASE(183, 183, 4, 0x0060, 0x10, 24, 1),
PIN_FIELD_BASE(184, 184, 4, 0x0060, 0x10, 13, 1),
PIN_FIELD_BASE(185, 185, 4, 0x0060, 0x10, 12, 1),
PIN_FIELD_BASE(186, 186, 4, 0x0060, 0x10, 14, 1),
PIN_FIELD_BASE(187, 187, 4, 0x0060, 0x10, 11, 1),
PIN_FIELD_BASE(188, 188, 4, 0x0060, 0x10, 15, 1),
PIN_FIELD_BASE(189, 189, 4, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(190, 190, 4, 0x0060, 0x10, 9, 1),
PIN_FIELD_BASE(191, 192, 4, 0x0060, 0x10, 4, 1),
PIN_FIELD_BASE(193, 194, 4, 0x0060, 0x10, 1, 1),
PIN_FIELD_BASE(195, 195, 2, 0x0090, 0x10, 30, 1),
PIN_FIELD_BASE(196, 196, 2, 0x0090, 0x10, 25, 1),
PIN_FIELD_BASE(197, 197, 2, 0x00a0, 0x10, 3, 1),
PIN_FIELD_BASE(198, 198, 5, 0x00a0, 0x10, 18, 1),
PIN_FIELD_BASE(199, 199, 5, 0x00a0, 0x10, 24, 1),
PIN_FIELD_BASE(200, 201, 6, 0x0090, 0x10, 7, 1),
PIN_FIELD_BASE(202, 202, 5, 0x00a0, 0x10, 14, 1),
};
static const struct mtk_pin_field_calc mt6785_pin_pd_range[] = {
PIN_FIELD_BASE(0, 9, 6, 0x0060, 0x10, 3, 1),
PIN_FIELD_BASE(16, 16, 4, 0x0040, 0x10, 10, 1),
PIN_FIELD_BASE(17, 18, 6, 0x0060, 0x10, 28, 1),
PIN_FIELD_BASE(19, 19, 6, 0x0060, 0x10, 27, 1),
PIN_FIELD_BASE(20, 20, 6, 0x0060, 0x10, 26, 1),
PIN_FIELD_BASE(21, 24, 6, 0x0060, 0x10, 19, 1),
PIN_FIELD_BASE(25, 25, 6, 0x0060, 0x10, 30, 1),
PIN_FIELD_BASE(26, 26, 6, 0x0060, 0x10, 23, 1),
PIN_FIELD_BASE(27, 27, 6, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(28, 29, 6, 0x0060, 0x10, 24, 1),
PIN_FIELD_BASE(30, 30, 6, 0x0060, 0x10, 16, 1),
PIN_FIELD_BASE(31, 31, 6, 0x0060, 0x10, 13, 1),
PIN_FIELD_BASE(32, 32, 6, 0x0060, 0x10, 15, 1),
PIN_FIELD_BASE(33, 33, 6, 0x0060, 0x10, 17, 1),
PIN_FIELD_BASE(34, 34, 6, 0x0060, 0x10, 14, 1),
PIN_FIELD_BASE(35, 35, 6, 0x0070, 0x10, 5, 1),
PIN_FIELD_BASE(36, 36, 6, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(37, 37, 6, 0x0070, 0x10, 6, 1),
PIN_FIELD_BASE(38, 41, 6, 0x0070, 0x10, 1, 1),
PIN_FIELD_BASE(42, 43, 6, 0x0060, 0x10, 1, 1),
PIN_FIELD_BASE(44, 44, 6, 0x0060, 0x10, 18, 1),
PIN_FIELD_BASE(45, 45, 5, 0x0070, 0x10, 17, 1),
PIN_FIELD_BASE(46, 46, 5, 0x0070, 0x10, 23, 1),
PIN_FIELD_BASE(47, 47, 5, 0x0070, 0x10, 29, 1),
PIN_FIELD_BASE(48, 48, 5, 0x0070, 0x10, 28, 1),
PIN_FIELD_BASE(49, 49, 5, 0x0070, 0x10, 30, 1),
PIN_FIELD_BASE(50, 50, 5, 0x0070, 0x10, 27, 1),
PIN_FIELD_BASE(51, 51, 5, 0x0070, 0x10, 15, 1),
PIN_FIELD_BASE(52, 52, 5, 0x0070, 0x10, 21, 1),
PIN_FIELD_BASE(53, 54, 5, 0x0080, 0x10, 3, 1),
PIN_FIELD_BASE(55, 55, 5, 0x0070, 0x10, 16, 1),
PIN_FIELD_BASE(56, 56, 5, 0x0070, 0x10, 22, 1),
PIN_FIELD_BASE(61, 62, 3, 0x0030, 0x10, 13, 1),
PIN_FIELD_BASE(63, 63, 4, 0x0040, 0x10, 18, 1),
PIN_FIELD_BASE(64, 64, 4, 0x0040, 0x10, 17, 1),
PIN_FIELD_BASE(65, 65, 4, 0x0040, 0x10, 19, 1),
PIN_FIELD_BASE(66, 66, 4, 0x0040, 0x10, 16, 1),
PIN_FIELD_BASE(67, 67, 2, 0x0080, 0x10, 7, 1),
PIN_FIELD_BASE(68, 68, 2, 0x0080, 0x10, 6, 1),
PIN_FIELD_BASE(69, 69, 2, 0x0080, 0x10, 8, 1),
PIN_FIELD_BASE(70, 71, 2, 0x0080, 0x10, 4, 1),
PIN_FIELD_BASE(72, 72, 3, 0x0030, 0x10, 3, 1),
PIN_FIELD_BASE(73, 73, 3, 0x0030, 0x10, 2, 1),
PIN_FIELD_BASE(74, 74, 3, 0x0030, 0x10, 1, 1),
PIN_FIELD_BASE(75, 75, 3, 0x0030, 0x10, 4, 1),
PIN_FIELD_BASE(76, 76, 3, 0x0030, 0x10, 11, 1),
PIN_FIELD_BASE(77, 77, 3, 0x0030, 0x10, 10, 1),
PIN_FIELD_BASE(78, 78, 2, 0x0070, 0x10, 18, 1),
PIN_FIELD_BASE(79, 79, 2, 0x0070, 0x10, 17, 1),
PIN_FIELD_BASE(80, 81, 2, 0x0070, 0x10, 19, 1),
PIN_FIELD_BASE(82, 88, 2, 0x0070, 0x10, 1, 1),
PIN_FIELD_BASE(89, 89, 2, 0x0070, 0x10, 16, 1),
PIN_FIELD_BASE(90, 90, 2, 0x0070, 0x10, 15, 1),
PIN_FIELD_BASE(91, 91, 2, 0x0070, 0x10, 14, 1),
PIN_FIELD_BASE(92, 92, 2, 0x0070, 0x10, 8, 1),
PIN_FIELD_BASE(93, 93, 3, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(94, 94, 2, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(95, 95, 3, 0x0030, 0x10, 7, 1),
PIN_FIELD_BASE(96, 96, 3, 0x0030, 0x10, 5, 1),
PIN_FIELD_BASE(97, 97, 3, 0x0030, 0x10, 8, 1),
PIN_FIELD_BASE(98, 98, 3, 0x0030, 0x10, 6, 1),
PIN_FIELD_BASE(99, 99, 2, 0x0080, 0x10, 9, 1),
PIN_FIELD_BASE(100, 100, 2, 0x0080, 0x10, 12, 1),
PIN_FIELD_BASE(101, 101, 2, 0x0080, 0x10, 10, 1),
PIN_FIELD_BASE(102, 102, 2, 0x0080, 0x10, 13, 1),
PIN_FIELD_BASE(103, 103, 2, 0x0080, 0x10, 11, 1),
PIN_FIELD_BASE(104, 104, 2, 0x0080, 0x10, 14, 1),
PIN_FIELD_BASE(105, 105, 2, 0x0070, 0x10, 10, 1),
PIN_FIELD_BASE(106, 106, 2, 0x0070, 0x10, 9, 1),
PIN_FIELD_BASE(107, 108, 2, 0x0070, 0x10, 12, 1),
PIN_FIELD_BASE(109, 109, 2, 0x0070, 0x10, 11, 1),
PIN_FIELD_BASE(110, 110, 2, 0x0080, 0x10, 16, 1),
PIN_FIELD_BASE(111, 111, 2, 0x0080, 0x10, 18, 1),
PIN_FIELD_BASE(112, 112, 2, 0x0080, 0x10, 15, 1),
PIN_FIELD_BASE(113, 113, 2, 0x0080, 0x10, 17, 1),
PIN_FIELD_BASE(114, 115, 2, 0x0070, 0x10, 26, 1),
PIN_FIELD_BASE(116, 117, 2, 0x0070, 0x10, 21, 1),
PIN_FIELD_BASE(118, 118, 2, 0x0070, 0x10, 31, 1),
PIN_FIELD_BASE(119, 119, 2, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(120, 121, 2, 0x0070, 0x10, 23, 1),
PIN_FIELD_BASE(122, 123, 2, 0x0070, 0x10, 28, 1),
PIN_FIELD_BASE(124, 125, 2, 0x0080, 0x10, 1, 1),
PIN_FIELD_BASE(126, 127, 1, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(140, 141, 5, 0x0070, 0x10, 12, 1),
PIN_FIELD_BASE(142, 142, 4, 0x0040, 0x10, 20, 1),
PIN_FIELD_BASE(143, 143, 4, 0x0040, 0x10, 6, 1),
PIN_FIELD_BASE(144, 144, 4, 0x0040, 0x10, 8, 1),
PIN_FIELD_BASE(145, 145, 4, 0x0040, 0x10, 7, 1),
PIN_FIELD_BASE(146, 146, 4, 0x0040, 0x10, 3, 1),
PIN_FIELD_BASE(147, 149, 5, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(150, 150, 5, 0x0080, 0x10, 2, 1),
PIN_FIELD_BASE(151, 151, 5, 0x0070, 0x10, 26, 1),
PIN_FIELD_BASE(152, 152, 5, 0x0070, 0x10, 20, 1),
PIN_FIELD_BASE(153, 153, 5, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(154, 154, 5, 0x0070, 0x10, 25, 1),
PIN_FIELD_BASE(155, 155, 5, 0x0070, 0x10, 19, 1),
PIN_FIELD_BASE(156, 157, 5, 0x0070, 0x10, 6, 1),
PIN_FIELD_BASE(158, 158, 5, 0x0070, 0x10, 5, 1),
PIN_FIELD_BASE(159, 159, 5, 0x0070, 0x10, 8, 1),
PIN_FIELD_BASE(160, 161, 5, 0x0070, 0x10, 3, 1),
PIN_FIELD_BASE(162, 164, 5, 0x0070, 0x10, 9, 1),
PIN_FIELD_BASE(165, 165, 5, 0x0070, 0x10, 31, 1),
PIN_FIELD_BASE(166, 166, 5, 0x0080, 0x10, 1, 1),
PIN_FIELD_BASE(179, 179, 3, 0x0030, 0x10, 12, 1),
PIN_FIELD_BASE(180, 180, 3, 0x0030, 0x10, 9, 1),
PIN_FIELD_BASE(181, 182, 4, 0x0040, 0x10, 21, 1),
PIN_FIELD_BASE(183, 183, 4, 0x0040, 0x10, 24, 1),
PIN_FIELD_BASE(184, 184, 4, 0x0040, 0x10, 13, 1),
PIN_FIELD_BASE(185, 185, 4, 0x0040, 0x10, 12, 1),
PIN_FIELD_BASE(186, 186, 4, 0x0040, 0x10, 14, 1),
PIN_FIELD_BASE(187, 187, 4, 0x0040, 0x10, 11, 1),
PIN_FIELD_BASE(188, 188, 4, 0x0040, 0x10, 15, 1),
PIN_FIELD_BASE(189, 189, 4, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(190, 190, 4, 0x0040, 0x10, 9, 1),
PIN_FIELD_BASE(191, 192, 4, 0x0040, 0x10, 4, 1),
PIN_FIELD_BASE(193, 194, 4, 0x0040, 0x10, 1, 1),
PIN_FIELD_BASE(195, 195, 2, 0x0070, 0x10, 30, 1),
PIN_FIELD_BASE(196, 196, 2, 0x0070, 0x10, 25, 1),
PIN_FIELD_BASE(197, 197, 2, 0x0080, 0x10, 3, 1),
PIN_FIELD_BASE(198, 198, 5, 0x0070, 0x10, 18, 1),
PIN_FIELD_BASE(199, 199, 5, 0x0070, 0x10, 24, 1),
PIN_FIELD_BASE(200, 201, 6, 0x0070, 0x10, 7, 1),
PIN_FIELD_BASE(202, 202, 5, 0x0070, 0x10, 14, 1),
};
static const struct mtk_pin_field_calc mt6785_pin_pupd_range[] = {
PIN_FIELD_BASE(10, 15, 4, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(57, 57, 5, 0x0090, 0x10, 3, 1),
PIN_FIELD_BASE(58, 58, 5, 0x0090, 0x10, 2, 1),
PIN_FIELD_BASE(59, 60, 5, 0x0090, 0x10, 0, 1),
PIN_FIELD_BASE(128, 129, 1, 0x0060, 0x10, 7, 1),
PIN_FIELD_BASE(130, 130, 1, 0x0060, 0x10, 6, 1),
PIN_FIELD_BASE(131, 131, 1, 0x0060, 0x10, 9, 1),
PIN_FIELD_BASE(132, 132, 1, 0x0060, 0x10, 11, 1),
PIN_FIELD_BASE(133, 133, 1, 0x0060, 0x10, 10, 1),
PIN_FIELD_BASE(134, 135, 1, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(136, 136, 1, 0x0060, 0x10, 5, 1),
PIN_FIELD_BASE(137, 137, 1, 0x0060, 0x10, 2, 1),
PIN_FIELD_BASE(138, 138, 1, 0x0060, 0x10, 4, 1),
PIN_FIELD_BASE(139, 139, 1, 0x0060, 0x10, 3, 1),
PIN_FIELD_BASE(167, 168, 7, 0x0020, 0x10, 1, 1),
PIN_FIELD_BASE(169, 169, 7, 0x0020, 0x10, 4, 1),
PIN_FIELD_BASE(170, 170, 7, 0x0020, 0x10, 6, 1),
PIN_FIELD_BASE(171, 171, 7, 0x0020, 0x10, 8, 1),
PIN_FIELD_BASE(172, 172, 7, 0x0020, 0x10, 3, 1),
PIN_FIELD_BASE(173, 173, 7, 0x0020, 0x10, 7, 1),
PIN_FIELD_BASE(174, 175, 7, 0x0020, 0x10, 9, 1),
PIN_FIELD_BASE(176, 176, 7, 0x0020, 0x10, 0, 1),
PIN_FIELD_BASE(177, 177, 7, 0x0020, 0x10, 5, 1),
PIN_FIELD_BASE(178, 178, 7, 0x0020, 0x10, 11, 1),
};
static const struct mtk_pin_field_calc mt6785_pin_r0_range[] = {
PIN_FIELD_BASE(10, 15, 4, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(57, 57, 5, 0x00c0, 0x10, 3, 1),
PIN_FIELD_BASE(58, 58, 5, 0x00c0, 0x10, 2, 1),
PIN_FIELD_BASE(59, 60, 5, 0x00c0, 0x10, 0, 1),
PIN_FIELD_BASE(128, 129, 1, 0x0080, 0x10, 7, 1),
PIN_FIELD_BASE(130, 130, 1, 0x0080, 0x10, 6, 1),
PIN_FIELD_BASE(131, 131, 1, 0x0080, 0x10, 9, 1),
PIN_FIELD_BASE(132, 132, 1, 0x0080, 0x10, 11, 1),
PIN_FIELD_BASE(133, 133, 1, 0x0080, 0x10, 10, 1),
PIN_FIELD_BASE(134, 135, 1, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(136, 136, 1, 0x0080, 0x10, 5, 1),
PIN_FIELD_BASE(137, 137, 1, 0x0080, 0x10, 2, 1),
PIN_FIELD_BASE(138, 138, 1, 0x0080, 0x10, 4, 1),
PIN_FIELD_BASE(139, 139, 1, 0x0080, 0x10, 3, 1),
PIN_FIELD_BASE(167, 168, 7, 0x0030, 0x10, 1, 1),
PIN_FIELD_BASE(169, 169, 7, 0x0030, 0x10, 4, 1),
PIN_FIELD_BASE(170, 170, 7, 0x0030, 0x10, 6, 1),
PIN_FIELD_BASE(171, 171, 7, 0x0030, 0x10, 8, 1),
PIN_FIELD_BASE(172, 172, 7, 0x0030, 0x10, 3, 1),
PIN_FIELD_BASE(173, 173, 7, 0x0030, 0x10, 7, 1),
PIN_FIELD_BASE(174, 175, 7, 0x0030, 0x10, 9, 1),
PIN_FIELD_BASE(176, 176, 7, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(177, 177, 7, 0x0030, 0x10, 5, 1),
PIN_FIELD_BASE(178, 178, 7, 0x0030, 0x10, 11, 1),
};
static const struct mtk_pin_field_calc mt6785_pin_r1_range[] = {
PIN_FIELD_BASE(10, 15, 4, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(57, 57, 5, 0x00d0, 0x10, 3, 1),
PIN_FIELD_BASE(58, 58, 5, 0x00d0, 0x10, 2, 1),
PIN_FIELD_BASE(59, 60, 5, 0x00d0, 0x10, 0, 1),
PIN_FIELD_BASE(128, 129, 1, 0x0090, 0x10, 7, 1),
PIN_FIELD_BASE(130, 130, 1, 0x0090, 0x10, 6, 1),
PIN_FIELD_BASE(131, 131, 1, 0x0090, 0x10, 9, 1),
PIN_FIELD_BASE(132, 132, 1, 0x0090, 0x10, 11, 1),
PIN_FIELD_BASE(133, 133, 1, 0x0090, 0x10, 10, 1),
PIN_FIELD_BASE(134, 135, 1, 0x0090, 0x10, 0, 1),
PIN_FIELD_BASE(136, 136, 1, 0x0090, 0x10, 5, 1),
PIN_FIELD_BASE(137, 137, 1, 0x0090, 0x10, 2, 1),
PIN_FIELD_BASE(138, 138, 1, 0x0090, 0x10, 4, 1),
PIN_FIELD_BASE(139, 139, 1, 0x0090, 0x10, 3, 1),
PIN_FIELD_BASE(167, 168, 7, 0x0040, 0x10, 1, 1),
PIN_FIELD_BASE(169, 169, 7, 0x0040, 0x10, 4, 1),
PIN_FIELD_BASE(170, 170, 7, 0x0040, 0x10, 6, 1),
PIN_FIELD_BASE(171, 171, 7, 0x0040, 0x10, 8, 1),
PIN_FIELD_BASE(172, 172, 7, 0x0040, 0x10, 3, 1),
PIN_FIELD_BASE(173, 173, 7, 0x0040, 0x10, 7, 1),
PIN_FIELD_BASE(174, 175, 7, 0x0040, 0x10, 9, 1),
PIN_FIELD_BASE(176, 176, 7, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(177, 177, 7, 0x0040, 0x10, 5, 1),
PIN_FIELD_BASE(178, 178, 7, 0x0040, 0x10, 11, 1),
};
static const struct mtk_pin_field_calc mt6785_pin_drv_range[] = {
PINS_FIELD_BASE(0, 9, 6, 0x0000, 0x10, 9, 3),
PIN_FIELD_BASE(10, 16, 4, 0x0000, 0x10, 6, 3),
PINS_FIELD_BASE(17, 19, 6, 0x0010, 0x10, 3, 3),
PIN_FIELD_BASE(20, 20, 6, 0x0010, 0x10, 6, 3),
PINS_FIELD_BASE(21, 24, 6, 0x0000, 0x10, 21, 3),
PIN_FIELD_BASE(25, 25, 6, 0x0010, 0x10, 9, 3),
PIN_FIELD_BASE(26, 26, 6, 0x0000, 0x10, 24, 3),
PIN_FIELD_BASE(27, 27, 6, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(28, 28, 6, 0x0000, 0x10, 27, 3),
PIN_FIELD_BASE(29, 29, 6, 0x0010, 0x10, 0, 3),
PINS_FIELD_BASE(30, 32, 6, 0x0000, 0x10, 12, 3),
PIN_FIELD_BASE(33, 33, 6, 0x0000, 0x10, 15, 3),
PIN_FIELD_BASE(34, 34, 6, 0x0000, 0x10, 12, 3),
PINS_FIELD_BASE(35, 41, 6, 0x0010, 0x10, 12, 3),
PIN_FIELD_BASE(42, 43, 6, 0x0000, 0x10, 3, 3),
PIN_FIELD_BASE(44, 44, 6, 0x0000, 0x10, 18, 3),
PIN_FIELD_BASE(45, 45, 5, 0x0010, 0x10, 18, 3),
PIN_FIELD_BASE(46, 46, 5, 0x0020, 0x10, 6, 3),
PINS_FIELD_BASE(47, 49, 5, 0x0020, 0x10, 18, 3),
PIN_FIELD_BASE(50, 50, 5, 0x0020, 0x10, 21, 3),
PIN_FIELD_BASE(51, 51, 5, 0x0010, 0x10, 12, 3),
PIN_FIELD_BASE(52, 52, 5, 0x0020, 0x10, 0, 3),
PINS_FIELD_BASE(53, 54, 5, 0x0030, 0x10, 0, 3),
PIN_FIELD_BASE(55, 55, 5, 0x0010, 0x10, 15, 3),
PIN_FIELD_BASE(56, 56, 5, 0x0020, 0x10, 3, 3),
PIN_FIELD_BASE(57, 57, 5, 0x0010, 0x10, 6, 3),
PIN_FIELD_BASE(58, 58, 5, 0x0010, 0x10, 3, 3),
PIN_FIELD_BASE(59, 59, 5, 0x0000, 0x10, 27, 3),
PIN_FIELD_BASE(60, 60, 5, 0x0010, 0x10, 0, 3),
PIN_FIELD_BASE(61, 62, 3, 0x0000, 0x10, 18, 3),
PINS_FIELD_BASE(63, 65, 4, 0x0010, 0x10, 6, 3),
PIN_FIELD_BASE(66, 66, 4, 0x0010, 0x10, 9, 3),
PINS_FIELD_BASE(67, 69, 2, 0x0010, 0x10, 3, 3),
PIN_FIELD_BASE(70, 71, 2, 0x0010, 0x10, 0, 3),
PINS_FIELD_BASE(72, 75, 3, 0x0000, 0x10, 0, 3),
PINS_FIELD_BASE(76, 77, 3, 0x0000, 0x10, 12, 3),
PINS_FIELD_BASE(78, 86, 2, 0x0000, 0x10, 3, 3),
PINS_FIELD_BASE(87, 92, 2, 0x0000, 0x10, 6, 3),
PIN_FIELD_BASE(93, 93, 3, 0x0000, 0x10, 3, 3),
PIN_FIELD_BASE(94, 94, 2, 0x0000, 0x10, 6, 3),
PINS_FIELD_BASE(95, 96, 3, 0x0000, 0x10, 6, 3),
PINS_FIELD_BASE(97, 98, 3, 0x0000, 0x10, 9, 3),
PINS_FIELD_BASE(99, 100, 2, 0x0010, 0x10, 6, 3),
PINS_FIELD_BASE(101, 102, 2, 0x0010, 0x10, 9, 3),
PINS_FIELD_BASE(103, 104, 2, 0x0010, 0x10, 12, 3),
PINS_FIELD_BASE(105, 109, 2, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(110, 110, 2, 0x0010, 0x10, 18, 3),
PIN_FIELD_BASE(111, 111, 2, 0x0010, 0x10, 24, 3),
PIN_FIELD_BASE(112, 112, 2, 0x0010, 0x10, 15, 3),
PIN_FIELD_BASE(113, 113, 2, 0x0010, 0x10, 21, 3),
PINS_FIELD_BASE(114, 115, 2, 0x0000, 0x10, 12, 3),
PIN_FIELD_BASE(116, 117, 2, 0x0000, 0x10, 15, 3),
PINS_FIELD_BASE(118, 119, 2, 0x0000, 0x10, 12, 3),
PIN_FIELD_BASE(120, 121, 2, 0x0000, 0x10, 21, 3),
PINS_FIELD_BASE(122, 125, 2, 0x0000, 0x10, 9, 3),
PINS_FIELD_BASE(126, 127, 1, 0x0000, 0x10, 9, 3),
PIN_FIELD_BASE(128, 129, 1, 0x0000, 0x10, 14, 2),
PIN_FIELD_BASE(130, 130, 1, 0x0000, 0x10, 12, 2),
PIN_FIELD_BASE(131, 131, 1, 0x0000, 0x10, 18, 2),
PIN_FIELD_BASE(132, 132, 1, 0x0000, 0x10, 22, 2),
PIN_FIELD_BASE(133, 133, 1, 0x0000, 0x10, 20, 2),
PIN_FIELD_BASE(134, 135, 1, 0x0000, 0x10, 0, 3),
PINS_FIELD_BASE(136, 139, 1, 0x0000, 0x10, 6, 3),
PINS_FIELD_BASE(140, 141, 5, 0x0000, 0x10, 24, 3),
PIN_FIELD_BASE(142, 142, 4, 0x0010, 0x10, 12, 3),
PINS_FIELD_BASE(143, 146, 4, 0x0000, 0x10, 0, 3),
PINS_FIELD_BASE(147, 149, 5, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(150, 150, 5, 0x0020, 0x10, 24, 3),
PIN_FIELD_BASE(151, 151, 5, 0x0020, 0x10, 15, 3),
PIN_FIELD_BASE(152, 152, 5, 0x0010, 0x10, 27, 3),
PIN_FIELD_BASE(153, 153, 5, 0x0020, 0x10, 24, 3),
PIN_FIELD_BASE(154, 154, 5, 0x0020, 0x10, 12, 3),
PIN_FIELD_BASE(155, 155, 5, 0x0010, 0x10, 24, 3),
PIN_FIELD_BASE(156, 157, 5, 0x0000, 0x10, 15, 3),
PIN_FIELD_BASE(158, 158, 5, 0x0000, 0x10, 9, 3),
PIN_FIELD_BASE(159, 159, 5, 0x0000, 0x10, 21, 3),
PIN_FIELD_BASE(160, 161, 5, 0x0000, 0x10, 3, 3),
PINS_FIELD_BASE(162, 164, 5, 0x0000, 0x10, 12, 3),
PIN_FIELD_BASE(165, 165, 5, 0x0020, 0x10, 27, 3),
PIN_FIELD_BASE(166, 166, 5, 0x0020, 0x10, 24, 3),
PIN_FIELD_BASE(167, 167, 7, 0x0000, 0x10, 3, 3),
PINS_FIELD_BASE(168, 174, 7, 0x0000, 0x10, 6, 3),
PIN_FIELD_BASE(175, 175, 7, 0x0000, 0x10, 9, 3),
PIN_FIELD_BASE(176, 176, 7, 0x0000, 0x10, 0, 3),
PINS_FIELD_BASE(177, 178, 7, 0x0000, 0x10, 6, 3),
PIN_FIELD_BASE(179, 180, 3, 0x0000, 0x10, 12, 3),
PIN_FIELD_BASE(181, 183, 4, 0x0010, 0x10, 15, 3),
PINS_FIELD_BASE(184, 186, 4, 0x0000, 0x10, 27, 3),
PIN_FIELD_BASE(187, 188, 4, 0x0010, 0x10, 0, 3),
PIN_FIELD_BASE(189, 189, 4, 0x0000, 0x10, 3, 3),
PINS_FIELD_BASE(190, 194, 4, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(195, 195, 2, 0x0000, 0x10, 9, 3),
PIN_FIELD_BASE(196, 196, 2, 0x0000, 0x10, 27, 3),
PIN_FIELD_BASE(197, 197, 2, 0x0000, 0x10, 9, 3),
PIN_FIELD_BASE(198, 198, 5, 0x0010, 0x10, 21, 3),
PIN_FIELD_BASE(199, 199, 5, 0x0020, 0x10, 9, 3),
PINS_FIELD_BASE(200, 201, 6, 0x0010, 0x10, 15, 3),
PIN_FIELD_BASE(202, 202, 5, 0x0010, 0x10, 9, 3),
};
static const struct mtk_pin_reg_calc mt6785_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt6785_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt6785_pin_dir_range),
[PINCTRL_PIN_REG_DI] = MTK_RANGE(mt6785_pin_di_range),
[PINCTRL_PIN_REG_DO] = MTK_RANGE(mt6785_pin_do_range),
[PINCTRL_PIN_REG_SR] = MTK_RANGE(mt6785_pin_dir_range),
[PINCTRL_PIN_REG_SMT] = MTK_RANGE(mt6785_pin_smt_range),
[PINCTRL_PIN_REG_IES] = MTK_RANGE(mt6785_pin_ies_range),
[PINCTRL_PIN_REG_PU] = MTK_RANGE(mt6785_pin_pu_range),
[PINCTRL_PIN_REG_PD] = MTK_RANGE(mt6785_pin_pd_range),
[PINCTRL_PIN_REG_DRV] = MTK_RANGE(mt6785_pin_drv_range),
[PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt6785_pin_pupd_range),
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt6785_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt6785_pin_r1_range),
};
static const struct mtk_eint_hw mt6785_eint_hw = {
.port_mask = 7,
.ports = 6,
.ap_num = 212,
.db_cnt = 13,
};
static const struct mtk_pin_soc mt6785_data = {
.reg_cal = mt6785_reg_cals,
.pins = mtk_pins_mt6785,
.npins = ARRAY_SIZE(mtk_pins_mt6785),
.ngrps = ARRAY_SIZE(mtk_pins_mt6785),
.nfuncs = 8,
.eint_hw = &mt6785_eint_hw,
.gpio_m = 0,
.race_free_access = true,
.bias_set_combo = mtk_pinconf_bias_set_combo,
.bias_get_combo = mtk_pinconf_bias_get_combo,
.drive_set = mtk_pinconf_drive_set_raw,
.drive_get = mtk_pinconf_drive_get_raw,
};
static const struct of_device_id mt6785_pinctrl_of_match[] = {
{ .compatible = "mediatek,mt6785-pinctrl", },
{ }
};
static int mt6785_pinctrl_probe(struct platform_device *pdev)
{
pr_err("mt6785_pinctrl_probe called\n");
return mtk_paris_pinctrl_probe(pdev, &mt6785_data);
}
static struct platform_driver mt6785_pinctrl_driver = {
.driver = {
.name = "mt6785-pinctrl",
.of_match_table = mt6785_pinctrl_of_match,
.pm = &mtk_eint_pm_ops_v2,
},
.probe = mt6785_pinctrl_probe,
};
static int __init mt6785_pinctrl_init(void)
{
pr_err("mt6785_pinctrl_init called\n");
return platform_driver_register(&mt6785_pinctrl_driver);
}
arch_initcall(mt6785_pinctrl_init);
+82
View File
@@ -0,0 +1,82 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Based on pinctrl-mt6765.c
*
* Copyright (C) 2018 MediaTek Inc.
*
* Author: ZH Chen <zh.chen@mediatek.com>
*
* Copyright (C) Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
*
*/
#include "pinctrl-mtk-mt6797.h"
#include "pinctrl-paris.h"
/*
* MT6797 have multiple bases to program pin configuration listed as the below:
* gpio:0x10005000, iocfg[l]:0x10002000, iocfg[b]:0x10002400,
* iocfg[r]:0x10002800, iocfg[t]:0x10002C00.
* _i_base could be used to indicate what base the pin should be mapped into.
*/
static const struct mtk_pin_field_calc mt6797_pin_mode_range[] = {
PIN_FIELD(0, 261, 0x300, 0x10, 0, 4),
};
static const struct mtk_pin_field_calc mt6797_pin_dir_range[] = {
PIN_FIELD(0, 261, 0x0, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6797_pin_di_range[] = {
PIN_FIELD(0, 261, 0x200, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6797_pin_do_range[] = {
PIN_FIELD(0, 261, 0x100, 0x10, 0, 1),
};
static const struct mtk_pin_reg_calc mt6797_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt6797_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt6797_pin_dir_range),
[PINCTRL_PIN_REG_DI] = MTK_RANGE(mt6797_pin_di_range),
[PINCTRL_PIN_REG_DO] = MTK_RANGE(mt6797_pin_do_range),
};
static const char * const mt6797_pinctrl_register_base_names[] = {
"gpio", "iocfgl", "iocfgb", "iocfgr", "iocfgt",
};
static const struct mtk_pin_soc mt6797_data = {
.reg_cal = mt6797_reg_cals,
.pins = mtk_pins_mt6797,
.npins = ARRAY_SIZE(mtk_pins_mt6797),
.ngrps = ARRAY_SIZE(mtk_pins_mt6797),
.gpio_m = 0,
.base_names = mt6797_pinctrl_register_base_names,
.nbase_names = ARRAY_SIZE(mt6797_pinctrl_register_base_names),
};
static const struct of_device_id mt6797_pinctrl_of_match[] = {
{ .compatible = "mediatek,mt6797-pinctrl", },
{ }
};
static int mt6797_pinctrl_probe(struct platform_device *pdev)
{
return mtk_paris_pinctrl_probe(pdev, &mt6797_data);
}
static struct platform_driver mt6797_pinctrl_driver = {
.driver = {
.name = "mt6797-pinctrl",
.of_match_table = mt6797_pinctrl_of_match,
},
.probe = mt6797_pinctrl_probe,
};
static int __init mt6797_pinctrl_init(void)
{
return platform_driver_register(&mt6797_pinctrl_driver);
}
arch_initcall(mt6797_pinctrl_init);
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+797
View File
@@ -0,0 +1,797 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
* Author: Andy Teng <andy.teng@mediatek.com>
*
*/
#include "pinctrl-mtk-mt6877.h"
#include "pinctrl-paris.h"
/* MT6877 have multiple bases to program pin configuration listed as the below:
* gpio:0x10005000, iocfg_rm:0x11C20000, iocfg_rb:0x11C30000,
* iocfg_bm:0x11D10000, iocfg_bl:0x11D30000, iocfg_br:0x11D40000,
* iocfg_lm:0x11E20000, iocfg_rt:0x11EA0000, iocfg_tl:0x11F30000
* _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)
#define PINS_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, 1)
static const struct mtk_pin_field_calc mt6877_pin_mode_range[] = {
PIN_FIELD_BASE(0, 7, 0, 0x0300, 0x10, 0, 4),
PIN_FIELD_BASE(8, 15, 0, 0x0310, 0x10, 0, 4),
PIN_FIELD_BASE(16, 23, 0, 0x0320, 0x10, 0, 4),
PIN_FIELD_BASE(24, 31, 0, 0x0330, 0x10, 0, 4),
PIN_FIELD_BASE(32, 39, 0, 0x0340, 0x10, 0, 4),
PIN_FIELD_BASE(40, 47, 0, 0x0350, 0x10, 0, 4),
PIN_FIELD_BASE(48, 55, 0, 0x0360, 0x10, 0, 4),
PIN_FIELD_BASE(56, 63, 0, 0x0370, 0x10, 0, 4),
PIN_FIELD_BASE(64, 71, 0, 0x0380, 0x10, 0, 4),
PIN_FIELD_BASE(72, 79, 0, 0x0390, 0x10, 0, 4),
PIN_FIELD_BASE(80, 87, 0, 0x03a0, 0x10, 0, 4),
PIN_FIELD_BASE(88, 95, 0, 0x03b0, 0x10, 0, 4),
PIN_FIELD_BASE(96, 103, 0, 0x03c0, 0x10, 0, 4),
PIN_FIELD_BASE(104, 111, 0, 0x03d0, 0x10, 0, 4),
PIN_FIELD_BASE(112, 119, 0, 0x03e0, 0x10, 0, 4),
PIN_FIELD_BASE(120, 127, 0, 0x03f0, 0x10, 0, 4),
PIN_FIELD_BASE(128, 135, 0, 0x0400, 0x10, 0, 4),
PIN_FIELD_BASE(136, 143, 0, 0x0410, 0x10, 0, 4),
PIN_FIELD_BASE(144, 151, 0, 0x0420, 0x10, 0, 4),
PIN_FIELD_BASE(152, 159, 0, 0x0430, 0x10, 0, 4),
PIN_FIELD_BASE(160, 167, 0, 0x0440, 0x10, 0, 4),
PIN_FIELD_BASE(168, 175, 0, 0x0450, 0x10, 0, 4),
PIN_FIELD_BASE(176, 183, 0, 0x0460, 0x10, 0, 4),
PIN_FIELD_BASE(184, 191, 0, 0x0470, 0x10, 0, 4),
PIN_FIELD_BASE(192, 199, 0, 0x0480, 0x10, 0, 4),
PIN_FIELD_BASE(200, 207, 0, 0x0490, 0x10, 0, 4),
PIN_FIELD_BASE(208, 208, 0, 0x04a0, 0x10, 0, 4),
};
static const struct mtk_pin_field_calc mt6877_pin_dir_range[] = {
PIN_FIELD_BASE(0, 31, 0, 0x0000, 0x10, 0, 1),
PIN_FIELD_BASE(32, 63, 0, 0x0010, 0x10, 0, 1),
PIN_FIELD_BASE(64, 95, 0, 0x0020, 0x10, 0, 1),
PIN_FIELD_BASE(96, 127, 0, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(128, 159, 0, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(160, 191, 0, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(192, 208, 0, 0x0060, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6877_pin_di_range[] = {
PIN_FIELD_BASE(0, 31, 0, 0x0200, 0x10, 0, 1),
PIN_FIELD_BASE(32, 63, 0, 0x0210, 0x10, 0, 1),
PIN_FIELD_BASE(64, 95, 0, 0x0220, 0x10, 0, 1),
PIN_FIELD_BASE(96, 127, 0, 0x0230, 0x10, 0, 1),
PIN_FIELD_BASE(128, 159, 0, 0x0240, 0x10, 0, 1),
PIN_FIELD_BASE(160, 191, 0, 0x0250, 0x10, 0, 1),
PIN_FIELD_BASE(192, 208, 0, 0x0260, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6877_pin_do_range[] = {
PIN_FIELD_BASE(0, 31, 0, 0x0100, 0x10, 0, 1),
PIN_FIELD_BASE(32, 63, 0, 0x0110, 0x10, 0, 1),
PIN_FIELD_BASE(64, 95, 0, 0x0120, 0x10, 0, 1),
PIN_FIELD_BASE(96, 127, 0, 0x0130, 0x10, 0, 1),
PIN_FIELD_BASE(128, 159, 0, 0x0140, 0x10, 0, 1),
PIN_FIELD_BASE(160, 191, 0, 0x0150, 0x10, 0, 1),
PIN_FIELD_BASE(192, 208, 0, 0x0160, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6877_pin_smt_range[] = {
PINS_FIELD_BASE(0, 2, 5, 0x0100, 0x10, 20, 1),
PIN_FIELD_BASE(3, 3, 5, 0x0100, 0x10, 18, 1),
PINS_FIELD_BASE(4, 5, 5, 0x0100, 0x10, 19, 1),
PINS_FIELD_BASE(6, 7, 5, 0x0100, 0x10, 14, 1),
PIN_FIELD_BASE(8, 8, 5, 0x0100, 0x10, 12, 1),
PINS_FIELD_BASE(9, 11, 5, 0x0100, 0x10, 17, 1),
PINS_FIELD_BASE(12, 13, 6, 0x00b0, 0x10, 0, 1),
PINS_FIELD_BASE(14, 15, 8, 0x00f0, 0x10, 12, 1),
PINS_FIELD_BASE(16, 20, 3, 0x00f0, 0x10, 7, 1),
PINS_FIELD_BASE(21, 22, 3, 0x00f0, 0x10, 3, 1),
PIN_FIELD_BASE(23, 23, 3, 0x00f0, 0x10, 6, 1),
PIN_FIELD_BASE(24, 24, 8, 0x00f0, 0x10, 10, 1),
PIN_FIELD_BASE(25, 26, 8, 0x00f0, 0x10, 0, 1),
PIN_FIELD_BASE(27, 27, 8, 0x00f0, 0x10, 11, 1),
PIN_FIELD_BASE(28, 35, 8, 0x00f0, 0x10, 2, 1),
PIN_FIELD_BASE(36, 37, 8, 0x00f0, 0x10, 14, 1),
PINS_FIELD_BASE(38, 39, 8, 0x00f0, 0x10, 12, 1),
PIN_FIELD_BASE(40, 40, 8, 0x00f0, 0x10, 13, 1),
PINS_FIELD_BASE(41, 44, 6, 0x00b0, 0x10, 1, 1),
PIN_FIELD_BASE(45, 45, 6, 0x00b0, 0x10, 5, 1),
PINS_FIELD_BASE(46, 47, 6, 0x00b0, 0x10, 2, 1),
PIN_FIELD_BASE(48, 48, 6, 0x00b0, 0x10, 3, 1),
PIN_FIELD_BASE(49, 49, 6, 0x00b0, 0x10, 12, 1),
PIN_FIELD_BASE(50, 51, 6, 0x00b0, 0x10, 3, 1),
PINS_FIELD_BASE(52, 53, 6, 0x00b0, 0x10, 3, 1),
PIN_FIELD_BASE(54, 54, 6, 0x00b0, 0x10, 5, 1),
PINS_FIELD_BASE(55, 57, 6, 0x00b0, 0x10, 4, 1),
PINS_FIELD_BASE(58, 59, 6, 0x00b0, 0x10, 2, 1),
PIN_FIELD_BASE(60, 63, 6, 0x00b0, 0x10, 8, 1),
PIN_FIELD_BASE(64, 65, 6, 0x00b0, 0x10, 6, 1),
PINS_FIELD_BASE(66, 67, 4, 0x0090, 0x10, 11, 1),
PINS_FIELD_BASE(68, 69, 4, 0x0090, 0x10, 10, 1),
PIN_FIELD_BASE(70, 70, 4, 0x0090, 0x10, 1, 1),
PINS_FIELD_BASE(71, 74, 4, 0x0090, 0x10, 2, 1),
PINS_FIELD_BASE(75, 78, 4, 0x0090, 0x10, 3, 1),
PINS_FIELD_BASE(79, 81, 4, 0x0090, 0x10, 4, 1),
PINS_FIELD_BASE(82, 83, 4, 0x0090, 0x10, 9, 1),
PINS_FIELD_BASE(84, 85, 4, 0x0090, 0x10, 8, 1),
PIN_FIELD_BASE(86, 86, 4, 0x0090, 0x10, 1, 1),
PIN_FIELD_BASE(87, 87, 4, 0x0090, 0x10, 4, 1),
PINS_FIELD_BASE(88, 91, 4, 0x0090, 0x10, 5, 1),
PINS_FIELD_BASE(92, 95, 4, 0x0090, 0x10, 6, 1),
PINS_FIELD_BASE(96, 97, 4, 0x0090, 0x10, 7, 1),
PIN_FIELD_BASE(98, 98, 4, 0x0090, 0x10, 0, 1),
PIN_FIELD_BASE(99, 99, 3, 0x00f0, 0x10, 5, 1),
PIN_FIELD_BASE(100, 100, 3, 0x00f0, 0x10, 9, 1),
PIN_FIELD_BASE(101, 101, 4, 0x0090, 0x10, 0, 1),
PIN_FIELD_BASE(102, 102, 3, 0x00f0, 0x10, 9, 1),
PINS_FIELD_BASE(103, 104, 3, 0x00f0, 0x10, 8, 1),
PIN_FIELD_BASE(105, 105, 3, 0x00f0, 0x10, 9, 1),
PIN_FIELD_BASE(106, 106, 3, 0x00f0, 0x10, 6, 1),
PINS_FIELD_BASE(107, 108, 3, 0x00f0, 0x10, 10, 1),
PIN_FIELD_BASE(109, 110, 3, 0x00f0, 0x10, 1, 1),
PIN_FIELD_BASE(111, 111, 5, 0x0100, 0x10, 13, 1),
PIN_FIELD_BASE(112, 112, 3, 0x00f0, 0x10, 9, 1),
PINS_FIELD_BASE(113, 114, 3, 0x00f0, 0x10, 13, 1),
PIN_FIELD_BASE(115, 115, 3, 0x00f0, 0x10, 11, 1),
PIN_FIELD_BASE(116, 118, 3, 0x00f0, 0x10, 10, 1),
PIN_FIELD_BASE(119, 119, 3, 0x00f0, 0x10, 11, 1),
PIN_FIELD_BASE(120, 120, 3, 0x00f0, 0x10, 4, 1),
PIN_FIELD_BASE(121, 121, 3, 0x00f0, 0x10, 11, 1),
PIN_FIELD_BASE(122, 122, 3, 0x00f0, 0x10, 10, 1),
PINS_FIELD_BASE(123, 125, 3, 0x00f0, 0x10, 12, 1),
PINS_FIELD_BASE(126, 127, 3, 0x00f0, 0x10, 13, 1),
PIN_FIELD_BASE(128, 128, 5, 0x0100, 0x10, 19, 1),
PIN_FIELD_BASE(129, 129, 5, 0x0100, 0x10, 18, 1),
PIN_FIELD_BASE(130, 130, 5, 0x0100, 0x10, 23, 1),
PIN_FIELD_BASE(131, 131, 3, 0x00f0, 0x10, 14, 1),
PIN_FIELD_BASE(132, 133, 5, 0x0100, 0x10, 21, 1),
PIN_FIELD_BASE(134, 134, 5, 0x0100, 0x10, 5, 1),
PIN_FIELD_BASE(135, 135, 5, 0x0100, 0x10, 9, 1),
PIN_FIELD_BASE(136, 136, 3, 0x00f0, 0x10, 0, 1),
PIN_FIELD_BASE(137, 137, 5, 0x0100, 0x10, 10, 1),
PIN_FIELD_BASE(138, 138, 5, 0x0100, 0x10, 15, 1),
PIN_FIELD_BASE(139, 139, 5, 0x0100, 0x10, 14, 1),
PIN_FIELD_BASE(140, 140, 5, 0x0100, 0x10, 19, 1),
PIN_FIELD_BASE(141, 141, 5, 0x0100, 0x10, 18, 1),
PIN_FIELD_BASE(142, 142, 3, 0x00f0, 0x10, 6, 1),
PIN_FIELD_BASE(143, 143, 5, 0x0100, 0x10, 3, 1),
PIN_FIELD_BASE(144, 144, 5, 0x0100, 0x10, 7, 1),
PIN_FIELD_BASE(145, 145, 5, 0x0100, 0x10, 4, 1),
PIN_FIELD_BASE(146, 146, 5, 0x0100, 0x10, 8, 1),
PIN_FIELD_BASE(147, 147, 5, 0x0100, 0x10, 6, 1),
PIN_FIELD_BASE(148, 148, 5, 0x0100, 0x10, 11, 1),
PIN_FIELD_BASE(149, 153, 2, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(154, 154, 2, 0x0060, 0x10, 6, 1),
PIN_FIELD_BASE(155, 155, 5, 0x0100, 0x10, 17, 1),
PIN_FIELD_BASE(156, 156, 2, 0x0060, 0x10, 5, 1),
PIN_FIELD_BASE(157, 157, 5, 0x0100, 0x10, 1, 1),
PIN_FIELD_BASE(158, 158, 2, 0x0060, 0x10, 7, 1),
PIN_FIELD_BASE(159, 159, 2, 0x0060, 0x10, 6, 1),
PINS_FIELD_BASE(160, 161, 5, 0x0100, 0x10, 16, 1),
PIN_FIELD_BASE(162, 162, 5, 0x0100, 0x10, 0, 1),
PIN_FIELD_BASE(163, 163, 5, 0x0100, 0x10, 2, 1),
PIN_FIELD_BASE(164, 164, 1, 0x00a0, 0x10, 1, 1),
PIN_FIELD_BASE(165, 165, 1, 0x00a0, 0x10, 0, 1),
PIN_FIELD_BASE(166, 166, 1, 0x00a0, 0x10, 5, 1),
PIN_FIELD_BASE(167, 168, 1, 0x00a0, 0x10, 3, 1),
PIN_FIELD_BASE(169, 169, 1, 0x00a0, 0x10, 2, 1),
PIN_FIELD_BASE(170, 170, 1, 0x00a0, 0x10, 10, 1),
PIN_FIELD_BASE(171, 171, 1, 0x00a0, 0x10, 9, 1),
PIN_FIELD_BASE(172, 172, 1, 0x00a0, 0x10, 11, 1),
PIN_FIELD_BASE(173, 173, 1, 0x00a0, 0x10, 8, 1),
PIN_FIELD_BASE(174, 175, 1, 0x00a0, 0x10, 6, 1),
PINS_FIELD_BASE(176, 177, 7, 0x00d0, 0x10, 10, 1),
PINS_FIELD_BASE(178, 179, 7, 0x00d0, 0x10, 7, 1),
PINS_FIELD_BASE(180, 181, 7, 0x00d0, 0x10, 10, 1),
PINS_FIELD_BASE(182, 185, 7, 0x00d0, 0x10, 11, 1),
PIN_FIELD_BASE(186, 187, 7, 0x00d0, 0x10, 12, 1),
PIN_FIELD_BASE(188, 189, 7, 0x00d0, 0x10, 0, 1),
PIN_FIELD_BASE(190, 190, 7, 0x00d0, 0x10, 6, 1),
PIN_FIELD_BASE(191, 195, 7, 0x00d0, 0x10, 2, 1),
PINS_FIELD_BASE(196, 206, 7, 0x00d0, 0x10, 8, 1),
PINS_FIELD_BASE(207, 208, 7, 0x00d0, 0x10, 9, 1),
};
static const struct mtk_pin_field_calc mt6877_pin_ies_range[] = {
PIN_FIELD_BASE(0, 1, 5, 0x0070, 0x10, 15, 1),
PIN_FIELD_BASE(2, 9, 5, 0x0070, 0x10, 19, 1),
PIN_FIELD_BASE(10, 11, 5, 0x0070, 0x10, 17, 1),
PIN_FIELD_BASE(12, 13, 6, 0x0060, 0x10, 10, 1),
PIN_FIELD_BASE(14, 15, 8, 0x0050, 0x10, 2, 1),
PIN_FIELD_BASE(16, 23, 3, 0x0040, 0x10, 2, 1),
PIN_FIELD_BASE(24, 24, 8, 0x0050, 0x10, 15, 1),
PIN_FIELD_BASE(25, 26, 8, 0x0050, 0x10, 5, 1),
PIN_FIELD_BASE(27, 27, 8, 0x0050, 0x10, 16, 1),
PIN_FIELD_BASE(28, 35, 8, 0x0050, 0x10, 7, 1),
PIN_FIELD_BASE(36, 37, 8, 0x0050, 0x10, 17, 1),
PIN_FIELD_BASE(38, 39, 8, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(40, 40, 8, 0x0050, 0x10, 4, 1),
PIN_FIELD_BASE(41, 42, 6, 0x0060, 0x10, 12, 1),
PIN_FIELD_BASE(43, 43, 6, 0x0060, 0x10, 15, 1),
PIN_FIELD_BASE(44, 44, 6, 0x0060, 0x10, 14, 1),
PIN_FIELD_BASE(45, 45, 6, 0x0060, 0x10, 16, 1),
PIN_FIELD_BASE(46, 46, 6, 0x0060, 0x10, 18, 1),
PIN_FIELD_BASE(47, 49, 6, 0x0060, 0x10, 24, 1),
PIN_FIELD_BASE(50, 50, 6, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(51, 51, 6, 0x0060, 0x10, 9, 1),
PIN_FIELD_BASE(52, 54, 6, 0x0060, 0x10, 4, 1),
PIN_FIELD_BASE(55, 55, 6, 0x0060, 0x10, 8, 1),
PIN_FIELD_BASE(56, 56, 6, 0x0060, 0x10, 7, 1),
PIN_FIELD_BASE(57, 59, 6, 0x0060, 0x10, 1, 1),
PIN_FIELD_BASE(60, 63, 6, 0x0060, 0x10, 20, 1),
PIN_FIELD_BASE(64, 64, 6, 0x0060, 0x10, 17, 1),
PIN_FIELD_BASE(65, 65, 6, 0x0060, 0x10, 19, 1),
PIN_FIELD_BASE(66, 67, 4, 0x0020, 0x10, 30, 1),
PIN_FIELD_BASE(68, 69, 4, 0x0020, 0x10, 28, 1),
PIN_FIELD_BASE(70, 70, 4, 0x0020, 0x10, 23, 1),
PIN_FIELD_BASE(71, 72, 4, 0x0020, 0x10, 0, 1),
PIN_FIELD_BASE(73, 73, 4, 0x0020, 0x10, 12, 1),
PIN_FIELD_BASE(74, 80, 4, 0x0020, 0x10, 15, 1),
PIN_FIELD_BASE(81, 81, 4, 0x0020, 0x10, 2, 1),
PIN_FIELD_BASE(82, 83, 4, 0x0020, 0x10, 26, 1),
PIN_FIELD_BASE(84, 85, 4, 0x0020, 0x10, 24, 1),
PIN_FIELD_BASE(86, 86, 4, 0x0020, 0x10, 22, 1),
PIN_FIELD_BASE(87, 95, 4, 0x0020, 0x10, 3, 1),
PIN_FIELD_BASE(96, 97, 4, 0x0020, 0x10, 13, 1),
PIN_FIELD_BASE(98, 98, 4, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(99, 100, 3, 0x0050, 0x10, 4, 1),
PIN_FIELD_BASE(101, 101, 4, 0x0030, 0x10, 1, 1),
PIN_FIELD_BASE(102, 102, 3, 0x0040, 0x10, 19, 1),
PIN_FIELD_BASE(103, 103, 3, 0x0040, 0x10, 16, 1),
PIN_FIELD_BASE(104, 104, 3, 0x0040, 0x10, 18, 1),
PIN_FIELD_BASE(105, 105, 3, 0x0040, 0x10, 10, 1),
PIN_FIELD_BASE(106, 106, 3, 0x0040, 0x10, 17, 1),
PIN_FIELD_BASE(107, 110, 3, 0x0040, 0x10, 25, 1),
PIN_FIELD_BASE(111, 111, 5, 0x0070, 0x10, 31, 1),
PIN_FIELD_BASE(112, 112, 3, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(113, 113, 3, 0x0040, 0x10, 23, 1),
PIN_FIELD_BASE(114, 115, 3, 0x0040, 0x10, 21, 1),
PIN_FIELD_BASE(116, 116, 3, 0x0040, 0x10, 20, 1),
PIN_FIELD_BASE(117, 117, 3, 0x0040, 0x10, 14, 1),
PIN_FIELD_BASE(118, 118, 3, 0x0040, 0x10, 11, 1),
PIN_FIELD_BASE(119, 119, 3, 0x0040, 0x10, 13, 1),
PIN_FIELD_BASE(120, 120, 3, 0x0040, 0x10, 15, 1),
PIN_FIELD_BASE(121, 121, 3, 0x0040, 0x10, 12, 1),
PIN_FIELD_BASE(122, 125, 3, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(126, 127, 3, 0x0040, 0x10, 29, 1),
PIN_FIELD_BASE(128, 129, 5, 0x0080, 0x10, 1, 1),
PIN_FIELD_BASE(130, 130, 5, 0x0080, 0x10, 4, 1),
PIN_FIELD_BASE(131, 131, 3, 0x0040, 0x10, 31, 1),
PIN_FIELD_BASE(132, 132, 5, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(133, 133, 5, 0x0080, 0x10, 3, 1),
PIN_FIELD_BASE(134, 134, 5, 0x0070, 0x10, 8, 1),
PIN_FIELD_BASE(135, 135, 5, 0x0070, 0x10, 12, 1),
PIN_FIELD_BASE(136, 136, 3, 0x0040, 0x10, 1, 1),
PIN_FIELD_BASE(137, 137, 5, 0x0070, 0x10, 13, 1),
PIN_FIELD_BASE(138, 141, 5, 0x0070, 0x10, 27, 1),
PIN_FIELD_BASE(142, 142, 3, 0x0040, 0x10, 24, 1),
PIN_FIELD_BASE(143, 143, 5, 0x0070, 0x10, 6, 1),
PIN_FIELD_BASE(144, 144, 5, 0x0070, 0x10, 10, 1),
PIN_FIELD_BASE(145, 145, 5, 0x0070, 0x10, 7, 1),
PIN_FIELD_BASE(146, 146, 5, 0x0070, 0x10, 11, 1),
PIN_FIELD_BASE(147, 147, 5, 0x0070, 0x10, 9, 1),
PIN_FIELD_BASE(148, 148, 5, 0x0070, 0x10, 14, 1),
PIN_FIELD_BASE(149, 154, 2, 0x0020, 0x10, 0, 1),
PIN_FIELD_BASE(155, 155, 5, 0x0070, 0x10, 2, 1),
PIN_FIELD_BASE(156, 156, 2, 0x0020, 0x10, 6, 1),
PIN_FIELD_BASE(157, 157, 5, 0x0070, 0x10, 3, 1),
PIN_FIELD_BASE(158, 159, 2, 0x0020, 0x10, 7, 1),
PIN_FIELD_BASE(160, 160, 5, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(161, 161, 5, 0x0070, 0x10, 4, 1),
PIN_FIELD_BASE(162, 162, 5, 0x0070, 0x10, 1, 1),
PIN_FIELD_BASE(163, 163, 5, 0x0070, 0x10, 5, 1),
PIN_FIELD_BASE(164, 164, 1, 0x0020, 0x10, 1, 1),
PIN_FIELD_BASE(165, 165, 1, 0x0020, 0x10, 0, 1),
PIN_FIELD_BASE(166, 166, 1, 0x0020, 0x10, 5, 1),
PIN_FIELD_BASE(167, 168, 1, 0x0020, 0x10, 3, 1),
PIN_FIELD_BASE(169, 169, 1, 0x0020, 0x10, 2, 1),
PIN_FIELD_BASE(170, 170, 1, 0x0020, 0x10, 10, 1),
PIN_FIELD_BASE(171, 171, 1, 0x0020, 0x10, 9, 1),
PIN_FIELD_BASE(172, 172, 1, 0x0020, 0x10, 11, 1),
PIN_FIELD_BASE(173, 173, 1, 0x0020, 0x10, 8, 1),
PIN_FIELD_BASE(174, 175, 1, 0x0020, 0x10, 6, 1),
PIN_FIELD_BASE(176, 177, 7, 0x0050, 0x10, 21, 1),
PIN_FIELD_BASE(178, 178, 7, 0x0050, 0x10, 31, 1),
PIN_FIELD_BASE(179, 179, 7, 0x0050, 0x10, 29, 1),
PIN_FIELD_BASE(180, 180, 7, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(181, 181, 7, 0x0050, 0x10, 30, 1),
PIN_FIELD_BASE(182, 185, 7, 0x0050, 0x10, 25, 1),
PIN_FIELD_BASE(186, 187, 7, 0x0050, 0x10, 23, 1),
PIN_FIELD_BASE(188, 198, 7, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(199, 206, 7, 0x0050, 0x10, 13, 1),
PIN_FIELD_BASE(207, 208, 7, 0x0050, 0x10, 11, 1),
};
static const struct mtk_pin_field_calc mt6877_pin_pu_range[] = {
PIN_FIELD_BASE(0, 1, 5, 0x00b0, 0x10, 15, 1),
PIN_FIELD_BASE(2, 9, 5, 0x00b0, 0x10, 19, 1),
PIN_FIELD_BASE(10, 11, 5, 0x00b0, 0x10, 17, 1),
PIN_FIELD_BASE(12, 13, 6, 0x0080, 0x10, 10, 1),
PIN_FIELD_BASE(14, 15, 8, 0x0080, 0x10, 2, 1),
PIN_FIELD_BASE(16, 23, 3, 0x0090, 0x10, 2, 1),
PIN_FIELD_BASE(36, 37, 8, 0x0080, 0x10, 5, 1),
PIN_FIELD_BASE(38, 39, 8, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(40, 40, 8, 0x0080, 0x10, 4, 1),
PIN_FIELD_BASE(41, 42, 6, 0x0080, 0x10, 12, 1),
PIN_FIELD_BASE(43, 43, 6, 0x0080, 0x10, 15, 1),
PIN_FIELD_BASE(44, 44, 6, 0x0080, 0x10, 14, 1),
PIN_FIELD_BASE(45, 45, 6, 0x0080, 0x10, 16, 1),
PIN_FIELD_BASE(46, 46, 6, 0x0080, 0x10, 18, 1),
PIN_FIELD_BASE(47, 49, 6, 0x0080, 0x10, 24, 1),
PIN_FIELD_BASE(50, 50, 6, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(51, 51, 6, 0x0080, 0x10, 9, 1),
PIN_FIELD_BASE(52, 54, 6, 0x0080, 0x10, 4, 1),
PIN_FIELD_BASE(55, 55, 6, 0x0080, 0x10, 8, 1),
PIN_FIELD_BASE(56, 56, 6, 0x0080, 0x10, 7, 1),
PIN_FIELD_BASE(57, 59, 6, 0x0080, 0x10, 1, 1),
PIN_FIELD_BASE(60, 63, 6, 0x0080, 0x10, 20, 1),
PIN_FIELD_BASE(64, 64, 6, 0x0080, 0x10, 17, 1),
PIN_FIELD_BASE(65, 65, 6, 0x0080, 0x10, 19, 1),
PIN_FIELD_BASE(66, 67, 4, 0x0060, 0x10, 30, 1),
PIN_FIELD_BASE(68, 69, 4, 0x0060, 0x10, 28, 1),
PIN_FIELD_BASE(70, 70, 4, 0x0060, 0x10, 23, 1),
PIN_FIELD_BASE(71, 72, 4, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(73, 73, 4, 0x0060, 0x10, 12, 1),
PIN_FIELD_BASE(74, 80, 4, 0x0060, 0x10, 15, 1),
PIN_FIELD_BASE(81, 81, 4, 0x0060, 0x10, 2, 1),
PIN_FIELD_BASE(82, 83, 4, 0x0060, 0x10, 26, 1),
PIN_FIELD_BASE(84, 85, 4, 0x0060, 0x10, 24, 1),
PIN_FIELD_BASE(86, 86, 4, 0x0060, 0x10, 22, 1),
PIN_FIELD_BASE(87, 95, 4, 0x0060, 0x10, 3, 1),
PIN_FIELD_BASE(96, 97, 4, 0x0060, 0x10, 13, 1),
PIN_FIELD_BASE(98, 98, 4, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(99, 100, 3, 0x00a0, 0x10, 0, 1),
PIN_FIELD_BASE(101, 101, 4, 0x0070, 0x10, 1, 1),
PIN_FIELD_BASE(102, 102, 3, 0x0090, 0x10, 19, 1),
PIN_FIELD_BASE(103, 103, 3, 0x0090, 0x10, 16, 1),
PIN_FIELD_BASE(104, 104, 3, 0x0090, 0x10, 18, 1),
PIN_FIELD_BASE(105, 105, 3, 0x0090, 0x10, 10, 1),
PIN_FIELD_BASE(106, 106, 3, 0x0090, 0x10, 17, 1),
PIN_FIELD_BASE(107, 110, 3, 0x0090, 0x10, 21, 1),
PIN_FIELD_BASE(111, 111, 5, 0x00b0, 0x10, 31, 1),
PIN_FIELD_BASE(112, 112, 3, 0x0090, 0x10, 0, 1),
PIN_FIELD_BASE(117, 117, 3, 0x0090, 0x10, 14, 1),
PIN_FIELD_BASE(118, 118, 3, 0x0090, 0x10, 11, 1),
PIN_FIELD_BASE(119, 119, 3, 0x0090, 0x10, 13, 1),
PIN_FIELD_BASE(120, 120, 3, 0x0090, 0x10, 15, 1),
PIN_FIELD_BASE(121, 121, 3, 0x0090, 0x10, 12, 1),
PIN_FIELD_BASE(122, 125, 3, 0x0090, 0x10, 28, 1),
PIN_FIELD_BASE(126, 127, 3, 0x0090, 0x10, 25, 1),
PIN_FIELD_BASE(128, 129, 5, 0x00c0, 0x10, 1, 1),
PIN_FIELD_BASE(130, 130, 5, 0x00c0, 0x10, 4, 1),
PIN_FIELD_BASE(131, 131, 3, 0x0090, 0x10, 27, 1),
PIN_FIELD_BASE(132, 132, 5, 0x00c0, 0x10, 0, 1),
PIN_FIELD_BASE(133, 133, 5, 0x00c0, 0x10, 3, 1),
PIN_FIELD_BASE(134, 134, 5, 0x00b0, 0x10, 8, 1),
PIN_FIELD_BASE(135, 135, 5, 0x00b0, 0x10, 12, 1),
PIN_FIELD_BASE(136, 136, 3, 0x0090, 0x10, 1, 1),
PIN_FIELD_BASE(137, 137, 5, 0x00b0, 0x10, 13, 1),
PIN_FIELD_BASE(138, 141, 5, 0x00b0, 0x10, 27, 1),
PIN_FIELD_BASE(142, 142, 3, 0x0090, 0x10, 20, 1),
PIN_FIELD_BASE(143, 143, 5, 0x00b0, 0x10, 6, 1),
PIN_FIELD_BASE(144, 144, 5, 0x00b0, 0x10, 10, 1),
PIN_FIELD_BASE(145, 145, 5, 0x00b0, 0x10, 7, 1),
PIN_FIELD_BASE(146, 146, 5, 0x00b0, 0x10, 11, 1),
PIN_FIELD_BASE(147, 147, 5, 0x00b0, 0x10, 9, 1),
PIN_FIELD_BASE(148, 148, 5, 0x00b0, 0x10, 14, 1),
PIN_FIELD_BASE(149, 154, 2, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(155, 155, 5, 0x00b0, 0x10, 2, 1),
PIN_FIELD_BASE(156, 156, 2, 0x0040, 0x10, 6, 1),
PIN_FIELD_BASE(157, 157, 5, 0x00b0, 0x10, 3, 1),
PIN_FIELD_BASE(158, 159, 2, 0x0040, 0x10, 7, 1),
PIN_FIELD_BASE(160, 160, 5, 0x00b0, 0x10, 0, 1),
PIN_FIELD_BASE(161, 161, 5, 0x00b0, 0x10, 4, 1),
PIN_FIELD_BASE(162, 162, 5, 0x00b0, 0x10, 1, 1),
PIN_FIELD_BASE(163, 163, 5, 0x00b0, 0x10, 5, 1),
PIN_FIELD_BASE(176, 177, 7, 0x0090, 0x10, 21, 1),
PIN_FIELD_BASE(178, 178, 7, 0x0090, 0x10, 31, 1),
PIN_FIELD_BASE(179, 179, 7, 0x0090, 0x10, 29, 1),
PIN_FIELD_BASE(180, 180, 7, 0x00a0, 0x10, 0, 1),
PIN_FIELD_BASE(181, 181, 7, 0x0090, 0x10, 30, 1),
PIN_FIELD_BASE(182, 185, 7, 0x0090, 0x10, 25, 1),
PIN_FIELD_BASE(186, 187, 7, 0x0090, 0x10, 23, 1),
PIN_FIELD_BASE(188, 198, 7, 0x0090, 0x10, 0, 1),
PIN_FIELD_BASE(199, 206, 7, 0x0090, 0x10, 13, 1),
PIN_FIELD_BASE(207, 208, 7, 0x0090, 0x10, 11, 1),
};
static const struct mtk_pin_field_calc mt6877_pin_pd_range[] = {
PIN_FIELD_BASE(0, 1, 5, 0x0090, 0x10, 15, 1),
PIN_FIELD_BASE(2, 9, 5, 0x0090, 0x10, 19, 1),
PIN_FIELD_BASE(10, 11, 5, 0x0090, 0x10, 17, 1),
PIN_FIELD_BASE(12, 13, 6, 0x0070, 0x10, 10, 1),
PIN_FIELD_BASE(14, 15, 8, 0x0060, 0x10, 2, 1),
PIN_FIELD_BASE(16, 23, 3, 0x0060, 0x10, 2, 1),
PIN_FIELD_BASE(36, 37, 8, 0x0060, 0x10, 5, 1),
PIN_FIELD_BASE(38, 39, 8, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(40, 40, 8, 0x0060, 0x10, 4, 1),
PIN_FIELD_BASE(41, 42, 6, 0x0070, 0x10, 12, 1),
PIN_FIELD_BASE(43, 43, 6, 0x0070, 0x10, 15, 1),
PIN_FIELD_BASE(44, 44, 6, 0x0070, 0x10, 14, 1),
PIN_FIELD_BASE(45, 45, 6, 0x0070, 0x10, 16, 1),
PIN_FIELD_BASE(46, 46, 6, 0x0070, 0x10, 18, 1),
PIN_FIELD_BASE(47, 49, 6, 0x0070, 0x10, 24, 1),
PIN_FIELD_BASE(50, 50, 6, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(51, 51, 6, 0x0070, 0x10, 9, 1),
PIN_FIELD_BASE(52, 54, 6, 0x0070, 0x10, 4, 1),
PIN_FIELD_BASE(55, 55, 6, 0x0070, 0x10, 8, 1),
PIN_FIELD_BASE(56, 56, 6, 0x0070, 0x10, 7, 1),
PIN_FIELD_BASE(57, 59, 6, 0x0070, 0x10, 1, 1),
PIN_FIELD_BASE(60, 63, 6, 0x0070, 0x10, 20, 1),
PIN_FIELD_BASE(64, 64, 6, 0x0070, 0x10, 17, 1),
PIN_FIELD_BASE(65, 65, 6, 0x0070, 0x10, 19, 1),
PIN_FIELD_BASE(66, 67, 4, 0x0040, 0x10, 30, 1),
PIN_FIELD_BASE(68, 69, 4, 0x0040, 0x10, 28, 1),
PIN_FIELD_BASE(70, 70, 4, 0x0040, 0x10, 23, 1),
PIN_FIELD_BASE(71, 72, 4, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(73, 73, 4, 0x0040, 0x10, 12, 1),
PIN_FIELD_BASE(74, 80, 4, 0x0040, 0x10, 15, 1),
PIN_FIELD_BASE(81, 81, 4, 0x0040, 0x10, 2, 1),
PIN_FIELD_BASE(82, 83, 4, 0x0040, 0x10, 26, 1),
PIN_FIELD_BASE(84, 85, 4, 0x0040, 0x10, 24, 1),
PIN_FIELD_BASE(86, 86, 4, 0x0040, 0x10, 22, 1),
PIN_FIELD_BASE(87, 95, 4, 0x0040, 0x10, 3, 1),
PIN_FIELD_BASE(96, 97, 4, 0x0040, 0x10, 13, 1),
PIN_FIELD_BASE(98, 98, 4, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(99, 100, 3, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(101, 101, 4, 0x0050, 0x10, 1, 1),
PIN_FIELD_BASE(102, 102, 3, 0x0060, 0x10, 19, 1),
PIN_FIELD_BASE(103, 103, 3, 0x0060, 0x10, 16, 1),
PIN_FIELD_BASE(104, 104, 3, 0x0060, 0x10, 18, 1),
PIN_FIELD_BASE(105, 105, 3, 0x0060, 0x10, 10, 1),
PIN_FIELD_BASE(106, 106, 3, 0x0060, 0x10, 17, 1),
PIN_FIELD_BASE(107, 110, 3, 0x0060, 0x10, 21, 1),
PIN_FIELD_BASE(111, 111, 5, 0x0090, 0x10, 31, 1),
PIN_FIELD_BASE(112, 112, 3, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(117, 117, 3, 0x0060, 0x10, 14, 1),
PIN_FIELD_BASE(118, 118, 3, 0x0060, 0x10, 11, 1),
PIN_FIELD_BASE(119, 119, 3, 0x0060, 0x10, 13, 1),
PIN_FIELD_BASE(120, 120, 3, 0x0060, 0x10, 15, 1),
PIN_FIELD_BASE(121, 121, 3, 0x0060, 0x10, 12, 1),
PIN_FIELD_BASE(122, 125, 3, 0x0060, 0x10, 28, 1),
PIN_FIELD_BASE(126, 127, 3, 0x0060, 0x10, 25, 1),
PIN_FIELD_BASE(128, 129, 5, 0x00a0, 0x10, 1, 1),
PIN_FIELD_BASE(130, 130, 5, 0x00a0, 0x10, 4, 1),
PIN_FIELD_BASE(131, 131, 3, 0x0060, 0x10, 27, 1),
PIN_FIELD_BASE(132, 132, 5, 0x00a0, 0x10, 0, 1),
PIN_FIELD_BASE(133, 133, 5, 0x00a0, 0x10, 3, 1),
PIN_FIELD_BASE(134, 134, 5, 0x0090, 0x10, 8, 1),
PIN_FIELD_BASE(135, 135, 5, 0x0090, 0x10, 12, 1),
PIN_FIELD_BASE(136, 136, 3, 0x0060, 0x10, 1, 1),
PIN_FIELD_BASE(137, 137, 5, 0x0090, 0x10, 13, 1),
PIN_FIELD_BASE(138, 141, 5, 0x0090, 0x10, 27, 1),
PIN_FIELD_BASE(142, 142, 3, 0x0060, 0x10, 20, 1),
PIN_FIELD_BASE(143, 143, 5, 0x0090, 0x10, 6, 1),
PIN_FIELD_BASE(144, 144, 5, 0x0090, 0x10, 10, 1),
PIN_FIELD_BASE(145, 145, 5, 0x0090, 0x10, 7, 1),
PIN_FIELD_BASE(146, 146, 5, 0x0090, 0x10, 11, 1),
PIN_FIELD_BASE(147, 147, 5, 0x0090, 0x10, 9, 1),
PIN_FIELD_BASE(148, 148, 5, 0x0090, 0x10, 14, 1),
PIN_FIELD_BASE(149, 154, 2, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(155, 155, 5, 0x0090, 0x10, 2, 1),
PIN_FIELD_BASE(156, 156, 2, 0x0030, 0x10, 6, 1),
PIN_FIELD_BASE(157, 157, 5, 0x0090, 0x10, 3, 1),
PIN_FIELD_BASE(158, 159, 2, 0x0030, 0x10, 7, 1),
PIN_FIELD_BASE(160, 160, 5, 0x0090, 0x10, 0, 1),
PIN_FIELD_BASE(161, 161, 5, 0x0090, 0x10, 4, 1),
PIN_FIELD_BASE(162, 162, 5, 0x0090, 0x10, 1, 1),
PIN_FIELD_BASE(163, 163, 5, 0x0090, 0x10, 5, 1),
PIN_FIELD_BASE(176, 177, 7, 0x0070, 0x10, 21, 1),
PIN_FIELD_BASE(178, 178, 7, 0x0070, 0x10, 31, 1),
PIN_FIELD_BASE(179, 179, 7, 0x0070, 0x10, 29, 1),
PIN_FIELD_BASE(180, 180, 7, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(181, 181, 7, 0x0070, 0x10, 30, 1),
PIN_FIELD_BASE(182, 185, 7, 0x0070, 0x10, 25, 1),
PIN_FIELD_BASE(186, 187, 7, 0x0070, 0x10, 23, 1),
PIN_FIELD_BASE(188, 198, 7, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(199, 206, 7, 0x0070, 0x10, 13, 1),
PIN_FIELD_BASE(207, 208, 7, 0x0070, 0x10, 11, 1),
};
static const struct mtk_pin_field_calc mt6877_pin_drv_range[] = {
PIN_FIELD_BASE(0, 6, 5, 0x0010, 0x10, 9, 3),
PIN_FIELD_BASE(7, 8, 5, 0x0020, 0x10, 0, 3),
PINS_FIELD_BASE(9, 11, 5, 0x0020, 0x10, 15, 3),
PIN_FIELD_BASE(12, 13, 6, 0x0010, 0x10, 0, 3),
PINS_FIELD_BASE(14, 15, 8, 0x0010, 0x10, 6, 3),
PIN_FIELD_BASE(16, 22, 3, 0x0000, 0x10, 3, 3),
PIN_FIELD_BASE(23, 23, 3, 0x0020, 0x10, 6, 3),
PIN_FIELD_BASE(24, 24, 8, 0x0010, 0x10, 0, 3),
PIN_FIELD_BASE(25, 26, 8, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(27, 27, 8, 0x0010, 0x10, 3, 3),
PIN_FIELD_BASE(28, 35, 8, 0x0000, 0x10, 6, 3),
PIN_FIELD_BASE(36, 37, 8, 0x0010, 0x10, 12, 3),
PINS_FIELD_BASE(38, 39, 8, 0x0010, 0x10, 6, 3),
PIN_FIELD_BASE(40, 40, 8, 0x0010, 0x10, 9, 3),
PINS_FIELD_BASE(41, 44, 6, 0x0010, 0x10, 6, 3),
PINS_FIELD_BASE(46, 48, 6, 0x0010, 0x10, 9, 3),
PIN_FIELD_BASE(49, 49, 6, 0x0020, 0x10, 0, 3),
PIN_FIELD_BASE(50, 50, 6, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(51, 51, 6, 0x0000, 0x10, 27, 3),
PIN_FIELD_BASE(52, 54, 6, 0x0000, 0x10, 12, 3),
PIN_FIELD_BASE(55, 55, 6, 0x0000, 0x10, 24, 3),
PIN_FIELD_BASE(56, 56, 6, 0x0000, 0x10, 21, 3),
PIN_FIELD_BASE(57, 59, 6, 0x0000, 0x10, 3, 3),
PIN_FIELD_BASE(60, 63, 6, 0x0010, 0x10, 18, 3),
PIN_FIELD_BASE(64, 65, 6, 0x0010, 0x10, 12, 3),
PINS_FIELD_BASE(66, 67, 4, 0x0010, 0x10, 3, 3),
PINS_FIELD_BASE(68, 69, 4, 0x0010, 0x10, 0, 3),
PIN_FIELD_BASE(70, 70, 4, 0x0000, 0x10, 3, 3),
PINS_FIELD_BASE(71, 74, 4, 0x0000, 0x10, 6, 3),
PINS_FIELD_BASE(75, 78, 4, 0x0000, 0x10, 9, 3),
PINS_FIELD_BASE(79, 81, 4, 0x0000, 0x10, 12, 3),
PINS_FIELD_BASE(82, 83, 4, 0x0000, 0x10, 27, 3),
PINS_FIELD_BASE(84, 85, 4, 0x0000, 0x10, 24, 3),
PIN_FIELD_BASE(86, 86, 4, 0x0000, 0x10, 3, 3),
PIN_FIELD_BASE(87, 87, 4, 0x0000, 0x10, 12, 3),
PINS_FIELD_BASE(88, 91, 4, 0x0000, 0x10, 15, 3),
PINS_FIELD_BASE(92, 95, 4, 0x0000, 0x10, 18, 3),
PINS_FIELD_BASE(96, 97, 4, 0x0000, 0x10, 21, 3),
PIN_FIELD_BASE(98, 98, 4, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(99, 99, 3, 0x0020, 0x10, 3, 3),
PIN_FIELD_BASE(100, 100, 3, 0x0020, 0x10, 9, 3),
PIN_FIELD_BASE(101, 101, 4, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(102, 102, 3, 0x0010, 0x10, 21, 3),
PIN_FIELD_BASE(103, 103, 3, 0x0010, 0x10, 12, 3),
PIN_FIELD_BASE(104, 104, 3, 0x0010, 0x10, 18, 3),
PIN_FIELD_BASE(105, 105, 3, 0x0000, 0x10, 24, 3),
PIN_FIELD_BASE(106, 106, 3, 0x0010, 0x10, 15, 3),
PINS_FIELD_BASE(107, 108, 3, 0x0020, 0x10, 12, 3),
PIN_FIELD_BASE(109, 110, 3, 0x0010, 0x10, 24, 3),
PIN_FIELD_BASE(111, 111, 5, 0x0020, 0x10, 6, 3),
PIN_FIELD_BASE(112, 112, 3, 0x0020, 0x10, 9, 3),
PINS_FIELD_BASE(113, 114, 3, 0x0020, 0x10, 0, 3),
PIN_FIELD_BASE(115, 115, 3, 0x0020, 0x10, 15, 3),
PIN_FIELD_BASE(116, 116, 3, 0x0020, 0x10, 12, 3),
PIN_FIELD_BASE(117, 117, 3, 0x0010, 0x10, 6, 3),
PIN_FIELD_BASE(118, 118, 3, 0x0000, 0x10, 27, 3),
PIN_FIELD_BASE(119, 119, 3, 0x0010, 0x10, 3, 3),
PIN_FIELD_BASE(120, 120, 3, 0x0010, 0x10, 9, 3),
PIN_FIELD_BASE(121, 121, 3, 0x0010, 0x10, 0, 3),
PIN_FIELD_BASE(122, 122, 3, 0x0020, 0x10, 12, 3),
PINS_FIELD_BASE(123, 125, 3, 0x0020, 0x10, 15, 3),
PIN_FIELD_BASE(126, 127, 3, 0x0020, 0x10, 18, 3),
PIN_FIELD_BASE(128, 128, 5, 0x0020, 0x10, 27, 3),
PIN_FIELD_BASE(129, 129, 5, 0x0030, 0x10, 0, 3),
PIN_FIELD_BASE(130, 130, 5, 0x0030, 0x10, 6, 3),
PIN_FIELD_BASE(131, 131, 3, 0x0020, 0x10, 24, 3),
PIN_FIELD_BASE(132, 132, 5, 0x0020, 0x10, 24, 3),
PIN_FIELD_BASE(133, 133, 5, 0x0030, 0x10, 3, 3),
PIN_FIELD_BASE(134, 134, 5, 0x0000, 0x10, 18, 3),
PIN_FIELD_BASE(135, 135, 5, 0x0010, 0x10, 0, 3),
PIN_FIELD_BASE(136, 136, 3, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(137, 137, 5, 0x0010, 0x10, 3, 3),
PIN_FIELD_BASE(138, 139, 5, 0x0020, 0x10, 9, 3),
PINS_FIELD_BASE(140, 141, 5, 0x0020, 0x10, 21, 3),
PIN_FIELD_BASE(142, 142, 3, 0x0020, 0x10, 6, 3),
PIN_FIELD_BASE(143, 143, 5, 0x0000, 0x10, 12, 3),
PIN_FIELD_BASE(144, 144, 5, 0x0000, 0x10, 24, 3),
PIN_FIELD_BASE(145, 145, 5, 0x0000, 0x10, 15, 3),
PIN_FIELD_BASE(146, 146, 5, 0x0000, 0x10, 27, 3),
PIN_FIELD_BASE(147, 147, 5, 0x0000, 0x10, 21, 3),
PIN_FIELD_BASE(148, 148, 5, 0x0010, 0x10, 6, 3),
PIN_FIELD_BASE(149, 154, 2, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(155, 155, 5, 0x0000, 0x10, 3, 3),
PIN_FIELD_BASE(156, 156, 2, 0x0000, 0x10, 18, 3),
PIN_FIELD_BASE(157, 157, 5, 0x0000, 0x10, 6, 3),
PIN_FIELD_BASE(158, 159, 2, 0x0000, 0x10, 21, 3),
PINS_FIELD_BASE(160, 161, 5, 0x0020, 0x10, 18, 3),
PIN_FIELD_BASE(162, 162, 5, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(163, 163, 5, 0x0000, 0x10, 9, 3),
PIN_FIELD_BASE(164, 164, 1, 0x0000, 0x10, 3, 3),
PIN_FIELD_BASE(165, 165, 1, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(166, 166, 1, 0x0000, 0x10, 15, 3),
PIN_FIELD_BASE(167, 168, 1, 0x0000, 0x10, 9, 3),
PIN_FIELD_BASE(169, 169, 1, 0x0000, 0x10, 6, 3),
PIN_FIELD_BASE(170, 170, 1, 0x0000, 0x10, 26, 2),
PIN_FIELD_BASE(171, 171, 1, 0x0000, 0x10, 24, 2),
PIN_FIELD_BASE(172, 172, 1, 0x0000, 0x10, 28, 2),
PIN_FIELD_BASE(173, 173, 1, 0x0000, 0x10, 22, 2),
PIN_FIELD_BASE(174, 175, 1, 0x0000, 0x10, 18, 2),
PINS_FIELD_BASE(176, 177, 7, 0x0010, 0x10, 3, 3),
PINS_FIELD_BASE(178, 179, 7, 0x0000, 0x10, 24, 3),
PINS_FIELD_BASE(180, 181, 7, 0x0010, 0x10, 3, 3),
PIN_FIELD_BASE(182, 185, 7, 0x0010, 0x10, 12, 3),
PIN_FIELD_BASE(186, 187, 7, 0x0010, 0x10, 6, 3),
PIN_FIELD_BASE(188, 195, 7, 0x0000, 0x10, 0, 3),
PINS_FIELD_BASE(196, 206, 7, 0x0000, 0x10, 27, 3),
PINS_FIELD_BASE(207, 208, 7, 0x0010, 0x10, 0, 3),
};
static const struct mtk_pin_field_calc mt6877_pin_pupd_range[] = {
PIN_FIELD_BASE(24, 24, 8, 0x0070, 0x10, 10, 1),
PIN_FIELD_BASE(25, 26, 8, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(27, 27, 8, 0x0070, 0x10, 11, 1),
PIN_FIELD_BASE(28, 35, 8, 0x0070, 0x10, 2, 1),
PIN_FIELD_BASE(113, 113, 3, 0x0080, 0x10, 3, 1),
PIN_FIELD_BASE(114, 115, 3, 0x0080, 0x10, 1, 1),
PIN_FIELD_BASE(116, 116, 3, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(164, 164, 1, 0x0040, 0x10, 1, 1),
PIN_FIELD_BASE(165, 165, 1, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(166, 166, 1, 0x0040, 0x10, 5, 1),
PIN_FIELD_BASE(167, 168, 1, 0x0040, 0x10, 3, 1),
PIN_FIELD_BASE(169, 169, 1, 0x0040, 0x10, 2, 1),
PIN_FIELD_BASE(170, 170, 1, 0x0040, 0x10, 10, 1),
PIN_FIELD_BASE(171, 171, 1, 0x0040, 0x10, 9, 1),
PIN_FIELD_BASE(172, 172, 1, 0x0040, 0x10, 11, 1),
PIN_FIELD_BASE(173, 173, 1, 0x0040, 0x10, 8, 1),
PIN_FIELD_BASE(174, 175, 1, 0x0040, 0x10, 6, 1),
};
static const struct mtk_pin_field_calc mt6877_pin_r0_range[] = {
PIN_FIELD_BASE(24, 24, 8, 0x0090, 0x10, 10, 1),
PIN_FIELD_BASE(25, 26, 8, 0x0090, 0x10, 0, 1),
PIN_FIELD_BASE(27, 27, 8, 0x0090, 0x10, 11, 1),
PIN_FIELD_BASE(28, 35, 8, 0x0090, 0x10, 2, 1),
PIN_FIELD_BASE(113, 113, 3, 0x00b0, 0x10, 3, 1),
PIN_FIELD_BASE(114, 115, 3, 0x00b0, 0x10, 1, 1),
PIN_FIELD_BASE(116, 116, 3, 0x00b0, 0x10, 0, 1),
PIN_FIELD_BASE(164, 164, 1, 0x0050, 0x10, 1, 1),
PIN_FIELD_BASE(165, 165, 1, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(166, 166, 1, 0x0050, 0x10, 5, 1),
PIN_FIELD_BASE(167, 168, 1, 0x0050, 0x10, 3, 1),
PIN_FIELD_BASE(169, 169, 1, 0x0050, 0x10, 2, 1),
PIN_FIELD_BASE(170, 170, 1, 0x0050, 0x10, 10, 1),
PIN_FIELD_BASE(171, 171, 1, 0x0050, 0x10, 9, 1),
PIN_FIELD_BASE(172, 172, 1, 0x0050, 0x10, 11, 1),
PIN_FIELD_BASE(173, 173, 1, 0x0050, 0x10, 8, 1),
PIN_FIELD_BASE(174, 175, 1, 0x0050, 0x10, 6, 1),
};
static const struct mtk_pin_field_calc mt6877_pin_r1_range[] = {
PIN_FIELD_BASE(24, 24, 8, 0x00a0, 0x10, 10, 1),
PIN_FIELD_BASE(25, 26, 8, 0x00a0, 0x10, 0, 1),
PIN_FIELD_BASE(27, 27, 8, 0x00a0, 0x10, 11, 1),
PIN_FIELD_BASE(28, 35, 8, 0x00a0, 0x10, 2, 1),
PIN_FIELD_BASE(113, 113, 3, 0x00c0, 0x10, 3, 1),
PIN_FIELD_BASE(114, 115, 3, 0x00c0, 0x10, 1, 1),
PIN_FIELD_BASE(116, 116, 3, 0x00c0, 0x10, 0, 1),
PIN_FIELD_BASE(164, 164, 1, 0x0060, 0x10, 1, 1),
PIN_FIELD_BASE(165, 165, 1, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(166, 166, 1, 0x0060, 0x10, 5, 1),
PIN_FIELD_BASE(167, 168, 1, 0x0060, 0x10, 3, 1),
PIN_FIELD_BASE(169, 169, 1, 0x0060, 0x10, 2, 1),
PIN_FIELD_BASE(170, 170, 1, 0x0060, 0x10, 10, 1),
PIN_FIELD_BASE(171, 171, 1, 0x0060, 0x10, 9, 1),
PIN_FIELD_BASE(172, 172, 1, 0x0060, 0x10, 11, 1),
PIN_FIELD_BASE(173, 173, 1, 0x0060, 0x10, 8, 1),
PIN_FIELD_BASE(174, 175, 1, 0x0060, 0x10, 6, 1),
};
static const struct mtk_pin_field_calc mt6877_pin_eh_range[] = {
PIN_FIELD_BASE(36, 36, 8, 0x0030, 0x10, 0, 3),
PIN_FIELD_BASE(37, 37, 8, 0x0030, 0x10, 3, 3),
PIN_FIELD_BASE(60, 60, 6, 0x0030, 0x10, 6, 5),
PIN_FIELD_BASE(61, 61, 6, 0x0030, 0x10, 11, 5),
PIN_FIELD_BASE(62, 62, 6, 0x0030, 0x10, 16, 5),
PIN_FIELD_BASE(63, 63, 6, 0x0030, 0x10, 21, 5),
PIN_FIELD_BASE(64, 64, 6, 0x0030, 0x10, 0, 3),
PIN_FIELD_BASE(65, 65, 6, 0x0030, 0x10, 3, 3),
PIN_FIELD_BASE(130, 130, 5, 0x0050, 0x10, 3, 3),
PIN_FIELD_BASE(131, 131, 3, 0x0030, 0x10, 3, 3),
PIN_FIELD_BASE(132, 132, 5, 0x0040, 0x10, 27, 3),
PIN_FIELD_BASE(133, 133, 5, 0x0050, 0x10, 0, 3),
PIN_FIELD_BASE(134, 134, 5, 0x0040, 0x10, 6, 3),
PIN_FIELD_BASE(135, 135, 5, 0x0040, 0x10, 18, 3),
PIN_FIELD_BASE(136, 136, 3, 0x0030, 0x10, 0, 3),
PIN_FIELD_BASE(137, 137, 5, 0x0040, 0x10, 21, 3),
PIN_FIELD_BASE(143, 143, 5, 0x0040, 0x10, 0, 3),
PIN_FIELD_BASE(144, 144, 5, 0x0040, 0x10, 12, 3),
PIN_FIELD_BASE(145, 145, 5, 0x0040, 0x10, 3, 3),
PIN_FIELD_BASE(146, 146, 5, 0x0040, 0x10, 15, 3),
PIN_FIELD_BASE(147, 147, 5, 0x0040, 0x10, 9, 3),
PIN_FIELD_BASE(148, 148, 5, 0x0040, 0x10, 24, 3),
PIN_FIELD_BASE(149, 149, 2, 0x0010, 0x10, 0, 5),
PIN_FIELD_BASE(150, 150, 2, 0x0010, 0x10, 5, 5),
PIN_FIELD_BASE(151, 151, 2, 0x0010, 0x10, 10, 5),
PIN_FIELD_BASE(152, 152, 2, 0x0010, 0x10, 15, 5),
PIN_FIELD_BASE(153, 153, 2, 0x0010, 0x10, 20, 5),
PIN_FIELD_BASE(186, 186, 7, 0x0030, 0x10, 0, 3),
PIN_FIELD_BASE(187, 187, 7, 0x0030, 0x10, 3, 3),
};
static const struct mtk_eint_hw mt6877_eint_hw = {
.port_mask = 7,
.ports = 7,
.ap_num = 128,
.db_cnt = 32,
};
static const struct mtk_pin_reg_calc mt6877_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt6877_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt6877_pin_dir_range),
[PINCTRL_PIN_REG_DI] = MTK_RANGE(mt6877_pin_di_range),
[PINCTRL_PIN_REG_DO] = MTK_RANGE(mt6877_pin_do_range),
[PINCTRL_PIN_REG_SR] = MTK_RANGE(mt6877_pin_dir_range),
[PINCTRL_PIN_REG_SMT] = MTK_RANGE(mt6877_pin_smt_range),
[PINCTRL_PIN_REG_IES] = MTK_RANGE(mt6877_pin_ies_range),
[PINCTRL_PIN_REG_PU] = MTK_RANGE(mt6877_pin_pu_range),
[PINCTRL_PIN_REG_PD] = MTK_RANGE(mt6877_pin_pd_range),
[PINCTRL_PIN_REG_DRV] = MTK_RANGE(mt6877_pin_drv_range),
[PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt6877_pin_pupd_range),
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt6877_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt6877_pin_r1_range),
[PINCTRL_PIN_REG_DRV_EH] = MTK_RANGE(mt6877_pin_eh_range),
};
static const struct mtk_eh_pin_pinmux mt6877_eh_pin_pinmux_list[] = {
/* pin number, pinmux number */
{36, 1},
{37, 1},
{60, 2},
{61, 2},
{62, 2},
{63, 2},
{64, 1},
{65, 1},
{130, 1},
{131, 1},
{132, 1},
{133, 1},
{134, 1},
{135, 1},
{136, 1},
{137, 1},
{143, 1},
{144, 1},
{145, 1},
{146, 1},
{147, 1},
{148, 1},
{186, 1},
{187, 1},
{0xffff, 0}, /* indicate end of array */
};
static const struct mtk_pin_soc mt6877_data = {
.reg_cal = mt6877_reg_cals,
.pins = mtk_pins_mt6877,
.npins = ARRAY_SIZE(mtk_pins_mt6877),
.ngrps = ARRAY_SIZE(mtk_pins_mt6877),
.eint_hw = &mt6877_eint_hw,
.nfuncs = 8,
.gpio_m = 0,
.race_free_access = true,
.eh_pin_pinmux = mt6877_eh_pin_pinmux_list,
.bias_set_combo = mtk_pinconf_bias_set_combo,
.bias_get_combo = mtk_pinconf_bias_get_combo,
.drive_set = mtk_pinconf_drive_set_raw,
.drive_get = mtk_pinconf_drive_get_raw,
.adv_pull_get = mtk_pinconf_adv_pull_get,
.adv_pull_set = mtk_pinconf_adv_pull_set,
.adv_drive_get = mtk_pinconf_adv_drive_get,
.adv_drive_set = mtk_pinconf_adv_drive_set,
};
static const struct of_device_id mt6877_pinctrl_of_match[] = {
{ .compatible = "mediatek,mt6877-pinctrl", },
{ }
};
static int mt6877_pinctrl_probe(struct platform_device *pdev)
{
return mtk_paris_pinctrl_probe(pdev, &mt6877_data);
}
static struct platform_driver mt6877_pinctrl_driver = {
.driver = {
.name = "mt6877-pinctrl",
.of_match_table = mt6877_pinctrl_of_match,
.pm = &mtk_eint_pm_ops_v2,
},
.probe = mt6877_pinctrl_probe,
};
static int __init mt6877_pinctrl_init(void)
{
return platform_driver_register(&mt6877_pinctrl_driver);
}
arch_initcall(mt6877_pinctrl_init);
+816
View File
@@ -0,0 +1,816 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2019 MediaTek Inc.
* Author: Andy Teng <andy.teng@mediatek.com>
*
*/
#include "pinctrl-mtk-mt6885.h"
#include "pinctrl-paris.h"
/* MT6885 have multiple bases to program pin configuration listed as the below:
* gpio:0x10005000, iocfg_rm:0x11C20000, iocfg_br:0x11D10000,
* iocfg_lm:0x11E20000, iocfg_lb:0x11E70000, iocfg_rt:0x11EA0000,
* iocfg_lt:0x11F20000, iocfg_tm:0x11F30000
* _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)
#define PINS_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, 1)
static const struct mtk_pin_field_calc mt6885_pin_mode_range[] = {
PIN_FIELD_BASE(0, 7, 0, 0x0300, 0x10, 0, 4),
PIN_FIELD_BASE(8, 15, 0, 0x0310, 0x10, 0, 4),
PIN_FIELD_BASE(16, 23, 0, 0x0320, 0x10, 0, 4),
PIN_FIELD_BASE(24, 31, 0, 0x0330, 0x10, 0, 4),
PIN_FIELD_BASE(32, 39, 0, 0x0340, 0x10, 0, 4),
PIN_FIELD_BASE(40, 47, 0, 0x0350, 0x10, 0, 4),
PIN_FIELD_BASE(48, 55, 0, 0x0360, 0x10, 0, 4),
PIN_FIELD_BASE(56, 63, 0, 0x0370, 0x10, 0, 4),
PIN_FIELD_BASE(64, 71, 0, 0x0380, 0x10, 0, 4),
PIN_FIELD_BASE(72, 79, 0, 0x0390, 0x10, 0, 4),
PIN_FIELD_BASE(80, 87, 0, 0x03A0, 0x10, 0, 4),
PIN_FIELD_BASE(88, 95, 0, 0x03B0, 0x10, 0, 4),
PIN_FIELD_BASE(96, 103, 0, 0x03C0, 0x10, 0, 4),
PIN_FIELD_BASE(104, 111, 0, 0x03D0, 0x10, 0, 4),
PIN_FIELD_BASE(112, 119, 0, 0x03E0, 0x10, 0, 4),
PIN_FIELD_BASE(120, 127, 0, 0x03F0, 0x10, 0, 4),
PIN_FIELD_BASE(128, 135, 0, 0x0400, 0x10, 0, 4),
PIN_FIELD_BASE(136, 143, 0, 0x0410, 0x10, 0, 4),
PIN_FIELD_BASE(144, 151, 0, 0x0420, 0x10, 0, 4),
PIN_FIELD_BASE(152, 159, 0, 0x0430, 0x10, 0, 4),
PIN_FIELD_BASE(160, 167, 0, 0x0440, 0x10, 0, 4),
PIN_FIELD_BASE(168, 175, 0, 0x0450, 0x10, 0, 4),
PIN_FIELD_BASE(176, 183, 0, 0x0460, 0x10, 0, 4),
PIN_FIELD_BASE(184, 191, 0, 0x0470, 0x10, 0, 4),
PIN_FIELD_BASE(192, 199, 0, 0x0480, 0x10, 0, 4),
PIN_FIELD_BASE(200, 207, 0, 0x0490, 0x10, 0, 4),
PIN_FIELD_BASE(208, 215, 0, 0x04A0, 0x10, 0, 4),
PIN_FIELD_BASE(216, 219, 0, 0x04B0, 0x10, 0, 4),
};
static const struct mtk_pin_field_calc mt6885_pin_dir_range[] = {
PIN_FIELD_BASE(0, 31, 0, 0x0000, 0x10, 0, 1),
PIN_FIELD_BASE(32, 63, 0, 0x0010, 0x10, 0, 1),
PIN_FIELD_BASE(64, 95, 0, 0x0020, 0x10, 0, 1),
PIN_FIELD_BASE(96, 127, 0, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(128, 159, 0, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(160, 191, 0, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(192, 219, 0, 0x0060, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6885_pin_di_range[] = {
PIN_FIELD_BASE(0, 31, 0, 0x0200, 0x10, 0, 1),
PIN_FIELD_BASE(32, 63, 0, 0x0210, 0x10, 0, 1),
PIN_FIELD_BASE(64, 95, 0, 0x0220, 0x10, 0, 1),
PIN_FIELD_BASE(96, 127, 0, 0x0230, 0x10, 0, 1),
PIN_FIELD_BASE(128, 159, 0, 0x0240, 0x10, 0, 1),
PIN_FIELD_BASE(160, 191, 0, 0x0250, 0x10, 0, 1),
PIN_FIELD_BASE(192, 219, 0, 0x0260, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6885_pin_do_range[] = {
PIN_FIELD_BASE(0, 31, 0, 0x0100, 0x10, 0, 1),
PIN_FIELD_BASE(32, 63, 0, 0x0110, 0x10, 0, 1),
PIN_FIELD_BASE(64, 95, 0, 0x0120, 0x10, 0, 1),
PIN_FIELD_BASE(96, 127, 0, 0x0130, 0x10, 0, 1),
PIN_FIELD_BASE(128, 159, 0, 0x0140, 0x10, 0, 1),
PIN_FIELD_BASE(160, 191, 0, 0x0150, 0x10, 0, 1),
PIN_FIELD_BASE(192, 219, 0, 0x0160, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6885_pin_smt_range[] = {
PINS_FIELD_BASE(0, 9, 2, 0x00f0, 0x10, 7, 1),
PINS_FIELD_BASE(10, 15, 1, 0x0090, 0x10, 4, 1),
PIN_FIELD_BASE(16, 17, 5, 0x00c0, 0x10, 8, 1),
PINS_FIELD_BASE(18, 25, 7, 0x00f0, 0x10, 1, 1),
PINS_FIELD_BASE(26, 30, 6, 0x00e0, 0x10, 6, 1),
PINS_FIELD_BASE(31, 35, 6, 0x00e0, 0x10, 2, 1),
PIN_FIELD_BASE(36, 36, 6, 0x00e0, 0x10, 16, 1),
PINS_FIELD_BASE(37, 39, 6, 0x00e0, 0x10, 15, 1),
PIN_FIELD_BASE(40, 41, 6, 0x00e0, 0x10, 0, 1),
PIN_FIELD_BASE(42, 42, 6, 0x00e0, 0x10, 5, 1),
PIN_FIELD_BASE(43, 44, 6, 0x00e0, 0x10, 3, 1),
PIN_FIELD_BASE(45, 45, 6, 0x00e0, 0x10, 12, 1),
PIN_FIELD_BASE(46, 46, 6, 0x00e0, 0x10, 14, 1),
PIN_FIELD_BASE(47, 47, 6, 0x00e0, 0x10, 13, 1),
PIN_FIELD_BASE(48, 49, 6, 0x00e0, 0x10, 10, 1),
PIN_FIELD_BASE(50, 50, 6, 0x00e0, 0x10, 9, 1),
PIN_FIELD_BASE(51, 52, 3, 0x0090, 0x10, 6, 1),
PINS_FIELD_BASE(53, 56, 3, 0x0090, 0x10, 8, 1),
PIN_FIELD_BASE(57, 60, 3, 0x0090, 0x10, 2, 1),
PIN_FIELD_BASE(61, 61, 3, 0x0090, 0x10, 1, 1),
PIN_FIELD_BASE(62, 62, 4, 0x0050, 0x10, 1, 1),
PINS_FIELD_BASE(63, 73, 3, 0x0090, 0x10, 0, 1),
PINS_FIELD_BASE(74, 84, 4, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(85, 86, 4, 0x0050, 0x10, 4, 1),
PIN_FIELD_BASE(87, 88, 4, 0x0050, 0x10, 2, 1),
PIN_FIELD_BASE(89, 90, 2, 0x00f0, 0x10, 26, 1),
PIN_FIELD_BASE(91, 91, 2, 0x00f0, 0x10, 0, 1),
PINS_FIELD_BASE(92, 95, 2, 0x0100, 0x10, 0, 1),
PIN_FIELD_BASE(96, 96, 2, 0x00f0, 0x10, 30, 1),
PIN_FIELD_BASE(97, 97, 2, 0x00f0, 0x10, 28, 1),
PIN_FIELD_BASE(98, 98, 2, 0x00f0, 0x10, 31, 1),
PINS_FIELD_BASE(99, 102, 2, 0x00f0, 0x10, 29, 1),
PINS_FIELD_BASE(103, 105, 2, 0x00f0, 0x10, 24, 1),
PIN_FIELD_BASE(106, 106, 2, 0x00f0, 0x10, 25, 1),
PIN_FIELD_BASE(107, 108, 2, 0x00f0, 0x10, 5, 1),
PINS_FIELD_BASE(109, 113, 2, 0x00f0, 0x10, 8, 1),
PINS_FIELD_BASE(114, 116, 2, 0x00f0, 0x10, 16, 1),
PIN_FIELD_BASE(117, 117, 2, 0x00f0, 0x10, 17, 1),
PIN_FIELD_BASE(118, 118, 2, 0x00f0, 0x10, 10, 1),
PIN_FIELD_BASE(119, 119, 2, 0x00f0, 0x10, 18, 1),
PIN_FIELD_BASE(120, 120, 2, 0x00f0, 0x10, 15, 1),
PIN_FIELD_BASE(121, 121, 2, 0x00f0, 0x10, 23, 1),
PIN_FIELD_BASE(122, 122, 2, 0x00f0, 0x10, 14, 1),
PIN_FIELD_BASE(123, 123, 2, 0x00f0, 0x10, 22, 1),
PIN_FIELD_BASE(124, 124, 2, 0x00f0, 0x10, 13, 1),
PIN_FIELD_BASE(125, 125, 2, 0x00f0, 0x10, 21, 1),
PINS_FIELD_BASE(126, 129, 2, 0x00f0, 0x10, 9, 1),
PINS_FIELD_BASE(130, 135, 2, 0x00f0, 0x10, 4, 1),
PIN_FIELD_BASE(136, 138, 2, 0x00f0, 0x10, 1, 1),
PIN_FIELD_BASE(139, 139, 2, 0x00f0, 0x10, 12, 1),
PIN_FIELD_BASE(140, 140, 2, 0x00f0, 0x10, 20, 1),
PIN_FIELD_BASE(141, 141, 2, 0x00f0, 0x10, 11, 1),
PIN_FIELD_BASE(142, 142, 2, 0x00f0, 0x10, 19, 1),
PINS_FIELD_BASE(143, 148, 1, 0x0090, 0x10, 3, 1),
PIN_FIELD_BASE(149, 151, 1, 0x0090, 0x10, 0, 1),
PINS_FIELD_BASE(152, 155, 5, 0x00c0, 0x10, 10, 1),
PIN_FIELD_BASE(156, 156, 5, 0x00c0, 0x10, 14, 1),
PINS_FIELD_BASE(157, 159, 5, 0x00c0, 0x10, 13, 1),
PIN_FIELD_BASE(160, 161, 5, 0x00c0, 0x10, 11, 1),
PINS_FIELD_BASE(162, 171, 5, 0x00c0, 0x10, 0, 1),
PIN_FIELD_BASE(172, 173, 5, 0x00c0, 0x10, 4, 1),
PIN_FIELD_BASE(174, 174, 5, 0x00c0, 0x10, 3, 1),
PIN_FIELD_BASE(175, 175, 5, 0x00c0, 0x10, 6, 1),
PIN_FIELD_BASE(176, 177, 5, 0x00c0, 0x10, 1, 1),
PINS_FIELD_BASE(178, 182, 5, 0x00c0, 0x10, 7, 1),
PIN_FIELD_BASE(183, 183, 7, 0x00f0, 0x10, 3, 1),
PINS_FIELD_BASE(184, 190, 7, 0x00f0, 0x10, 4, 1),
PIN_FIELD_BASE(191, 191, 7, 0x00f0, 0x10, 5, 1),
PIN_FIELD_BASE(192, 192, 7, 0x00f0, 0x10, 2, 1),
PIN_FIELD_BASE(193, 193, 7, 0x00f0, 0x10, 4, 1),
PIN_FIELD_BASE(194, 194, 7, 0x00f0, 0x10, 6, 1),
PIN_FIELD_BASE(195, 195, 7, 0x00f0, 0x10, 12, 1),
PINS_FIELD_BASE(196, 199, 7, 0x00f0, 0x10, 0, 1),
PIN_FIELD_BASE(200, 200, 7, 0x00f0, 0x10, 11, 1),
PIN_FIELD_BASE(201, 201, 7, 0x00f0, 0x10, 14, 1),
PIN_FIELD_BASE(202, 202, 7, 0x00f0, 0x10, 10, 1),
PIN_FIELD_BASE(203, 203, 7, 0x00f0, 0x10, 13, 1),
PIN_FIELD_BASE(204, 205, 6, 0x00e0, 0x10, 7, 1),
PIN_FIELD_BASE(206, 208, 7, 0x00f0, 0x10, 15, 1),
PINS_FIELD_BASE(209, 211, 7, 0x00f0, 0x10, 7, 1),
PIN_FIELD_BASE(212, 213, 7, 0x00f0, 0x10, 8, 1),
PINS_FIELD_BASE(214, 219, 7, 0x00f0, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt6885_pin_ies_range[] = {
PIN_FIELD_BASE(0, 9, 2, 0x0060, 0x10, 12, 1),
PIN_FIELD_BASE(10, 15, 1, 0x0020, 0x10, 9, 1),
PIN_FIELD_BASE(16, 17, 5, 0x0030, 0x10, 21, 1),
PIN_FIELD_BASE(18, 25, 7, 0x0050, 0x10, 10, 1),
PIN_FIELD_BASE(26, 30, 6, 0x0040, 0x10, 10, 1),
PIN_FIELD_BASE(31, 31, 6, 0x0040, 0x10, 6, 1),
PIN_FIELD_BASE(32, 32, 6, 0x0040, 0x10, 3, 1),
PIN_FIELD_BASE(33, 33, 6, 0x0040, 0x10, 5, 1),
PIN_FIELD_BASE(34, 34, 6, 0x0040, 0x10, 2, 1),
PIN_FIELD_BASE(35, 35, 6, 0x0040, 0x10, 4, 1),
PIN_FIELD_BASE(36, 39, 6, 0x0040, 0x10, 23, 1),
PIN_FIELD_BASE(40, 41, 6, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(42, 42, 6, 0x0040, 0x10, 9, 1),
PIN_FIELD_BASE(43, 44, 6, 0x0040, 0x10, 7, 1),
PIN_FIELD_BASE(45, 45, 6, 0x0040, 0x10, 20, 1),
PIN_FIELD_BASE(46, 46, 6, 0x0040, 0x10, 22, 1),
PIN_FIELD_BASE(47, 47, 6, 0x0040, 0x10, 21, 1),
PIN_FIELD_BASE(48, 49, 6, 0x0040, 0x10, 18, 1),
PIN_FIELD_BASE(50, 50, 6, 0x0040, 0x10, 17, 1),
PIN_FIELD_BASE(51, 52, 3, 0x0020, 0x10, 16, 1),
PIN_FIELD_BASE(53, 53, 3, 0x0020, 0x10, 21, 1),
PIN_FIELD_BASE(54, 54, 3, 0x0020, 0x10, 18, 1),
PIN_FIELD_BASE(55, 55, 3, 0x0020, 0x10, 20, 1),
PIN_FIELD_BASE(56, 56, 3, 0x0020, 0x10, 19, 1),
PIN_FIELD_BASE(57, 60, 3, 0x0020, 0x10, 12, 1),
PIN_FIELD_BASE(61, 61, 3, 0x0020, 0x10, 11, 1),
PIN_FIELD_BASE(62, 62, 4, 0x0010, 0x10, 11, 1),
PIN_FIELD_BASE(63, 64, 3, 0x0020, 0x10, 0, 1),
PIN_FIELD_BASE(65, 72, 3, 0x0020, 0x10, 3, 1),
PIN_FIELD_BASE(73, 73, 3, 0x0020, 0x10, 2, 1),
PIN_FIELD_BASE(74, 84, 4, 0x0010, 0x10, 0, 1),
PIN_FIELD_BASE(85, 86, 4, 0x0010, 0x10, 14, 1),
PIN_FIELD_BASE(87, 88, 4, 0x0010, 0x10, 12, 1),
PIN_FIELD_BASE(89, 90, 2, 0x0070, 0x10, 19, 1),
PIN_FIELD_BASE(91, 91, 2, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(92, 92, 2, 0x0070, 0x10, 28, 1),
PIN_FIELD_BASE(93, 93, 2, 0x0070, 0x10, 30, 1),
PIN_FIELD_BASE(94, 94, 2, 0x0070, 0x10, 29, 1),
PIN_FIELD_BASE(95, 95, 2, 0x0070, 0x10, 31, 1),
PIN_FIELD_BASE(96, 96, 2, 0x0070, 0x10, 26, 1),
PIN_FIELD_BASE(97, 97, 2, 0x0070, 0x10, 21, 1),
PIN_FIELD_BASE(98, 98, 2, 0x0070, 0x10, 27, 1),
PIN_FIELD_BASE(99, 102, 2, 0x0070, 0x10, 22, 1),
PIN_FIELD_BASE(103, 103, 2, 0x0070, 0x10, 17, 1),
PIN_FIELD_BASE(104, 104, 2, 0x0070, 0x10, 16, 1),
PIN_FIELD_BASE(105, 105, 2, 0x0070, 0x10, 18, 1),
PIN_FIELD_BASE(106, 106, 2, 0x0070, 0x10, 15, 1),
PIN_FIELD_BASE(107, 108, 2, 0x0060, 0x10, 10, 1),
PIN_FIELD_BASE(109, 109, 2, 0x0060, 0x10, 25, 1),
PIN_FIELD_BASE(110, 110, 2, 0x0060, 0x10, 22, 1),
PIN_FIELD_BASE(111, 111, 2, 0x0060, 0x10, 24, 1),
PIN_FIELD_BASE(112, 112, 2, 0x0060, 0x10, 26, 1),
PIN_FIELD_BASE(113, 113, 2, 0x0060, 0x10, 23, 1),
PIN_FIELD_BASE(114, 114, 2, 0x0070, 0x10, 7, 1),
PIN_FIELD_BASE(115, 115, 2, 0x0070, 0x10, 6, 1),
PIN_FIELD_BASE(116, 116, 2, 0x0070, 0x10, 8, 1),
PIN_FIELD_BASE(117, 117, 2, 0x0070, 0x10, 5, 1),
PIN_FIELD_BASE(118, 118, 2, 0x0060, 0x10, 31, 1),
PIN_FIELD_BASE(119, 119, 2, 0x0070, 0x10, 9, 1),
PIN_FIELD_BASE(120, 120, 2, 0x0070, 0x10, 4, 1),
PIN_FIELD_BASE(121, 121, 2, 0x0070, 0x10, 14, 1),
PIN_FIELD_BASE(122, 122, 2, 0x0070, 0x10, 3, 1),
PIN_FIELD_BASE(123, 123, 2, 0x0070, 0x10, 13, 1),
PIN_FIELD_BASE(124, 124, 2, 0x0070, 0x10, 2, 1),
PIN_FIELD_BASE(125, 125, 2, 0x0070, 0x10, 12, 1),
PIN_FIELD_BASE(126, 129, 2, 0x0060, 0x10, 27, 1),
PIN_FIELD_BASE(130, 132, 2, 0x0060, 0x10, 7, 1),
PIN_FIELD_BASE(133, 135, 2, 0x0060, 0x10, 4, 1),
PIN_FIELD_BASE(136, 138, 2, 0x0060, 0x10, 1, 1),
PIN_FIELD_BASE(139, 139, 2, 0x0070, 0x10, 1, 1),
PIN_FIELD_BASE(140, 140, 2, 0x0070, 0x10, 11, 1),
PIN_FIELD_BASE(141, 141, 2, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(142, 142, 2, 0x0070, 0x10, 10, 1),
PIN_FIELD_BASE(143, 145, 1, 0x0020, 0x10, 6, 1),
PIN_FIELD_BASE(146, 148, 1, 0x0020, 0x10, 3, 1),
PIN_FIELD_BASE(149, 151, 1, 0x0020, 0x10, 0, 1),
PIN_FIELD_BASE(152, 152, 5, 0x0030, 0x10, 26, 1),
PIN_FIELD_BASE(153, 153, 5, 0x0030, 0x10, 25, 1),
PIN_FIELD_BASE(154, 155, 5, 0x0030, 0x10, 23, 1),
PIN_FIELD_BASE(156, 158, 5, 0x0030, 0x10, 29, 1),
PIN_FIELD_BASE(159, 159, 5, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(160, 161, 5, 0x0030, 0x10, 27, 1),
PIN_FIELD_BASE(162, 171, 5, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(172, 173, 5, 0x0030, 0x10, 13, 1),
PIN_FIELD_BASE(174, 174, 5, 0x0030, 0x10, 12, 1),
PIN_FIELD_BASE(175, 175, 5, 0x0030, 0x10, 15, 1),
PIN_FIELD_BASE(176, 177, 5, 0x0030, 0x10, 10, 1),
PIN_FIELD_BASE(178, 182, 5, 0x0030, 0x10, 16, 1),
PIN_FIELD_BASE(183, 184, 7, 0x0050, 0x10, 19, 1),
PIN_FIELD_BASE(185, 185, 7, 0x0050, 0x10, 22, 1),
PIN_FIELD_BASE(186, 186, 7, 0x0050, 0x10, 24, 1),
PIN_FIELD_BASE(187, 187, 7, 0x0050, 0x10, 26, 1),
PIN_FIELD_BASE(188, 188, 7, 0x0050, 0x10, 21, 1),
PIN_FIELD_BASE(189, 189, 7, 0x0050, 0x10, 25, 1),
PIN_FIELD_BASE(190, 191, 7, 0x0050, 0x10, 27, 1),
PIN_FIELD_BASE(192, 192, 7, 0x0050, 0x10, 18, 1),
PIN_FIELD_BASE(193, 193, 7, 0x0050, 0x10, 23, 1),
PIN_FIELD_BASE(194, 194, 7, 0x0050, 0x10, 29, 1),
PIN_FIELD_BASE(195, 195, 7, 0x0060, 0x10, 5, 1),
PIN_FIELD_BASE(196, 196, 7, 0x0050, 0x10, 6, 1),
PIN_FIELD_BASE(197, 197, 7, 0x0050, 0x10, 8, 1),
PIN_FIELD_BASE(198, 198, 7, 0x0050, 0x10, 7, 1),
PIN_FIELD_BASE(199, 199, 7, 0x0050, 0x10, 3, 1),
PIN_FIELD_BASE(200, 200, 7, 0x0060, 0x10, 4, 1),
PIN_FIELD_BASE(201, 201, 7, 0x0060, 0x10, 7, 1),
PIN_FIELD_BASE(202, 202, 7, 0x0060, 0x10, 3, 1),
PIN_FIELD_BASE(203, 203, 7, 0x0060, 0x10, 6, 1),
PIN_FIELD_BASE(204, 205, 6, 0x0040, 0x10, 15, 1),
PIN_FIELD_BASE(206, 208, 7, 0x0060, 0x10, 8, 1),
PIN_FIELD_BASE(209, 209, 7, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(210, 210, 7, 0x0050, 0x10, 31, 1),
PIN_FIELD_BASE(211, 211, 7, 0x0060, 0x10, 1, 1),
PIN_FIELD_BASE(212, 212, 7, 0x0050, 0x10, 30, 1),
PIN_FIELD_BASE(213, 213, 7, 0x0060, 0x10, 2, 1),
PIN_FIELD_BASE(214, 214, 7, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(215, 215, 7, 0x0050, 0x10, 9, 1),
PIN_FIELD_BASE(216, 217, 7, 0x0050, 0x10, 4, 1),
PIN_FIELD_BASE(218, 219, 7, 0x0050, 0x10, 1, 1),
};
static const struct mtk_pin_field_calc mt6885_pin_pu_range[] = {
PIN_FIELD_BASE(0, 9, 2, 0x00a0, 0x10, 12, 1),
PIN_FIELD_BASE(16, 17, 5, 0x0070, 0x10, 21, 1),
PIN_FIELD_BASE(18, 25, 7, 0x0090, 0x10, 10, 1),
PIN_FIELD_BASE(26, 30, 6, 0x0080, 0x10, 10, 1),
PIN_FIELD_BASE(31, 31, 6, 0x0080, 0x10, 6, 1),
PIN_FIELD_BASE(32, 32, 6, 0x0080, 0x10, 3, 1),
PIN_FIELD_BASE(33, 33, 6, 0x0080, 0x10, 5, 1),
PIN_FIELD_BASE(34, 34, 6, 0x0080, 0x10, 2, 1),
PIN_FIELD_BASE(35, 35, 6, 0x0080, 0x10, 4, 1),
PIN_FIELD_BASE(36, 39, 6, 0x0080, 0x10, 17, 1),
PIN_FIELD_BASE(40, 41, 6, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(42, 42, 6, 0x0080, 0x10, 9, 1),
PIN_FIELD_BASE(43, 44, 6, 0x0080, 0x10, 7, 1),
PIN_FIELD_BASE(57, 60, 3, 0x0050, 0x10, 12, 1),
PIN_FIELD_BASE(61, 61, 3, 0x0050, 0x10, 11, 1),
PIN_FIELD_BASE(62, 62, 4, 0x0030, 0x10, 11, 1),
PIN_FIELD_BASE(63, 64, 3, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(65, 72, 3, 0x0050, 0x10, 3, 1),
PIN_FIELD_BASE(73, 73, 3, 0x0050, 0x10, 2, 1),
PIN_FIELD_BASE(74, 84, 4, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(85, 86, 4, 0x0030, 0x10, 14, 1),
PIN_FIELD_BASE(87, 88, 4, 0x0030, 0x10, 12, 1),
PIN_FIELD_BASE(89, 90, 2, 0x00b0, 0x10, 19, 1),
PIN_FIELD_BASE(91, 91, 2, 0x00a0, 0x10, 0, 1),
PIN_FIELD_BASE(92, 92, 2, 0x00b0, 0x10, 28, 1),
PIN_FIELD_BASE(93, 93, 2, 0x00b0, 0x10, 30, 1),
PIN_FIELD_BASE(94, 94, 2, 0x00b0, 0x10, 29, 1),
PIN_FIELD_BASE(95, 95, 2, 0x00b0, 0x10, 31, 1),
PIN_FIELD_BASE(96, 96, 2, 0x00b0, 0x10, 26, 1),
PIN_FIELD_BASE(97, 97, 2, 0x00b0, 0x10, 21, 1),
PIN_FIELD_BASE(98, 98, 2, 0x00b0, 0x10, 27, 1),
PIN_FIELD_BASE(99, 102, 2, 0x00b0, 0x10, 22, 1),
PIN_FIELD_BASE(103, 103, 2, 0x00b0, 0x10, 17, 1),
PIN_FIELD_BASE(104, 104, 2, 0x00b0, 0x10, 16, 1),
PIN_FIELD_BASE(105, 105, 2, 0x00b0, 0x10, 18, 1),
PIN_FIELD_BASE(106, 106, 2, 0x00b0, 0x10, 15, 1),
PIN_FIELD_BASE(107, 108, 2, 0x00a0, 0x10, 10, 1),
PIN_FIELD_BASE(109, 109, 2, 0x00a0, 0x10, 25, 1),
PIN_FIELD_BASE(110, 110, 2, 0x00a0, 0x10, 22, 1),
PIN_FIELD_BASE(111, 111, 2, 0x00a0, 0x10, 24, 1),
PIN_FIELD_BASE(112, 112, 2, 0x00a0, 0x10, 26, 1),
PIN_FIELD_BASE(113, 113, 2, 0x00a0, 0x10, 23, 1),
PIN_FIELD_BASE(114, 114, 2, 0x00b0, 0x10, 7, 1),
PIN_FIELD_BASE(115, 115, 2, 0x00b0, 0x10, 6, 1),
PIN_FIELD_BASE(116, 116, 2, 0x00b0, 0x10, 8, 1),
PIN_FIELD_BASE(117, 117, 2, 0x00b0, 0x10, 5, 1),
PIN_FIELD_BASE(118, 118, 2, 0x00a0, 0x10, 31, 1),
PIN_FIELD_BASE(119, 119, 2, 0x00b0, 0x10, 9, 1),
PIN_FIELD_BASE(120, 120, 2, 0x00b0, 0x10, 4, 1),
PIN_FIELD_BASE(121, 121, 2, 0x00b0, 0x10, 14, 1),
PIN_FIELD_BASE(122, 122, 2, 0x00b0, 0x10, 3, 1),
PIN_FIELD_BASE(123, 123, 2, 0x00b0, 0x10, 13, 1),
PIN_FIELD_BASE(124, 124, 2, 0x00b0, 0x10, 2, 1),
PIN_FIELD_BASE(125, 125, 2, 0x00b0, 0x10, 12, 1),
PIN_FIELD_BASE(126, 129, 2, 0x00a0, 0x10, 27, 1),
PIN_FIELD_BASE(130, 132, 2, 0x00a0, 0x10, 7, 1),
PIN_FIELD_BASE(133, 135, 2, 0x00a0, 0x10, 4, 1),
PIN_FIELD_BASE(136, 138, 2, 0x00a0, 0x10, 1, 1),
PIN_FIELD_BASE(139, 139, 2, 0x00b0, 0x10, 1, 1),
PIN_FIELD_BASE(140, 140, 2, 0x00b0, 0x10, 11, 1),
PIN_FIELD_BASE(141, 141, 2, 0x00b0, 0x10, 0, 1),
PIN_FIELD_BASE(142, 142, 2, 0x00b0, 0x10, 10, 1),
PIN_FIELD_BASE(143, 145, 1, 0x0050, 0x10, 6, 1),
PIN_FIELD_BASE(146, 148, 1, 0x0050, 0x10, 3, 1),
PIN_FIELD_BASE(149, 151, 1, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(156, 159, 5, 0x0070, 0x10, 25, 1),
PIN_FIELD_BASE(160, 161, 5, 0x0070, 0x10, 23, 1),
PIN_FIELD_BASE(162, 171, 5, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(172, 173, 5, 0x0070, 0x10, 13, 1),
PIN_FIELD_BASE(174, 174, 5, 0x0070, 0x10, 12, 1),
PIN_FIELD_BASE(175, 175, 5, 0x0070, 0x10, 15, 1),
PIN_FIELD_BASE(176, 177, 5, 0x0070, 0x10, 10, 1),
PIN_FIELD_BASE(178, 182, 5, 0x0070, 0x10, 16, 1),
PIN_FIELD_BASE(195, 195, 7, 0x0090, 0x10, 25, 1),
PIN_FIELD_BASE(196, 196, 7, 0x0090, 0x10, 6, 1),
PIN_FIELD_BASE(197, 197, 7, 0x0090, 0x10, 8, 1),
PIN_FIELD_BASE(198, 198, 7, 0x0090, 0x10, 7, 1),
PIN_FIELD_BASE(199, 199, 7, 0x0090, 0x10, 3, 1),
PIN_FIELD_BASE(200, 200, 7, 0x0090, 0x10, 24, 1),
PIN_FIELD_BASE(201, 201, 7, 0x0090, 0x10, 27, 1),
PIN_FIELD_BASE(202, 202, 7, 0x0090, 0x10, 23, 1),
PIN_FIELD_BASE(203, 203, 7, 0x0090, 0x10, 26, 1),
PIN_FIELD_BASE(204, 205, 6, 0x0080, 0x10, 15, 1),
PIN_FIELD_BASE(206, 208, 7, 0x0090, 0x10, 28, 1),
PIN_FIELD_BASE(209, 209, 7, 0x0090, 0x10, 20, 1),
PIN_FIELD_BASE(210, 210, 7, 0x0090, 0x10, 19, 1),
PIN_FIELD_BASE(211, 211, 7, 0x0090, 0x10, 21, 1),
PIN_FIELD_BASE(212, 212, 7, 0x0090, 0x10, 18, 1),
PIN_FIELD_BASE(213, 213, 7, 0x0090, 0x10, 22, 1),
PIN_FIELD_BASE(214, 214, 7, 0x0090, 0x10, 0, 1),
PIN_FIELD_BASE(215, 215, 7, 0x0090, 0x10, 9, 1),
PIN_FIELD_BASE(216, 217, 7, 0x0090, 0x10, 4, 1),
PIN_FIELD_BASE(218, 219, 7, 0x0090, 0x10, 1, 1),
};
static const struct mtk_pin_field_calc mt6885_pin_pd_range[] = {
PIN_FIELD_BASE(0, 9, 2, 0x0080, 0x10, 12, 1),
PIN_FIELD_BASE(16, 17, 5, 0x0050, 0x10, 21, 1),
PIN_FIELD_BASE(18, 25, 7, 0x0070, 0x10, 10, 1),
PIN_FIELD_BASE(26, 30, 6, 0x0060, 0x10, 10, 1),
PIN_FIELD_BASE(31, 31, 6, 0x0060, 0x10, 6, 1),
PIN_FIELD_BASE(32, 32, 6, 0x0060, 0x10, 3, 1),
PIN_FIELD_BASE(33, 33, 6, 0x0060, 0x10, 5, 1),
PIN_FIELD_BASE(34, 34, 6, 0x0060, 0x10, 2, 1),
PIN_FIELD_BASE(35, 35, 6, 0x0060, 0x10, 4, 1),
PIN_FIELD_BASE(36, 39, 6, 0x0060, 0x10, 17, 1),
PIN_FIELD_BASE(40, 41, 6, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(42, 42, 6, 0x0060, 0x10, 9, 1),
PIN_FIELD_BASE(43, 44, 6, 0x0060, 0x10, 7, 1),
PIN_FIELD_BASE(57, 60, 3, 0x0030, 0x10, 12, 1),
PIN_FIELD_BASE(61, 61, 3, 0x0030, 0x10, 11, 1),
PIN_FIELD_BASE(62, 62, 4, 0x0020, 0x10, 11, 1),
PIN_FIELD_BASE(63, 64, 3, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(65, 72, 3, 0x0030, 0x10, 3, 1),
PIN_FIELD_BASE(73, 73, 3, 0x0030, 0x10, 2, 1),
PIN_FIELD_BASE(74, 84, 4, 0x0020, 0x10, 0, 1),
PIN_FIELD_BASE(85, 86, 4, 0x0020, 0x10, 14, 1),
PIN_FIELD_BASE(87, 88, 4, 0x0020, 0x10, 12, 1),
PIN_FIELD_BASE(89, 90, 2, 0x0090, 0x10, 19, 1),
PIN_FIELD_BASE(91, 91, 2, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(92, 92, 2, 0x0090, 0x10, 28, 1),
PIN_FIELD_BASE(93, 93, 2, 0x0090, 0x10, 30, 1),
PIN_FIELD_BASE(94, 94, 2, 0x0090, 0x10, 29, 1),
PIN_FIELD_BASE(95, 95, 2, 0x0090, 0x10, 31, 1),
PIN_FIELD_BASE(96, 96, 2, 0x0090, 0x10, 26, 1),
PIN_FIELD_BASE(97, 97, 2, 0x0090, 0x10, 21, 1),
PIN_FIELD_BASE(98, 98, 2, 0x0090, 0x10, 27, 1),
PIN_FIELD_BASE(99, 102, 2, 0x0090, 0x10, 22, 1),
PIN_FIELD_BASE(103, 103, 2, 0x0090, 0x10, 17, 1),
PIN_FIELD_BASE(104, 104, 2, 0x0090, 0x10, 16, 1),
PIN_FIELD_BASE(105, 105, 2, 0x0090, 0x10, 18, 1),
PIN_FIELD_BASE(106, 106, 2, 0x0090, 0x10, 15, 1),
PIN_FIELD_BASE(107, 108, 2, 0x0080, 0x10, 10, 1),
PIN_FIELD_BASE(109, 109, 2, 0x0080, 0x10, 25, 1),
PIN_FIELD_BASE(110, 110, 2, 0x0080, 0x10, 22, 1),
PIN_FIELD_BASE(111, 111, 2, 0x0080, 0x10, 24, 1),
PIN_FIELD_BASE(112, 112, 2, 0x0080, 0x10, 26, 1),
PIN_FIELD_BASE(113, 113, 2, 0x0080, 0x10, 23, 1),
PIN_FIELD_BASE(114, 114, 2, 0x0090, 0x10, 7, 1),
PIN_FIELD_BASE(115, 115, 2, 0x0090, 0x10, 6, 1),
PIN_FIELD_BASE(116, 116, 2, 0x0090, 0x10, 8, 1),
PIN_FIELD_BASE(117, 117, 2, 0x0090, 0x10, 5, 1),
PIN_FIELD_BASE(118, 118, 2, 0x0080, 0x10, 31, 1),
PIN_FIELD_BASE(119, 119, 2, 0x0090, 0x10, 9, 1),
PIN_FIELD_BASE(120, 120, 2, 0x0090, 0x10, 4, 1),
PIN_FIELD_BASE(121, 121, 2, 0x0090, 0x10, 14, 1),
PIN_FIELD_BASE(122, 122, 2, 0x0090, 0x10, 3, 1),
PIN_FIELD_BASE(123, 123, 2, 0x0090, 0x10, 13, 1),
PIN_FIELD_BASE(124, 124, 2, 0x0090, 0x10, 2, 1),
PIN_FIELD_BASE(125, 125, 2, 0x0090, 0x10, 12, 1),
PIN_FIELD_BASE(126, 129, 2, 0x0080, 0x10, 27, 1),
PIN_FIELD_BASE(130, 132, 2, 0x0080, 0x10, 7, 1),
PIN_FIELD_BASE(133, 135, 2, 0x0080, 0x10, 4, 1),
PIN_FIELD_BASE(136, 138, 2, 0x0080, 0x10, 1, 1),
PIN_FIELD_BASE(139, 139, 2, 0x0090, 0x10, 1, 1),
PIN_FIELD_BASE(140, 140, 2, 0x0090, 0x10, 11, 1),
PIN_FIELD_BASE(141, 141, 2, 0x0090, 0x10, 0, 1),
PIN_FIELD_BASE(142, 142, 2, 0x0090, 0x10, 10, 1),
PIN_FIELD_BASE(143, 145, 1, 0x0030, 0x10, 6, 1),
PIN_FIELD_BASE(146, 148, 1, 0x0030, 0x10, 3, 1),
PIN_FIELD_BASE(149, 151, 1, 0x0030, 0x10, 0, 1),
PIN_FIELD_BASE(156, 159, 5, 0x0050, 0x10, 25, 1),
PIN_FIELD_BASE(160, 161, 5, 0x0050, 0x10, 23, 1),
PIN_FIELD_BASE(162, 171, 5, 0x0050, 0x10, 0, 1),
PIN_FIELD_BASE(172, 173, 5, 0x0050, 0x10, 13, 1),
PIN_FIELD_BASE(174, 174, 5, 0x0050, 0x10, 12, 1),
PIN_FIELD_BASE(175, 175, 5, 0x0050, 0x10, 15, 1),
PIN_FIELD_BASE(176, 177, 5, 0x0050, 0x10, 10, 1),
PIN_FIELD_BASE(178, 182, 5, 0x0050, 0x10, 16, 1),
PIN_FIELD_BASE(195, 195, 7, 0x0070, 0x10, 25, 1),
PIN_FIELD_BASE(196, 196, 7, 0x0070, 0x10, 6, 1),
PIN_FIELD_BASE(197, 197, 7, 0x0070, 0x10, 8, 1),
PIN_FIELD_BASE(198, 198, 7, 0x0070, 0x10, 7, 1),
PIN_FIELD_BASE(199, 199, 7, 0x0070, 0x10, 3, 1),
PIN_FIELD_BASE(200, 200, 7, 0x0070, 0x10, 24, 1),
PIN_FIELD_BASE(201, 201, 7, 0x0070, 0x10, 27, 1),
PIN_FIELD_BASE(202, 202, 7, 0x0070, 0x10, 23, 1),
PIN_FIELD_BASE(203, 203, 7, 0x0070, 0x10, 26, 1),
PIN_FIELD_BASE(204, 205, 6, 0x0060, 0x10, 15, 1),
PIN_FIELD_BASE(206, 208, 7, 0x0070, 0x10, 28, 1),
PIN_FIELD_BASE(209, 209, 7, 0x0070, 0x10, 20, 1),
PIN_FIELD_BASE(210, 210, 7, 0x0070, 0x10, 19, 1),
PIN_FIELD_BASE(211, 211, 7, 0x0070, 0x10, 21, 1),
PIN_FIELD_BASE(212, 212, 7, 0x0070, 0x10, 18, 1),
PIN_FIELD_BASE(213, 213, 7, 0x0070, 0x10, 22, 1),
PIN_FIELD_BASE(214, 214, 7, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(215, 215, 7, 0x0070, 0x10, 9, 1),
PIN_FIELD_BASE(216, 217, 7, 0x0070, 0x10, 4, 1),
PIN_FIELD_BASE(218, 219, 7, 0x0070, 0x10, 1, 1),
};
static const struct mtk_pin_field_calc mt6885_pin_drv_range[] = {
PINS_FIELD_BASE(0, 9, 2, 0x0000, 0x10, 21, 3),
PINS_FIELD_BASE(10, 15, 1, 0x0000, 0x10, 12, 3),
PIN_FIELD_BASE(16, 17, 5, 0x0000, 0x10, 18, 3),
PINS_FIELD_BASE(18, 25, 7, 0x0000, 0x10, 3, 3),
PINS_FIELD_BASE(26, 30, 6, 0x0000, 0x10, 15, 3),
PINS_FIELD_BASE(31, 35, 6, 0x0000, 0x10, 6, 3),
PIN_FIELD_BASE(36, 36, 6, 0x0010, 0x10, 7, 3),
PINS_FIELD_BASE(37, 39, 6, 0x0010, 0x10, 4, 3),
PIN_FIELD_BASE(40, 41, 6, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(42, 42, 6, 0x0000, 0x10, 12, 3),
PINS_FIELD_BASE(43, 44, 6, 0x0000, 0x10, 9, 3),
PIN_FIELD_BASE(45, 45, 6, 0x0000, 0x10, 30, 2),
PIN_FIELD_BASE(46, 46, 6, 0x0010, 0x10, 2, 2),
PIN_FIELD_BASE(47, 47, 6, 0x0010, 0x10, 0, 2),
PIN_FIELD_BASE(48, 49, 6, 0x0000, 0x10, 26, 2),
PIN_FIELD_BASE(50, 50, 6, 0x0000, 0x10, 24, 2),
PIN_FIELD_BASE(51, 52, 3, 0x0000, 0x10, 18, 3),
PINS_FIELD_BASE(53, 56, 3, 0x0000, 0x10, 24, 3),
PIN_FIELD_BASE(57, 60, 3, 0x0000, 0x10, 6, 3),
PIN_FIELD_BASE(61, 61, 3, 0x0000, 0x10, 3, 3),
PIN_FIELD_BASE(62, 62, 4, 0x0000, 0x10, 3, 3),
PINS_FIELD_BASE(63, 73, 3, 0x0000, 0x10, 0, 3),
PINS_FIELD_BASE(74, 84, 4, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(85, 86, 4, 0x0000, 0x10, 12, 3),
PIN_FIELD_BASE(87, 88, 4, 0x0000, 0x10, 6, 3),
PIN_FIELD_BASE(89, 90, 2, 0x0020, 0x10, 15, 3),
PIN_FIELD_BASE(91, 91, 2, 0x0000, 0x10, 0, 3),
PINS_FIELD_BASE(92, 95, 2, 0x0030, 0x10, 3, 3),
PIN_FIELD_BASE(96, 96, 2, 0x0020, 0x10, 27, 3),
PIN_FIELD_BASE(97, 97, 2, 0x0020, 0x10, 21, 3),
PIN_FIELD_BASE(98, 98, 2, 0x0030, 0x10, 0, 3),
PINS_FIELD_BASE(99, 102, 2, 0x0020, 0x10, 24, 3),
PINS_FIELD_BASE(103, 105, 2, 0x0020, 0x10, 9, 3),
PIN_FIELD_BASE(106, 106, 2, 0x0020, 0x10, 12, 3),
PIN_FIELD_BASE(107, 108, 2, 0x0000, 0x10, 15, 3),
PINS_FIELD_BASE(109, 113, 2, 0x0000, 0x10, 24, 3),
PINS_FIELD_BASE(114, 117, 2, 0x0010, 0x10, 18, 3),
PIN_FIELD_BASE(118, 118, 2, 0x0010, 0x10, 0, 3),
PIN_FIELD_BASE(119, 119, 2, 0x0010, 0x10, 21, 3),
PIN_FIELD_BASE(120, 120, 2, 0x0010, 0x10, 15, 3),
PIN_FIELD_BASE(121, 121, 2, 0x0020, 0x10, 6, 3),
PIN_FIELD_BASE(122, 122, 2, 0x0010, 0x10, 12, 3),
PIN_FIELD_BASE(123, 123, 2, 0x0020, 0x10, 3, 3),
PIN_FIELD_BASE(124, 124, 2, 0x0010, 0x10, 9, 3),
PIN_FIELD_BASE(125, 125, 2, 0x0020, 0x10, 0, 3),
PINS_FIELD_BASE(126, 129, 2, 0x0000, 0x10, 27, 3),
PINS_FIELD_BASE(130, 135, 2, 0x0000, 0x10, 12, 3),
PIN_FIELD_BASE(136, 138, 2, 0x0000, 0x10, 3, 3),
PIN_FIELD_BASE(139, 139, 2, 0x0010, 0x10, 6, 3),
PIN_FIELD_BASE(140, 140, 2, 0x0010, 0x10, 27, 3),
PIN_FIELD_BASE(141, 141, 2, 0x0010, 0x10, 3, 3),
PIN_FIELD_BASE(142, 142, 2, 0x0010, 0x10, 24, 3),
PINS_FIELD_BASE(143, 148, 1, 0x0000, 0x10, 9, 3),
PIN_FIELD_BASE(149, 151, 1, 0x0000, 0x10, 0, 3),
PINS_FIELD_BASE(152, 155, 5, 0x0000, 0x10, 24, 3),
PIN_FIELD_BASE(156, 156, 5, 0x0010, 0x10, 6, 3),
PINS_FIELD_BASE(157, 159, 5, 0x0010, 0x10, 3, 3),
PIN_FIELD_BASE(160, 160, 5, 0x0000, 0x10, 27, 3),
PIN_FIELD_BASE(161, 161, 5, 0x0010, 0x10, 0, 3),
PINS_FIELD_BASE(162, 171, 5, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(172, 172, 5, 0x0000, 0x10, 15, 3),
PIN_FIELD_BASE(173, 173, 5, 0x0000, 0x10, 3, 3),
PIN_FIELD_BASE(174, 174, 5, 0x0000, 0x10, 12, 3),
PIN_FIELD_BASE(175, 177, 5, 0x0000, 0x10, 3, 3),
PINS_FIELD_BASE(178, 182, 5, 0x0000, 0x10, 3, 3),
PIN_FIELD_BASE(183, 183, 7, 0x0000, 0x10, 9, 3),
PINS_FIELD_BASE(184, 190, 7, 0x0000, 0x10, 12, 3),
PIN_FIELD_BASE(191, 191, 7, 0x0000, 0x10, 15, 3),
PIN_FIELD_BASE(192, 192, 7, 0x0000, 0x10, 6, 3),
PIN_FIELD_BASE(193, 193, 7, 0x0000, 0x10, 12, 3),
PIN_FIELD_BASE(194, 194, 7, 0x0000, 0x10, 18, 3),
PIN_FIELD_BASE(195, 195, 7, 0x0010, 0x10, 3, 3),
PINS_FIELD_BASE(196, 199, 7, 0x0000, 0x10, 0, 3),
PIN_FIELD_BASE(200, 200, 7, 0x0010, 0x10, 0, 3),
PIN_FIELD_BASE(201, 201, 7, 0x0010, 0x10, 9, 3),
PIN_FIELD_BASE(202, 202, 7, 0x0000, 0x10, 27, 3),
PIN_FIELD_BASE(203, 203, 7, 0x0010, 0x10, 6, 3),
PIN_FIELD_BASE(204, 205, 6, 0x0000, 0x10, 18, 3),
PIN_FIELD_BASE(206, 208, 7, 0x0010, 0x10, 12, 3),
PINS_FIELD_BASE(209, 212, 7, 0x0000, 0x10, 21, 3),
PIN_FIELD_BASE(213, 213, 7, 0x0000, 0x10, 24, 3),
PINS_FIELD_BASE(214, 219, 7, 0x0000, 0x10, 0, 3),
};
static const struct mtk_pin_field_calc mt6885_pin_pupd_range[] = {
PIN_FIELD_BASE(10, 15, 1, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(45, 45, 6, 0x0070, 0x10, 3, 1),
PIN_FIELD_BASE(46, 46, 6, 0x0070, 0x10, 5, 1),
PIN_FIELD_BASE(47, 47, 6, 0x0070, 0x10, 4, 1),
PIN_FIELD_BASE(48, 49, 6, 0x0070, 0x10, 1, 1),
PIN_FIELD_BASE(50, 50, 6, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(51, 52, 3, 0x0040, 0x10, 0, 1),
PIN_FIELD_BASE(53, 53, 3, 0x0040, 0x10, 5, 1),
PIN_FIELD_BASE(54, 54, 3, 0x0040, 0x10, 2, 1),
PIN_FIELD_BASE(55, 55, 3, 0x0040, 0x10, 4, 1),
PIN_FIELD_BASE(56, 56, 3, 0x0040, 0x10, 3, 1),
PIN_FIELD_BASE(152, 152, 5, 0x0060, 0x10, 3, 1),
PIN_FIELD_BASE(153, 153, 5, 0x0060, 0x10, 2, 1),
PIN_FIELD_BASE(154, 155, 5, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(183, 184, 7, 0x0080, 0x10, 1, 1),
PIN_FIELD_BASE(185, 185, 7, 0x0080, 0x10, 4, 1),
PIN_FIELD_BASE(186, 186, 7, 0x0080, 0x10, 6, 1),
PIN_FIELD_BASE(187, 187, 7, 0x0080, 0x10, 8, 1),
PIN_FIELD_BASE(188, 188, 7, 0x0080, 0x10, 3, 1),
PIN_FIELD_BASE(189, 189, 7, 0x0080, 0x10, 7, 1),
PIN_FIELD_BASE(190, 191, 7, 0x0080, 0x10, 9, 1),
PIN_FIELD_BASE(192, 192, 7, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(193, 193, 7, 0x0080, 0x10, 5, 1),
PIN_FIELD_BASE(194, 194, 7, 0x0080, 0x10, 11, 1),
};
static const struct mtk_pin_field_calc mt6885_pin_r0_range[] = {
PIN_FIELD_BASE(10, 15, 1, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(24, 24, 7, 0x00e0, 0x10, 0, 1),
PIN_FIELD_BASE(25, 25, 7, 0x00e0, 0x10, 2, 1),
PIN_FIELD_BASE(45, 45, 6, 0x0090, 0x10, 3, 1),
PIN_FIELD_BASE(46, 46, 6, 0x0090, 0x10, 5, 1),
PIN_FIELD_BASE(47, 47, 6, 0x0090, 0x10, 4, 1),
PIN_FIELD_BASE(48, 49, 6, 0x0090, 0x10, 1, 1),
PIN_FIELD_BASE(50, 50, 6, 0x0090, 0x10, 0, 1),
PIN_FIELD_BASE(51, 52, 3, 0x0060, 0x10, 0, 1),
PIN_FIELD_BASE(53, 53, 3, 0x0060, 0x10, 5, 1),
PIN_FIELD_BASE(54, 54, 3, 0x0060, 0x10, 2, 1),
PIN_FIELD_BASE(55, 55, 3, 0x0060, 0x10, 4, 1),
PIN_FIELD_BASE(56, 56, 3, 0x0060, 0x10, 3, 1),
PIN_FIELD_BASE(118, 118, 2, 0x00e0, 0x10, 0, 1),
PIN_FIELD_BASE(119, 119, 2, 0x00e0, 0x10, 12, 1),
PIN_FIELD_BASE(120, 120, 2, 0x00e0, 0x10, 10, 1),
PIN_FIELD_BASE(121, 121, 2, 0x00e0, 0x10, 22, 1),
PIN_FIELD_BASE(122, 122, 2, 0x00e0, 0x10, 8, 1),
PIN_FIELD_BASE(123, 123, 2, 0x00e0, 0x10, 20, 1),
PIN_FIELD_BASE(124, 124, 2, 0x00e0, 0x10, 6, 1),
PIN_FIELD_BASE(125, 125, 2, 0x00e0, 0x10, 18, 1),
PIN_FIELD_BASE(139, 139, 2, 0x00e0, 0x10, 4, 1),
PIN_FIELD_BASE(140, 140, 2, 0x00e0, 0x10, 16, 1),
PIN_FIELD_BASE(141, 141, 2, 0x00e0, 0x10, 2, 1),
PIN_FIELD_BASE(142, 142, 2, 0x00e0, 0x10, 14, 1),
PIN_FIELD_BASE(152, 152, 5, 0x0080, 0x10, 3, 1),
PIN_FIELD_BASE(153, 153, 5, 0x0080, 0x10, 2, 1),
PIN_FIELD_BASE(154, 155, 5, 0x0080, 0x10, 0, 1),
PIN_FIELD_BASE(160, 160, 5, 0x00b0, 0x10, 0, 1),
PIN_FIELD_BASE(161, 161, 5, 0x00b0, 0x10, 2, 1),
PIN_FIELD_BASE(183, 184, 7, 0x00a0, 0x10, 1, 1),
PIN_FIELD_BASE(185, 185, 7, 0x00a0, 0x10, 4, 1),
PIN_FIELD_BASE(186, 186, 7, 0x00a0, 0x10, 6, 1),
PIN_FIELD_BASE(187, 187, 7, 0x00a0, 0x10, 8, 1),
PIN_FIELD_BASE(188, 188, 7, 0x00a0, 0x10, 3, 1),
PIN_FIELD_BASE(189, 189, 7, 0x00a0, 0x10, 7, 1),
PIN_FIELD_BASE(190, 191, 7, 0x00a0, 0x10, 9, 1),
PIN_FIELD_BASE(192, 192, 7, 0x00a0, 0x10, 0, 1),
PIN_FIELD_BASE(193, 193, 7, 0x00a0, 0x10, 5, 1),
PIN_FIELD_BASE(194, 194, 7, 0x00a0, 0x10, 11, 1),
PIN_FIELD_BASE(200, 200, 7, 0x00e0, 0x10, 6, 1),
PIN_FIELD_BASE(201, 201, 7, 0x00e0, 0x10, 10, 1),
PIN_FIELD_BASE(202, 202, 7, 0x00e0, 0x10, 4, 1),
PIN_FIELD_BASE(203, 203, 7, 0x00e0, 0x10, 8, 1),
PIN_FIELD_BASE(204, 204, 6, 0x00d0, 0x10, 0, 1),
PIN_FIELD_BASE(205, 205, 6, 0x00d0, 0x10, 2, 1),
};
static const struct mtk_pin_field_calc mt6885_pin_r1_range[] = {
PIN_FIELD_BASE(10, 15, 1, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(24, 24, 7, 0x00e0, 0x10, 1, 1),
PIN_FIELD_BASE(25, 25, 7, 0x00e0, 0x10, 3, 1),
PIN_FIELD_BASE(45, 45, 6, 0x00a0, 0x10, 3, 1),
PIN_FIELD_BASE(46, 46, 6, 0x00a0, 0x10, 5, 1),
PIN_FIELD_BASE(47, 47, 6, 0x00a0, 0x10, 4, 1),
PIN_FIELD_BASE(48, 49, 6, 0x00a0, 0x10, 1, 1),
PIN_FIELD_BASE(50, 50, 6, 0x00a0, 0x10, 0, 1),
PIN_FIELD_BASE(51, 52, 3, 0x0070, 0x10, 0, 1),
PIN_FIELD_BASE(53, 53, 3, 0x0070, 0x10, 5, 1),
PIN_FIELD_BASE(54, 54, 3, 0x0070, 0x10, 2, 1),
PIN_FIELD_BASE(55, 55, 3, 0x0070, 0x10, 4, 1),
PIN_FIELD_BASE(56, 56, 3, 0x0070, 0x10, 3, 1),
PIN_FIELD_BASE(118, 118, 2, 0x00e0, 0x10, 1, 1),
PIN_FIELD_BASE(119, 119, 2, 0x00e0, 0x10, 13, 1),
PIN_FIELD_BASE(120, 120, 2, 0x00e0, 0x10, 11, 1),
PIN_FIELD_BASE(121, 121, 2, 0x00e0, 0x10, 23, 1),
PIN_FIELD_BASE(122, 122, 2, 0x00e0, 0x10, 9, 1),
PIN_FIELD_BASE(123, 123, 2, 0x00e0, 0x10, 21, 1),
PIN_FIELD_BASE(124, 124, 2, 0x00e0, 0x10, 7, 1),
PIN_FIELD_BASE(125, 125, 2, 0x00e0, 0x10, 19, 1),
PIN_FIELD_BASE(139, 139, 2, 0x00e0, 0x10, 5, 1),
PIN_FIELD_BASE(140, 140, 2, 0x00e0, 0x10, 17, 1),
PIN_FIELD_BASE(141, 141, 2, 0x00e0, 0x10, 3, 1),
PIN_FIELD_BASE(142, 142, 2, 0x00e0, 0x10, 15, 1),
PIN_FIELD_BASE(152, 152, 5, 0x0090, 0x10, 3, 1),
PIN_FIELD_BASE(153, 153, 5, 0x0090, 0x10, 2, 1),
PIN_FIELD_BASE(154, 155, 5, 0x0090, 0x10, 0, 1),
PIN_FIELD_BASE(160, 160, 5, 0x00b0, 0x10, 1, 1),
PIN_FIELD_BASE(161, 161, 5, 0x00b0, 0x10, 3, 1),
PIN_FIELD_BASE(183, 184, 7, 0x00b0, 0x10, 1, 1),
PIN_FIELD_BASE(185, 185, 7, 0x00b0, 0x10, 4, 1),
PIN_FIELD_BASE(186, 186, 7, 0x00b0, 0x10, 6, 1),
PIN_FIELD_BASE(187, 187, 7, 0x00b0, 0x10, 8, 1),
PIN_FIELD_BASE(188, 188, 7, 0x00b0, 0x10, 3, 1),
PIN_FIELD_BASE(189, 189, 7, 0x00b0, 0x10, 7, 1),
PIN_FIELD_BASE(190, 191, 7, 0x00b0, 0x10, 9, 1),
PIN_FIELD_BASE(192, 192, 7, 0x00b0, 0x10, 0, 1),
PIN_FIELD_BASE(193, 193, 7, 0x00b0, 0x10, 5, 1),
PIN_FIELD_BASE(194, 194, 7, 0x00b0, 0x10, 11, 1),
PIN_FIELD_BASE(200, 200, 7, 0x00e0, 0x10, 7, 1),
PIN_FIELD_BASE(201, 201, 7, 0x00e0, 0x10, 11, 1),
PIN_FIELD_BASE(202, 202, 7, 0x00e0, 0x10, 5, 1),
PIN_FIELD_BASE(203, 203, 7, 0x00e0, 0x10, 9, 1),
PIN_FIELD_BASE(204, 204, 6, 0x00d0, 0x10, 1, 1),
PIN_FIELD_BASE(205, 205, 6, 0x00d0, 0x10, 3, 1),
};
static const struct mtk_pin_field_calc mt6885_pin_eh_range[] = {
PIN_FIELD_BASE(24, 24, 7, 0x0030, 0x10, 0, 3),
PIN_FIELD_BASE(25, 25, 7, 0x0030, 0x10, 3, 3),
PIN_FIELD_BASE(89, 89, 2, 0x0050, 0x10, 6, 5),
PIN_FIELD_BASE(90, 90, 2, 0x0050, 0x10, 11, 5),
PIN_FIELD_BASE(118, 118, 2, 0x0040, 0x10, 0, 3),
PIN_FIELD_BASE(119, 119, 2, 0x0040, 0x10, 18, 3),
PIN_FIELD_BASE(120, 120, 2, 0x0040, 0x10, 15, 3),
PIN_FIELD_BASE(121, 121, 2, 0x0050, 0x10, 3, 3),
PIN_FIELD_BASE(122, 122, 2, 0x0040, 0x10, 12, 3),
PIN_FIELD_BASE(123, 123, 2, 0x0050, 0x10, 0, 3),
PIN_FIELD_BASE(124, 124, 2, 0x0040, 0x10, 9, 3),
PIN_FIELD_BASE(125, 125, 2, 0x0040, 0x10, 27, 3),
PIN_FIELD_BASE(139, 139, 2, 0x0040, 0x10, 6, 3),
PIN_FIELD_BASE(140, 140, 2, 0x0040, 0x10, 24, 3),
PIN_FIELD_BASE(141, 141, 2, 0x0040, 0x10, 3, 3),
PIN_FIELD_BASE(142, 142, 2, 0x0040, 0x10, 21, 3),
PIN_FIELD_BASE(160, 160, 5, 0x0020, 0x10, 0, 3),
PIN_FIELD_BASE(161, 161, 5, 0x0020, 0x10, 3, 3),
PIN_FIELD_BASE(200, 200, 7, 0x0030, 0x10, 9, 3),
PIN_FIELD_BASE(201, 201, 7, 0x0030, 0x10, 15, 3),
PIN_FIELD_BASE(202, 202, 7, 0x0030, 0x10, 6, 3),
PIN_FIELD_BASE(203, 203, 7, 0x0030, 0x10, 12, 3),
PIN_FIELD_BASE(204, 204, 6, 0x0020, 0x10, 0, 3),
PIN_FIELD_BASE(205, 205, 6, 0x0020, 0x10, 3, 3),
};
static const struct mtk_pin_reg_calc mt6885_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt6885_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt6885_pin_dir_range),
[PINCTRL_PIN_REG_DI] = MTK_RANGE(mt6885_pin_di_range),
[PINCTRL_PIN_REG_DO] = MTK_RANGE(mt6885_pin_do_range),
[PINCTRL_PIN_REG_SR] = MTK_RANGE(mt6885_pin_dir_range),
[PINCTRL_PIN_REG_SMT] = MTK_RANGE(mt6885_pin_smt_range),
[PINCTRL_PIN_REG_IES] = MTK_RANGE(mt6885_pin_ies_range),
[PINCTRL_PIN_REG_PU] = MTK_RANGE(mt6885_pin_pu_range),
[PINCTRL_PIN_REG_PD] = MTK_RANGE(mt6885_pin_pd_range),
[PINCTRL_PIN_REG_DRV] = MTK_RANGE(mt6885_pin_drv_range),
[PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt6885_pin_pupd_range),
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt6885_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt6885_pin_r1_range),
[PINCTRL_PIN_REG_DRV_EH] = MTK_RANGE(mt6885_pin_eh_range),
};
static const struct mtk_eh_pin_pinmux mt6885_eh_pin_pinmux_list[] = {
/* pin number, pinmux number */
{89, 2},
{90, 2},
{118, 1},
{119, 1},
{120, 1},
{121, 1},
{122, 1},
{123, 1},
{124, 1},
{125, 1},
{139, 1},
{140, 1},
{141, 1},
{142, 1},
{160, 1},
{161, 1},
{200, 1},
{201, 1},
{202, 1},
{203, 1},
{204, 1},
{205, 1},
{0xffff, 0}, /* indicate end of array */
};
static const struct mtk_eint_hw mt6885_eint_hw = {
.port_mask = 7,
.ports = 7,
.ap_num = 223,
.db_cnt = 32,
};
static const struct mtk_pin_soc mt6885_data = {
.reg_cal = mt6885_reg_cals,
.pins = mtk_pins_mt6885,
.npins = ARRAY_SIZE(mtk_pins_mt6885),
.ngrps = ARRAY_SIZE(mtk_pins_mt6885),
.eint_hw = &mt6885_eint_hw,
.nfuncs = 8,
.gpio_m = 0,
.race_free_access = true,
.eh_pin_pinmux = mt6885_eh_pin_pinmux_list,
.bias_set_combo = mtk_pinconf_bias_set_combo,
.bias_get_combo = mtk_pinconf_bias_get_combo,
.drive_set = mtk_pinconf_drive_set_raw,
.drive_get = mtk_pinconf_drive_get_raw,
.adv_pull_get = mtk_pinconf_adv_pull_get,
.adv_pull_set = mtk_pinconf_adv_pull_set,
.adv_drive_get = mtk_pinconf_adv_drive_get,
.adv_drive_set = mtk_pinconf_adv_drive_set,
};
static const struct of_device_id mt6885_pinctrl_of_match[] = {
{ .compatible = "mediatek,mt6885-pinctrl", },
{ }
};
static int mt6885_pinctrl_probe(struct platform_device *pdev)
{
return mtk_paris_pinctrl_probe(pdev, &mt6885_data);
}
static struct platform_driver mt6885_pinctrl_driver = {
.driver = {
.name = "mt6885-pinctrl",
.of_match_table = mt6885_pinctrl_of_match,
.pm = &mtk_eint_pm_ops_v2,
},
.probe = mt6885_pinctrl_probe,
};
static int __init mt6885_pinctrl_init(void)
{
return platform_driver_register(&mt6885_pinctrl_driver);
}
arch_initcall(mt6885_pinctrl_init);
+802
View File
@@ -0,0 +1,802 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2017-2018 MediaTek Inc.
*
* Author: Sean Wang <sean.wang@mediatek.com>
*
*/
#include "pinctrl-moore.h"
#define MT7622_PIN(_number, _name) \
MTK_PIN(_number, _name, 1, _number, DRV_GRP0)
static const struct mtk_pin_field_calc mt7622_pin_mode_range[] = {
PIN_FIELD(0, 0, 0x320, 0x10, 16, 4),
PIN_FIELD(1, 4, 0x3a0, 0x10, 16, 4),
PIN_FIELD(5, 5, 0x320, 0x10, 0, 4),
PINS_FIELD(6, 7, 0x300, 0x10, 4, 4),
PIN_FIELD(8, 9, 0x350, 0x10, 20, 4),
PINS_FIELD(10, 13, 0x300, 0x10, 8, 4),
PIN_FIELD(14, 15, 0x320, 0x10, 4, 4),
PIN_FIELD(16, 17, 0x320, 0x10, 20, 4),
PIN_FIELD(18, 21, 0x310, 0x10, 16, 4),
PIN_FIELD(22, 22, 0x380, 0x10, 16, 4),
PINS_FIELD(23, 24, 0x300, 0x10, 24, 4),
PINS_FIELD(25, 36, 0x300, 0x10, 12, 4),
PINS_FIELD(37, 50, 0x300, 0x10, 20, 4),
PIN_FIELD(51, 70, 0x330, 0x10, 4, 4),
PINS_FIELD(71, 72, 0x300, 0x10, 16, 4),
PIN_FIELD(73, 76, 0x310, 0x10, 0, 4),
PIN_FIELD(77, 77, 0x320, 0x10, 28, 4),
PIN_FIELD(78, 78, 0x320, 0x10, 12, 4),
PIN_FIELD(79, 82, 0x3a0, 0x10, 0, 4),
PIN_FIELD(83, 83, 0x350, 0x10, 28, 4),
PIN_FIELD(84, 84, 0x330, 0x10, 0, 4),
PIN_FIELD(85, 90, 0x360, 0x10, 4, 4),
PIN_FIELD(91, 94, 0x390, 0x10, 16, 4),
PIN_FIELD(95, 97, 0x380, 0x10, 20, 4),
PIN_FIELD(98, 101, 0x390, 0x10, 0, 4),
PIN_FIELD(102, 102, 0x360, 0x10, 0, 4),
};
static const struct mtk_pin_field_calc mt7622_pin_dir_range[] = {
PIN_FIELD(0, 102, 0x0, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt7622_pin_di_range[] = {
PIN_FIELD(0, 102, 0x200, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt7622_pin_do_range[] = {
PIN_FIELD(0, 102, 0x100, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt7622_pin_sr_range[] = {
PIN_FIELD(0, 31, 0x910, 0x10, 0, 1),
PIN_FIELD(32, 50, 0xa10, 0x10, 0, 1),
PIN_FIELD(51, 70, 0x810, 0x10, 0, 1),
PIN_FIELD(71, 72, 0xb10, 0x10, 0, 1),
PIN_FIELD(73, 86, 0xb10, 0x10, 4, 1),
PIN_FIELD(87, 90, 0xc10, 0x10, 0, 1),
PIN_FIELD(91, 102, 0xb10, 0x10, 18, 1),
};
static const struct mtk_pin_field_calc mt7622_pin_smt_range[] = {
PIN_FIELD(0, 31, 0x920, 0x10, 0, 1),
PIN_FIELD(32, 50, 0xa20, 0x10, 0, 1),
PIN_FIELD(51, 70, 0x820, 0x10, 0, 1),
PIN_FIELD(71, 72, 0xb20, 0x10, 0, 1),
PIN_FIELD(73, 86, 0xb20, 0x10, 4, 1),
PIN_FIELD(87, 90, 0xc20, 0x10, 0, 1),
PIN_FIELD(91, 102, 0xb20, 0x10, 18, 1),
};
static const struct mtk_pin_field_calc mt7622_pin_pu_range[] = {
PIN_FIELD(0, 31, 0x930, 0x10, 0, 1),
PIN_FIELD(32, 50, 0xa30, 0x10, 0, 1),
PIN_FIELD(51, 70, 0x830, 0x10, 0, 1),
PIN_FIELD(71, 72, 0xb30, 0x10, 0, 1),
PIN_FIELD(73, 86, 0xb30, 0x10, 4, 1),
PIN_FIELD(87, 90, 0xc30, 0x10, 0, 1),
PIN_FIELD(91, 102, 0xb30, 0x10, 18, 1),
};
static const struct mtk_pin_field_calc mt7622_pin_pd_range[] = {
PIN_FIELD(0, 31, 0x940, 0x10, 0, 1),
PIN_FIELD(32, 50, 0xa40, 0x10, 0, 1),
PIN_FIELD(51, 70, 0x840, 0x10, 0, 1),
PIN_FIELD(71, 72, 0xb40, 0x10, 0, 1),
PIN_FIELD(73, 86, 0xb40, 0x10, 4, 1),
PIN_FIELD(87, 90, 0xc40, 0x10, 0, 1),
PIN_FIELD(91, 102, 0xb40, 0x10, 18, 1),
};
static const struct mtk_pin_field_calc mt7622_pin_e4_range[] = {
PIN_FIELD(0, 31, 0x960, 0x10, 0, 1),
PIN_FIELD(32, 50, 0xa60, 0x10, 0, 1),
PIN_FIELD(51, 70, 0x860, 0x10, 0, 1),
PIN_FIELD(71, 72, 0xb60, 0x10, 0, 1),
PIN_FIELD(73, 86, 0xb60, 0x10, 4, 1),
PIN_FIELD(87, 90, 0xc60, 0x10, 0, 1),
PIN_FIELD(91, 102, 0xb60, 0x10, 18, 1),
};
static const struct mtk_pin_field_calc mt7622_pin_e8_range[] = {
PIN_FIELD(0, 31, 0x970, 0x10, 0, 1),
PIN_FIELD(32, 50, 0xa70, 0x10, 0, 1),
PIN_FIELD(51, 70, 0x870, 0x10, 0, 1),
PIN_FIELD(71, 72, 0xb70, 0x10, 0, 1),
PIN_FIELD(73, 86, 0xb70, 0x10, 4, 1),
PIN_FIELD(87, 90, 0xc70, 0x10, 0, 1),
PIN_FIELD(91, 102, 0xb70, 0x10, 18, 1),
};
static const struct mtk_pin_field_calc mt7622_pin_tdsel_range[] = {
PIN_FIELD(0, 31, 0x980, 0x4, 0, 4),
PIN_FIELD(32, 50, 0xa80, 0x4, 0, 4),
PIN_FIELD(51, 70, 0x880, 0x4, 0, 4),
PIN_FIELD(71, 72, 0xb80, 0x4, 0, 4),
PIN_FIELD(73, 86, 0xb80, 0x4, 16, 4),
PIN_FIELD(87, 90, 0xc80, 0x4, 0, 4),
PIN_FIELD(91, 102, 0xb88, 0x4, 8, 4),
};
static const struct mtk_pin_field_calc mt7622_pin_rdsel_range[] = {
PIN_FIELD(0, 31, 0x990, 0x4, 0, 6),
PIN_FIELD(32, 50, 0xa90, 0x4, 0, 6),
PIN_FIELD(51, 58, 0x890, 0x4, 0, 6),
PIN_FIELD(59, 60, 0x894, 0x4, 28, 6),
PIN_FIELD(61, 62, 0x894, 0x4, 16, 6),
PIN_FIELD(63, 66, 0x898, 0x4, 8, 6),
PIN_FIELD(67, 68, 0x89c, 0x4, 12, 6),
PIN_FIELD(69, 70, 0x89c, 0x4, 0, 6),
PIN_FIELD(71, 72, 0xb90, 0x4, 0, 6),
PIN_FIELD(73, 86, 0xb90, 0x4, 24, 6),
PIN_FIELD(87, 90, 0xc90, 0x4, 0, 6),
PIN_FIELD(91, 102, 0xb9c, 0x4, 12, 6),
};
static const struct mtk_pin_reg_calc mt7622_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt7622_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt7622_pin_dir_range),
[PINCTRL_PIN_REG_DI] = MTK_RANGE(mt7622_pin_di_range),
[PINCTRL_PIN_REG_DO] = MTK_RANGE(mt7622_pin_do_range),
[PINCTRL_PIN_REG_SR] = MTK_RANGE(mt7622_pin_sr_range),
[PINCTRL_PIN_REG_SMT] = MTK_RANGE(mt7622_pin_smt_range),
[PINCTRL_PIN_REG_PU] = MTK_RANGE(mt7622_pin_pu_range),
[PINCTRL_PIN_REG_PD] = MTK_RANGE(mt7622_pin_pd_range),
[PINCTRL_PIN_REG_E4] = MTK_RANGE(mt7622_pin_e4_range),
[PINCTRL_PIN_REG_E8] = MTK_RANGE(mt7622_pin_e8_range),
[PINCTRL_PIN_REG_TDSEL] = MTK_RANGE(mt7622_pin_tdsel_range),
[PINCTRL_PIN_REG_RDSEL] = MTK_RANGE(mt7622_pin_rdsel_range),
};
static const struct mtk_pin_desc mt7622_pins[] = {
MT7622_PIN(0, "GPIO_A"),
MT7622_PIN(1, "I2S1_IN"),
MT7622_PIN(2, "I2S1_OUT"),
MT7622_PIN(3, "I2S_BCLK"),
MT7622_PIN(4, "I2S_WS"),
MT7622_PIN(5, "I2S_MCLK"),
MT7622_PIN(6, "TXD0"),
MT7622_PIN(7, "RXD0"),
MT7622_PIN(8, "SPI_WP"),
MT7622_PIN(9, "SPI_HOLD"),
MT7622_PIN(10, "SPI_CLK"),
MT7622_PIN(11, "SPI_MOSI"),
MT7622_PIN(12, "SPI_MISO"),
MT7622_PIN(13, "SPI_CS"),
MT7622_PIN(14, "I2C_SDA"),
MT7622_PIN(15, "I2C_SCL"),
MT7622_PIN(16, "I2S2_IN"),
MT7622_PIN(17, "I2S3_IN"),
MT7622_PIN(18, "I2S4_IN"),
MT7622_PIN(19, "I2S2_OUT"),
MT7622_PIN(20, "I2S3_OUT"),
MT7622_PIN(21, "I2S4_OUT"),
MT7622_PIN(22, "GPIO_B"),
MT7622_PIN(23, "MDC"),
MT7622_PIN(24, "MDIO"),
MT7622_PIN(25, "G2_TXD0"),
MT7622_PIN(26, "G2_TXD1"),
MT7622_PIN(27, "G2_TXD2"),
MT7622_PIN(28, "G2_TXD3"),
MT7622_PIN(29, "G2_TXEN"),
MT7622_PIN(30, "G2_TXC"),
MT7622_PIN(31, "G2_RXD0"),
MT7622_PIN(32, "G2_RXD1"),
MT7622_PIN(33, "G2_RXD2"),
MT7622_PIN(34, "G2_RXD3"),
MT7622_PIN(35, "G2_RXDV"),
MT7622_PIN(36, "G2_RXC"),
MT7622_PIN(37, "NCEB"),
MT7622_PIN(38, "NWEB"),
MT7622_PIN(39, "NREB"),
MT7622_PIN(40, "NDL4"),
MT7622_PIN(41, "NDL5"),
MT7622_PIN(42, "NDL6"),
MT7622_PIN(43, "NDL7"),
MT7622_PIN(44, "NRB"),
MT7622_PIN(45, "NCLE"),
MT7622_PIN(46, "NALE"),
MT7622_PIN(47, "NDL0"),
MT7622_PIN(48, "NDL1"),
MT7622_PIN(49, "NDL2"),
MT7622_PIN(50, "NDL3"),
MT7622_PIN(51, "MDI_TP_P0"),
MT7622_PIN(52, "MDI_TN_P0"),
MT7622_PIN(53, "MDI_RP_P0"),
MT7622_PIN(54, "MDI_RN_P0"),
MT7622_PIN(55, "MDI_TP_P1"),
MT7622_PIN(56, "MDI_TN_P1"),
MT7622_PIN(57, "MDI_RP_P1"),
MT7622_PIN(58, "MDI_RN_P1"),
MT7622_PIN(59, "MDI_RP_P2"),
MT7622_PIN(60, "MDI_RN_P2"),
MT7622_PIN(61, "MDI_TP_P2"),
MT7622_PIN(62, "MDI_TN_P2"),
MT7622_PIN(63, "MDI_TP_P3"),
MT7622_PIN(64, "MDI_TN_P3"),
MT7622_PIN(65, "MDI_RP_P3"),
MT7622_PIN(66, "MDI_RN_P3"),
MT7622_PIN(67, "MDI_RP_P4"),
MT7622_PIN(68, "MDI_RN_P4"),
MT7622_PIN(69, "MDI_TP_P4"),
MT7622_PIN(70, "MDI_TN_P4"),
MT7622_PIN(71, "PMIC_SCL"),
MT7622_PIN(72, "PMIC_SDA"),
MT7622_PIN(73, "SPIC1_CLK"),
MT7622_PIN(74, "SPIC1_MOSI"),
MT7622_PIN(75, "SPIC1_MISO"),
MT7622_PIN(76, "SPIC1_CS"),
MT7622_PIN(77, "GPIO_D"),
MT7622_PIN(78, "WATCHDOG"),
MT7622_PIN(79, "RTS3_N"),
MT7622_PIN(80, "CTS3_N"),
MT7622_PIN(81, "TXD3"),
MT7622_PIN(82, "RXD3"),
MT7622_PIN(83, "PERST0_N"),
MT7622_PIN(84, "PERST1_N"),
MT7622_PIN(85, "WLED_N"),
MT7622_PIN(86, "EPHY_LED0_N"),
MT7622_PIN(87, "AUXIN0"),
MT7622_PIN(88, "AUXIN1"),
MT7622_PIN(89, "AUXIN2"),
MT7622_PIN(90, "AUXIN3"),
MT7622_PIN(91, "TXD4"),
MT7622_PIN(92, "RXD4"),
MT7622_PIN(93, "RTS4_N"),
MT7622_PIN(94, "CTS4_N"),
MT7622_PIN(95, "PWM1"),
MT7622_PIN(96, "PWM2"),
MT7622_PIN(97, "PWM3"),
MT7622_PIN(98, "PWM4"),
MT7622_PIN(99, "PWM5"),
MT7622_PIN(100, "PWM6"),
MT7622_PIN(101, "PWM7"),
MT7622_PIN(102, "GPIO_E"),
};
/* List all groups consisting of these pins dedicated to the enablement of
* certain hardware block and the corresponding mode for all of the pins. The
* hardware probably has multiple combinations of these pinouts.
*/
/* EMMC */
static int mt7622_emmc_pins[] = { 40, 41, 42, 43, 44, 45, 47, 48, 49, 50, };
static int mt7622_emmc_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, };
static int mt7622_emmc_rst_pins[] = { 37, };
static int mt7622_emmc_rst_funcs[] = { 1, };
/* LED for EPHY */
static int mt7622_ephy_leds_pins[] = { 86, 91, 92, 93, 94, };
static int mt7622_ephy_leds_funcs[] = { 0, 0, 0, 0, 0, };
static int mt7622_ephy0_led_pins[] = { 86, };
static int mt7622_ephy0_led_funcs[] = { 0, };
static int mt7622_ephy1_led_pins[] = { 91, };
static int mt7622_ephy1_led_funcs[] = { 2, };
static int mt7622_ephy2_led_pins[] = { 92, };
static int mt7622_ephy2_led_funcs[] = { 2, };
static int mt7622_ephy3_led_pins[] = { 93, };
static int mt7622_ephy3_led_funcs[] = { 2, };
static int mt7622_ephy4_led_pins[] = { 94, };
static int mt7622_ephy4_led_funcs[] = { 2, };
/* Embedded Switch */
static int mt7622_esw_pins[] = { 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
62, 63, 64, 65, 66, 67, 68, 69, 70, };
static int mt7622_esw_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, };
static int mt7622_esw_p0_p1_pins[] = { 51, 52, 53, 54, 55, 56, 57, 58, };
static int mt7622_esw_p0_p1_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
static int mt7622_esw_p2_p3_p4_pins[] = { 59, 60, 61, 62, 63, 64, 65, 66, 67,
68, 69, 70, };
static int mt7622_esw_p2_p3_p4_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, };
/* RGMII via ESW */
static int mt7622_rgmii_via_esw_pins[] = { 59, 60, 61, 62, 63, 64, 65, 66,
67, 68, 69, 70, };
static int mt7622_rgmii_via_esw_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, };
/* RGMII via GMAC1 */
static int mt7622_rgmii_via_gmac1_pins[] = { 59, 60, 61, 62, 63, 64, 65, 66,
67, 68, 69, 70, };
static int mt7622_rgmii_via_gmac1_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, };
/* RGMII via GMAC2 */
static int mt7622_rgmii_via_gmac2_pins[] = { 25, 26, 27, 28, 29, 30, 31, 32,
33, 34, 35, 36, };
static int mt7622_rgmii_via_gmac2_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, };
/* I2C */
static int mt7622_i2c0_pins[] = { 14, 15, };
static int mt7622_i2c0_funcs[] = { 0, 0, };
static int mt7622_i2c1_0_pins[] = { 55, 56, };
static int mt7622_i2c1_0_funcs[] = { 0, 0, };
static int mt7622_i2c1_1_pins[] = { 73, 74, };
static int mt7622_i2c1_1_funcs[] = { 3, 3, };
static int mt7622_i2c1_2_pins[] = { 87, 88, };
static int mt7622_i2c1_2_funcs[] = { 0, 0, };
static int mt7622_i2c2_0_pins[] = { 57, 58, };
static int mt7622_i2c2_0_funcs[] = { 0, 0, };
static int mt7622_i2c2_1_pins[] = { 75, 76, };
static int mt7622_i2c2_1_funcs[] = { 3, 3, };
static int mt7622_i2c2_2_pins[] = { 89, 90, };
static int mt7622_i2c2_2_funcs[] = { 0, 0, };
/* I2S */
static int mt7622_i2s_in_mclk_bclk_ws_pins[] = { 3, 4, 5, };
static int mt7622_i2s_in_mclk_bclk_ws_funcs[] = { 3, 3, 0, };
static int mt7622_i2s1_in_data_pins[] = { 1, };
static int mt7622_i2s1_in_data_funcs[] = { 0, };
static int mt7622_i2s2_in_data_pins[] = { 16, };
static int mt7622_i2s2_in_data_funcs[] = { 0, };
static int mt7622_i2s3_in_data_pins[] = { 17, };
static int mt7622_i2s3_in_data_funcs[] = { 0, };
static int mt7622_i2s4_in_data_pins[] = { 18, };
static int mt7622_i2s4_in_data_funcs[] = { 0, };
static int mt7622_i2s_out_mclk_bclk_ws_pins[] = { 3, 4, 5, };
static int mt7622_i2s_out_mclk_bclk_ws_funcs[] = { 0, 0, 0, };
static int mt7622_i2s1_out_data_pins[] = { 2, };
static int mt7622_i2s1_out_data_funcs[] = { 0, };
static int mt7622_i2s2_out_data_pins[] = { 19, };
static int mt7622_i2s2_out_data_funcs[] = { 0, };
static int mt7622_i2s3_out_data_pins[] = { 20, };
static int mt7622_i2s3_out_data_funcs[] = { 0, };
static int mt7622_i2s4_out_data_pins[] = { 21, };
static int mt7622_i2s4_out_data_funcs[] = { 0, };
/* IR */
static int mt7622_ir_0_tx_pins[] = { 16, };
static int mt7622_ir_0_tx_funcs[] = { 4, };
static int mt7622_ir_1_tx_pins[] = { 59, };
static int mt7622_ir_1_tx_funcs[] = { 5, };
static int mt7622_ir_2_tx_pins[] = { 99, };
static int mt7622_ir_2_tx_funcs[] = { 3, };
static int mt7622_ir_0_rx_pins[] = { 17, };
static int mt7622_ir_0_rx_funcs[] = { 4, };
static int mt7622_ir_1_rx_pins[] = { 60, };
static int mt7622_ir_1_rx_funcs[] = { 5, };
static int mt7622_ir_2_rx_pins[] = { 100, };
static int mt7622_ir_2_rx_funcs[] = { 3, };
/* MDIO */
static int mt7622_mdc_mdio_pins[] = { 23, 24, };
static int mt7622_mdc_mdio_funcs[] = { 0, 0, };
/* PCIE */
static int mt7622_pcie0_0_waken_pins[] = { 14, };
static int mt7622_pcie0_0_waken_funcs[] = { 2, };
static int mt7622_pcie0_0_clkreq_pins[] = { 15, };
static int mt7622_pcie0_0_clkreq_funcs[] = { 2, };
static int mt7622_pcie0_1_waken_pins[] = { 79, };
static int mt7622_pcie0_1_waken_funcs[] = { 4, };
static int mt7622_pcie0_1_clkreq_pins[] = { 80, };
static int mt7622_pcie0_1_clkreq_funcs[] = { 4, };
static int mt7622_pcie1_0_waken_pins[] = { 14, };
static int mt7622_pcie1_0_waken_funcs[] = { 3, };
static int mt7622_pcie1_0_clkreq_pins[] = { 15, };
static int mt7622_pcie1_0_clkreq_funcs[] = { 3, };
static int mt7622_pcie0_pad_perst_pins[] = { 83, };
static int mt7622_pcie0_pad_perst_funcs[] = { 0, };
static int mt7622_pcie1_pad_perst_pins[] = { 84, };
static int mt7622_pcie1_pad_perst_funcs[] = { 0, };
/* PMIC bus */
static int mt7622_pmic_bus_pins[] = { 71, 72, };
static int mt7622_pmic_bus_funcs[] = { 0, 0, };
/* Parallel NAND */
static int mt7622_pnand_pins[] = { 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, };
static int mt7622_pnand_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, };
/* PWM */
static int mt7622_pwm_ch1_0_pins[] = { 51, };
static int mt7622_pwm_ch1_0_funcs[] = { 3, };
static int mt7622_pwm_ch1_1_pins[] = { 73, };
static int mt7622_pwm_ch1_1_funcs[] = { 4, };
static int mt7622_pwm_ch1_2_pins[] = { 95, };
static int mt7622_pwm_ch1_2_funcs[] = { 0, };
static int mt7622_pwm_ch2_0_pins[] = { 52, };
static int mt7622_pwm_ch2_0_funcs[] = { 3, };
static int mt7622_pwm_ch2_1_pins[] = { 74, };
static int mt7622_pwm_ch2_1_funcs[] = { 4, };
static int mt7622_pwm_ch2_2_pins[] = { 96, };
static int mt7622_pwm_ch2_2_funcs[] = { 0, };
static int mt7622_pwm_ch3_0_pins[] = { 53, };
static int mt7622_pwm_ch3_0_funcs[] = { 3, };
static int mt7622_pwm_ch3_1_pins[] = { 75, };
static int mt7622_pwm_ch3_1_funcs[] = { 4, };
static int mt7622_pwm_ch3_2_pins[] = { 97, };
static int mt7622_pwm_ch3_2_funcs[] = { 0, };
static int mt7622_pwm_ch4_0_pins[] = { 54, };
static int mt7622_pwm_ch4_0_funcs[] = { 3, };
static int mt7622_pwm_ch4_1_pins[] = { 67, };
static int mt7622_pwm_ch4_1_funcs[] = { 3, };
static int mt7622_pwm_ch4_2_pins[] = { 76, };
static int mt7622_pwm_ch4_2_funcs[] = { 4, };
static int mt7622_pwm_ch4_3_pins[] = { 98, };
static int mt7622_pwm_ch4_3_funcs[] = { 0, };
static int mt7622_pwm_ch5_0_pins[] = { 68, };
static int mt7622_pwm_ch5_0_funcs[] = { 3, };
static int mt7622_pwm_ch5_1_pins[] = { 77, };
static int mt7622_pwm_ch5_1_funcs[] = { 4, };
static int mt7622_pwm_ch5_2_pins[] = { 99, };
static int mt7622_pwm_ch5_2_funcs[] = { 0, };
static int mt7622_pwm_ch6_0_pins[] = { 69, };
static int mt7622_pwm_ch6_0_funcs[] = { 3, };
static int mt7622_pwm_ch6_1_pins[] = { 78, };
static int mt7622_pwm_ch6_1_funcs[] = { 4, };
static int mt7622_pwm_ch6_2_pins[] = { 81, };
static int mt7622_pwm_ch6_2_funcs[] = { 4, };
static int mt7622_pwm_ch6_3_pins[] = { 100, };
static int mt7622_pwm_ch6_3_funcs[] = { 0, };
static int mt7622_pwm_ch7_0_pins[] = { 70, };
static int mt7622_pwm_ch7_0_funcs[] = { 3, };
static int mt7622_pwm_ch7_1_pins[] = { 82, };
static int mt7622_pwm_ch7_1_funcs[] = { 4, };
static int mt7622_pwm_ch7_2_pins[] = { 101, };
static int mt7622_pwm_ch7_2_funcs[] = { 0, };
/* SD */
static int mt7622_sd_0_pins[] = { 16, 17, 18, 19, 20, 21, };
static int mt7622_sd_0_funcs[] = { 2, 2, 2, 2, 2, 2, };
static int mt7622_sd_1_pins[] = { 25, 26, 27, 28, 29, 30, };
static int mt7622_sd_1_funcs[] = { 2, 2, 2, 2, 2, 2, };
/* Serial NAND */
static int mt7622_snfi_pins[] = { 8, 9, 10, 11, 12, 13, };
static int mt7622_snfi_funcs[] = { 2, 2, 2, 2, 2, 2, };
/* SPI NOR */
static int mt7622_spi_pins[] = { 8, 9, 10, 11, 12, 13 };
static int mt7622_spi_funcs[] = { 0, 0, 0, 0, 0, 0, };
/* SPIC */
static int mt7622_spic0_0_pins[] = { 63, 64, 65, 66, };
static int mt7622_spic0_0_funcs[] = { 4, 4, 4, 4, };
static int mt7622_spic0_1_pins[] = { 79, 80, 81, 82, };
static int mt7622_spic0_1_funcs[] = { 3, 3, 3, 3, };
static int mt7622_spic1_0_pins[] = { 67, 68, 69, 70, };
static int mt7622_spic1_0_funcs[] = { 4, 4, 4, 4, };
static int mt7622_spic1_1_pins[] = { 73, 74, 75, 76, };
static int mt7622_spic1_1_funcs[] = { 0, 0, 0, 0, };
static int mt7622_spic2_0_pins[] = { 10, 11, 12, 13, };
static int mt7622_spic2_0_funcs[] = { 0, 0, 0, 0, };
static int mt7622_spic2_0_wp_hold_pins[] = { 8, 9, };
static int mt7622_spic2_0_wp_hold_funcs[] = { 0, 0, };
/* TDM */
static int mt7622_tdm_0_out_mclk_bclk_ws_pins[] = { 8, 9, 10, };
static int mt7622_tdm_0_out_mclk_bclk_ws_funcs[] = { 3, 3, 3, };
static int mt7622_tdm_0_in_mclk_bclk_ws_pins[] = { 11, 12, 13, };
static int mt7622_tdm_0_in_mclk_bclk_ws_funcs[] = { 3, 3, 3, };
static int mt7622_tdm_0_out_data_pins[] = { 20, };
static int mt7622_tdm_0_out_data_funcs[] = { 3, };
static int mt7622_tdm_0_in_data_pins[] = { 21, };
static int mt7622_tdm_0_in_data_funcs[] = { 3, };
static int mt7622_tdm_1_out_mclk_bclk_ws_pins[] = { 57, 58, 59, };
static int mt7622_tdm_1_out_mclk_bclk_ws_funcs[] = { 3, 3, 3, };
static int mt7622_tdm_1_in_mclk_bclk_ws_pins[] = { 60, 61, 62, };
static int mt7622_tdm_1_in_mclk_bclk_ws_funcs[] = { 3, 3, 3, };
static int mt7622_tdm_1_out_data_pins[] = { 55, };
static int mt7622_tdm_1_out_data_funcs[] = { 3, };
static int mt7622_tdm_1_in_data_pins[] = { 56, };
static int mt7622_tdm_1_in_data_funcs[] = { 3, };
/* UART */
static int mt7622_uart0_0_tx_rx_pins[] = { 6, 7, };
static int mt7622_uart0_0_tx_rx_funcs[] = { 0, 0, };
static int mt7622_uart1_0_tx_rx_pins[] = { 55, 56, };
static int mt7622_uart1_0_tx_rx_funcs[] = { 2, 2, };
static int mt7622_uart1_0_rts_cts_pins[] = { 57, 58, };
static int mt7622_uart1_0_rts_cts_funcs[] = { 2, 2, };
static int mt7622_uart1_1_tx_rx_pins[] = { 73, 74, };
static int mt7622_uart1_1_tx_rx_funcs[] = { 2, 2, };
static int mt7622_uart1_1_rts_cts_pins[] = { 75, 76, };
static int mt7622_uart1_1_rts_cts_funcs[] = { 2, 2, };
static int mt7622_uart2_0_tx_rx_pins[] = { 3, 4, };
static int mt7622_uart2_0_tx_rx_funcs[] = { 2, 2, };
static int mt7622_uart2_0_rts_cts_pins[] = { 1, 2, };
static int mt7622_uart2_0_rts_cts_funcs[] = { 2, 2, };
static int mt7622_uart2_1_tx_rx_pins[] = { 51, 52, };
static int mt7622_uart2_1_tx_rx_funcs[] = { 0, 0, };
static int mt7622_uart2_1_rts_cts_pins[] = { 53, 54, };
static int mt7622_uart2_1_rts_cts_funcs[] = { 0, 0, };
static int mt7622_uart2_2_tx_rx_pins[] = { 59, 60, };
static int mt7622_uart2_2_tx_rx_funcs[] = { 4, 4, };
static int mt7622_uart2_2_rts_cts_pins[] = { 61, 62, };
static int mt7622_uart2_2_rts_cts_funcs[] = { 4, 4, };
static int mt7622_uart2_3_tx_rx_pins[] = { 95, 96, };
static int mt7622_uart2_3_tx_rx_funcs[] = { 3, 3, };
static int mt7622_uart3_0_tx_rx_pins[] = { 57, 58, };
static int mt7622_uart3_0_tx_rx_funcs[] = { 5, 5, };
static int mt7622_uart3_1_tx_rx_pins[] = { 81, 82, };
static int mt7622_uart3_1_tx_rx_funcs[] = { 0, 0, };
static int mt7622_uart3_1_rts_cts_pins[] = { 79, 80, };
static int mt7622_uart3_1_rts_cts_funcs[] = { 0, 0, };
static int mt7622_uart4_0_tx_rx_pins[] = { 61, 62, };
static int mt7622_uart4_0_tx_rx_funcs[] = { 5, 5, };
static int mt7622_uart4_1_tx_rx_pins[] = { 91, 92, };
static int mt7622_uart4_1_tx_rx_funcs[] = { 0, 0, };
static int mt7622_uart4_1_rts_cts_pins[] = { 93, 94 };
static int mt7622_uart4_1_rts_cts_funcs[] = { 0, 0, };
static int mt7622_uart4_2_tx_rx_pins[] = { 97, 98, };
static int mt7622_uart4_2_tx_rx_funcs[] = { 2, 2, };
static int mt7622_uart4_2_rts_cts_pins[] = { 95, 96 };
static int mt7622_uart4_2_rts_cts_funcs[] = { 2, 2, };
/* Watchdog */
static int mt7622_watchdog_pins[] = { 78, };
static int mt7622_watchdog_funcs[] = { 0, };
/* WLAN LED */
static int mt7622_wled_pins[] = { 85, };
static int mt7622_wled_funcs[] = { 0, };
static const struct group_desc mt7622_groups[] = {
PINCTRL_PIN_GROUP("emmc", mt7622_emmc),
PINCTRL_PIN_GROUP("emmc_rst", mt7622_emmc_rst),
PINCTRL_PIN_GROUP("ephy_leds", mt7622_ephy_leds),
PINCTRL_PIN_GROUP("ephy0_led", mt7622_ephy0_led),
PINCTRL_PIN_GROUP("ephy1_led", mt7622_ephy1_led),
PINCTRL_PIN_GROUP("ephy2_led", mt7622_ephy2_led),
PINCTRL_PIN_GROUP("ephy3_led", mt7622_ephy3_led),
PINCTRL_PIN_GROUP("ephy4_led", mt7622_ephy4_led),
PINCTRL_PIN_GROUP("esw", mt7622_esw),
PINCTRL_PIN_GROUP("esw_p0_p1", mt7622_esw_p0_p1),
PINCTRL_PIN_GROUP("esw_p2_p3_p4", mt7622_esw_p2_p3_p4),
PINCTRL_PIN_GROUP("rgmii_via_esw", mt7622_rgmii_via_esw),
PINCTRL_PIN_GROUP("rgmii_via_gmac1", mt7622_rgmii_via_gmac1),
PINCTRL_PIN_GROUP("rgmii_via_gmac2", mt7622_rgmii_via_gmac2),
PINCTRL_PIN_GROUP("i2c0", mt7622_i2c0),
PINCTRL_PIN_GROUP("i2c1_0", mt7622_i2c1_0),
PINCTRL_PIN_GROUP("i2c1_1", mt7622_i2c1_1),
PINCTRL_PIN_GROUP("i2c1_2", mt7622_i2c1_2),
PINCTRL_PIN_GROUP("i2c2_0", mt7622_i2c2_0),
PINCTRL_PIN_GROUP("i2c2_1", mt7622_i2c2_1),
PINCTRL_PIN_GROUP("i2c2_2", mt7622_i2c2_2),
PINCTRL_PIN_GROUP("i2s_out_mclk_bclk_ws", mt7622_i2s_out_mclk_bclk_ws),
PINCTRL_PIN_GROUP("i2s_in_mclk_bclk_ws", mt7622_i2s_in_mclk_bclk_ws),
PINCTRL_PIN_GROUP("i2s1_in_data", mt7622_i2s1_in_data),
PINCTRL_PIN_GROUP("i2s2_in_data", mt7622_i2s2_in_data),
PINCTRL_PIN_GROUP("i2s3_in_data", mt7622_i2s3_in_data),
PINCTRL_PIN_GROUP("i2s4_in_data", mt7622_i2s4_in_data),
PINCTRL_PIN_GROUP("i2s1_out_data", mt7622_i2s1_out_data),
PINCTRL_PIN_GROUP("i2s2_out_data", mt7622_i2s2_out_data),
PINCTRL_PIN_GROUP("i2s3_out_data", mt7622_i2s3_out_data),
PINCTRL_PIN_GROUP("i2s4_out_data", mt7622_i2s4_out_data),
PINCTRL_PIN_GROUP("ir_0_tx", mt7622_ir_0_tx),
PINCTRL_PIN_GROUP("ir_1_tx", mt7622_ir_1_tx),
PINCTRL_PIN_GROUP("ir_2_tx", mt7622_ir_2_tx),
PINCTRL_PIN_GROUP("ir_0_rx", mt7622_ir_0_rx),
PINCTRL_PIN_GROUP("ir_1_rx", mt7622_ir_1_rx),
PINCTRL_PIN_GROUP("ir_2_rx", mt7622_ir_2_rx),
PINCTRL_PIN_GROUP("mdc_mdio", mt7622_mdc_mdio),
PINCTRL_PIN_GROUP("pcie0_0_waken", mt7622_pcie0_0_waken),
PINCTRL_PIN_GROUP("pcie0_0_clkreq", mt7622_pcie0_0_clkreq),
PINCTRL_PIN_GROUP("pcie0_1_waken", mt7622_pcie0_1_waken),
PINCTRL_PIN_GROUP("pcie0_1_clkreq", mt7622_pcie0_1_clkreq),
PINCTRL_PIN_GROUP("pcie1_0_waken", mt7622_pcie1_0_waken),
PINCTRL_PIN_GROUP("pcie1_0_clkreq", mt7622_pcie1_0_clkreq),
PINCTRL_PIN_GROUP("pcie0_pad_perst", mt7622_pcie0_pad_perst),
PINCTRL_PIN_GROUP("pcie1_pad_perst", mt7622_pcie1_pad_perst),
PINCTRL_PIN_GROUP("par_nand", mt7622_pnand),
PINCTRL_PIN_GROUP("pmic_bus", mt7622_pmic_bus),
PINCTRL_PIN_GROUP("pwm_ch1_0", mt7622_pwm_ch1_0),
PINCTRL_PIN_GROUP("pwm_ch1_1", mt7622_pwm_ch1_1),
PINCTRL_PIN_GROUP("pwm_ch1_2", mt7622_pwm_ch1_2),
PINCTRL_PIN_GROUP("pwm_ch2_0", mt7622_pwm_ch2_0),
PINCTRL_PIN_GROUP("pwm_ch2_1", mt7622_pwm_ch2_1),
PINCTRL_PIN_GROUP("pwm_ch2_2", mt7622_pwm_ch2_2),
PINCTRL_PIN_GROUP("pwm_ch3_0", mt7622_pwm_ch3_0),
PINCTRL_PIN_GROUP("pwm_ch3_1", mt7622_pwm_ch3_1),
PINCTRL_PIN_GROUP("pwm_ch3_2", mt7622_pwm_ch3_2),
PINCTRL_PIN_GROUP("pwm_ch4_0", mt7622_pwm_ch4_0),
PINCTRL_PIN_GROUP("pwm_ch4_1", mt7622_pwm_ch4_1),
PINCTRL_PIN_GROUP("pwm_ch4_2", mt7622_pwm_ch4_2),
PINCTRL_PIN_GROUP("pwm_ch4_3", mt7622_pwm_ch4_3),
PINCTRL_PIN_GROUP("pwm_ch5_0", mt7622_pwm_ch5_0),
PINCTRL_PIN_GROUP("pwm_ch5_1", mt7622_pwm_ch5_1),
PINCTRL_PIN_GROUP("pwm_ch5_2", mt7622_pwm_ch5_2),
PINCTRL_PIN_GROUP("pwm_ch6_0", mt7622_pwm_ch6_0),
PINCTRL_PIN_GROUP("pwm_ch6_1", mt7622_pwm_ch6_1),
PINCTRL_PIN_GROUP("pwm_ch6_2", mt7622_pwm_ch6_2),
PINCTRL_PIN_GROUP("pwm_ch6_3", mt7622_pwm_ch6_3),
PINCTRL_PIN_GROUP("pwm_ch7_0", mt7622_pwm_ch7_0),
PINCTRL_PIN_GROUP("pwm_ch7_1", mt7622_pwm_ch7_1),
PINCTRL_PIN_GROUP("pwm_ch7_2", mt7622_pwm_ch7_2),
PINCTRL_PIN_GROUP("sd_0", mt7622_sd_0),
PINCTRL_PIN_GROUP("sd_1", mt7622_sd_1),
PINCTRL_PIN_GROUP("snfi", mt7622_snfi),
PINCTRL_PIN_GROUP("spi_nor", mt7622_spi),
PINCTRL_PIN_GROUP("spic0_0", mt7622_spic0_0),
PINCTRL_PIN_GROUP("spic0_1", mt7622_spic0_1),
PINCTRL_PIN_GROUP("spic1_0", mt7622_spic1_0),
PINCTRL_PIN_GROUP("spic1_1", mt7622_spic1_1),
PINCTRL_PIN_GROUP("spic2_0", mt7622_spic2_0),
PINCTRL_PIN_GROUP("spic2_0_wp_hold", mt7622_spic2_0_wp_hold),
PINCTRL_PIN_GROUP("tdm_0_out_mclk_bclk_ws",
mt7622_tdm_0_out_mclk_bclk_ws),
PINCTRL_PIN_GROUP("tdm_0_in_mclk_bclk_ws",
mt7622_tdm_0_in_mclk_bclk_ws),
PINCTRL_PIN_GROUP("tdm_0_out_data", mt7622_tdm_0_out_data),
PINCTRL_PIN_GROUP("tdm_0_in_data", mt7622_tdm_0_in_data),
PINCTRL_PIN_GROUP("tdm_1_out_mclk_bclk_ws",
mt7622_tdm_1_out_mclk_bclk_ws),
PINCTRL_PIN_GROUP("tdm_1_in_mclk_bclk_ws",
mt7622_tdm_1_in_mclk_bclk_ws),
PINCTRL_PIN_GROUP("tdm_1_out_data", mt7622_tdm_1_out_data),
PINCTRL_PIN_GROUP("tdm_1_in_data", mt7622_tdm_1_in_data),
PINCTRL_PIN_GROUP("uart0_0_tx_rx", mt7622_uart0_0_tx_rx),
PINCTRL_PIN_GROUP("uart1_0_tx_rx", mt7622_uart1_0_tx_rx),
PINCTRL_PIN_GROUP("uart1_0_rts_cts", mt7622_uart1_0_rts_cts),
PINCTRL_PIN_GROUP("uart1_1_tx_rx", mt7622_uart1_1_tx_rx),
PINCTRL_PIN_GROUP("uart1_1_rts_cts", mt7622_uart1_1_rts_cts),
PINCTRL_PIN_GROUP("uart2_0_tx_rx", mt7622_uart2_0_tx_rx),
PINCTRL_PIN_GROUP("uart2_0_rts_cts", mt7622_uart2_0_rts_cts),
PINCTRL_PIN_GROUP("uart2_1_tx_rx", mt7622_uart2_1_tx_rx),
PINCTRL_PIN_GROUP("uart2_1_rts_cts", mt7622_uart2_1_rts_cts),
PINCTRL_PIN_GROUP("uart2_2_tx_rx", mt7622_uart2_2_tx_rx),
PINCTRL_PIN_GROUP("uart2_2_rts_cts", mt7622_uart2_2_rts_cts),
PINCTRL_PIN_GROUP("uart2_3_tx_rx", mt7622_uart2_3_tx_rx),
PINCTRL_PIN_GROUP("uart3_0_tx_rx", mt7622_uart3_0_tx_rx),
PINCTRL_PIN_GROUP("uart3_1_tx_rx", mt7622_uart3_1_tx_rx),
PINCTRL_PIN_GROUP("uart3_1_rts_cts", mt7622_uart3_1_rts_cts),
PINCTRL_PIN_GROUP("uart4_0_tx_rx", mt7622_uart4_0_tx_rx),
PINCTRL_PIN_GROUP("uart4_1_tx_rx", mt7622_uart4_1_tx_rx),
PINCTRL_PIN_GROUP("uart4_1_rts_cts", mt7622_uart4_1_rts_cts),
PINCTRL_PIN_GROUP("uart4_2_tx_rx", mt7622_uart4_2_tx_rx),
PINCTRL_PIN_GROUP("uart4_2_rts_cts", mt7622_uart4_2_rts_cts),
PINCTRL_PIN_GROUP("watchdog", mt7622_watchdog),
PINCTRL_PIN_GROUP("wled", mt7622_wled),
};
/* Joint those groups owning the same capability in user point of view which
* allows that people tend to use through the device tree.
*/
static const char *mt7622_emmc_groups[] = { "emmc", "emmc_rst", };
static const char *mt7622_ethernet_groups[] = { "esw", "esw_p0_p1",
"esw_p2_p3_p4", "mdc_mdio",
"rgmii_via_gmac1",
"rgmii_via_gmac2",
"rgmii_via_esw", };
static const char *mt7622_i2c_groups[] = { "i2c0", "i2c1_0", "i2c1_1",
"i2c1_2", "i2c2_0", "i2c2_1",
"i2c2_2", };
static const char *mt7622_i2s_groups[] = { "i2s_out_mclk_bclk_ws",
"i2s_in_mclk_bclk_ws",
"i2s1_in_data", "i2s2_in_data",
"i2s3_in_data", "i2s4_in_data",
"i2s1_out_data", "i2s2_out_data",
"i2s3_out_data", "i2s4_out_data", };
static const char *mt7622_ir_groups[] = { "ir_0_tx", "ir_1_tx", "ir_2_tx",
"ir_0_rx", "ir_1_rx", "ir_2_rx"};
static const char *mt7622_led_groups[] = { "ephy_leds", "ephy0_led",
"ephy1_led", "ephy2_led",
"ephy3_led", "ephy4_led",
"wled", };
static const char *mt7622_flash_groups[] = { "par_nand", "snfi", "spi_nor"};
static const char *mt7622_pcie_groups[] = { "pcie0_0_waken", "pcie0_0_clkreq",
"pcie0_1_waken", "pcie0_1_clkreq",
"pcie1_0_waken", "pcie1_0_clkreq",
"pcie0_pad_perst",
"pcie1_pad_perst", };
static const char *mt7622_pmic_bus_groups[] = { "pmic_bus", };
static const char *mt7622_pwm_groups[] = { "pwm_ch1_0", "pwm_ch1_1",
"pwm_ch1_2", "pwm_ch2_0",
"pwm_ch2_1", "pwm_ch2_2",
"pwm_ch3_0", "pwm_ch3_1",
"pwm_ch3_2", "pwm_ch4_0",
"pwm_ch4_1", "pwm_ch4_2",
"pwm_ch4_3", "pwm_ch5_0",
"pwm_ch5_1", "pwm_ch5_2",
"pwm_ch6_0", "pwm_ch6_1",
"pwm_ch6_2", "pwm_ch6_3",
"pwm_ch7_0", "pwm_ch7_1",
"pwm_ch7_2", };
static const char *mt7622_sd_groups[] = { "sd_0", "sd_1", };
static const char *mt7622_spic_groups[] = { "spic0_0", "spic0_1", "spic1_0",
"spic1_1", "spic2_0",
"spic2_0_wp_hold", };
static const char *mt7622_tdm_groups[] = { "tdm_0_out_mclk_bclk_ws",
"tdm_0_in_mclk_bclk_ws",
"tdm_0_out_data",
"tdm_0_in_data",
"tdm_1_out_mclk_bclk_ws",
"tdm_1_in_mclk_bclk_ws",
"tdm_1_out_data",
"tdm_1_in_data", };
static const char *mt7622_uart_groups[] = { "uart0_0_tx_rx",
"uart1_0_tx_rx", "uart1_0_rts_cts",
"uart1_1_tx_rx", "uart1_1_rts_cts",
"uart2_0_tx_rx", "uart2_0_rts_cts",
"uart2_1_tx_rx", "uart2_1_rts_cts",
"uart2_2_tx_rx", "uart2_2_rts_cts",
"uart2_3_tx_rx",
"uart3_0_tx_rx",
"uart3_1_tx_rx", "uart3_1_rts_cts",
"uart4_0_tx_rx",
"uart4_1_tx_rx", "uart4_1_rts_cts",
"uart4_2_tx_rx",
"uart4_2_rts_cts",};
static const char *mt7622_wdt_groups[] = { "watchdog", };
static const struct function_desc mt7622_functions[] = {
{"emmc", mt7622_emmc_groups, ARRAY_SIZE(mt7622_emmc_groups)},
{"eth", mt7622_ethernet_groups, ARRAY_SIZE(mt7622_ethernet_groups)},
{"i2c", mt7622_i2c_groups, ARRAY_SIZE(mt7622_i2c_groups)},
{"i2s", mt7622_i2s_groups, ARRAY_SIZE(mt7622_i2s_groups)},
{"ir", mt7622_ir_groups, ARRAY_SIZE(mt7622_ir_groups)},
{"led", mt7622_led_groups, ARRAY_SIZE(mt7622_led_groups)},
{"flash", mt7622_flash_groups, ARRAY_SIZE(mt7622_flash_groups)},
{"pcie", mt7622_pcie_groups, ARRAY_SIZE(mt7622_pcie_groups)},
{"pmic", mt7622_pmic_bus_groups, ARRAY_SIZE(mt7622_pmic_bus_groups)},
{"pwm", mt7622_pwm_groups, ARRAY_SIZE(mt7622_pwm_groups)},
{"sd", mt7622_sd_groups, ARRAY_SIZE(mt7622_sd_groups)},
{"spi", mt7622_spic_groups, ARRAY_SIZE(mt7622_spic_groups)},
{"tdm", mt7622_tdm_groups, ARRAY_SIZE(mt7622_tdm_groups)},
{"uart", mt7622_uart_groups, ARRAY_SIZE(mt7622_uart_groups)},
{"watchdog", mt7622_wdt_groups, ARRAY_SIZE(mt7622_wdt_groups)},
};
static const struct mtk_eint_hw mt7622_eint_hw = {
.port_mask = 7,
.ports = 7,
.ap_num = ARRAY_SIZE(mt7622_pins),
.db_cnt = 20,
};
static const struct mtk_pin_soc mt7622_data = {
.reg_cal = mt7622_reg_cals,
.pins = mt7622_pins,
.npins = ARRAY_SIZE(mt7622_pins),
.grps = mt7622_groups,
.ngrps = ARRAY_SIZE(mt7622_groups),
.funcs = mt7622_functions,
.nfuncs = ARRAY_SIZE(mt7622_functions),
.eint_hw = &mt7622_eint_hw,
.gpio_m = 1,
.ies_present = false,
.base_names = mtk_default_register_base_names,
.nbase_names = ARRAY_SIZE(mtk_default_register_base_names),
.bias_disable_set = mtk_pinconf_bias_disable_set,
.bias_disable_get = mtk_pinconf_bias_disable_get,
.bias_set = mtk_pinconf_bias_set,
.bias_get = mtk_pinconf_bias_get,
.drive_set = mtk_pinconf_drive_set,
.drive_get = mtk_pinconf_drive_get,
};
static const struct of_device_id mt7622_pinctrl_of_match[] = {
{ .compatible = "mediatek,mt7622-pinctrl", },
{ }
};
static int mt7622_pinctrl_probe(struct platform_device *pdev)
{
return mtk_moore_pinctrl_probe(pdev, &mt7622_data);
}
static struct platform_driver mt7622_pinctrl_driver = {
.driver = {
.name = "mt7622-pinctrl",
.of_match_table = mt7622_pinctrl_of_match,
},
.probe = mt7622_pinctrl_probe,
};
static int __init mt7622_pinctrl_init(void)
{
return platform_driver_register(&mt7622_pinctrl_driver);
}
arch_initcall(mt7622_pinctrl_init);
File diff suppressed because it is too large. Load diff
+450
View File
@@ -0,0 +1,450 @@
// SPDX-License-Identifier: GPL-2.0
/*
* The MT7629 driver based on Linux generic pinctrl binding.
*
* Copyright (C) 2018 MediaTek Inc.
* Author: Ryder Lee <ryder.lee@mediatek.com>
*/
#include "pinctrl-moore.h"
#define MT7629_PIN(_number, _name, _eint_n) \
MTK_PIN(_number, _name, 0, _eint_n, DRV_GRP1)
static const struct mtk_pin_field_calc mt7629_pin_mode_range[] = {
PIN_FIELD(0, 78, 0x300, 0x10, 0, 4),
};
static const struct mtk_pin_field_calc mt7629_pin_dir_range[] = {
PIN_FIELD(0, 78, 0x0, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt7629_pin_di_range[] = {
PIN_FIELD(0, 78, 0x200, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt7629_pin_do_range[] = {
PIN_FIELD(0, 78, 0x100, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt7629_pin_ies_range[] = {
PIN_FIELD(0, 10, 0x1000, 0x10, 0, 1),
PIN_FIELD(11, 18, 0x2000, 0x10, 0, 1),
PIN_FIELD(19, 32, 0x3000, 0x10, 0, 1),
PIN_FIELD(33, 48, 0x4000, 0x10, 0, 1),
PIN_FIELD(49, 50, 0x5000, 0x10, 0, 1),
PIN_FIELD(51, 69, 0x6000, 0x10, 0, 1),
PIN_FIELD(70, 78, 0x7000, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt7629_pin_smt_range[] = {
PIN_FIELD(0, 10, 0x1100, 0x10, 0, 1),
PIN_FIELD(11, 18, 0x2100, 0x10, 0, 1),
PIN_FIELD(19, 32, 0x3100, 0x10, 0, 1),
PIN_FIELD(33, 48, 0x4100, 0x10, 0, 1),
PIN_FIELD(49, 50, 0x5100, 0x10, 0, 1),
PIN_FIELD(51, 69, 0x6100, 0x10, 0, 1),
PIN_FIELD(70, 78, 0x7100, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt7629_pin_pullen_range[] = {
PIN_FIELD(0, 10, 0x1400, 0x10, 0, 1),
PIN_FIELD(11, 18, 0x2400, 0x10, 0, 1),
PIN_FIELD(19, 32, 0x3400, 0x10, 0, 1),
PIN_FIELD(33, 48, 0x4400, 0x10, 0, 1),
PIN_FIELD(49, 50, 0x5400, 0x10, 0, 1),
PIN_FIELD(51, 69, 0x6400, 0x10, 0, 1),
PIN_FIELD(70, 78, 0x7400, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt7629_pin_pullsel_range[] = {
PIN_FIELD(0, 10, 0x1500, 0x10, 0, 1),
PIN_FIELD(11, 18, 0x2500, 0x10, 0, 1),
PIN_FIELD(19, 32, 0x3500, 0x10, 0, 1),
PIN_FIELD(33, 48, 0x4500, 0x10, 0, 1),
PIN_FIELD(49, 50, 0x5500, 0x10, 0, 1),
PIN_FIELD(51, 69, 0x6500, 0x10, 0, 1),
PIN_FIELD(70, 78, 0x7500, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt7629_pin_drv_range[] = {
PIN_FIELD(0, 10, 0x1600, 0x10, 0, 4),
PIN_FIELD(11, 18, 0x2600, 0x10, 0, 4),
PIN_FIELD(19, 32, 0x3600, 0x10, 0, 4),
PIN_FIELD(33, 48, 0x4600, 0x10, 0, 4),
PIN_FIELD(49, 50, 0x5600, 0x10, 0, 4),
PIN_FIELD(51, 69, 0x6600, 0x10, 0, 4),
PIN_FIELD(70, 78, 0x7600, 0x10, 0, 4),
};
static const struct mtk_pin_field_calc mt7629_pin_tdsel_range[] = {
PIN_FIELD(0, 10, 0x1200, 0x10, 0, 4),
PIN_FIELD(11, 18, 0x2200, 0x10, 0, 4),
PIN_FIELD(19, 32, 0x3200, 0x10, 0, 4),
PIN_FIELD(33, 48, 0x4200, 0x10, 0, 4),
PIN_FIELD(49, 50, 0x5200, 0x10, 0, 4),
PIN_FIELD(51, 69, 0x6200, 0x10, 0, 4),
PIN_FIELD(70, 78, 0x7200, 0x10, 0, 4),
};
static const struct mtk_pin_field_calc mt7629_pin_rdsel_range[] = {
PIN_FIELD(0, 10, 0x1300, 0x10, 0, 4),
PIN_FIELD(11, 18, 0x2300, 0x10, 0, 4),
PIN_FIELD(19, 32, 0x3300, 0x10, 0, 4),
PIN_FIELD(33, 48, 0x4300, 0x10, 0, 4),
PIN_FIELD(49, 50, 0x5300, 0x10, 0, 4),
PIN_FIELD(51, 69, 0x6300, 0x10, 0, 4),
PIN_FIELD(70, 78, 0x7300, 0x10, 0, 4),
};
static const struct mtk_pin_reg_calc mt7629_reg_cals[] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt7629_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt7629_pin_dir_range),
[PINCTRL_PIN_REG_DI] = MTK_RANGE(mt7629_pin_di_range),
[PINCTRL_PIN_REG_DO] = MTK_RANGE(mt7629_pin_do_range),
[PINCTRL_PIN_REG_IES] = MTK_RANGE(mt7629_pin_ies_range),
[PINCTRL_PIN_REG_SMT] = MTK_RANGE(mt7629_pin_smt_range),
[PINCTRL_PIN_REG_PULLSEL] = MTK_RANGE(mt7629_pin_pullsel_range),
[PINCTRL_PIN_REG_PULLEN] = MTK_RANGE(mt7629_pin_pullen_range),
[PINCTRL_PIN_REG_DRV] = MTK_RANGE(mt7629_pin_drv_range),
[PINCTRL_PIN_REG_TDSEL] = MTK_RANGE(mt7629_pin_tdsel_range),
[PINCTRL_PIN_REG_RDSEL] = MTK_RANGE(mt7629_pin_rdsel_range),
};
static const struct mtk_pin_desc mt7629_pins[] = {
MT7629_PIN(0, "TOP_5G_CLK", 53),
MT7629_PIN(1, "TOP_5G_DATA", 54),
MT7629_PIN(2, "WF0_5G_HB0", 55),
MT7629_PIN(3, "WF0_5G_HB1", 56),
MT7629_PIN(4, "WF0_5G_HB2", 57),
MT7629_PIN(5, "WF0_5G_HB3", 58),
MT7629_PIN(6, "WF0_5G_HB4", 59),
MT7629_PIN(7, "WF0_5G_HB5", 60),
MT7629_PIN(8, "WF0_5G_HB6", 61),
MT7629_PIN(9, "XO_REQ", 9),
MT7629_PIN(10, "TOP_RST_N", 10),
MT7629_PIN(11, "SYS_WATCHDOG", 11),
MT7629_PIN(12, "EPHY_LED0_N_JTDO", 12),
MT7629_PIN(13, "EPHY_LED1_N_JTDI", 13),
MT7629_PIN(14, "EPHY_LED2_N_JTMS", 14),
MT7629_PIN(15, "EPHY_LED3_N_JTCLK", 15),
MT7629_PIN(16, "EPHY_LED4_N_JTRST_N", 16),
MT7629_PIN(17, "WF2G_LED_N", 17),
MT7629_PIN(18, "WF5G_LED_N", 18),
MT7629_PIN(19, "I2C_SDA", 19),
MT7629_PIN(20, "I2C_SCL", 20),
MT7629_PIN(21, "GPIO_9", 21),
MT7629_PIN(22, "GPIO_10", 22),
MT7629_PIN(23, "GPIO_11", 23),
MT7629_PIN(24, "GPIO_12", 24),
MT7629_PIN(25, "UART1_TXD", 25),
MT7629_PIN(26, "UART1_RXD", 26),
MT7629_PIN(27, "UART1_CTS", 27),
MT7629_PIN(28, "UART1_RTS", 28),
MT7629_PIN(29, "UART2_TXD", 29),
MT7629_PIN(30, "UART2_RXD", 30),
MT7629_PIN(31, "UART2_CTS", 31),
MT7629_PIN(32, "UART2_RTS", 32),
MT7629_PIN(33, "MDI_TP_P1", 33),
MT7629_PIN(34, "MDI_TN_P1", 34),
MT7629_PIN(35, "MDI_RP_P1", 35),
MT7629_PIN(36, "MDI_RN_P1", 36),
MT7629_PIN(37, "MDI_RP_P2", 37),
MT7629_PIN(38, "MDI_RN_P2", 38),
MT7629_PIN(39, "MDI_TP_P2", 39),
MT7629_PIN(40, "MDI_TN_P2", 40),
MT7629_PIN(41, "MDI_TP_P3", 41),
MT7629_PIN(42, "MDI_TN_P3", 42),
MT7629_PIN(43, "MDI_RP_P3", 43),
MT7629_PIN(44, "MDI_RN_P3", 44),
MT7629_PIN(45, "MDI_RP_P4", 45),
MT7629_PIN(46, "MDI_RN_P4", 46),
MT7629_PIN(47, "MDI_TP_P4", 47),
MT7629_PIN(48, "MDI_TN_P4", 48),
MT7629_PIN(49, "SMI_MDC", 49),
MT7629_PIN(50, "SMI_MDIO", 50),
MT7629_PIN(51, "PCIE_PERESET_N", 51),
MT7629_PIN(52, "PWM_0", 52),
MT7629_PIN(53, "GPIO_0", 0),
MT7629_PIN(54, "GPIO_1", 1),
MT7629_PIN(55, "GPIO_2", 2),
MT7629_PIN(56, "GPIO_3", 3),
MT7629_PIN(57, "GPIO_4", 4),
MT7629_PIN(58, "GPIO_5", 5),
MT7629_PIN(59, "GPIO_6", 6),
MT7629_PIN(60, "GPIO_7", 7),
MT7629_PIN(61, "GPIO_8", 8),
MT7629_PIN(62, "SPI_CLK", 62),
MT7629_PIN(63, "SPI_CS", 63),
MT7629_PIN(64, "SPI_MOSI", 64),
MT7629_PIN(65, "SPI_MISO", 65),
MT7629_PIN(66, "SPI_WP", 66),
MT7629_PIN(67, "SPI_HOLD", 67),
MT7629_PIN(68, "UART0_TXD", 68),
MT7629_PIN(69, "UART0_RXD", 69),
MT7629_PIN(70, "TOP_2G_CLK", 70),
MT7629_PIN(71, "TOP_2G_DATA", 71),
MT7629_PIN(72, "WF0_2G_HB0", 72),
MT7629_PIN(73, "WF0_2G_HB1", 73),
MT7629_PIN(74, "WF0_2G_HB2", 74),
MT7629_PIN(75, "WF0_2G_HB3", 75),
MT7629_PIN(76, "WF0_2G_HB4", 76),
MT7629_PIN(77, "WF0_2G_HB5", 77),
MT7629_PIN(78, "WF0_2G_HB6", 78),
};
/* List all groups consisting of these pins dedicated to the enablement of
* certain hardware block and the corresponding mode for all of the pins.
* The hardware probably has multiple combinations of these pinouts.
*/
/* LED for EPHY */
static int mt7629_ephy_leds_pins[] = { 12, 13, 14, 15, 16, 17, 18, };
static int mt7629_ephy_leds_funcs[] = { 1, 1, 1, 1, 1, 1, 1, };
static int mt7629_ephy_led0_pins[] = { 12, };
static int mt7629_ephy_led0_funcs[] = { 1, };
static int mt7629_ephy_led1_pins[] = { 13, };
static int mt7629_ephy_led1_funcs[] = { 1, };
static int mt7629_ephy_led2_pins[] = { 14, };
static int mt7629_ephy_led2_funcs[] = { 1, };
static int mt7629_ephy_led3_pins[] = { 15, };
static int mt7629_ephy_led3_funcs[] = { 1, };
static int mt7629_ephy_led4_pins[] = { 16, };
static int mt7629_ephy_led4_funcs[] = { 1, };
static int mt7629_wf2g_led_pins[] = { 17, };
static int mt7629_wf2g_led_funcs[] = { 1, };
static int mt7629_wf5g_led_pins[] = { 18, };
static int mt7629_wf5g_led_funcs[] = { 1, };
/* Watchdog */
static int mt7629_watchdog_pins[] = { 11, };
static int mt7629_watchdog_funcs[] = { 1, };
/* LED for GPHY */
static int mt7629_gphy_leds_0_pins[] = { 21, 22, 23, };
static int mt7629_gphy_leds_0_funcs[] = { 2, 2, 2, };
static int mt7629_gphy_led1_0_pins[] = { 21, };
static int mt7629_gphy_led1_0_funcs[] = { 2, };
static int mt7629_gphy_led2_0_pins[] = { 22, };
static int mt7629_gphy_led2_0_funcs[] = { 2, };
static int mt7629_gphy_led3_0_pins[] = { 23, };
static int mt7629_gphy_led3_0_funcs[] = { 2, };
static int mt7629_gphy_leds_1_pins[] = { 57, 58, 59, };
static int mt7629_gphy_leds_1_funcs[] = { 1, 1, 1, };
static int mt7629_gphy_led1_1_pins[] = { 57, };
static int mt7629_gphy_led1_1_funcs[] = { 1, };
static int mt7629_gphy_led2_1_pins[] = { 58, };
static int mt7629_gphy_led2_1_funcs[] = { 1, };
static int mt7629_gphy_led3_1_pins[] = { 59, };
static int mt7629_gphy_led3_1_funcs[] = { 1, };
/* I2C */
static int mt7629_i2c_0_pins[] = { 19, 20, };
static int mt7629_i2c_0_funcs[] = { 1, 1, };
static int mt7629_i2c_1_pins[] = { 53, 54, };
static int mt7629_i2c_1_funcs[] = { 1, 1, };
/* SPI */
static int mt7629_spi_0_pins[] = { 21, 22, 23, 24, };
static int mt7629_spi_0_funcs[] = { 1, 1, 1, 1, };
static int mt7629_spi_1_pins[] = { 62, 63, 64, 65, };
static int mt7629_spi_1_funcs[] = { 1, 1, 1, 1, };
static int mt7629_spi_wp_pins[] = { 66, };
static int mt7629_spi_wp_funcs[] = { 1, };
static int mt7629_spi_hold_pins[] = { 67, };
static int mt7629_spi_hold_funcs[] = { 1, };
/* UART */
static int mt7629_uart1_0_txd_rxd_pins[] = { 25, 26, };
static int mt7629_uart1_0_txd_rxd_funcs[] = { 1, 1, };
static int mt7629_uart1_1_txd_rxd_pins[] = { 53, 54, };
static int mt7629_uart1_1_txd_rxd_funcs[] = { 2, 2, };
static int mt7629_uart2_0_txd_rxd_pins[] = { 29, 30, };
static int mt7629_uart2_0_txd_rxd_funcs[] = { 1, 1, };
static int mt7629_uart2_1_txd_rxd_pins[] = { 57, 58, };
static int mt7629_uart2_1_txd_rxd_funcs[] = { 2, 2, };
static int mt7629_uart1_0_cts_rts_pins[] = { 27, 28, };
static int mt7629_uart1_0_cts_rts_funcs[] = { 1, 1, };
static int mt7629_uart1_1_cts_rts_pins[] = { 55, 56, };
static int mt7629_uart1_1_cts_rts_funcs[] = { 2, 2, };
static int mt7629_uart2_0_cts_rts_pins[] = { 31, 32, };
static int mt7629_uart2_0_cts_rts_funcs[] = { 1, 1, };
static int mt7629_uart2_1_cts_rts_pins[] = { 59, 60, };
static int mt7629_uart2_1_cts_rts_funcs[] = { 2, 2, };
static int mt7629_uart0_txd_rxd_pins[] = { 68, 69, };
static int mt7629_uart0_txd_rxd_funcs[] = { 1, 1, };
/* MDC/MDIO */
static int mt7629_mdc_mdio_pins[] = { 49, 50, };
static int mt7629_mdc_mdio_funcs[] = { 1, 1, };
/* PCIE */
static int mt7629_pcie_pereset_pins[] = { 51, };
static int mt7629_pcie_pereset_funcs[] = { 1, };
static int mt7629_pcie_wake_pins[] = { 55, };
static int mt7629_pcie_wake_funcs[] = { 1, };
static int mt7629_pcie_clkreq_pins[] = { 56, };
static int mt7629_pcie_clkreq_funcs[] = { 1, };
/* PWM */
static int mt7629_pwm_0_pins[] = { 52, };
static int mt7629_pwm_0_funcs[] = { 1, };
static int mt7629_pwm_1_pins[] = { 61, };
static int mt7629_pwm_1_funcs[] = { 2, };
/* WF 2G */
static int mt7629_wf0_2g_pins[] = { 70, 71, 72, 73, 74, 75, 76, 77, 78, };
static int mt7629_wf0_2g_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, };
/* WF 5G */
static int mt7629_wf0_5g_pins[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, };
static int mt7629_wf0_5g_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
/* SNFI */
static int mt7629_snfi_pins[] = { 62, 63, 64, 65, 66, 67 };
static int mt7629_snfi_funcs[] = { 2, 2, 2, 2, 2, 2 };
/* SPI NOR */
static int mt7629_snor_pins[] = { 62, 63, 64, 65, 66, 67 };
static int mt7629_snor_funcs[] = { 1, 1, 1, 1, 1, 1 };
static const struct group_desc mt7629_groups[] = {
PINCTRL_PIN_GROUP("ephy_leds", mt7629_ephy_leds),
PINCTRL_PIN_GROUP("ephy_led0", mt7629_ephy_led0),
PINCTRL_PIN_GROUP("ephy_led1", mt7629_ephy_led1),
PINCTRL_PIN_GROUP("ephy_led2", mt7629_ephy_led2),
PINCTRL_PIN_GROUP("ephy_led3", mt7629_ephy_led3),
PINCTRL_PIN_GROUP("ephy_led4", mt7629_ephy_led4),
PINCTRL_PIN_GROUP("wf2g_led", mt7629_wf2g_led),
PINCTRL_PIN_GROUP("wf5g_led", mt7629_wf5g_led),
PINCTRL_PIN_GROUP("watchdog", mt7629_watchdog),
PINCTRL_PIN_GROUP("gphy_leds_0", mt7629_gphy_leds_0),
PINCTRL_PIN_GROUP("gphy_led1_0", mt7629_gphy_led1_0),
PINCTRL_PIN_GROUP("gphy_led2_0", mt7629_gphy_led2_0),
PINCTRL_PIN_GROUP("gphy_led3_0", mt7629_gphy_led3_0),
PINCTRL_PIN_GROUP("gphy_leds_1", mt7629_gphy_leds_1),
PINCTRL_PIN_GROUP("gphy_led1_1", mt7629_gphy_led1_1),
PINCTRL_PIN_GROUP("gphy_led2_1", mt7629_gphy_led2_1),
PINCTRL_PIN_GROUP("gphy_led3_1", mt7629_gphy_led3_1),
PINCTRL_PIN_GROUP("i2c_0", mt7629_i2c_0),
PINCTRL_PIN_GROUP("i2c_1", mt7629_i2c_1),
PINCTRL_PIN_GROUP("spi_0", mt7629_spi_0),
PINCTRL_PIN_GROUP("spi_1", mt7629_spi_1),
PINCTRL_PIN_GROUP("spi_wp", mt7629_spi_wp),
PINCTRL_PIN_GROUP("spi_hold", mt7629_spi_hold),
PINCTRL_PIN_GROUP("uart1_0_txd_rxd", mt7629_uart1_0_txd_rxd),
PINCTRL_PIN_GROUP("uart1_1_txd_rxd", mt7629_uart1_1_txd_rxd),
PINCTRL_PIN_GROUP("uart2_0_txd_rxd", mt7629_uart2_0_txd_rxd),
PINCTRL_PIN_GROUP("uart2_1_txd_rxd", mt7629_uart2_1_txd_rxd),
PINCTRL_PIN_GROUP("uart1_0_cts_rts", mt7629_uart1_0_cts_rts),
PINCTRL_PIN_GROUP("uart1_1_cts_rts", mt7629_uart1_1_cts_rts),
PINCTRL_PIN_GROUP("uart2_0_cts_rts", mt7629_uart2_0_cts_rts),
PINCTRL_PIN_GROUP("uart2_1_cts_rts", mt7629_uart2_1_cts_rts),
PINCTRL_PIN_GROUP("uart0_txd_rxd", mt7629_uart0_txd_rxd),
PINCTRL_PIN_GROUP("mdc_mdio", mt7629_mdc_mdio),
PINCTRL_PIN_GROUP("pcie_pereset", mt7629_pcie_pereset),
PINCTRL_PIN_GROUP("pcie_wake", mt7629_pcie_wake),
PINCTRL_PIN_GROUP("pcie_clkreq", mt7629_pcie_clkreq),
PINCTRL_PIN_GROUP("pwm_0", mt7629_pwm_0),
PINCTRL_PIN_GROUP("pwm_1", mt7629_pwm_1),
PINCTRL_PIN_GROUP("wf0_5g", mt7629_wf0_5g),
PINCTRL_PIN_GROUP("wf0_2g", mt7629_wf0_2g),
PINCTRL_PIN_GROUP("snfi", mt7629_snfi),
PINCTRL_PIN_GROUP("spi_nor", mt7629_snor),
};
/* Joint those groups owning the same capability in user point of view which
* allows that people tend to use through the device tree.
*/
static const char *mt7629_ethernet_groups[] = { "mdc_mdio", };
static const char *mt7629_i2c_groups[] = { "i2c_0", "i2c_1", };
static const char *mt7629_led_groups[] = { "ephy_leds", "ephy_led0",
"ephy_led1", "ephy_led2",
"ephy_led3", "ephy_led4",
"wf2g_led", "wf5g_led",
"gphy_leds_0", "gphy_led1_0",
"gphy_led2_0", "gphy_led3_0",
"gphy_leds_1", "gphy_led1_1",
"gphy_led2_1", "gphy_led3_1",};
static const char *mt7629_pcie_groups[] = { "pcie_pereset", "pcie_wake",
"pcie_clkreq", };
static const char *mt7629_pwm_groups[] = { "pwm_0", "pwm_1", };
static const char *mt7629_spi_groups[] = { "spi_0", "spi_1", "spi_wp",
"spi_hold", };
static const char *mt7629_uart_groups[] = { "uart1_0_txd_rxd",
"uart1_1_txd_rxd",
"uart2_0_txd_rxd",
"uart2_1_txd_rxd",
"uart1_0_cts_rts",
"uart1_1_cts_rts",
"uart2_0_cts_rts",
"uart2_1_cts_rts",
"uart0_txd_rxd", };
static const char *mt7629_wdt_groups[] = { "watchdog", };
static const char *mt7629_wifi_groups[] = { "wf0_5g", "wf0_2g", };
static const char *mt7629_flash_groups[] = { "snfi", "spi_nor" };
static const struct function_desc mt7629_functions[] = {
{"eth", mt7629_ethernet_groups, ARRAY_SIZE(mt7629_ethernet_groups)},
{"i2c", mt7629_i2c_groups, ARRAY_SIZE(mt7629_i2c_groups)},
{"led", mt7629_led_groups, ARRAY_SIZE(mt7629_led_groups)},
{"pcie", mt7629_pcie_groups, ARRAY_SIZE(mt7629_pcie_groups)},
{"pwm", mt7629_pwm_groups, ARRAY_SIZE(mt7629_pwm_groups)},
{"spi", mt7629_spi_groups, ARRAY_SIZE(mt7629_spi_groups)},
{"uart", mt7629_uart_groups, ARRAY_SIZE(mt7629_uart_groups)},
{"watchdog", mt7629_wdt_groups, ARRAY_SIZE(mt7629_wdt_groups)},
{"wifi", mt7629_wifi_groups, ARRAY_SIZE(mt7629_wifi_groups)},
{"flash", mt7629_flash_groups, ARRAY_SIZE(mt7629_flash_groups)},
};
static const struct mtk_eint_hw mt7629_eint_hw = {
.port_mask = 7,
.ports = 7,
.ap_num = ARRAY_SIZE(mt7629_pins),
.db_cnt = 16,
};
static struct mtk_pin_soc mt7629_data = {
.reg_cal = mt7629_reg_cals,
.pins = mt7629_pins,
.npins = ARRAY_SIZE(mt7629_pins),
.grps = mt7629_groups,
.ngrps = ARRAY_SIZE(mt7629_groups),
.funcs = mt7629_functions,
.nfuncs = ARRAY_SIZE(mt7629_functions),
.eint_hw = &mt7629_eint_hw,
.gpio_m = 0,
.ies_present = true,
.base_names = mtk_default_register_base_names,
.nbase_names = ARRAY_SIZE(mtk_default_register_base_names),
.bias_disable_set = mtk_pinconf_bias_disable_set_rev1,
.bias_disable_get = mtk_pinconf_bias_disable_get_rev1,
.bias_set = mtk_pinconf_bias_set_rev1,
.bias_get = mtk_pinconf_bias_get_rev1,
.drive_set = mtk_pinconf_drive_set_rev1,
.drive_get = mtk_pinconf_drive_get_rev1,
};
static const struct of_device_id mt7629_pinctrl_of_match[] = {
{ .compatible = "mediatek,mt7629-pinctrl", },
{}
};
static int mt7629_pinctrl_probe(struct platform_device *pdev)
{
return mtk_moore_pinctrl_probe(pdev, &mt7629_data);
}
static struct platform_driver mt7629_pinctrl_driver = {
.driver = {
.name = "mt7629-pinctrl",
.of_match_table = mt7629_pinctrl_of_match,
},
.probe = mt7629_pinctrl_probe,
};
static int __init mt7629_pinctrl_init(void)
{
return platform_driver_register(&mt7629_pinctrl_driver);
}
arch_initcall(mt7629_pinctrl_init);
+333
View File
@@ -0,0 +1,333 @@
/*
* Copyright (c) 2015 MediaTek Inc.
* Author: Hongzhou.Yang <hongzhou.yang@mediatek.com>
* Yingjoe Chen <yingjoe.chen@mediatek.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/regmap.h>
#include <dt-bindings/pinctrl/mt65xx.h>
#include "pinctrl-mtk-common.h"
#include "pinctrl-mtk-mt8127.h"
static const struct mtk_drv_group_desc mt8127_drv_grp[] = {
/* 0E4E8SR 4/8/12/16 */
MTK_DRV_GRP(4, 16, 1, 2, 4),
/* 0E2E4SR 2/4/6/8 */
MTK_DRV_GRP(2, 8, 1, 2, 2),
/* E8E4E2 2/4/6/8/10/12/14/16 */
MTK_DRV_GRP(2, 16, 0, 2, 2)
};
static const struct mtk_pin_drv_grp mt8127_pin_drv[] = {
MTK_PIN_DRV_GRP(0, 0xb00, 0, 1),
MTK_PIN_DRV_GRP(1, 0xb00, 0, 1),
MTK_PIN_DRV_GRP(2, 0xb00, 0, 1),
MTK_PIN_DRV_GRP(3, 0xb00, 0, 1),
MTK_PIN_DRV_GRP(4, 0xb00, 0, 1),
MTK_PIN_DRV_GRP(5, 0xb00, 0, 1),
MTK_PIN_DRV_GRP(6, 0xb00, 0, 1),
MTK_PIN_DRV_GRP(7, 0xb00, 12, 1),
MTK_PIN_DRV_GRP(8, 0xb00, 12, 1),
MTK_PIN_DRV_GRP(9, 0xb00, 12, 1),
MTK_PIN_DRV_GRP(10, 0xb00, 8, 1),
MTK_PIN_DRV_GRP(11, 0xb00, 8, 1),
MTK_PIN_DRV_GRP(12, 0xb00, 8, 1),
MTK_PIN_DRV_GRP(13, 0xb00, 8, 1),
MTK_PIN_DRV_GRP(14, 0xb10, 4, 0),
MTK_PIN_DRV_GRP(15, 0xb10, 4, 0),
MTK_PIN_DRV_GRP(16, 0xb10, 4, 0),
MTK_PIN_DRV_GRP(17, 0xb10, 4, 0),
MTK_PIN_DRV_GRP(18, 0xb10, 8, 0),
MTK_PIN_DRV_GRP(19, 0xb10, 8, 0),
MTK_PIN_DRV_GRP(20, 0xb10, 8, 0),
MTK_PIN_DRV_GRP(21, 0xb10, 8, 0),
MTK_PIN_DRV_GRP(22, 0xb20, 0, 0),
MTK_PIN_DRV_GRP(23, 0xb20, 0, 0),
MTK_PIN_DRV_GRP(24, 0xb20, 0, 0),
MTK_PIN_DRV_GRP(25, 0xb20, 0, 0),
MTK_PIN_DRV_GRP(26, 0xb20, 0, 0),
MTK_PIN_DRV_GRP(27, 0xb20, 4, 0),
MTK_PIN_DRV_GRP(28, 0xb20, 4, 0),
MTK_PIN_DRV_GRP(29, 0xb20, 4, 0),
MTK_PIN_DRV_GRP(30, 0xb20, 4, 0),
MTK_PIN_DRV_GRP(31, 0xb20, 4, 0),
MTK_PIN_DRV_GRP(32, 0xb20, 4, 0),
MTK_PIN_DRV_GRP(33, 0xb30, 4, 1),
MTK_PIN_DRV_GRP(34, 0xb30, 8, 1),
MTK_PIN_DRV_GRP(35, 0xb30, 8, 1),
MTK_PIN_DRV_GRP(36, 0xb30, 8, 1),
MTK_PIN_DRV_GRP(37, 0xb30, 8, 1),
MTK_PIN_DRV_GRP(38, 0xb30, 8, 1),
MTK_PIN_DRV_GRP(39, 0xb30, 12, 1),
MTK_PIN_DRV_GRP(40, 0xb30, 12, 1),
MTK_PIN_DRV_GRP(41, 0xb30, 12, 1),
MTK_PIN_DRV_GRP(42, 0xb30, 12, 1),
MTK_PIN_DRV_GRP(43, 0xb40, 12, 0),
MTK_PIN_DRV_GRP(44, 0xb40, 12, 0),
MTK_PIN_DRV_GRP(45, 0xb40, 12, 0),
MTK_PIN_DRV_GRP(46, 0xb50, 0, 2),
MTK_PIN_DRV_GRP(47, 0xb50, 0, 2),
MTK_PIN_DRV_GRP(48, 0xb50, 0, 2),
MTK_PIN_DRV_GRP(49, 0xb50, 0, 2),
MTK_PIN_DRV_GRP(50, 0xb70, 0, 1),
MTK_PIN_DRV_GRP(51, 0xb70, 0, 1),
MTK_PIN_DRV_GRP(52, 0xb70, 0, 1),
MTK_PIN_DRV_GRP(53, 0xb50, 12, 1),
MTK_PIN_DRV_GRP(54, 0xb50, 12, 1),
MTK_PIN_DRV_GRP(55, 0xb50, 12, 1),
MTK_PIN_DRV_GRP(56, 0xb50, 12, 1),
MTK_PIN_DRV_GRP(59, 0xb40, 4, 1),
MTK_PIN_DRV_GRP(60, 0xb40, 0, 1),
MTK_PIN_DRV_GRP(61, 0xb40, 0, 1),
MTK_PIN_DRV_GRP(62, 0xb40, 0, 1),
MTK_PIN_DRV_GRP(63, 0xb40, 4, 1),
MTK_PIN_DRV_GRP(64, 0xb40, 4, 1),
MTK_PIN_DRV_GRP(65, 0xb40, 4, 1),
MTK_PIN_DRV_GRP(66, 0xb40, 8, 1),
MTK_PIN_DRV_GRP(67, 0xb40, 8, 1),
MTK_PIN_DRV_GRP(68, 0xb40, 8, 1),
MTK_PIN_DRV_GRP(69, 0xb40, 8, 1),
MTK_PIN_DRV_GRP(70, 0xb40, 8, 1),
MTK_PIN_DRV_GRP(71, 0xb40, 8, 1),
MTK_PIN_DRV_GRP(72, 0xb50, 4, 1),
MTK_PIN_DRV_GRP(73, 0xb50, 4, 1),
MTK_PIN_DRV_GRP(74, 0xb50, 4, 1),
MTK_PIN_DRV_GRP(79, 0xb50, 8, 1),
MTK_PIN_DRV_GRP(80, 0xb50, 8, 1),
MTK_PIN_DRV_GRP(81, 0xb50, 8, 1),
MTK_PIN_DRV_GRP(82, 0xb50, 8, 1),
MTK_PIN_DRV_GRP(83, 0xb50, 8, 1),
MTK_PIN_DRV_GRP(84, 0xb50, 8, 1),
MTK_PIN_DRV_GRP(85, 0xce0, 0, 2),
MTK_PIN_DRV_GRP(86, 0xcd0, 0, 2),
MTK_PIN_DRV_GRP(87, 0xcf0, 0, 2),
MTK_PIN_DRV_GRP(88, 0xcf0, 0, 2),
MTK_PIN_DRV_GRP(89, 0xcf0, 0, 2),
MTK_PIN_DRV_GRP(90, 0xcf0, 0, 2),
MTK_PIN_DRV_GRP(117, 0xb60, 12, 1),
MTK_PIN_DRV_GRP(118, 0xb60, 12, 1),
MTK_PIN_DRV_GRP(119, 0xb60, 12, 1),
MTK_PIN_DRV_GRP(120, 0xb60, 12, 1),
MTK_PIN_DRV_GRP(121, 0xc80, 0, 2),
MTK_PIN_DRV_GRP(122, 0xc70, 0, 2),
MTK_PIN_DRV_GRP(123, 0xc90, 0, 2),
MTK_PIN_DRV_GRP(124, 0xc90, 0, 2),
MTK_PIN_DRV_GRP(125, 0xc90, 0, 2),
MTK_PIN_DRV_GRP(126, 0xc90, 0, 2),
MTK_PIN_DRV_GRP(127, 0xc20, 0, 2),
MTK_PIN_DRV_GRP(128, 0xc20, 0, 2),
MTK_PIN_DRV_GRP(129, 0xc20, 0, 2),
MTK_PIN_DRV_GRP(130, 0xc20, 0, 2),
MTK_PIN_DRV_GRP(131, 0xc20, 0, 2),
MTK_PIN_DRV_GRP(132, 0xc10, 0, 2),
MTK_PIN_DRV_GRP(133, 0xc00, 0, 2),
MTK_PIN_DRV_GRP(134, 0xc20, 0, 2),
MTK_PIN_DRV_GRP(135, 0xc20, 0, 2),
MTK_PIN_DRV_GRP(136, 0xc20, 0, 2),
MTK_PIN_DRV_GRP(137, 0xc20, 0, 2),
MTK_PIN_DRV_GRP(142, 0xb50, 0, 2),
};
static const struct mtk_pin_spec_pupd_set_samereg mt8127_spec_pupd[] = {
MTK_PIN_PUPD_SPEC_SR(33, 0xd90, 2, 0, 1), /* KPROW0 */
MTK_PIN_PUPD_SPEC_SR(34, 0xd90, 6, 4, 5), /* KPROW1 */
MTK_PIN_PUPD_SPEC_SR(35, 0xd90, 10, 8, 9), /* KPROW2 */
MTK_PIN_PUPD_SPEC_SR(36, 0xda0, 2, 0, 1), /* KPCOL0 */
MTK_PIN_PUPD_SPEC_SR(37, 0xda0, 6, 4, 5), /* KPCOL1 */
MTK_PIN_PUPD_SPEC_SR(38, 0xda0, 10, 8, 9), /* KPCOL2 */
MTK_PIN_PUPD_SPEC_SR(46, 0xdb0, 2, 0, 1), /* EINT14 */
MTK_PIN_PUPD_SPEC_SR(47, 0xdb0, 6, 4, 5), /* EINT15 */
MTK_PIN_PUPD_SPEC_SR(48, 0xdb0, 10, 8, 9), /* EINT16 */
MTK_PIN_PUPD_SPEC_SR(49, 0xdb0, 14, 12, 13), /* EINT17 */
MTK_PIN_PUPD_SPEC_SR(85, 0xce0, 8, 10, 9), /* MSDC2_CMD */
MTK_PIN_PUPD_SPEC_SR(86, 0xcd0, 8, 10, 9), /* MSDC2_CLK */
MTK_PIN_PUPD_SPEC_SR(87, 0xd00, 0, 2, 1), /* MSDC2_DAT0 */
MTK_PIN_PUPD_SPEC_SR(88, 0xd00, 4, 6, 5), /* MSDC2_DAT1 */
MTK_PIN_PUPD_SPEC_SR(89, 0xd00, 8, 10, 9), /* MSDC2_DAT2 */
MTK_PIN_PUPD_SPEC_SR(90, 0xd00, 12, 14, 13), /* MSDC2_DAT3 */
MTK_PIN_PUPD_SPEC_SR(121, 0xc80, 8, 10, 9), /* MSDC1_CMD */
MTK_PIN_PUPD_SPEC_SR(122, 0xc70, 8, 10, 9), /* MSDC1_CLK */
MTK_PIN_PUPD_SPEC_SR(123, 0xca0, 0, 2, 1), /* MSDC1_DAT0 */
MTK_PIN_PUPD_SPEC_SR(124, 0xca0, 4, 6, 5), /* MSDC1_DAT1 */
MTK_PIN_PUPD_SPEC_SR(125, 0xca0, 8, 10, 9), /* MSDC1_DAT2 */
MTK_PIN_PUPD_SPEC_SR(126, 0xca0, 12, 14, 13), /* MSDC1_DAT3 */
MTK_PIN_PUPD_SPEC_SR(127, 0xc40, 12, 14, 13), /* MSDC0_DAT7 */
MTK_PIN_PUPD_SPEC_SR(128, 0xc40, 8, 10, 9), /* MSDC0_DAT6 */
MTK_PIN_PUPD_SPEC_SR(129, 0xc40, 4, 6, 5), /* MSDC0_DAT5 */
MTK_PIN_PUPD_SPEC_SR(130, 0xc40, 0, 2, 1), /* MSDC0_DAT4 */
MTK_PIN_PUPD_SPEC_SR(131, 0xc50, 0, 2, 1), /* MSDC0_RSTB */
MTK_PIN_PUPD_SPEC_SR(132, 0xc10, 8, 10, 9), /* MSDC0_CMD */
MTK_PIN_PUPD_SPEC_SR(133, 0xc00, 8, 10, 9), /* MSDC0_CLK */
MTK_PIN_PUPD_SPEC_SR(134, 0xc30, 12, 14, 13), /* MSDC0_DAT3 */
MTK_PIN_PUPD_SPEC_SR(135, 0xc30, 8, 10, 9), /* MSDC0_DAT2 */
MTK_PIN_PUPD_SPEC_SR(136, 0xc30, 4, 6, 5), /* MSDC0_DAT1 */
MTK_PIN_PUPD_SPEC_SR(137, 0xc30, 0, 2, 1), /* MSDC0_DAT0 */
MTK_PIN_PUPD_SPEC_SR(142, 0xdc0, 2, 0, 1), /* EINT21 */
};
static int mt8127_spec_pull_set(struct regmap *regmap, unsigned int pin,
unsigned char align, bool isup, unsigned int r1r0)
{
return mtk_pctrl_spec_pull_set_samereg(regmap, mt8127_spec_pupd,
ARRAY_SIZE(mt8127_spec_pupd), pin, align, isup, r1r0);
}
static const struct mtk_pin_ies_smt_set mt8127_ies_set[] = {
MTK_PIN_IES_SMT_SPEC(0, 9, 0x900, 0),
MTK_PIN_IES_SMT_SPEC(10, 13, 0x900, 1),
MTK_PIN_IES_SMT_SPEC(14, 28, 0x900, 2),
MTK_PIN_IES_SMT_SPEC(29, 32, 0x900, 3),
MTK_PIN_IES_SMT_SPEC(33, 33, 0x910, 11),
MTK_PIN_IES_SMT_SPEC(34, 38, 0x900, 10),
MTK_PIN_IES_SMT_SPEC(39, 42, 0x900, 11),
MTK_PIN_IES_SMT_SPEC(43, 45, 0x900, 12),
MTK_PIN_IES_SMT_SPEC(46, 49, 0x900, 13),
MTK_PIN_IES_SMT_SPEC(50, 52, 0x910, 10),
MTK_PIN_IES_SMT_SPEC(53, 56, 0x900, 14),
MTK_PIN_IES_SMT_SPEC(57, 58, 0x910, 0),
MTK_PIN_IES_SMT_SPEC(59, 65, 0x910, 2),
MTK_PIN_IES_SMT_SPEC(66, 71, 0x910, 3),
MTK_PIN_IES_SMT_SPEC(72, 74, 0x910, 4),
MTK_PIN_IES_SMT_SPEC(75, 76, 0x900, 15),
MTK_PIN_IES_SMT_SPEC(77, 78, 0x910, 1),
MTK_PIN_IES_SMT_SPEC(79, 82, 0x910, 5),
MTK_PIN_IES_SMT_SPEC(83, 84, 0x910, 6),
MTK_PIN_IES_SMT_SPEC(117, 120, 0x910, 7),
MTK_PIN_IES_SMT_SPEC(121, 121, 0xc80, 4),
MTK_PIN_IES_SMT_SPEC(122, 122, 0xc70, 4),
MTK_PIN_IES_SMT_SPEC(123, 126, 0xc90, 4),
MTK_PIN_IES_SMT_SPEC(127, 131, 0xc20, 4),
MTK_PIN_IES_SMT_SPEC(132, 132, 0xc10, 4),
MTK_PIN_IES_SMT_SPEC(133, 133, 0xc00, 4),
MTK_PIN_IES_SMT_SPEC(134, 137, 0xc20, 4),
MTK_PIN_IES_SMT_SPEC(138, 141, 0x910, 9),
MTK_PIN_IES_SMT_SPEC(142, 142, 0x900, 13),
};
static const struct mtk_pin_ies_smt_set mt8127_smt_set[] = {
MTK_PIN_IES_SMT_SPEC(0, 9, 0x920, 0),
MTK_PIN_IES_SMT_SPEC(10, 13, 0x920, 1),
MTK_PIN_IES_SMT_SPEC(14, 28, 0x920, 2),
MTK_PIN_IES_SMT_SPEC(29, 32, 0x920, 3),
MTK_PIN_IES_SMT_SPEC(33, 33, 0x930, 11),
MTK_PIN_IES_SMT_SPEC(34, 38, 0x920, 10),
MTK_PIN_IES_SMT_SPEC(39, 42, 0x920, 11),
MTK_PIN_IES_SMT_SPEC(43, 45, 0x920, 12),
MTK_PIN_IES_SMT_SPEC(46, 49, 0x920, 13),
MTK_PIN_IES_SMT_SPEC(50, 52, 0x930, 10),
MTK_PIN_IES_SMT_SPEC(53, 56, 0x920, 14),
MTK_PIN_IES_SMT_SPEC(57, 58, 0x930, 0),
MTK_PIN_IES_SMT_SPEC(59, 65, 0x930, 2),
MTK_PIN_IES_SMT_SPEC(66, 71, 0x930, 3),
MTK_PIN_IES_SMT_SPEC(72, 74, 0x930, 4),
MTK_PIN_IES_SMT_SPEC(75, 76, 0x920, 15),
MTK_PIN_IES_SMT_SPEC(77, 78, 0x930, 1),
MTK_PIN_IES_SMT_SPEC(79, 82, 0x930, 5),
MTK_PIN_IES_SMT_SPEC(83, 84, 0x930, 6),
MTK_PIN_IES_SMT_SPEC(85, 85, 0xce0, 11),
MTK_PIN_IES_SMT_SPEC(86, 86, 0xcd0, 11),
MTK_PIN_IES_SMT_SPEC(87, 87, 0xd00, 3),
MTK_PIN_IES_SMT_SPEC(88, 88, 0xd00, 7),
MTK_PIN_IES_SMT_SPEC(89, 89, 0xd00, 11),
MTK_PIN_IES_SMT_SPEC(90, 90, 0xd00, 15),
MTK_PIN_IES_SMT_SPEC(117, 120, 0x930, 7),
MTK_PIN_IES_SMT_SPEC(121, 121, 0xc80, 11),
MTK_PIN_IES_SMT_SPEC(122, 122, 0xc70, 11),
MTK_PIN_IES_SMT_SPEC(123, 123, 0xca0, 3),
MTK_PIN_IES_SMT_SPEC(124, 124, 0xca0, 7),
MTK_PIN_IES_SMT_SPEC(125, 125, 0xca0, 11),
MTK_PIN_IES_SMT_SPEC(126, 126, 0xca0, 15),
MTK_PIN_IES_SMT_SPEC(127, 127, 0xc40, 15),
MTK_PIN_IES_SMT_SPEC(128, 128, 0xc40, 11),
MTK_PIN_IES_SMT_SPEC(129, 129, 0xc40, 7),
MTK_PIN_IES_SMT_SPEC(130, 130, 0xc40, 3),
MTK_PIN_IES_SMT_SPEC(131, 131, 0xc50, 3),
MTK_PIN_IES_SMT_SPEC(132, 132, 0xc10, 11),
MTK_PIN_IES_SMT_SPEC(133, 133, 0xc00, 11),
MTK_PIN_IES_SMT_SPEC(134, 134, 0xc30, 15),
MTK_PIN_IES_SMT_SPEC(135, 135, 0xc30, 11),
MTK_PIN_IES_SMT_SPEC(136, 136, 0xc30, 7),
MTK_PIN_IES_SMT_SPEC(137, 137, 0xc30, 3),
MTK_PIN_IES_SMT_SPEC(138, 141, 0x930, 9),
MTK_PIN_IES_SMT_SPEC(142, 142, 0x920, 13),
};
static int mt8127_ies_smt_set(struct regmap *regmap, unsigned int pin,
unsigned char align, int value, enum pin_config_param arg)
{
if (arg == PIN_CONFIG_INPUT_ENABLE)
return mtk_pconf_spec_set_ies_smt_range(regmap, mt8127_ies_set,
ARRAY_SIZE(mt8127_ies_set), pin, align, value);
else if (arg == PIN_CONFIG_INPUT_SCHMITT_ENABLE)
return mtk_pconf_spec_set_ies_smt_range(regmap, mt8127_smt_set,
ARRAY_SIZE(mt8127_smt_set), pin, align, value);
return -EINVAL;
}
static const struct mtk_pinctrl_devdata mt8127_pinctrl_data = {
.pins = mtk_pins_mt8127,
.npins = ARRAY_SIZE(mtk_pins_mt8127),
.grp_desc = mt8127_drv_grp,
.n_grp_cls = ARRAY_SIZE(mt8127_drv_grp),
.pin_drv_grp = mt8127_pin_drv,
.n_pin_drv_grps = ARRAY_SIZE(mt8127_pin_drv),
.spec_pull_set = mt8127_spec_pull_set,
.spec_ies_smt_set = mt8127_ies_smt_set,
.dir_offset = 0x0000,
.pullen_offset = 0x0100,
.pullsel_offset = 0x0200,
.dout_offset = 0x0400,
.din_offset = 0x0500,
.pinmux_offset = 0x0600,
.type1_start = 143,
.type1_end = 143,
.port_shf = 4,
.port_mask = 0xf,
.port_align = 4,
.eint_hw = {
.port_mask = 7,
.ports = 6,
.ap_num = 143,
.db_cnt = 16,
},
};
static int mt8127_pinctrl_probe(struct platform_device *pdev)
{
return mtk_pctrl_init(pdev, &mt8127_pinctrl_data, NULL);
}
static const struct of_device_id mt8127_pctrl_match[] = {
{ .compatible = "mediatek,mt8127-pinctrl", },
{ }
};
static struct platform_driver mtk_pinctrl_driver = {
.probe = mt8127_pinctrl_probe,
.driver = {
.name = "mediatek-mt8127-pinctrl",
.of_match_table = mt8127_pctrl_match,
},
};
static int __init mtk_pinctrl_init(void)
{
return platform_driver_register(&mtk_pinctrl_driver);
}
arch_initcall(mtk_pinctrl_init);
+348
View File
@@ -0,0 +1,348 @@
/*
* Copyright (c) 2014 MediaTek Inc.
* Author: Hongzhou.Yang <hongzhou.yang@mediatek.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/regmap.h>
#include <dt-bindings/pinctrl/mt65xx.h>
#include "pinctrl-mtk-common.h"
#include "pinctrl-mtk-mt8135.h"
#define DRV_BASE1 0x500
#define DRV_BASE2 0x510
#define PUPD_BASE1 0x400
#define PUPD_BASE2 0x450
#define R0_BASE1 0x4d0
#define R1_BASE1 0x200
#define R1_BASE2 0x250
struct mtk_spec_pull_set {
unsigned char pin;
unsigned char pupd_bit;
unsigned short pupd_offset;
unsigned short r0_offset;
unsigned short r1_offset;
unsigned char r0_bit;
unsigned char r1_bit;
};
#define SPEC_PULL(_pin, _pupd_offset, _pupd_bit, _r0_offset, \
_r0_bit, _r1_offset, _r1_bit) \
{ \
.pin = _pin, \
.pupd_offset = _pupd_offset, \
.pupd_bit = _pupd_bit, \
.r0_offset = _r0_offset, \
.r0_bit = _r0_bit, \
.r1_offset = _r1_offset, \
.r1_bit = _r1_bit, \
}
static const struct mtk_drv_group_desc mt8135_drv_grp[] = {
/* E8E4E2 2/4/6/8/10/12/14/16 */
MTK_DRV_GRP(2, 16, 0, 2, 2),
/* E8E4 4/8/12/16 */
MTK_DRV_GRP(4, 16, 1, 2, 4),
/* E4E2 2/4/6/8 */
MTK_DRV_GRP(2, 8, 0, 1, 2),
/* E16E8E4 4/8/12/16/20/24/28/32 */
MTK_DRV_GRP(4, 32, 0, 2, 4)
};
static const struct mtk_pin_drv_grp mt8135_pin_drv[] = {
MTK_PIN_DRV_GRP(0, DRV_BASE1, 0, 0),
MTK_PIN_DRV_GRP(1, DRV_BASE1, 0, 0),
MTK_PIN_DRV_GRP(2, DRV_BASE1, 0, 0),
MTK_PIN_DRV_GRP(3, DRV_BASE1, 0, 0),
MTK_PIN_DRV_GRP(4, DRV_BASE1, 4, 0),
MTK_PIN_DRV_GRP(5, DRV_BASE1, 8, 0),
MTK_PIN_DRV_GRP(6, DRV_BASE1, 0, 0),
MTK_PIN_DRV_GRP(7, DRV_BASE1, 0, 0),
MTK_PIN_DRV_GRP(8, DRV_BASE1, 0, 0),
MTK_PIN_DRV_GRP(9, DRV_BASE1, 0, 0),
MTK_PIN_DRV_GRP(10, DRV_BASE1, 12, 1),
MTK_PIN_DRV_GRP(11, DRV_BASE1, 12, 1),
MTK_PIN_DRV_GRP(12, DRV_BASE1, 12, 1),
MTK_PIN_DRV_GRP(13, DRV_BASE1, 12, 1),
MTK_PIN_DRV_GRP(14, DRV_BASE1, 12, 1),
MTK_PIN_DRV_GRP(15, DRV_BASE1, 12, 1),
MTK_PIN_DRV_GRP(16, DRV_BASE1, 12, 1),
MTK_PIN_DRV_GRP(17, DRV_BASE1, 16, 1),
MTK_PIN_DRV_GRP(18, DRV_BASE1, 16, 1),
MTK_PIN_DRV_GRP(19, DRV_BASE1, 16, 1),
MTK_PIN_DRV_GRP(20, DRV_BASE1, 16, 1),
MTK_PIN_DRV_GRP(21, DRV_BASE1, 16, 1),
MTK_PIN_DRV_GRP(22, DRV_BASE1, 16, 1),
MTK_PIN_DRV_GRP(23, DRV_BASE1, 16, 1),
MTK_PIN_DRV_GRP(24, DRV_BASE1, 16, 1),
MTK_PIN_DRV_GRP(33, DRV_BASE1, 24, 1),
MTK_PIN_DRV_GRP(34, DRV_BASE2, 12, 2),
MTK_PIN_DRV_GRP(37, DRV_BASE2, 20, 1),
MTK_PIN_DRV_GRP(38, DRV_BASE2, 20, 1),
MTK_PIN_DRV_GRP(39, DRV_BASE2, 20, 1),
MTK_PIN_DRV_GRP(40, DRV_BASE2, 24, 1),
MTK_PIN_DRV_GRP(41, DRV_BASE2, 24, 1),
MTK_PIN_DRV_GRP(42, DRV_BASE2, 24, 1),
MTK_PIN_DRV_GRP(43, DRV_BASE2, 28, 1),
MTK_PIN_DRV_GRP(44, DRV_BASE2, 28, 1),
MTK_PIN_DRV_GRP(45, DRV_BASE2, 28, 1),
MTK_PIN_DRV_GRP(46, DRV_BASE2, 28, 1),
MTK_PIN_DRV_GRP(47, DRV_BASE2, 28, 1),
MTK_PIN_DRV_GRP(49, DRV_BASE2+0x10, 0, 1),
MTK_PIN_DRV_GRP(50, DRV_BASE2+0x10, 4, 1),
MTK_PIN_DRV_GRP(51, DRV_BASE2+0x10, 8, 1),
MTK_PIN_DRV_GRP(52, DRV_BASE2+0x10, 12, 2),
MTK_PIN_DRV_GRP(53, DRV_BASE2+0x10, 16, 1),
MTK_PIN_DRV_GRP(54, DRV_BASE2+0x10, 20, 1),
MTK_PIN_DRV_GRP(55, DRV_BASE2+0x10, 24, 1),
MTK_PIN_DRV_GRP(56, DRV_BASE2+0x10, 28, 1),
MTK_PIN_DRV_GRP(57, DRV_BASE2+0x20, 0, 1),
MTK_PIN_DRV_GRP(58, DRV_BASE2+0x20, 0, 1),
MTK_PIN_DRV_GRP(59, DRV_BASE2+0x20, 0, 1),
MTK_PIN_DRV_GRP(60, DRV_BASE2+0x20, 0, 1),
MTK_PIN_DRV_GRP(61, DRV_BASE2+0x20, 0, 1),
MTK_PIN_DRV_GRP(62, DRV_BASE2+0x20, 0, 1),
MTK_PIN_DRV_GRP(63, DRV_BASE2+0x20, 4, 1),
MTK_PIN_DRV_GRP(64, DRV_BASE2+0x20, 8, 1),
MTK_PIN_DRV_GRP(65, DRV_BASE2+0x20, 12, 1),
MTK_PIN_DRV_GRP(66, DRV_BASE2+0x20, 16, 1),
MTK_PIN_DRV_GRP(67, DRV_BASE2+0x20, 20, 1),
MTK_PIN_DRV_GRP(68, DRV_BASE2+0x20, 24, 1),
MTK_PIN_DRV_GRP(69, DRV_BASE2+0x20, 28, 1),
MTK_PIN_DRV_GRP(70, DRV_BASE2+0x30, 0, 1),
MTK_PIN_DRV_GRP(71, DRV_BASE2+0x30, 4, 1),
MTK_PIN_DRV_GRP(72, DRV_BASE2+0x30, 8, 1),
MTK_PIN_DRV_GRP(73, DRV_BASE2+0x30, 12, 1),
MTK_PIN_DRV_GRP(74, DRV_BASE2+0x30, 16, 1),
MTK_PIN_DRV_GRP(75, DRV_BASE2+0x30, 20, 1),
MTK_PIN_DRV_GRP(76, DRV_BASE2+0x30, 24, 1),
MTK_PIN_DRV_GRP(77, DRV_BASE2+0x30, 28, 3),
MTK_PIN_DRV_GRP(78, DRV_BASE2+0x30, 28, 3),
MTK_PIN_DRV_GRP(79, DRV_BASE2+0x40, 0, 3),
MTK_PIN_DRV_GRP(80, DRV_BASE2+0x40, 4, 3),
MTK_PIN_DRV_GRP(81, DRV_BASE2+0x30, 28, 3),
MTK_PIN_DRV_GRP(82, DRV_BASE2+0x30, 28, 3),
MTK_PIN_DRV_GRP(83, DRV_BASE2+0x40, 8, 3),
MTK_PIN_DRV_GRP(84, DRV_BASE2+0x40, 8, 3),
MTK_PIN_DRV_GRP(85, DRV_BASE2+0x40, 12, 3),
MTK_PIN_DRV_GRP(86, DRV_BASE2+0x40, 16, 3),
MTK_PIN_DRV_GRP(87, DRV_BASE2+0x40, 8, 3),
MTK_PIN_DRV_GRP(88, DRV_BASE2+0x40, 8, 3),
MTK_PIN_DRV_GRP(89, DRV_BASE2+0x50, 12, 0),
MTK_PIN_DRV_GRP(90, DRV_BASE2+0x50, 12, 0),
MTK_PIN_DRV_GRP(91, DRV_BASE2+0x50, 12, 0),
MTK_PIN_DRV_GRP(92, DRV_BASE2+0x50, 12, 0),
MTK_PIN_DRV_GRP(93, DRV_BASE2+0x50, 12, 0),
MTK_PIN_DRV_GRP(94, DRV_BASE2+0x50, 12, 0),
MTK_PIN_DRV_GRP(95, DRV_BASE2+0x50, 12, 0),
MTK_PIN_DRV_GRP(96, DRV_BASE1+0xb0, 28, 0),
MTK_PIN_DRV_GRP(97, DRV_BASE2+0x50, 12, 0),
MTK_PIN_DRV_GRP(98, DRV_BASE2+0x50, 16, 0),
MTK_PIN_DRV_GRP(99, DRV_BASE2+0x50, 20, 1),
MTK_PIN_DRV_GRP(102, DRV_BASE2+0x50, 24, 1),
MTK_PIN_DRV_GRP(103, DRV_BASE2+0x50, 28, 1),
MTK_PIN_DRV_GRP(104, DRV_BASE2+0x60, 0, 1),
MTK_PIN_DRV_GRP(105, DRV_BASE2+0x60, 4, 1),
MTK_PIN_DRV_GRP(106, DRV_BASE2+0x60, 4, 1),
MTK_PIN_DRV_GRP(107, DRV_BASE2+0x60, 4, 1),
MTK_PIN_DRV_GRP(108, DRV_BASE2+0x60, 4, 1),
MTK_PIN_DRV_GRP(109, DRV_BASE2+0x60, 8, 2),
MTK_PIN_DRV_GRP(110, DRV_BASE2+0x60, 12, 2),
MTK_PIN_DRV_GRP(111, DRV_BASE2+0x60, 16, 2),
MTK_PIN_DRV_GRP(112, DRV_BASE2+0x60, 20, 2),
MTK_PIN_DRV_GRP(113, DRV_BASE2+0x60, 24, 2),
MTK_PIN_DRV_GRP(114, DRV_BASE2+0x60, 28, 2),
MTK_PIN_DRV_GRP(115, DRV_BASE2+0x70, 0, 2),
MTK_PIN_DRV_GRP(116, DRV_BASE2+0x70, 4, 2),
MTK_PIN_DRV_GRP(117, DRV_BASE2+0x70, 8, 2),
MTK_PIN_DRV_GRP(118, DRV_BASE2+0x70, 12, 2),
MTK_PIN_DRV_GRP(119, DRV_BASE2+0x70, 16, 2),
MTK_PIN_DRV_GRP(120, DRV_BASE2+0x70, 20, 2),
MTK_PIN_DRV_GRP(181, DRV_BASE1+0xa0, 12, 1),
MTK_PIN_DRV_GRP(182, DRV_BASE1+0xa0, 16, 1),
MTK_PIN_DRV_GRP(183, DRV_BASE1+0xa0, 20, 1),
MTK_PIN_DRV_GRP(184, DRV_BASE1+0xa0, 24, 1),
MTK_PIN_DRV_GRP(185, DRV_BASE1+0xa0, 28, 1),
MTK_PIN_DRV_GRP(186, DRV_BASE1+0xb0, 0, 2),
MTK_PIN_DRV_GRP(187, DRV_BASE1+0xb0, 0, 2),
MTK_PIN_DRV_GRP(188, DRV_BASE1+0xb0, 0, 2),
MTK_PIN_DRV_GRP(189, DRV_BASE1+0xb0, 0, 2),
MTK_PIN_DRV_GRP(190, DRV_BASE1+0xb0, 4, 1),
MTK_PIN_DRV_GRP(191, DRV_BASE1+0xb0, 8, 1),
MTK_PIN_DRV_GRP(192, DRV_BASE1+0xb0, 12, 1),
MTK_PIN_DRV_GRP(197, DRV_BASE1+0xb0, 16, 0),
MTK_PIN_DRV_GRP(198, DRV_BASE1+0xb0, 16, 0),
MTK_PIN_DRV_GRP(199, DRV_BASE1+0xb0, 20, 0),
MTK_PIN_DRV_GRP(200, DRV_BASE1+0xb0, 24, 0),
MTK_PIN_DRV_GRP(201, DRV_BASE1+0xb0, 16, 0),
MTK_PIN_DRV_GRP(202, DRV_BASE1+0xb0, 16, 0)
};
static const struct mtk_spec_pull_set spec_pupd[] = {
SPEC_PULL(0, PUPD_BASE1, 0, R0_BASE1, 9, R1_BASE1, 0),
SPEC_PULL(1, PUPD_BASE1, 1, R0_BASE1, 8, R1_BASE1, 1),
SPEC_PULL(2, PUPD_BASE1, 2, R0_BASE1, 7, R1_BASE1, 2),
SPEC_PULL(3, PUPD_BASE1, 3, R0_BASE1, 6, R1_BASE1, 3),
SPEC_PULL(4, PUPD_BASE1, 4, R0_BASE1, 1, R1_BASE1, 4),
SPEC_PULL(5, PUPD_BASE1, 5, R0_BASE1, 0, R1_BASE1, 5),
SPEC_PULL(6, PUPD_BASE1, 6, R0_BASE1, 5, R1_BASE1, 6),
SPEC_PULL(7, PUPD_BASE1, 7, R0_BASE1, 4, R1_BASE1, 7),
SPEC_PULL(8, PUPD_BASE1, 8, R0_BASE1, 3, R1_BASE1, 8),
SPEC_PULL(9, PUPD_BASE1, 9, R0_BASE1, 2, R1_BASE1, 9),
SPEC_PULL(89, PUPD_BASE2, 9, R0_BASE1, 18, R1_BASE2, 9),
SPEC_PULL(90, PUPD_BASE2, 10, R0_BASE1, 19, R1_BASE2, 10),
SPEC_PULL(91, PUPD_BASE2, 11, R0_BASE1, 23, R1_BASE2, 11),
SPEC_PULL(92, PUPD_BASE2, 12, R0_BASE1, 24, R1_BASE2, 12),
SPEC_PULL(93, PUPD_BASE2, 13, R0_BASE1, 25, R1_BASE2, 13),
SPEC_PULL(94, PUPD_BASE2, 14, R0_BASE1, 22, R1_BASE2, 14),
SPEC_PULL(95, PUPD_BASE2, 15, R0_BASE1, 20, R1_BASE2, 15),
SPEC_PULL(96, PUPD_BASE2+0x10, 0, R0_BASE1, 16, R1_BASE2+0x10, 0),
SPEC_PULL(97, PUPD_BASE2+0x10, 1, R0_BASE1, 21, R1_BASE2+0x10, 1),
SPEC_PULL(98, PUPD_BASE2+0x10, 2, R0_BASE1, 17, R1_BASE2+0x10, 2),
SPEC_PULL(197, PUPD_BASE1+0xc0, 5, R0_BASE1, 13, R1_BASE2+0xc0, 5),
SPEC_PULL(198, PUPD_BASE2+0xc0, 6, R0_BASE1, 14, R1_BASE2+0xc0, 6),
SPEC_PULL(199, PUPD_BASE2+0xc0, 7, R0_BASE1, 11, R1_BASE2+0xc0, 7),
SPEC_PULL(200, PUPD_BASE2+0xc0, 8, R0_BASE1, 10, R1_BASE2+0xc0, 8),
SPEC_PULL(201, PUPD_BASE2+0xc0, 9, R0_BASE1, 13, R1_BASE2+0xc0, 9),
SPEC_PULL(202, PUPD_BASE2+0xc0, 10, R0_BASE1, 12, R1_BASE2+0xc0, 10)
};
static int spec_pull_set(struct regmap *regmap, unsigned int pin,
unsigned char align, bool isup, unsigned int r1r0)
{
unsigned int i;
unsigned int reg_pupd, reg_set_r0, reg_set_r1;
unsigned int reg_rst_r0, reg_rst_r1;
bool find = false;
for (i = 0; i < ARRAY_SIZE(spec_pupd); i++) {
if (pin == spec_pupd[i].pin) {
find = true;
break;
}
}
if (!find)
return -EINVAL;
if (isup)
reg_pupd = spec_pupd[i].pupd_offset + align;
else
reg_pupd = spec_pupd[i].pupd_offset + (align << 1);
regmap_write(regmap, reg_pupd, spec_pupd[i].pupd_bit);
reg_set_r0 = spec_pupd[i].r0_offset + align;
reg_rst_r0 = spec_pupd[i].r0_offset + (align << 1);
reg_set_r1 = spec_pupd[i].r1_offset + align;
reg_rst_r1 = spec_pupd[i].r1_offset + (align << 1);
switch (r1r0) {
case MTK_PUPD_SET_R1R0_00:
regmap_write(regmap, reg_rst_r0, spec_pupd[i].r0_bit);
regmap_write(regmap, reg_rst_r1, spec_pupd[i].r1_bit);
break;
case MTK_PUPD_SET_R1R0_01:
regmap_write(regmap, reg_set_r0, spec_pupd[i].r0_bit);
regmap_write(regmap, reg_rst_r1, spec_pupd[i].r1_bit);
break;
case MTK_PUPD_SET_R1R0_10:
regmap_write(regmap, reg_rst_r0, spec_pupd[i].r0_bit);
regmap_write(regmap, reg_set_r1, spec_pupd[i].r1_bit);
break;
case MTK_PUPD_SET_R1R0_11:
regmap_write(regmap, reg_set_r0, spec_pupd[i].r0_bit);
regmap_write(regmap, reg_set_r1, spec_pupd[i].r1_bit);
break;
default:
return -EINVAL;
}
return 0;
}
static const struct mtk_pinctrl_devdata mt8135_pinctrl_data = {
.pins = mtk_pins_mt8135,
.npins = ARRAY_SIZE(mtk_pins_mt8135),
.grp_desc = mt8135_drv_grp,
.n_grp_cls = ARRAY_SIZE(mt8135_drv_grp),
.pin_drv_grp = mt8135_pin_drv,
.n_pin_drv_grps = ARRAY_SIZE(mt8135_pin_drv),
.spec_pull_set = spec_pull_set,
.dir_offset = 0x0000,
.ies_offset = 0x0100,
.pullen_offset = 0x0200,
.smt_offset = 0x0300,
.pullsel_offset = 0x0400,
.dout_offset = 0x0800,
.din_offset = 0x0A00,
.pinmux_offset = 0x0C00,
.type1_start = 34,
.type1_end = 149,
.port_shf = 4,
.port_mask = 0xf,
.port_align = 4,
.eint_hw = {
.port_mask = 7,
.ports = 6,
.ap_num = 192,
.db_cnt = 16,
},
};
static int mt8135_pinctrl_probe(struct platform_device *pdev)
{
return mtk_pctrl_init(pdev, &mt8135_pinctrl_data, NULL);
}
static const struct of_device_id mt8135_pctrl_match[] = {
{
.compatible = "mediatek,mt8135-pinctrl",
},
{ }
};
static struct platform_driver mtk_pinctrl_driver = {
.probe = mt8135_pinctrl_probe,
.driver = {
.name = "mediatek-mt8135-pinctrl",
.of_match_table = mt8135_pctrl_match,
},
};
static int __init mtk_pinctrl_init(void)
{
return platform_driver_register(&mtk_pinctrl_driver);
}
arch_initcall(mtk_pinctrl_init);
+376
View File
@@ -0,0 +1,376 @@
/*
* Copyright (c) 2014-2015 MediaTek Inc.
* Author: Hongzhou.Yang <hongzhou.yang@mediatek.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/regmap.h>
#include <linux/pinctrl/pinconf-generic.h>
#include <dt-bindings/pinctrl/mt65xx.h>
#include "pinctrl-mtk-common.h"
#include "pinctrl-mtk-mt8173.h"
#define DRV_BASE 0xb00
static const struct mtk_pin_spec_pupd_set_samereg mt8173_spec_pupd[] = {
MTK_PIN_PUPD_SPEC_SR(119, 0xe00, 2, 1, 0), /* KROW0 */
MTK_PIN_PUPD_SPEC_SR(120, 0xe00, 6, 5, 4), /* KROW1 */
MTK_PIN_PUPD_SPEC_SR(121, 0xe00, 10, 9, 8), /* KROW2 */
MTK_PIN_PUPD_SPEC_SR(122, 0xe10, 2, 1, 0), /* KCOL0 */
MTK_PIN_PUPD_SPEC_SR(123, 0xe10, 6, 5, 4), /* KCOL1 */
MTK_PIN_PUPD_SPEC_SR(124, 0xe10, 10, 9, 8), /* KCOL2 */
MTK_PIN_PUPD_SPEC_SR(67, 0xd10, 2, 1, 0), /* ms0 DS */
MTK_PIN_PUPD_SPEC_SR(68, 0xd00, 2, 1, 0), /* ms0 RST */
MTK_PIN_PUPD_SPEC_SR(66, 0xc10, 2, 1, 0), /* ms0 cmd */
MTK_PIN_PUPD_SPEC_SR(65, 0xc00, 2, 1, 0), /* ms0 clk */
MTK_PIN_PUPD_SPEC_SR(57, 0xc20, 2, 1, 0), /* ms0 data0 */
MTK_PIN_PUPD_SPEC_SR(58, 0xc20, 2, 1, 0), /* ms0 data1 */
MTK_PIN_PUPD_SPEC_SR(59, 0xc20, 2, 1, 0), /* ms0 data2 */
MTK_PIN_PUPD_SPEC_SR(60, 0xc20, 2, 1, 0), /* ms0 data3 */
MTK_PIN_PUPD_SPEC_SR(61, 0xc20, 2, 1, 0), /* ms0 data4 */
MTK_PIN_PUPD_SPEC_SR(62, 0xc20, 2, 1, 0), /* ms0 data5 */
MTK_PIN_PUPD_SPEC_SR(63, 0xc20, 2, 1, 0), /* ms0 data6 */
MTK_PIN_PUPD_SPEC_SR(64, 0xc20, 2, 1, 0), /* ms0 data7 */
MTK_PIN_PUPD_SPEC_SR(78, 0xc50, 2, 1, 0), /* ms1 cmd */
MTK_PIN_PUPD_SPEC_SR(73, 0xd20, 2, 1, 0), /* ms1 dat0 */
MTK_PIN_PUPD_SPEC_SR(74, 0xd20, 6, 5, 4), /* ms1 dat1 */
MTK_PIN_PUPD_SPEC_SR(75, 0xd20, 10, 9, 8), /* ms1 dat2 */
MTK_PIN_PUPD_SPEC_SR(76, 0xd20, 14, 13, 12), /* ms1 dat3 */
MTK_PIN_PUPD_SPEC_SR(77, 0xc40, 2, 1, 0), /* ms1 clk */
MTK_PIN_PUPD_SPEC_SR(100, 0xd40, 2, 1, 0), /* ms2 dat0 */
MTK_PIN_PUPD_SPEC_SR(101, 0xd40, 6, 5, 4), /* ms2 dat1 */
MTK_PIN_PUPD_SPEC_SR(102, 0xd40, 10, 9, 8), /* ms2 dat2 */
MTK_PIN_PUPD_SPEC_SR(103, 0xd40, 14, 13, 12), /* ms2 dat3 */
MTK_PIN_PUPD_SPEC_SR(104, 0xc80, 2, 1, 0), /* ms2 clk */
MTK_PIN_PUPD_SPEC_SR(105, 0xc90, 2, 1, 0), /* ms2 cmd */
MTK_PIN_PUPD_SPEC_SR(22, 0xd60, 2, 1, 0), /* ms3 dat0 */
MTK_PIN_PUPD_SPEC_SR(23, 0xd60, 6, 5, 4), /* ms3 dat1 */
MTK_PIN_PUPD_SPEC_SR(24, 0xd60, 10, 9, 8), /* ms3 dat2 */
MTK_PIN_PUPD_SPEC_SR(25, 0xd60, 14, 13, 12), /* ms3 dat3 */
MTK_PIN_PUPD_SPEC_SR(26, 0xcc0, 2, 1, 0), /* ms3 clk */
MTK_PIN_PUPD_SPEC_SR(27, 0xcd0, 2, 1, 0) /* ms3 cmd */
};
static int mt8173_spec_pull_set(struct regmap *regmap, unsigned int pin,
unsigned char align, bool isup, unsigned int r1r0)
{
return mtk_pctrl_spec_pull_set_samereg(regmap, mt8173_spec_pupd,
ARRAY_SIZE(mt8173_spec_pupd), pin, align, isup, r1r0);
}
static const struct mtk_pin_ies_smt_set mt8173_smt_set[] = {
MTK_PIN_IES_SMT_SPEC(0, 4, 0x930, 1),
MTK_PIN_IES_SMT_SPEC(5, 9, 0x930, 2),
MTK_PIN_IES_SMT_SPEC(10, 13, 0x930, 10),
MTK_PIN_IES_SMT_SPEC(14, 15, 0x940, 10),
MTK_PIN_IES_SMT_SPEC(16, 16, 0x930, 0),
MTK_PIN_IES_SMT_SPEC(17, 17, 0x950, 2),
MTK_PIN_IES_SMT_SPEC(18, 21, 0x940, 3),
MTK_PIN_IES_SMT_SPEC(22, 25, 0xce0, 13),
MTK_PIN_IES_SMT_SPEC(26, 26, 0xcc0, 13),
MTK_PIN_IES_SMT_SPEC(27, 27, 0xcd0, 13),
MTK_PIN_IES_SMT_SPEC(28, 28, 0xd70, 13),
MTK_PIN_IES_SMT_SPEC(29, 32, 0x930, 3),
MTK_PIN_IES_SMT_SPEC(33, 33, 0x930, 4),
MTK_PIN_IES_SMT_SPEC(34, 36, 0x930, 5),
MTK_PIN_IES_SMT_SPEC(37, 38, 0x930, 6),
MTK_PIN_IES_SMT_SPEC(39, 39, 0x930, 7),
MTK_PIN_IES_SMT_SPEC(40, 41, 0x930, 9),
MTK_PIN_IES_SMT_SPEC(42, 42, 0x940, 0),
MTK_PIN_IES_SMT_SPEC(43, 44, 0x930, 11),
MTK_PIN_IES_SMT_SPEC(45, 46, 0x930, 12),
MTK_PIN_IES_SMT_SPEC(57, 64, 0xc20, 13),
MTK_PIN_IES_SMT_SPEC(65, 65, 0xc10, 13),
MTK_PIN_IES_SMT_SPEC(66, 66, 0xc00, 13),
MTK_PIN_IES_SMT_SPEC(67, 67, 0xd10, 13),
MTK_PIN_IES_SMT_SPEC(68, 68, 0xd00, 13),
MTK_PIN_IES_SMT_SPEC(69, 72, 0x940, 14),
MTK_PIN_IES_SMT_SPEC(73, 76, 0xc60, 13),
MTK_PIN_IES_SMT_SPEC(77, 77, 0xc40, 13),
MTK_PIN_IES_SMT_SPEC(78, 78, 0xc50, 13),
MTK_PIN_IES_SMT_SPEC(79, 82, 0x940, 15),
MTK_PIN_IES_SMT_SPEC(83, 83, 0x950, 0),
MTK_PIN_IES_SMT_SPEC(84, 85, 0x950, 1),
MTK_PIN_IES_SMT_SPEC(86, 91, 0x950, 2),
MTK_PIN_IES_SMT_SPEC(92, 92, 0x930, 13),
MTK_PIN_IES_SMT_SPEC(93, 95, 0x930, 14),
MTK_PIN_IES_SMT_SPEC(96, 99, 0x930, 15),
MTK_PIN_IES_SMT_SPEC(100, 103, 0xca0, 13),
MTK_PIN_IES_SMT_SPEC(104, 104, 0xc80, 13),
MTK_PIN_IES_SMT_SPEC(105, 105, 0xc90, 13),
MTK_PIN_IES_SMT_SPEC(106, 107, 0x940, 4),
MTK_PIN_IES_SMT_SPEC(108, 112, 0x940, 1),
MTK_PIN_IES_SMT_SPEC(113, 116, 0x940, 2),
MTK_PIN_IES_SMT_SPEC(117, 118, 0x940, 5),
MTK_PIN_IES_SMT_SPEC(119, 124, 0x940, 6),
MTK_PIN_IES_SMT_SPEC(125, 126, 0x940, 7),
MTK_PIN_IES_SMT_SPEC(127, 127, 0x940, 0),
MTK_PIN_IES_SMT_SPEC(128, 128, 0x950, 8),
MTK_PIN_IES_SMT_SPEC(129, 130, 0x950, 9),
MTK_PIN_IES_SMT_SPEC(131, 132, 0x950, 8),
MTK_PIN_IES_SMT_SPEC(133, 134, 0x910, 8)
};
static const struct mtk_pin_ies_smt_set mt8173_ies_set[] = {
MTK_PIN_IES_SMT_SPEC(0, 4, 0x900, 1),
MTK_PIN_IES_SMT_SPEC(5, 9, 0x900, 2),
MTK_PIN_IES_SMT_SPEC(10, 13, 0x900, 10),
MTK_PIN_IES_SMT_SPEC(14, 15, 0x910, 10),
MTK_PIN_IES_SMT_SPEC(16, 16, 0x900, 0),
MTK_PIN_IES_SMT_SPEC(17, 17, 0x920, 2),
MTK_PIN_IES_SMT_SPEC(18, 21, 0x910, 3),
MTK_PIN_IES_SMT_SPEC(22, 25, 0xce0, 14),
MTK_PIN_IES_SMT_SPEC(26, 26, 0xcc0, 14),
MTK_PIN_IES_SMT_SPEC(27, 27, 0xcd0, 14),
MTK_PIN_IES_SMT_SPEC(28, 28, 0xd70, 14),
MTK_PIN_IES_SMT_SPEC(29, 32, 0x900, 3),
MTK_PIN_IES_SMT_SPEC(33, 33, 0x900, 4),
MTK_PIN_IES_SMT_SPEC(34, 36, 0x900, 5),
MTK_PIN_IES_SMT_SPEC(37, 38, 0x900, 6),
MTK_PIN_IES_SMT_SPEC(39, 39, 0x900, 7),
MTK_PIN_IES_SMT_SPEC(40, 41, 0x900, 9),
MTK_PIN_IES_SMT_SPEC(42, 42, 0x910, 0),
MTK_PIN_IES_SMT_SPEC(43, 44, 0x900, 11),
MTK_PIN_IES_SMT_SPEC(45, 46, 0x900, 12),
MTK_PIN_IES_SMT_SPEC(57, 64, 0xc20, 14),
MTK_PIN_IES_SMT_SPEC(65, 65, 0xc10, 14),
MTK_PIN_IES_SMT_SPEC(66, 66, 0xc00, 14),
MTK_PIN_IES_SMT_SPEC(67, 67, 0xd10, 14),
MTK_PIN_IES_SMT_SPEC(68, 68, 0xd00, 14),
MTK_PIN_IES_SMT_SPEC(69, 72, 0x910, 14),
MTK_PIN_IES_SMT_SPEC(73, 76, 0xc60, 14),
MTK_PIN_IES_SMT_SPEC(77, 77, 0xc40, 14),
MTK_PIN_IES_SMT_SPEC(78, 78, 0xc50, 14),
MTK_PIN_IES_SMT_SPEC(79, 82, 0x910, 15),
MTK_PIN_IES_SMT_SPEC(83, 83, 0x920, 0),
MTK_PIN_IES_SMT_SPEC(84, 85, 0x920, 1),
MTK_PIN_IES_SMT_SPEC(86, 91, 0x920, 2),
MTK_PIN_IES_SMT_SPEC(92, 92, 0x900, 13),
MTK_PIN_IES_SMT_SPEC(93, 95, 0x900, 14),
MTK_PIN_IES_SMT_SPEC(96, 99, 0x900, 15),
MTK_PIN_IES_SMT_SPEC(100, 103, 0xca0, 14),
MTK_PIN_IES_SMT_SPEC(104, 104, 0xc80, 14),
MTK_PIN_IES_SMT_SPEC(105, 105, 0xc90, 14),
MTK_PIN_IES_SMT_SPEC(106, 107, 0x910, 4),
MTK_PIN_IES_SMT_SPEC(108, 112, 0x910, 1),
MTK_PIN_IES_SMT_SPEC(113, 116, 0x910, 2),
MTK_PIN_IES_SMT_SPEC(117, 118, 0x910, 5),
MTK_PIN_IES_SMT_SPEC(119, 124, 0x910, 6),
MTK_PIN_IES_SMT_SPEC(125, 126, 0x910, 7),
MTK_PIN_IES_SMT_SPEC(127, 127, 0x910, 0),
MTK_PIN_IES_SMT_SPEC(128, 128, 0x920, 8),
MTK_PIN_IES_SMT_SPEC(129, 130, 0x920, 9),
MTK_PIN_IES_SMT_SPEC(131, 132, 0x920, 8),
MTK_PIN_IES_SMT_SPEC(133, 134, 0x910, 8)
};
static int mt8173_ies_smt_set(struct regmap *regmap, unsigned int pin,
unsigned char align, int value, enum pin_config_param arg)
{
if (arg == PIN_CONFIG_INPUT_ENABLE)
return mtk_pconf_spec_set_ies_smt_range(regmap, mt8173_ies_set,
ARRAY_SIZE(mt8173_ies_set), pin, align, value);
else if (arg == PIN_CONFIG_INPUT_SCHMITT_ENABLE)
return mtk_pconf_spec_set_ies_smt_range(regmap, mt8173_smt_set,
ARRAY_SIZE(mt8173_smt_set), pin, align, value);
return -EINVAL;
}
static const struct mtk_drv_group_desc mt8173_drv_grp[] = {
/* 0E4E8SR 4/8/12/16 */
MTK_DRV_GRP(4, 16, 1, 2, 4),
/* 0E2E4SR 2/4/6/8 */
MTK_DRV_GRP(2, 8, 1, 2, 2),
/* E8E4E2 2/4/6/8/10/12/14/16 */
MTK_DRV_GRP(2, 16, 0, 2, 2)
};
static const struct mtk_pin_drv_grp mt8173_pin_drv[] = {
MTK_PIN_DRV_GRP(0, DRV_BASE+0x20, 12, 0),
MTK_PIN_DRV_GRP(1, DRV_BASE+0x20, 12, 0),
MTK_PIN_DRV_GRP(2, DRV_BASE+0x20, 12, 0),
MTK_PIN_DRV_GRP(3, DRV_BASE+0x20, 12, 0),
MTK_PIN_DRV_GRP(4, DRV_BASE+0x20, 12, 0),
MTK_PIN_DRV_GRP(5, DRV_BASE+0x30, 0, 0),
MTK_PIN_DRV_GRP(6, DRV_BASE+0x30, 0, 0),
MTK_PIN_DRV_GRP(7, DRV_BASE+0x30, 0, 0),
MTK_PIN_DRV_GRP(8, DRV_BASE+0x30, 0, 0),
MTK_PIN_DRV_GRP(9, DRV_BASE+0x30, 0, 0),
MTK_PIN_DRV_GRP(10, DRV_BASE+0x30, 4, 1),
MTK_PIN_DRV_GRP(11, DRV_BASE+0x30, 4, 1),
MTK_PIN_DRV_GRP(12, DRV_BASE+0x30, 4, 1),
MTK_PIN_DRV_GRP(13, DRV_BASE+0x30, 4, 1),
MTK_PIN_DRV_GRP(14, DRV_BASE+0x40, 8, 1),
MTK_PIN_DRV_GRP(15, DRV_BASE+0x40, 8, 1),
MTK_PIN_DRV_GRP(16, DRV_BASE, 8, 1),
MTK_PIN_DRV_GRP(17, 0xce0, 8, 2),
MTK_PIN_DRV_GRP(22, 0xce0, 8, 2),
MTK_PIN_DRV_GRP(23, 0xce0, 8, 2),
MTK_PIN_DRV_GRP(24, 0xce0, 8, 2),
MTK_PIN_DRV_GRP(25, 0xce0, 8, 2),
MTK_PIN_DRV_GRP(26, 0xcc0, 8, 2),
MTK_PIN_DRV_GRP(27, 0xcd0, 8, 2),
MTK_PIN_DRV_GRP(28, 0xd70, 8, 2),
MTK_PIN_DRV_GRP(29, DRV_BASE+0x80, 12, 1),
MTK_PIN_DRV_GRP(30, DRV_BASE+0x80, 12, 1),
MTK_PIN_DRV_GRP(31, DRV_BASE+0x80, 12, 1),
MTK_PIN_DRV_GRP(32, DRV_BASE+0x80, 12, 1),
MTK_PIN_DRV_GRP(33, DRV_BASE+0x10, 12, 1),
MTK_PIN_DRV_GRP(34, DRV_BASE+0x10, 8, 1),
MTK_PIN_DRV_GRP(35, DRV_BASE+0x10, 8, 1),
MTK_PIN_DRV_GRP(36, DRV_BASE+0x10, 8, 1),
MTK_PIN_DRV_GRP(37, DRV_BASE+0x10, 4, 1),
MTK_PIN_DRV_GRP(38, DRV_BASE+0x10, 4, 1),
MTK_PIN_DRV_GRP(39, DRV_BASE+0x20, 0, 0),
MTK_PIN_DRV_GRP(40, DRV_BASE+0x20, 8, 0),
MTK_PIN_DRV_GRP(41, DRV_BASE+0x20, 8, 0),
MTK_PIN_DRV_GRP(42, DRV_BASE+0x50, 8, 1),
MTK_PIN_DRV_GRP(57, 0xc20, 8, 2),
MTK_PIN_DRV_GRP(58, 0xc20, 8, 2),
MTK_PIN_DRV_GRP(59, 0xc20, 8, 2),
MTK_PIN_DRV_GRP(60, 0xc20, 8, 2),
MTK_PIN_DRV_GRP(61, 0xc20, 8, 2),
MTK_PIN_DRV_GRP(62, 0xc20, 8, 2),
MTK_PIN_DRV_GRP(63, 0xc20, 8, 2),
MTK_PIN_DRV_GRP(64, 0xc20, 8, 2),
MTK_PIN_DRV_GRP(65, 0xc00, 8, 2),
MTK_PIN_DRV_GRP(66, 0xc10, 8, 2),
MTK_PIN_DRV_GRP(67, 0xd10, 8, 2),
MTK_PIN_DRV_GRP(68, 0xd00, 8, 2),
MTK_PIN_DRV_GRP(69, DRV_BASE+0x80, 0, 1),
MTK_PIN_DRV_GRP(70, DRV_BASE+0x80, 0, 1),
MTK_PIN_DRV_GRP(71, DRV_BASE+0x80, 0, 1),
MTK_PIN_DRV_GRP(72, DRV_BASE+0x80, 0, 1),
MTK_PIN_DRV_GRP(73, 0xc60, 8, 2),
MTK_PIN_DRV_GRP(74, 0xc60, 8, 2),
MTK_PIN_DRV_GRP(75, 0xc60, 8, 2),
MTK_PIN_DRV_GRP(76, 0xc60, 8, 2),
MTK_PIN_DRV_GRP(77, 0xc40, 8, 2),
MTK_PIN_DRV_GRP(78, 0xc50, 8, 2),
MTK_PIN_DRV_GRP(79, DRV_BASE+0x70, 12, 1),
MTK_PIN_DRV_GRP(80, DRV_BASE+0x70, 12, 1),
MTK_PIN_DRV_GRP(81, DRV_BASE+0x70, 12, 1),
MTK_PIN_DRV_GRP(82, DRV_BASE+0x70, 12, 1),
MTK_PIN_DRV_GRP(83, DRV_BASE, 4, 1),
MTK_PIN_DRV_GRP(84, DRV_BASE, 0, 1),
MTK_PIN_DRV_GRP(85, DRV_BASE, 0, 1),
MTK_PIN_DRV_GRP(85, DRV_BASE+0x60, 8, 1),
MTK_PIN_DRV_GRP(86, DRV_BASE+0x60, 8, 1),
MTK_PIN_DRV_GRP(87, DRV_BASE+0x60, 8, 1),
MTK_PIN_DRV_GRP(88, DRV_BASE+0x60, 8, 1),
MTK_PIN_DRV_GRP(89, DRV_BASE+0x60, 8, 1),
MTK_PIN_DRV_GRP(90, DRV_BASE+0x60, 8, 1),
MTK_PIN_DRV_GRP(91, DRV_BASE+0x60, 8, 1),
MTK_PIN_DRV_GRP(92, DRV_BASE+0x60, 4, 0),
MTK_PIN_DRV_GRP(93, DRV_BASE+0x60, 0, 0),
MTK_PIN_DRV_GRP(94, DRV_BASE+0x60, 0, 0),
MTK_PIN_DRV_GRP(95, DRV_BASE+0x60, 0, 0),
MTK_PIN_DRV_GRP(96, DRV_BASE+0x80, 8, 1),
MTK_PIN_DRV_GRP(97, DRV_BASE+0x80, 8, 1),
MTK_PIN_DRV_GRP(98, DRV_BASE+0x80, 8, 1),
MTK_PIN_DRV_GRP(99, DRV_BASE+0x80, 8, 1),
MTK_PIN_DRV_GRP(100, 0xca0, 8, 2),
MTK_PIN_DRV_GRP(101, 0xca0, 8, 2),
MTK_PIN_DRV_GRP(102, 0xca0, 8, 2),
MTK_PIN_DRV_GRP(103, 0xca0, 8, 2),
MTK_PIN_DRV_GRP(104, 0xc80, 8, 2),
MTK_PIN_DRV_GRP(105, 0xc90, 8, 2),
MTK_PIN_DRV_GRP(108, DRV_BASE+0x50, 0, 1),
MTK_PIN_DRV_GRP(109, DRV_BASE+0x50, 0, 1),
MTK_PIN_DRV_GRP(110, DRV_BASE+0x50, 0, 1),
MTK_PIN_DRV_GRP(111, DRV_BASE+0x50, 0, 1),
MTK_PIN_DRV_GRP(112, DRV_BASE+0x50, 0, 1),
MTK_PIN_DRV_GRP(113, DRV_BASE+0x80, 4, 1),
MTK_PIN_DRV_GRP(114, DRV_BASE+0x80, 4, 1),
MTK_PIN_DRV_GRP(115, DRV_BASE+0x80, 4, 1),
MTK_PIN_DRV_GRP(116, DRV_BASE+0x80, 4, 1),
MTK_PIN_DRV_GRP(117, DRV_BASE+0x90, 0, 1),
MTK_PIN_DRV_GRP(118, DRV_BASE+0x90, 0, 1),
MTK_PIN_DRV_GRP(119, DRV_BASE+0x50, 4, 1),
MTK_PIN_DRV_GRP(120, DRV_BASE+0x50, 4, 1),
MTK_PIN_DRV_GRP(121, DRV_BASE+0x50, 4, 1),
MTK_PIN_DRV_GRP(122, DRV_BASE+0x50, 4, 1),
MTK_PIN_DRV_GRP(123, DRV_BASE+0x50, 4, 1),
MTK_PIN_DRV_GRP(124, DRV_BASE+0x50, 4, 1),
MTK_PIN_DRV_GRP(125, DRV_BASE+0x30, 12, 1),
MTK_PIN_DRV_GRP(126, DRV_BASE+0x30, 12, 1),
MTK_PIN_DRV_GRP(127, DRV_BASE+0x50, 8, 1),
MTK_PIN_DRV_GRP(128, DRV_BASE+0x40, 0, 1),
MTK_PIN_DRV_GRP(129, DRV_BASE+0x40, 0, 1),
MTK_PIN_DRV_GRP(130, DRV_BASE+0x40, 0, 1),
MTK_PIN_DRV_GRP(131, DRV_BASE+0x40, 0, 1),
MTK_PIN_DRV_GRP(132, DRV_BASE+0x40, 0, 1)
};
static const struct mtk_pinctrl_devdata mt8173_pinctrl_data = {
.pins = mtk_pins_mt8173,
.npins = ARRAY_SIZE(mtk_pins_mt8173),
.grp_desc = mt8173_drv_grp,
.n_grp_cls = ARRAY_SIZE(mt8173_drv_grp),
.pin_drv_grp = mt8173_pin_drv,
.n_pin_drv_grps = ARRAY_SIZE(mt8173_pin_drv),
.spec_pull_set = mt8173_spec_pull_set,
.spec_ies_smt_set = mt8173_ies_smt_set,
.dir_offset = 0x0000,
.pullen_offset = 0x0100,
.pullsel_offset = 0x0200,
.dout_offset = 0x0400,
.din_offset = 0x0500,
.pinmux_offset = 0x0600,
.type1_start = 135,
.type1_end = 135,
.port_shf = 4,
.port_mask = 0xf,
.port_align = 4,
.eint_hw = {
.port_mask = 7,
.ports = 6,
.ap_num = 224,
.db_cnt = 16,
},
};
static int mt8173_pinctrl_probe(struct platform_device *pdev)
{
return mtk_pctrl_init(pdev, &mt8173_pinctrl_data, NULL);
}
static const struct of_device_id mt8173_pctrl_match[] = {
{
.compatible = "mediatek,mt8173-pinctrl",
},
{ }
};
static struct platform_driver mtk_pinctrl_driver = {
.probe = mt8173_pinctrl_probe,
.driver = {
.name = "mediatek-mt8173-pinctrl",
.of_match_table = mt8173_pctrl_match,
.pm = &mtk_eint_pm_ops,
},
};
static int __init mtk_pinctrl_init(void)
{
return platform_driver_register(&mtk_pinctrl_driver);
}
arch_initcall(mtk_pinctrl_init);
+541
View File
@@ -0,0 +1,541 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2018 MediaTek Inc.
*
* Author: Zhiyong Tao <zhiyong.tao@mediatek.com>
*
*/
#include "pinctrl-mtk-mt8183.h"
#include "pinctrl-paris.h"
/* MT8183 have multiple bases to program pin configuration listed as the below:
* iocfg[0]:0x10005000, iocfg[1]:0x11F20000, iocfg[2]:0x11E80000,
* iocfg[3]:0x11E70000, iocfg[4]:0x11E90000, iocfg[5]:0x11D30000,
* iocfg[6]:0x11D20000, iocfg[7]:0x11C50000, iocfg[8]:0x11F30000.
* _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)
#define PINS_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, 1)
static const struct mtk_pin_field_calc mt8183_pin_mode_range[] = {
PIN_FIELD(0, 192, 0x300, 0x10, 0, 4),
};
static const struct mtk_pin_field_calc mt8183_pin_dir_range[] = {
PIN_FIELD(0, 192, 0x0, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt8183_pin_di_range[] = {
PIN_FIELD(0, 192, 0x200, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt8183_pin_do_range[] = {
PIN_FIELD(0, 192, 0x100, 0x10, 0, 1),
};
static const struct mtk_pin_field_calc mt8183_pin_ies_range[] = {
PINS_FIELD_BASE(0, 3, 6, 0x000, 0x10, 3, 1),
PINS_FIELD_BASE(4, 7, 6, 0x000, 0x10, 5, 1),
PIN_FIELD_BASE(8, 8, 6, 0x000, 0x10, 0, 1),
PINS_FIELD_BASE(9, 10, 6, 0x000, 0x10, 12, 1),
PIN_FIELD_BASE(11, 11, 1, 0x000, 0x10, 3, 1),
PIN_FIELD_BASE(12, 12, 1, 0x000, 0x10, 7, 1),
PINS_FIELD_BASE(13, 16, 2, 0x000, 0x10, 2, 1),
PINS_FIELD_BASE(17, 20, 2, 0x000, 0x10, 3, 1),
PINS_FIELD_BASE(21, 24, 2, 0x000, 0x10, 4, 1),
PINS_FIELD_BASE(25, 28, 2, 0x000, 0x10, 5, 1),
PIN_FIELD_BASE(29, 29, 2, 0x000, 0x10, 6, 1),
PIN_FIELD_BASE(30, 30, 2, 0x000, 0x10, 7, 1),
PINS_FIELD_BASE(31, 31, 2, 0x000, 0x10, 8, 1),
PINS_FIELD_BASE(32, 34, 2, 0x000, 0x10, 7, 1),
PINS_FIELD_BASE(35, 37, 3, 0x000, 0x10, 0, 1),
PINS_FIELD_BASE(38, 40, 3, 0x000, 0x10, 1, 1),
PINS_FIELD_BASE(41, 42, 3, 0x000, 0x10, 2, 1),
PINS_FIELD_BASE(43, 45, 3, 0x000, 0x10, 3, 1),
PINS_FIELD_BASE(46, 47, 3, 0x000, 0x10, 4, 1),
PINS_FIELD_BASE(48, 49, 3, 0x000, 0x10, 5, 1),
PINS_FIELD_BASE(50, 51, 4, 0x000, 0x10, 0, 1),
PINS_FIELD_BASE(52, 57, 4, 0x000, 0x10, 1, 1),
PINS_FIELD_BASE(58, 60, 4, 0x000, 0x10, 2, 1),
PINS_FIELD_BASE(61, 64, 5, 0x000, 0x10, 0, 1),
PINS_FIELD_BASE(65, 66, 5, 0x000, 0x10, 1, 1),
PINS_FIELD_BASE(67, 68, 5, 0x000, 0x10, 2, 1),
PINS_FIELD_BASE(69, 71, 5, 0x000, 0x10, 3, 1),
PINS_FIELD_BASE(72, 76, 5, 0x000, 0x10, 4, 1),
PINS_FIELD_BASE(77, 80, 5, 0x000, 0x10, 5, 1),
PIN_FIELD_BASE(81, 81, 5, 0x000, 0x10, 6, 1),
PINS_FIELD_BASE(82, 83, 5, 0x000, 0x10, 7, 1),
PIN_FIELD_BASE(84, 84, 5, 0x000, 0x10, 6, 1),
PINS_FIELD_BASE(85, 88, 5, 0x000, 0x10, 8, 1),
PIN_FIELD_BASE(89, 89, 6, 0x000, 0x10, 11, 1),
PIN_FIELD_BASE(90, 90, 6, 0x000, 0x10, 1, 1),
PINS_FIELD_BASE(91, 94, 6, 0x000, 0x10, 2, 1),
PINS_FIELD_BASE(95, 96, 6, 0x000, 0x10, 6, 1),
PINS_FIELD_BASE(97, 98, 6, 0x000, 0x10, 7, 1),
PIN_FIELD_BASE(99, 99, 6, 0x000, 0x10, 8, 1),
PIN_FIELD_BASE(100, 100, 6, 0x000, 0x10, 9, 1),
PINS_FIELD_BASE(101, 102, 6, 0x000, 0x10, 10, 1),
PINS_FIELD_BASE(103, 104, 6, 0x000, 0x10, 13, 1),
PINS_FIELD_BASE(105, 106, 6, 0x000, 0x10, 14, 1),
PIN_FIELD_BASE(107, 107, 7, 0x000, 0x10, 0, 1),
PIN_FIELD_BASE(108, 108, 7, 0x000, 0x10, 1, 1),
PIN_FIELD_BASE(109, 109, 7, 0x000, 0x10, 2, 1),
PIN_FIELD_BASE(110, 110, 7, 0x000, 0x10, 0, 1),
PIN_FIELD_BASE(111, 111, 7, 0x000, 0x10, 3, 1),
PIN_FIELD_BASE(112, 112, 7, 0x000, 0x10, 2, 1),
PIN_FIELD_BASE(113, 113, 7, 0x000, 0x10, 4, 1),
PIN_FIELD_BASE(114, 114, 7, 0x000, 0x10, 5, 1),
PIN_FIELD_BASE(115, 115, 7, 0x000, 0x10, 6, 1),
PIN_FIELD_BASE(116, 116, 7, 0x000, 0x10, 7, 1),
PIN_FIELD_BASE(117, 117, 7, 0x000, 0x10, 8, 1),
PIN_FIELD_BASE(118, 118, 7, 0x000, 0x10, 9, 1),
PIN_FIELD_BASE(119, 119, 7, 0x000, 0x10, 10, 1),
PIN_FIELD_BASE(120, 120, 7, 0x000, 0x10, 11, 1),
PIN_FIELD_BASE(121, 121, 7, 0x000, 0x10, 12, 1),
PIN_FIELD_BASE(122, 122, 8, 0x000, 0x10, 0, 1),
PIN_FIELD_BASE(123, 123, 8, 0x000, 0x10, 1, 1),
PIN_FIELD_BASE(124, 124, 8, 0x000, 0x10, 2, 1),
PINS_FIELD_BASE(125, 130, 8, 0x000, 0x10, 1, 1),
PIN_FIELD_BASE(131, 131, 8, 0x000, 0x10, 3, 1),
PIN_FIELD_BASE(132, 132, 8, 0x000, 0x10, 1, 1),
PIN_FIELD_BASE(133, 133, 8, 0x000, 0x10, 4, 1),
PIN_FIELD_BASE(134, 134, 1, 0x000, 0x10, 0, 1),
PIN_FIELD_BASE(135, 135, 1, 0x000, 0x10, 1, 1),
PINS_FIELD_BASE(136, 143, 1, 0x000, 0x10, 2, 1),
PINS_FIELD_BASE(144, 147, 1, 0x000, 0x10, 4, 1),
PIN_FIELD_BASE(148, 148, 1, 0x000, 0x10, 5, 1),
PIN_FIELD_BASE(149, 149, 1, 0x000, 0x10, 6, 1),
PINS_FIELD_BASE(150, 153, 1, 0x000, 0x10, 8, 1),
PIN_FIELD_BASE(154, 154, 1, 0x000, 0x10, 9, 1),
PINS_FIELD_BASE(155, 157, 1, 0x000, 0x10, 10, 1),
PINS_FIELD_BASE(158, 160, 1, 0x000, 0x10, 8, 1),
PINS_FIELD_BASE(161, 164, 2, 0x000, 0x10, 0, 1),
PINS_FIELD_BASE(165, 166, 2, 0x000, 0x10, 1, 1),
PINS_FIELD_BASE(167, 168, 4, 0x000, 0x10, 2, 1),
PIN_FIELD_BASE(169, 169, 4, 0x000, 0x10, 3, 1),
PINS_FIELD_BASE(170, 174, 4, 0x000, 0x10, 4, 1),
PINS_FIELD_BASE(175, 176, 4, 0x000, 0x10, 3, 1),
PINS_FIELD_BASE(177, 179, 6, 0x000, 0x10, 4, 1),
};
static const struct mtk_pin_field_calc mt8183_pin_smt_range[] = {
PINS_FIELD_BASE(0, 3, 6, 0x010, 0x10, 3, 1),
PINS_FIELD_BASE(4, 7, 6, 0x010, 0x10, 5, 1),
PIN_FIELD_BASE(8, 8, 6, 0x010, 0x10, 0, 1),
PINS_FIELD_BASE(9, 10, 6, 0x010, 0x10, 12, 1),
PIN_FIELD_BASE(11, 11, 1, 0x010, 0x10, 3, 1),
PIN_FIELD_BASE(12, 12, 1, 0x010, 0x10, 7, 1),
PINS_FIELD_BASE(13, 16, 2, 0x010, 0x10, 2, 1),
PINS_FIELD_BASE(17, 20, 2, 0x010, 0x10, 3, 1),
PINS_FIELD_BASE(21, 24, 2, 0x010, 0x10, 4, 1),
PINS_FIELD_BASE(25, 28, 2, 0x010, 0x10, 5, 1),
PIN_FIELD_BASE(29, 29, 2, 0x010, 0x10, 6, 1),
PIN_FIELD_BASE(30, 30, 2, 0x010, 0x10, 7, 1),
PINS_FIELD_BASE(31, 31, 2, 0x010, 0x10, 8, 1),
PINS_FIELD_BASE(32, 34, 2, 0x010, 0x10, 7, 1),
PINS_FIELD_BASE(35, 37, 3, 0x010, 0x10, 0, 1),
PINS_FIELD_BASE(38, 40, 3, 0x010, 0x10, 1, 1),
PINS_FIELD_BASE(41, 42, 3, 0x010, 0x10, 2, 1),
PINS_FIELD_BASE(43, 45, 3, 0x010, 0x10, 3, 1),
PINS_FIELD_BASE(46, 47, 3, 0x010, 0x10, 4, 1),
PINS_FIELD_BASE(48, 49, 3, 0x010, 0x10, 5, 1),
PINS_FIELD_BASE(50, 51, 4, 0x010, 0x10, 0, 1),
PINS_FIELD_BASE(52, 57, 4, 0x010, 0x10, 1, 1),
PINS_FIELD_BASE(58, 60, 4, 0x010, 0x10, 2, 1),
PINS_FIELD_BASE(61, 64, 5, 0x010, 0x10, 0, 1),
PINS_FIELD_BASE(65, 66, 5, 0x010, 0x10, 1, 1),
PINS_FIELD_BASE(67, 68, 5, 0x010, 0x10, 2, 1),
PINS_FIELD_BASE(69, 71, 5, 0x010, 0x10, 3, 1),
PINS_FIELD_BASE(72, 76, 5, 0x010, 0x10, 4, 1),
PINS_FIELD_BASE(77, 80, 5, 0x010, 0x10, 5, 1),
PIN_FIELD_BASE(81, 81, 5, 0x010, 0x10, 6, 1),
PINS_FIELD_BASE(82, 83, 5, 0x010, 0x10, 7, 1),
PIN_FIELD_BASE(84, 84, 5, 0x010, 0x10, 6, 1),
PINS_FIELD_BASE(85, 88, 5, 0x010, 0x10, 8, 1),
PIN_FIELD_BASE(89, 89, 6, 0x010, 0x10, 11, 1),
PIN_FIELD_BASE(90, 90, 6, 0x010, 0x10, 1, 1),
PINS_FIELD_BASE(91, 94, 6, 0x010, 0x10, 2, 1),
PINS_FIELD_BASE(95, 96, 6, 0x010, 0x10, 6, 1),
PINS_FIELD_BASE(97, 98, 6, 0x010, 0x10, 7, 1),
PIN_FIELD_BASE(99, 99, 6, 0x010, 0x10, 8, 1),
PIN_FIELD_BASE(100, 100, 6, 0x010, 0x10, 9, 1),
PINS_FIELD_BASE(101, 102, 6, 0x010, 0x10, 10, 1),
PINS_FIELD_BASE(103, 104, 6, 0x010, 0x10, 13, 1),
PINS_FIELD_BASE(105, 106, 6, 0x010, 0x10, 14, 1),
PIN_FIELD_BASE(107, 107, 7, 0x010, 0x10, 0, 1),
PIN_FIELD_BASE(108, 108, 7, 0x010, 0x10, 1, 1),
PIN_FIELD_BASE(109, 109, 7, 0x010, 0x10, 2, 1),
PIN_FIELD_BASE(110, 110, 7, 0x010, 0x10, 0, 1),
PIN_FIELD_BASE(111, 111, 7, 0x010, 0x10, 3, 1),
PIN_FIELD_BASE(112, 112, 7, 0x010, 0x10, 2, 1),
PIN_FIELD_BASE(113, 113, 7, 0x010, 0x10, 4, 1),
PIN_FIELD_BASE(114, 114, 7, 0x010, 0x10, 5, 1),
PIN_FIELD_BASE(115, 115, 7, 0x010, 0x10, 6, 1),
PIN_FIELD_BASE(116, 116, 7, 0x010, 0x10, 7, 1),
PIN_FIELD_BASE(117, 117, 7, 0x010, 0x10, 8, 1),
PIN_FIELD_BASE(118, 118, 7, 0x010, 0x10, 9, 1),
PIN_FIELD_BASE(119, 119, 7, 0x010, 0x10, 10, 1),
PIN_FIELD_BASE(120, 120, 7, 0x010, 0x10, 11, 1),
PIN_FIELD_BASE(121, 121, 7, 0x010, 0x10, 12, 1),
PIN_FIELD_BASE(122, 122, 8, 0x010, 0x10, 0, 1),
PIN_FIELD_BASE(123, 123, 8, 0x010, 0x10, 1, 1),
PIN_FIELD_BASE(124, 124, 8, 0x010, 0x10, 2, 1),
PINS_FIELD_BASE(125, 130, 8, 0x010, 0x10, 1, 1),
PIN_FIELD_BASE(131, 131, 8, 0x010, 0x10, 3, 1),
PIN_FIELD_BASE(132, 132, 8, 0x010, 0x10, 1, 1),
PIN_FIELD_BASE(133, 133, 8, 0x010, 0x10, 4, 1),
PIN_FIELD_BASE(134, 134, 1, 0x010, 0x10, 0, 1),
PIN_FIELD_BASE(135, 135, 1, 0x010, 0x10, 1, 1),
PINS_FIELD_BASE(136, 143, 1, 0x010, 0x10, 2, 1),
PINS_FIELD_BASE(144, 147, 1, 0x010, 0x10, 4, 1),
PIN_FIELD_BASE(148, 148, 1, 0x010, 0x10, 5, 1),
PIN_FIELD_BASE(149, 149, 1, 0x010, 0x10, 6, 1),
PINS_FIELD_BASE(150, 153, 1, 0x010, 0x10, 8, 1),
PIN_FIELD_BASE(154, 154, 1, 0x010, 0x10, 9, 1),
PINS_FIELD_BASE(155, 157, 1, 0x010, 0x10, 10, 1),
PINS_FIELD_BASE(158, 160, 1, 0x010, 0x10, 8, 1),
PINS_FIELD_BASE(161, 164, 2, 0x010, 0x10, 0, 1),
PINS_FIELD_BASE(165, 166, 2, 0x010, 0x10, 1, 1),
PINS_FIELD_BASE(167, 168, 4, 0x010, 0x10, 2, 1),
PIN_FIELD_BASE(169, 169, 4, 0x010, 0x10, 3, 1),
PINS_FIELD_BASE(170, 174, 4, 0x010, 0x10, 4, 1),
PINS_FIELD_BASE(175, 176, 4, 0x010, 0x10, 3, 1),
PINS_FIELD_BASE(177, 179, 6, 0x010, 0x10, 4, 1),
};
static const struct mtk_pin_field_calc mt8183_pin_pullen_range[] = {
PIN_FIELD_BASE(0, 3, 6, 0x060, 0x10, 6, 1),
PIN_FIELD_BASE(4, 7, 6, 0x060, 0x10, 11, 1),
PIN_FIELD_BASE(8, 8, 6, 0x060, 0x10, 0, 1),
PIN_FIELD_BASE(9, 10, 6, 0x060, 0x10, 26, 1),
PIN_FIELD_BASE(11, 11, 1, 0x060, 0x10, 10, 1),
PIN_FIELD_BASE(12, 12, 1, 0x060, 0x10, 17, 1),
PIN_FIELD_BASE(13, 28, 2, 0x060, 0x10, 6, 1),
PIN_FIELD_BASE(43, 49, 3, 0x060, 0x10, 8, 1),
PIN_FIELD_BASE(50, 60, 4, 0x060, 0x10, 0, 1),
PIN_FIELD_BASE(61, 88, 5, 0x060, 0x10, 0, 1),
PIN_FIELD_BASE(89, 89, 6, 0x060, 0x10, 24, 1),
PIN_FIELD_BASE(90, 90, 6, 0x060, 0x10, 1, 1),
PIN_FIELD_BASE(95, 95, 6, 0x060, 0x10, 15, 1),
PIN_FIELD_BASE(96, 102, 6, 0x060, 0x10, 17, 1),
PIN_FIELD_BASE(103, 106, 6, 0x060, 0x10, 28, 1),
PIN_FIELD_BASE(107, 121, 7, 0x060, 0x10, 0, 1),
PIN_FIELD_BASE(134, 143, 1, 0x060, 0x10, 0, 1),
PIN_FIELD_BASE(144, 149, 1, 0x060, 0x10, 11, 1),
PIN_FIELD_BASE(150, 160, 1, 0x060, 0x10, 18, 1),
PIN_FIELD_BASE(161, 166, 2, 0x060, 0x10, 0, 1),
PIN_FIELD_BASE(167, 176, 4, 0x060, 0x10, 11, 1),
PIN_FIELD_BASE(177, 177, 6, 0x060, 0x10, 10, 1),
PIN_FIELD_BASE(178, 178, 6, 0x060, 0x10, 16, 1),
PIN_FIELD_BASE(179, 179, 6, 0x060, 0x10, 25, 1),
};
static const struct mtk_pin_field_calc mt8183_pin_pullsel_range[] = {
PIN_FIELD_BASE(0, 3, 6, 0x080, 0x10, 6, 1),
PIN_FIELD_BASE(4, 7, 6, 0x080, 0x10, 11, 1),
PIN_FIELD_BASE(8, 8, 6, 0x080, 0x10, 0, 1),
PIN_FIELD_BASE(9, 10, 6, 0x080, 0x10, 26, 1),
PIN_FIELD_BASE(11, 11, 1, 0x080, 0x10, 10, 1),
PIN_FIELD_BASE(12, 12, 1, 0x080, 0x10, 17, 1),
PIN_FIELD_BASE(13, 28, 2, 0x080, 0x10, 6, 1),
PIN_FIELD_BASE(43, 49, 3, 0x080, 0x10, 8, 1),
PIN_FIELD_BASE(50, 60, 4, 0x080, 0x10, 0, 1),
PIN_FIELD_BASE(61, 88, 5, 0x080, 0x10, 0, 1),
PIN_FIELD_BASE(89, 89, 6, 0x080, 0x10, 24, 1),
PIN_FIELD_BASE(90, 90, 6, 0x080, 0x10, 1, 1),
PIN_FIELD_BASE(95, 95, 6, 0x080, 0x10, 15, 1),
PIN_FIELD_BASE(96, 102, 6, 0x080, 0x10, 17, 1),
PIN_FIELD_BASE(103, 106, 6, 0x080, 0x10, 28, 1),
PIN_FIELD_BASE(107, 121, 7, 0x080, 0x10, 0, 1),
PIN_FIELD_BASE(134, 143, 1, 0x080, 0x10, 0, 1),
PIN_FIELD_BASE(144, 149, 1, 0x080, 0x10, 11, 1),
PIN_FIELD_BASE(150, 160, 1, 0x080, 0x10, 18, 1),
PIN_FIELD_BASE(161, 166, 2, 0x080, 0x10, 0, 1),
PIN_FIELD_BASE(167, 176, 4, 0x080, 0x10, 11, 1),
PIN_FIELD_BASE(177, 177, 6, 0x080, 0x10, 10, 1),
PIN_FIELD_BASE(178, 178, 6, 0x080, 0x10, 16, 1),
PIN_FIELD_BASE(179, 179, 6, 0x080, 0x10, 25, 1),
};
static const struct mtk_pin_field_calc mt8183_pin_drv_range[] = {
PINS_FIELD_BASE(0, 3, 6, 0x0A0, 0x10, 12, 3),
PINS_FIELD_BASE(4, 7, 6, 0x0A0, 0x10, 20, 3),
PIN_FIELD_BASE(8, 8, 6, 0x0A0, 0x10, 0, 3),
PINS_FIELD_BASE(9, 10, 6, 0x0B0, 0x10, 16, 3),
PIN_FIELD_BASE(11, 11, 1, 0x0A0, 0x10, 12, 3),
PIN_FIELD_BASE(12, 12, 1, 0x0A0, 0x10, 28, 3),
PINS_FIELD_BASE(13, 16, 2, 0x0A0, 0x10, 8, 3),
PINS_FIELD_BASE(17, 20, 2, 0x0A0, 0x10, 12, 3),
PINS_FIELD_BASE(21, 24, 2, 0x0A0, 0x10, 16, 3),
PINS_FIELD_BASE(25, 28, 2, 0x0A0, 0x10, 20, 3),
PIN_FIELD_BASE(29, 29, 2, 0x0A0, 0x10, 24, 3),
PIN_FIELD_BASE(30, 30, 2, 0x0A0, 0x10, 28, 3),
PINS_FIELD_BASE(31, 31, 2, 0x0B0, 0x10, 0, 3),
PINS_FIELD_BASE(32, 34, 2, 0x0A0, 0x10, 28, 3),
PINS_FIELD_BASE(35, 37, 3, 0x0A0, 0x10, 0, 3),
PINS_FIELD_BASE(38, 40, 3, 0x0A0, 0x10, 4, 3),
PINS_FIELD_BASE(41, 42, 3, 0x0A0, 0x10, 8, 3),
PINS_FIELD_BASE(43, 45, 3, 0x0A0, 0x10, 12, 3),
PINS_FIELD_BASE(46, 47, 3, 0x0A0, 0x10, 16, 3),
PINS_FIELD_BASE(48, 49, 3, 0x0A0, 0x10, 20, 3),
PINS_FIELD_BASE(50, 51, 4, 0x0A0, 0x10, 0, 3),
PINS_FIELD_BASE(52, 57, 4, 0x0A0, 0x10, 4, 3),
PINS_FIELD_BASE(58, 60, 4, 0x0A0, 0x10, 8, 3),
PINS_FIELD_BASE(61, 64, 5, 0x0A0, 0x10, 0, 3),
PINS_FIELD_BASE(65, 66, 5, 0x0A0, 0x10, 4, 3),
PINS_FIELD_BASE(67, 68, 5, 0x0A0, 0x10, 8, 3),
PINS_FIELD_BASE(69, 71, 5, 0x0A0, 0x10, 12, 3),
PINS_FIELD_BASE(72, 76, 5, 0x0A0, 0x10, 16, 3),
PINS_FIELD_BASE(77, 80, 5, 0x0A0, 0x10, 20, 3),
PIN_FIELD_BASE(81, 81, 5, 0x0A0, 0x10, 24, 3),
PINS_FIELD_BASE(82, 83, 5, 0x0A0, 0x10, 28, 3),
PIN_FIELD_BASE(84, 84, 5, 0x0A0, 0x10, 24, 3),
PINS_FIELD_BASE(85, 88, 5, 0x0B0, 0x10, 0, 3),
PIN_FIELD_BASE(89, 89, 6, 0x0B0, 0x10, 12, 3),
PIN_FIELD_BASE(90, 90, 6, 0x0A0, 0x10, 4, 3),
PINS_FIELD_BASE(91, 94, 6, 0x0A0, 0x10, 8, 3),
PINS_FIELD_BASE(95, 96, 6, 0x0A0, 0x10, 24, 3),
PINS_FIELD_BASE(97, 98, 6, 0x0A0, 0x10, 28, 3),
PIN_FIELD_BASE(99, 99, 6, 0x0B0, 0x10, 0, 3),
PIN_FIELD_BASE(100, 100, 6, 0x0B0, 0x10, 4, 3),
PINS_FIELD_BASE(101, 102, 6, 0x0B0, 0x10, 8, 3),
PINS_FIELD_BASE(103, 104, 6, 0x0B0, 0x10, 20, 3),
PINS_FIELD_BASE(105, 106, 6, 0x0B0, 0x10, 24, 3),
PIN_FIELD_BASE(107, 107, 7, 0x0A0, 0x10, 0, 3),
PIN_FIELD_BASE(108, 108, 7, 0x0A0, 0x10, 4, 3),
PIN_FIELD_BASE(109, 109, 7, 0x0A0, 0x10, 8, 3),
PIN_FIELD_BASE(110, 110, 7, 0x0A0, 0x10, 0, 3),
PIN_FIELD_BASE(111, 111, 7, 0x0A0, 0x10, 4, 3),
PIN_FIELD_BASE(112, 112, 7, 0x0A0, 0x10, 8, 3),
PIN_FIELD_BASE(113, 113, 7, 0x0A0, 0x10, 16, 3),
PIN_FIELD_BASE(114, 114, 7, 0x0A0, 0x10, 20, 3),
PIN_FIELD_BASE(115, 115, 7, 0x0A0, 0x10, 24, 3),
PIN_FIELD_BASE(116, 116, 7, 0x0A0, 0x10, 28, 3),
PIN_FIELD_BASE(117, 117, 7, 0x0B0, 0x10, 0, 3),
PIN_FIELD_BASE(118, 118, 7, 0x0B0, 0x10, 4, 3),
PIN_FIELD_BASE(119, 119, 7, 0x0B0, 0x10, 8, 3),
PIN_FIELD_BASE(120, 120, 7, 0x0B0, 0x10, 12, 3),
PIN_FIELD_BASE(121, 121, 7, 0x0B0, 0x10, 16, 3),
PIN_FIELD_BASE(122, 122, 8, 0x0A0, 0x10, 0, 3),
PIN_FIELD_BASE(123, 123, 8, 0x0A0, 0x10, 4, 3),
PIN_FIELD_BASE(124, 124, 8, 0x0A0, 0x10, 8, 3),
PINS_FIELD_BASE(125, 130, 8, 0x0A0, 0x10, 4, 3),
PIN_FIELD_BASE(131, 131, 8, 0x0A0, 0x10, 12, 3),
PIN_FIELD_BASE(132, 132, 8, 0x0A0, 0x10, 4, 3),
PIN_FIELD_BASE(133, 133, 8, 0x0A0, 0x10, 16, 3),
PIN_FIELD_BASE(134, 134, 1, 0x0A0, 0x10, 0, 3),
PIN_FIELD_BASE(135, 135, 1, 0x0A0, 0x10, 4, 3),
PINS_FIELD_BASE(136, 143, 1, 0x0A0, 0x10, 8, 3),
PINS_FIELD_BASE(144, 147, 1, 0x0A0, 0x10, 16, 3),
PIN_FIELD_BASE(148, 148, 1, 0x0A0, 0x10, 20, 3),
PIN_FIELD_BASE(149, 149, 1, 0x0A0, 0x10, 24, 3),
PINS_FIELD_BASE(150, 153, 1, 0x0B0, 0x10, 0, 3),
PIN_FIELD_BASE(154, 154, 1, 0x0B0, 0x10, 4, 3),
PINS_FIELD_BASE(155, 157, 1, 0x0B0, 0x10, 8, 3),
PINS_FIELD_BASE(158, 160, 1, 0x0B0, 0x10, 0, 3),
PINS_FIELD_BASE(161, 164, 2, 0x0A0, 0x10, 0, 3),
PINS_FIELD_BASE(165, 166, 2, 0x0A0, 0x10, 4, 3),
PINS_FIELD_BASE(167, 168, 4, 0x0A0, 0x10, 8, 3),
PIN_FIELD_BASE(169, 169, 4, 0x0A0, 0x10, 12, 3),
PINS_FIELD_BASE(170, 174, 4, 0x0A0, 0x10, 16, 3),
PINS_FIELD_BASE(175, 176, 4, 0x0A0, 0x10, 12, 3),
PINS_FIELD_BASE(177, 179, 6, 0x0A0, 0x10, 16, 3),
};
static const struct mtk_pin_field_calc mt8183_pin_pupd_range[] = {
PIN_FIELD_BASE(29, 29, 2, 0x0C0, 0x10, 2, 1),
PIN_FIELD_BASE(30, 30, 2, 0x0C0, 0x10, 6, 1),
PIN_FIELD_BASE(31, 31, 2, 0x0C0, 0x10, 10, 1),
PIN_FIELD_BASE(32, 32, 2, 0x0C0, 0x10, 14, 1),
PIN_FIELD_BASE(33, 33, 2, 0x0C0, 0x10, 18, 1),
PIN_FIELD_BASE(34, 34, 2, 0x0C0, 0x10, 22, 1),
PIN_FIELD_BASE(35, 35, 3, 0x0C0, 0x10, 2, 1),
PIN_FIELD_BASE(36, 36, 3, 0x0C0, 0x10, 6, 1),
PIN_FIELD_BASE(37, 37, 3, 0x0C0, 0x10, 10, 1),
PIN_FIELD_BASE(38, 38, 3, 0x0C0, 0x10, 14, 1),
PIN_FIELD_BASE(39, 39, 3, 0x0C0, 0x10, 18, 1),
PIN_FIELD_BASE(40, 40, 3, 0x0C0, 0x10, 22, 1),
PIN_FIELD_BASE(41, 41, 3, 0x0C0, 0x10, 26, 1),
PIN_FIELD_BASE(42, 42, 3, 0x0C0, 0x10, 30, 1),
PIN_FIELD_BASE(91, 91, 6, 0x0C0, 0x10, 2, 1),
PIN_FIELD_BASE(92, 92, 6, 0x0C0, 0x10, 6, 1),
PIN_FIELD_BASE(93, 93, 6, 0x0C0, 0x10, 10, 1),
PIN_FIELD_BASE(94, 94, 6, 0x0C0, 0x10, 14, 1),
PIN_FIELD_BASE(122, 122, 8, 0x0C0, 0x10, 2, 1),
PIN_FIELD_BASE(123, 123, 8, 0x0C0, 0x10, 6, 1),
PIN_FIELD_BASE(124, 124, 8, 0x0C0, 0x10, 10, 1),
PIN_FIELD_BASE(125, 125, 8, 0x0C0, 0x10, 14, 1),
PIN_FIELD_BASE(126, 126, 8, 0x0C0, 0x10, 18, 1),
PIN_FIELD_BASE(127, 127, 8, 0x0C0, 0x10, 22, 1),
PIN_FIELD_BASE(128, 128, 8, 0x0C0, 0x10, 26, 1),
PIN_FIELD_BASE(129, 129, 8, 0x0C0, 0x10, 30, 1),
PIN_FIELD_BASE(130, 130, 8, 0x0D0, 0x10, 2, 1),
PIN_FIELD_BASE(131, 131, 8, 0x0D0, 0x10, 6, 1),
PIN_FIELD_BASE(132, 132, 8, 0x0D0, 0x10, 10, 1),
PIN_FIELD_BASE(133, 133, 8, 0x0D0, 0x10, 14, 1),
};
static const struct mtk_pin_field_calc mt8183_pin_r0_range[] = {
PIN_FIELD_BASE(29, 29, 2, 0x0C0, 0x10, 0, 1),
PIN_FIELD_BASE(30, 30, 2, 0x0C0, 0x10, 4, 1),
PIN_FIELD_BASE(31, 31, 2, 0x0C0, 0x10, 8, 1),
PIN_FIELD_BASE(32, 32, 2, 0x0C0, 0x10, 12, 1),
PIN_FIELD_BASE(33, 33, 2, 0x0C0, 0x10, 16, 1),
PIN_FIELD_BASE(34, 34, 2, 0x0C0, 0x10, 20, 1),
PIN_FIELD_BASE(35, 35, 3, 0x0C0, 0x10, 0, 1),
PIN_FIELD_BASE(36, 36, 3, 0x0C0, 0x10, 4, 1),
PIN_FIELD_BASE(37, 37, 3, 0x0C0, 0x10, 8, 1),
PIN_FIELD_BASE(38, 38, 3, 0x0C0, 0x10, 12, 1),
PIN_FIELD_BASE(39, 39, 3, 0x0C0, 0x10, 16, 1),
PIN_FIELD_BASE(40, 40, 3, 0x0C0, 0x10, 20, 1),
PIN_FIELD_BASE(41, 41, 3, 0x0C0, 0x10, 24, 1),
PIN_FIELD_BASE(42, 42, 3, 0x0C0, 0x10, 28, 1),
PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 18, 1),
PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 13, 1),
PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 10, 1),
PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 5, 1),
PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 7, 1),
PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 5, 1),
PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 15, 1),
PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 17, 1),
PIN_FIELD_BASE(91, 91, 6, 0x0C0, 0x10, 0, 1),
PIN_FIELD_BASE(92, 92, 6, 0x0C0, 0x10, 4, 1),
PIN_FIELD_BASE(93, 93, 6, 0x0C0, 0x10, 8, 1),
PIN_FIELD_BASE(94, 94, 6, 0x0C0, 0x10, 12, 1),
PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 20, 1),
PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 10, 1),
PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 22, 1),
PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 12, 1),
PIN_FIELD_BASE(122, 122, 8, 0x0C0, 0x10, 0, 1),
PIN_FIELD_BASE(123, 123, 8, 0x0C0, 0x10, 4, 1),
PIN_FIELD_BASE(124, 124, 8, 0x0C0, 0x10, 8, 1),
PIN_FIELD_BASE(125, 125, 8, 0x0C0, 0x10, 12, 1),
PIN_FIELD_BASE(126, 126, 8, 0x0C0, 0x10, 16, 1),
PIN_FIELD_BASE(127, 127, 8, 0x0C0, 0x10, 20, 1),
PIN_FIELD_BASE(128, 128, 8, 0x0C0, 0x10, 24, 1),
PIN_FIELD_BASE(129, 129, 8, 0x0C0, 0x10, 28, 1),
PIN_FIELD_BASE(130, 130, 8, 0x0D0, 0x10, 0, 1),
PIN_FIELD_BASE(131, 131, 8, 0x0D0, 0x10, 4, 1),
PIN_FIELD_BASE(132, 132, 8, 0x0D0, 0x10, 8, 1),
PIN_FIELD_BASE(133, 133, 8, 0x0D0, 0x10, 12, 1),
};
static const struct mtk_pin_field_calc mt8183_pin_r1_range[] = {
PIN_FIELD_BASE(29, 29, 2, 0x0C0, 0x10, 1, 1),
PIN_FIELD_BASE(30, 30, 2, 0x0C0, 0x10, 5, 1),
PIN_FIELD_BASE(31, 31, 2, 0x0C0, 0x10, 9, 1),
PIN_FIELD_BASE(32, 32, 2, 0x0C0, 0x10, 13, 1),
PIN_FIELD_BASE(33, 33, 2, 0x0C0, 0x10, 17, 1),
PIN_FIELD_BASE(34, 34, 2, 0x0C0, 0x10, 21, 1),
PIN_FIELD_BASE(35, 35, 3, 0x0C0, 0x10, 1, 1),
PIN_FIELD_BASE(36, 36, 3, 0x0C0, 0x10, 5, 1),
PIN_FIELD_BASE(37, 37, 3, 0x0C0, 0x10, 9, 1),
PIN_FIELD_BASE(38, 38, 3, 0x0C0, 0x10, 13, 1),
PIN_FIELD_BASE(39, 39, 3, 0x0C0, 0x10, 17, 1),
PIN_FIELD_BASE(40, 40, 3, 0x0C0, 0x10, 21, 1),
PIN_FIELD_BASE(41, 41, 3, 0x0C0, 0x10, 25, 1),
PIN_FIELD_BASE(42, 42, 3, 0x0C0, 0x10, 29, 1),
PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 19, 1),
PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 14, 1),
PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 11, 1),
PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 6, 1),
PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 8, 1),
PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 6, 1),
PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 16, 1),
PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 18, 1),
PIN_FIELD_BASE(91, 91, 6, 0x0C0, 0x10, 1, 1),
PIN_FIELD_BASE(92, 92, 6, 0x0C0, 0x10, 5, 1),
PIN_FIELD_BASE(93, 93, 6, 0x0C0, 0x10, 9, 1),
PIN_FIELD_BASE(94, 94, 6, 0x0C0, 0x10, 13, 1),
PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 21, 1),
PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 11, 1),
PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 23, 1),
PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 13, 1),
PIN_FIELD_BASE(122, 122, 8, 0x0C0, 0x10, 1, 1),
PIN_FIELD_BASE(123, 123, 8, 0x0C0, 0x10, 5, 1),
PIN_FIELD_BASE(124, 124, 8, 0x0C0, 0x10, 9, 1),
PIN_FIELD_BASE(125, 125, 8, 0x0C0, 0x10, 13, 1),
PIN_FIELD_BASE(126, 126, 8, 0x0C0, 0x10, 17, 1),
PIN_FIELD_BASE(127, 127, 8, 0x0C0, 0x10, 21, 1),
PIN_FIELD_BASE(128, 128, 8, 0x0C0, 0x10, 25, 1),
PIN_FIELD_BASE(129, 129, 8, 0x0C0, 0x10, 29, 1),
PIN_FIELD_BASE(130, 130, 8, 0x0D0, 0x10, 1, 1),
PIN_FIELD_BASE(131, 131, 8, 0x0D0, 0x10, 5, 1),
PIN_FIELD_BASE(132, 132, 8, 0x0D0, 0x10, 9, 1),
PIN_FIELD_BASE(133, 133, 8, 0x0D0, 0x10, 13, 1),
};
static const struct mtk_pin_reg_calc mt8183_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8183_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8183_pin_dir_range),
[PINCTRL_PIN_REG_DI] = MTK_RANGE(mt8183_pin_di_range),
[PINCTRL_PIN_REG_DO] = MTK_RANGE(mt8183_pin_do_range),
[PINCTRL_PIN_REG_SMT] = MTK_RANGE(mt8183_pin_smt_range),
[PINCTRL_PIN_REG_IES] = MTK_RANGE(mt8183_pin_ies_range),
[PINCTRL_PIN_REG_PULLEN] = MTK_RANGE(mt8183_pin_pullen_range),
[PINCTRL_PIN_REG_PULLSEL] = MTK_RANGE(mt8183_pin_pullsel_range),
[PINCTRL_PIN_REG_DRV] = MTK_RANGE(mt8183_pin_drv_range),
[PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt8183_pin_pupd_range),
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt8183_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt8183_pin_r1_range),
};
static const char * const mt8183_pinctrl_register_base_names[] = {
"iocfg0", "iocfg1", "iocfg2", "iocfg3", "iocfg4", "iocfg5",
"iocfg6", "iocfg7", "iocfg8",
};
static const struct mtk_eint_hw mt8183_eint_hw = {
.port_mask = 7,
.ports = 6,
.ap_num = 212,
.db_cnt = 13,
};
static const struct mtk_pin_soc mt8183_data = {
.reg_cal = mt8183_reg_cals,
.pins = mtk_pins_mt8183,
.npins = ARRAY_SIZE(mtk_pins_mt8183),
.ngrps = ARRAY_SIZE(mtk_pins_mt8183),
.eint_hw = &mt8183_eint_hw,
.gpio_m = 0,
.base_names = mt8183_pinctrl_register_base_names,
.nbase_names = ARRAY_SIZE(mt8183_pinctrl_register_base_names),
.bias_set_combo = mtk_pinconf_bias_set_combo,
.bias_get_combo = mtk_pinconf_bias_get_combo,
.drive_set = mtk_pinconf_drive_set_rev1,
.drive_get = mtk_pinconf_drive_get_rev1,
.adv_pull_get = mtk_pinconf_adv_pull_get,
.adv_pull_set = mtk_pinconf_adv_pull_set,
};
static const struct of_device_id mt8183_pinctrl_of_match[] = {
{ .compatible = "mediatek,mt8183-pinctrl", },
{ }
};
static int mt8183_pinctrl_probe(struct platform_device *pdev)
{
return mtk_paris_pinctrl_probe(pdev, &mt8183_data);
}
static struct platform_driver mt8183_pinctrl_driver = {
.driver = {
.name = "mt8183-pinctrl",
.of_match_table = mt8183_pinctrl_of_match,
},
.probe = mt8183_pinctrl_probe,
};
static int __init mt8183_pinctrl_init(void)
{
return platform_driver_register(&mt8183_pinctrl_driver);
}
arch_initcall(mt8183_pinctrl_init);
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,340 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2018 MediaTek Inc.
*
* Author: Sean Wang <sean.wang@mediatek.com>
*
*/
#ifndef __PINCTRL_MTK_COMMON_V2_H
#define __PINCTRL_MTK_COMMON_V2_H
#include <linux/gpio/driver.h>
#define MTK_INPUT 0
#define MTK_OUTPUT 1
#define MTK_DISABLE 0
#define MTK_ENABLE 1
#define MTK_PULLDOWN 0
#define MTK_PULLUP 1
#define EINT_NA U16_MAX
#define NO_EINT_SUPPORT EINT_NA
#define PIN_FIELD_CALC(_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, \
_s_bit, _x_bits, _sz_reg, _fixed) { \
.s_pin = _s_pin, \
.e_pin = _e_pin, \
.i_base = _i_base, \
.s_addr = _s_addr, \
.x_addrs = _x_addrs, \
.s_bit = _s_bit, \
.x_bits = _x_bits, \
.sz_reg = _sz_reg, \
.fixed = _fixed, \
}
#define PIN_FIELD(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, _x_bits) \
PIN_FIELD_CALC(_s_pin, _e_pin, 0, _s_addr, _x_addrs, _s_bit, \
_x_bits, 32, 0)
#define PINS_FIELD(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, _x_bits) \
PIN_FIELD_CALC(_s_pin, _e_pin, 0, _s_addr, _x_addrs, _s_bit, \
_x_bits, 32, 1)
/* List these attributes which could be modified for the pin */
enum {
PINCTRL_PIN_REG_MODE,
PINCTRL_PIN_REG_DIR,
PINCTRL_PIN_REG_DI,
PINCTRL_PIN_REG_DO,
PINCTRL_PIN_REG_SR,
PINCTRL_PIN_REG_SMT,
PINCTRL_PIN_REG_PD,
PINCTRL_PIN_REG_PU,
PINCTRL_PIN_REG_E4,
PINCTRL_PIN_REG_E8,
PINCTRL_PIN_REG_TDSEL,
PINCTRL_PIN_REG_RDSEL,
PINCTRL_PIN_REG_DRV,
PINCTRL_PIN_REG_PUPD,
PINCTRL_PIN_REG_R0,
PINCTRL_PIN_REG_R1,
PINCTRL_PIN_REG_IES,
PINCTRL_PIN_REG_PULLEN,
PINCTRL_PIN_REG_PULLSEL,
PINCTRL_PIN_REG_DRV_EH,
PINCTRL_PIN_REG_DRV_EN,
PINCTRL_PIN_REG_DRV_E0,
PINCTRL_PIN_REG_DRV_E1,
PINCTRL_PIN_REG_MAX,
};
/* Group the pins by the driving current */
enum {
DRV_FIXED,
DRV_GRP0,
DRV_GRP1,
DRV_GRP2,
DRV_GRP3,
DRV_GRP4,
DRV_GRP_MAX,
};
static const char * const mtk_default_register_base_names[] = {
"base",
};
/* struct mtk_pin_field - the structure that holds the information of the field
* used to describe the attribute for the pin
* @base: the index pointing to the entry in base address list
* @offset: the register offset relative to the base address
* @mask: the mask used to filter out the field from the register
* @bitpos: the start bit relative to the register
* @next: the indication that the field would be extended to the
next register
*/
struct mtk_pin_field {
u8 index;
u32 offset;
u32 mask;
u8 bitpos;
u8 next;
};
/* struct mtk_pin_field_calc - the structure that holds the range providing
* the guide used to look up the relevant field
* @s_pin: the start pin within the range
* @e_pin: the end pin within the range
* @i_base: the index pointing to the entry in base address list
* @s_addr: the start address for the range
* @x_addrs: the address distance between two consecutive registers
* within the range
* @s_bit: the start bit for the first register within the range
* @x_bits: the bit distance between two consecutive pins within
* the range
* @sz_reg: the size of bits in a register
* @fixed: the consecutive pins share the same bits with the 1st
* pin
*/
struct mtk_pin_field_calc {
u16 s_pin;
u16 e_pin;
u8 i_base;
u32 s_addr;
u8 x_addrs;
u8 s_bit;
u8 x_bits;
u8 sz_reg;
u8 fixed;
};
/* struct mtk_pin_reg_calc - the structure that holds all ranges used to
* determine which register the pin would make use of
* for certain pin attribute.
* @range: the start address for the range
* @nranges: the number of items in the range
*/
struct mtk_pin_reg_calc {
const struct mtk_pin_field_calc *range;
unsigned int nranges;
};
/**
* struct mtk_func_desc - the structure that providing information
* all the funcs for this pin
* @name: the name of function
* @muxval: the mux to the function
*/
struct mtk_func_desc {
const char *name;
u8 muxval;
};
/**
* struct mtk_eint_desc - the structure that providing information
* for eint data per pin
* @eint_m: the eint mux for this pin
* @eitn_n: the eint number for this pin
*/
struct mtk_eint_desc {
u16 eint_m;
u16 eint_n;
};
/**
* struct mtk_eh_pin_pinmux - entry recording (pin, pinmux) whose
* eh can be enabled
* @pin: pin numbereint mux for this pin
* @pinmux: pinmux number
*/
struct mtk_eh_pin_pinmux {
u16 pin;
u16 pinmux;
};
/**
* struct mtk_pin_desc - the structure that providing information
* for each pin of chips
* @number: unique pin number from the global pin number space
* @name: name for this pin
* @eint: the eint data for this pin
* @drv_n: the index with the driving group
* @funcs: all available functions for this pins (only used in
* those drivers compatible to pinctrl-mtk-common.c-like
* ones)
*/
struct mtk_pin_desc {
unsigned int number;
const char *name;
struct mtk_eint_desc eint;
u8 drv_n;
struct mtk_func_desc *funcs;
};
struct mtk_pinctrl_group {
const char *name;
unsigned long config;
unsigned pin;
};
struct mtk_pinctrl;
/* struct mtk_pin_soc - the structure that holds SoC-specific data */
struct mtk_pin_soc {
const struct mtk_pin_reg_calc *reg_cal;
const struct mtk_pin_desc *pins;
unsigned int npins;
const struct group_desc *grps;
unsigned int ngrps;
const struct function_desc *funcs;
unsigned int nfuncs;
const struct mtk_eint_regs *eint_regs;
const struct mtk_eint_hw *eint_hw;
/* Specific parameters per SoC */
u8 gpio_m;
bool ies_present;
bool race_free_access;
const char * const *base_names;
unsigned int nbase_names;
const struct mtk_eh_pin_pinmux *eh_pin_pinmux;
/* Specific pinconfig operations */
int (*bias_disable_set)(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc);
int (*bias_disable_get)(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, int *res);
int (*bias_set)(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, bool pullup);
int (*bias_get)(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, bool pullup, int *res);
int (*bias_set_combo)(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, u32 pullup, u32 arg);
int (*bias_get_combo)(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, u32 *pullup, u32 *arg);
int (*drive_set)(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, u32 arg);
int (*drive_get)(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, int *val);
int (*adv_pull_set)(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, bool pullup,
u32 arg);
int (*adv_pull_get)(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, bool pullup,
u32 *val);
int (*adv_drive_set)(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, u32 arg);
int (*adv_drive_get)(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, u32 *val);
/* Specific driver data */
void *driver_data;
};
struct mtk_pinctrl {
struct pinctrl_dev *pctrl;
void __iomem **base;
u8 nbase;
struct device *dev;
struct gpio_chip chip;
const struct mtk_pin_soc *soc;
struct mtk_eint *eint;
struct mtk_pinctrl_group *groups;
const char **grp_names;
};
void mtk_rmw(struct mtk_pinctrl *pctl, u8 i, u32 reg, u32 mask, u32 set);
int mtk_hw_set_value(struct mtk_pinctrl *hw, const struct mtk_pin_desc *desc,
int field, int value);
int mtk_hw_get_value(struct mtk_pinctrl *hw, const struct mtk_pin_desc *desc,
int field, int *value);
void mtk_eh_ctrl(struct mtk_pinctrl *hw, const struct mtk_pin_desc *desc,
u16 mode);
int mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev);
extern const struct dev_pm_ops mtk_eint_pm_ops_v2;
int mtk_pinconf_bias_disable_set(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc);
int mtk_pinconf_bias_disable_get(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, int *res);
int mtk_pinconf_bias_set(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, bool pullup);
int mtk_pinconf_bias_get(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, bool pullup,
int *res);
int mtk_pinconf_bias_disable_set_rev1(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc);
int mtk_pinconf_bias_disable_get_rev1(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc,
int *res);
int mtk_pinconf_bias_set_rev1(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, bool pullup);
int mtk_pinconf_bias_get_rev1(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, bool pullup,
int *res);
int mtk_pinconf_drive_set(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, u32 arg);
int mtk_pinconf_drive_get(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, int *val);
int mtk_pinconf_drive_set_rev1(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, u32 arg);
int mtk_pinconf_drive_get_rev1(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, int *val);
int mtk_pinconf_drive_set_raw(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, u32 arg);
int mtk_pinconf_drive_get_raw(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, int *val);
int mtk_pinconf_adv_pull_set(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, bool pullup,
u32 arg);
int mtk_pinconf_adv_pull_get(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, bool pullup,
u32 *val);
int mtk_pinconf_adv_drive_set(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, u32 arg);
int mtk_pinconf_adv_drive_get(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc, u32 *val);
int mtk_pinconf_bias_set_combo(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc,
u32 pullup, u32 enable);
int mtk_pinconf_bias_get_combo(struct mtk_pinctrl *hw,
const struct mtk_pin_desc *desc,
u32 *pullup, u32 *enable);
bool mtk_is_virt_gpio(struct mtk_pinctrl *hw, unsigned int gpio_n);
#endif /* __PINCTRL_MTK_COMMON_V2_H */
@@ -0,0 +1,431 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2020 MediaTek Inc.
*
* Author: Light Hsieh <light.hsieh@mediatek.com>
*
*/
#include <linux/module.h>
#include <dt-bindings/pinctrl/mt65xx.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <../../gpio/gpiolib.h>
#include <asm-generic/gpio.h>
#include <linux/delay.h>
#include "pinctrl-paris.h"
#define MTK_PINCTRL_DEV_NAME "pinctrl_paris"
#define PULL_DELAY 50 /* in ms */
#define FUN_3STATE "gpio_get_value_tristate"
static const char *pinctrl_paris_modname = MTK_PINCTRL_DEV_NAME;
static struct mtk_pinctrl *g_hw;
static void mtk_gpio_find_mtk_pinctrl_dev(void)
{
struct gpio_desc *gdesc;
unsigned int pin = ARCH_NR_GPIOS - 1;
do {
gdesc = gpio_to_desc(pin);
if (!gdesc)
break;
if (!strncmp(pinctrl_paris_modname,
gdesc->gdev->chip->label,
strlen(pinctrl_paris_modname))) {
g_hw = gpiochip_get_data(gdesc->gdev->chip);
return;
}
pin = (pin + 1) - gdesc->gdev->chip->base;
} while (pin > 0);
}
int gpio_get_tristate_input(unsigned int pin)
{
struct mtk_pinctrl *hw = NULL;
const struct mtk_pin_desc *desc;
int val, val_up, val_down, ret, pullup, pullen, pull_type;
if (!g_hw)
mtk_gpio_find_mtk_pinctrl_dev();
if (!g_hw)
return -ENOTSUPP;
hw = g_hw;
if (!hw->soc) {
pr_notice("invalid gpio chip\n");
return -EINVAL;
}
if (!hw->soc->bias_set_combo) {
pr_notice("not supported gpio chip\n");
return -ENOTSUPP;
}
if (pin < hw->chip.base) {
pr_notice(FUN_3STATE ": please use virtual pin number\n");
return -EINVAL;
}
pin -= hw->chip.base;
if (pin >= hw->soc->npins) {
pr_notice(FUN_3STATE ": invalid pin number: %u\n",
pin);
return -EINVAL;
}
desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];
ret = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_MODE, &val);
if (ret)
return ret;
if (val != 0) {
pr_notice(FUN_3STATE ":GPIO%d in mode %d, not GPIO mode\n",
pin, val);
return -EINVAL;
}
ret = hw->soc->bias_get_combo(hw, desc, &pullup, &pullen);
if (ret)
return ret;
if (pullen == 0 || pullen == MTK_PUPD_SET_R1R0_00) {
pr_notice(FUN_3STATE ":GPIO%d not pullen, skip floating test\n",
pin);
return gpio_get_value(pin+hw->chip.base);
}
if (pullen > MTK_PUPD_SET_R1R0_00)
pull_type = 1;
else
pull_type = 0;
/* set pullsel as pull-up and get input value */
pr_notice(FUN_3STATE ":pull up GPIO%d\n", pin);
ret = hw->soc->bias_set_combo(hw, desc, 1,
(pull_type ? MTK_PUPD_SET_R1R0_11 : MTK_ENABLE));
if (ret)
goto out;
mdelay(PULL_DELAY);
val_up = gpio_get_value(pin+hw->chip.base);
pr_notice(FUN_3STATE ":GPIO%d input %d\n", pin, val_up);
/* set pullsel as pull-down and get input value */
pr_notice(FUN_3STATE ":pull down GPIO%d\n", pin);
ret = hw->soc->bias_set_combo(hw, desc, 0,
(pull_type ? MTK_PUPD_SET_R1R0_11 : MTK_ENABLE));
if (ret)
goto out;
mdelay(PULL_DELAY);
val_down = gpio_get_value(pin+hw->chip.base);
pr_notice(FUN_3STATE ":GPIO%d input %d\n", pin, val_down);
if (val_up && val_down)
ret = 1;
else if (!val_up && !val_down)
ret = 0;
else if (val_up && !val_down)
ret = 2;
else {
pr_notice(FUN_3STATE ":GPIO%d pull HW is abnormal\n", pin);
ret = -EINVAL;
}
out:
/* restore pullsel */
hw->soc->bias_set_combo(hw, desc, pullup, pullen);
return ret;
}
static int mtk_hw_set_value_wrap(struct mtk_pinctrl *hw, unsigned int gpio,
int value, int field)
{
const struct mtk_pin_desc *desc;
if (gpio > hw->soc->npins)
return -EINVAL;
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
return mtk_hw_set_value(hw, desc, field, value);
}
#define mtk_pctrl_set_pinmux(hw, gpio, val) \
mtk_hw_set_value_wrap(hw, gpio, val, PINCTRL_PIN_REG_MODE)
/* MTK HW use 0 as input, 1 for output
* This interface is for set direct register value,
* so don't reverse
*/
#define mtk_pctrl_set_direction(hw, gpio, val) \
mtk_hw_set_value_wrap(hw, gpio, val, PINCTRL_PIN_REG_DIR)
#define mtk_pctrl_set_out(hw, gpio, val) \
mtk_hw_set_value_wrap(hw, gpio, val, PINCTRL_PIN_REG_DO)
#define mtk_pctrl_set_smt(hw, gpio, val) \
mtk_hw_set_value_wrap(hw, gpio, val, PINCTRL_PIN_REG_SMT)
#define mtk_pctrl_set_ies(hw, gpio, val) \
mtk_hw_set_value_wrap(hw, gpio, val, PINCTRL_PIN_REG_IES)
static ssize_t mtk_gpio_show_pin(struct device *dev,
struct device_attribute *attr, char *buf)
{
int len = 0;
unsigned int bufLen = PAGE_SIZE;
unsigned int i = 0;
struct mtk_pinctrl *hw = dev_get_drvdata(dev);
struct gpio_chip *chip;
if (!hw || !buf) {
pr_debug("[pinctrl] Err: NULL pointer!\n");
return len;
}
chip = &hw->chip;
len += snprintf(buf+len, bufLen-len,
"pins base: %d\n", chip->base);
len += snprintf(buf+len, bufLen-len,
"PIN: (MODE)(DIR)(DOUT)(DIN)(DRIVE)(SMT)(IES)(PULL_EN)(PULL_SEL)(R1 R0)\n");
for (i = 0; i < chip->ngpio; i++) {
if (len > (bufLen - 96)) {
pr_debug("[pinctrl]err:%d exceed to max size %d\n",
len, (bufLen - 96));
break;
}
len += mtk_pctrl_show_one_pin(hw, i, buf + len, bufLen - len);
}
return len;
}
void gpio_dump_regs_range(int start, int end)
{
struct gpio_chip *chip = NULL;
struct mtk_pinctrl *hw;
char buf[96];
int i;
if (!g_hw)
mtk_gpio_find_mtk_pinctrl_dev();
if (!g_hw)
return;
hw = g_hw;
chip = &hw->chip;
if (start < 0) {
start = 0;
end = chip->ngpio - 1;
}
if (end < 0)
end = chip->ngpio - 1;
if (end > chip->ngpio - 1)
end = chip->ngpio - 1;
pr_notice("PIN: (MODE)(DIR)(DOUT)(DIN)(DRIVE)(SMT)(IES)(PULL_EN)(PULL_SEL)(R1 R0)\n");
for (i = start; i < end; i++) {
(void)mtk_pctrl_show_one_pin(hw, i, buf, 96);
pr_notice("%s", buf);
}
}
EXPORT_SYMBOL_GPL(gpio_dump_regs_range);
void gpio_dump_regs(void)
{
gpio_dump_regs_range(-1, -1);
}
static ssize_t mtk_gpio_store_pin(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
int i, gpio, val, val2, pullup = 0, pullen = 0;
int vals[12];
char attrs[12];
struct mtk_pinctrl *hw = dev_get_drvdata(dev);
const struct mtk_pin_desc *desc;
struct gpio_chip *chip;
int r1r0_en[4] = {MTK_PUPD_SET_R1R0_00, MTK_PUPD_SET_R1R0_01,
MTK_PUPD_SET_R1R0_10, MTK_PUPD_SET_R1R0_11};
if (!hw || !hw->soc) {
pr_notice("[pinctrl]cannot find %s device\n",
pinctrl_paris_modname);
return count;
}
chip = &hw->chip;
if (!strncmp(buf, "mode", 4)
&& (sscanf(buf+4, "%d %d", &gpio, &val) == 2)) {
mtk_pctrl_set_pinmux(hw, gpio, val);
} else if (!strncmp(buf, "dir", 3)
&& (sscanf(buf+3, "%d %d", &gpio, &val) == 2)) {
mtk_pctrl_set_direction(hw, gpio, val);
} else if (!strncmp(buf, "out", 3)
&& (sscanf(buf+3, "%d %d", &gpio, &val) == 2)) {
mtk_pctrl_set_direction(hw, gpio, 1);
/* mtk_gpio_set(chip, gpio, val); */
mtk_pctrl_set_out(hw, gpio, val);
} else if (!strncmp(buf, "pullen", 6)
&& (sscanf(buf+6, "%d %d", &gpio, &val) == 2)) {
if (gpio < 0 || gpio > hw->soc->npins) {
pr_notice("invalid pin number\n");
goto out;
}
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
if (!hw->soc->bias_get_combo || !hw->soc->bias_set_combo)
goto no_bias_combo_out;
hw->soc->bias_get_combo(hw, desc, &pullup, &pullen);
if (pullen < MTK_PUPD_SET_R1R0_00) {
pullen = !!val;
} else {
if (val < 0)
val = 0;
else if (val > 3)
val = 3;
pullen = r1r0_en[val];
}
hw->soc->bias_set_combo(hw, desc, pullup, pullen);
} else if ((!strncmp(buf, "pullsel", 7))
&& (sscanf(buf+7, "%d %d", &gpio, &val) == 2)) {
if (gpio < 0 || gpio > hw->soc->npins) {
pr_notice("invalid pin number\n");
goto out;
}
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
if (!hw->soc->bias_get_combo || !hw->soc->bias_set_combo)
goto no_bias_combo_out;
hw->soc->bias_get_combo(hw, desc, &pullup, &pullen);
hw->soc->bias_set_combo(hw, desc, !!val, pullen);
} else if ((!strncmp(buf, "ies", 3))
&& (sscanf(buf+3, "%d %d", &gpio, &val) == 2)) {
mtk_pctrl_set_ies(hw, gpio, val);
} else if ((!strncmp(buf, "smt", 3))
&& (sscanf(buf+3, "%d %d", &gpio, &val) == 2)) {
mtk_pctrl_set_smt(hw, gpio, val);
} else if ((!strncmp(buf, "driving", 7))
&& (sscanf(buf+7, "%d %d", &gpio, &val) == 2)) {
if (gpio < 0 || gpio > hw->soc->npins) {
pr_notice("invalid pin number\n");
goto out;
}
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
hw->soc->drive_set(hw, desc, val);
} else if ((!strncmp(buf, "r1r0", 4))
&& (sscanf(buf+4, "%d %d %d", &gpio, &val, &val2) == 3)) {
if (gpio < 0 || gpio > hw->soc->npins) {
pr_notice("invalid pin number\n");
goto out;
}
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
if (!hw->soc->bias_get_combo || !hw->soc->bias_set_combo)
goto no_bias_combo_out;
hw->soc->bias_get_combo(hw, desc, &pullup, &pullen);
pullen = r1r0_en[(((!!val) << 1) + !!val2)];
hw->soc->bias_set_combo(hw, desc, pullup, pullen);
} else if (!strncmp(buf, "set", 3)) {
val = sscanf(buf+3, "%d %c%c%c%c%c%c%c%c%c%c %c%c", &gpio,
&attrs[0], &attrs[1], &attrs[2], &attrs[3],
&attrs[4], &attrs[5], &attrs[6], &attrs[7],
&attrs[8], &attrs[9], &attrs[10], &attrs[11]);
if (val <= 0 || val > 13) {
pr_notice("invalid input count %d\n", val);
goto out;
}
if (!hw->soc->bias_get_combo || !hw->soc->bias_set_combo)
goto no_bias_combo_out;
for (i = 0; i < ARRAY_SIZE(attrs); i++) {
if ((attrs[i] >= '0') && (attrs[i] <= '9'))
vals[i] = attrs[i] - '0';
else
vals[i] = 0;
}
if (gpio < 0) {
pr_notice("invalid pin number\n");
goto out;
}
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
/* MODE */
mtk_pctrl_set_pinmux(hw, gpio, vals[0]);
/* DIR */
mtk_pctrl_set_direction(hw, gpio, !!vals[1]);
/* DOUT */
if (vals[1])
/*mtk_gpio_set(chip, gpio, !!vals[2]); */
mtk_pctrl_set_out(hw, gpio, !!vals[2]);
/* DRIVING */
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
hw->soc->drive_set(hw, desc, vals[4]*10 + vals[5]);
/* SMT */
mtk_pctrl_set_smt(hw, gpio, vals[6]);
/* IES */
mtk_pctrl_set_ies(hw, gpio, vals[7]);
/* PULL */
hw->soc->bias_get_combo(hw, desc, &pullup, &pullen);
if (pullen < MTK_PUPD_SET_R1R0_00) {
hw->soc->bias_set_combo(hw, desc, !!vals[9],
!!vals[8]);
} else {
pullen = r1r0_en[(((!!vals[10]) << 1) + !!vals[11])];
hw->soc->bias_set_combo(hw, desc, !!vals[9],
pullen);
}
}
out:
return count;
no_bias_combo_out:
pr_notice("[pinctrl]bias_set_combo/bias_get_combo not supported\n");
return count;
}
static DEVICE_ATTR(mt_gpio, 0444, mtk_gpio_show_pin, mtk_gpio_store_pin);
static int mtk_gpio_create_attr(void)
{
struct mtk_pinctrl *hw = NULL;
struct gpio_desc *gdesc;
unsigned int pin = ARCH_NR_GPIOS - 1;
int err = 0;
do {
gdesc = gpio_to_desc(pin);
if (!gdesc)
break;
if (!strncmp(pinctrl_paris_modname,
gdesc->gdev->chip->label,
strlen(pinctrl_paris_modname))) {
hw = gpiochip_get_data(gdesc->gdev->chip);
if (!hw || !hw->soc || !hw->dev) {
pr_notice("invalid gpio chip\n");
return -EINVAL;
}
err = device_create_file(hw->dev, &dev_attr_mt_gpio);
if (err) {
pr_notice("[pinctrl]error create mtk_gpio\n");
break;
}
}
pin = (pin + 1) - gdesc->gdev->chip->base;
} while (pin > 0);
return err;
}
static int __init pinctrl_mtk_debug_v2_init(void)
{
return mtk_gpio_create_attr();
}
late_initcall(pinctrl_mtk_debug_v2_init);
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("MediaTek Pinctrl DEBUG Driver");
@@ -0,0 +1,14 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2019 MediaTek Inc.
*
* Author: Light Hsieh <light.hsieh@mediatek.com>
*
*/
#ifndef __PINCTRL_MTK_COMMON_V2_DEBUG_H
#define __PINCTRL_MTK_COMMON_V2_DEBUG_H
int gpio_get_tristate_input(unsigned int pin);
#endif /* __PINCTRL_MTK_COMMON_V2_DEBUG_H */
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,296 @@
/*
* Copyright (c) 2014 MediaTek Inc.
* Author: Hongzhou.Yang <hongzhou.yang@mediatek.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __PINCTRL_MTK_COMMON_H
#define __PINCTRL_MTK_COMMON_H
#include <linux/pinctrl/pinctrl.h>
#include <linux/regmap.h>
#include <linux/pinctrl/pinconf-generic.h>
#include "mtk-eint.h"
#define NO_EINT_SUPPORT 255
#define MT_EDGE_SENSITIVE 0
#define MT_LEVEL_SENSITIVE 1
#define EINT_DBNC_SET_DBNC_BITS 4
#define EINT_DBNC_RST_BIT (0x1 << 1)
#define EINT_DBNC_SET_EN (0x1 << 0)
#define MTK_PINCTRL_NOT_SUPPORT (0xffff)
struct mtk_desc_function {
const char *name;
unsigned char muxval;
};
struct mtk_desc_eint {
unsigned char eintmux;
unsigned char eintnum;
};
struct mtk_desc_pin {
struct pinctrl_pin_desc pin;
const struct mtk_desc_eint eint;
const struct mtk_desc_function *functions;
};
#define MTK_PIN(_pin, _pad, _chip, _eint, ...) \
{ \
.pin = _pin, \
.eint = _eint, \
.functions = (struct mtk_desc_function[]){ \
__VA_ARGS__, { } }, \
}
#define MTK_EINT_FUNCTION(_eintmux, _eintnum) \
{ \
.eintmux = _eintmux, \
.eintnum = _eintnum, \
}
#define MTK_FUNCTION(_val, _name) \
{ \
.muxval = _val, \
.name = _name, \
}
#define SET_ADDR(x, y) (x + (y->devdata->port_align))
#define CLR_ADDR(x, y) (x + (y->devdata->port_align << 1))
struct mtk_pinctrl_group {
const char *name;
unsigned long config;
unsigned pin;
};
/**
* struct mtk_drv_group_desc - Provide driving group data.
* @max_drv: The maximum current of this group.
* @min_drv: The minimum current of this group.
* @low_bit: The lowest bit of this group.
* @high_bit: The highest bit of this group.
* @step: The step current of this group.
*/
struct mtk_drv_group_desc {
unsigned char min_drv;
unsigned char max_drv;
unsigned char low_bit;
unsigned char high_bit;
unsigned char step;
};
#define MTK_DRV_GRP(_min, _max, _low, _high, _step) \
{ \
.min_drv = _min, \
.max_drv = _max, \
.low_bit = _low, \
.high_bit = _high, \
.step = _step, \
}
/**
* struct mtk_pin_drv_grp - Provide each pin driving info.
* @pin: The pin number.
* @offset: The offset of driving register for this pin.
* @bit: The bit of driving register for this pin.
* @grp: The group for this pin belongs to.
*/
struct mtk_pin_drv_grp {
unsigned short pin;
unsigned short offset;
unsigned char bit;
unsigned char grp;
};
#define MTK_PIN_DRV_GRP(_pin, _offset, _bit, _grp) \
{ \
.pin = _pin, \
.offset = _offset, \
.bit = _bit, \
.grp = _grp, \
}
/**
* struct mtk_pin_spec_pupd_set_samereg
* - For special pins' pull up/down setting which resides in same register
* @pin: The pin number.
* @offset: The offset of special pull up/down setting register.
* @pupd_bit: The pull up/down bit in this register.
* @r0_bit: The r0 bit of pull resistor.
* @r1_bit: The r1 bit of pull resistor.
*/
struct mtk_pin_spec_pupd_set_samereg {
unsigned short pin;
unsigned short offset;
unsigned char pupd_bit;
unsigned char r1_bit;
unsigned char r0_bit;
};
#define MTK_PIN_PUPD_SPEC_SR(_pin, _offset, _pupd, _r1, _r0) \
{ \
.pin = _pin, \
.offset = _offset, \
.pupd_bit = _pupd, \
.r1_bit = _r1, \
.r0_bit = _r0, \
}
/**
* struct mtk_pin_ies_set - For special pins' ies and smt setting.
* @start: The start pin number of those special pins.
* @end: The end pin number of those special pins.
* @offset: The offset of special setting register.
* @bit: The bit of special setting register.
*/
struct mtk_pin_ies_smt_set {
unsigned short start;
unsigned short end;
unsigned short offset;
unsigned char bit;
};
#define MTK_PIN_IES_SMT_SPEC(_start, _end, _offset, _bit) \
{ \
.start = _start, \
.end = _end, \
.bit = _bit, \
.offset = _offset, \
}
struct mtk_eint_offsets {
const char *name;
unsigned int stat;
unsigned int ack;
unsigned int mask;
unsigned int mask_set;
unsigned int mask_clr;
unsigned int sens;
unsigned int sens_set;
unsigned int sens_clr;
unsigned int soft;
unsigned int soft_set;
unsigned int soft_clr;
unsigned int pol;
unsigned int pol_set;
unsigned int pol_clr;
unsigned int dom_en;
unsigned int dbnc_ctrl;
unsigned int dbnc_set;
unsigned int dbnc_clr;
u8 port_mask;
u8 ports;
};
/**
* struct mtk_pinctrl_devdata - Provide HW GPIO related data.
* @pins: An array describing all pins the pin controller affects.
* @npins: The number of entries in @pins.
*
* @grp_desc: The driving group info.
* @pin_drv_grp: The driving group for all pins.
* @spec_pull_set: Each SoC may have special pins for pull up/down setting,
* these pins' pull setting are very different, they have separate pull
* up/down bit, R0 and R1 resistor bit, so they need special pull setting.
* If special setting is success, this should return 0, otherwise it should
* return non-zero value.
* @spec_ies_smt_set: Some pins are irregular, their input enable and smt
* control register are discontinuous, but they are mapping together. That
* means when user set smt, input enable is set at the same time. So they
* also need special control. If special control is success, this should
* return 0, otherwise return non-zero value.
* @spec_pinmux_set: In some cases, there are two pinmux functions share
* the same value in the same segment of pinmux control register. If user
* want to use one of the two functions, they need an extra bit setting to
* select the right one.
* @spec_dir_set: In very few SoCs, direction control registers are not
* arranged continuously, they may be cut to parts. So they need special
* dir setting.
* @dir_offset: The direction register offset.
* @pullen_offset: The pull-up/pull-down enable register offset.
* @pinmux_offset: The pinmux register offset.
*
* @type1_start: Some chips have two base addresses for pull select register,
* that means some pins use the first address and others use the second. This
* member record the start of pin number to use the second address.
* @type1_end: The end of pin number to use the second address.
*
* @port_shf: The shift between two registers.
* @port_mask: The mask of register.
* @port_align: Provide clear register and set register step.
*/
struct mtk_pinctrl_devdata {
const struct mtk_desc_pin *pins;
unsigned int npins;
const struct mtk_drv_group_desc *grp_desc;
unsigned int n_grp_cls;
const struct mtk_pin_drv_grp *pin_drv_grp;
unsigned int n_pin_drv_grps;
int (*spec_pull_set)(struct regmap *reg, unsigned int pin,
unsigned char align, bool isup, unsigned int arg);
int (*spec_ies_smt_set)(struct regmap *reg, unsigned int pin,
unsigned char align, int value, enum pin_config_param arg);
void (*spec_pinmux_set)(struct regmap *reg, unsigned int pin,
unsigned int mode);
void (*spec_dir_set)(unsigned int *reg_addr, unsigned int pin);
unsigned int dir_offset;
unsigned int ies_offset;
unsigned int smt_offset;
unsigned int pullen_offset;
unsigned int pullsel_offset;
unsigned int drv_offset;
unsigned int dout_offset;
unsigned int din_offset;
unsigned int pinmux_offset;
unsigned short type1_start;
unsigned short type1_end;
unsigned char port_shf;
unsigned char port_mask;
unsigned char port_align;
struct mtk_eint_hw eint_hw;
struct mtk_eint_regs *eint_regs;
};
struct mtk_pinctrl {
struct regmap *regmap1;
struct regmap *regmap2;
struct pinctrl_desc pctl_desc;
struct device *dev;
struct gpio_chip *chip;
struct mtk_pinctrl_group *groups;
unsigned ngroups;
const char **grp_names;
struct pinctrl_dev *pctl_dev;
const struct mtk_pinctrl_devdata *devdata;
struct mtk_eint *eint;
};
int mtk_pctrl_init(struct platform_device *pdev,
const struct mtk_pinctrl_devdata *data,
struct regmap *regmap);
int mtk_pctrl_spec_pull_set_samereg(struct regmap *regmap,
const struct mtk_pin_spec_pupd_set_samereg *pupd_infos,
unsigned int info_num, unsigned int pin,
unsigned char align, bool isup, unsigned int r1r0);
int mtk_pconf_spec_set_ies_smt_range(struct regmap *regmap,
const struct mtk_pin_ies_smt_set *ies_smt_infos, unsigned int info_num,
unsigned int pin, unsigned char align, int value);
extern const struct dev_pm_ops mtk_eint_pm_ops;
#endif /* __PINCTRL_MTK_COMMON_H */
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,384 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __PINCTRL_MTK_MT6397_H
#define __PINCTRL_MTK_MT6397_H
#include <linux/pinctrl/pinctrl.h>
#include "pinctrl-mtk-common.h"
static const struct mtk_desc_pin mtk_pins_mt6397[] = {
MTK_PIN(PINCTRL_PIN(0, "INT"),
"N2", "mt6397",
MTK_EINT_FUNCTION(NO_EINT_SUPPORT, NO_EINT_SUPPORT),
MTK_FUNCTION(0, "GPIO0"),
MTK_FUNCTION(1, "INT")
),
MTK_PIN(PINCTRL_PIN(1, "SRCVOLTEN"),
"M4", "mt6397",
MTK_EINT_FUNCTION(NO_EINT_SUPPORT, NO_EINT_SUPPORT),
MTK_FUNCTION(0, "GPIO1"),
MTK_FUNCTION(1, "SRCVOLTEN"),
MTK_FUNCTION(6, "TEST_CK1")
),
MTK_PIN(PINCTRL_PIN(2, "SRCLKEN_PERI"),
"M2", "mt6397",
MTK_EINT_FUNCTION(NO_EINT_SUPPORT, NO_EINT_SUPPORT),
MTK_FUNCTION(0, "GPIO2"),
MTK_FUNCTION(1, "SRCLKEN_PERI"),
MTK_FUNCTION(6, "TEST_CK2")
),
MTK_PIN(PINCTRL_PIN(3, "RTC_32K1V8"),
"K3", "mt6397",
MTK_EINT_FUNCTION(NO_EINT_SUPPORT, NO_EINT_SUPPORT),
MTK_FUNCTION(0, "GPIO3"),
MTK_FUNCTION(1, "RTC_32K1V8"),
MTK_FUNCTION(6, "TEST_CK3")
),
MTK_PIN(PINCTRL_PIN(4, "WRAP_EVENT"),
"J2", "mt6397",
MTK_EINT_FUNCTION(NO_EINT_SUPPORT, NO_EINT_SUPPORT),
MTK_FUNCTION(0, "GPIO4"),
MTK_FUNCTION(1, "WRAP_EVENT")
),
MTK_PIN(PINCTRL_PIN(5, "SPI_CLK"),
"L4", "mt6397",
MTK_EINT_FUNCTION(NO_EINT_SUPPORT, NO_EINT_SUPPORT),
MTK_FUNCTION(0, "GPIO5"),
MTK_FUNCTION(1, "SPI_CLK")
),
MTK_PIN(PINCTRL_PIN(6, "SPI_CSN"),
"J3", "mt6397",
MTK_EINT_FUNCTION(NO_EINT_SUPPORT, NO_EINT_SUPPORT),
MTK_FUNCTION(0, "GPIO6"),
MTK_FUNCTION(1, "SPI_CSN")
),
MTK_PIN(PINCTRL_PIN(7, "SPI_MOSI"),
"J1", "mt6397",
MTK_EINT_FUNCTION(NO_EINT_SUPPORT, NO_EINT_SUPPORT),
MTK_FUNCTION(0, "GPIO7"),
MTK_FUNCTION(1, "SPI_MOSI")
),
MTK_PIN(PINCTRL_PIN(8, "SPI_MISO"),
"L3", "mt6397",
MTK_EINT_FUNCTION(NO_EINT_SUPPORT, NO_EINT_SUPPORT),
MTK_FUNCTION(0, "GPIO8"),
MTK_FUNCTION(1, "SPI_MISO")
),
MTK_PIN(PINCTRL_PIN(9, "AUD_CLK_MOSI"),
"H2", "mt6397",
MTK_EINT_FUNCTION(NO_EINT_SUPPORT, NO_EINT_SUPPORT),
MTK_FUNCTION(0, "GPIO9"),
MTK_FUNCTION(1, "AUD_CLK"),
MTK_FUNCTION(6, "TEST_IN0"),
MTK_FUNCTION(7, "TEST_OUT0")
),
MTK_PIN(PINCTRL_PIN(10, "AUD_DAT_MISO"),
"H3", "mt6397",
MTK_EINT_FUNCTION(NO_EINT_SUPPORT, NO_EINT_SUPPORT),
MTK_FUNCTION(0, "GPIO10"),
MTK_FUNCTION(1, "AUD_MISO"),
MTK_FUNCTION(6, "TEST_IN1"),
MTK_FUNCTION(7, "TEST_OUT1")
),
MTK_PIN(PINCTRL_PIN(11, "AUD_DAT_MOSI"),
"H1", "mt6397",
MTK_EINT_FUNCTION(NO_EINT_SUPPORT, NO_EINT_SUPPORT),
MTK_FUNCTION(0, "GPIO11"),
MTK_FUNCTION(1, "AUD_MOSI"),
MTK_FUNCTION(6, "TEST_IN2"),
MTK_FUNCTION(7, "TEST_OUT2")
),
MTK_PIN(PINCTRL_PIN(12, "COL0"),
"F3", "mt6397",
MTK_EINT_FUNCTION(2, 10),
MTK_FUNCTION(0, "GPIO12"),
MTK_FUNCTION(1, "COL0_USBDL"),
MTK_FUNCTION(2, "EINT10_1X"),
MTK_FUNCTION(3, "PWM1_3X"),
MTK_FUNCTION(6, "TEST_IN3"),
MTK_FUNCTION(7, "TEST_OUT3")
),
MTK_PIN(PINCTRL_PIN(13, "COL1"),
"G8", "mt6397",
MTK_EINT_FUNCTION(2, 11),
MTK_FUNCTION(0, "GPIO13"),
MTK_FUNCTION(1, "COL1"),
MTK_FUNCTION(2, "EINT11_1X"),
MTK_FUNCTION(3, "SCL0_2X"),
MTK_FUNCTION(6, "TEST_IN4"),
MTK_FUNCTION(7, "TEST_OUT4")
),
MTK_PIN(PINCTRL_PIN(14, "COL2"),
"H4", "mt6397",
MTK_EINT_FUNCTION(2, 12),
MTK_FUNCTION(0, "GPIO14"),
MTK_FUNCTION(1, "COL2"),
MTK_FUNCTION(2, "EINT12_1X"),
MTK_FUNCTION(3, "SDA0_2X"),
MTK_FUNCTION(6, "TEST_IN5"),
MTK_FUNCTION(7, "TEST_OUT5")
),
MTK_PIN(PINCTRL_PIN(15, "COL3"),
"G2", "mt6397",
MTK_EINT_FUNCTION(2, 13),
MTK_FUNCTION(0, "GPIO15"),
MTK_FUNCTION(1, "COL3"),
MTK_FUNCTION(2, "EINT13_1X"),
MTK_FUNCTION(3, "SCL1_2X"),
MTK_FUNCTION(6, "TEST_IN6"),
MTK_FUNCTION(7, "TEST_OUT6")
),
MTK_PIN(PINCTRL_PIN(16, "COL4"),
"F2", "mt6397",
MTK_EINT_FUNCTION(2, 14),
MTK_FUNCTION(0, "GPIO16"),
MTK_FUNCTION(1, "COL4"),
MTK_FUNCTION(2, "EINT14_1X"),
MTK_FUNCTION(3, "SDA1_2X"),
MTK_FUNCTION(6, "TEST_IN7"),
MTK_FUNCTION(7, "TEST_OUT7")
),
MTK_PIN(PINCTRL_PIN(17, "COL5"),
"G7", "mt6397",
MTK_EINT_FUNCTION(2, 15),
MTK_FUNCTION(0, "GPIO17"),
MTK_FUNCTION(1, "COL5"),
MTK_FUNCTION(2, "EINT15_1X"),
MTK_FUNCTION(3, "SCL2_2X"),
MTK_FUNCTION(6, "TEST_IN8"),
MTK_FUNCTION(7, "TEST_OUT8")
),
MTK_PIN(PINCTRL_PIN(18, "COL6"),
"J6", "mt6397",
MTK_EINT_FUNCTION(2, 16),
MTK_FUNCTION(0, "GPIO18"),
MTK_FUNCTION(1, "COL6"),
MTK_FUNCTION(2, "EINT16_1X"),
MTK_FUNCTION(3, "SDA2_2X"),
MTK_FUNCTION(4, "GPIO32K_0"),
MTK_FUNCTION(5, "GPIO26M_0"),
MTK_FUNCTION(6, "TEST_IN9"),
MTK_FUNCTION(7, "TEST_OUT9")
),
MTK_PIN(PINCTRL_PIN(19, "COL7"),
"J5", "mt6397",
MTK_EINT_FUNCTION(2, 17),
MTK_FUNCTION(0, "GPIO19"),
MTK_FUNCTION(1, "COL7"),
MTK_FUNCTION(2, "EINT17_1X"),
MTK_FUNCTION(3, "PWM2_3X"),
MTK_FUNCTION(4, "GPIO32K_1"),
MTK_FUNCTION(5, "GPIO26M_1"),
MTK_FUNCTION(6, "TEST_IN10"),
MTK_FUNCTION(7, "TEST_OUT10")
),
MTK_PIN(PINCTRL_PIN(20, "ROW0"),
"L7", "mt6397",
MTK_EINT_FUNCTION(2, 18),
MTK_FUNCTION(0, "GPIO20"),
MTK_FUNCTION(1, "ROW0"),
MTK_FUNCTION(2, "EINT18_1X"),
MTK_FUNCTION(3, "SCL0_3X"),
MTK_FUNCTION(6, "TEST_IN11"),
MTK_FUNCTION(7, "TEST_OUT11")
),
MTK_PIN(PINCTRL_PIN(21, "ROW1"),
"P1", "mt6397",
MTK_EINT_FUNCTION(2, 19),
MTK_FUNCTION(0, "GPIO21"),
MTK_FUNCTION(1, "ROW1"),
MTK_FUNCTION(2, "EINT19_1X"),
MTK_FUNCTION(3, "SDA0_3X"),
MTK_FUNCTION(4, "AUD_TSTCK"),
MTK_FUNCTION(6, "TEST_IN12"),
MTK_FUNCTION(7, "TEST_OUT12")
),
MTK_PIN(PINCTRL_PIN(22, "ROW2"),
"J8", "mt6397",
MTK_EINT_FUNCTION(2, 20),
MTK_FUNCTION(0, "GPIO22"),
MTK_FUNCTION(1, "ROW2"),
MTK_FUNCTION(2, "EINT20_1X"),
MTK_FUNCTION(3, "SCL1_3X"),
MTK_FUNCTION(6, "TEST_IN13"),
MTK_FUNCTION(7, "TEST_OUT13")
),
MTK_PIN(PINCTRL_PIN(23, "ROW3"),
"J7", "mt6397",
MTK_EINT_FUNCTION(2, 21),
MTK_FUNCTION(0, "GPIO23"),
MTK_FUNCTION(1, "ROW3"),
MTK_FUNCTION(2, "EINT21_1X"),
MTK_FUNCTION(3, "SDA1_3X"),
MTK_FUNCTION(6, "TEST_IN14"),
MTK_FUNCTION(7, "TEST_OUT14")
),
MTK_PIN(PINCTRL_PIN(24, "ROW4"),
"L5", "mt6397",
MTK_EINT_FUNCTION(2, 22),
MTK_FUNCTION(0, "GPIO24"),
MTK_FUNCTION(1, "ROW4"),
MTK_FUNCTION(2, "EINT22_1X"),
MTK_FUNCTION(3, "SCL2_3X"),
MTK_FUNCTION(6, "TEST_IN15"),
MTK_FUNCTION(7, "TEST_OUT15")
),
MTK_PIN(PINCTRL_PIN(25, "ROW5"),
"N6", "mt6397",
MTK_EINT_FUNCTION(2, 23),
MTK_FUNCTION(0, "GPIO25"),
MTK_FUNCTION(1, "ROW5"),
MTK_FUNCTION(2, "EINT23_1X"),
MTK_FUNCTION(3, "SDA2_3X"),
MTK_FUNCTION(6, "TEST_IN16"),
MTK_FUNCTION(7, "TEST_OUT16")
),
MTK_PIN(PINCTRL_PIN(26, "ROW6"),
"L6", "mt6397",
MTK_EINT_FUNCTION(2, 24),
MTK_FUNCTION(0, "GPIO26"),
MTK_FUNCTION(1, "ROW6"),
MTK_FUNCTION(2, "EINT24_1X"),
MTK_FUNCTION(3, "PWM3_3X"),
MTK_FUNCTION(4, "GPIO32K_2"),
MTK_FUNCTION(5, "GPIO26M_2"),
MTK_FUNCTION(6, "TEST_IN17"),
MTK_FUNCTION(7, "TEST_OUT17")
),
MTK_PIN(PINCTRL_PIN(27, "ROW7"),
"P2", "mt6397",
MTK_EINT_FUNCTION(2, 3),
MTK_FUNCTION(0, "GPIO27"),
MTK_FUNCTION(1, "ROW7"),
MTK_FUNCTION(2, "EINT3_1X"),
MTK_FUNCTION(3, "CBUS"),
MTK_FUNCTION(4, "GPIO32K_3"),
MTK_FUNCTION(5, "GPIO26M_3"),
MTK_FUNCTION(6, "TEST_IN18"),
MTK_FUNCTION(7, "TEST_OUT18")
),
MTK_PIN(PINCTRL_PIN(28, "PWM1(VMSEL1)"),
"J4", "mt6397",
MTK_EINT_FUNCTION(2, 4),
MTK_FUNCTION(0, "GPIO28"),
MTK_FUNCTION(1, "PWM1"),
MTK_FUNCTION(2, "EINT4_1X"),
MTK_FUNCTION(4, "GPIO32K_4"),
MTK_FUNCTION(5, "GPIO26M_4"),
MTK_FUNCTION(6, "TEST_IN19"),
MTK_FUNCTION(7, "TEST_OUT19")
),
MTK_PIN(PINCTRL_PIN(29, "PWM2(VMSEL2)"),
"N5", "mt6397",
MTK_EINT_FUNCTION(2, 5),
MTK_FUNCTION(0, "GPIO29"),
MTK_FUNCTION(1, "PWM2"),
MTK_FUNCTION(2, "EINT5_1X"),
MTK_FUNCTION(4, "GPIO32K_5"),
MTK_FUNCTION(5, "GPIO26M_5"),
MTK_FUNCTION(6, "TEST_IN20"),
MTK_FUNCTION(7, "TEST_OUT20")
),
MTK_PIN(PINCTRL_PIN(30, "PWM3(PWM)"),
"R3", "mt6397",
MTK_EINT_FUNCTION(2, 6),
MTK_FUNCTION(0, "GPIO30"),
MTK_FUNCTION(1, "PWM3"),
MTK_FUNCTION(2, "EINT6_1X"),
MTK_FUNCTION(3, "COL0"),
MTK_FUNCTION(4, "GPIO32K_6"),
MTK_FUNCTION(5, "GPIO26M_6"),
MTK_FUNCTION(6, "TEST_IN21"),
MTK_FUNCTION(7, "TEST_OUT21")
),
MTK_PIN(PINCTRL_PIN(31, "SCL0"),
"N1", "mt6397",
MTK_EINT_FUNCTION(2, 7),
MTK_FUNCTION(0, "GPIO31"),
MTK_FUNCTION(1, "SCL0"),
MTK_FUNCTION(2, "EINT7_1X"),
MTK_FUNCTION(3, "PWM1_2X"),
MTK_FUNCTION(6, "TEST_IN22"),
MTK_FUNCTION(7, "TEST_OUT22")
),
MTK_PIN(PINCTRL_PIN(32, "SDA0"),
"N3", "mt6397",
MTK_EINT_FUNCTION(2, 8),
MTK_FUNCTION(0, "GPIO32"),
MTK_FUNCTION(1, "SDA0"),
MTK_FUNCTION(2, "EINT8_1X"),
MTK_FUNCTION(6, "TEST_IN23"),
MTK_FUNCTION(7, "TEST_OUT23")
),
MTK_PIN(PINCTRL_PIN(33, "SCL1"),
"T1", "mt6397",
MTK_EINT_FUNCTION(2, 9),
MTK_FUNCTION(0, "GPIO33"),
MTK_FUNCTION(1, "SCL1"),
MTK_FUNCTION(2, "EINT9_1X"),
MTK_FUNCTION(3, "PWM2_2X"),
MTK_FUNCTION(6, "TEST_IN24"),
MTK_FUNCTION(7, "TEST_OUT24")
),
MTK_PIN(PINCTRL_PIN(34, "SDA1"),
"T2", "mt6397",
MTK_EINT_FUNCTION(2, 0),
MTK_FUNCTION(0, "GPIO34"),
MTK_FUNCTION(1, "SDA1"),
MTK_FUNCTION(2, "EINT0_1X"),
MTK_FUNCTION(6, "TEST_IN25"),
MTK_FUNCTION(7, "TEST_OUT25")
),
MTK_PIN(PINCTRL_PIN(35, "SCL2"),
"T3", "mt6397",
MTK_EINT_FUNCTION(2, 1),
MTK_FUNCTION(0, "GPIO35"),
MTK_FUNCTION(1, "SCL2"),
MTK_FUNCTION(2, "EINT1_1X"),
MTK_FUNCTION(3, "PWM3_2X"),
MTK_FUNCTION(6, "TEST_IN26"),
MTK_FUNCTION(7, "TEST_OUT26")
),
MTK_PIN(PINCTRL_PIN(36, "SDA2"),
"U2", "mt6397",
MTK_EINT_FUNCTION(2, 2),
MTK_FUNCTION(0, "GPIO36"),
MTK_FUNCTION(1, "SDA2"),
MTK_FUNCTION(2, "EINT2_1X"),
MTK_FUNCTION(6, "TEST_IN27"),
MTK_FUNCTION(7, "TEST_OUT27")
),
MTK_PIN(PINCTRL_PIN(37, "HDMISD"),
"H6", "mt6397",
MTK_EINT_FUNCTION(NO_EINT_SUPPORT, NO_EINT_SUPPORT),
MTK_FUNCTION(0, "GPIO37"),
MTK_FUNCTION(1, "HDMISD"),
MTK_FUNCTION(6, "TEST_IN28"),
MTK_FUNCTION(7, "TEST_OUT28")
),
MTK_PIN(PINCTRL_PIN(38, "HDMISCK"),
"H5", "mt6397",
MTK_EINT_FUNCTION(NO_EINT_SUPPORT, NO_EINT_SUPPORT),
MTK_FUNCTION(0, "GPIO38"),
MTK_FUNCTION(1, "HDMISCK"),
MTK_FUNCTION(6, "TEST_IN29"),
MTK_FUNCTION(7, "TEST_OUT29")
),
MTK_PIN(PINCTRL_PIN(39, "HTPLG"),
"H7", "mt6397",
MTK_EINT_FUNCTION(NO_EINT_SUPPORT, NO_EINT_SUPPORT),
MTK_FUNCTION(0, "GPIO39"),
MTK_FUNCTION(1, "HTPLG"),
MTK_FUNCTION(6, "TEST_IN30"),
MTK_FUNCTION(7, "TEST_OUT30")
),
MTK_PIN(PINCTRL_PIN(40, "CEC"),
"J9", "mt6397",
MTK_EINT_FUNCTION(NO_EINT_SUPPORT, NO_EINT_SUPPORT),
MTK_FUNCTION(0, "GPIO40"),
MTK_FUNCTION(1, "CEC"),
MTK_FUNCTION(6, "TEST_IN31"),
MTK_FUNCTION(7, "TEST_OUT31")
),
};
#endif /* __PINCTRL_MTK_MT6397_H */
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+66
View File
@@ -0,0 +1,66 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2018 MediaTek Inc.
*
* Author: Sean Wang <sean.wang@mediatek.com>
* Zhiyong Tao <zhiyong.tao@mediatek.com>
* Hongzhou.Yang <hongzhou.yang@mediatek.com>
*/
#ifndef __PINCTRL_PARIS_H
#define __PINCTRL_PARIS_H
#include <linux/io.h>
#include <linux/init.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/pinctrl/pinmux.h>
#include <linux/pinctrl/pinconf.h>
#include <linux/pinctrl/pinconf-generic.h>
#include "../core.h"
#include "../pinconf.h"
#include "../pinctrl-utils.h"
#include "../pinmux.h"
#include "mtk-eint.h"
#include "pinctrl-mtk-common-v2.h"
#define MTK_RANGE(_a) { .range = (_a), .nranges = ARRAY_SIZE(_a), }
#define MTK_EINT_FUNCTION(_eintmux, _eintnum) \
{ \
.eint_m = _eintmux, \
.eint_n = _eintnum, \
}
#define MTK_FUNCTION(_val, _name) \
{ \
.muxval = _val, \
.name = _name, \
}
#define MTK_PIN(_number, _name, _eint, _drv_n, ...) { \
.number = _number, \
.name = _name, \
.eint = _eint, \
.drv_n = _drv_n, \
.funcs = (struct mtk_func_desc[]){ \
__VA_ARGS__, { } }, \
}
#define PINCTRL_PIN_GROUP(name, id) \
{ \
name, \
id##_pins, \
ARRAY_SIZE(id##_pins), \
id##_funcs, \
}
int mtk_paris_pinctrl_probe(struct platform_device *pdev,
const struct mtk_pin_soc *soc);
ssize_t mtk_pctrl_show_one_pin(struct mtk_pinctrl *hw,
unsigned int gpio, char *buf, unsigned int bufLen);
#endif /* __PINCTRL_PARIS_H */