aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2016-02-19 03:44:07 -0500
committerMatthias Brugger <matthias.bgg@gmail.com>2016-04-20 07:03:00 -0400
commita397845338af260658f55b2ba73834940244cf6d (patch)
tree6f9897fe3c57e14ca0be650e552cf7200f1498a3
parent9bebedb054f98b70c798423cba6d9ba903b27d63 (diff)
soc: mediatek: PMIC wrap: add wrapper callbacks for init_reg_clock
Split init_reg_clock up into SoC specific callbacks. The patch also reorders the code to avoid the need for callback function prototypes. Signed-off-by: John Crispin <blogic@openwrt.org> Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
-rw-r--r--drivers/soc/mediatek/mtk-pmic-wrap.c70
1 files changed, 38 insertions, 32 deletions
diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
index 340c4b520da1..b22b664b155b 100644
--- a/drivers/soc/mediatek/mtk-pmic-wrap.c
+++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
@@ -354,24 +354,6 @@ enum pwrap_type {
354 PWRAP_MT8173, 354 PWRAP_MT8173,
355}; 355};
356 356
357struct pmic_wrapper_type {
358 int *regs;
359 enum pwrap_type type;
360 u32 arb_en_all;
361};
362
363static struct pmic_wrapper_type pwrap_mt8135 = {
364 .regs = mt8135_regs,
365 .type = PWRAP_MT8135,
366 .arb_en_all = 0x1ff,
367};
368
369static struct pmic_wrapper_type pwrap_mt8173 = {
370 .regs = mt8173_regs,
371 .type = PWRAP_MT8173,
372 .arb_en_all = 0x3f,
373};
374
375struct pmic_wrapper { 357struct pmic_wrapper {
376 struct device *dev; 358 struct device *dev;
377 void __iomem *base; 359 void __iomem *base;
@@ -385,6 +367,13 @@ struct pmic_wrapper {
385 void __iomem *bridge_base; 367 void __iomem *bridge_base;
386}; 368};
387 369
370struct pmic_wrapper_type {
371 int *regs;
372 enum pwrap_type type;
373 u32 arb_en_all;
374 int (*init_reg_clock)(struct pmic_wrapper *wrp);
375};
376
388static inline int pwrap_is_mt8135(struct pmic_wrapper *wrp) 377static inline int pwrap_is_mt8135(struct pmic_wrapper *wrp)
389{ 378{
390 return wrp->master->type == PWRAP_MT8135; 379 return wrp->master->type == PWRAP_MT8135;
@@ -578,20 +567,23 @@ static int pwrap_init_sidly(struct pmic_wrapper *wrp)
578 return 0; 567 return 0;
579} 568}
580 569
581static int pwrap_init_reg_clock(struct pmic_wrapper *wrp) 570static int pwrap_mt8135_init_reg_clock(struct pmic_wrapper *wrp)
582{ 571{
583 if (pwrap_is_mt8135(wrp)) { 572 pwrap_writel(wrp, 0x4, PWRAP_CSHEXT);
584 pwrap_writel(wrp, 0x4, PWRAP_CSHEXT); 573 pwrap_writel(wrp, 0x0, PWRAP_CSHEXT_WRITE);
585 pwrap_writel(wrp, 0x0, PWRAP_CSHEXT_WRITE); 574 pwrap_writel(wrp, 0x4, PWRAP_CSHEXT_READ);
586 pwrap_writel(wrp, 0x4, PWRAP_CSHEXT_READ); 575 pwrap_writel(wrp, 0x0, PWRAP_CSLEXT_START);
587 pwrap_writel(wrp, 0x0, PWRAP_CSLEXT_START); 576 pwrap_writel(wrp, 0x0, PWRAP_CSLEXT_END);
588 pwrap_writel(wrp, 0x0, PWRAP_CSLEXT_END); 577
589 } else { 578 return 0;
590 pwrap_writel(wrp, 0x0, PWRAP_CSHEXT_WRITE); 579}
591 pwrap_writel(wrp, 0x4, PWRAP_CSHEXT_READ); 580
592 pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_START); 581static int pwrap_mt8173_init_reg_clock(struct pmic_wrapper *wrp)
593 pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_END); 582{
594 } 583 pwrap_writel(wrp, 0x0, PWRAP_CSHEXT_WRITE);
584 pwrap_writel(wrp, 0x4, PWRAP_CSHEXT_READ);
585 pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_START);
586 pwrap_writel(wrp, 0x2, PWRAP_CSLEXT_END);
595 587
596 return 0; 588 return 0;
597} 589}
@@ -699,7 +691,7 @@ static int pwrap_init(struct pmic_wrapper *wrp)
699 691
700 pwrap_writel(wrp, 1, PWRAP_WACS2_EN); 692 pwrap_writel(wrp, 1, PWRAP_WACS2_EN);
701 693
702 ret = pwrap_init_reg_clock(wrp); 694 ret = wrp->master->init_reg_clock(wrp);
703 if (ret) 695 if (ret)
704 return ret; 696 return ret;
705 697
@@ -814,6 +806,20 @@ static const struct regmap_config pwrap_regmap_config = {
814 .max_register = 0xffff, 806 .max_register = 0xffff,
815}; 807};
816 808
809static struct pmic_wrapper_type pwrap_mt8135 = {
810 .regs = mt8135_regs,
811 .type = PWRAP_MT8135,
812 .arb_en_all = 0x1ff,
813 .init_reg_clock = pwrap_mt8135_init_reg_clock,
814};
815
816static struct pmic_wrapper_type pwrap_mt8173 = {
817 .regs = mt8173_regs,
818 .type = PWRAP_MT8173,
819 .arb_en_all = 0x3f,
820 .init_reg_clock = pwrap_mt8173_init_reg_clock,
821};
822
817static struct of_device_id of_pwrap_match_tbl[] = { 823static struct of_device_id of_pwrap_match_tbl[] = {
818 { 824 {
819 .compatible = "mediatek,mt8135-pwrap", 825 .compatible = "mediatek,mt8135-pwrap",