diff options
author | John Crispin <blogic@openwrt.org> | 2016-02-19 03:44:06 -0500 |
---|---|---|
committer | Matthias Brugger <matthias.bgg@gmail.com> | 2016-04-20 07:02:59 -0400 |
commit | 9bebedb054f98b70c798423cba6d9ba903b27d63 (patch) | |
tree | e2069c27316cdc327cc10bb3ecb2f6b3102e9f3b | |
parent | f55532a0c0b8bb6148f4e07853b876ef73bc69ca (diff) |
soc: mediatek: PMIC wrap: don't duplicate the wrapper data
As we add support for more devices struct pmic_wrapper_type will grow and
we do not really want to start duplicating all the elements in
struct pmic_wrapper.
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.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c index 0d9b19a78d27..340c4b520da1 100644 --- a/drivers/soc/mediatek/mtk-pmic-wrap.c +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c | |||
@@ -376,9 +376,7 @@ struct pmic_wrapper { | |||
376 | struct device *dev; | 376 | struct device *dev; |
377 | void __iomem *base; | 377 | void __iomem *base; |
378 | struct regmap *regmap; | 378 | struct regmap *regmap; |
379 | int *regs; | 379 | const struct pmic_wrapper_type *master; |
380 | enum pwrap_type type; | ||
381 | u32 arb_en_all; | ||
382 | struct clk *clk_spi; | 380 | struct clk *clk_spi; |
383 | struct clk *clk_wrap; | 381 | struct clk *clk_wrap; |
384 | struct reset_control *rstc; | 382 | struct reset_control *rstc; |
@@ -389,22 +387,22 @@ struct pmic_wrapper { | |||
389 | 387 | ||
390 | static inline int pwrap_is_mt8135(struct pmic_wrapper *wrp) | 388 | static inline int pwrap_is_mt8135(struct pmic_wrapper *wrp) |
391 | { | 389 | { |
392 | return wrp->type == PWRAP_MT8135; | 390 | return wrp->master->type == PWRAP_MT8135; |
393 | } | 391 | } |
394 | 392 | ||
395 | static inline int pwrap_is_mt8173(struct pmic_wrapper *wrp) | 393 | static inline int pwrap_is_mt8173(struct pmic_wrapper *wrp) |
396 | { | 394 | { |
397 | return wrp->type == PWRAP_MT8173; | 395 | return wrp->master->type == PWRAP_MT8173; |
398 | } | 396 | } |
399 | 397 | ||
400 | static u32 pwrap_readl(struct pmic_wrapper *wrp, enum pwrap_regs reg) | 398 | static u32 pwrap_readl(struct pmic_wrapper *wrp, enum pwrap_regs reg) |
401 | { | 399 | { |
402 | return readl(wrp->base + wrp->regs[reg]); | 400 | return readl(wrp->base + wrp->master->regs[reg]); |
403 | } | 401 | } |
404 | 402 | ||
405 | static void pwrap_writel(struct pmic_wrapper *wrp, u32 val, enum pwrap_regs reg) | 403 | static void pwrap_writel(struct pmic_wrapper *wrp, u32 val, enum pwrap_regs reg) |
406 | { | 404 | { |
407 | writel(val, wrp->base + wrp->regs[reg]); | 405 | writel(val, wrp->base + wrp->master->regs[reg]); |
408 | } | 406 | } |
409 | 407 | ||
410 | static bool pwrap_is_fsm_idle(struct pmic_wrapper *wrp) | 408 | static bool pwrap_is_fsm_idle(struct pmic_wrapper *wrp) |
@@ -697,7 +695,7 @@ static int pwrap_init(struct pmic_wrapper *wrp) | |||
697 | 695 | ||
698 | pwrap_writel(wrp, 1, PWRAP_WRAP_EN); | 696 | pwrap_writel(wrp, 1, PWRAP_WRAP_EN); |
699 | 697 | ||
700 | pwrap_writel(wrp, wrp->arb_en_all, PWRAP_HIPRIO_ARB_EN); | 698 | pwrap_writel(wrp, wrp->master->arb_en_all, PWRAP_HIPRIO_ARB_EN); |
701 | 699 | ||
702 | pwrap_writel(wrp, 1, PWRAP_WACS2_EN); | 700 | pwrap_writel(wrp, 1, PWRAP_WACS2_EN); |
703 | 701 | ||
@@ -742,7 +740,7 @@ static int pwrap_init(struct pmic_wrapper *wrp) | |||
742 | pwrap_writel(wrp, 0x1, PWRAP_CRC_EN); | 740 | pwrap_writel(wrp, 0x1, PWRAP_CRC_EN); |
743 | pwrap_writel(wrp, 0x0, PWRAP_SIG_MODE); | 741 | pwrap_writel(wrp, 0x0, PWRAP_SIG_MODE); |
744 | pwrap_writel(wrp, PWRAP_DEW_CRC_VAL, PWRAP_SIG_ADR); | 742 | pwrap_writel(wrp, PWRAP_DEW_CRC_VAL, PWRAP_SIG_ADR); |
745 | pwrap_writel(wrp, wrp->arb_en_all, PWRAP_HIPRIO_ARB_EN); | 743 | pwrap_writel(wrp, wrp->master->arb_en_all, PWRAP_HIPRIO_ARB_EN); |
746 | 744 | ||
747 | if (pwrap_is_mt8135(wrp)) | 745 | if (pwrap_is_mt8135(wrp)) |
748 | pwrap_writel(wrp, 0x7, PWRAP_RRARB_EN); | 746 | pwrap_writel(wrp, 0x7, PWRAP_RRARB_EN); |
@@ -836,7 +834,6 @@ static int pwrap_probe(struct platform_device *pdev) | |||
836 | struct device_node *np = pdev->dev.of_node; | 834 | struct device_node *np = pdev->dev.of_node; |
837 | const struct of_device_id *of_id = | 835 | const struct of_device_id *of_id = |
838 | of_match_device(of_pwrap_match_tbl, &pdev->dev); | 836 | of_match_device(of_pwrap_match_tbl, &pdev->dev); |
839 | const struct pmic_wrapper_type *type; | ||
840 | struct resource *res; | 837 | struct resource *res; |
841 | 838 | ||
842 | wrp = devm_kzalloc(&pdev->dev, sizeof(*wrp), GFP_KERNEL); | 839 | wrp = devm_kzalloc(&pdev->dev, sizeof(*wrp), GFP_KERNEL); |
@@ -845,10 +842,7 @@ static int pwrap_probe(struct platform_device *pdev) | |||
845 | 842 | ||
846 | platform_set_drvdata(pdev, wrp); | 843 | platform_set_drvdata(pdev, wrp); |
847 | 844 | ||
848 | type = of_id->data; | 845 | wrp->master = of_id->data; |
849 | wrp->regs = type->regs; | ||
850 | wrp->type = type->type; | ||
851 | wrp->arb_en_all = type->arb_en_all; | ||
852 | wrp->dev = &pdev->dev; | 846 | wrp->dev = &pdev->dev; |
853 | 847 | ||
854 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pwrap"); | 848 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pwrap"); |