1*2874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later 206763c74SThomas Petazzoni /* 306763c74SThomas Petazzoni * Marvell Dove pinctrl driver based on mvebu pinctrl core 406763c74SThomas Petazzoni * 506763c74SThomas Petazzoni * Author: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> 606763c74SThomas Petazzoni */ 706763c74SThomas Petazzoni 806763c74SThomas Petazzoni #include <linux/err.h> 906763c74SThomas Petazzoni #include <linux/init.h> 1006763c74SThomas Petazzoni #include <linux/io.h> 1106763c74SThomas Petazzoni #include <linux/bitops.h> 1206763c74SThomas Petazzoni #include <linux/platform_device.h> 1306763c74SThomas Petazzoni #include <linux/clk.h> 1406763c74SThomas Petazzoni #include <linux/of.h> 1506763c74SThomas Petazzoni #include <linux/of_device.h> 16e91f7916SSebastian Hesselbarth #include <linux/mfd/syscon.h> 1706763c74SThomas Petazzoni #include <linux/pinctrl/pinctrl.h> 18e91f7916SSebastian Hesselbarth #include <linux/regmap.h> 1906763c74SThomas Petazzoni 2006763c74SThomas Petazzoni #include "pinctrl-mvebu.h" 2106763c74SThomas Petazzoni 224d73fc77SSebastian Hesselbarth /* Internal registers can be configured at any 1 MiB aligned address */ 234d73fc77SSebastian Hesselbarth #define INT_REGS_MASK ~(SZ_1M - 1) 244d73fc77SSebastian Hesselbarth #define MPP4_REGS_OFFS 0xd0440 254d73fc77SSebastian Hesselbarth #define PMU_REGS_OFFS 0xd802c 26e91f7916SSebastian Hesselbarth #define GC_REGS_OFFS 0xe802c 274d73fc77SSebastian Hesselbarth 2800202b01SSebastian Hesselbarth /* MPP Base registers */ 2900202b01SSebastian Hesselbarth #define PMU_MPP_GENERAL_CTRL 0x10 3000202b01SSebastian Hesselbarth #define AU0_AC97_SEL BIT(16) 3100202b01SSebastian Hesselbarth 322c4b229bSSebastian Hesselbarth /* MPP Control 4 register */ 332c4b229bSSebastian Hesselbarth #define SPI_GPIO_SEL BIT(5) 342c4b229bSSebastian Hesselbarth #define UART1_GPIO_SEL BIT(4) 352c4b229bSSebastian Hesselbarth #define AU1_GPIO_SEL BIT(3) 362c4b229bSSebastian Hesselbarth #define CAM_GPIO_SEL BIT(2) 372c4b229bSSebastian Hesselbarth #define SD1_GPIO_SEL BIT(1) 382c4b229bSSebastian Hesselbarth #define SD0_GPIO_SEL BIT(0) 392c4b229bSSebastian Hesselbarth 4018e6f28eSSebastian Hesselbarth /* PMU Signal Select registers */ 4118e6f28eSSebastian Hesselbarth #define PMU_SIGNAL_SELECT_0 0x00 4218e6f28eSSebastian Hesselbarth #define PMU_SIGNAL_SELECT_1 0x04 4318e6f28eSSebastian Hesselbarth 446da67cabSSebastian Hesselbarth /* Global Config regmap registers */ 456da67cabSSebastian Hesselbarth #define GLOBAL_CONFIG_1 0x00 466da67cabSSebastian Hesselbarth #define TWSI_ENABLE_OPTION1 BIT(7) 476da67cabSSebastian Hesselbarth #define GLOBAL_CONFIG_2 0x04 486da67cabSSebastian Hesselbarth #define TWSI_ENABLE_OPTION2 BIT(20) 496da67cabSSebastian Hesselbarth #define TWSI_ENABLE_OPTION3 BIT(21) 506da67cabSSebastian Hesselbarth #define TWSI_OPTION3_GPIO BIT(22) 516da67cabSSebastian Hesselbarth #define SSP_CTRL_STATUS_1 0x08 526da67cabSSebastian Hesselbarth #define SSP_ON_AU1 BIT(0) 536da67cabSSebastian Hesselbarth #define MPP_GENERAL_CONFIG 0x10 546da67cabSSebastian Hesselbarth #define AU1_SPDIFO_GPIO_EN BIT(1) 556da67cabSSebastian Hesselbarth #define NAND_GPIO_EN BIT(0) 566da67cabSSebastian Hesselbarth 5706763c74SThomas Petazzoni #define CONFIG_PMU BIT(4) 5806763c74SThomas Petazzoni 594d73fc77SSebastian Hesselbarth static void __iomem *mpp4_base; 604d73fc77SSebastian Hesselbarth static void __iomem *pmu_base; 61e91f7916SSebastian Hesselbarth static struct regmap *gconfmap; 6217bdec67SSebastian Hesselbarth 6320955c5fSRussell King static int dove_pmu_mpp_ctrl_get(struct mvebu_mpp_ctrl_data *data, 6420955c5fSRussell King unsigned pid, unsigned long *config) 6506763c74SThomas Petazzoni { 6617bdec67SSebastian Hesselbarth unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; 6717bdec67SSebastian Hesselbarth unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; 68ad9ec4ecSRussell King unsigned long pmu = readl(data->base + PMU_MPP_GENERAL_CTRL); 69bbd7b275SSebastian Hesselbarth unsigned long func; 7006763c74SThomas Petazzoni 7178c2c3d3SSebastian Hesselbarth if ((pmu & BIT(pid)) == 0) 72ad9ec4ecSRussell King return mvebu_mmio_mpp_ctrl_get(data, pid, config); 7378c2c3d3SSebastian Hesselbarth 7418e6f28eSSebastian Hesselbarth func = readl(pmu_base + PMU_SIGNAL_SELECT_0 + off); 7517bdec67SSebastian Hesselbarth *config = (func >> shift) & MVEBU_MPP_MASK; 76bbd7b275SSebastian Hesselbarth *config |= CONFIG_PMU; 7778c2c3d3SSebastian Hesselbarth 7806763c74SThomas Petazzoni return 0; 7906763c74SThomas Petazzoni } 8006763c74SThomas Petazzoni 8120955c5fSRussell King static int dove_pmu_mpp_ctrl_set(struct mvebu_mpp_ctrl_data *data, 8220955c5fSRussell King unsigned pid, unsigned long config) 8306763c74SThomas Petazzoni { 8417bdec67SSebastian Hesselbarth unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; 8517bdec67SSebastian Hesselbarth unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; 86ad9ec4ecSRussell King unsigned long pmu = readl(data->base + PMU_MPP_GENERAL_CTRL); 87bbd7b275SSebastian Hesselbarth unsigned long func; 8806763c74SThomas Petazzoni 8978c2c3d3SSebastian Hesselbarth if ((config & CONFIG_PMU) == 0) { 90ad9ec4ecSRussell King writel(pmu & ~BIT(pid), data->base + PMU_MPP_GENERAL_CTRL); 91ad9ec4ecSRussell King return mvebu_mmio_mpp_ctrl_set(data, pid, config); 9278c2c3d3SSebastian Hesselbarth } 9378c2c3d3SSebastian Hesselbarth 94ad9ec4ecSRussell King writel(pmu | BIT(pid), data->base + PMU_MPP_GENERAL_CTRL); 9518e6f28eSSebastian Hesselbarth func = readl(pmu_base + PMU_SIGNAL_SELECT_0 + off); 9617bdec67SSebastian Hesselbarth func &= ~(MVEBU_MPP_MASK << shift); 9717bdec67SSebastian Hesselbarth func |= (config & MVEBU_MPP_MASK) << shift; 9818e6f28eSSebastian Hesselbarth writel(func, pmu_base + PMU_SIGNAL_SELECT_0 + off); 9978c2c3d3SSebastian Hesselbarth 10006763c74SThomas Petazzoni return 0; 10106763c74SThomas Petazzoni } 10206763c74SThomas Petazzoni 10320955c5fSRussell King static int dove_mpp4_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid, 10420955c5fSRussell King unsigned long *config) 10506763c74SThomas Petazzoni { 1062c4b229bSSebastian Hesselbarth unsigned long mpp4 = readl(mpp4_base); 10706763c74SThomas Petazzoni unsigned long mask; 10806763c74SThomas Petazzoni 1092035d39dSSebastian Hesselbarth switch (pid) { 11006763c74SThomas Petazzoni case 24: /* mpp_camera */ 1112c4b229bSSebastian Hesselbarth mask = CAM_GPIO_SEL; 11206763c74SThomas Petazzoni break; 11306763c74SThomas Petazzoni case 40: /* mpp_sdio0 */ 1142c4b229bSSebastian Hesselbarth mask = SD0_GPIO_SEL; 11506763c74SThomas Petazzoni break; 11606763c74SThomas Petazzoni case 46: /* mpp_sdio1 */ 1172c4b229bSSebastian Hesselbarth mask = SD1_GPIO_SEL; 11806763c74SThomas Petazzoni break; 11906763c74SThomas Petazzoni case 58: /* mpp_spi0 */ 1202c4b229bSSebastian Hesselbarth mask = SPI_GPIO_SEL; 12106763c74SThomas Petazzoni break; 12206763c74SThomas Petazzoni case 62: /* mpp_uart1 */ 1232c4b229bSSebastian Hesselbarth mask = UART1_GPIO_SEL; 12406763c74SThomas Petazzoni break; 12506763c74SThomas Petazzoni default: 12606763c74SThomas Petazzoni return -EINVAL; 12706763c74SThomas Petazzoni } 12806763c74SThomas Petazzoni 12906763c74SThomas Petazzoni *config = ((mpp4 & mask) != 0); 13006763c74SThomas Petazzoni 13106763c74SThomas Petazzoni return 0; 13206763c74SThomas Petazzoni } 13306763c74SThomas Petazzoni 13420955c5fSRussell King static int dove_mpp4_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid, 13520955c5fSRussell King unsigned long config) 13606763c74SThomas Petazzoni { 1372c4b229bSSebastian Hesselbarth unsigned long mpp4 = readl(mpp4_base); 13806763c74SThomas Petazzoni unsigned long mask; 13906763c74SThomas Petazzoni 1402035d39dSSebastian Hesselbarth switch (pid) { 14106763c74SThomas Petazzoni case 24: /* mpp_camera */ 1422c4b229bSSebastian Hesselbarth mask = CAM_GPIO_SEL; 14306763c74SThomas Petazzoni break; 14406763c74SThomas Petazzoni case 40: /* mpp_sdio0 */ 1452c4b229bSSebastian Hesselbarth mask = SD0_GPIO_SEL; 14606763c74SThomas Petazzoni break; 14706763c74SThomas Petazzoni case 46: /* mpp_sdio1 */ 1482c4b229bSSebastian Hesselbarth mask = SD1_GPIO_SEL; 14906763c74SThomas Petazzoni break; 15006763c74SThomas Petazzoni case 58: /* mpp_spi0 */ 1512c4b229bSSebastian Hesselbarth mask = SPI_GPIO_SEL; 15206763c74SThomas Petazzoni break; 15306763c74SThomas Petazzoni case 62: /* mpp_uart1 */ 1542c4b229bSSebastian Hesselbarth mask = UART1_GPIO_SEL; 15506763c74SThomas Petazzoni break; 15606763c74SThomas Petazzoni default: 15706763c74SThomas Petazzoni return -EINVAL; 15806763c74SThomas Petazzoni } 15906763c74SThomas Petazzoni 16006763c74SThomas Petazzoni mpp4 &= ~mask; 16106763c74SThomas Petazzoni if (config) 16206763c74SThomas Petazzoni mpp4 |= mask; 16306763c74SThomas Petazzoni 1642c4b229bSSebastian Hesselbarth writel(mpp4, mpp4_base); 16506763c74SThomas Petazzoni 16606763c74SThomas Petazzoni return 0; 16706763c74SThomas Petazzoni } 16806763c74SThomas Petazzoni 16920955c5fSRussell King static int dove_nand_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid, 17020955c5fSRussell King unsigned long *config) 17106763c74SThomas Petazzoni { 1726da67cabSSebastian Hesselbarth unsigned int gmpp; 17306763c74SThomas Petazzoni 1746da67cabSSebastian Hesselbarth regmap_read(gconfmap, MPP_GENERAL_CONFIG, &gmpp); 1756da67cabSSebastian Hesselbarth *config = ((gmpp & NAND_GPIO_EN) != 0); 17606763c74SThomas Petazzoni 17706763c74SThomas Petazzoni return 0; 17806763c74SThomas Petazzoni } 17906763c74SThomas Petazzoni 18020955c5fSRussell King static int dove_nand_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid, 18120955c5fSRussell King unsigned long config) 18206763c74SThomas Petazzoni { 1836da67cabSSebastian Hesselbarth regmap_update_bits(gconfmap, MPP_GENERAL_CONFIG, 1846da67cabSSebastian Hesselbarth NAND_GPIO_EN, 1856da67cabSSebastian Hesselbarth (config) ? NAND_GPIO_EN : 0); 18606763c74SThomas Petazzoni return 0; 18706763c74SThomas Petazzoni } 18806763c74SThomas Petazzoni 18920955c5fSRussell King static int dove_audio0_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid, 19020955c5fSRussell King unsigned long *config) 19106763c74SThomas Petazzoni { 192ad9ec4ecSRussell King unsigned long pmu = readl(data->base + PMU_MPP_GENERAL_CTRL); 19306763c74SThomas Petazzoni 19400202b01SSebastian Hesselbarth *config = ((pmu & AU0_AC97_SEL) != 0); 19506763c74SThomas Petazzoni 19606763c74SThomas Petazzoni return 0; 19706763c74SThomas Petazzoni } 19806763c74SThomas Petazzoni 19920955c5fSRussell King static int dove_audio0_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid, 20020955c5fSRussell King unsigned long config) 20106763c74SThomas Petazzoni { 202ad9ec4ecSRussell King unsigned long pmu = readl(data->base + PMU_MPP_GENERAL_CTRL); 20306763c74SThomas Petazzoni 20400202b01SSebastian Hesselbarth pmu &= ~AU0_AC97_SEL; 20506763c74SThomas Petazzoni if (config) 20600202b01SSebastian Hesselbarth pmu |= AU0_AC97_SEL; 207ad9ec4ecSRussell King writel(pmu, data->base + PMU_MPP_GENERAL_CTRL); 20806763c74SThomas Petazzoni 20906763c74SThomas Petazzoni return 0; 21006763c74SThomas Petazzoni } 21106763c74SThomas Petazzoni 21220955c5fSRussell King static int dove_audio1_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid, 21320955c5fSRussell King unsigned long *config) 21406763c74SThomas Petazzoni { 2152c4b229bSSebastian Hesselbarth unsigned int mpp4 = readl(mpp4_base); 2166da67cabSSebastian Hesselbarth unsigned int sspc1; 2176da67cabSSebastian Hesselbarth unsigned int gmpp; 2186da67cabSSebastian Hesselbarth unsigned int gcfg2; 2196da67cabSSebastian Hesselbarth 2206da67cabSSebastian Hesselbarth regmap_read(gconfmap, SSP_CTRL_STATUS_1, &sspc1); 2216da67cabSSebastian Hesselbarth regmap_read(gconfmap, MPP_GENERAL_CONFIG, &gmpp); 2226da67cabSSebastian Hesselbarth regmap_read(gconfmap, GLOBAL_CONFIG_2, &gcfg2); 22306763c74SThomas Petazzoni 22406763c74SThomas Petazzoni *config = 0; 2252c4b229bSSebastian Hesselbarth if (mpp4 & AU1_GPIO_SEL) 22606763c74SThomas Petazzoni *config |= BIT(3); 2276da67cabSSebastian Hesselbarth if (sspc1 & SSP_ON_AU1) 22806763c74SThomas Petazzoni *config |= BIT(2); 2296da67cabSSebastian Hesselbarth if (gmpp & AU1_SPDIFO_GPIO_EN) 23006763c74SThomas Petazzoni *config |= BIT(1); 2316da67cabSSebastian Hesselbarth if (gcfg2 & TWSI_OPTION3_GPIO) 23206763c74SThomas Petazzoni *config |= BIT(0); 23306763c74SThomas Petazzoni 23406763c74SThomas Petazzoni /* SSP/TWSI only if I2S1 not set*/ 23506763c74SThomas Petazzoni if ((*config & BIT(3)) == 0) 23606763c74SThomas Petazzoni *config &= ~(BIT(2) | BIT(0)); 23706763c74SThomas Petazzoni /* TWSI only if SPDIFO not set*/ 23806763c74SThomas Petazzoni if ((*config & BIT(1)) == 0) 23906763c74SThomas Petazzoni *config &= ~BIT(0); 24006763c74SThomas Petazzoni return 0; 24106763c74SThomas Petazzoni } 24206763c74SThomas Petazzoni 24320955c5fSRussell King static int dove_audio1_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid, 24420955c5fSRussell King unsigned long config) 24506763c74SThomas Petazzoni { 2462c4b229bSSebastian Hesselbarth unsigned int mpp4 = readl(mpp4_base); 24706763c74SThomas Petazzoni 2482c4b229bSSebastian Hesselbarth mpp4 &= ~AU1_GPIO_SEL; 24906763c74SThomas Petazzoni if (config & BIT(3)) 2502c4b229bSSebastian Hesselbarth mpp4 |= AU1_GPIO_SEL; 2512c4b229bSSebastian Hesselbarth writel(mpp4, mpp4_base); 2526da67cabSSebastian Hesselbarth 2536da67cabSSebastian Hesselbarth regmap_update_bits(gconfmap, SSP_CTRL_STATUS_1, 2546da67cabSSebastian Hesselbarth SSP_ON_AU1, 2556da67cabSSebastian Hesselbarth (config & BIT(2)) ? SSP_ON_AU1 : 0); 2566da67cabSSebastian Hesselbarth regmap_update_bits(gconfmap, MPP_GENERAL_CONFIG, 2576da67cabSSebastian Hesselbarth AU1_SPDIFO_GPIO_EN, 2586da67cabSSebastian Hesselbarth (config & BIT(1)) ? AU1_SPDIFO_GPIO_EN : 0); 2596da67cabSSebastian Hesselbarth regmap_update_bits(gconfmap, GLOBAL_CONFIG_2, 2606da67cabSSebastian Hesselbarth TWSI_OPTION3_GPIO, 2616da67cabSSebastian Hesselbarth (config & BIT(0)) ? TWSI_OPTION3_GPIO : 0); 26206763c74SThomas Petazzoni 26306763c74SThomas Petazzoni return 0; 26406763c74SThomas Petazzoni } 26506763c74SThomas Petazzoni 26606763c74SThomas Petazzoni /* mpp[52:57] gpio pins depend heavily on current config; 26706763c74SThomas Petazzoni * gpio_req does not try to mux in gpio capabilities to not 26806763c74SThomas Petazzoni * break other functions. If you require all mpps as gpio 26906763c74SThomas Petazzoni * enforce gpio setting by pinctrl mapping. 27006763c74SThomas Petazzoni */ 27120955c5fSRussell King static int dove_audio1_ctrl_gpio_req(struct mvebu_mpp_ctrl_data *data, 27220955c5fSRussell King unsigned pid) 27306763c74SThomas Petazzoni { 27406763c74SThomas Petazzoni unsigned long config; 27506763c74SThomas Petazzoni 27620955c5fSRussell King dove_audio1_ctrl_get(data, pid, &config); 27706763c74SThomas Petazzoni 27806763c74SThomas Petazzoni switch (config) { 27906763c74SThomas Petazzoni case 0x02: /* i2s1 : gpio[56:57] */ 28006763c74SThomas Petazzoni case 0x0e: /* ssp : gpio[56:57] */ 28106763c74SThomas Petazzoni if (pid >= 56) 28206763c74SThomas Petazzoni return 0; 28306763c74SThomas Petazzoni return -ENOTSUPP; 28406763c74SThomas Petazzoni case 0x08: /* spdifo : gpio[52:55] */ 28506763c74SThomas Petazzoni case 0x0b: /* twsi : gpio[52:55] */ 28606763c74SThomas Petazzoni if (pid <= 55) 28706763c74SThomas Petazzoni return 0; 28806763c74SThomas Petazzoni return -ENOTSUPP; 28906763c74SThomas Petazzoni case 0x0a: /* all gpio */ 29006763c74SThomas Petazzoni return 0; 29106763c74SThomas Petazzoni /* 0x00 : i2s1/spdifo : no gpio */ 29206763c74SThomas Petazzoni /* 0x0c : ssp/spdifo : no gpio */ 29306763c74SThomas Petazzoni /* 0x0f : ssp/twsi : no gpio */ 29406763c74SThomas Petazzoni } 29506763c74SThomas Petazzoni return -ENOTSUPP; 29606763c74SThomas Petazzoni } 29706763c74SThomas Petazzoni 29806763c74SThomas Petazzoni /* mpp[52:57] has gpio pins capable of in and out */ 29920955c5fSRussell King static int dove_audio1_ctrl_gpio_dir(struct mvebu_mpp_ctrl_data *data, 30020955c5fSRussell King unsigned pid, bool input) 30106763c74SThomas Petazzoni { 30206763c74SThomas Petazzoni if (pid < 52 || pid > 57) 30306763c74SThomas Petazzoni return -ENOTSUPP; 30406763c74SThomas Petazzoni return 0; 30506763c74SThomas Petazzoni } 30606763c74SThomas Petazzoni 30720955c5fSRussell King static int dove_twsi_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid, 30820955c5fSRussell King unsigned long *config) 30906763c74SThomas Petazzoni { 3106da67cabSSebastian Hesselbarth unsigned int gcfg1; 3116da67cabSSebastian Hesselbarth unsigned int gcfg2; 3126da67cabSSebastian Hesselbarth 3136da67cabSSebastian Hesselbarth regmap_read(gconfmap, GLOBAL_CONFIG_1, &gcfg1); 3146da67cabSSebastian Hesselbarth regmap_read(gconfmap, GLOBAL_CONFIG_2, &gcfg2); 31506763c74SThomas Petazzoni 31606763c74SThomas Petazzoni *config = 0; 3176da67cabSSebastian Hesselbarth if (gcfg1 & TWSI_ENABLE_OPTION1) 31806763c74SThomas Petazzoni *config = 1; 3196da67cabSSebastian Hesselbarth else if (gcfg2 & TWSI_ENABLE_OPTION2) 32006763c74SThomas Petazzoni *config = 2; 3216da67cabSSebastian Hesselbarth else if (gcfg2 & TWSI_ENABLE_OPTION3) 32206763c74SThomas Petazzoni *config = 3; 32306763c74SThomas Petazzoni 32406763c74SThomas Petazzoni return 0; 32506763c74SThomas Petazzoni } 32606763c74SThomas Petazzoni 32720955c5fSRussell King static int dove_twsi_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid, 32820955c5fSRussell King unsigned long config) 32906763c74SThomas Petazzoni { 3306da67cabSSebastian Hesselbarth unsigned int gcfg1 = 0; 3316da67cabSSebastian Hesselbarth unsigned int gcfg2 = 0; 33206763c74SThomas Petazzoni 33306763c74SThomas Petazzoni switch (config) { 33406763c74SThomas Petazzoni case 1: 3356da67cabSSebastian Hesselbarth gcfg1 = TWSI_ENABLE_OPTION1; 33606763c74SThomas Petazzoni break; 33706763c74SThomas Petazzoni case 2: 3386da67cabSSebastian Hesselbarth gcfg2 = TWSI_ENABLE_OPTION2; 33906763c74SThomas Petazzoni break; 34006763c74SThomas Petazzoni case 3: 3416da67cabSSebastian Hesselbarth gcfg2 = TWSI_ENABLE_OPTION3; 34206763c74SThomas Petazzoni break; 34306763c74SThomas Petazzoni } 34406763c74SThomas Petazzoni 3456da67cabSSebastian Hesselbarth regmap_update_bits(gconfmap, GLOBAL_CONFIG_1, 3466da67cabSSebastian Hesselbarth TWSI_ENABLE_OPTION1, 3476da67cabSSebastian Hesselbarth gcfg1); 3486da67cabSSebastian Hesselbarth regmap_update_bits(gconfmap, GLOBAL_CONFIG_2, 3496da67cabSSebastian Hesselbarth TWSI_ENABLE_OPTION2 | TWSI_ENABLE_OPTION3, 3506da67cabSSebastian Hesselbarth gcfg2); 35106763c74SThomas Petazzoni 35206763c74SThomas Petazzoni return 0; 35306763c74SThomas Petazzoni } 35406763c74SThomas Petazzoni 35530be3fb9SRussell King static const struct mvebu_mpp_ctrl dove_mpp_controls[] = { 356c2f082feSSebastian Hesselbarth MPP_FUNC_CTRL(0, 15, NULL, dove_pmu_mpp_ctrl), 357ad9ec4ecSRussell King MPP_FUNC_CTRL(16, 23, NULL, mvebu_mmio_mpp_ctrl), 35806763c74SThomas Petazzoni MPP_FUNC_CTRL(24, 39, "mpp_camera", dove_mpp4_ctrl), 35906763c74SThomas Petazzoni MPP_FUNC_CTRL(40, 45, "mpp_sdio0", dove_mpp4_ctrl), 36006763c74SThomas Petazzoni MPP_FUNC_CTRL(46, 51, "mpp_sdio1", dove_mpp4_ctrl), 36106763c74SThomas Petazzoni MPP_FUNC_GPIO_CTRL(52, 57, "mpp_audio1", dove_audio1_ctrl), 36206763c74SThomas Petazzoni MPP_FUNC_CTRL(58, 61, "mpp_spi0", dove_mpp4_ctrl), 36306763c74SThomas Petazzoni MPP_FUNC_CTRL(62, 63, "mpp_uart1", dove_mpp4_ctrl), 36406763c74SThomas Petazzoni MPP_FUNC_CTRL(64, 71, "mpp_nand", dove_nand_ctrl), 36506763c74SThomas Petazzoni MPP_FUNC_CTRL(72, 72, "audio0", dove_audio0_ctrl), 36606763c74SThomas Petazzoni MPP_FUNC_CTRL(73, 73, "twsi", dove_twsi_ctrl), 36706763c74SThomas Petazzoni }; 36806763c74SThomas Petazzoni 36906763c74SThomas Petazzoni static struct mvebu_mpp_mode dove_mpp_modes[] = { 37006763c74SThomas Petazzoni MPP_MODE(0, 37106763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 37206763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "rts"), 37306763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "cd"), 37406763c74SThomas Petazzoni MPP_FUNCTION(0x0f, "lcd0", "pwm"), 375bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 376bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 377bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 378bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 379bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 380bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 381bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 382bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 383bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 384bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 385bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 386bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 38706763c74SThomas Petazzoni MPP_MODE(1, 38806763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 38906763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "cts"), 39006763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "wp"), 39106763c74SThomas Petazzoni MPP_FUNCTION(0x0f, "lcd1", "pwm"), 392bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 393bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 394bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 395bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 396bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 397bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 398bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 399bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 400bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 401bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 402bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 403bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 40406763c74SThomas Petazzoni MPP_MODE(2, 40506763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 40606763c74SThomas Petazzoni MPP_FUNCTION(0x01, "sata", "prsnt"), 40706763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "txd"), 40806763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "buspwr"), 40906763c74SThomas Petazzoni MPP_FUNCTION(0x04, "uart1", "rts"), 410bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 411bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 412bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 413bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 414bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 415bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 416bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 417bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 418bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 419bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 420bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 421bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 42206763c74SThomas Petazzoni MPP_MODE(3, 42306763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 42406763c74SThomas Petazzoni MPP_FUNCTION(0x01, "sata", "act"), 42506763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "rxd"), 42606763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "ledctrl"), 42706763c74SThomas Petazzoni MPP_FUNCTION(0x04, "uart1", "cts"), 42806763c74SThomas Petazzoni MPP_FUNCTION(0x0f, "lcd-spi", "cs1"), 429bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 430bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 431bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 432bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 433bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 434bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 435bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 436bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 437bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 438bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 439bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 440bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 44106763c74SThomas Petazzoni MPP_MODE(4, 44206763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 44306763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "rts"), 44406763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "cd"), 44506763c74SThomas Petazzoni MPP_FUNCTION(0x04, "spi1", "miso"), 446bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 447bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 448bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 449bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 450bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 451bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 452bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 453bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 454bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 455bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 456bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 457bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 45806763c74SThomas Petazzoni MPP_MODE(5, 45906763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 46006763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "cts"), 46106763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "wp"), 46206763c74SThomas Petazzoni MPP_FUNCTION(0x04, "spi1", "cs"), 463bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 464bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 465bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 466bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 467bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 468bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 469bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 470bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 471bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 472bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 473bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 474bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 47506763c74SThomas Petazzoni MPP_MODE(6, 47606763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 47706763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "txd"), 47806763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "buspwr"), 47906763c74SThomas Petazzoni MPP_FUNCTION(0x04, "spi1", "mosi"), 480bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 481bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 482bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 483bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 484bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 485bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 486bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 487bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 488bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 489bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 490bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 491bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 49206763c74SThomas Petazzoni MPP_MODE(7, 49306763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 49406763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "rxd"), 49506763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "ledctrl"), 49606763c74SThomas Petazzoni MPP_FUNCTION(0x04, "spi1", "sck"), 497bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 498bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 499bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 500bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 501bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 502bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 503bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 504bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 505bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 506bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 507bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 508bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 50906763c74SThomas Petazzoni MPP_MODE(8, 51006763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 51106763c74SThomas Petazzoni MPP_FUNCTION(0x01, "watchdog", "rstout"), 512bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 513bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 514bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 515bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 516bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 517bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 518bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 519bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 520bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 521bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 522bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 523bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 52406763c74SThomas Petazzoni MPP_MODE(9, 52506763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 52606763c74SThomas Petazzoni MPP_FUNCTION(0x05, "pex1", "clkreq"), 527bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 528bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 529bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 530bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 531bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 532bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 533bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 534bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 535bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 536bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 537bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 538bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 53906763c74SThomas Petazzoni MPP_MODE(10, 54006763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 54106763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ssp", "sclk"), 542bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 543bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 544bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 545bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 546bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 547bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 548bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 549bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 550bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 551bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 552bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 553bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 55406763c74SThomas Petazzoni MPP_MODE(11, 55506763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 55606763c74SThomas Petazzoni MPP_FUNCTION(0x01, "sata", "prsnt"), 55706763c74SThomas Petazzoni MPP_FUNCTION(0x02, "sata-1", "act"), 55806763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "ledctrl"), 55906763c74SThomas Petazzoni MPP_FUNCTION(0x04, "sdio1", "ledctrl"), 56006763c74SThomas Petazzoni MPP_FUNCTION(0x05, "pex0", "clkreq"), 561bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 562bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 563bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 564bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 565bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 566bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 567bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 568bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 569bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 570bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 571bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 572bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 57306763c74SThomas Petazzoni MPP_MODE(12, 57406763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 57506763c74SThomas Petazzoni MPP_FUNCTION(0x01, "sata", "act"), 57606763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "rts"), 57706763c74SThomas Petazzoni MPP_FUNCTION(0x03, "audio0", "extclk"), 57806763c74SThomas Petazzoni MPP_FUNCTION(0x04, "sdio1", "cd"), 579bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 580bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 581bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 582bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 583bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 584bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 585bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 586bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 587bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 588bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 589bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 590bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 59106763c74SThomas Petazzoni MPP_MODE(13, 59206763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 59306763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "cts"), 59406763c74SThomas Petazzoni MPP_FUNCTION(0x03, "audio1", "extclk"), 59506763c74SThomas Petazzoni MPP_FUNCTION(0x04, "sdio1", "wp"), 59606763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ssp", "extclk"), 597bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 598bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 599bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 600bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 601bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 602bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 603bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 604bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 605bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 606bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 607bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 608bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 60906763c74SThomas Petazzoni MPP_MODE(14, 61006763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 61106763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "txd"), 61206763c74SThomas Petazzoni MPP_FUNCTION(0x04, "sdio1", "buspwr"), 61306763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ssp", "rxd"), 614bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 615bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 616bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 617bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 618bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 619bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 620bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 621bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 622bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 623bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 624bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 625bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 62606763c74SThomas Petazzoni MPP_MODE(15, 62706763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 62806763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "rxd"), 62906763c74SThomas Petazzoni MPP_FUNCTION(0x04, "sdio1", "ledctrl"), 63006763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ssp", "sfrm"), 631bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 632bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 633bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 634bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 635bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 636bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 637bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 638bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 639bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 640bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 641bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 642bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 64306763c74SThomas Petazzoni MPP_MODE(16, 64406763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 64506763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "rts"), 64606763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "cd"), 64706763c74SThomas Petazzoni MPP_FUNCTION(0x04, "lcd-spi", "cs1"), 64806763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ac97", "sdi1")), 64906763c74SThomas Petazzoni MPP_MODE(17, 65006763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 65106763c74SThomas Petazzoni MPP_FUNCTION(0x01, "ac97-1", "sysclko"), 65206763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "cts"), 65306763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "wp"), 65406763c74SThomas Petazzoni MPP_FUNCTION(0x04, "twsi", "sda"), 65506763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ac97", "sdi2")), 65606763c74SThomas Petazzoni MPP_MODE(18, 65706763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 65806763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "txd"), 65906763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "buspwr"), 66006763c74SThomas Petazzoni MPP_FUNCTION(0x04, "lcd0", "pwm"), 66106763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ac97", "sdi3")), 66206763c74SThomas Petazzoni MPP_MODE(19, 66306763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 66406763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "rxd"), 66506763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "ledctrl"), 66606763c74SThomas Petazzoni MPP_FUNCTION(0x04, "twsi", "sck")), 66706763c74SThomas Petazzoni MPP_MODE(20, 66806763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 66906763c74SThomas Petazzoni MPP_FUNCTION(0x01, "ac97", "sysclko"), 67006763c74SThomas Petazzoni MPP_FUNCTION(0x02, "lcd-spi", "miso"), 67106763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "cd"), 67206763c74SThomas Petazzoni MPP_FUNCTION(0x05, "sdio0", "cd"), 67306763c74SThomas Petazzoni MPP_FUNCTION(0x06, "spi1", "miso")), 67406763c74SThomas Petazzoni MPP_MODE(21, 67506763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 67606763c74SThomas Petazzoni MPP_FUNCTION(0x01, "uart1", "rts"), 67706763c74SThomas Petazzoni MPP_FUNCTION(0x02, "lcd-spi", "cs0"), 67806763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "wp"), 67906763c74SThomas Petazzoni MPP_FUNCTION(0x04, "ssp", "sfrm"), 68006763c74SThomas Petazzoni MPP_FUNCTION(0x05, "sdio0", "wp"), 68106763c74SThomas Petazzoni MPP_FUNCTION(0x06, "spi1", "cs")), 68206763c74SThomas Petazzoni MPP_MODE(22, 68306763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 68406763c74SThomas Petazzoni MPP_FUNCTION(0x01, "uart1", "cts"), 68506763c74SThomas Petazzoni MPP_FUNCTION(0x02, "lcd-spi", "mosi"), 68606763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "buspwr"), 68706763c74SThomas Petazzoni MPP_FUNCTION(0x04, "ssp", "txd"), 68806763c74SThomas Petazzoni MPP_FUNCTION(0x05, "sdio0", "buspwr"), 68906763c74SThomas Petazzoni MPP_FUNCTION(0x06, "spi1", "mosi")), 69006763c74SThomas Petazzoni MPP_MODE(23, 69106763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 69206763c74SThomas Petazzoni MPP_FUNCTION(0x02, "lcd-spi", "sck"), 69306763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "ledctrl"), 69406763c74SThomas Petazzoni MPP_FUNCTION(0x04, "ssp", "sclk"), 69506763c74SThomas Petazzoni MPP_FUNCTION(0x05, "sdio0", "ledctrl"), 69606763c74SThomas Petazzoni MPP_FUNCTION(0x06, "spi1", "sck")), 69706763c74SThomas Petazzoni MPP_MODE(24, 69806763c74SThomas Petazzoni MPP_FUNCTION(0x00, "camera", NULL), 69906763c74SThomas Petazzoni MPP_FUNCTION(0x01, "gpio", NULL)), 70006763c74SThomas Petazzoni MPP_MODE(40, 70106763c74SThomas Petazzoni MPP_FUNCTION(0x00, "sdio0", NULL), 70206763c74SThomas Petazzoni MPP_FUNCTION(0x01, "gpio", NULL)), 70306763c74SThomas Petazzoni MPP_MODE(46, 70406763c74SThomas Petazzoni MPP_FUNCTION(0x00, "sdio1", NULL), 70506763c74SThomas Petazzoni MPP_FUNCTION(0x01, "gpio", NULL)), 70606763c74SThomas Petazzoni MPP_MODE(52, 70706763c74SThomas Petazzoni MPP_FUNCTION(0x00, "i2s1/spdifo", NULL), 70806763c74SThomas Petazzoni MPP_FUNCTION(0x02, "i2s1", NULL), 70906763c74SThomas Petazzoni MPP_FUNCTION(0x08, "spdifo", NULL), 71006763c74SThomas Petazzoni MPP_FUNCTION(0x0a, "gpio", NULL), 71106763c74SThomas Petazzoni MPP_FUNCTION(0x0b, "twsi", NULL), 71206763c74SThomas Petazzoni MPP_FUNCTION(0x0c, "ssp/spdifo", NULL), 71306763c74SThomas Petazzoni MPP_FUNCTION(0x0e, "ssp", NULL), 71406763c74SThomas Petazzoni MPP_FUNCTION(0x0f, "ssp/twsi", NULL)), 71506763c74SThomas Petazzoni MPP_MODE(58, 71606763c74SThomas Petazzoni MPP_FUNCTION(0x00, "spi0", NULL), 71706763c74SThomas Petazzoni MPP_FUNCTION(0x01, "gpio", NULL)), 71806763c74SThomas Petazzoni MPP_MODE(62, 71906763c74SThomas Petazzoni MPP_FUNCTION(0x00, "uart1", NULL), 72006763c74SThomas Petazzoni MPP_FUNCTION(0x01, "gpio", NULL)), 72106763c74SThomas Petazzoni MPP_MODE(64, 72206763c74SThomas Petazzoni MPP_FUNCTION(0x00, "nand", NULL), 72306763c74SThomas Petazzoni MPP_FUNCTION(0x01, "gpo", NULL)), 72406763c74SThomas Petazzoni MPP_MODE(72, 72506763c74SThomas Petazzoni MPP_FUNCTION(0x00, "i2s", NULL), 72606763c74SThomas Petazzoni MPP_FUNCTION(0x01, "ac97", NULL)), 72706763c74SThomas Petazzoni MPP_MODE(73, 72806763c74SThomas Petazzoni MPP_FUNCTION(0x00, "twsi-none", NULL), 72906763c74SThomas Petazzoni MPP_FUNCTION(0x01, "twsi-opt1", NULL), 73006763c74SThomas Petazzoni MPP_FUNCTION(0x02, "twsi-opt2", NULL), 73106763c74SThomas Petazzoni MPP_FUNCTION(0x03, "twsi-opt3", NULL)), 73206763c74SThomas Petazzoni }; 73306763c74SThomas Petazzoni 73406763c74SThomas Petazzoni static struct pinctrl_gpio_range dove_mpp_gpio_ranges[] = { 73506763c74SThomas Petazzoni MPP_GPIO_RANGE(0, 0, 0, 32), 73606763c74SThomas Petazzoni MPP_GPIO_RANGE(1, 32, 32, 32), 73706763c74SThomas Petazzoni MPP_GPIO_RANGE(2, 64, 64, 8), 73806763c74SThomas Petazzoni }; 73906763c74SThomas Petazzoni 74006763c74SThomas Petazzoni static struct mvebu_pinctrl_soc_info dove_pinctrl_info = { 74106763c74SThomas Petazzoni .controls = dove_mpp_controls, 74206763c74SThomas Petazzoni .ncontrols = ARRAY_SIZE(dove_mpp_controls), 74306763c74SThomas Petazzoni .modes = dove_mpp_modes, 74406763c74SThomas Petazzoni .nmodes = ARRAY_SIZE(dove_mpp_modes), 74506763c74SThomas Petazzoni .gpioranges = dove_mpp_gpio_ranges, 74606763c74SThomas Petazzoni .ngpioranges = ARRAY_SIZE(dove_mpp_gpio_ranges), 74706763c74SThomas Petazzoni .variant = 0, 74806763c74SThomas Petazzoni }; 74906763c74SThomas Petazzoni 75006763c74SThomas Petazzoni static struct clk *clk; 75106763c74SThomas Petazzoni 75223259f19SKrzysztof Kozlowski static const struct of_device_id dove_pinctrl_of_match[] = { 75306763c74SThomas Petazzoni { .compatible = "marvell,dove-pinctrl", .data = &dove_pinctrl_info }, 75406763c74SThomas Petazzoni { } 75506763c74SThomas Petazzoni }; 75606763c74SThomas Petazzoni 75723259f19SKrzysztof Kozlowski static const struct regmap_config gc_regmap_config = { 758e91f7916SSebastian Hesselbarth .reg_bits = 32, 759e91f7916SSebastian Hesselbarth .val_bits = 32, 760e91f7916SSebastian Hesselbarth .reg_stride = 4, 761e91f7916SSebastian Hesselbarth .max_register = 5, 762e91f7916SSebastian Hesselbarth }; 763e91f7916SSebastian Hesselbarth 764150632b0SGreg Kroah-Hartman static int dove_pinctrl_probe(struct platform_device *pdev) 76506763c74SThomas Petazzoni { 7664d73fc77SSebastian Hesselbarth struct resource *res, *mpp_res; 7674d73fc77SSebastian Hesselbarth struct resource fb_res; 76806763c74SThomas Petazzoni const struct of_device_id *match = 76906763c74SThomas Petazzoni of_match_device(dove_pinctrl_of_match, &pdev->dev); 770ad9ec4ecSRussell King struct mvebu_mpp_ctrl_data *mpp_data; 771ad9ec4ecSRussell King void __iomem *base; 772ad9ec4ecSRussell King int i; 773ad9ec4ecSRussell King 77416fa36beSAndrew Lunn pdev->dev.platform_data = (void *)match->data; 77506763c74SThomas Petazzoni 77606763c74SThomas Petazzoni /* 77706763c74SThomas Petazzoni * General MPP Configuration Register is part of pdma registers. 77806763c74SThomas Petazzoni * grab clk to make sure it is ticking. 77906763c74SThomas Petazzoni */ 78006763c74SThomas Petazzoni clk = devm_clk_get(&pdev->dev, NULL); 781ba607b62SSebastian Hesselbarth if (IS_ERR(clk)) { 782ba607b62SSebastian Hesselbarth dev_err(&pdev->dev, "Unable to get pdma clock"); 7835795c6acSRusty Russell return PTR_ERR(clk); 784ba607b62SSebastian Hesselbarth } 78506763c74SThomas Petazzoni clk_prepare_enable(clk); 78606763c74SThomas Petazzoni 7874d73fc77SSebastian Hesselbarth mpp_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 788ad9ec4ecSRussell King base = devm_ioremap_resource(&pdev->dev, mpp_res); 789ad9ec4ecSRussell King if (IS_ERR(base)) 790ad9ec4ecSRussell King return PTR_ERR(base); 791ad9ec4ecSRussell King 792ad9ec4ecSRussell King mpp_data = devm_kcalloc(&pdev->dev, dove_pinctrl_info.ncontrols, 793ad9ec4ecSRussell King sizeof(*mpp_data), GFP_KERNEL); 794ad9ec4ecSRussell King if (!mpp_data) 795ad9ec4ecSRussell King return -ENOMEM; 796ad9ec4ecSRussell King 797ad9ec4ecSRussell King dove_pinctrl_info.control_data = mpp_data; 798ad9ec4ecSRussell King for (i = 0; i < ARRAY_SIZE(dove_mpp_controls); i++) 799ad9ec4ecSRussell King mpp_data[i].base = base; 8001217b790SSebastian Hesselbarth 8014d73fc77SSebastian Hesselbarth /* prepare fallback resource */ 8024d73fc77SSebastian Hesselbarth memcpy(&fb_res, mpp_res, sizeof(struct resource)); 8034d73fc77SSebastian Hesselbarth fb_res.start = 0; 8044d73fc77SSebastian Hesselbarth 8054d73fc77SSebastian Hesselbarth res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 8064d73fc77SSebastian Hesselbarth if (!res) { 8074d73fc77SSebastian Hesselbarth dev_warn(&pdev->dev, "falling back to hardcoded MPP4 resource\n"); 8084d73fc77SSebastian Hesselbarth adjust_resource(&fb_res, 8094d73fc77SSebastian Hesselbarth (mpp_res->start & INT_REGS_MASK) + MPP4_REGS_OFFS, 0x4); 8104d73fc77SSebastian Hesselbarth res = &fb_res; 8114d73fc77SSebastian Hesselbarth } 8124d73fc77SSebastian Hesselbarth 8134d73fc77SSebastian Hesselbarth mpp4_base = devm_ioremap_resource(&pdev->dev, res); 8144d73fc77SSebastian Hesselbarth if (IS_ERR(mpp4_base)) 8154d73fc77SSebastian Hesselbarth return PTR_ERR(mpp4_base); 8164d73fc77SSebastian Hesselbarth 8174d73fc77SSebastian Hesselbarth res = platform_get_resource(pdev, IORESOURCE_MEM, 2); 8184d73fc77SSebastian Hesselbarth if (!res) { 8194d73fc77SSebastian Hesselbarth dev_warn(&pdev->dev, "falling back to hardcoded PMU resource\n"); 8204d73fc77SSebastian Hesselbarth adjust_resource(&fb_res, 8214d73fc77SSebastian Hesselbarth (mpp_res->start & INT_REGS_MASK) + PMU_REGS_OFFS, 0x8); 8224d73fc77SSebastian Hesselbarth res = &fb_res; 8234d73fc77SSebastian Hesselbarth } 8244d73fc77SSebastian Hesselbarth 8254d73fc77SSebastian Hesselbarth pmu_base = devm_ioremap_resource(&pdev->dev, res); 8264d73fc77SSebastian Hesselbarth if (IS_ERR(pmu_base)) 8274d73fc77SSebastian Hesselbarth return PTR_ERR(pmu_base); 8284d73fc77SSebastian Hesselbarth 829e91f7916SSebastian Hesselbarth gconfmap = syscon_regmap_lookup_by_compatible("marvell,dove-global-config"); 830e91f7916SSebastian Hesselbarth if (IS_ERR(gconfmap)) { 831e91f7916SSebastian Hesselbarth void __iomem *gc_base; 832e91f7916SSebastian Hesselbarth 833e91f7916SSebastian Hesselbarth dev_warn(&pdev->dev, "falling back to hardcoded global registers\n"); 834e91f7916SSebastian Hesselbarth adjust_resource(&fb_res, 835e91f7916SSebastian Hesselbarth (mpp_res->start & INT_REGS_MASK) + GC_REGS_OFFS, 0x14); 836e91f7916SSebastian Hesselbarth gc_base = devm_ioremap_resource(&pdev->dev, &fb_res); 837e91f7916SSebastian Hesselbarth if (IS_ERR(gc_base)) 838e91f7916SSebastian Hesselbarth return PTR_ERR(gc_base); 839e91f7916SSebastian Hesselbarth gconfmap = devm_regmap_init_mmio(&pdev->dev, 840e91f7916SSebastian Hesselbarth gc_base, &gc_regmap_config); 841e91f7916SSebastian Hesselbarth if (IS_ERR(gconfmap)) 842e91f7916SSebastian Hesselbarth return PTR_ERR(gconfmap); 843e91f7916SSebastian Hesselbarth } 844e91f7916SSebastian Hesselbarth 8454d73fc77SSebastian Hesselbarth /* Warn on any missing DT resource */ 8463c7d5637SSebastian Hesselbarth if (fb_res.start) 8473c7d5637SSebastian Hesselbarth dev_warn(&pdev->dev, FW_BUG "Missing pinctrl regs in DTB. Please update your firmware.\n"); 8484d73fc77SSebastian Hesselbarth 84906763c74SThomas Petazzoni return mvebu_pinctrl_probe(pdev); 85006763c74SThomas Petazzoni } 85106763c74SThomas Petazzoni 85206763c74SThomas Petazzoni static struct platform_driver dove_pinctrl_driver = { 85306763c74SThomas Petazzoni .driver = { 85406763c74SThomas Petazzoni .name = "dove-pinctrl", 855fdbde81bSPaul Gortmaker .suppress_bind_attrs = true, 856f2e9394dSSachin Kamat .of_match_table = dove_pinctrl_of_match, 85706763c74SThomas Petazzoni }, 85806763c74SThomas Petazzoni .probe = dove_pinctrl_probe, 85906763c74SThomas Petazzoni }; 860fdbde81bSPaul Gortmaker builtin_platform_driver(dove_pinctrl_driver); 861