drivers/pinctrl/mediatek/pinctrl-mt6765.c

Source file repositories/reference/linux-study-clean/drivers/pinctrl/mediatek/pinctrl-mt6765.c

File Facts

System
Linux kernel
Corpus path
drivers/pinctrl/mediatek/pinctrl-mt6765.c
Extension
.c
Size
52189 bytes
Lines
1107
Domain
Driver Families
Bucket
drivers/pinctrl
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (C) 2018 MediaTek Inc.
 *
 * Author: ZH Chen <zh.chen@mediatek.com>
 *
 */

#include <linux/module.h>
#include "pinctrl-mtk-mt6765.h"
#include "pinctrl-paris.h"

/* MT6765 have multiple bases to program pin configuration listed as the below:
 * iocfg[0]:0x10005000, iocfg[1]:0x10002C00, iocfg[2]:0x10002800,
 * iocfg[3]:0x10002A00, iocfg[4]:0x10002000, iocfg[5]:0x10002200,
 * iocfg[6]:0x10002500, iocfg[7]:0x10002600.
 * _i_base 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 mt6765_pin_mode_range[] = {
	PIN_FIELD(0, 202, 0x300, 0x10, 0, 4),
};

static const struct mtk_pin_field_calc mt6765_pin_dir_range[] = {
	PIN_FIELD(0, 202, 0x0, 0x10, 0, 1),
};

static const struct mtk_pin_field_calc mt6765_pin_di_range[] = {
	PIN_FIELD(0, 202, 0x200, 0x10, 0, 1),
};

static const struct mtk_pin_field_calc mt6765_pin_do_range[] = {
	PIN_FIELD(0, 202, 0x100, 0x10, 0, 1),
};

static const struct mtk_pin_field_calc mt6765_pin_smt_range[] = {
	PINS_FIELD_BASE(0, 3, 2, 0x00b0, 0x10, 4, 1),
	PINS_FIELD_BASE(4, 7, 2, 0x00b0, 0x10, 5, 1),
	PIN_FIELD_BASE(8, 8, 3, 0x0080, 0x10, 3, 1),
	PINS_FIELD_BASE(9, 11, 2, 0x00b0, 0x10, 6, 1),
	PIN_FIELD_BASE(12, 12, 5, 0x0060, 0x10, 9, 1),
	PINS_FIELD_BASE(13, 16, 6, 0x00b0, 0x10, 10, 1),
	PINS_FIELD_BASE(17, 20, 6, 0x00b0, 0x10, 8, 1),
	PINS_FIELD_BASE(21, 24, 6, 0x00b0, 0x10, 9, 1),
	PINS_FIELD_BASE(25, 28, 6, 0x00b0, 0x10, 7, 1),
	PIN_FIELD_BASE(29, 29, 6, 0x00b0, 0x10, 0, 1),
	PIN_FIELD_BASE(30, 30, 6, 0x00b0, 0x10, 1, 1),
	PINS_FIELD_BASE(31, 34, 6, 0x00b0, 0x10, 2, 1),
	PINS_FIELD_BASE(35, 36, 6, 0x00b0, 0x10, 5, 1),
	PIN_FIELD_BASE(37, 37, 6, 0x00b0, 0x10, 6, 1),
	PIN_FIELD_BASE(38, 38, 6, 0x00b0, 0x10, 4, 1),
	PINS_FIELD_BASE(39, 40, 6, 0x00b0, 0x10, 3, 1),
	PINS_FIELD_BASE(41, 42, 7, 0x00c0, 0x10, 6, 1),
	PIN_FIELD_BASE(43, 43, 7, 0x00c0, 0x10, 3, 1),
	PIN_FIELD_BASE(44, 44, 7, 0x00c0, 0x10, 4, 1),
	PIN_FIELD_BASE(45, 45, 7, 0x00c0, 0x10, 8, 1),
	PINS_FIELD_BASE(46, 47, 7, 0x00c0, 0x10, 7, 1),
	PIN_FIELD_BASE(48, 48, 7, 0x00c0, 0x10, 15, 1),
	PIN_FIELD_BASE(49, 49, 7, 0x00c0, 0x10, 17, 1),
	PIN_FIELD_BASE(50, 50, 7, 0x00c0, 0x10, 14, 1),
	PIN_FIELD_BASE(51, 51, 7, 0x00c0, 0x10, 16, 1),
	PINS_FIELD_BASE(52, 57, 7, 0x00c0, 0x10, 0, 1),
	PINS_FIELD_BASE(58, 60, 7, 0x00c0, 0x10, 12, 1),
	PINS_FIELD_BASE(61, 62, 3, 0x0080, 0x10, 5, 1),
	PINS_FIELD_BASE(63, 64, 3, 0x0080, 0x10, 4, 1),
	PINS_FIELD_BASE(65, 66, 3, 0x0080, 0x10, 7, 1),
	PINS_FIELD_BASE(67, 68, 3, 0x0080, 0x10, 6, 1),
	PINS_FIELD_BASE(69, 73, 3, 0x0080, 0x10, 1, 1),
	PINS_FIELD_BASE(74, 78, 3, 0x0080, 0x10, 2, 1),
	PINS_FIELD_BASE(79, 80, 3, 0x0080, 0x10, 0, 1),
	PIN_FIELD_BASE(81, 81, 3, 0x0080, 0x10, 12, 1),
	PIN_FIELD_BASE(82, 82, 3, 0x0080, 0x10, 11, 1),
	PIN_FIELD_BASE(83, 83, 3, 0x0080, 0x10, 9, 1),
	PIN_FIELD_BASE(84, 84, 3, 0x0080, 0x10, 10, 1),
	PIN_FIELD_BASE(85, 85, 7, 0x00c0, 0x10, 12, 1),
	PIN_FIELD_BASE(86, 86, 7, 0x00c0, 0x10, 13, 1),
	PIN_FIELD_BASE(87, 87, 7, 0x00c0, 0x10, 2, 1),
	PIN_FIELD_BASE(88, 88, 7, 0x00c0, 0x10, 1, 1),
	PIN_FIELD_BASE(89, 89, 2, 0x00b0, 0x10, 13, 1),
	PIN_FIELD_BASE(90, 90, 3, 0x0080, 0x10, 8, 1),
	PINS_FIELD_BASE(91, 92, 2, 0x00b0, 0x10, 8, 1),
	PINS_FIELD_BASE(93, 94, 2, 0x00b0, 0x10, 7, 1),

Annotation

Implementation Notes