148b6bce3SAntoine Tenart /* 248b6bce3SAntoine Tenart * Marvell Berlin BG2CD pinctrl driver. 348b6bce3SAntoine Tenart * 448b6bce3SAntoine Tenart * Copyright (C) 2014 Marvell Technology Group Ltd. 548b6bce3SAntoine Tenart * 61d48fb6eSAntoine Ténart * Antoine Ténart <antoine.tenart@free-electrons.com> 748b6bce3SAntoine Tenart * 848b6bce3SAntoine Tenart * This file is licensed under the terms of the GNU General Public 948b6bce3SAntoine Tenart * License version 2. This program is licensed "as is" without any 1048b6bce3SAntoine Tenart * warranty of any kind, whether express or implied. 1148b6bce3SAntoine Tenart */ 1248b6bce3SAntoine Tenart 139ec1a286SPaul Gortmaker #include <linux/init.h> 1448b6bce3SAntoine Tenart #include <linux/of_device.h> 1548b6bce3SAntoine Tenart #include <linux/platform_device.h> 1648b6bce3SAntoine Tenart #include <linux/regmap.h> 1748b6bce3SAntoine Tenart 1848b6bce3SAntoine Tenart #include "berlin.h" 1948b6bce3SAntoine Tenart 2048b6bce3SAntoine Tenart static const struct berlin_desc_group berlin2cd_soc_pinctrl_groups[] = { 2148b6bce3SAntoine Tenart /* G */ 223c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G0", 0x00, 0x3, 0x00, 2348b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x0, "jtag"), 2448b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), 2548b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x2, "led"), 2648b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x3, "pwm")), 273c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G1", 0x00, 0x3, 0x03, 2848b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 2948b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), 3048b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x6, "usb0_dbg"), 3148b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x7, "usb1_dbg")), 323c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G2", 0x00, 0x3, 0x06, 3348b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 3448b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), 3548b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x2, "fe"), 3648b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x3, "pll"), 3748b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x6, "usb0_dbg"), 3848b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x7, "usb1_dbg")), 393c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G3", 0x00, 0x3, 0x09, 4048b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 4148b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), 4248b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x2, "twsi2"), 4348b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x3, "pll"), 4448b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x4, "fe"), 4548b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x6, "usb0_dbg"), 4648b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x7, "usb1_dbg")), 473c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G4", 0x00, 0x3, 0x0c, 4848b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 4948b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), 5048b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x2, "twsi3"), 5148b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x3, "pll"), 5248b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x4, "pwm"), 5348b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x6, "usb0_dbg"), 5448b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x7, "usb1_dbg")), 553c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G5", 0x00, 0x3, 0x0f, 5648b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 5748b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), 5848b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x2, "twsi3"), 5948b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x3, "arc"), 6048b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x4, "pwm"), 6148b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x6, "usb0_dbg"), 6248b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x7, "usb1_dbg")), 633c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G6", 0x00, 0x3, 0x12, 6448b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x0, "uart0"), /* RX/TX */ 6548b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), 663c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G7", 0x00, 0x3, 0x15, 6748b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x0, "eddc"), 6848b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x1, "twsi1"), 6948b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x2, "gpio")), 703c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G8", 0x00, 0x3, 0x18, 712e89f4c3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS0n */ 7248b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), 733c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G9", 0x00, 0x3, 0x1b, 7448b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 752e89f4c3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x1, "spi1"), /* SS1n/SS2n */ 763c6531c7SThomas Hebb BERLIN_PINCTRL_FUNCTION(0x3, "twsi0")), 773c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G10", 0x00, 0x2, 0x1e, 782e89f4c3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* CLK */ 7948b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), 803c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G11", 0x04, 0x2, 0x00, 812e89f4c3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SDI/SDO */ 8248b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), 833c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G12", 0x04, 0x3, 0x02, 8448b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x0, "usb1"), 8548b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), 863c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G13", 0x04, 0x3, 0x05, 8748b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x0, "nand"), 8848b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x1, "usb0_dbg"), 8948b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x2, "usb1_dbg")), 903c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G14", 0x04, 0x1, 0x08, 9148b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x0, "nand"), 9248b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), 933c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G15", 0x04, 0x3, 0x09, 9448b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x0, "jtag"), 9548b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), 963c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G16", 0x04, 0x3, 0x0c, 9748b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 983c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G17", 0x04, 0x3, 0x0f, 9948b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1003c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G18", 0x04, 0x2, 0x12, 10148b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1023c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G19", 0x04, 0x2, 0x14, 10348b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1043c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G20", 0x04, 0x2, 0x16, 10548b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1063c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G21", 0x04, 0x3, 0x18, 10748b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1083c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G22", 0x04, 0x3, 0x1b, 10948b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1103c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G23", 0x08, 0x3, 0x00, 11148b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1123c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G24", 0x08, 0x2, 0x03, 11348b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1143c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G25", 0x08, 0x2, 0x05, 11548b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1163c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G26", 0x08, 0x1, 0x07, 11748b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1183c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G27", 0x08, 0x2, 0x08, 11948b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1203c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G28", 0x08, 0x3, 0x0a, 1213c6531c7SThomas Hebb BERLIN_PINCTRL_FUNCTION_UNKNOWN), 1223c6531c7SThomas Hebb BERLIN_PINCTRL_GROUP("G29", 0x08, 0x3, 0x0d, 12348b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 12448b6bce3SAntoine Tenart }; 12548b6bce3SAntoine Tenart 12648b6bce3SAntoine Tenart static const struct berlin_desc_group berlin2cd_sysmgr_pinctrl_groups[] = { 12748b6bce3SAntoine Tenart /* GSM */ 12848b6bce3SAntoine Tenart BERLIN_PINCTRL_GROUP("GSM0", 0x40, 0x2, 0x00, 12948b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 13048b6bce3SAntoine Tenart BERLIN_PINCTRL_GROUP("GSM1", 0x40, 0x2, 0x02, 13148b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 13248b6bce3SAntoine Tenart BERLIN_PINCTRL_GROUP("GSM2", 0x40, 0x2, 0x04, 13348b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 13448b6bce3SAntoine Tenart BERLIN_PINCTRL_GROUP("GSM3", 0x40, 0x2, 0x06, 13548b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 13648b6bce3SAntoine Tenart BERLIN_PINCTRL_GROUP("GSM4", 0x40, 0x2, 0x08, 13748b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 13848b6bce3SAntoine Tenart BERLIN_PINCTRL_GROUP("GSM5", 0x40, 0x2, 0x0a, 13948b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 14048b6bce3SAntoine Tenart BERLIN_PINCTRL_GROUP("GSM6", 0x40, 0x2, 0x0c, 14148b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 14248b6bce3SAntoine Tenart BERLIN_PINCTRL_GROUP("GSM7", 0x40, 0x1, 0x0e, 14348b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 14448b6bce3SAntoine Tenart BERLIN_PINCTRL_GROUP("GSM8", 0x40, 0x1, 0x0f, 14548b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 14648b6bce3SAntoine Tenart BERLIN_PINCTRL_GROUP("GSM9", 0x40, 0x1, 0x10, 14748b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 14848b6bce3SAntoine Tenart BERLIN_PINCTRL_GROUP("GSM10", 0x40, 0x1, 0x11, 14948b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 15048b6bce3SAntoine Tenart BERLIN_PINCTRL_GROUP("GSM11", 0x40, 0x1, 0x12, 15148b6bce3SAntoine Tenart BERLIN_PINCTRL_FUNCTION_UNKNOWN), 15248b6bce3SAntoine Tenart }; 15348b6bce3SAntoine Tenart 15448b6bce3SAntoine Tenart static const struct berlin_pinctrl_desc berlin2cd_soc_pinctrl_data = { 15548b6bce3SAntoine Tenart .groups = berlin2cd_soc_pinctrl_groups, 15648b6bce3SAntoine Tenart .ngroups = ARRAY_SIZE(berlin2cd_soc_pinctrl_groups), 15748b6bce3SAntoine Tenart }; 15848b6bce3SAntoine Tenart 15948b6bce3SAntoine Tenart static const struct berlin_pinctrl_desc berlin2cd_sysmgr_pinctrl_data = { 16048b6bce3SAntoine Tenart .groups = berlin2cd_sysmgr_pinctrl_groups, 16148b6bce3SAntoine Tenart .ngroups = ARRAY_SIZE(berlin2cd_sysmgr_pinctrl_groups), 16248b6bce3SAntoine Tenart }; 16348b6bce3SAntoine Tenart 16448b6bce3SAntoine Tenart static const struct of_device_id berlin2cd_pinctrl_match[] = { 16548b6bce3SAntoine Tenart { 166f52bf55cSAntoine Tenart .compatible = "marvell,berlin2cd-soc-pinctrl", 16748b6bce3SAntoine Tenart .data = &berlin2cd_soc_pinctrl_data 16848b6bce3SAntoine Tenart }, 16948b6bce3SAntoine Tenart { 170f52bf55cSAntoine Tenart .compatible = "marvell,berlin2cd-system-pinctrl", 17148b6bce3SAntoine Tenart .data = &berlin2cd_sysmgr_pinctrl_data 17248b6bce3SAntoine Tenart }, 17348b6bce3SAntoine Tenart {} 17448b6bce3SAntoine Tenart }; 17548b6bce3SAntoine Tenart 17648b6bce3SAntoine Tenart static int berlin2cd_pinctrl_probe(struct platform_device *pdev) 17748b6bce3SAntoine Tenart { 17848b6bce3SAntoine Tenart const struct of_device_id *match = 17948b6bce3SAntoine Tenart of_match_device(berlin2cd_pinctrl_match, &pdev->dev); 18048b6bce3SAntoine Tenart 18148b6bce3SAntoine Tenart return berlin_pinctrl_probe(pdev, match->data); 18248b6bce3SAntoine Tenart } 18348b6bce3SAntoine Tenart 18448b6bce3SAntoine Tenart static struct platform_driver berlin2cd_pinctrl_driver = { 18548b6bce3SAntoine Tenart .probe = berlin2cd_pinctrl_probe, 18648b6bce3SAntoine Tenart .driver = { 18748b6bce3SAntoine Tenart .name = "berlin-bg2cd-pinctrl", 18848b6bce3SAntoine Tenart .of_match_table = berlin2cd_pinctrl_match, 18948b6bce3SAntoine Tenart }, 19048b6bce3SAntoine Tenart }; 1919ec1a286SPaul Gortmaker builtin_platform_driver(berlin2cd_pinctrl_driver); 192