106763c74SThomas Petazzoni /* 206763c74SThomas Petazzoni * Marvell Dove pinctrl driver based on mvebu pinctrl core 306763c74SThomas Petazzoni * 406763c74SThomas Petazzoni * Author: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> 506763c74SThomas Petazzoni * 606763c74SThomas Petazzoni * This program is free software; you can redistribute it and/or modify 706763c74SThomas Petazzoni * it under the terms of the GNU General Public License as published by 806763c74SThomas Petazzoni * the Free Software Foundation; either version 2 of the License, or 906763c74SThomas Petazzoni * (at your option) any later version. 1006763c74SThomas Petazzoni */ 1106763c74SThomas Petazzoni 1206763c74SThomas Petazzoni #include <linux/err.h> 1306763c74SThomas Petazzoni #include <linux/init.h> 1406763c74SThomas Petazzoni #include <linux/io.h> 1506763c74SThomas Petazzoni #include <linux/module.h> 1606763c74SThomas Petazzoni #include <linux/bitops.h> 1706763c74SThomas Petazzoni #include <linux/platform_device.h> 1806763c74SThomas Petazzoni #include <linux/clk.h> 1906763c74SThomas Petazzoni #include <linux/of.h> 2006763c74SThomas Petazzoni #include <linux/of_device.h> 21e91f7916SSebastian Hesselbarth #include <linux/mfd/syscon.h> 2206763c74SThomas Petazzoni #include <linux/pinctrl/pinctrl.h> 23e91f7916SSebastian Hesselbarth #include <linux/regmap.h> 2406763c74SThomas Petazzoni 2506763c74SThomas Petazzoni #include "pinctrl-mvebu.h" 2606763c74SThomas Petazzoni 274d73fc77SSebastian Hesselbarth /* Internal registers can be configured at any 1 MiB aligned address */ 284d73fc77SSebastian Hesselbarth #define INT_REGS_MASK ~(SZ_1M - 1) 294d73fc77SSebastian Hesselbarth #define MPP4_REGS_OFFS 0xd0440 304d73fc77SSebastian Hesselbarth #define PMU_REGS_OFFS 0xd802c 31e91f7916SSebastian Hesselbarth #define GC_REGS_OFFS 0xe802c 324d73fc77SSebastian Hesselbarth 3378f9f3b1SSebastian Hesselbarth #define DOVE_SB_REGS_VIRT_BASE IOMEM(0xfde00000) 34bbd7b275SSebastian Hesselbarth #define DOVE_PMU_SIGNAL_SELECT_0 (DOVE_SB_REGS_VIRT_BASE + 0xd802C) 35bbd7b275SSebastian Hesselbarth #define DOVE_PMU_SIGNAL_SELECT_1 (DOVE_SB_REGS_VIRT_BASE + 0xd8030) 36bbd7b275SSebastian Hesselbarth #define DOVE_GLOBAL_CONFIG_1 (DOVE_SB_REGS_VIRT_BASE + 0xe802C) 3778f9f3b1SSebastian Hesselbarth #define DOVE_GLOBAL_CONFIG_1 (DOVE_SB_REGS_VIRT_BASE + 0xe802C) 3806763c74SThomas Petazzoni #define DOVE_TWSI_ENABLE_OPTION1 BIT(7) 3978f9f3b1SSebastian Hesselbarth #define DOVE_GLOBAL_CONFIG_2 (DOVE_SB_REGS_VIRT_BASE + 0xe8030) 4006763c74SThomas Petazzoni #define DOVE_TWSI_ENABLE_OPTION2 BIT(20) 4106763c74SThomas Petazzoni #define DOVE_TWSI_ENABLE_OPTION3 BIT(21) 4206763c74SThomas Petazzoni #define DOVE_TWSI_OPTION3_GPIO BIT(22) 4378f9f3b1SSebastian Hesselbarth #define DOVE_SSP_CTRL_STATUS_1 (DOVE_SB_REGS_VIRT_BASE + 0xe8034) 4406763c74SThomas Petazzoni #define DOVE_SSP_ON_AU1 BIT(0) 4578f9f3b1SSebastian Hesselbarth #define DOVE_MPP_GENERAL_VIRT_BASE (DOVE_SB_REGS_VIRT_BASE + 0xe803c) 4606763c74SThomas Petazzoni #define DOVE_AU1_SPDIFO_GPIO_EN BIT(1) 4706763c74SThomas Petazzoni #define DOVE_NAND_GPIO_EN BIT(0) 4878f9f3b1SSebastian Hesselbarth #define DOVE_GPIO_LO_VIRT_BASE (DOVE_SB_REGS_VIRT_BASE + 0xd0400) 4906763c74SThomas Petazzoni 5000202b01SSebastian Hesselbarth /* MPP Base registers */ 5100202b01SSebastian Hesselbarth #define PMU_MPP_GENERAL_CTRL 0x10 5200202b01SSebastian Hesselbarth #define AU0_AC97_SEL BIT(16) 5300202b01SSebastian Hesselbarth 54*2c4b229bSSebastian Hesselbarth /* MPP Control 4 register */ 55*2c4b229bSSebastian Hesselbarth #define SPI_GPIO_SEL BIT(5) 56*2c4b229bSSebastian Hesselbarth #define UART1_GPIO_SEL BIT(4) 57*2c4b229bSSebastian Hesselbarth #define AU1_GPIO_SEL BIT(3) 58*2c4b229bSSebastian Hesselbarth #define CAM_GPIO_SEL BIT(2) 59*2c4b229bSSebastian Hesselbarth #define SD1_GPIO_SEL BIT(1) 60*2c4b229bSSebastian Hesselbarth #define SD0_GPIO_SEL BIT(0) 61*2c4b229bSSebastian Hesselbarth 6206763c74SThomas Petazzoni #define CONFIG_PMU BIT(4) 6306763c74SThomas Petazzoni 6417bdec67SSebastian Hesselbarth static void __iomem *mpp_base; 654d73fc77SSebastian Hesselbarth static void __iomem *mpp4_base; 664d73fc77SSebastian Hesselbarth static void __iomem *pmu_base; 67e91f7916SSebastian Hesselbarth static struct regmap *gconfmap; 6817bdec67SSebastian Hesselbarth 6917bdec67SSebastian Hesselbarth static int dove_mpp_ctrl_get(unsigned pid, unsigned long *config) 7017bdec67SSebastian Hesselbarth { 7117bdec67SSebastian Hesselbarth return default_mpp_ctrl_get(mpp_base, pid, config); 7217bdec67SSebastian Hesselbarth } 7317bdec67SSebastian Hesselbarth 7417bdec67SSebastian Hesselbarth static int dove_mpp_ctrl_set(unsigned pid, unsigned long config) 7517bdec67SSebastian Hesselbarth { 7617bdec67SSebastian Hesselbarth return default_mpp_ctrl_set(mpp_base, pid, config); 7717bdec67SSebastian Hesselbarth } 7817bdec67SSebastian Hesselbarth 792035d39dSSebastian Hesselbarth static int dove_pmu_mpp_ctrl_get(unsigned pid, unsigned long *config) 8006763c74SThomas Petazzoni { 8117bdec67SSebastian Hesselbarth unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; 8217bdec67SSebastian Hesselbarth unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; 8300202b01SSebastian Hesselbarth unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL); 84bbd7b275SSebastian Hesselbarth unsigned long func; 8506763c74SThomas Petazzoni 8678c2c3d3SSebastian Hesselbarth if ((pmu & BIT(pid)) == 0) 8778c2c3d3SSebastian Hesselbarth return default_mpp_ctrl_get(mpp_base, pid, config); 8878c2c3d3SSebastian Hesselbarth 89bbd7b275SSebastian Hesselbarth func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); 9017bdec67SSebastian Hesselbarth *config = (func >> shift) & MVEBU_MPP_MASK; 91bbd7b275SSebastian Hesselbarth *config |= CONFIG_PMU; 9278c2c3d3SSebastian Hesselbarth 9306763c74SThomas Petazzoni return 0; 9406763c74SThomas Petazzoni } 9506763c74SThomas Petazzoni 962035d39dSSebastian Hesselbarth static int dove_pmu_mpp_ctrl_set(unsigned pid, unsigned long config) 9706763c74SThomas Petazzoni { 9817bdec67SSebastian Hesselbarth unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; 9917bdec67SSebastian Hesselbarth unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; 10000202b01SSebastian Hesselbarth unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL); 101bbd7b275SSebastian Hesselbarth unsigned long func; 10206763c74SThomas Petazzoni 10378c2c3d3SSebastian Hesselbarth if ((config & CONFIG_PMU) == 0) { 10400202b01SSebastian Hesselbarth writel(pmu & ~BIT(pid), mpp_base + PMU_MPP_GENERAL_CTRL); 10578c2c3d3SSebastian Hesselbarth return default_mpp_ctrl_set(mpp_base, pid, config); 10678c2c3d3SSebastian Hesselbarth } 10778c2c3d3SSebastian Hesselbarth 10800202b01SSebastian Hesselbarth writel(pmu | BIT(pid), mpp_base + PMU_MPP_GENERAL_CTRL); 109bbd7b275SSebastian Hesselbarth func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); 11017bdec67SSebastian Hesselbarth func &= ~(MVEBU_MPP_MASK << shift); 11117bdec67SSebastian Hesselbarth func |= (config & MVEBU_MPP_MASK) << shift; 112bbd7b275SSebastian Hesselbarth writel(func, DOVE_PMU_SIGNAL_SELECT_0 + off); 11378c2c3d3SSebastian Hesselbarth 11406763c74SThomas Petazzoni return 0; 11506763c74SThomas Petazzoni } 11606763c74SThomas Petazzoni 1172035d39dSSebastian Hesselbarth static int dove_mpp4_ctrl_get(unsigned pid, unsigned long *config) 11806763c74SThomas Petazzoni { 119*2c4b229bSSebastian Hesselbarth unsigned long mpp4 = readl(mpp4_base); 12006763c74SThomas Petazzoni unsigned long mask; 12106763c74SThomas Petazzoni 1222035d39dSSebastian Hesselbarth switch (pid) { 12306763c74SThomas Petazzoni case 24: /* mpp_camera */ 124*2c4b229bSSebastian Hesselbarth mask = CAM_GPIO_SEL; 12506763c74SThomas Petazzoni break; 12606763c74SThomas Petazzoni case 40: /* mpp_sdio0 */ 127*2c4b229bSSebastian Hesselbarth mask = SD0_GPIO_SEL; 12806763c74SThomas Petazzoni break; 12906763c74SThomas Petazzoni case 46: /* mpp_sdio1 */ 130*2c4b229bSSebastian Hesselbarth mask = SD1_GPIO_SEL; 13106763c74SThomas Petazzoni break; 13206763c74SThomas Petazzoni case 58: /* mpp_spi0 */ 133*2c4b229bSSebastian Hesselbarth mask = SPI_GPIO_SEL; 13406763c74SThomas Petazzoni break; 13506763c74SThomas Petazzoni case 62: /* mpp_uart1 */ 136*2c4b229bSSebastian Hesselbarth mask = UART1_GPIO_SEL; 13706763c74SThomas Petazzoni break; 13806763c74SThomas Petazzoni default: 13906763c74SThomas Petazzoni return -EINVAL; 14006763c74SThomas Petazzoni } 14106763c74SThomas Petazzoni 14206763c74SThomas Petazzoni *config = ((mpp4 & mask) != 0); 14306763c74SThomas Petazzoni 14406763c74SThomas Petazzoni return 0; 14506763c74SThomas Petazzoni } 14606763c74SThomas Petazzoni 1472035d39dSSebastian Hesselbarth static int dove_mpp4_ctrl_set(unsigned pid, unsigned long config) 14806763c74SThomas Petazzoni { 149*2c4b229bSSebastian Hesselbarth unsigned long mpp4 = readl(mpp4_base); 15006763c74SThomas Petazzoni unsigned long mask; 15106763c74SThomas Petazzoni 1522035d39dSSebastian Hesselbarth switch (pid) { 15306763c74SThomas Petazzoni case 24: /* mpp_camera */ 154*2c4b229bSSebastian Hesselbarth mask = CAM_GPIO_SEL; 15506763c74SThomas Petazzoni break; 15606763c74SThomas Petazzoni case 40: /* mpp_sdio0 */ 157*2c4b229bSSebastian Hesselbarth mask = SD0_GPIO_SEL; 15806763c74SThomas Petazzoni break; 15906763c74SThomas Petazzoni case 46: /* mpp_sdio1 */ 160*2c4b229bSSebastian Hesselbarth mask = SD1_GPIO_SEL; 16106763c74SThomas Petazzoni break; 16206763c74SThomas Petazzoni case 58: /* mpp_spi0 */ 163*2c4b229bSSebastian Hesselbarth mask = SPI_GPIO_SEL; 16406763c74SThomas Petazzoni break; 16506763c74SThomas Petazzoni case 62: /* mpp_uart1 */ 166*2c4b229bSSebastian Hesselbarth mask = UART1_GPIO_SEL; 16706763c74SThomas Petazzoni break; 16806763c74SThomas Petazzoni default: 16906763c74SThomas Petazzoni return -EINVAL; 17006763c74SThomas Petazzoni } 17106763c74SThomas Petazzoni 17206763c74SThomas Petazzoni mpp4 &= ~mask; 17306763c74SThomas Petazzoni if (config) 17406763c74SThomas Petazzoni mpp4 |= mask; 17506763c74SThomas Petazzoni 176*2c4b229bSSebastian Hesselbarth writel(mpp4, mpp4_base); 17706763c74SThomas Petazzoni 17806763c74SThomas Petazzoni return 0; 17906763c74SThomas Petazzoni } 18006763c74SThomas Petazzoni 1812035d39dSSebastian Hesselbarth static int dove_nand_ctrl_get(unsigned pid, unsigned long *config) 18206763c74SThomas Petazzoni { 18306763c74SThomas Petazzoni unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE); 18406763c74SThomas Petazzoni 18506763c74SThomas Petazzoni *config = ((gmpp & DOVE_NAND_GPIO_EN) != 0); 18606763c74SThomas Petazzoni 18706763c74SThomas Petazzoni return 0; 18806763c74SThomas Petazzoni } 18906763c74SThomas Petazzoni 1902035d39dSSebastian Hesselbarth static int dove_nand_ctrl_set(unsigned pid, unsigned long config) 19106763c74SThomas Petazzoni { 19206763c74SThomas Petazzoni unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE); 19306763c74SThomas Petazzoni 19406763c74SThomas Petazzoni gmpp &= ~DOVE_NAND_GPIO_EN; 19506763c74SThomas Petazzoni if (config) 19606763c74SThomas Petazzoni gmpp |= DOVE_NAND_GPIO_EN; 19706763c74SThomas Petazzoni 19806763c74SThomas Petazzoni writel(gmpp, DOVE_MPP_GENERAL_VIRT_BASE); 19906763c74SThomas Petazzoni 20006763c74SThomas Petazzoni return 0; 20106763c74SThomas Petazzoni } 20206763c74SThomas Petazzoni 2032035d39dSSebastian Hesselbarth static int dove_audio0_ctrl_get(unsigned pid, unsigned long *config) 20406763c74SThomas Petazzoni { 20500202b01SSebastian Hesselbarth unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL); 20606763c74SThomas Petazzoni 20700202b01SSebastian Hesselbarth *config = ((pmu & AU0_AC97_SEL) != 0); 20806763c74SThomas Petazzoni 20906763c74SThomas Petazzoni return 0; 21006763c74SThomas Petazzoni } 21106763c74SThomas Petazzoni 2122035d39dSSebastian Hesselbarth static int dove_audio0_ctrl_set(unsigned pid, unsigned long config) 21306763c74SThomas Petazzoni { 21400202b01SSebastian Hesselbarth unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL); 21506763c74SThomas Petazzoni 21600202b01SSebastian Hesselbarth pmu &= ~AU0_AC97_SEL; 21706763c74SThomas Petazzoni if (config) 21800202b01SSebastian Hesselbarth pmu |= AU0_AC97_SEL; 21900202b01SSebastian Hesselbarth writel(pmu, mpp_base + PMU_MPP_GENERAL_CTRL); 22006763c74SThomas Petazzoni 22106763c74SThomas Petazzoni return 0; 22206763c74SThomas Petazzoni } 22306763c74SThomas Petazzoni 2242035d39dSSebastian Hesselbarth static int dove_audio1_ctrl_get(unsigned pid, unsigned long *config) 22506763c74SThomas Petazzoni { 226*2c4b229bSSebastian Hesselbarth unsigned int mpp4 = readl(mpp4_base); 22706763c74SThomas Petazzoni unsigned long sspc1 = readl(DOVE_SSP_CTRL_STATUS_1); 22806763c74SThomas Petazzoni unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE); 22906763c74SThomas Petazzoni unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2); 23006763c74SThomas Petazzoni 23106763c74SThomas Petazzoni *config = 0; 232*2c4b229bSSebastian Hesselbarth if (mpp4 & AU1_GPIO_SEL) 23306763c74SThomas Petazzoni *config |= BIT(3); 23406763c74SThomas Petazzoni if (sspc1 & DOVE_SSP_ON_AU1) 23506763c74SThomas Petazzoni *config |= BIT(2); 23606763c74SThomas Petazzoni if (gmpp & DOVE_AU1_SPDIFO_GPIO_EN) 23706763c74SThomas Petazzoni *config |= BIT(1); 23806763c74SThomas Petazzoni if (gcfg2 & DOVE_TWSI_OPTION3_GPIO) 23906763c74SThomas Petazzoni *config |= BIT(0); 24006763c74SThomas Petazzoni 24106763c74SThomas Petazzoni /* SSP/TWSI only if I2S1 not set*/ 24206763c74SThomas Petazzoni if ((*config & BIT(3)) == 0) 24306763c74SThomas Petazzoni *config &= ~(BIT(2) | BIT(0)); 24406763c74SThomas Petazzoni /* TWSI only if SPDIFO not set*/ 24506763c74SThomas Petazzoni if ((*config & BIT(1)) == 0) 24606763c74SThomas Petazzoni *config &= ~BIT(0); 24706763c74SThomas Petazzoni return 0; 24806763c74SThomas Petazzoni } 24906763c74SThomas Petazzoni 2502035d39dSSebastian Hesselbarth static int dove_audio1_ctrl_set(unsigned pid, unsigned long config) 25106763c74SThomas Petazzoni { 252*2c4b229bSSebastian Hesselbarth unsigned int mpp4 = readl(mpp4_base); 25306763c74SThomas Petazzoni unsigned long sspc1 = readl(DOVE_SSP_CTRL_STATUS_1); 25406763c74SThomas Petazzoni unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE); 25506763c74SThomas Petazzoni unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2); 25606763c74SThomas Petazzoni 25763ace077SAxel Lin /* 25863ace077SAxel Lin * clear all audio1 related bits before configure 25963ace077SAxel Lin */ 26063ace077SAxel Lin gcfg2 &= ~DOVE_TWSI_OPTION3_GPIO; 26163ace077SAxel Lin gmpp &= ~DOVE_AU1_SPDIFO_GPIO_EN; 26263ace077SAxel Lin sspc1 &= ~DOVE_SSP_ON_AU1; 263*2c4b229bSSebastian Hesselbarth mpp4 &= ~AU1_GPIO_SEL; 26463ace077SAxel Lin 26506763c74SThomas Petazzoni if (config & BIT(0)) 26606763c74SThomas Petazzoni gcfg2 |= DOVE_TWSI_OPTION3_GPIO; 26706763c74SThomas Petazzoni if (config & BIT(1)) 26806763c74SThomas Petazzoni gmpp |= DOVE_AU1_SPDIFO_GPIO_EN; 26906763c74SThomas Petazzoni if (config & BIT(2)) 27006763c74SThomas Petazzoni sspc1 |= DOVE_SSP_ON_AU1; 27106763c74SThomas Petazzoni if (config & BIT(3)) 272*2c4b229bSSebastian Hesselbarth mpp4 |= AU1_GPIO_SEL; 27306763c74SThomas Petazzoni 274*2c4b229bSSebastian Hesselbarth writel(mpp4, mpp4_base); 27506763c74SThomas Petazzoni writel(sspc1, DOVE_SSP_CTRL_STATUS_1); 27606763c74SThomas Petazzoni writel(gmpp, DOVE_MPP_GENERAL_VIRT_BASE); 27706763c74SThomas Petazzoni writel(gcfg2, DOVE_GLOBAL_CONFIG_2); 27806763c74SThomas Petazzoni 27906763c74SThomas Petazzoni return 0; 28006763c74SThomas Petazzoni } 28106763c74SThomas Petazzoni 28206763c74SThomas Petazzoni /* mpp[52:57] gpio pins depend heavily on current config; 28306763c74SThomas Petazzoni * gpio_req does not try to mux in gpio capabilities to not 28406763c74SThomas Petazzoni * break other functions. If you require all mpps as gpio 28506763c74SThomas Petazzoni * enforce gpio setting by pinctrl mapping. 28606763c74SThomas Petazzoni */ 2872035d39dSSebastian Hesselbarth static int dove_audio1_ctrl_gpio_req(unsigned pid) 28806763c74SThomas Petazzoni { 28906763c74SThomas Petazzoni unsigned long config; 29006763c74SThomas Petazzoni 2912035d39dSSebastian Hesselbarth dove_audio1_ctrl_get(pid, &config); 29206763c74SThomas Petazzoni 29306763c74SThomas Petazzoni switch (config) { 29406763c74SThomas Petazzoni case 0x02: /* i2s1 : gpio[56:57] */ 29506763c74SThomas Petazzoni case 0x0e: /* ssp : gpio[56:57] */ 29606763c74SThomas Petazzoni if (pid >= 56) 29706763c74SThomas Petazzoni return 0; 29806763c74SThomas Petazzoni return -ENOTSUPP; 29906763c74SThomas Petazzoni case 0x08: /* spdifo : gpio[52:55] */ 30006763c74SThomas Petazzoni case 0x0b: /* twsi : gpio[52:55] */ 30106763c74SThomas Petazzoni if (pid <= 55) 30206763c74SThomas Petazzoni return 0; 30306763c74SThomas Petazzoni return -ENOTSUPP; 30406763c74SThomas Petazzoni case 0x0a: /* all gpio */ 30506763c74SThomas Petazzoni return 0; 30606763c74SThomas Petazzoni /* 0x00 : i2s1/spdifo : no gpio */ 30706763c74SThomas Petazzoni /* 0x0c : ssp/spdifo : no gpio */ 30806763c74SThomas Petazzoni /* 0x0f : ssp/twsi : no gpio */ 30906763c74SThomas Petazzoni } 31006763c74SThomas Petazzoni return -ENOTSUPP; 31106763c74SThomas Petazzoni } 31206763c74SThomas Petazzoni 31306763c74SThomas Petazzoni /* mpp[52:57] has gpio pins capable of in and out */ 3142035d39dSSebastian Hesselbarth static int dove_audio1_ctrl_gpio_dir(unsigned pid, bool input) 31506763c74SThomas Petazzoni { 31606763c74SThomas Petazzoni if (pid < 52 || pid > 57) 31706763c74SThomas Petazzoni return -ENOTSUPP; 31806763c74SThomas Petazzoni return 0; 31906763c74SThomas Petazzoni } 32006763c74SThomas Petazzoni 3212035d39dSSebastian Hesselbarth static int dove_twsi_ctrl_get(unsigned pid, unsigned long *config) 32206763c74SThomas Petazzoni { 32306763c74SThomas Petazzoni unsigned long gcfg1 = readl(DOVE_GLOBAL_CONFIG_1); 32406763c74SThomas Petazzoni unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2); 32506763c74SThomas Petazzoni 32606763c74SThomas Petazzoni *config = 0; 32706763c74SThomas Petazzoni if (gcfg1 & DOVE_TWSI_ENABLE_OPTION1) 32806763c74SThomas Petazzoni *config = 1; 32906763c74SThomas Petazzoni else if (gcfg2 & DOVE_TWSI_ENABLE_OPTION2) 33006763c74SThomas Petazzoni *config = 2; 33106763c74SThomas Petazzoni else if (gcfg2 & DOVE_TWSI_ENABLE_OPTION3) 33206763c74SThomas Petazzoni *config = 3; 33306763c74SThomas Petazzoni 33406763c74SThomas Petazzoni return 0; 33506763c74SThomas Petazzoni } 33606763c74SThomas Petazzoni 3372035d39dSSebastian Hesselbarth static int dove_twsi_ctrl_set(unsigned pid, unsigned long config) 33806763c74SThomas Petazzoni { 33906763c74SThomas Petazzoni unsigned long gcfg1 = readl(DOVE_GLOBAL_CONFIG_1); 34006763c74SThomas Petazzoni unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2); 34106763c74SThomas Petazzoni 34206763c74SThomas Petazzoni gcfg1 &= ~DOVE_TWSI_ENABLE_OPTION1; 3436d0a4ed2SRoel Kluin gcfg2 &= ~(DOVE_TWSI_ENABLE_OPTION2 | DOVE_TWSI_ENABLE_OPTION3); 34406763c74SThomas Petazzoni 34506763c74SThomas Petazzoni switch (config) { 34606763c74SThomas Petazzoni case 1: 34706763c74SThomas Petazzoni gcfg1 |= DOVE_TWSI_ENABLE_OPTION1; 34806763c74SThomas Petazzoni break; 34906763c74SThomas Petazzoni case 2: 35006763c74SThomas Petazzoni gcfg2 |= DOVE_TWSI_ENABLE_OPTION2; 35106763c74SThomas Petazzoni break; 35206763c74SThomas Petazzoni case 3: 35306763c74SThomas Petazzoni gcfg2 |= DOVE_TWSI_ENABLE_OPTION3; 35406763c74SThomas Petazzoni break; 35506763c74SThomas Petazzoni } 35606763c74SThomas Petazzoni 35706763c74SThomas Petazzoni writel(gcfg1, DOVE_GLOBAL_CONFIG_1); 35806763c74SThomas Petazzoni writel(gcfg2, DOVE_GLOBAL_CONFIG_2); 35906763c74SThomas Petazzoni 36006763c74SThomas Petazzoni return 0; 36106763c74SThomas Petazzoni } 36206763c74SThomas Petazzoni 36306763c74SThomas Petazzoni static struct mvebu_mpp_ctrl dove_mpp_controls[] = { 364c2f082feSSebastian Hesselbarth MPP_FUNC_CTRL(0, 15, NULL, dove_pmu_mpp_ctrl), 3651217b790SSebastian Hesselbarth MPP_FUNC_CTRL(16, 23, NULL, dove_mpp_ctrl), 36606763c74SThomas Petazzoni MPP_FUNC_CTRL(24, 39, "mpp_camera", dove_mpp4_ctrl), 36706763c74SThomas Petazzoni MPP_FUNC_CTRL(40, 45, "mpp_sdio0", dove_mpp4_ctrl), 36806763c74SThomas Petazzoni MPP_FUNC_CTRL(46, 51, "mpp_sdio1", dove_mpp4_ctrl), 36906763c74SThomas Petazzoni MPP_FUNC_GPIO_CTRL(52, 57, "mpp_audio1", dove_audio1_ctrl), 37006763c74SThomas Petazzoni MPP_FUNC_CTRL(58, 61, "mpp_spi0", dove_mpp4_ctrl), 37106763c74SThomas Petazzoni MPP_FUNC_CTRL(62, 63, "mpp_uart1", dove_mpp4_ctrl), 37206763c74SThomas Petazzoni MPP_FUNC_CTRL(64, 71, "mpp_nand", dove_nand_ctrl), 37306763c74SThomas Petazzoni MPP_FUNC_CTRL(72, 72, "audio0", dove_audio0_ctrl), 37406763c74SThomas Petazzoni MPP_FUNC_CTRL(73, 73, "twsi", dove_twsi_ctrl), 37506763c74SThomas Petazzoni }; 37606763c74SThomas Petazzoni 37706763c74SThomas Petazzoni static struct mvebu_mpp_mode dove_mpp_modes[] = { 37806763c74SThomas Petazzoni MPP_MODE(0, 37906763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 38006763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "rts"), 38106763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "cd"), 38206763c74SThomas Petazzoni MPP_FUNCTION(0x0f, "lcd0", "pwm"), 383bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 384bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 385bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 386bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 387bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 388bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 389bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 390bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 391bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 392bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 393bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 394bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 39506763c74SThomas Petazzoni MPP_MODE(1, 39606763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 39706763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "cts"), 39806763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "wp"), 39906763c74SThomas Petazzoni MPP_FUNCTION(0x0f, "lcd1", "pwm"), 400bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 401bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 402bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 403bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 404bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 405bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 406bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 407bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 408bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 409bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 410bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 411bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 41206763c74SThomas Petazzoni MPP_MODE(2, 41306763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 41406763c74SThomas Petazzoni MPP_FUNCTION(0x01, "sata", "prsnt"), 41506763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "txd"), 41606763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "buspwr"), 41706763c74SThomas Petazzoni MPP_FUNCTION(0x04, "uart1", "rts"), 418bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 419bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 420bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 421bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 422bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 423bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 424bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 425bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 426bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 427bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 428bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 429bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 43006763c74SThomas Petazzoni MPP_MODE(3, 43106763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 43206763c74SThomas Petazzoni MPP_FUNCTION(0x01, "sata", "act"), 43306763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "rxd"), 43406763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "ledctrl"), 43506763c74SThomas Petazzoni MPP_FUNCTION(0x04, "uart1", "cts"), 43606763c74SThomas Petazzoni MPP_FUNCTION(0x0f, "lcd-spi", "cs1"), 437bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 438bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 439bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 440bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 441bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 442bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 443bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 444bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 445bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 446bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 447bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 448bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 44906763c74SThomas Petazzoni MPP_MODE(4, 45006763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 45106763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "rts"), 45206763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "cd"), 45306763c74SThomas Petazzoni MPP_FUNCTION(0x04, "spi1", "miso"), 454bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 455bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 456bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 457bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 458bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 459bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 460bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 461bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 462bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 463bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 464bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 465bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 46606763c74SThomas Petazzoni MPP_MODE(5, 46706763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 46806763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "cts"), 46906763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "wp"), 47006763c74SThomas Petazzoni MPP_FUNCTION(0x04, "spi1", "cs"), 471bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 472bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 473bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 474bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 475bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 476bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 477bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 478bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 479bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 480bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 481bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 482bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 48306763c74SThomas Petazzoni MPP_MODE(6, 48406763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 48506763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "txd"), 48606763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "buspwr"), 48706763c74SThomas Petazzoni MPP_FUNCTION(0x04, "spi1", "mosi"), 488bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 489bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 490bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 491bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 492bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 493bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 494bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 495bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 496bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 497bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 498bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 499bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 50006763c74SThomas Petazzoni MPP_MODE(7, 50106763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 50206763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "rxd"), 50306763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "ledctrl"), 50406763c74SThomas Petazzoni MPP_FUNCTION(0x04, "spi1", "sck"), 505bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 506bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 507bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 508bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 509bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 510bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 511bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 512bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 513bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 514bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 515bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 516bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 51706763c74SThomas Petazzoni MPP_MODE(8, 51806763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 51906763c74SThomas Petazzoni MPP_FUNCTION(0x01, "watchdog", "rstout"), 520bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 521bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 522bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 523bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 524bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 525bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 526bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 527bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 528bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 529bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 530bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 531bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 53206763c74SThomas Petazzoni MPP_MODE(9, 53306763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 53406763c74SThomas Petazzoni MPP_FUNCTION(0x05, "pex1", "clkreq"), 535bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 536bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 537bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 538bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 539bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 540bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 541bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 542bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 543bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 544bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 545bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 546bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 54706763c74SThomas Petazzoni MPP_MODE(10, 54806763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 54906763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ssp", "sclk"), 550bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 551bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 552bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 553bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 554bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 555bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 556bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 557bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 558bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 559bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 560bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 561bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 56206763c74SThomas Petazzoni MPP_MODE(11, 56306763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 56406763c74SThomas Petazzoni MPP_FUNCTION(0x01, "sata", "prsnt"), 56506763c74SThomas Petazzoni MPP_FUNCTION(0x02, "sata-1", "act"), 56606763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "ledctrl"), 56706763c74SThomas Petazzoni MPP_FUNCTION(0x04, "sdio1", "ledctrl"), 56806763c74SThomas Petazzoni MPP_FUNCTION(0x05, "pex0", "clkreq"), 569bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 570bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 571bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 572bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 573bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 574bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 575bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 576bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 577bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 578bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 579bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 580bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 58106763c74SThomas Petazzoni MPP_MODE(12, 58206763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 58306763c74SThomas Petazzoni MPP_FUNCTION(0x01, "sata", "act"), 58406763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "rts"), 58506763c74SThomas Petazzoni MPP_FUNCTION(0x03, "audio0", "extclk"), 58606763c74SThomas Petazzoni MPP_FUNCTION(0x04, "sdio1", "cd"), 587bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 588bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 589bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 590bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 591bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 592bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 593bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 594bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 595bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 596bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 597bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 598bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 59906763c74SThomas Petazzoni MPP_MODE(13, 60006763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 60106763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "cts"), 60206763c74SThomas Petazzoni MPP_FUNCTION(0x03, "audio1", "extclk"), 60306763c74SThomas Petazzoni MPP_FUNCTION(0x04, "sdio1", "wp"), 60406763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ssp", "extclk"), 605bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 606bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 607bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 608bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 609bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 610bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 611bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 612bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 613bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 614bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 615bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 616bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 61706763c74SThomas Petazzoni MPP_MODE(14, 61806763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 61906763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "txd"), 62006763c74SThomas Petazzoni MPP_FUNCTION(0x04, "sdio1", "buspwr"), 62106763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ssp", "rxd"), 622bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 623bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 624bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 625bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 626bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 627bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 628bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 629bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 630bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 631bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 632bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 633bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 63406763c74SThomas Petazzoni MPP_MODE(15, 63506763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 63606763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "rxd"), 63706763c74SThomas Petazzoni MPP_FUNCTION(0x04, "sdio1", "ledctrl"), 63806763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ssp", "sfrm"), 639bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 640bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 641bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 642bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 643bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 644bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 645bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 646bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 647bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 648bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 649bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 650bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 65106763c74SThomas Petazzoni MPP_MODE(16, 65206763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 65306763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "rts"), 65406763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "cd"), 65506763c74SThomas Petazzoni MPP_FUNCTION(0x04, "lcd-spi", "cs1"), 65606763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ac97", "sdi1")), 65706763c74SThomas Petazzoni MPP_MODE(17, 65806763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 65906763c74SThomas Petazzoni MPP_FUNCTION(0x01, "ac97-1", "sysclko"), 66006763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "cts"), 66106763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "wp"), 66206763c74SThomas Petazzoni MPP_FUNCTION(0x04, "twsi", "sda"), 66306763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ac97", "sdi2")), 66406763c74SThomas Petazzoni MPP_MODE(18, 66506763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 66606763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "txd"), 66706763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "buspwr"), 66806763c74SThomas Petazzoni MPP_FUNCTION(0x04, "lcd0", "pwm"), 66906763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ac97", "sdi3")), 67006763c74SThomas Petazzoni MPP_MODE(19, 67106763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 67206763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "rxd"), 67306763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "ledctrl"), 67406763c74SThomas Petazzoni MPP_FUNCTION(0x04, "twsi", "sck")), 67506763c74SThomas Petazzoni MPP_MODE(20, 67606763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 67706763c74SThomas Petazzoni MPP_FUNCTION(0x01, "ac97", "sysclko"), 67806763c74SThomas Petazzoni MPP_FUNCTION(0x02, "lcd-spi", "miso"), 67906763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "cd"), 68006763c74SThomas Petazzoni MPP_FUNCTION(0x05, "sdio0", "cd"), 68106763c74SThomas Petazzoni MPP_FUNCTION(0x06, "spi1", "miso")), 68206763c74SThomas Petazzoni MPP_MODE(21, 68306763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 68406763c74SThomas Petazzoni MPP_FUNCTION(0x01, "uart1", "rts"), 68506763c74SThomas Petazzoni MPP_FUNCTION(0x02, "lcd-spi", "cs0"), 68606763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "wp"), 68706763c74SThomas Petazzoni MPP_FUNCTION(0x04, "ssp", "sfrm"), 68806763c74SThomas Petazzoni MPP_FUNCTION(0x05, "sdio0", "wp"), 68906763c74SThomas Petazzoni MPP_FUNCTION(0x06, "spi1", "cs")), 69006763c74SThomas Petazzoni MPP_MODE(22, 69106763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 69206763c74SThomas Petazzoni MPP_FUNCTION(0x01, "uart1", "cts"), 69306763c74SThomas Petazzoni MPP_FUNCTION(0x02, "lcd-spi", "mosi"), 69406763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "buspwr"), 69506763c74SThomas Petazzoni MPP_FUNCTION(0x04, "ssp", "txd"), 69606763c74SThomas Petazzoni MPP_FUNCTION(0x05, "sdio0", "buspwr"), 69706763c74SThomas Petazzoni MPP_FUNCTION(0x06, "spi1", "mosi")), 69806763c74SThomas Petazzoni MPP_MODE(23, 69906763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 70006763c74SThomas Petazzoni MPP_FUNCTION(0x02, "lcd-spi", "sck"), 70106763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "ledctrl"), 70206763c74SThomas Petazzoni MPP_FUNCTION(0x04, "ssp", "sclk"), 70306763c74SThomas Petazzoni MPP_FUNCTION(0x05, "sdio0", "ledctrl"), 70406763c74SThomas Petazzoni MPP_FUNCTION(0x06, "spi1", "sck")), 70506763c74SThomas Petazzoni MPP_MODE(24, 70606763c74SThomas Petazzoni MPP_FUNCTION(0x00, "camera", NULL), 70706763c74SThomas Petazzoni MPP_FUNCTION(0x01, "gpio", NULL)), 70806763c74SThomas Petazzoni MPP_MODE(40, 70906763c74SThomas Petazzoni MPP_FUNCTION(0x00, "sdio0", NULL), 71006763c74SThomas Petazzoni MPP_FUNCTION(0x01, "gpio", NULL)), 71106763c74SThomas Petazzoni MPP_MODE(46, 71206763c74SThomas Petazzoni MPP_FUNCTION(0x00, "sdio1", NULL), 71306763c74SThomas Petazzoni MPP_FUNCTION(0x01, "gpio", NULL)), 71406763c74SThomas Petazzoni MPP_MODE(52, 71506763c74SThomas Petazzoni MPP_FUNCTION(0x00, "i2s1/spdifo", NULL), 71606763c74SThomas Petazzoni MPP_FUNCTION(0x02, "i2s1", NULL), 71706763c74SThomas Petazzoni MPP_FUNCTION(0x08, "spdifo", NULL), 71806763c74SThomas Petazzoni MPP_FUNCTION(0x0a, "gpio", NULL), 71906763c74SThomas Petazzoni MPP_FUNCTION(0x0b, "twsi", NULL), 72006763c74SThomas Petazzoni MPP_FUNCTION(0x0c, "ssp/spdifo", NULL), 72106763c74SThomas Petazzoni MPP_FUNCTION(0x0e, "ssp", NULL), 72206763c74SThomas Petazzoni MPP_FUNCTION(0x0f, "ssp/twsi", NULL)), 72306763c74SThomas Petazzoni MPP_MODE(58, 72406763c74SThomas Petazzoni MPP_FUNCTION(0x00, "spi0", NULL), 72506763c74SThomas Petazzoni MPP_FUNCTION(0x01, "gpio", NULL)), 72606763c74SThomas Petazzoni MPP_MODE(62, 72706763c74SThomas Petazzoni MPP_FUNCTION(0x00, "uart1", NULL), 72806763c74SThomas Petazzoni MPP_FUNCTION(0x01, "gpio", NULL)), 72906763c74SThomas Petazzoni MPP_MODE(64, 73006763c74SThomas Petazzoni MPP_FUNCTION(0x00, "nand", NULL), 73106763c74SThomas Petazzoni MPP_FUNCTION(0x01, "gpo", NULL)), 73206763c74SThomas Petazzoni MPP_MODE(72, 73306763c74SThomas Petazzoni MPP_FUNCTION(0x00, "i2s", NULL), 73406763c74SThomas Petazzoni MPP_FUNCTION(0x01, "ac97", NULL)), 73506763c74SThomas Petazzoni MPP_MODE(73, 73606763c74SThomas Petazzoni MPP_FUNCTION(0x00, "twsi-none", NULL), 73706763c74SThomas Petazzoni MPP_FUNCTION(0x01, "twsi-opt1", NULL), 73806763c74SThomas Petazzoni MPP_FUNCTION(0x02, "twsi-opt2", NULL), 73906763c74SThomas Petazzoni MPP_FUNCTION(0x03, "twsi-opt3", NULL)), 74006763c74SThomas Petazzoni }; 74106763c74SThomas Petazzoni 74206763c74SThomas Petazzoni static struct pinctrl_gpio_range dove_mpp_gpio_ranges[] = { 74306763c74SThomas Petazzoni MPP_GPIO_RANGE(0, 0, 0, 32), 74406763c74SThomas Petazzoni MPP_GPIO_RANGE(1, 32, 32, 32), 74506763c74SThomas Petazzoni MPP_GPIO_RANGE(2, 64, 64, 8), 74606763c74SThomas Petazzoni }; 74706763c74SThomas Petazzoni 74806763c74SThomas Petazzoni static struct mvebu_pinctrl_soc_info dove_pinctrl_info = { 74906763c74SThomas Petazzoni .controls = dove_mpp_controls, 75006763c74SThomas Petazzoni .ncontrols = ARRAY_SIZE(dove_mpp_controls), 75106763c74SThomas Petazzoni .modes = dove_mpp_modes, 75206763c74SThomas Petazzoni .nmodes = ARRAY_SIZE(dove_mpp_modes), 75306763c74SThomas Petazzoni .gpioranges = dove_mpp_gpio_ranges, 75406763c74SThomas Petazzoni .ngpioranges = ARRAY_SIZE(dove_mpp_gpio_ranges), 75506763c74SThomas Petazzoni .variant = 0, 75606763c74SThomas Petazzoni }; 75706763c74SThomas Petazzoni 75806763c74SThomas Petazzoni static struct clk *clk; 75906763c74SThomas Petazzoni 760150632b0SGreg Kroah-Hartman static struct of_device_id dove_pinctrl_of_match[] = { 76106763c74SThomas Petazzoni { .compatible = "marvell,dove-pinctrl", .data = &dove_pinctrl_info }, 76206763c74SThomas Petazzoni { } 76306763c74SThomas Petazzoni }; 76406763c74SThomas Petazzoni 765e91f7916SSebastian Hesselbarth static struct regmap_config gc_regmap_config = { 766e91f7916SSebastian Hesselbarth .reg_bits = 32, 767e91f7916SSebastian Hesselbarth .val_bits = 32, 768e91f7916SSebastian Hesselbarth .reg_stride = 4, 769e91f7916SSebastian Hesselbarth .max_register = 5, 770e91f7916SSebastian Hesselbarth }; 771e91f7916SSebastian Hesselbarth 772150632b0SGreg Kroah-Hartman static int dove_pinctrl_probe(struct platform_device *pdev) 77306763c74SThomas Petazzoni { 7744d73fc77SSebastian Hesselbarth struct resource *res, *mpp_res; 7754d73fc77SSebastian Hesselbarth struct resource fb_res; 77606763c74SThomas Petazzoni const struct of_device_id *match = 77706763c74SThomas Petazzoni of_match_device(dove_pinctrl_of_match, &pdev->dev); 77816fa36beSAndrew Lunn pdev->dev.platform_data = (void *)match->data; 77906763c74SThomas Petazzoni 78006763c74SThomas Petazzoni /* 78106763c74SThomas Petazzoni * General MPP Configuration Register is part of pdma registers. 78206763c74SThomas Petazzoni * grab clk to make sure it is ticking. 78306763c74SThomas Petazzoni */ 78406763c74SThomas Petazzoni clk = devm_clk_get(&pdev->dev, NULL); 785ba607b62SSebastian Hesselbarth if (IS_ERR(clk)) { 786ba607b62SSebastian Hesselbarth dev_err(&pdev->dev, "Unable to get pdma clock"); 7875795c6acSRusty Russell return PTR_ERR(clk); 788ba607b62SSebastian Hesselbarth } 78906763c74SThomas Petazzoni clk_prepare_enable(clk); 79006763c74SThomas Petazzoni 7914d73fc77SSebastian Hesselbarth mpp_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 7924d73fc77SSebastian Hesselbarth mpp_base = devm_ioremap_resource(&pdev->dev, mpp_res); 7931217b790SSebastian Hesselbarth if (IS_ERR(mpp_base)) 7941217b790SSebastian Hesselbarth return PTR_ERR(mpp_base); 7951217b790SSebastian Hesselbarth 7964d73fc77SSebastian Hesselbarth /* prepare fallback resource */ 7974d73fc77SSebastian Hesselbarth memcpy(&fb_res, mpp_res, sizeof(struct resource)); 7984d73fc77SSebastian Hesselbarth fb_res.start = 0; 7994d73fc77SSebastian Hesselbarth 8004d73fc77SSebastian Hesselbarth res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 8014d73fc77SSebastian Hesselbarth if (!res) { 8024d73fc77SSebastian Hesselbarth dev_warn(&pdev->dev, "falling back to hardcoded MPP4 resource\n"); 8034d73fc77SSebastian Hesselbarth adjust_resource(&fb_res, 8044d73fc77SSebastian Hesselbarth (mpp_res->start & INT_REGS_MASK) + MPP4_REGS_OFFS, 0x4); 8054d73fc77SSebastian Hesselbarth res = &fb_res; 8064d73fc77SSebastian Hesselbarth } 8074d73fc77SSebastian Hesselbarth 8084d73fc77SSebastian Hesselbarth mpp4_base = devm_ioremap_resource(&pdev->dev, res); 8094d73fc77SSebastian Hesselbarth if (IS_ERR(mpp4_base)) 8104d73fc77SSebastian Hesselbarth return PTR_ERR(mpp4_base); 8114d73fc77SSebastian Hesselbarth 8124d73fc77SSebastian Hesselbarth res = platform_get_resource(pdev, IORESOURCE_MEM, 2); 8134d73fc77SSebastian Hesselbarth if (!res) { 8144d73fc77SSebastian Hesselbarth dev_warn(&pdev->dev, "falling back to hardcoded PMU resource\n"); 8154d73fc77SSebastian Hesselbarth adjust_resource(&fb_res, 8164d73fc77SSebastian Hesselbarth (mpp_res->start & INT_REGS_MASK) + PMU_REGS_OFFS, 0x8); 8174d73fc77SSebastian Hesselbarth res = &fb_res; 8184d73fc77SSebastian Hesselbarth } 8194d73fc77SSebastian Hesselbarth 8204d73fc77SSebastian Hesselbarth pmu_base = devm_ioremap_resource(&pdev->dev, res); 8214d73fc77SSebastian Hesselbarth if (IS_ERR(pmu_base)) 8224d73fc77SSebastian Hesselbarth return PTR_ERR(pmu_base); 8234d73fc77SSebastian Hesselbarth 824e91f7916SSebastian Hesselbarth gconfmap = syscon_regmap_lookup_by_compatible("marvell,dove-global-config"); 825e91f7916SSebastian Hesselbarth if (IS_ERR(gconfmap)) { 826e91f7916SSebastian Hesselbarth void __iomem *gc_base; 827e91f7916SSebastian Hesselbarth 828e91f7916SSebastian Hesselbarth dev_warn(&pdev->dev, "falling back to hardcoded global registers\n"); 829e91f7916SSebastian Hesselbarth adjust_resource(&fb_res, 830e91f7916SSebastian Hesselbarth (mpp_res->start & INT_REGS_MASK) + GC_REGS_OFFS, 0x14); 831e91f7916SSebastian Hesselbarth gc_base = devm_ioremap_resource(&pdev->dev, &fb_res); 832e91f7916SSebastian Hesselbarth if (IS_ERR(gc_base)) 833e91f7916SSebastian Hesselbarth return PTR_ERR(gc_base); 834e91f7916SSebastian Hesselbarth gconfmap = devm_regmap_init_mmio(&pdev->dev, 835e91f7916SSebastian Hesselbarth gc_base, &gc_regmap_config); 836e91f7916SSebastian Hesselbarth if (IS_ERR(gconfmap)) 837e91f7916SSebastian Hesselbarth return PTR_ERR(gconfmap); 838e91f7916SSebastian Hesselbarth } 839e91f7916SSebastian Hesselbarth 8404d73fc77SSebastian Hesselbarth /* Warn on any missing DT resource */ 8414d73fc77SSebastian Hesselbarth WARN(fb_res.start, FW_BUG "Missing pinctrl regs in DTB. Please update your firmware.\n"); 8424d73fc77SSebastian Hesselbarth 84306763c74SThomas Petazzoni return mvebu_pinctrl_probe(pdev); 84406763c74SThomas Petazzoni } 84506763c74SThomas Petazzoni 846150632b0SGreg Kroah-Hartman static int dove_pinctrl_remove(struct platform_device *pdev) 84706763c74SThomas Petazzoni { 84806763c74SThomas Petazzoni int ret; 84906763c74SThomas Petazzoni 85006763c74SThomas Petazzoni ret = mvebu_pinctrl_remove(pdev); 85106763c74SThomas Petazzoni if (!IS_ERR(clk)) 85206763c74SThomas Petazzoni clk_disable_unprepare(clk); 85306763c74SThomas Petazzoni return ret; 85406763c74SThomas Petazzoni } 85506763c74SThomas Petazzoni 85606763c74SThomas Petazzoni static struct platform_driver dove_pinctrl_driver = { 85706763c74SThomas Petazzoni .driver = { 85806763c74SThomas Petazzoni .name = "dove-pinctrl", 85906763c74SThomas Petazzoni .owner = THIS_MODULE, 860f2e9394dSSachin Kamat .of_match_table = dove_pinctrl_of_match, 86106763c74SThomas Petazzoni }, 86206763c74SThomas Petazzoni .probe = dove_pinctrl_probe, 863150632b0SGreg Kroah-Hartman .remove = dove_pinctrl_remove, 86406763c74SThomas Petazzoni }; 86506763c74SThomas Petazzoni 86606763c74SThomas Petazzoni module_platform_driver(dove_pinctrl_driver); 86706763c74SThomas Petazzoni 86806763c74SThomas Petazzoni MODULE_AUTHOR("Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>"); 86906763c74SThomas Petazzoni MODULE_DESCRIPTION("Marvell Dove pinctrl driver"); 87006763c74SThomas Petazzoni MODULE_LICENSE("GPL v2"); 871