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 3300202b01SSebastian Hesselbarth /* MPP Base registers */ 3400202b01SSebastian Hesselbarth #define PMU_MPP_GENERAL_CTRL 0x10 3500202b01SSebastian Hesselbarth #define AU0_AC97_SEL BIT(16) 3600202b01SSebastian Hesselbarth 372c4b229bSSebastian Hesselbarth /* MPP Control 4 register */ 382c4b229bSSebastian Hesselbarth #define SPI_GPIO_SEL BIT(5) 392c4b229bSSebastian Hesselbarth #define UART1_GPIO_SEL BIT(4) 402c4b229bSSebastian Hesselbarth #define AU1_GPIO_SEL BIT(3) 412c4b229bSSebastian Hesselbarth #define CAM_GPIO_SEL BIT(2) 422c4b229bSSebastian Hesselbarth #define SD1_GPIO_SEL BIT(1) 432c4b229bSSebastian Hesselbarth #define SD0_GPIO_SEL BIT(0) 442c4b229bSSebastian Hesselbarth 4518e6f28eSSebastian Hesselbarth /* PMU Signal Select registers */ 4618e6f28eSSebastian Hesselbarth #define PMU_SIGNAL_SELECT_0 0x00 4718e6f28eSSebastian Hesselbarth #define PMU_SIGNAL_SELECT_1 0x04 4818e6f28eSSebastian Hesselbarth 496da67cabSSebastian Hesselbarth /* Global Config regmap registers */ 506da67cabSSebastian Hesselbarth #define GLOBAL_CONFIG_1 0x00 516da67cabSSebastian Hesselbarth #define TWSI_ENABLE_OPTION1 BIT(7) 526da67cabSSebastian Hesselbarth #define GLOBAL_CONFIG_2 0x04 536da67cabSSebastian Hesselbarth #define TWSI_ENABLE_OPTION2 BIT(20) 546da67cabSSebastian Hesselbarth #define TWSI_ENABLE_OPTION3 BIT(21) 556da67cabSSebastian Hesselbarth #define TWSI_OPTION3_GPIO BIT(22) 566da67cabSSebastian Hesselbarth #define SSP_CTRL_STATUS_1 0x08 576da67cabSSebastian Hesselbarth #define SSP_ON_AU1 BIT(0) 586da67cabSSebastian Hesselbarth #define MPP_GENERAL_CONFIG 0x10 596da67cabSSebastian Hesselbarth #define AU1_SPDIFO_GPIO_EN BIT(1) 606da67cabSSebastian Hesselbarth #define NAND_GPIO_EN BIT(0) 616da67cabSSebastian 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 69*20955c5fSRussell King static int dove_mpp_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid, 70*20955c5fSRussell King unsigned long *config) 7117bdec67SSebastian Hesselbarth { 7217bdec67SSebastian Hesselbarth return default_mpp_ctrl_get(mpp_base, pid, config); 7317bdec67SSebastian Hesselbarth } 7417bdec67SSebastian Hesselbarth 75*20955c5fSRussell King static int dove_mpp_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid, 76*20955c5fSRussell King unsigned long config) 7717bdec67SSebastian Hesselbarth { 7817bdec67SSebastian Hesselbarth return default_mpp_ctrl_set(mpp_base, pid, config); 7917bdec67SSebastian Hesselbarth } 8017bdec67SSebastian Hesselbarth 81*20955c5fSRussell King static int dove_pmu_mpp_ctrl_get(struct mvebu_mpp_ctrl_data *data, 82*20955c5fSRussell 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; 8600202b01SSebastian Hesselbarth unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL); 87bbd7b275SSebastian Hesselbarth unsigned long func; 8806763c74SThomas Petazzoni 8978c2c3d3SSebastian Hesselbarth if ((pmu & BIT(pid)) == 0) 9078c2c3d3SSebastian Hesselbarth return default_mpp_ctrl_get(mpp_base, pid, config); 9178c2c3d3SSebastian Hesselbarth 9218e6f28eSSebastian Hesselbarth func = readl(pmu_base + PMU_SIGNAL_SELECT_0 + off); 9317bdec67SSebastian Hesselbarth *config = (func >> shift) & MVEBU_MPP_MASK; 94bbd7b275SSebastian Hesselbarth *config |= CONFIG_PMU; 9578c2c3d3SSebastian Hesselbarth 9606763c74SThomas Petazzoni return 0; 9706763c74SThomas Petazzoni } 9806763c74SThomas Petazzoni 99*20955c5fSRussell King static int dove_pmu_mpp_ctrl_set(struct mvebu_mpp_ctrl_data *data, 100*20955c5fSRussell King unsigned pid, unsigned long config) 10106763c74SThomas Petazzoni { 10217bdec67SSebastian Hesselbarth unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; 10317bdec67SSebastian Hesselbarth unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; 10400202b01SSebastian Hesselbarth unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL); 105bbd7b275SSebastian Hesselbarth unsigned long func; 10606763c74SThomas Petazzoni 10778c2c3d3SSebastian Hesselbarth if ((config & CONFIG_PMU) == 0) { 10800202b01SSebastian Hesselbarth writel(pmu & ~BIT(pid), mpp_base + PMU_MPP_GENERAL_CTRL); 10978c2c3d3SSebastian Hesselbarth return default_mpp_ctrl_set(mpp_base, pid, config); 11078c2c3d3SSebastian Hesselbarth } 11178c2c3d3SSebastian Hesselbarth 11200202b01SSebastian Hesselbarth writel(pmu | BIT(pid), mpp_base + PMU_MPP_GENERAL_CTRL); 11318e6f28eSSebastian Hesselbarth func = readl(pmu_base + PMU_SIGNAL_SELECT_0 + off); 11417bdec67SSebastian Hesselbarth func &= ~(MVEBU_MPP_MASK << shift); 11517bdec67SSebastian Hesselbarth func |= (config & MVEBU_MPP_MASK) << shift; 11618e6f28eSSebastian Hesselbarth writel(func, pmu_base + PMU_SIGNAL_SELECT_0 + off); 11778c2c3d3SSebastian Hesselbarth 11806763c74SThomas Petazzoni return 0; 11906763c74SThomas Petazzoni } 12006763c74SThomas Petazzoni 121*20955c5fSRussell King static int dove_mpp4_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid, 122*20955c5fSRussell King unsigned long *config) 12306763c74SThomas Petazzoni { 1242c4b229bSSebastian Hesselbarth unsigned long mpp4 = readl(mpp4_base); 12506763c74SThomas Petazzoni unsigned long mask; 12606763c74SThomas Petazzoni 1272035d39dSSebastian Hesselbarth switch (pid) { 12806763c74SThomas Petazzoni case 24: /* mpp_camera */ 1292c4b229bSSebastian Hesselbarth mask = CAM_GPIO_SEL; 13006763c74SThomas Petazzoni break; 13106763c74SThomas Petazzoni case 40: /* mpp_sdio0 */ 1322c4b229bSSebastian Hesselbarth mask = SD0_GPIO_SEL; 13306763c74SThomas Petazzoni break; 13406763c74SThomas Petazzoni case 46: /* mpp_sdio1 */ 1352c4b229bSSebastian Hesselbarth mask = SD1_GPIO_SEL; 13606763c74SThomas Petazzoni break; 13706763c74SThomas Petazzoni case 58: /* mpp_spi0 */ 1382c4b229bSSebastian Hesselbarth mask = SPI_GPIO_SEL; 13906763c74SThomas Petazzoni break; 14006763c74SThomas Petazzoni case 62: /* mpp_uart1 */ 1412c4b229bSSebastian Hesselbarth mask = UART1_GPIO_SEL; 14206763c74SThomas Petazzoni break; 14306763c74SThomas Petazzoni default: 14406763c74SThomas Petazzoni return -EINVAL; 14506763c74SThomas Petazzoni } 14606763c74SThomas Petazzoni 14706763c74SThomas Petazzoni *config = ((mpp4 & mask) != 0); 14806763c74SThomas Petazzoni 14906763c74SThomas Petazzoni return 0; 15006763c74SThomas Petazzoni } 15106763c74SThomas Petazzoni 152*20955c5fSRussell King static int dove_mpp4_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid, 153*20955c5fSRussell King unsigned long config) 15406763c74SThomas Petazzoni { 1552c4b229bSSebastian Hesselbarth unsigned long mpp4 = readl(mpp4_base); 15606763c74SThomas Petazzoni unsigned long mask; 15706763c74SThomas Petazzoni 1582035d39dSSebastian Hesselbarth switch (pid) { 15906763c74SThomas Petazzoni case 24: /* mpp_camera */ 1602c4b229bSSebastian Hesselbarth mask = CAM_GPIO_SEL; 16106763c74SThomas Petazzoni break; 16206763c74SThomas Petazzoni case 40: /* mpp_sdio0 */ 1632c4b229bSSebastian Hesselbarth mask = SD0_GPIO_SEL; 16406763c74SThomas Petazzoni break; 16506763c74SThomas Petazzoni case 46: /* mpp_sdio1 */ 1662c4b229bSSebastian Hesselbarth mask = SD1_GPIO_SEL; 16706763c74SThomas Petazzoni break; 16806763c74SThomas Petazzoni case 58: /* mpp_spi0 */ 1692c4b229bSSebastian Hesselbarth mask = SPI_GPIO_SEL; 17006763c74SThomas Petazzoni break; 17106763c74SThomas Petazzoni case 62: /* mpp_uart1 */ 1722c4b229bSSebastian Hesselbarth mask = UART1_GPIO_SEL; 17306763c74SThomas Petazzoni break; 17406763c74SThomas Petazzoni default: 17506763c74SThomas Petazzoni return -EINVAL; 17606763c74SThomas Petazzoni } 17706763c74SThomas Petazzoni 17806763c74SThomas Petazzoni mpp4 &= ~mask; 17906763c74SThomas Petazzoni if (config) 18006763c74SThomas Petazzoni mpp4 |= mask; 18106763c74SThomas Petazzoni 1822c4b229bSSebastian Hesselbarth writel(mpp4, mpp4_base); 18306763c74SThomas Petazzoni 18406763c74SThomas Petazzoni return 0; 18506763c74SThomas Petazzoni } 18606763c74SThomas Petazzoni 187*20955c5fSRussell King static int dove_nand_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid, 188*20955c5fSRussell King unsigned long *config) 18906763c74SThomas Petazzoni { 1906da67cabSSebastian Hesselbarth unsigned int gmpp; 19106763c74SThomas Petazzoni 1926da67cabSSebastian Hesselbarth regmap_read(gconfmap, MPP_GENERAL_CONFIG, &gmpp); 1936da67cabSSebastian Hesselbarth *config = ((gmpp & NAND_GPIO_EN) != 0); 19406763c74SThomas Petazzoni 19506763c74SThomas Petazzoni return 0; 19606763c74SThomas Petazzoni } 19706763c74SThomas Petazzoni 198*20955c5fSRussell King static int dove_nand_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid, 199*20955c5fSRussell King unsigned long config) 20006763c74SThomas Petazzoni { 2016da67cabSSebastian Hesselbarth regmap_update_bits(gconfmap, MPP_GENERAL_CONFIG, 2026da67cabSSebastian Hesselbarth NAND_GPIO_EN, 2036da67cabSSebastian Hesselbarth (config) ? NAND_GPIO_EN : 0); 20406763c74SThomas Petazzoni return 0; 20506763c74SThomas Petazzoni } 20606763c74SThomas Petazzoni 207*20955c5fSRussell King static int dove_audio0_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid, 208*20955c5fSRussell King unsigned long *config) 20906763c74SThomas Petazzoni { 21000202b01SSebastian Hesselbarth unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL); 21106763c74SThomas Petazzoni 21200202b01SSebastian Hesselbarth *config = ((pmu & AU0_AC97_SEL) != 0); 21306763c74SThomas Petazzoni 21406763c74SThomas Petazzoni return 0; 21506763c74SThomas Petazzoni } 21606763c74SThomas Petazzoni 217*20955c5fSRussell King static int dove_audio0_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid, 218*20955c5fSRussell King unsigned long config) 21906763c74SThomas Petazzoni { 22000202b01SSebastian Hesselbarth unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL); 22106763c74SThomas Petazzoni 22200202b01SSebastian Hesselbarth pmu &= ~AU0_AC97_SEL; 22306763c74SThomas Petazzoni if (config) 22400202b01SSebastian Hesselbarth pmu |= AU0_AC97_SEL; 22500202b01SSebastian Hesselbarth writel(pmu, mpp_base + PMU_MPP_GENERAL_CTRL); 22606763c74SThomas Petazzoni 22706763c74SThomas Petazzoni return 0; 22806763c74SThomas Petazzoni } 22906763c74SThomas Petazzoni 230*20955c5fSRussell King static int dove_audio1_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid, 231*20955c5fSRussell King unsigned long *config) 23206763c74SThomas Petazzoni { 2332c4b229bSSebastian Hesselbarth unsigned int mpp4 = readl(mpp4_base); 2346da67cabSSebastian Hesselbarth unsigned int sspc1; 2356da67cabSSebastian Hesselbarth unsigned int gmpp; 2366da67cabSSebastian Hesselbarth unsigned int gcfg2; 2376da67cabSSebastian Hesselbarth 2386da67cabSSebastian Hesselbarth regmap_read(gconfmap, SSP_CTRL_STATUS_1, &sspc1); 2396da67cabSSebastian Hesselbarth regmap_read(gconfmap, MPP_GENERAL_CONFIG, &gmpp); 2406da67cabSSebastian Hesselbarth regmap_read(gconfmap, GLOBAL_CONFIG_2, &gcfg2); 24106763c74SThomas Petazzoni 24206763c74SThomas Petazzoni *config = 0; 2432c4b229bSSebastian Hesselbarth if (mpp4 & AU1_GPIO_SEL) 24406763c74SThomas Petazzoni *config |= BIT(3); 2456da67cabSSebastian Hesselbarth if (sspc1 & SSP_ON_AU1) 24606763c74SThomas Petazzoni *config |= BIT(2); 2476da67cabSSebastian Hesselbarth if (gmpp & AU1_SPDIFO_GPIO_EN) 24806763c74SThomas Petazzoni *config |= BIT(1); 2496da67cabSSebastian Hesselbarth if (gcfg2 & TWSI_OPTION3_GPIO) 25006763c74SThomas Petazzoni *config |= BIT(0); 25106763c74SThomas Petazzoni 25206763c74SThomas Petazzoni /* SSP/TWSI only if I2S1 not set*/ 25306763c74SThomas Petazzoni if ((*config & BIT(3)) == 0) 25406763c74SThomas Petazzoni *config &= ~(BIT(2) | BIT(0)); 25506763c74SThomas Petazzoni /* TWSI only if SPDIFO not set*/ 25606763c74SThomas Petazzoni if ((*config & BIT(1)) == 0) 25706763c74SThomas Petazzoni *config &= ~BIT(0); 25806763c74SThomas Petazzoni return 0; 25906763c74SThomas Petazzoni } 26006763c74SThomas Petazzoni 261*20955c5fSRussell King static int dove_audio1_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid, 262*20955c5fSRussell King unsigned long config) 26306763c74SThomas Petazzoni { 2642c4b229bSSebastian Hesselbarth unsigned int mpp4 = readl(mpp4_base); 26506763c74SThomas Petazzoni 2662c4b229bSSebastian Hesselbarth mpp4 &= ~AU1_GPIO_SEL; 26706763c74SThomas Petazzoni if (config & BIT(3)) 2682c4b229bSSebastian Hesselbarth mpp4 |= AU1_GPIO_SEL; 2692c4b229bSSebastian Hesselbarth writel(mpp4, mpp4_base); 2706da67cabSSebastian Hesselbarth 2716da67cabSSebastian Hesselbarth regmap_update_bits(gconfmap, SSP_CTRL_STATUS_1, 2726da67cabSSebastian Hesselbarth SSP_ON_AU1, 2736da67cabSSebastian Hesselbarth (config & BIT(2)) ? SSP_ON_AU1 : 0); 2746da67cabSSebastian Hesselbarth regmap_update_bits(gconfmap, MPP_GENERAL_CONFIG, 2756da67cabSSebastian Hesselbarth AU1_SPDIFO_GPIO_EN, 2766da67cabSSebastian Hesselbarth (config & BIT(1)) ? AU1_SPDIFO_GPIO_EN : 0); 2776da67cabSSebastian Hesselbarth regmap_update_bits(gconfmap, GLOBAL_CONFIG_2, 2786da67cabSSebastian Hesselbarth TWSI_OPTION3_GPIO, 2796da67cabSSebastian Hesselbarth (config & BIT(0)) ? TWSI_OPTION3_GPIO : 0); 28006763c74SThomas Petazzoni 28106763c74SThomas Petazzoni return 0; 28206763c74SThomas Petazzoni } 28306763c74SThomas Petazzoni 28406763c74SThomas Petazzoni /* mpp[52:57] gpio pins depend heavily on current config; 28506763c74SThomas Petazzoni * gpio_req does not try to mux in gpio capabilities to not 28606763c74SThomas Petazzoni * break other functions. If you require all mpps as gpio 28706763c74SThomas Petazzoni * enforce gpio setting by pinctrl mapping. 28806763c74SThomas Petazzoni */ 289*20955c5fSRussell King static int dove_audio1_ctrl_gpio_req(struct mvebu_mpp_ctrl_data *data, 290*20955c5fSRussell King unsigned pid) 29106763c74SThomas Petazzoni { 29206763c74SThomas Petazzoni unsigned long config; 29306763c74SThomas Petazzoni 294*20955c5fSRussell King dove_audio1_ctrl_get(data, pid, &config); 29506763c74SThomas Petazzoni 29606763c74SThomas Petazzoni switch (config) { 29706763c74SThomas Petazzoni case 0x02: /* i2s1 : gpio[56:57] */ 29806763c74SThomas Petazzoni case 0x0e: /* ssp : gpio[56:57] */ 29906763c74SThomas Petazzoni if (pid >= 56) 30006763c74SThomas Petazzoni return 0; 30106763c74SThomas Petazzoni return -ENOTSUPP; 30206763c74SThomas Petazzoni case 0x08: /* spdifo : gpio[52:55] */ 30306763c74SThomas Petazzoni case 0x0b: /* twsi : gpio[52:55] */ 30406763c74SThomas Petazzoni if (pid <= 55) 30506763c74SThomas Petazzoni return 0; 30606763c74SThomas Petazzoni return -ENOTSUPP; 30706763c74SThomas Petazzoni case 0x0a: /* all gpio */ 30806763c74SThomas Petazzoni return 0; 30906763c74SThomas Petazzoni /* 0x00 : i2s1/spdifo : no gpio */ 31006763c74SThomas Petazzoni /* 0x0c : ssp/spdifo : no gpio */ 31106763c74SThomas Petazzoni /* 0x0f : ssp/twsi : no gpio */ 31206763c74SThomas Petazzoni } 31306763c74SThomas Petazzoni return -ENOTSUPP; 31406763c74SThomas Petazzoni } 31506763c74SThomas Petazzoni 31606763c74SThomas Petazzoni /* mpp[52:57] has gpio pins capable of in and out */ 317*20955c5fSRussell King static int dove_audio1_ctrl_gpio_dir(struct mvebu_mpp_ctrl_data *data, 318*20955c5fSRussell King unsigned pid, bool input) 31906763c74SThomas Petazzoni { 32006763c74SThomas Petazzoni if (pid < 52 || pid > 57) 32106763c74SThomas Petazzoni return -ENOTSUPP; 32206763c74SThomas Petazzoni return 0; 32306763c74SThomas Petazzoni } 32406763c74SThomas Petazzoni 325*20955c5fSRussell King static int dove_twsi_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid, 326*20955c5fSRussell King unsigned long *config) 32706763c74SThomas Petazzoni { 3286da67cabSSebastian Hesselbarth unsigned int gcfg1; 3296da67cabSSebastian Hesselbarth unsigned int gcfg2; 3306da67cabSSebastian Hesselbarth 3316da67cabSSebastian Hesselbarth regmap_read(gconfmap, GLOBAL_CONFIG_1, &gcfg1); 3326da67cabSSebastian Hesselbarth regmap_read(gconfmap, GLOBAL_CONFIG_2, &gcfg2); 33306763c74SThomas Petazzoni 33406763c74SThomas Petazzoni *config = 0; 3356da67cabSSebastian Hesselbarth if (gcfg1 & TWSI_ENABLE_OPTION1) 33606763c74SThomas Petazzoni *config = 1; 3376da67cabSSebastian Hesselbarth else if (gcfg2 & TWSI_ENABLE_OPTION2) 33806763c74SThomas Petazzoni *config = 2; 3396da67cabSSebastian Hesselbarth else if (gcfg2 & TWSI_ENABLE_OPTION3) 34006763c74SThomas Petazzoni *config = 3; 34106763c74SThomas Petazzoni 34206763c74SThomas Petazzoni return 0; 34306763c74SThomas Petazzoni } 34406763c74SThomas Petazzoni 345*20955c5fSRussell King static int dove_twsi_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid, 346*20955c5fSRussell King unsigned long config) 34706763c74SThomas Petazzoni { 3486da67cabSSebastian Hesselbarth unsigned int gcfg1 = 0; 3496da67cabSSebastian Hesselbarth unsigned int gcfg2 = 0; 35006763c74SThomas Petazzoni 35106763c74SThomas Petazzoni switch (config) { 35206763c74SThomas Petazzoni case 1: 3536da67cabSSebastian Hesselbarth gcfg1 = TWSI_ENABLE_OPTION1; 35406763c74SThomas Petazzoni break; 35506763c74SThomas Petazzoni case 2: 3566da67cabSSebastian Hesselbarth gcfg2 = TWSI_ENABLE_OPTION2; 35706763c74SThomas Petazzoni break; 35806763c74SThomas Petazzoni case 3: 3596da67cabSSebastian Hesselbarth gcfg2 = TWSI_ENABLE_OPTION3; 36006763c74SThomas Petazzoni break; 36106763c74SThomas Petazzoni } 36206763c74SThomas Petazzoni 3636da67cabSSebastian Hesselbarth regmap_update_bits(gconfmap, GLOBAL_CONFIG_1, 3646da67cabSSebastian Hesselbarth TWSI_ENABLE_OPTION1, 3656da67cabSSebastian Hesselbarth gcfg1); 3666da67cabSSebastian Hesselbarth regmap_update_bits(gconfmap, GLOBAL_CONFIG_2, 3676da67cabSSebastian Hesselbarth TWSI_ENABLE_OPTION2 | TWSI_ENABLE_OPTION3, 3686da67cabSSebastian Hesselbarth gcfg2); 36906763c74SThomas Petazzoni 37006763c74SThomas Petazzoni return 0; 37106763c74SThomas Petazzoni } 37206763c74SThomas Petazzoni 37330be3fb9SRussell King static const struct mvebu_mpp_ctrl dove_mpp_controls[] = { 374c2f082feSSebastian Hesselbarth MPP_FUNC_CTRL(0, 15, NULL, dove_pmu_mpp_ctrl), 3751217b790SSebastian Hesselbarth MPP_FUNC_CTRL(16, 23, NULL, dove_mpp_ctrl), 37606763c74SThomas Petazzoni MPP_FUNC_CTRL(24, 39, "mpp_camera", dove_mpp4_ctrl), 37706763c74SThomas Petazzoni MPP_FUNC_CTRL(40, 45, "mpp_sdio0", dove_mpp4_ctrl), 37806763c74SThomas Petazzoni MPP_FUNC_CTRL(46, 51, "mpp_sdio1", dove_mpp4_ctrl), 37906763c74SThomas Petazzoni MPP_FUNC_GPIO_CTRL(52, 57, "mpp_audio1", dove_audio1_ctrl), 38006763c74SThomas Petazzoni MPP_FUNC_CTRL(58, 61, "mpp_spi0", dove_mpp4_ctrl), 38106763c74SThomas Petazzoni MPP_FUNC_CTRL(62, 63, "mpp_uart1", dove_mpp4_ctrl), 38206763c74SThomas Petazzoni MPP_FUNC_CTRL(64, 71, "mpp_nand", dove_nand_ctrl), 38306763c74SThomas Petazzoni MPP_FUNC_CTRL(72, 72, "audio0", dove_audio0_ctrl), 38406763c74SThomas Petazzoni MPP_FUNC_CTRL(73, 73, "twsi", dove_twsi_ctrl), 38506763c74SThomas Petazzoni }; 38606763c74SThomas Petazzoni 38706763c74SThomas Petazzoni static struct mvebu_mpp_mode dove_mpp_modes[] = { 38806763c74SThomas Petazzoni MPP_MODE(0, 38906763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 39006763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "rts"), 39106763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "cd"), 39206763c74SThomas Petazzoni MPP_FUNCTION(0x0f, "lcd0", "pwm"), 393bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 394bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 395bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 396bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 397bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 398bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 399bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 400bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 401bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 402bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 403bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 404bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 40506763c74SThomas Petazzoni MPP_MODE(1, 40606763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 40706763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "cts"), 40806763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "wp"), 40906763c74SThomas Petazzoni MPP_FUNCTION(0x0f, "lcd1", "pwm"), 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(2, 42306763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 42406763c74SThomas Petazzoni MPP_FUNCTION(0x01, "sata", "prsnt"), 42506763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "txd"), 42606763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "buspwr"), 42706763c74SThomas Petazzoni MPP_FUNCTION(0x04, "uart1", "rts"), 428bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 429bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 430bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 431bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 432bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 433bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 434bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 435bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 436bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 437bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 438bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 439bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 44006763c74SThomas Petazzoni MPP_MODE(3, 44106763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 44206763c74SThomas Petazzoni MPP_FUNCTION(0x01, "sata", "act"), 44306763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "rxd"), 44406763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "ledctrl"), 44506763c74SThomas Petazzoni MPP_FUNCTION(0x04, "uart1", "cts"), 44606763c74SThomas Petazzoni MPP_FUNCTION(0x0f, "lcd-spi", "cs1"), 447bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 448bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 449bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 450bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 451bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 452bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 453bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 454bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 455bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 456bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 457bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 458bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 45906763c74SThomas Petazzoni MPP_MODE(4, 46006763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 46106763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "rts"), 46206763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "cd"), 46306763c74SThomas Petazzoni MPP_FUNCTION(0x04, "spi1", "miso"), 464bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 465bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 466bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 467bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 468bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 469bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 470bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 471bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 472bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 473bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 474bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 475bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 47606763c74SThomas Petazzoni MPP_MODE(5, 47706763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 47806763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "cts"), 47906763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "wp"), 48006763c74SThomas Petazzoni MPP_FUNCTION(0x04, "spi1", "cs"), 481bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 482bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 483bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 484bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 485bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 486bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 487bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 488bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 489bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 490bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 491bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 492bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 49306763c74SThomas Petazzoni MPP_MODE(6, 49406763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 49506763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "txd"), 49606763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "buspwr"), 49706763c74SThomas Petazzoni MPP_FUNCTION(0x04, "spi1", "mosi"), 498bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 499bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 500bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 501bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 502bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 503bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 504bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 505bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 506bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 507bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 508bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 509bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 51006763c74SThomas Petazzoni MPP_MODE(7, 51106763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 51206763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "rxd"), 51306763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "ledctrl"), 51406763c74SThomas Petazzoni MPP_FUNCTION(0x04, "spi1", "sck"), 515bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 516bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 517bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 518bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 519bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 520bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 521bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "core-pwr-good", NULL), 522bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 523bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 524bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 525bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 526bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 52706763c74SThomas Petazzoni MPP_MODE(8, 52806763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 52906763c74SThomas Petazzoni MPP_FUNCTION(0x01, "watchdog", "rstout"), 530bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 531bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 532bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 533bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 534bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 535bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 536bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 537bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 538bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 539bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 540bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 541bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 54206763c74SThomas Petazzoni MPP_MODE(9, 54306763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 54406763c74SThomas Petazzoni MPP_FUNCTION(0x05, "pex1", "clkreq"), 545bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 546bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 547bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 548bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 549bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 550bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 551bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 552bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 553bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 554bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 555bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 556bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 55706763c74SThomas Petazzoni MPP_MODE(10, 55806763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 55906763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ssp", "sclk"), 560bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 561bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 562bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 563bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 564bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 565bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 566bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 567bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 568bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 569bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 570bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 571bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 57206763c74SThomas Petazzoni MPP_MODE(11, 57306763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 57406763c74SThomas Petazzoni MPP_FUNCTION(0x01, "sata", "prsnt"), 57506763c74SThomas Petazzoni MPP_FUNCTION(0x02, "sata-1", "act"), 57606763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "ledctrl"), 57706763c74SThomas Petazzoni MPP_FUNCTION(0x04, "sdio1", "ledctrl"), 57806763c74SThomas Petazzoni MPP_FUNCTION(0x05, "pex0", "clkreq"), 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(12, 59206763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 59306763c74SThomas Petazzoni MPP_FUNCTION(0x01, "sata", "act"), 59406763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "rts"), 59506763c74SThomas Petazzoni MPP_FUNCTION(0x03, "audio0", "extclk"), 59606763c74SThomas Petazzoni MPP_FUNCTION(0x04, "sdio1", "cd"), 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(13, 61006763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 61106763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "cts"), 61206763c74SThomas Petazzoni MPP_FUNCTION(0x03, "audio1", "extclk"), 61306763c74SThomas Petazzoni MPP_FUNCTION(0x04, "sdio1", "wp"), 61406763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ssp", "extclk"), 615bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 616bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 617bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 618bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 619bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 620bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 621bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 622bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 623bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 624bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 625bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 626bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 62706763c74SThomas Petazzoni MPP_MODE(14, 62806763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 62906763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "txd"), 63006763c74SThomas Petazzoni MPP_FUNCTION(0x04, "sdio1", "buspwr"), 63106763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ssp", "rxd"), 632bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 633bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 634bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 635bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 636bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 637bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 638bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 639bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 640bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 641bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 642bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 643bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 64406763c74SThomas Petazzoni MPP_MODE(15, 64506763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 64606763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart2", "rxd"), 64706763c74SThomas Petazzoni MPP_FUNCTION(0x04, "sdio1", "ledctrl"), 64806763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ssp", "sfrm"), 649bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x0, "pmu-nc", NULL), 650bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x1, "pmu-low", NULL), 651bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x2, "pmu-high", NULL), 652bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x3, "pmic", "sdi"), 653bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x4, "cpu-pwr-down", NULL), 654bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x5, "standby-pwr-down", NULL), 655bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0x8, "cpu-pwr-good", NULL), 656bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xa, "bat-fault", NULL), 657bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xb, "ext0-wakeup", NULL), 658bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xc, "ext1-wakeup", NULL), 659bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xd, "ext2-wakeup", NULL), 660bbd7b275SSebastian Hesselbarth MPP_FUNCTION(CONFIG_PMU | 0xe, "pmu-blink", NULL)), 66106763c74SThomas Petazzoni MPP_MODE(16, 66206763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 66306763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "rts"), 66406763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "cd"), 66506763c74SThomas Petazzoni MPP_FUNCTION(0x04, "lcd-spi", "cs1"), 66606763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ac97", "sdi1")), 66706763c74SThomas Petazzoni MPP_MODE(17, 66806763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 66906763c74SThomas Petazzoni MPP_FUNCTION(0x01, "ac97-1", "sysclko"), 67006763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "cts"), 67106763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "wp"), 67206763c74SThomas Petazzoni MPP_FUNCTION(0x04, "twsi", "sda"), 67306763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ac97", "sdi2")), 67406763c74SThomas Petazzoni MPP_MODE(18, 67506763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 67606763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "txd"), 67706763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "buspwr"), 67806763c74SThomas Petazzoni MPP_FUNCTION(0x04, "lcd0", "pwm"), 67906763c74SThomas Petazzoni MPP_FUNCTION(0x05, "ac97", "sdi3")), 68006763c74SThomas Petazzoni MPP_MODE(19, 68106763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 68206763c74SThomas Petazzoni MPP_FUNCTION(0x02, "uart3", "rxd"), 68306763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio0", "ledctrl"), 68406763c74SThomas Petazzoni MPP_FUNCTION(0x04, "twsi", "sck")), 68506763c74SThomas Petazzoni MPP_MODE(20, 68606763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 68706763c74SThomas Petazzoni MPP_FUNCTION(0x01, "ac97", "sysclko"), 68806763c74SThomas Petazzoni MPP_FUNCTION(0x02, "lcd-spi", "miso"), 68906763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "cd"), 69006763c74SThomas Petazzoni MPP_FUNCTION(0x05, "sdio0", "cd"), 69106763c74SThomas Petazzoni MPP_FUNCTION(0x06, "spi1", "miso")), 69206763c74SThomas Petazzoni MPP_MODE(21, 69306763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 69406763c74SThomas Petazzoni MPP_FUNCTION(0x01, "uart1", "rts"), 69506763c74SThomas Petazzoni MPP_FUNCTION(0x02, "lcd-spi", "cs0"), 69606763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "wp"), 69706763c74SThomas Petazzoni MPP_FUNCTION(0x04, "ssp", "sfrm"), 69806763c74SThomas Petazzoni MPP_FUNCTION(0x05, "sdio0", "wp"), 69906763c74SThomas Petazzoni MPP_FUNCTION(0x06, "spi1", "cs")), 70006763c74SThomas Petazzoni MPP_MODE(22, 70106763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 70206763c74SThomas Petazzoni MPP_FUNCTION(0x01, "uart1", "cts"), 70306763c74SThomas Petazzoni MPP_FUNCTION(0x02, "lcd-spi", "mosi"), 70406763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "buspwr"), 70506763c74SThomas Petazzoni MPP_FUNCTION(0x04, "ssp", "txd"), 70606763c74SThomas Petazzoni MPP_FUNCTION(0x05, "sdio0", "buspwr"), 70706763c74SThomas Petazzoni MPP_FUNCTION(0x06, "spi1", "mosi")), 70806763c74SThomas Petazzoni MPP_MODE(23, 70906763c74SThomas Petazzoni MPP_FUNCTION(0x00, "gpio", NULL), 71006763c74SThomas Petazzoni MPP_FUNCTION(0x02, "lcd-spi", "sck"), 71106763c74SThomas Petazzoni MPP_FUNCTION(0x03, "sdio1", "ledctrl"), 71206763c74SThomas Petazzoni MPP_FUNCTION(0x04, "ssp", "sclk"), 71306763c74SThomas Petazzoni MPP_FUNCTION(0x05, "sdio0", "ledctrl"), 71406763c74SThomas Petazzoni MPP_FUNCTION(0x06, "spi1", "sck")), 71506763c74SThomas Petazzoni MPP_MODE(24, 71606763c74SThomas Petazzoni MPP_FUNCTION(0x00, "camera", NULL), 71706763c74SThomas Petazzoni MPP_FUNCTION(0x01, "gpio", NULL)), 71806763c74SThomas Petazzoni MPP_MODE(40, 71906763c74SThomas Petazzoni MPP_FUNCTION(0x00, "sdio0", NULL), 72006763c74SThomas Petazzoni MPP_FUNCTION(0x01, "gpio", NULL)), 72106763c74SThomas Petazzoni MPP_MODE(46, 72206763c74SThomas Petazzoni MPP_FUNCTION(0x00, "sdio1", NULL), 72306763c74SThomas Petazzoni MPP_FUNCTION(0x01, "gpio", NULL)), 72406763c74SThomas Petazzoni MPP_MODE(52, 72506763c74SThomas Petazzoni MPP_FUNCTION(0x00, "i2s1/spdifo", NULL), 72606763c74SThomas Petazzoni MPP_FUNCTION(0x02, "i2s1", NULL), 72706763c74SThomas Petazzoni MPP_FUNCTION(0x08, "spdifo", NULL), 72806763c74SThomas Petazzoni MPP_FUNCTION(0x0a, "gpio", NULL), 72906763c74SThomas Petazzoni MPP_FUNCTION(0x0b, "twsi", NULL), 73006763c74SThomas Petazzoni MPP_FUNCTION(0x0c, "ssp/spdifo", NULL), 73106763c74SThomas Petazzoni MPP_FUNCTION(0x0e, "ssp", NULL), 73206763c74SThomas Petazzoni MPP_FUNCTION(0x0f, "ssp/twsi", NULL)), 73306763c74SThomas Petazzoni MPP_MODE(58, 73406763c74SThomas Petazzoni MPP_FUNCTION(0x00, "spi0", NULL), 73506763c74SThomas Petazzoni MPP_FUNCTION(0x01, "gpio", NULL)), 73606763c74SThomas Petazzoni MPP_MODE(62, 73706763c74SThomas Petazzoni MPP_FUNCTION(0x00, "uart1", NULL), 73806763c74SThomas Petazzoni MPP_FUNCTION(0x01, "gpio", NULL)), 73906763c74SThomas Petazzoni MPP_MODE(64, 74006763c74SThomas Petazzoni MPP_FUNCTION(0x00, "nand", NULL), 74106763c74SThomas Petazzoni MPP_FUNCTION(0x01, "gpo", NULL)), 74206763c74SThomas Petazzoni MPP_MODE(72, 74306763c74SThomas Petazzoni MPP_FUNCTION(0x00, "i2s", NULL), 74406763c74SThomas Petazzoni MPP_FUNCTION(0x01, "ac97", NULL)), 74506763c74SThomas Petazzoni MPP_MODE(73, 74606763c74SThomas Petazzoni MPP_FUNCTION(0x00, "twsi-none", NULL), 74706763c74SThomas Petazzoni MPP_FUNCTION(0x01, "twsi-opt1", NULL), 74806763c74SThomas Petazzoni MPP_FUNCTION(0x02, "twsi-opt2", NULL), 74906763c74SThomas Petazzoni MPP_FUNCTION(0x03, "twsi-opt3", NULL)), 75006763c74SThomas Petazzoni }; 75106763c74SThomas Petazzoni 75206763c74SThomas Petazzoni static struct pinctrl_gpio_range dove_mpp_gpio_ranges[] = { 75306763c74SThomas Petazzoni MPP_GPIO_RANGE(0, 0, 0, 32), 75406763c74SThomas Petazzoni MPP_GPIO_RANGE(1, 32, 32, 32), 75506763c74SThomas Petazzoni MPP_GPIO_RANGE(2, 64, 64, 8), 75606763c74SThomas Petazzoni }; 75706763c74SThomas Petazzoni 75806763c74SThomas Petazzoni static struct mvebu_pinctrl_soc_info dove_pinctrl_info = { 75906763c74SThomas Petazzoni .controls = dove_mpp_controls, 76006763c74SThomas Petazzoni .ncontrols = ARRAY_SIZE(dove_mpp_controls), 76106763c74SThomas Petazzoni .modes = dove_mpp_modes, 76206763c74SThomas Petazzoni .nmodes = ARRAY_SIZE(dove_mpp_modes), 76306763c74SThomas Petazzoni .gpioranges = dove_mpp_gpio_ranges, 76406763c74SThomas Petazzoni .ngpioranges = ARRAY_SIZE(dove_mpp_gpio_ranges), 76506763c74SThomas Petazzoni .variant = 0, 76606763c74SThomas Petazzoni }; 76706763c74SThomas Petazzoni 76806763c74SThomas Petazzoni static struct clk *clk; 76906763c74SThomas Petazzoni 77023259f19SKrzysztof Kozlowski static const struct of_device_id dove_pinctrl_of_match[] = { 77106763c74SThomas Petazzoni { .compatible = "marvell,dove-pinctrl", .data = &dove_pinctrl_info }, 77206763c74SThomas Petazzoni { } 77306763c74SThomas Petazzoni }; 77406763c74SThomas Petazzoni 77523259f19SKrzysztof Kozlowski static const struct regmap_config gc_regmap_config = { 776e91f7916SSebastian Hesselbarth .reg_bits = 32, 777e91f7916SSebastian Hesselbarth .val_bits = 32, 778e91f7916SSebastian Hesselbarth .reg_stride = 4, 779e91f7916SSebastian Hesselbarth .max_register = 5, 780e91f7916SSebastian Hesselbarth }; 781e91f7916SSebastian Hesselbarth 782150632b0SGreg Kroah-Hartman static int dove_pinctrl_probe(struct platform_device *pdev) 78306763c74SThomas Petazzoni { 7844d73fc77SSebastian Hesselbarth struct resource *res, *mpp_res; 7854d73fc77SSebastian Hesselbarth struct resource fb_res; 78606763c74SThomas Petazzoni const struct of_device_id *match = 78706763c74SThomas Petazzoni of_match_device(dove_pinctrl_of_match, &pdev->dev); 78816fa36beSAndrew Lunn pdev->dev.platform_data = (void *)match->data; 78906763c74SThomas Petazzoni 79006763c74SThomas Petazzoni /* 79106763c74SThomas Petazzoni * General MPP Configuration Register is part of pdma registers. 79206763c74SThomas Petazzoni * grab clk to make sure it is ticking. 79306763c74SThomas Petazzoni */ 79406763c74SThomas Petazzoni clk = devm_clk_get(&pdev->dev, NULL); 795ba607b62SSebastian Hesselbarth if (IS_ERR(clk)) { 796ba607b62SSebastian Hesselbarth dev_err(&pdev->dev, "Unable to get pdma clock"); 7975795c6acSRusty Russell return PTR_ERR(clk); 798ba607b62SSebastian Hesselbarth } 79906763c74SThomas Petazzoni clk_prepare_enable(clk); 80006763c74SThomas Petazzoni 8014d73fc77SSebastian Hesselbarth mpp_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 8024d73fc77SSebastian Hesselbarth mpp_base = devm_ioremap_resource(&pdev->dev, mpp_res); 8031217b790SSebastian Hesselbarth if (IS_ERR(mpp_base)) 8041217b790SSebastian Hesselbarth return PTR_ERR(mpp_base); 8051217b790SSebastian Hesselbarth 8064d73fc77SSebastian Hesselbarth /* prepare fallback resource */ 8074d73fc77SSebastian Hesselbarth memcpy(&fb_res, mpp_res, sizeof(struct resource)); 8084d73fc77SSebastian Hesselbarth fb_res.start = 0; 8094d73fc77SSebastian Hesselbarth 8104d73fc77SSebastian Hesselbarth res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 8114d73fc77SSebastian Hesselbarth if (!res) { 8124d73fc77SSebastian Hesselbarth dev_warn(&pdev->dev, "falling back to hardcoded MPP4 resource\n"); 8134d73fc77SSebastian Hesselbarth adjust_resource(&fb_res, 8144d73fc77SSebastian Hesselbarth (mpp_res->start & INT_REGS_MASK) + MPP4_REGS_OFFS, 0x4); 8154d73fc77SSebastian Hesselbarth res = &fb_res; 8164d73fc77SSebastian Hesselbarth } 8174d73fc77SSebastian Hesselbarth 8184d73fc77SSebastian Hesselbarth mpp4_base = devm_ioremap_resource(&pdev->dev, res); 8194d73fc77SSebastian Hesselbarth if (IS_ERR(mpp4_base)) 8204d73fc77SSebastian Hesselbarth return PTR_ERR(mpp4_base); 8214d73fc77SSebastian Hesselbarth 8224d73fc77SSebastian Hesselbarth res = platform_get_resource(pdev, IORESOURCE_MEM, 2); 8234d73fc77SSebastian Hesselbarth if (!res) { 8244d73fc77SSebastian Hesselbarth dev_warn(&pdev->dev, "falling back to hardcoded PMU resource\n"); 8254d73fc77SSebastian Hesselbarth adjust_resource(&fb_res, 8264d73fc77SSebastian Hesselbarth (mpp_res->start & INT_REGS_MASK) + PMU_REGS_OFFS, 0x8); 8274d73fc77SSebastian Hesselbarth res = &fb_res; 8284d73fc77SSebastian Hesselbarth } 8294d73fc77SSebastian Hesselbarth 8304d73fc77SSebastian Hesselbarth pmu_base = devm_ioremap_resource(&pdev->dev, res); 8314d73fc77SSebastian Hesselbarth if (IS_ERR(pmu_base)) 8324d73fc77SSebastian Hesselbarth return PTR_ERR(pmu_base); 8334d73fc77SSebastian Hesselbarth 834e91f7916SSebastian Hesselbarth gconfmap = syscon_regmap_lookup_by_compatible("marvell,dove-global-config"); 835e91f7916SSebastian Hesselbarth if (IS_ERR(gconfmap)) { 836e91f7916SSebastian Hesselbarth void __iomem *gc_base; 837e91f7916SSebastian Hesselbarth 838e91f7916SSebastian Hesselbarth dev_warn(&pdev->dev, "falling back to hardcoded global registers\n"); 839e91f7916SSebastian Hesselbarth adjust_resource(&fb_res, 840e91f7916SSebastian Hesselbarth (mpp_res->start & INT_REGS_MASK) + GC_REGS_OFFS, 0x14); 841e91f7916SSebastian Hesselbarth gc_base = devm_ioremap_resource(&pdev->dev, &fb_res); 842e91f7916SSebastian Hesselbarth if (IS_ERR(gc_base)) 843e91f7916SSebastian Hesselbarth return PTR_ERR(gc_base); 844e91f7916SSebastian Hesselbarth gconfmap = devm_regmap_init_mmio(&pdev->dev, 845e91f7916SSebastian Hesselbarth gc_base, &gc_regmap_config); 846e91f7916SSebastian Hesselbarth if (IS_ERR(gconfmap)) 847e91f7916SSebastian Hesselbarth return PTR_ERR(gconfmap); 848e91f7916SSebastian Hesselbarth } 849e91f7916SSebastian Hesselbarth 8504d73fc77SSebastian Hesselbarth /* Warn on any missing DT resource */ 8513c7d5637SSebastian Hesselbarth if (fb_res.start) 8523c7d5637SSebastian Hesselbarth dev_warn(&pdev->dev, FW_BUG "Missing pinctrl regs in DTB. Please update your firmware.\n"); 8534d73fc77SSebastian Hesselbarth 85406763c74SThomas Petazzoni return mvebu_pinctrl_probe(pdev); 85506763c74SThomas Petazzoni } 85606763c74SThomas Petazzoni 857150632b0SGreg Kroah-Hartman static int dove_pinctrl_remove(struct platform_device *pdev) 85806763c74SThomas Petazzoni { 85906763c74SThomas Petazzoni if (!IS_ERR(clk)) 86006763c74SThomas Petazzoni clk_disable_unprepare(clk); 861699097a9SLaxman Dewangan return 0; 86206763c74SThomas Petazzoni } 86306763c74SThomas Petazzoni 86406763c74SThomas Petazzoni static struct platform_driver dove_pinctrl_driver = { 86506763c74SThomas Petazzoni .driver = { 86606763c74SThomas Petazzoni .name = "dove-pinctrl", 867f2e9394dSSachin Kamat .of_match_table = dove_pinctrl_of_match, 86806763c74SThomas Petazzoni }, 86906763c74SThomas Petazzoni .probe = dove_pinctrl_probe, 870150632b0SGreg Kroah-Hartman .remove = dove_pinctrl_remove, 87106763c74SThomas Petazzoni }; 87206763c74SThomas Petazzoni 87306763c74SThomas Petazzoni module_platform_driver(dove_pinctrl_driver); 87406763c74SThomas Petazzoni 87506763c74SThomas Petazzoni MODULE_AUTHOR("Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>"); 87606763c74SThomas Petazzoni MODULE_DESCRIPTION("Marvell Dove pinctrl driver"); 87706763c74SThomas Petazzoni MODULE_LICENSE("GPL v2"); 878