Commit 08d4f0c8 authored by Jason Cooper's avatar Jason Cooper

Merge remote-tracking branch 'shesselba/for-mvebu/pinctrl-dove' into mvebu/pinctrl

parents 55387764 6da67cab
Marvell Dove Platforms Device Tree Bindings
-----------------------------------------------
Boards with a Marvell Dove SoC shall have the following properties:
Required root node property:
- compatible: must contain "marvell,dove";
* Global Configuration registers
Global Configuration registers of Dove SoC are shared by a syscon node.
Required properties:
- compatible: must contain "marvell,dove-global-config" and "syscon".
- reg: base address and size of the Global Configuration registers.
Example:
gconf: global-config@e802c {
compatible = "marvell,dove-global-config", "syscon";
reg = <0xe802c 0x14>;
};
...@@ -5,6 +5,7 @@ part and usage. ...@@ -5,6 +5,7 @@ part and usage.
Required properties: Required properties:
- compatible: "marvell,88f6710-pinctrl" - compatible: "marvell,88f6710-pinctrl"
- reg: register specifier of MPP registers
Available mpp pins/groups and functions: Available mpp pins/groups and functions:
Note: brackets (x) are not part of the mpp name for marvell,function and given Note: brackets (x) are not part of the mpp name for marvell,function and given
......
...@@ -6,6 +6,7 @@ part and usage. ...@@ -6,6 +6,7 @@ part and usage.
Required properties: Required properties:
- compatible: "marvell,mv78230-pinctrl", "marvell,mv78260-pinctrl", - compatible: "marvell,mv78230-pinctrl", "marvell,mv78260-pinctrl",
"marvell,mv78460-pinctrl" "marvell,mv78460-pinctrl"
- reg: register specifier of MPP registers
This driver supports all Armada XP variants, i.e. mv78230, mv78260, and mv78460. This driver supports all Armada XP variants, i.e. mv78230, mv78260, and mv78460.
......
...@@ -6,6 +6,7 @@ part and usage. ...@@ -6,6 +6,7 @@ part and usage.
Required properties: Required properties:
- compatible: "marvell,dove-pinctrl" - compatible: "marvell,dove-pinctrl"
- clocks: (optional) phandle of pdma clock - clocks: (optional) phandle of pdma clock
- reg: register specifiers of MPP, MPP4, and PMU MPP registers
Available mpp pins/groups and functions: Available mpp pins/groups and functions:
Note: brackets (x) are not part of the mpp name for marvell,function and given Note: brackets (x) are not part of the mpp name for marvell,function and given
......
...@@ -8,6 +8,7 @@ Required properties: ...@@ -8,6 +8,7 @@ Required properties:
"marvell,88f6190-pinctrl", "marvell,88f6192-pinctrl", "marvell,88f6190-pinctrl", "marvell,88f6192-pinctrl",
"marvell,88f6281-pinctrl", "marvell,88f6282-pinctrl" "marvell,88f6281-pinctrl", "marvell,88f6282-pinctrl"
"marvell,98dx4122-pinctrl" "marvell,98dx4122-pinctrl"
- reg: register specifier of MPP registers
This driver supports all kirkwood variants, i.e. 88f6180, 88f619x, and 88f628x. This driver supports all kirkwood variants, i.e. 88f6180, 88f619x, and 88f628x.
It also support the 88f6281-based variant in the 98dx412x Bobcat SoCs. It also support the 88f6281-based variant in the 98dx412x Bobcat SoCs.
......
...@@ -37,7 +37,7 @@ uart1: serial@12100 { ...@@ -37,7 +37,7 @@ uart1: serial@12100 {
pinctrl: pinctrl@d0200 { pinctrl: pinctrl@d0200 {
compatible = "marvell,dove-pinctrl"; compatible = "marvell,dove-pinctrl";
reg = <0xd0200 0x20>; reg = <0xd0200 0x14>, <0xd0440 0x04>, <0xd802c 0x08>;
pmx_uart1_sw: pmx-uart1-sw { pmx_uart1_sw: pmx-uart1-sw {
marvell,pins = "mpp_uart1"; marvell,pins = "mpp_uart1";
......
...@@ -8,6 +8,7 @@ config PINCTRL_MVEBU ...@@ -8,6 +8,7 @@ config PINCTRL_MVEBU
config PINCTRL_DOVE config PINCTRL_DOVE
bool bool
select PINCTRL_MVEBU select PINCTRL_MVEBU
select MFD_SYSCON
config PINCTRL_KIRKWOOD config PINCTRL_KIRKWOOD
bool bool
......
...@@ -18,40 +18,53 @@ ...@@ -18,40 +18,53 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/mfd/syscon.h>
#include <linux/pinctrl/pinctrl.h> #include <linux/pinctrl/pinctrl.h>
#include <linux/regmap.h>
#include "pinctrl-mvebu.h" #include "pinctrl-mvebu.h"
#define DOVE_SB_REGS_VIRT_BASE IOMEM(0xfde00000) /* Internal registers can be configured at any 1 MiB aligned address */
#define DOVE_MPP_VIRT_BASE (DOVE_SB_REGS_VIRT_BASE + 0xd0200) #define INT_REGS_MASK ~(SZ_1M - 1)
#define DOVE_PMU_MPP_GENERAL_CTRL (DOVE_MPP_VIRT_BASE + 0x10) #define MPP4_REGS_OFFS 0xd0440
#define DOVE_AU0_AC97_SEL BIT(16) #define PMU_REGS_OFFS 0xd802c
#define DOVE_PMU_SIGNAL_SELECT_0 (DOVE_SB_REGS_VIRT_BASE + 0xd802C) #define GC_REGS_OFFS 0xe802c
#define DOVE_PMU_SIGNAL_SELECT_1 (DOVE_SB_REGS_VIRT_BASE + 0xd8030)
#define DOVE_GLOBAL_CONFIG_1 (DOVE_SB_REGS_VIRT_BASE + 0xe802C) /* MPP Base registers */
#define DOVE_GLOBAL_CONFIG_1 (DOVE_SB_REGS_VIRT_BASE + 0xe802C) #define PMU_MPP_GENERAL_CTRL 0x10
#define DOVE_TWSI_ENABLE_OPTION1 BIT(7) #define AU0_AC97_SEL BIT(16)
#define DOVE_GLOBAL_CONFIG_2 (DOVE_SB_REGS_VIRT_BASE + 0xe8030)
#define DOVE_TWSI_ENABLE_OPTION2 BIT(20) /* MPP Control 4 register */
#define DOVE_TWSI_ENABLE_OPTION3 BIT(21) #define SPI_GPIO_SEL BIT(5)
#define DOVE_TWSI_OPTION3_GPIO BIT(22) #define UART1_GPIO_SEL BIT(4)
#define DOVE_SSP_CTRL_STATUS_1 (DOVE_SB_REGS_VIRT_BASE + 0xe8034) #define AU1_GPIO_SEL BIT(3)
#define DOVE_SSP_ON_AU1 BIT(0) #define CAM_GPIO_SEL BIT(2)
#define DOVE_MPP_GENERAL_VIRT_BASE (DOVE_SB_REGS_VIRT_BASE + 0xe803c) #define SD1_GPIO_SEL BIT(1)
#define DOVE_AU1_SPDIFO_GPIO_EN BIT(1) #define SD0_GPIO_SEL BIT(0)
#define DOVE_NAND_GPIO_EN BIT(0)
#define DOVE_GPIO_LO_VIRT_BASE (DOVE_SB_REGS_VIRT_BASE + 0xd0400) /* PMU Signal Select registers */
#define DOVE_MPP_CTRL4_VIRT_BASE (DOVE_GPIO_LO_VIRT_BASE + 0x40) #define PMU_SIGNAL_SELECT_0 0x00
#define DOVE_SPI_GPIO_SEL BIT(5) #define PMU_SIGNAL_SELECT_1 0x04
#define DOVE_UART1_GPIO_SEL BIT(4)
#define DOVE_AU1_GPIO_SEL BIT(3) /* Global Config regmap registers */
#define DOVE_CAM_GPIO_SEL BIT(2) #define GLOBAL_CONFIG_1 0x00
#define DOVE_SD1_GPIO_SEL BIT(1) #define TWSI_ENABLE_OPTION1 BIT(7)
#define DOVE_SD0_GPIO_SEL BIT(0) #define GLOBAL_CONFIG_2 0x04
#define TWSI_ENABLE_OPTION2 BIT(20)
#define TWSI_ENABLE_OPTION3 BIT(21)
#define TWSI_OPTION3_GPIO BIT(22)
#define SSP_CTRL_STATUS_1 0x08
#define SSP_ON_AU1 BIT(0)
#define MPP_GENERAL_CONFIG 0x10
#define AU1_SPDIFO_GPIO_EN BIT(1)
#define NAND_GPIO_EN BIT(0)
#define CONFIG_PMU BIT(4) #define CONFIG_PMU BIT(4)
static void __iomem *mpp_base; static void __iomem *mpp_base;
static void __iomem *mpp4_base;
static void __iomem *pmu_base;
static struct regmap *gconfmap;
static int dove_mpp_ctrl_get(unsigned pid, unsigned long *config) static int dove_mpp_ctrl_get(unsigned pid, unsigned long *config)
{ {
...@@ -67,13 +80,13 @@ static int dove_pmu_mpp_ctrl_get(unsigned pid, unsigned long *config) ...@@ -67,13 +80,13 @@ static int dove_pmu_mpp_ctrl_get(unsigned pid, unsigned long *config)
{ {
unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL);
unsigned long func; unsigned long func;
if ((pmu & BIT(pid)) == 0) if ((pmu & BIT(pid)) == 0)
return default_mpp_ctrl_get(mpp_base, pid, config); return default_mpp_ctrl_get(mpp_base, pid, config);
func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); func = readl(pmu_base + PMU_SIGNAL_SELECT_0 + off);
*config = (func >> shift) & MVEBU_MPP_MASK; *config = (func >> shift) & MVEBU_MPP_MASK;
*config |= CONFIG_PMU; *config |= CONFIG_PMU;
...@@ -84,43 +97,43 @@ static int dove_pmu_mpp_ctrl_set(unsigned pid, unsigned long config) ...@@ -84,43 +97,43 @@ static int dove_pmu_mpp_ctrl_set(unsigned pid, unsigned long config)
{ {
unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; unsigned off = (pid / MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS; unsigned shift = (pid % MVEBU_MPPS_PER_REG) * MVEBU_MPP_BITS;
unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL);
unsigned long func; unsigned long func;
if ((config & CONFIG_PMU) == 0) { if ((config & CONFIG_PMU) == 0) {
writel(pmu & ~BIT(pid), DOVE_PMU_MPP_GENERAL_CTRL); writel(pmu & ~BIT(pid), mpp_base + PMU_MPP_GENERAL_CTRL);
return default_mpp_ctrl_set(mpp_base, pid, config); return default_mpp_ctrl_set(mpp_base, pid, config);
} }
writel(pmu | BIT(pid), DOVE_PMU_MPP_GENERAL_CTRL); writel(pmu | BIT(pid), mpp_base + PMU_MPP_GENERAL_CTRL);
func = readl(DOVE_PMU_SIGNAL_SELECT_0 + off); func = readl(pmu_base + PMU_SIGNAL_SELECT_0 + off);
func &= ~(MVEBU_MPP_MASK << shift); func &= ~(MVEBU_MPP_MASK << shift);
func |= (config & MVEBU_MPP_MASK) << shift; func |= (config & MVEBU_MPP_MASK) << shift;
writel(func, DOVE_PMU_SIGNAL_SELECT_0 + off); writel(func, pmu_base + PMU_SIGNAL_SELECT_0 + off);
return 0; return 0;
} }
static int dove_mpp4_ctrl_get(unsigned pid, unsigned long *config) static int dove_mpp4_ctrl_get(unsigned pid, unsigned long *config)
{ {
unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE); unsigned long mpp4 = readl(mpp4_base);
unsigned long mask; unsigned long mask;
switch (pid) { switch (pid) {
case 24: /* mpp_camera */ case 24: /* mpp_camera */
mask = DOVE_CAM_GPIO_SEL; mask = CAM_GPIO_SEL;
break; break;
case 40: /* mpp_sdio0 */ case 40: /* mpp_sdio0 */
mask = DOVE_SD0_GPIO_SEL; mask = SD0_GPIO_SEL;
break; break;
case 46: /* mpp_sdio1 */ case 46: /* mpp_sdio1 */
mask = DOVE_SD1_GPIO_SEL; mask = SD1_GPIO_SEL;
break; break;
case 58: /* mpp_spi0 */ case 58: /* mpp_spi0 */
mask = DOVE_SPI_GPIO_SEL; mask = SPI_GPIO_SEL;
break; break;
case 62: /* mpp_uart1 */ case 62: /* mpp_uart1 */
mask = DOVE_UART1_GPIO_SEL; mask = UART1_GPIO_SEL;
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -133,24 +146,24 @@ static int dove_mpp4_ctrl_get(unsigned pid, unsigned long *config) ...@@ -133,24 +146,24 @@ static int dove_mpp4_ctrl_get(unsigned pid, unsigned long *config)
static int dove_mpp4_ctrl_set(unsigned pid, unsigned long config) static int dove_mpp4_ctrl_set(unsigned pid, unsigned long config)
{ {
unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE); unsigned long mpp4 = readl(mpp4_base);
unsigned long mask; unsigned long mask;
switch (pid) { switch (pid) {
case 24: /* mpp_camera */ case 24: /* mpp_camera */
mask = DOVE_CAM_GPIO_SEL; mask = CAM_GPIO_SEL;
break; break;
case 40: /* mpp_sdio0 */ case 40: /* mpp_sdio0 */
mask = DOVE_SD0_GPIO_SEL; mask = SD0_GPIO_SEL;
break; break;
case 46: /* mpp_sdio1 */ case 46: /* mpp_sdio1 */
mask = DOVE_SD1_GPIO_SEL; mask = SD1_GPIO_SEL;
break; break;
case 58: /* mpp_spi0 */ case 58: /* mpp_spi0 */
mask = DOVE_SPI_GPIO_SEL; mask = SPI_GPIO_SEL;
break; break;
case 62: /* mpp_uart1 */ case 62: /* mpp_uart1 */
mask = DOVE_UART1_GPIO_SEL; mask = UART1_GPIO_SEL;
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -160,69 +173,69 @@ static int dove_mpp4_ctrl_set(unsigned pid, unsigned long config) ...@@ -160,69 +173,69 @@ static int dove_mpp4_ctrl_set(unsigned pid, unsigned long config)
if (config) if (config)
mpp4 |= mask; mpp4 |= mask;
writel(mpp4, DOVE_MPP_CTRL4_VIRT_BASE); writel(mpp4, mpp4_base);
return 0; return 0;
} }
static int dove_nand_ctrl_get(unsigned pid, unsigned long *config) static int dove_nand_ctrl_get(unsigned pid, unsigned long *config)
{ {
unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE); unsigned int gmpp;
*config = ((gmpp & DOVE_NAND_GPIO_EN) != 0); regmap_read(gconfmap, MPP_GENERAL_CONFIG, &gmpp);
*config = ((gmpp & NAND_GPIO_EN) != 0);
return 0; return 0;
} }
static int dove_nand_ctrl_set(unsigned pid, unsigned long config) static int dove_nand_ctrl_set(unsigned pid, unsigned long config)
{ {
unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE); regmap_update_bits(gconfmap, MPP_GENERAL_CONFIG,
NAND_GPIO_EN,
gmpp &= ~DOVE_NAND_GPIO_EN; (config) ? NAND_GPIO_EN : 0);
if (config)
gmpp |= DOVE_NAND_GPIO_EN;
writel(gmpp, DOVE_MPP_GENERAL_VIRT_BASE);
return 0; return 0;
} }
static int dove_audio0_ctrl_get(unsigned pid, unsigned long *config) static int dove_audio0_ctrl_get(unsigned pid, unsigned long *config)
{ {
unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL);
*config = ((pmu & DOVE_AU0_AC97_SEL) != 0); *config = ((pmu & AU0_AC97_SEL) != 0);
return 0; return 0;
} }
static int dove_audio0_ctrl_set(unsigned pid, unsigned long config) static int dove_audio0_ctrl_set(unsigned pid, unsigned long config)
{ {
unsigned long pmu = readl(DOVE_PMU_MPP_GENERAL_CTRL); unsigned long pmu = readl(mpp_base + PMU_MPP_GENERAL_CTRL);
pmu &= ~DOVE_AU0_AC97_SEL; pmu &= ~AU0_AC97_SEL;
if (config) if (config)
pmu |= DOVE_AU0_AC97_SEL; pmu |= AU0_AC97_SEL;
writel(pmu, DOVE_PMU_MPP_GENERAL_CTRL); writel(pmu, mpp_base + PMU_MPP_GENERAL_CTRL);
return 0; return 0;
} }
static int dove_audio1_ctrl_get(unsigned pid, unsigned long *config) static int dove_audio1_ctrl_get(unsigned pid, unsigned long *config)
{ {
unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE); unsigned int mpp4 = readl(mpp4_base);
unsigned long sspc1 = readl(DOVE_SSP_CTRL_STATUS_1); unsigned int sspc1;
unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE); unsigned int gmpp;
unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2); unsigned int gcfg2;
regmap_read(gconfmap, SSP_CTRL_STATUS_1, &sspc1);
regmap_read(gconfmap, MPP_GENERAL_CONFIG, &gmpp);
regmap_read(gconfmap, GLOBAL_CONFIG_2, &gcfg2);
*config = 0; *config = 0;
if (mpp4 & DOVE_AU1_GPIO_SEL) if (mpp4 & AU1_GPIO_SEL)
*config |= BIT(3); *config |= BIT(3);
if (sspc1 & DOVE_SSP_ON_AU1) if (sspc1 & SSP_ON_AU1)
*config |= BIT(2); *config |= BIT(2);
if (gmpp & DOVE_AU1_SPDIFO_GPIO_EN) if (gmpp & AU1_SPDIFO_GPIO_EN)
*config |= BIT(1); *config |= BIT(1);
if (gcfg2 & DOVE_TWSI_OPTION3_GPIO) if (gcfg2 & TWSI_OPTION3_GPIO)
*config |= BIT(0); *config |= BIT(0);
/* SSP/TWSI only if I2S1 not set*/ /* SSP/TWSI only if I2S1 not set*/
...@@ -236,32 +249,22 @@ static int dove_audio1_ctrl_get(unsigned pid, unsigned long *config) ...@@ -236,32 +249,22 @@ static int dove_audio1_ctrl_get(unsigned pid, unsigned long *config)
static int dove_audio1_ctrl_set(unsigned pid, unsigned long config) static int dove_audio1_ctrl_set(unsigned pid, unsigned long config)
{ {
unsigned long mpp4 = readl(DOVE_MPP_CTRL4_VIRT_BASE); unsigned int mpp4 = readl(mpp4_base);
unsigned long sspc1 = readl(DOVE_SSP_CTRL_STATUS_1);
unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE);
unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2);
/* mpp4 &= ~AU1_GPIO_SEL;
* clear all audio1 related bits before configure
*/
gcfg2 &= ~DOVE_TWSI_OPTION3_GPIO;
gmpp &= ~DOVE_AU1_SPDIFO_GPIO_EN;
sspc1 &= ~DOVE_SSP_ON_AU1;
mpp4 &= ~DOVE_AU1_GPIO_SEL;
if (config & BIT(0))
gcfg2 |= DOVE_TWSI_OPTION3_GPIO;
if (config & BIT(1))
gmpp |= DOVE_AU1_SPDIFO_GPIO_EN;
if (config & BIT(2))
sspc1 |= DOVE_SSP_ON_AU1;
if (config & BIT(3)) if (config & BIT(3))
mpp4 |= DOVE_AU1_GPIO_SEL; mpp4 |= AU1_GPIO_SEL;
writel(mpp4, mpp4_base);
writel(mpp4, DOVE_MPP_CTRL4_VIRT_BASE);
writel(sspc1, DOVE_SSP_CTRL_STATUS_1); regmap_update_bits(gconfmap, SSP_CTRL_STATUS_1,
writel(gmpp, DOVE_MPP_GENERAL_VIRT_BASE); SSP_ON_AU1,
writel(gcfg2, DOVE_GLOBAL_CONFIG_2); (config & BIT(2)) ? SSP_ON_AU1 : 0);
regmap_update_bits(gconfmap, MPP_GENERAL_CONFIG,
AU1_SPDIFO_GPIO_EN,
(config & BIT(1)) ? AU1_SPDIFO_GPIO_EN : 0);
regmap_update_bits(gconfmap, GLOBAL_CONFIG_2,
TWSI_OPTION3_GPIO,
(config & BIT(0)) ? TWSI_OPTION3_GPIO : 0);
return 0; return 0;
} }
...@@ -307,15 +310,18 @@ static int dove_audio1_ctrl_gpio_dir(unsigned pid, bool input) ...@@ -307,15 +310,18 @@ static int dove_audio1_ctrl_gpio_dir(unsigned pid, bool input)
static int dove_twsi_ctrl_get(unsigned pid, unsigned long *config) static int dove_twsi_ctrl_get(unsigned pid, unsigned long *config)
{ {
unsigned long gcfg1 = readl(DOVE_GLOBAL_CONFIG_1); unsigned int gcfg1;
unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2); unsigned int gcfg2;
regmap_read(gconfmap, GLOBAL_CONFIG_1, &gcfg1);
regmap_read(gconfmap, GLOBAL_CONFIG_2, &gcfg2);
*config = 0; *config = 0;
if (gcfg1 & DOVE_TWSI_ENABLE_OPTION1) if (gcfg1 & TWSI_ENABLE_OPTION1)
*config = 1; *config = 1;
else if (gcfg2 & DOVE_TWSI_ENABLE_OPTION2) else if (gcfg2 & TWSI_ENABLE_OPTION2)
*config = 2; *config = 2;
else if (gcfg2 & DOVE_TWSI_ENABLE_OPTION3) else if (gcfg2 & TWSI_ENABLE_OPTION3)
*config = 3; *config = 3;
return 0; return 0;
...@@ -323,26 +329,27 @@ static int dove_twsi_ctrl_get(unsigned pid, unsigned long *config) ...@@ -323,26 +329,27 @@ static int dove_twsi_ctrl_get(unsigned pid, unsigned long *config)
static int dove_twsi_ctrl_set(unsigned pid, unsigned long config) static int dove_twsi_ctrl_set(unsigned pid, unsigned long config)
{ {
unsigned long gcfg1 = readl(DOVE_GLOBAL_CONFIG_1); unsigned int gcfg1 = 0;
unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2); unsigned int gcfg2 = 0;
gcfg1 &= ~DOVE_TWSI_ENABLE_OPTION1;
gcfg2 &= ~(DOVE_TWSI_ENABLE_OPTION2 | DOVE_TWSI_ENABLE_OPTION3);
switch (config) { switch (config) {
case 1: case 1:
gcfg1 |= DOVE_TWSI_ENABLE_OPTION1; gcfg1 = TWSI_ENABLE_OPTION1;
break; break;
case 2: case 2:
gcfg2 |= DOVE_TWSI_ENABLE_OPTION2; gcfg2 = TWSI_ENABLE_OPTION2;
break; break;
case 3: case 3:
gcfg2 |= DOVE_TWSI_ENABLE_OPTION3; gcfg2 = TWSI_ENABLE_OPTION3;
break; break;
} }
writel(gcfg1, DOVE_GLOBAL_CONFIG_1); regmap_update_bits(gconfmap, GLOBAL_CONFIG_1,
writel(gcfg2, DOVE_GLOBAL_CONFIG_2); TWSI_ENABLE_OPTION1,
gcfg1);
regmap_update_bits(gconfmap, GLOBAL_CONFIG_2,
TWSI_ENABLE_OPTION2 | TWSI_ENABLE_OPTION3,
gcfg2);
return 0; return 0;
} }
...@@ -749,9 +756,17 @@ static struct of_device_id dove_pinctrl_of_match[] = { ...@@ -749,9 +756,17 @@ static struct of_device_id dove_pinctrl_of_match[] = {
{ } { }
}; };
static struct regmap_config gc_regmap_config = {
.reg_bits = 32,
.val_bits = 32,
.reg_stride = 4,
.max_register = 5,
};
static int dove_pinctrl_probe(struct platform_device *pdev) static int dove_pinctrl_probe(struct platform_device *pdev)
{ {
struct resource *res; struct resource *res, *mpp_res;
struct resource fb_res;
const struct of_device_id *match = const struct of_device_id *match =
of_match_device(dove_pinctrl_of_match, &pdev->dev); of_match_device(dove_pinctrl_of_match, &pdev->dev);
pdev->dev.platform_data = (void *)match->data; pdev->dev.platform_data = (void *)match->data;
...@@ -767,11 +782,58 @@ static int dove_pinctrl_probe(struct platform_device *pdev) ...@@ -767,11 +782,58 @@ static int dove_pinctrl_probe(struct platform_device *pdev)
} }
clk_prepare_enable(clk); clk_prepare_enable(clk);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); mpp_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
mpp_base = devm_ioremap_resource(&pdev->dev, res); mpp_base = devm_ioremap_resource(&pdev->dev, mpp_res);
if (IS_ERR(mpp_base)) if (IS_ERR(mpp_base))
return PTR_ERR(mpp_base); return PTR_ERR(mpp_base);
/* prepare fallback resource */
memcpy(&fb_res, mpp_res, sizeof(struct resource));
fb_res.start = 0;
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (!res) {
dev_warn(&pdev->dev, "falling back to hardcoded MPP4 resource\n");
adjust_resource(&fb_res,
(mpp_res->start & INT_REGS_MASK) + MPP4_REGS_OFFS, 0x4);
res = &fb_res;
}
mpp4_base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(mpp4_base))
return PTR_ERR(mpp4_base);
res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
if (!res) {
dev_warn(&pdev->dev, "falling back to hardcoded PMU resource\n");
adjust_resource(&fb_res,
(mpp_res->start & INT_REGS_MASK) + PMU_REGS_OFFS, 0x8);
res = &fb_res;
}
pmu_base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(pmu_base))
return PTR_ERR(pmu_base);
gconfmap = syscon_regmap_lookup_by_compatible("marvell,dove-global-config");
if (IS_ERR(gconfmap)) {
void __iomem *gc_base;
dev_warn(&pdev->dev, "falling back to hardcoded global registers\n");
adjust_resource(&fb_res,
(mpp_res->start & INT_REGS_MASK) + GC_REGS_OFFS, 0x14);
gc_base = devm_ioremap_resource(&pdev->dev, &fb_res);
if (IS_ERR(gc_base))
return PTR_ERR(gc_base);
gconfmap = devm_regmap_init_mmio(&pdev->dev,
gc_base, &gc_regmap_config);
if (IS_ERR(gconfmap))
return PTR_ERR(gconfmap);
}
/* Warn on any missing DT resource */
WARN(fb_res.start, FW_BUG "Missing pinctrl regs in DTB. Please update your firmware.\n");
return mvebu_pinctrl_probe(pdev); return mvebu_pinctrl_probe(pdev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment