18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2014 MediaTek Inc. 48c2ecf20Sopenharmony_ci * Author: Hongzhou.Yang <hongzhou.yang@mediatek.com> 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#include <linux/init.h> 88c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 98c2ecf20Sopenharmony_ci#include <linux/of.h> 108c2ecf20Sopenharmony_ci#include <linux/of_device.h> 118c2ecf20Sopenharmony_ci#include <linux/pinctrl/pinctrl.h> 128c2ecf20Sopenharmony_ci#include <linux/regmap.h> 138c2ecf20Sopenharmony_ci#include <dt-bindings/pinctrl/mt65xx.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include "pinctrl-mtk-common.h" 168c2ecf20Sopenharmony_ci#include "pinctrl-mtk-mt8135.h" 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#define DRV_BASE1 0x500 198c2ecf20Sopenharmony_ci#define DRV_BASE2 0x510 208c2ecf20Sopenharmony_ci#define PUPD_BASE1 0x400 218c2ecf20Sopenharmony_ci#define PUPD_BASE2 0x450 228c2ecf20Sopenharmony_ci#define R0_BASE1 0x4d0 238c2ecf20Sopenharmony_ci#define R1_BASE1 0x200 248c2ecf20Sopenharmony_ci#define R1_BASE2 0x250 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cistruct mtk_spec_pull_set { 278c2ecf20Sopenharmony_ci unsigned char pin; 288c2ecf20Sopenharmony_ci unsigned char pupd_bit; 298c2ecf20Sopenharmony_ci unsigned short pupd_offset; 308c2ecf20Sopenharmony_ci unsigned short r0_offset; 318c2ecf20Sopenharmony_ci unsigned short r1_offset; 328c2ecf20Sopenharmony_ci unsigned char r0_bit; 338c2ecf20Sopenharmony_ci unsigned char r1_bit; 348c2ecf20Sopenharmony_ci}; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define SPEC_PULL(_pin, _pupd_offset, _pupd_bit, _r0_offset, \ 378c2ecf20Sopenharmony_ci _r0_bit, _r1_offset, _r1_bit) \ 388c2ecf20Sopenharmony_ci { \ 398c2ecf20Sopenharmony_ci .pin = _pin, \ 408c2ecf20Sopenharmony_ci .pupd_offset = _pupd_offset, \ 418c2ecf20Sopenharmony_ci .pupd_bit = _pupd_bit, \ 428c2ecf20Sopenharmony_ci .r0_offset = _r0_offset, \ 438c2ecf20Sopenharmony_ci .r0_bit = _r0_bit, \ 448c2ecf20Sopenharmony_ci .r1_offset = _r1_offset, \ 458c2ecf20Sopenharmony_ci .r1_bit = _r1_bit, \ 468c2ecf20Sopenharmony_ci } 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cistatic const struct mtk_drv_group_desc mt8135_drv_grp[] = { 498c2ecf20Sopenharmony_ci /* E8E4E2 2/4/6/8/10/12/14/16 */ 508c2ecf20Sopenharmony_ci MTK_DRV_GRP(2, 16, 0, 2, 2), 518c2ecf20Sopenharmony_ci /* E8E4 4/8/12/16 */ 528c2ecf20Sopenharmony_ci MTK_DRV_GRP(4, 16, 1, 2, 4), 538c2ecf20Sopenharmony_ci /* E4E2 2/4/6/8 */ 548c2ecf20Sopenharmony_ci MTK_DRV_GRP(2, 8, 0, 1, 2), 558c2ecf20Sopenharmony_ci /* E16E8E4 4/8/12/16/20/24/28/32 */ 568c2ecf20Sopenharmony_ci MTK_DRV_GRP(4, 32, 0, 2, 4) 578c2ecf20Sopenharmony_ci}; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_cistatic const struct mtk_pin_drv_grp mt8135_pin_drv[] = { 608c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(0, DRV_BASE1, 0, 0), 618c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(1, DRV_BASE1, 0, 0), 628c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(2, DRV_BASE1, 0, 0), 638c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(3, DRV_BASE1, 0, 0), 648c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(4, DRV_BASE1, 4, 0), 658c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(5, DRV_BASE1, 8, 0), 668c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(6, DRV_BASE1, 0, 0), 678c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(7, DRV_BASE1, 0, 0), 688c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(8, DRV_BASE1, 0, 0), 698c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(9, DRV_BASE1, 0, 0), 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(10, DRV_BASE1, 12, 1), 728c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(11, DRV_BASE1, 12, 1), 738c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(12, DRV_BASE1, 12, 1), 748c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(13, DRV_BASE1, 12, 1), 758c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(14, DRV_BASE1, 12, 1), 768c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(15, DRV_BASE1, 12, 1), 778c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(16, DRV_BASE1, 12, 1), 788c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(17, DRV_BASE1, 16, 1), 798c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(18, DRV_BASE1, 16, 1), 808c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(19, DRV_BASE1, 16, 1), 818c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(20, DRV_BASE1, 16, 1), 828c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(21, DRV_BASE1, 16, 1), 838c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(22, DRV_BASE1, 16, 1), 848c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(23, DRV_BASE1, 16, 1), 858c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(24, DRV_BASE1, 16, 1), 868c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(33, DRV_BASE1, 24, 1), 878c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(34, DRV_BASE2, 12, 2), 888c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(37, DRV_BASE2, 20, 1), 898c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(38, DRV_BASE2, 20, 1), 908c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(39, DRV_BASE2, 20, 1), 918c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(40, DRV_BASE2, 24, 1), 928c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(41, DRV_BASE2, 24, 1), 938c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(42, DRV_BASE2, 24, 1), 948c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(43, DRV_BASE2, 28, 1), 958c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(44, DRV_BASE2, 28, 1), 968c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(45, DRV_BASE2, 28, 1), 978c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(46, DRV_BASE2, 28, 1), 988c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(47, DRV_BASE2, 28, 1), 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(49, DRV_BASE2+0x10, 0, 1), 1018c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(50, DRV_BASE2+0x10, 4, 1), 1028c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(51, DRV_BASE2+0x10, 8, 1), 1038c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(52, DRV_BASE2+0x10, 12, 2), 1048c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(53, DRV_BASE2+0x10, 16, 1), 1058c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(54, DRV_BASE2+0x10, 20, 1), 1068c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(55, DRV_BASE2+0x10, 24, 1), 1078c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(56, DRV_BASE2+0x10, 28, 1), 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(57, DRV_BASE2+0x20, 0, 1), 1108c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(58, DRV_BASE2+0x20, 0, 1), 1118c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(59, DRV_BASE2+0x20, 0, 1), 1128c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(60, DRV_BASE2+0x20, 0, 1), 1138c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(61, DRV_BASE2+0x20, 0, 1), 1148c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(62, DRV_BASE2+0x20, 0, 1), 1158c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(63, DRV_BASE2+0x20, 4, 1), 1168c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(64, DRV_BASE2+0x20, 8, 1), 1178c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(65, DRV_BASE2+0x20, 12, 1), 1188c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(66, DRV_BASE2+0x20, 16, 1), 1198c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(67, DRV_BASE2+0x20, 20, 1), 1208c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(68, DRV_BASE2+0x20, 24, 1), 1218c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(69, DRV_BASE2+0x20, 28, 1), 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(70, DRV_BASE2+0x30, 0, 1), 1248c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(71, DRV_BASE2+0x30, 4, 1), 1258c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(72, DRV_BASE2+0x30, 8, 1), 1268c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(73, DRV_BASE2+0x30, 12, 1), 1278c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(74, DRV_BASE2+0x30, 16, 1), 1288c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(75, DRV_BASE2+0x30, 20, 1), 1298c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(76, DRV_BASE2+0x30, 24, 1), 1308c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(77, DRV_BASE2+0x30, 28, 3), 1318c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(78, DRV_BASE2+0x30, 28, 3), 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(79, DRV_BASE2+0x40, 0, 3), 1348c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(80, DRV_BASE2+0x40, 4, 3), 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(81, DRV_BASE2+0x30, 28, 3), 1378c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(82, DRV_BASE2+0x30, 28, 3), 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(83, DRV_BASE2+0x40, 8, 3), 1408c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(84, DRV_BASE2+0x40, 8, 3), 1418c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(85, DRV_BASE2+0x40, 12, 3), 1428c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(86, DRV_BASE2+0x40, 16, 3), 1438c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(87, DRV_BASE2+0x40, 8, 3), 1448c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(88, DRV_BASE2+0x40, 8, 3), 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(89, DRV_BASE2+0x50, 12, 0), 1478c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(90, DRV_BASE2+0x50, 12, 0), 1488c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(91, DRV_BASE2+0x50, 12, 0), 1498c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(92, DRV_BASE2+0x50, 12, 0), 1508c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(93, DRV_BASE2+0x50, 12, 0), 1518c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(94, DRV_BASE2+0x50, 12, 0), 1528c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(95, DRV_BASE2+0x50, 12, 0), 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(96, DRV_BASE1+0xb0, 28, 0), 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(97, DRV_BASE2+0x50, 12, 0), 1578c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(98, DRV_BASE2+0x50, 16, 0), 1588c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(99, DRV_BASE2+0x50, 20, 1), 1598c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(102, DRV_BASE2+0x50, 24, 1), 1608c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(103, DRV_BASE2+0x50, 28, 1), 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(104, DRV_BASE2+0x60, 0, 1), 1648c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(105, DRV_BASE2+0x60, 4, 1), 1658c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(106, DRV_BASE2+0x60, 4, 1), 1668c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(107, DRV_BASE2+0x60, 4, 1), 1678c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(108, DRV_BASE2+0x60, 4, 1), 1688c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(109, DRV_BASE2+0x60, 8, 2), 1698c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(110, DRV_BASE2+0x60, 12, 2), 1708c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(111, DRV_BASE2+0x60, 16, 2), 1718c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(112, DRV_BASE2+0x60, 20, 2), 1728c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(113, DRV_BASE2+0x60, 24, 2), 1738c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(114, DRV_BASE2+0x60, 28, 2), 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(115, DRV_BASE2+0x70, 0, 2), 1768c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(116, DRV_BASE2+0x70, 4, 2), 1778c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(117, DRV_BASE2+0x70, 8, 2), 1788c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(118, DRV_BASE2+0x70, 12, 2), 1798c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(119, DRV_BASE2+0x70, 16, 2), 1808c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(120, DRV_BASE2+0x70, 20, 2), 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(181, DRV_BASE1+0xa0, 12, 1), 1838c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(182, DRV_BASE1+0xa0, 16, 1), 1848c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(183, DRV_BASE1+0xa0, 20, 1), 1858c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(184, DRV_BASE1+0xa0, 24, 1), 1868c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(185, DRV_BASE1+0xa0, 28, 1), 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(186, DRV_BASE1+0xb0, 0, 2), 1898c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(187, DRV_BASE1+0xb0, 0, 2), 1908c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(188, DRV_BASE1+0xb0, 0, 2), 1918c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(189, DRV_BASE1+0xb0, 0, 2), 1928c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(190, DRV_BASE1+0xb0, 4, 1), 1938c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(191, DRV_BASE1+0xb0, 8, 1), 1948c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(192, DRV_BASE1+0xb0, 12, 1), 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(197, DRV_BASE1+0xb0, 16, 0), 1978c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(198, DRV_BASE1+0xb0, 16, 0), 1988c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(199, DRV_BASE1+0xb0, 20, 0), 1998c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(200, DRV_BASE1+0xb0, 24, 0), 2008c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(201, DRV_BASE1+0xb0, 16, 0), 2018c2ecf20Sopenharmony_ci MTK_PIN_DRV_GRP(202, DRV_BASE1+0xb0, 16, 0) 2028c2ecf20Sopenharmony_ci}; 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_cistatic const struct mtk_spec_pull_set spec_pupd[] = { 2058c2ecf20Sopenharmony_ci SPEC_PULL(0, PUPD_BASE1, 0, R0_BASE1, 9, R1_BASE1, 0), 2068c2ecf20Sopenharmony_ci SPEC_PULL(1, PUPD_BASE1, 1, R0_BASE1, 8, R1_BASE1, 1), 2078c2ecf20Sopenharmony_ci SPEC_PULL(2, PUPD_BASE1, 2, R0_BASE1, 7, R1_BASE1, 2), 2088c2ecf20Sopenharmony_ci SPEC_PULL(3, PUPD_BASE1, 3, R0_BASE1, 6, R1_BASE1, 3), 2098c2ecf20Sopenharmony_ci SPEC_PULL(4, PUPD_BASE1, 4, R0_BASE1, 1, R1_BASE1, 4), 2108c2ecf20Sopenharmony_ci SPEC_PULL(5, PUPD_BASE1, 5, R0_BASE1, 0, R1_BASE1, 5), 2118c2ecf20Sopenharmony_ci SPEC_PULL(6, PUPD_BASE1, 6, R0_BASE1, 5, R1_BASE1, 6), 2128c2ecf20Sopenharmony_ci SPEC_PULL(7, PUPD_BASE1, 7, R0_BASE1, 4, R1_BASE1, 7), 2138c2ecf20Sopenharmony_ci SPEC_PULL(8, PUPD_BASE1, 8, R0_BASE1, 3, R1_BASE1, 8), 2148c2ecf20Sopenharmony_ci SPEC_PULL(9, PUPD_BASE1, 9, R0_BASE1, 2, R1_BASE1, 9), 2158c2ecf20Sopenharmony_ci SPEC_PULL(89, PUPD_BASE2, 9, R0_BASE1, 18, R1_BASE2, 9), 2168c2ecf20Sopenharmony_ci SPEC_PULL(90, PUPD_BASE2, 10, R0_BASE1, 19, R1_BASE2, 10), 2178c2ecf20Sopenharmony_ci SPEC_PULL(91, PUPD_BASE2, 11, R0_BASE1, 23, R1_BASE2, 11), 2188c2ecf20Sopenharmony_ci SPEC_PULL(92, PUPD_BASE2, 12, R0_BASE1, 24, R1_BASE2, 12), 2198c2ecf20Sopenharmony_ci SPEC_PULL(93, PUPD_BASE2, 13, R0_BASE1, 25, R1_BASE2, 13), 2208c2ecf20Sopenharmony_ci SPEC_PULL(94, PUPD_BASE2, 14, R0_BASE1, 22, R1_BASE2, 14), 2218c2ecf20Sopenharmony_ci SPEC_PULL(95, PUPD_BASE2, 15, R0_BASE1, 20, R1_BASE2, 15), 2228c2ecf20Sopenharmony_ci SPEC_PULL(96, PUPD_BASE2+0x10, 0, R0_BASE1, 16, R1_BASE2+0x10, 0), 2238c2ecf20Sopenharmony_ci SPEC_PULL(97, PUPD_BASE2+0x10, 1, R0_BASE1, 21, R1_BASE2+0x10, 1), 2248c2ecf20Sopenharmony_ci SPEC_PULL(98, PUPD_BASE2+0x10, 2, R0_BASE1, 17, R1_BASE2+0x10, 2), 2258c2ecf20Sopenharmony_ci SPEC_PULL(197, PUPD_BASE1+0xc0, 5, R0_BASE1, 13, R1_BASE2+0xc0, 5), 2268c2ecf20Sopenharmony_ci SPEC_PULL(198, PUPD_BASE2+0xc0, 6, R0_BASE1, 14, R1_BASE2+0xc0, 6), 2278c2ecf20Sopenharmony_ci SPEC_PULL(199, PUPD_BASE2+0xc0, 7, R0_BASE1, 11, R1_BASE2+0xc0, 7), 2288c2ecf20Sopenharmony_ci SPEC_PULL(200, PUPD_BASE2+0xc0, 8, R0_BASE1, 10, R1_BASE2+0xc0, 8), 2298c2ecf20Sopenharmony_ci SPEC_PULL(201, PUPD_BASE2+0xc0, 9, R0_BASE1, 13, R1_BASE2+0xc0, 9), 2308c2ecf20Sopenharmony_ci SPEC_PULL(202, PUPD_BASE2+0xc0, 10, R0_BASE1, 12, R1_BASE2+0xc0, 10) 2318c2ecf20Sopenharmony_ci}; 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_cistatic int spec_pull_set(struct regmap *regmap, unsigned int pin, 2348c2ecf20Sopenharmony_ci unsigned char align, bool isup, unsigned int r1r0) 2358c2ecf20Sopenharmony_ci{ 2368c2ecf20Sopenharmony_ci unsigned int i; 2378c2ecf20Sopenharmony_ci unsigned int reg_pupd, reg_set_r0, reg_set_r1; 2388c2ecf20Sopenharmony_ci unsigned int reg_rst_r0, reg_rst_r1; 2398c2ecf20Sopenharmony_ci bool find = false; 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(spec_pupd); i++) { 2428c2ecf20Sopenharmony_ci if (pin == spec_pupd[i].pin) { 2438c2ecf20Sopenharmony_ci find = true; 2448c2ecf20Sopenharmony_ci break; 2458c2ecf20Sopenharmony_ci } 2468c2ecf20Sopenharmony_ci } 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_ci if (!find) 2498c2ecf20Sopenharmony_ci return -EINVAL; 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_ci if (isup) 2528c2ecf20Sopenharmony_ci reg_pupd = spec_pupd[i].pupd_offset + align; 2538c2ecf20Sopenharmony_ci else 2548c2ecf20Sopenharmony_ci reg_pupd = spec_pupd[i].pupd_offset + (align << 1); 2558c2ecf20Sopenharmony_ci 2568c2ecf20Sopenharmony_ci regmap_write(regmap, reg_pupd, spec_pupd[i].pupd_bit); 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci reg_set_r0 = spec_pupd[i].r0_offset + align; 2598c2ecf20Sopenharmony_ci reg_rst_r0 = spec_pupd[i].r0_offset + (align << 1); 2608c2ecf20Sopenharmony_ci reg_set_r1 = spec_pupd[i].r1_offset + align; 2618c2ecf20Sopenharmony_ci reg_rst_r1 = spec_pupd[i].r1_offset + (align << 1); 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci switch (r1r0) { 2648c2ecf20Sopenharmony_ci case MTK_PUPD_SET_R1R0_00: 2658c2ecf20Sopenharmony_ci regmap_write(regmap, reg_rst_r0, spec_pupd[i].r0_bit); 2668c2ecf20Sopenharmony_ci regmap_write(regmap, reg_rst_r1, spec_pupd[i].r1_bit); 2678c2ecf20Sopenharmony_ci break; 2688c2ecf20Sopenharmony_ci case MTK_PUPD_SET_R1R0_01: 2698c2ecf20Sopenharmony_ci regmap_write(regmap, reg_set_r0, spec_pupd[i].r0_bit); 2708c2ecf20Sopenharmony_ci regmap_write(regmap, reg_rst_r1, spec_pupd[i].r1_bit); 2718c2ecf20Sopenharmony_ci break; 2728c2ecf20Sopenharmony_ci case MTK_PUPD_SET_R1R0_10: 2738c2ecf20Sopenharmony_ci regmap_write(regmap, reg_rst_r0, spec_pupd[i].r0_bit); 2748c2ecf20Sopenharmony_ci regmap_write(regmap, reg_set_r1, spec_pupd[i].r1_bit); 2758c2ecf20Sopenharmony_ci break; 2768c2ecf20Sopenharmony_ci case MTK_PUPD_SET_R1R0_11: 2778c2ecf20Sopenharmony_ci regmap_write(regmap, reg_set_r0, spec_pupd[i].r0_bit); 2788c2ecf20Sopenharmony_ci regmap_write(regmap, reg_set_r1, spec_pupd[i].r1_bit); 2798c2ecf20Sopenharmony_ci break; 2808c2ecf20Sopenharmony_ci default: 2818c2ecf20Sopenharmony_ci return -EINVAL; 2828c2ecf20Sopenharmony_ci } 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci return 0; 2858c2ecf20Sopenharmony_ci} 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_cistatic const struct mtk_pinctrl_devdata mt8135_pinctrl_data = { 2888c2ecf20Sopenharmony_ci .pins = mtk_pins_mt8135, 2898c2ecf20Sopenharmony_ci .npins = ARRAY_SIZE(mtk_pins_mt8135), 2908c2ecf20Sopenharmony_ci .grp_desc = mt8135_drv_grp, 2918c2ecf20Sopenharmony_ci .n_grp_cls = ARRAY_SIZE(mt8135_drv_grp), 2928c2ecf20Sopenharmony_ci .pin_drv_grp = mt8135_pin_drv, 2938c2ecf20Sopenharmony_ci .n_pin_drv_grps = ARRAY_SIZE(mt8135_pin_drv), 2948c2ecf20Sopenharmony_ci .spec_pull_set = spec_pull_set, 2958c2ecf20Sopenharmony_ci .dir_offset = 0x0000, 2968c2ecf20Sopenharmony_ci .ies_offset = 0x0100, 2978c2ecf20Sopenharmony_ci .pullen_offset = 0x0200, 2988c2ecf20Sopenharmony_ci .smt_offset = 0x0300, 2998c2ecf20Sopenharmony_ci .pullsel_offset = 0x0400, 3008c2ecf20Sopenharmony_ci .dout_offset = 0x0800, 3018c2ecf20Sopenharmony_ci .din_offset = 0x0A00, 3028c2ecf20Sopenharmony_ci .pinmux_offset = 0x0C00, 3038c2ecf20Sopenharmony_ci .type1_start = 34, 3048c2ecf20Sopenharmony_ci .type1_end = 149, 3058c2ecf20Sopenharmony_ci .port_shf = 4, 3068c2ecf20Sopenharmony_ci .port_mask = 0xf, 3078c2ecf20Sopenharmony_ci .port_align = 4, 3088c2ecf20Sopenharmony_ci .eint_hw = { 3098c2ecf20Sopenharmony_ci .port_mask = 7, 3108c2ecf20Sopenharmony_ci .ports = 6, 3118c2ecf20Sopenharmony_ci .ap_num = 192, 3128c2ecf20Sopenharmony_ci .db_cnt = 16, 3138c2ecf20Sopenharmony_ci }, 3148c2ecf20Sopenharmony_ci}; 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_cistatic int mt8135_pinctrl_probe(struct platform_device *pdev) 3178c2ecf20Sopenharmony_ci{ 3188c2ecf20Sopenharmony_ci return mtk_pctrl_init(pdev, &mt8135_pinctrl_data, NULL); 3198c2ecf20Sopenharmony_ci} 3208c2ecf20Sopenharmony_ci 3218c2ecf20Sopenharmony_cistatic const struct of_device_id mt8135_pctrl_match[] = { 3228c2ecf20Sopenharmony_ci { 3238c2ecf20Sopenharmony_ci .compatible = "mediatek,mt8135-pinctrl", 3248c2ecf20Sopenharmony_ci }, 3258c2ecf20Sopenharmony_ci { } 3268c2ecf20Sopenharmony_ci}; 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_cistatic struct platform_driver mtk_pinctrl_driver = { 3298c2ecf20Sopenharmony_ci .probe = mt8135_pinctrl_probe, 3308c2ecf20Sopenharmony_ci .driver = { 3318c2ecf20Sopenharmony_ci .name = "mediatek-mt8135-pinctrl", 3328c2ecf20Sopenharmony_ci .of_match_table = mt8135_pctrl_match, 3338c2ecf20Sopenharmony_ci }, 3348c2ecf20Sopenharmony_ci}; 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_cistatic int __init mtk_pinctrl_init(void) 3378c2ecf20Sopenharmony_ci{ 3388c2ecf20Sopenharmony_ci return platform_driver_register(&mtk_pinctrl_driver); 3398c2ecf20Sopenharmony_ci} 3408c2ecf20Sopenharmony_ciarch_initcall(mtk_pinctrl_init); 341