Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * Marvell Armada 370 pinctrl driver based on mvebu pinctrl core
0004  *
0005  * Copyright (C) 2012 Marvell
0006  *
0007  * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
0008  */
0009 
0010 #include <linux/err.h>
0011 #include <linux/init.h>
0012 #include <linux/io.h>
0013 #include <linux/platform_device.h>
0014 #include <linux/clk.h>
0015 #include <linux/of.h>
0016 #include <linux/of_device.h>
0017 #include <linux/pinctrl/pinctrl.h>
0018 
0019 #include "pinctrl-mvebu.h"
0020 
0021 static struct mvebu_mpp_mode mv88f6710_mpp_modes[] = {
0022     MPP_MODE(0,
0023        MPP_FUNCTION(0x0, "gpio", NULL),
0024        MPP_FUNCTION(0x1, "uart0", "rxd")),
0025     MPP_MODE(1,
0026        MPP_FUNCTION(0x0, "gpo", NULL),
0027        MPP_FUNCTION(0x1, "uart0", "txd")),
0028     MPP_MODE(2,
0029        MPP_FUNCTION(0x0, "gpio", NULL),
0030        MPP_FUNCTION(0x1, "i2c0", "sck"),
0031        MPP_FUNCTION(0x2, "uart0", "txd")),
0032     MPP_MODE(3,
0033        MPP_FUNCTION(0x0, "gpio", NULL),
0034        MPP_FUNCTION(0x1, "i2c0", "sda"),
0035        MPP_FUNCTION(0x2, "uart0", "rxd")),
0036     MPP_MODE(4,
0037        MPP_FUNCTION(0x0, "gpio", NULL),
0038        MPP_FUNCTION(0x1, "vdd", "cpu-pd")),
0039     MPP_MODE(5,
0040        MPP_FUNCTION(0x0, "gpo", NULL),
0041        MPP_FUNCTION(0x1, "ge0", "txclkout"),
0042        MPP_FUNCTION(0x2, "uart1", "txd"),
0043        MPP_FUNCTION(0x4, "spi1", "sck"),
0044        MPP_FUNCTION(0x5, "audio", "mclk")),
0045     MPP_MODE(6,
0046        MPP_FUNCTION(0x0, "gpio", NULL),
0047        MPP_FUNCTION(0x1, "ge0", "txd0"),
0048        MPP_FUNCTION(0x2, "sata0", "prsnt"),
0049        MPP_FUNCTION(0x4, "tdm", "rst"),
0050        MPP_FUNCTION(0x5, "audio", "sdo")),
0051     MPP_MODE(7,
0052        MPP_FUNCTION(0x0, "gpo", NULL),
0053        MPP_FUNCTION(0x1, "ge0", "txd1"),
0054        MPP_FUNCTION(0x4, "tdm", "dtx"),
0055        MPP_FUNCTION(0x5, "audio", "lrclk")),
0056     MPP_MODE(8,
0057        MPP_FUNCTION(0x0, "gpio", NULL),
0058        MPP_FUNCTION(0x1, "ge0", "txd2"),
0059        MPP_FUNCTION(0x2, "uart0", "rts"),
0060        MPP_FUNCTION(0x4, "tdm", "drx"),
0061        MPP_FUNCTION(0x5, "audio", "bclk")),
0062     MPP_MODE(9,
0063        MPP_FUNCTION(0x0, "gpo", NULL),
0064        MPP_FUNCTION(0x1, "ge0", "txd3"),
0065        MPP_FUNCTION(0x2, "uart1", "txd"),
0066        MPP_FUNCTION(0x3, "sd0", "clk"),
0067        MPP_FUNCTION(0x5, "audio", "spdifo")),
0068     MPP_MODE(10,
0069        MPP_FUNCTION(0x0, "gpio", NULL),
0070        MPP_FUNCTION(0x1, "ge0", "txctl"),
0071        MPP_FUNCTION(0x2, "uart0", "cts"),
0072        MPP_FUNCTION(0x4, "tdm", "fsync"),
0073        MPP_FUNCTION(0x5, "audio", "sdi")),
0074     MPP_MODE(11,
0075        MPP_FUNCTION(0x0, "gpio", NULL),
0076        MPP_FUNCTION(0x1, "ge0", "rxd0"),
0077        MPP_FUNCTION(0x2, "uart1", "rxd"),
0078        MPP_FUNCTION(0x3, "sd0", "cmd"),
0079        MPP_FUNCTION(0x4, "spi0", "cs1"),
0080        MPP_FUNCTION(0x5, "sata1", "prsnt"),
0081        MPP_FUNCTION(0x6, "spi1", "cs1")),
0082     MPP_MODE(12,
0083        MPP_FUNCTION(0x0, "gpio", NULL),
0084        MPP_FUNCTION(0x1, "ge0", "rxd1"),
0085        MPP_FUNCTION(0x2, "i2c1", "sda"),
0086        MPP_FUNCTION(0x3, "sd0", "d0"),
0087        MPP_FUNCTION(0x4, "spi1", "cs0"),
0088        MPP_FUNCTION(0x5, "audio", "spdifi")),
0089     MPP_MODE(13,
0090        MPP_FUNCTION(0x0, "gpio", NULL),
0091        MPP_FUNCTION(0x1, "ge0", "rxd2"),
0092        MPP_FUNCTION(0x2, "i2c1", "sck"),
0093        MPP_FUNCTION(0x3, "sd0", "d1"),
0094        MPP_FUNCTION(0x4, "tdm", "pclk"),
0095        MPP_FUNCTION(0x5, "audio", "rmclk")),
0096     MPP_MODE(14,
0097        MPP_FUNCTION(0x0, "gpio", NULL),
0098        MPP_FUNCTION(0x1, "ge0", "rxd3"),
0099        MPP_FUNCTION(0x2, "pcie", "clkreq0"),
0100        MPP_FUNCTION(0x3, "sd0", "d2"),
0101        MPP_FUNCTION(0x4, "spi1", "mosi"),
0102        MPP_FUNCTION(0x5, "spi0", "cs2")),
0103     MPP_MODE(15,
0104        MPP_FUNCTION(0x0, "gpio", NULL),
0105        MPP_FUNCTION(0x1, "ge0", "rxctl"),
0106        MPP_FUNCTION(0x2, "pcie", "clkreq1"),
0107        MPP_FUNCTION(0x3, "sd0", "d3"),
0108        MPP_FUNCTION(0x4, "spi1", "miso"),
0109        MPP_FUNCTION(0x5, "spi0", "cs3")),
0110     MPP_MODE(16,
0111        MPP_FUNCTION(0x0, "gpio", NULL),
0112        MPP_FUNCTION(0x1, "ge0", "rxclk"),
0113        MPP_FUNCTION(0x2, "uart1", "rxd"),
0114        MPP_FUNCTION(0x4, "tdm", "int"),
0115        MPP_FUNCTION(0x5, "audio", "extclk")),
0116     MPP_MODE(17,
0117        MPP_FUNCTION(0x0, "gpo", NULL),
0118        MPP_FUNCTION(0x1, "ge", "mdc")),
0119     MPP_MODE(18,
0120        MPP_FUNCTION(0x0, "gpio", NULL),
0121        MPP_FUNCTION(0x1, "ge", "mdio")),
0122     MPP_MODE(19,
0123        MPP_FUNCTION(0x0, "gpio", NULL),
0124        MPP_FUNCTION(0x1, "ge0", "txclk"),
0125        MPP_FUNCTION(0x2, "ge1", "txclkout"),
0126        MPP_FUNCTION(0x4, "tdm", "pclk")),
0127     MPP_MODE(20,
0128        MPP_FUNCTION(0x0, "gpo", NULL),
0129        MPP_FUNCTION(0x1, "ge0", "txd4"),
0130        MPP_FUNCTION(0x2, "ge1", "txd0")),
0131     MPP_MODE(21,
0132        MPP_FUNCTION(0x0, "gpo", NULL),
0133        MPP_FUNCTION(0x1, "ge0", "txd5"),
0134        MPP_FUNCTION(0x2, "ge1", "txd1"),
0135        MPP_FUNCTION(0x4, "uart1", "txd")),
0136     MPP_MODE(22,
0137        MPP_FUNCTION(0x0, "gpo", NULL),
0138        MPP_FUNCTION(0x1, "ge0", "txd6"),
0139        MPP_FUNCTION(0x2, "ge1", "txd2"),
0140        MPP_FUNCTION(0x4, "uart0", "rts")),
0141     MPP_MODE(23,
0142        MPP_FUNCTION(0x0, "gpo", NULL),
0143        MPP_FUNCTION(0x1, "ge0", "txd7"),
0144        MPP_FUNCTION(0x2, "ge1", "txd3"),
0145        MPP_FUNCTION(0x4, "spi1", "mosi")),
0146     MPP_MODE(24,
0147        MPP_FUNCTION(0x0, "gpio", NULL),
0148        MPP_FUNCTION(0x1, "ge0", "col"),
0149        MPP_FUNCTION(0x2, "ge1", "txctl"),
0150        MPP_FUNCTION(0x4, "spi1", "cs0")),
0151     MPP_MODE(25,
0152        MPP_FUNCTION(0x0, "gpio", NULL),
0153        MPP_FUNCTION(0x1, "ge0", "rxerr"),
0154        MPP_FUNCTION(0x2, "ge1", "rxd0"),
0155        MPP_FUNCTION(0x4, "uart1", "rxd")),
0156     MPP_MODE(26,
0157        MPP_FUNCTION(0x0, "gpio", NULL),
0158        MPP_FUNCTION(0x1, "ge0", "crs"),
0159        MPP_FUNCTION(0x2, "ge1", "rxd1"),
0160        MPP_FUNCTION(0x4, "spi1", "miso")),
0161     MPP_MODE(27,
0162        MPP_FUNCTION(0x0, "gpio", NULL),
0163        MPP_FUNCTION(0x1, "ge0", "rxd4"),
0164        MPP_FUNCTION(0x2, "ge1", "rxd2"),
0165        MPP_FUNCTION(0x4, "uart0", "cts")),
0166     MPP_MODE(28,
0167        MPP_FUNCTION(0x0, "gpio", NULL),
0168        MPP_FUNCTION(0x1, "ge0", "rxd5"),
0169        MPP_FUNCTION(0x2, "ge1", "rxd3")),
0170     MPP_MODE(29,
0171        MPP_FUNCTION(0x0, "gpio", NULL),
0172        MPP_FUNCTION(0x1, "ge0", "rxd6"),
0173        MPP_FUNCTION(0x2, "ge1", "rxctl"),
0174        MPP_FUNCTION(0x4, "i2c1", "sda")),
0175     MPP_MODE(30,
0176        MPP_FUNCTION(0x0, "gpio", NULL),
0177        MPP_FUNCTION(0x1, "ge0", "rxd7"),
0178        MPP_FUNCTION(0x2, "ge1", "rxclk"),
0179        MPP_FUNCTION(0x4, "i2c1", "sck")),
0180     MPP_MODE(31,
0181        MPP_FUNCTION(0x0, "gpio", NULL),
0182        MPP_FUNCTION(0x3, "tclk", NULL),
0183        MPP_FUNCTION(0x4, "ge0", "txerr")),
0184     MPP_MODE(32,
0185        MPP_FUNCTION(0x0, "gpio", NULL),
0186        MPP_FUNCTION(0x1, "spi0", "cs0")),
0187     MPP_MODE(33,
0188        MPP_FUNCTION(0x0, "gpio", NULL),
0189        MPP_FUNCTION(0x1, "dev", "bootcs"),
0190        MPP_FUNCTION(0x2, "spi0", "cs0")),
0191     MPP_MODE(34,
0192        MPP_FUNCTION(0x0, "gpo", NULL),
0193        MPP_FUNCTION(0x1, "dev", "we0"),
0194        MPP_FUNCTION(0x2, "spi0", "mosi")),
0195     MPP_MODE(35,
0196        MPP_FUNCTION(0x0, "gpo", NULL),
0197        MPP_FUNCTION(0x1, "dev", "oe"),
0198        MPP_FUNCTION(0x2, "spi0", "sck")),
0199     MPP_MODE(36,
0200        MPP_FUNCTION(0x0, "gpo", NULL),
0201        MPP_FUNCTION(0x1, "dev", "a1"),
0202        MPP_FUNCTION(0x2, "spi0", "miso")),
0203     MPP_MODE(37,
0204        MPP_FUNCTION(0x0, "gpo", NULL),
0205        MPP_FUNCTION(0x1, "dev", "a0"),
0206        MPP_FUNCTION(0x2, "sata0", "prsnt")),
0207     MPP_MODE(38,
0208        MPP_FUNCTION(0x0, "gpio", NULL),
0209        MPP_FUNCTION(0x1, "dev", "ready"),
0210        MPP_FUNCTION(0x2, "uart1", "cts"),
0211        MPP_FUNCTION(0x3, "uart0", "cts")),
0212     MPP_MODE(39,
0213        MPP_FUNCTION(0x0, "gpo", NULL),
0214        MPP_FUNCTION(0x1, "dev", "ad0"),
0215        MPP_FUNCTION(0x2, "audio", "spdifo")),
0216     MPP_MODE(40,
0217        MPP_FUNCTION(0x0, "gpio", NULL),
0218        MPP_FUNCTION(0x1, "dev", "ad1"),
0219        MPP_FUNCTION(0x2, "uart1", "rts"),
0220        MPP_FUNCTION(0x3, "uart0", "rts")),
0221     MPP_MODE(41,
0222        MPP_FUNCTION(0x0, "gpio", NULL),
0223        MPP_FUNCTION(0x1, "dev", "ad2"),
0224        MPP_FUNCTION(0x2, "uart1", "rxd")),
0225     MPP_MODE(42,
0226        MPP_FUNCTION(0x0, "gpo", NULL),
0227        MPP_FUNCTION(0x1, "dev", "ad3"),
0228        MPP_FUNCTION(0x2, "uart1", "txd")),
0229     MPP_MODE(43,
0230        MPP_FUNCTION(0x0, "gpo", NULL),
0231        MPP_FUNCTION(0x1, "dev", "ad4"),
0232        MPP_FUNCTION(0x2, "audio", "bclk")),
0233     MPP_MODE(44,
0234        MPP_FUNCTION(0x0, "gpo", NULL),
0235        MPP_FUNCTION(0x1, "dev", "ad5"),
0236        MPP_FUNCTION(0x2, "audio", "mclk")),
0237     MPP_MODE(45,
0238        MPP_FUNCTION(0x0, "gpo", NULL),
0239        MPP_FUNCTION(0x1, "dev", "ad6"),
0240        MPP_FUNCTION(0x2, "audio", "lrclk")),
0241     MPP_MODE(46,
0242        MPP_FUNCTION(0x0, "gpo", NULL),
0243        MPP_FUNCTION(0x1, "dev", "ad7"),
0244        MPP_FUNCTION(0x2, "audio", "sdo")),
0245     MPP_MODE(47,
0246        MPP_FUNCTION(0x0, "gpo", NULL),
0247        MPP_FUNCTION(0x1, "dev", "ad8"),
0248        MPP_FUNCTION(0x3, "sd0", "clk"),
0249        MPP_FUNCTION(0x5, "audio", "spdifo")),
0250     MPP_MODE(48,
0251        MPP_FUNCTION(0x0, "gpio", NULL),
0252        MPP_FUNCTION(0x1, "dev", "ad9"),
0253        MPP_FUNCTION(0x2, "uart0", "rts"),
0254        MPP_FUNCTION(0x3, "sd0", "cmd"),
0255        MPP_FUNCTION(0x4, "sata1", "prsnt"),
0256        MPP_FUNCTION(0x5, "spi0", "cs1")),
0257     MPP_MODE(49,
0258        MPP_FUNCTION(0x0, "gpio", NULL),
0259        MPP_FUNCTION(0x1, "dev", "ad10"),
0260        MPP_FUNCTION(0x2, "pcie", "clkreq1"),
0261        MPP_FUNCTION(0x3, "sd0", "d0"),
0262        MPP_FUNCTION(0x4, "spi1", "cs0"),
0263        MPP_FUNCTION(0x5, "audio", "spdifi")),
0264     MPP_MODE(50,
0265        MPP_FUNCTION(0x0, "gpio", NULL),
0266        MPP_FUNCTION(0x1, "dev", "ad11"),
0267        MPP_FUNCTION(0x2, "uart0", "cts"),
0268        MPP_FUNCTION(0x3, "sd0", "d1"),
0269        MPP_FUNCTION(0x4, "spi1", "miso"),
0270        MPP_FUNCTION(0x5, "audio", "rmclk")),
0271     MPP_MODE(51,
0272        MPP_FUNCTION(0x0, "gpio", NULL),
0273        MPP_FUNCTION(0x1, "dev", "ad12"),
0274        MPP_FUNCTION(0x2, "i2c1", "sda"),
0275        MPP_FUNCTION(0x3, "sd0", "d2"),
0276        MPP_FUNCTION(0x4, "spi1", "mosi")),
0277     MPP_MODE(52,
0278        MPP_FUNCTION(0x0, "gpio", NULL),
0279        MPP_FUNCTION(0x1, "dev", "ad13"),
0280        MPP_FUNCTION(0x2, "i2c1", "sck"),
0281        MPP_FUNCTION(0x3, "sd0", "d3"),
0282        MPP_FUNCTION(0x4, "spi1", "sck")),
0283     MPP_MODE(53,
0284        MPP_FUNCTION(0x0, "gpio", NULL),
0285        MPP_FUNCTION(0x1, "dev", "ad14"),
0286        MPP_FUNCTION(0x2, "sd0", "clk"),
0287        MPP_FUNCTION(0x3, "tdm", "pclk"),
0288        MPP_FUNCTION(0x4, "spi0", "cs2"),
0289        MPP_FUNCTION(0x5, "pcie", "clkreq1")),
0290     MPP_MODE(54,
0291        MPP_FUNCTION(0x0, "gpo", NULL),
0292        MPP_FUNCTION(0x1, "dev", "ad15"),
0293        MPP_FUNCTION(0x3, "tdm", "dtx")),
0294     MPP_MODE(55,
0295        MPP_FUNCTION(0x0, "gpio", NULL),
0296        MPP_FUNCTION(0x1, "dev", "cs1"),
0297        MPP_FUNCTION(0x2, "uart1", "txd"),
0298        MPP_FUNCTION(0x3, "tdm", "rst"),
0299        MPP_FUNCTION(0x4, "sata1", "prsnt"),
0300        MPP_FUNCTION(0x5, "sata0", "prsnt")),
0301     MPP_MODE(56,
0302        MPP_FUNCTION(0x0, "gpio", NULL),
0303        MPP_FUNCTION(0x1, "dev", "cs2"),
0304        MPP_FUNCTION(0x2, "uart1", "cts"),
0305        MPP_FUNCTION(0x3, "uart0", "cts"),
0306        MPP_FUNCTION(0x4, "spi0", "cs3"),
0307        MPP_FUNCTION(0x5, "pcie", "clkreq0"),
0308        MPP_FUNCTION(0x6, "spi1", "cs1")),
0309     MPP_MODE(57,
0310        MPP_FUNCTION(0x0, "gpio", NULL),
0311        MPP_FUNCTION(0x1, "dev", "cs3"),
0312        MPP_FUNCTION(0x2, "uart1", "rxd"),
0313        MPP_FUNCTION(0x3, "tdm", "fsync"),
0314        MPP_FUNCTION(0x4, "sata0", "prsnt"),
0315        MPP_FUNCTION(0x5, "audio", "sdo")),
0316     MPP_MODE(58,
0317        MPP_FUNCTION(0x0, "gpio", NULL),
0318        MPP_FUNCTION(0x1, "dev", "cs0"),
0319        MPP_FUNCTION(0x2, "uart1", "rts"),
0320        MPP_FUNCTION(0x3, "tdm", "int"),
0321        MPP_FUNCTION(0x5, "audio", "extclk"),
0322        MPP_FUNCTION(0x6, "uart0", "rts")),
0323     MPP_MODE(59,
0324        MPP_FUNCTION(0x0, "gpo", NULL),
0325        MPP_FUNCTION(0x1, "dev", "ale0"),
0326        MPP_FUNCTION(0x2, "uart1", "rts"),
0327        MPP_FUNCTION(0x3, "uart0", "rts"),
0328        MPP_FUNCTION(0x5, "audio", "bclk")),
0329     MPP_MODE(60,
0330        MPP_FUNCTION(0x0, "gpio", NULL),
0331        MPP_FUNCTION(0x1, "dev", "ale1"),
0332        MPP_FUNCTION(0x2, "uart1", "rxd"),
0333        MPP_FUNCTION(0x3, "sata0", "prsnt"),
0334        MPP_FUNCTION(0x4, "pcie", "rstout"),
0335        MPP_FUNCTION(0x5, "audio", "sdi")),
0336     MPP_MODE(61,
0337        MPP_FUNCTION(0x0, "gpo", NULL),
0338        MPP_FUNCTION(0x1, "dev", "we1"),
0339        MPP_FUNCTION(0x2, "uart1", "txd"),
0340        MPP_FUNCTION(0x5, "audio", "lrclk")),
0341     MPP_MODE(62,
0342        MPP_FUNCTION(0x0, "gpio", NULL),
0343        MPP_FUNCTION(0x1, "dev", "a2"),
0344        MPP_FUNCTION(0x2, "uart1", "cts"),
0345        MPP_FUNCTION(0x3, "tdm", "drx"),
0346        MPP_FUNCTION(0x4, "pcie", "clkreq0"),
0347        MPP_FUNCTION(0x5, "audio", "mclk"),
0348        MPP_FUNCTION(0x6, "uart0", "cts")),
0349     MPP_MODE(63,
0350        MPP_FUNCTION(0x0, "gpio", NULL),
0351        MPP_FUNCTION(0x1, "spi0", "sck"),
0352        MPP_FUNCTION(0x2, "tclk", NULL)),
0353     MPP_MODE(64,
0354        MPP_FUNCTION(0x0, "gpio", NULL),
0355        MPP_FUNCTION(0x1, "spi0", "miso"),
0356        MPP_FUNCTION(0x2, "spi0", "cs1")),
0357     MPP_MODE(65,
0358        MPP_FUNCTION(0x0, "gpio", NULL),
0359        MPP_FUNCTION(0x1, "spi0", "mosi"),
0360        MPP_FUNCTION(0x2, "spi0", "cs2")),
0361 };
0362 
0363 static struct mvebu_pinctrl_soc_info armada_370_pinctrl_info;
0364 
0365 static const struct of_device_id armada_370_pinctrl_of_match[] = {
0366     { .compatible = "marvell,mv88f6710-pinctrl" },
0367     { },
0368 };
0369 
0370 static const struct mvebu_mpp_ctrl mv88f6710_mpp_controls[] = {
0371     MPP_FUNC_CTRL(0, 65, NULL, mvebu_mmio_mpp_ctrl),
0372 };
0373 
0374 static struct pinctrl_gpio_range mv88f6710_mpp_gpio_ranges[] = {
0375     MPP_GPIO_RANGE(0,   0,  0, 32),
0376     MPP_GPIO_RANGE(1,  32, 32, 32),
0377     MPP_GPIO_RANGE(2,  64, 64,  2),
0378 };
0379 
0380 static int armada_370_pinctrl_probe(struct platform_device *pdev)
0381 {
0382     struct mvebu_pinctrl_soc_info *soc = &armada_370_pinctrl_info;
0383 
0384     soc->variant = 0; /* no variants for Armada 370 */
0385     soc->controls = mv88f6710_mpp_controls;
0386     soc->ncontrols = ARRAY_SIZE(mv88f6710_mpp_controls);
0387     soc->modes = mv88f6710_mpp_modes;
0388     soc->nmodes = ARRAY_SIZE(mv88f6710_mpp_modes);
0389     soc->gpioranges = mv88f6710_mpp_gpio_ranges;
0390     soc->ngpioranges = ARRAY_SIZE(mv88f6710_mpp_gpio_ranges);
0391 
0392     pdev->dev.platform_data = soc;
0393 
0394     return mvebu_pinctrl_simple_mmio_probe(pdev);
0395 }
0396 
0397 static struct platform_driver armada_370_pinctrl_driver = {
0398     .driver = {
0399         .name = "armada-370-pinctrl",
0400         .of_match_table = armada_370_pinctrl_of_match,
0401     },
0402     .probe = armada_370_pinctrl_probe,
0403 };
0404 builtin_platform_driver(armada_370_pinctrl_driver);