aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/mvebu
diff options
context:
space:
mode:
authorSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>2014-01-24 17:18:09 -0500
committerSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>2014-02-25 15:16:08 -0500
commit4d73fc7728515d11fedff5b3ea7f2e03a84dfd60 (patch)
treec4c3388529bf2061c633df778d27692748cd7077 /drivers/pinctrl/mvebu
parent356ca6ce0aa4cc30fe4429aabb9be73a3a69cf42 (diff)
pinctrl: mvebu: dove: request additional resources
Dove pinctrl also requires additional registers to control all pins. This patch requests resources for mpp4 and pmu-mpp register ranges. As this changes DT to driver requirements, fallback to hardcoded resources, if the corresponding DT regs have not been set. Also, WARN about old DT binding usage to encourage users to update their DTBs. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Acked-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/mvebu')
-rw-r--r--drivers/pinctrl/mvebu/pinctrl-dove.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/drivers/pinctrl/mvebu/pinctrl-dove.c b/drivers/pinctrl/mvebu/pinctrl-dove.c
index da9ca26360fd..8d57d4bc1f0c 100644
--- a/drivers/pinctrl/mvebu/pinctrl-dove.c
+++ b/drivers/pinctrl/mvebu/pinctrl-dove.c
@@ -22,6 +22,11 @@
22 22
23#include "pinctrl-mvebu.h" 23#include "pinctrl-mvebu.h"
24 24
25/* Internal registers can be configured at any 1 MiB aligned address */
26#define INT_REGS_MASK ~(SZ_1M - 1)
27#define MPP4_REGS_OFFS 0xd0440
28#define PMU_REGS_OFFS 0xd802c
29
25#define DOVE_SB_REGS_VIRT_BASE IOMEM(0xfde00000) 30#define DOVE_SB_REGS_VIRT_BASE IOMEM(0xfde00000)
26#define DOVE_MPP_VIRT_BASE (DOVE_SB_REGS_VIRT_BASE + 0xd0200) 31#define DOVE_MPP_VIRT_BASE (DOVE_SB_REGS_VIRT_BASE + 0xd0200)
27#define DOVE_PMU_MPP_GENERAL_CTRL (DOVE_MPP_VIRT_BASE + 0x10) 32#define DOVE_PMU_MPP_GENERAL_CTRL (DOVE_MPP_VIRT_BASE + 0x10)
@@ -52,6 +57,8 @@
52#define CONFIG_PMU BIT(4) 57#define CONFIG_PMU BIT(4)
53 58
54static void __iomem *mpp_base; 59static void __iomem *mpp_base;
60static void __iomem *mpp4_base;
61static void __iomem *pmu_base;
55 62
56static int dove_mpp_ctrl_get(unsigned pid, unsigned long *config) 63static int dove_mpp_ctrl_get(unsigned pid, unsigned long *config)
57{ 64{
@@ -751,7 +758,8 @@ static struct of_device_id dove_pinctrl_of_match[] = {
751 758
752static int dove_pinctrl_probe(struct platform_device *pdev) 759static int dove_pinctrl_probe(struct platform_device *pdev)
753{ 760{
754 struct resource *res; 761 struct resource *res, *mpp_res;
762 struct resource fb_res;
755 const struct of_device_id *match = 763 const struct of_device_id *match =
756 of_match_device(dove_pinctrl_of_match, &pdev->dev); 764 of_match_device(dove_pinctrl_of_match, &pdev->dev);
757 pdev->dev.platform_data = (void *)match->data; 765 pdev->dev.platform_data = (void *)match->data;
@@ -767,11 +775,42 @@ static int dove_pinctrl_probe(struct platform_device *pdev)
767 } 775 }
768 clk_prepare_enable(clk); 776 clk_prepare_enable(clk);
769 777
770 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 778 mpp_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
771 mpp_base = devm_ioremap_resource(&pdev->dev, res); 779 mpp_base = devm_ioremap_resource(&pdev->dev, mpp_res);
772 if (IS_ERR(mpp_base)) 780 if (IS_ERR(mpp_base))
773 return PTR_ERR(mpp_base); 781 return PTR_ERR(mpp_base);
774 782
783 /* prepare fallback resource */
784 memcpy(&fb_res, mpp_res, sizeof(struct resource));
785 fb_res.start = 0;
786
787 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
788 if (!res) {
789 dev_warn(&pdev->dev, "falling back to hardcoded MPP4 resource\n");
790 adjust_resource(&fb_res,
791 (mpp_res->start & INT_REGS_MASK) + MPP4_REGS_OFFS, 0x4);
792 res = &fb_res;
793 }
794
795 mpp4_base = devm_ioremap_resource(&pdev->dev, res);
796 if (IS_ERR(mpp4_base))
797 return PTR_ERR(mpp4_base);
798
799 res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
800 if (!res) {
801 dev_warn(&pdev->dev, "falling back to hardcoded PMU resource\n");
802 adjust_resource(&fb_res,
803 (mpp_res->start & INT_REGS_MASK) + PMU_REGS_OFFS, 0x8);
804 res = &fb_res;
805 }
806
807 pmu_base = devm_ioremap_resource(&pdev->dev, res);
808 if (IS_ERR(pmu_base))
809 return PTR_ERR(pmu_base);
810
811 /* Warn on any missing DT resource */
812 WARN(fb_res.start, FW_BUG "Missing pinctrl regs in DTB. Please update your firmware.\n");
813
775 return mvebu_pinctrl_probe(pdev); 814 return mvebu_pinctrl_probe(pdev);
776} 815}
777 816