18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Marvell Berlin BG2CD pinctrl driver. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2014 Marvell Technology Group Ltd. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Antoine Ténart <antoine.tenart@free-electrons.com> 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/init.h> 118c2ecf20Sopenharmony_ci#include <linux/of_device.h> 128c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 138c2ecf20Sopenharmony_ci#include <linux/regmap.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include "berlin.h" 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_cistatic const struct berlin_desc_group berlin2cd_soc_pinctrl_groups[] = { 188c2ecf20Sopenharmony_ci /* G */ 198c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G0", 0x00, 0x3, 0x00, 208c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x0, "jtag"), 218c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), 228c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x2, "led"), 238c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x3, "pwm")), 248c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G1", 0x00, 0x3, 0x03, 258c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 268c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), 278c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x6, "usb0_dbg"), 288c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x7, "usb1_dbg")), 298c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G2", 0x00, 0x3, 0x06, 308c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 318c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), 328c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x2, "fe"), 338c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x3, "pll"), 348c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x6, "usb0_dbg"), 358c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x7, "usb1_dbg")), 368c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G3", 0x00, 0x3, 0x09, 378c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 388c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), 398c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x2, "twsi2"), 408c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x3, "pll"), 418c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x4, "fe"), 428c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x6, "usb0_dbg"), 438c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x7, "usb1_dbg")), 448c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G4", 0x00, 0x3, 0x0c, 458c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 468c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), 478c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x2, "twsi3"), 488c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x3, "pll"), 498c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x4, "pwm"), 508c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x6, "usb0_dbg"), 518c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x7, "usb1_dbg")), 528c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G5", 0x00, 0x3, 0x0f, 538c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 548c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), 558c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x2, "twsi3"), 568c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x3, "arc"), 578c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x4, "pwm"), 588c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x6, "usb0_dbg"), 598c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x7, "usb1_dbg")), 608c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G6", 0x00, 0x3, 0x12, 618c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x0, "uart0"), /* RX/TX */ 628c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), 638c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G7", 0x00, 0x3, 0x15, 648c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x0, "eddc"), 658c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x1, "twsi1"), 668c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x2, "gpio")), 678c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G8", 0x00, 0x3, 0x18, 688c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS0n */ 698c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), 708c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G9", 0x00, 0x3, 0x1b, 718c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 728c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x1, "spi1"), /* SS1n/SS2n */ 738c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x3, "twsi0")), 748c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G10", 0x00, 0x2, 0x1e, 758c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* CLK */ 768c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), 778c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G11", 0x04, 0x2, 0x00, 788c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SDI/SDO */ 798c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), 808c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G12", 0x04, 0x3, 0x02, 818c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x0, "usb1"), 828c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), 838c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G13", 0x04, 0x3, 0x05, 848c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x0, "nand"), 858c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x1, "usb0_dbg"), 868c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x2, "usb1_dbg")), 878c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G14", 0x04, 0x1, 0x08, 888c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x0, "nand"), 898c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), 908c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G15", 0x04, 0x3, 0x09, 918c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x0, "jtag"), 928c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), 938c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G16", 0x04, 0x3, 0x0c, 948c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 958c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G17", 0x04, 0x3, 0x0f, 968c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 978c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G18", 0x04, 0x2, 0x12, 988c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 998c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G19", 0x04, 0x2, 0x14, 1008c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1018c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G20", 0x04, 0x2, 0x16, 1028c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1038c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G21", 0x04, 0x3, 0x18, 1048c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1058c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G22", 0x04, 0x3, 0x1b, 1068c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1078c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G23", 0x08, 0x3, 0x00, 1088c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1098c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G24", 0x08, 0x2, 0x03, 1108c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1118c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G25", 0x08, 0x2, 0x05, 1128c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1138c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G26", 0x08, 0x1, 0x07, 1148c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1158c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G27", 0x08, 0x2, 0x08, 1168c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1178c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G28", 0x08, 0x3, 0x0a, 1188c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1198c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("G29", 0x08, 0x3, 0x0d, 1208c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1218c2ecf20Sopenharmony_ci}; 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_cistatic const struct berlin_desc_group berlin2cd_sysmgr_pinctrl_groups[] = { 1248c2ecf20Sopenharmony_ci /* GSM */ 1258c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("GSM0", 0x40, 0x2, 0x00, 1268c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1278c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("GSM1", 0x40, 0x2, 0x02, 1288c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1298c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("GSM2", 0x40, 0x2, 0x04, 1308c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1318c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("GSM3", 0x40, 0x2, 0x06, 1328c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1338c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("GSM4", 0x40, 0x2, 0x08, 1348c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1358c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("GSM5", 0x40, 0x2, 0x0a, 1368c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1378c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("GSM6", 0x40, 0x2, 0x0c, 1388c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1398c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("GSM7", 0x40, 0x1, 0x0e, 1408c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1418c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("GSM8", 0x40, 0x1, 0x0f, 1428c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1438c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("GSM9", 0x40, 0x1, 0x10, 1448c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1458c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("GSM10", 0x40, 0x1, 0x11, 1468c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1478c2ecf20Sopenharmony_ci BERLIN_PINCTRL_GROUP("GSM11", 0x40, 0x1, 0x12, 1488c2ecf20Sopenharmony_ci BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1498c2ecf20Sopenharmony_ci}; 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_cistatic const struct berlin_pinctrl_desc berlin2cd_soc_pinctrl_data = { 1528c2ecf20Sopenharmony_ci .groups = berlin2cd_soc_pinctrl_groups, 1538c2ecf20Sopenharmony_ci .ngroups = ARRAY_SIZE(berlin2cd_soc_pinctrl_groups), 1548c2ecf20Sopenharmony_ci}; 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_cistatic const struct berlin_pinctrl_desc berlin2cd_sysmgr_pinctrl_data = { 1578c2ecf20Sopenharmony_ci .groups = berlin2cd_sysmgr_pinctrl_groups, 1588c2ecf20Sopenharmony_ci .ngroups = ARRAY_SIZE(berlin2cd_sysmgr_pinctrl_groups), 1598c2ecf20Sopenharmony_ci}; 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_cistatic const struct of_device_id berlin2cd_pinctrl_match[] = { 1628c2ecf20Sopenharmony_ci { 1638c2ecf20Sopenharmony_ci .compatible = "marvell,berlin2cd-soc-pinctrl", 1648c2ecf20Sopenharmony_ci .data = &berlin2cd_soc_pinctrl_data 1658c2ecf20Sopenharmony_ci }, 1668c2ecf20Sopenharmony_ci { 1678c2ecf20Sopenharmony_ci .compatible = "marvell,berlin2cd-system-pinctrl", 1688c2ecf20Sopenharmony_ci .data = &berlin2cd_sysmgr_pinctrl_data 1698c2ecf20Sopenharmony_ci }, 1708c2ecf20Sopenharmony_ci {} 1718c2ecf20Sopenharmony_ci}; 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_cistatic int berlin2cd_pinctrl_probe(struct platform_device *pdev) 1748c2ecf20Sopenharmony_ci{ 1758c2ecf20Sopenharmony_ci const struct of_device_id *match = 1768c2ecf20Sopenharmony_ci of_match_device(berlin2cd_pinctrl_match, &pdev->dev); 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci return berlin_pinctrl_probe(pdev, match->data); 1798c2ecf20Sopenharmony_ci} 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_cistatic struct platform_driver berlin2cd_pinctrl_driver = { 1828c2ecf20Sopenharmony_ci .probe = berlin2cd_pinctrl_probe, 1838c2ecf20Sopenharmony_ci .driver = { 1848c2ecf20Sopenharmony_ci .name = "berlin-bg2cd-pinctrl", 1858c2ecf20Sopenharmony_ci .of_match_table = berlin2cd_pinctrl_match, 1868c2ecf20Sopenharmony_ci }, 1878c2ecf20Sopenharmony_ci}; 1888c2ecf20Sopenharmony_cibuiltin_platform_driver(berlin2cd_pinctrl_driver); 189