Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'v4.5-next-soc' of https://github.com/mbgg/linux-mediatek into next/soc

Merge "ARM: mediatek: soc updates for v4.6" from Matthias Brugger:

Fix state machine implemenation of PMIC wrapper.
Add SMP support for mt7623.
Disable watchdog of STAUPD in PMIC wrapper for mt8173.
Add SMP support for mt2701.
Use builtin_platform_driver for scpsys. Driver can't be build as module.
Fix regulator enablement in scpsys.

* tag 'v4.5-next-soc' of https://github.com/mbgg/linux-mediatek:
soc: mediatek: SCPSYS: Fix double enabling of regulators
soc: mediatek: SCPSYS: use builtin_platform_driver
ARM: mediatek: add mt2701 smp bringup code
soc: mediatek: PMIC wrap: clear the STAUPD_TRIG bit of WDT_SRC_EN
ARM: mediatek: add MT7623 smp bringup code
soc: mediatek: PMIC wrap: Clear the vldclr if state machine stay on FSM_VLDCLR state.

+71 -38
+8
arch/arm/mach-mediatek/platsmp.c
··· 44 44 { 0x38, 0x3c, 0x40 }, 45 45 }; 46 46 47 + static const struct mtk_smp_boot_info mtk_mt7623_boot = { 48 + 0x10202000, 0x34, 49 + { 0x534c4131, 0x4c415332, 0x41534c33 }, 50 + { 0x38, 0x3c, 0x40 }, 51 + }; 52 + 47 53 static const struct of_device_id mtk_tz_smp_boot_infos[] __initconst = { 48 54 { .compatible = "mediatek,mt8135", .data = &mtk_mt8135_tz_boot }, 49 55 { .compatible = "mediatek,mt8127", .data = &mtk_mt8135_tz_boot }, 56 + { .compatible = "mediatek,mt2701", .data = &mtk_mt8135_tz_boot }, 50 57 }; 51 58 52 59 static const struct of_device_id mtk_smp_boot_infos[] __initconst = { 53 60 { .compatible = "mediatek,mt6589", .data = &mtk_mt6589_boot }, 61 + { .compatible = "mediatek,mt7623", .data = &mtk_mt7623_boot }, 54 62 }; 55 63 56 64 static void __iomem *mtk_smp_base;
+37 -4
drivers/soc/mediatek/mtk-pmic-wrap.c
··· 60 60 #define PWRAP_MAN_CMD_OP_OUTD (0x9 << 8) 61 61 #define PWRAP_MAN_CMD_OP_OUTQ (0xa << 8) 62 62 63 + /* macro for Watch Dog Timer Source */ 64 + #define PWRAP_WDT_SRC_EN_STAUPD_TRIG (1 << 25) 65 + #define PWRAP_WDT_SRC_EN_HARB_STAUPD_DLE (1 << 20) 66 + #define PWRAP_WDT_SRC_EN_HARB_STAUPD_ALE (1 << 6) 67 + #define PWRAP_WDT_SRC_MASK_ALL 0xffffffff 68 + #define PWRAP_WDT_SRC_MASK_NO_STAUPD ~(PWRAP_WDT_SRC_EN_STAUPD_TRIG | \ 69 + PWRAP_WDT_SRC_EN_HARB_STAUPD_DLE | \ 70 + PWRAP_WDT_SRC_EN_HARB_STAUPD_ALE) 71 + 63 72 /* macro for slave device wrapper registers */ 64 73 #define PWRAP_DEW_BASE 0xbc00 65 74 #define PWRAP_DEW_EVENT_OUT_EN (PWRAP_DEW_BASE + 0x0) ··· 421 412 return PWRAP_GET_WACS_FSM(val) == PWRAP_WACS_FSM_WFVLDCLR; 422 413 } 423 414 415 + /* 416 + * Timeout issue sometimes caused by the last read command 417 + * failed because pmic wrap could not got the FSM_VLDCLR 418 + * in time after finishing WACS2_CMD. It made state machine 419 + * still on FSM_VLDCLR and timeout next time. 420 + * Check the status of FSM and clear the vldclr to recovery the 421 + * error. 422 + */ 423 + static inline void pwrap_leave_fsm_vldclr(struct pmic_wrapper *wrp) 424 + { 425 + if (pwrap_is_fsm_vldclr(wrp)) 426 + pwrap_writel(wrp, 1, PWRAP_WACS2_VLDCLR); 427 + } 428 + 424 429 static bool pwrap_is_sync_idle(struct pmic_wrapper *wrp) 425 430 { 426 431 return pwrap_readl(wrp, PWRAP_WACS2_RDATA) & PWRAP_STATE_SYNC_IDLE0; ··· 468 445 int ret; 469 446 470 447 ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle); 471 - if (ret) 448 + if (ret) { 449 + pwrap_leave_fsm_vldclr(wrp); 472 450 return ret; 451 + } 473 452 474 453 pwrap_writel(wrp, (1 << 31) | ((adr >> 1) << 16) | wdata, 475 454 PWRAP_WACS2_CMD); ··· 484 459 int ret; 485 460 486 461 ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle); 487 - if (ret) 462 + if (ret) { 463 + pwrap_leave_fsm_vldclr(wrp); 488 464 return ret; 465 + } 489 466 490 467 pwrap_writel(wrp, (adr >> 1) << 16, PWRAP_WACS2_CMD); 491 468 ··· 831 804 832 805 static int pwrap_probe(struct platform_device *pdev) 833 806 { 834 - int ret, irq; 807 + int ret, irq, wdt_src; 835 808 struct pmic_wrapper *wrp; 836 809 struct device_node *np = pdev->dev.of_node; 837 810 const struct of_device_id *of_id = ··· 921 894 922 895 /* Initialize watchdog, may not be done by the bootloader */ 923 896 pwrap_writel(wrp, 0xf, PWRAP_WDT_UNIT); 924 - pwrap_writel(wrp, 0xffffffff, PWRAP_WDT_SRC_EN); 897 + /* 898 + * Since STAUPD was not used on mt8173 platform, 899 + * so STAUPD of WDT_SRC which should be turned off 900 + */ 901 + wdt_src = pwrap_is_mt8173(wrp) ? 902 + PWRAP_WDT_SRC_MASK_NO_STAUPD : PWRAP_WDT_SRC_MASK_ALL; 903 + pwrap_writel(wrp, wdt_src, PWRAP_WDT_SRC_EN); 925 904 pwrap_writel(wrp, 0x1, PWRAP_TIMER_EN); 926 905 pwrap_writel(wrp, ~((1 << 31) | (1 << 1)), PWRAP_INT_EN); 927 906
+26 -34
drivers/soc/mediatek/mtk-scpsys.c
··· 76 76 bool active_wakeup; 77 77 }; 78 78 79 - static const struct scp_domain_data scp_domain_data[] __initconst = { 79 + static const struct scp_domain_data scp_domain_data[] = { 80 80 [MT8173_POWER_DOMAIN_VDEC] = { 81 81 .name = "vdec", 82 82 .sta_mask = PWR_STATUS_VDEC, ··· 174 174 struct generic_pm_domain genpd; 175 175 struct scp *scp; 176 176 struct clk *clk[MAX_CLKS]; 177 - u32 sta_mask; 178 - void __iomem *ctl_addr; 179 - u32 sram_pdn_bits; 180 - u32 sram_pdn_ack_bits; 181 - u32 bus_prot_mask; 182 - bool active_wakeup; 177 + const struct scp_domain_data *data; 183 178 struct regulator *supply; 184 179 }; 185 180 ··· 190 195 { 191 196 struct scp *scp = scpd->scp; 192 197 193 - u32 status = readl(scp->base + SPM_PWR_STATUS) & scpd->sta_mask; 194 - u32 status2 = readl(scp->base + SPM_PWR_STATUS_2ND) & scpd->sta_mask; 198 + u32 status = readl(scp->base + SPM_PWR_STATUS) & scpd->data->sta_mask; 199 + u32 status2 = readl(scp->base + SPM_PWR_STATUS_2ND) & 200 + scpd->data->sta_mask; 195 201 196 202 /* 197 203 * A domain is on when both status bits are set. If only one is set ··· 213 217 struct scp *scp = scpd->scp; 214 218 unsigned long timeout; 215 219 bool expired; 216 - void __iomem *ctl_addr = scpd->ctl_addr; 217 - u32 sram_pdn_ack = scpd->sram_pdn_ack_bits; 220 + void __iomem *ctl_addr = scp->base + scpd->data->ctl_offs; 221 + u32 sram_pdn_ack = scpd->data->sram_pdn_ack_bits; 218 222 u32 val; 219 223 int ret; 220 224 int i; ··· 269 273 val |= PWR_RST_B_BIT; 270 274 writel(val, ctl_addr); 271 275 272 - val &= ~scpd->sram_pdn_bits; 276 + val &= ~scpd->data->sram_pdn_bits; 273 277 writel(val, ctl_addr); 274 278 275 279 /* wait until SRAM_PDN_ACK all 0 */ ··· 288 292 expired = true; 289 293 } 290 294 291 - if (scpd->bus_prot_mask) { 295 + if (scpd->data->bus_prot_mask) { 292 296 ret = mtk_infracfg_clear_bus_protection(scp->infracfg, 293 - scpd->bus_prot_mask); 297 + scpd->data->bus_prot_mask); 294 298 if (ret) 295 299 goto err_pwr_ack; 296 300 } ··· 317 321 struct scp *scp = scpd->scp; 318 322 unsigned long timeout; 319 323 bool expired; 320 - void __iomem *ctl_addr = scpd->ctl_addr; 321 - u32 pdn_ack = scpd->sram_pdn_ack_bits; 324 + void __iomem *ctl_addr = scp->base + scpd->data->ctl_offs; 325 + u32 pdn_ack = scpd->data->sram_pdn_ack_bits; 322 326 u32 val; 323 327 int ret; 324 328 int i; 325 329 326 - if (scpd->bus_prot_mask) { 330 + if (scpd->data->bus_prot_mask) { 327 331 ret = mtk_infracfg_set_bus_protection(scp->infracfg, 328 - scpd->bus_prot_mask); 332 + scpd->data->bus_prot_mask); 329 333 if (ret) 330 334 goto out; 331 335 } 332 336 333 337 val = readl(ctl_addr); 334 - val |= scpd->sram_pdn_bits; 338 + val |= scpd->data->sram_pdn_bits; 335 339 writel(val, ctl_addr); 336 340 337 341 /* wait until SRAM_PDN_ACK all 1 */ ··· 405 409 genpd = pd_to_genpd(dev->pm_domain); 406 410 scpd = container_of(genpd, struct scp_domain, genpd); 407 411 408 - return scpd->active_wakeup; 412 + return scpd->data->active_wakeup; 409 413 } 410 414 411 - static int __init scpsys_probe(struct platform_device *pdev) 415 + static int scpsys_probe(struct platform_device *pdev) 412 416 { 413 417 struct genpd_onecell_data *pd_data; 414 418 struct resource *res; ··· 481 485 pd_data->domains[i] = genpd; 482 486 scpd->scp = scp; 483 487 484 - scpd->sta_mask = data->sta_mask; 485 - scpd->ctl_addr = scp->base + data->ctl_offs; 486 - scpd->sram_pdn_bits = data->sram_pdn_bits; 487 - scpd->sram_pdn_ack_bits = data->sram_pdn_ack_bits; 488 - scpd->bus_prot_mask = data->bus_prot_mask; 489 - scpd->active_wakeup = data->active_wakeup; 488 + scpd->data = data; 490 489 for (j = 0; j < MAX_CLKS && data->clk_id[j]; j++) 491 490 scpd->clk[j] = clk[data->clk_id[j]]; 492 491 ··· 491 500 genpd->dev_ops.active_wakeup = scpsys_active_wakeup; 492 501 493 502 /* 494 - * Initially turn on all domains to make the domains usable 495 - * with !CONFIG_PM and to get the hardware in sync with the 496 - * software. The unused domains will be switched off during 497 - * late_init time. 503 + * With CONFIG_PM disabled turn on all domains to make the 504 + * hardware usable. 498 505 */ 499 - genpd->power_on(genpd); 506 + if (!IS_ENABLED(CONFIG_PM)) 507 + genpd->power_on(genpd); 500 508 501 - pm_genpd_init(genpd, NULL, false); 509 + pm_genpd_init(genpd, NULL, true); 502 510 } 503 511 504 512 /* ··· 532 542 }; 533 543 534 544 static struct platform_driver scpsys_drv = { 545 + .probe = scpsys_probe, 535 546 .driver = { 536 547 .name = "mtk-scpsys", 548 + .suppress_bind_attrs = true, 537 549 .owner = THIS_MODULE, 538 550 .of_match_table = of_match_ptr(of_scpsys_match_tbl), 539 551 }, 540 552 }; 541 - builtin_platform_driver_probe(scpsys_drv, scpsys_probe); 553 + builtin_platform_driver(scpsys_drv);