Lines Matching refs:wrp
1067 int (*pwrap_read)(struct pmic_wrapper *wrp, u32 adr, u32 *rdata);
1068 int (*pwrap_write)(struct pmic_wrapper *wrp, u32 adr, u32 wdata);
1095 int (*init_reg_clock)(struct pmic_wrapper *wrp);
1096 int (*init_soc_specific)(struct pmic_wrapper *wrp);
1099 static u32 pwrap_readl(struct pmic_wrapper *wrp, enum pwrap_regs reg) in pwrap_readl() argument
1101 return readl(wrp->base + wrp->master->regs[reg]); in pwrap_readl()
1104 static void pwrap_writel(struct pmic_wrapper *wrp, u32 val, enum pwrap_regs reg) in pwrap_writel() argument
1106 writel(val, wrp->base + wrp->master->regs[reg]); in pwrap_writel()
1109 static bool pwrap_is_fsm_idle(struct pmic_wrapper *wrp) in pwrap_is_fsm_idle() argument
1111 u32 val = pwrap_readl(wrp, PWRAP_WACS2_RDATA); in pwrap_is_fsm_idle()
1116 static bool pwrap_is_fsm_vldclr(struct pmic_wrapper *wrp) in pwrap_is_fsm_vldclr() argument
1118 u32 val = pwrap_readl(wrp, PWRAP_WACS2_RDATA); in pwrap_is_fsm_vldclr()
1131 static inline void pwrap_leave_fsm_vldclr(struct pmic_wrapper *wrp) in pwrap_leave_fsm_vldclr() argument
1133 if (pwrap_is_fsm_vldclr(wrp)) in pwrap_leave_fsm_vldclr()
1134 pwrap_writel(wrp, 1, PWRAP_WACS2_VLDCLR); in pwrap_leave_fsm_vldclr()
1137 static bool pwrap_is_sync_idle(struct pmic_wrapper *wrp) in pwrap_is_sync_idle() argument
1139 return pwrap_readl(wrp, PWRAP_WACS2_RDATA) & PWRAP_STATE_SYNC_IDLE0; in pwrap_is_sync_idle()
1142 static bool pwrap_is_fsm_idle_and_sync_idle(struct pmic_wrapper *wrp) in pwrap_is_fsm_idle_and_sync_idle() argument
1144 u32 val = pwrap_readl(wrp, PWRAP_WACS2_RDATA); in pwrap_is_fsm_idle_and_sync_idle()
1150 static int pwrap_wait_for_state(struct pmic_wrapper *wrp, in pwrap_wait_for_state() argument
1159 return fp(wrp) ? 0 : -ETIMEDOUT; in pwrap_wait_for_state()
1160 if (fp(wrp)) in pwrap_wait_for_state()
1165 static int pwrap_read16(struct pmic_wrapper *wrp, u32 adr, u32 *rdata) in pwrap_read16() argument
1169 ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle); in pwrap_read16()
1171 pwrap_leave_fsm_vldclr(wrp); in pwrap_read16()
1175 pwrap_writel(wrp, (adr >> 1) << 16, PWRAP_WACS2_CMD); in pwrap_read16()
1177 ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_vldclr); in pwrap_read16()
1181 *rdata = PWRAP_GET_WACS_RDATA(pwrap_readl(wrp, PWRAP_WACS2_RDATA)); in pwrap_read16()
1183 pwrap_writel(wrp, 1, PWRAP_WACS2_VLDCLR); in pwrap_read16()
1188 static int pwrap_read32(struct pmic_wrapper *wrp, u32 adr, u32 *rdata) in pwrap_read32() argument
1194 ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle); in pwrap_read32()
1196 pwrap_leave_fsm_vldclr(wrp); in pwrap_read32()
1200 pwrap_writel(wrp, ((msb << 30) | (adr << 16)), in pwrap_read32()
1203 ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_vldclr); in pwrap_read32()
1207 *rdata += (PWRAP_GET_WACS_RDATA(pwrap_readl(wrp, in pwrap_read32()
1210 pwrap_writel(wrp, 1, PWRAP_WACS2_VLDCLR); in pwrap_read32()
1216 static int pwrap_read(struct pmic_wrapper *wrp, u32 adr, u32 *rdata) in pwrap_read() argument
1218 return wrp->slave->pwrap_read(wrp, adr, rdata); in pwrap_read()
1221 static int pwrap_write16(struct pmic_wrapper *wrp, u32 adr, u32 wdata) in pwrap_write16() argument
1225 ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle); in pwrap_write16()
1227 pwrap_leave_fsm_vldclr(wrp); in pwrap_write16()
1231 pwrap_writel(wrp, (1 << 31) | ((adr >> 1) << 16) | wdata, in pwrap_write16()
1237 static int pwrap_write32(struct pmic_wrapper *wrp, u32 adr, u32 wdata) in pwrap_write32() argument
1242 ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle); in pwrap_write32()
1244 pwrap_leave_fsm_vldclr(wrp); in pwrap_write32()
1248 pwrap_writel(wrp, (1 << 31) | (msb << 30) | (adr << 16) | in pwrap_write32()
1260 pwrap_read(wrp, adr, &rdata); in pwrap_write32()
1266 static int pwrap_write(struct pmic_wrapper *wrp, u32 adr, u32 wdata) in pwrap_write() argument
1268 return wrp->slave->pwrap_write(wrp, adr, wdata); in pwrap_write()
1281 static int pwrap_reset_spislave(struct pmic_wrapper *wrp) in pwrap_reset_spislave() argument
1285 pwrap_writel(wrp, 0, PWRAP_HIPRIO_ARB_EN); in pwrap_reset_spislave()
1286 pwrap_writel(wrp, 0, PWRAP_WRAP_EN); in pwrap_reset_spislave()
1287 pwrap_writel(wrp, 1, PWRAP_MUX_SEL); in pwrap_reset_spislave()
1288 pwrap_writel(wrp, 1, PWRAP_MAN_EN); in pwrap_reset_spislave()
1289 pwrap_writel(wrp, 0, PWRAP_DIO_EN); in pwrap_reset_spislave()
1291 pwrap_writel(wrp, wrp->master->spi_w | PWRAP_MAN_CMD_OP_CSL, in pwrap_reset_spislave()
1293 pwrap_writel(wrp, wrp->master->spi_w | PWRAP_MAN_CMD_OP_OUTS, in pwrap_reset_spislave()
1295 pwrap_writel(wrp, wrp->master->spi_w | PWRAP_MAN_CMD_OP_CSH, in pwrap_reset_spislave()
1299 pwrap_writel(wrp, wrp->master->spi_w | PWRAP_MAN_CMD_OP_OUTS, in pwrap_reset_spislave()
1302 ret = pwrap_wait_for_state(wrp, pwrap_is_sync_idle); in pwrap_reset_spislave()
1304 dev_err(wrp->dev, "%s fail, ret=%d\n", __func__, ret); in pwrap_reset_spislave()
1308 pwrap_writel(wrp, 0, PWRAP_MAN_EN); in pwrap_reset_spislave()
1309 pwrap_writel(wrp, 0, PWRAP_MUX_SEL); in pwrap_reset_spislave()
1320 static int pwrap_init_sidly(struct pmic_wrapper *wrp) in pwrap_init_sidly() argument
1330 pwrap_writel(wrp, i, PWRAP_SIDLY); in pwrap_init_sidly()
1331 pwrap_read(wrp, wrp->slave->dew_regs[PWRAP_DEW_READ_TEST], in pwrap_init_sidly()
1334 dev_dbg(wrp->dev, "[Read Test] pass, SIDLY=%x\n", i); in pwrap_init_sidly()
1340 dev_err(wrp->dev, "sidly pass range 0x%x not continuous\n", in pwrap_init_sidly()
1345 pwrap_writel(wrp, dly[pass], PWRAP_SIDLY); in pwrap_init_sidly()
1350 static int pwrap_init_dual_io(struct pmic_wrapper *wrp) in pwrap_init_dual_io() argument
1356 pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_DIO_EN], 1); in pwrap_init_dual_io()
1359 ret = pwrap_wait_for_state(wrp, in pwrap_init_dual_io()
1362 dev_err(wrp->dev, "%s fail, ret=%d\n", __func__, ret); in pwrap_init_dual_io()
1366 pwrap_writel(wrp, 1, PWRAP_DIO_EN); in pwrap_init_dual_io()
1369 pwrap_read(wrp, in pwrap_init_dual_io()
1370 wrp->slave->dew_regs[PWRAP_DEW_READ_TEST], &rdata); in pwrap_init_dual_io()
1372 dev_err(wrp->dev, in pwrap_init_dual_io()
1385 static void pwrap_init_chip_select_ext(struct pmic_wrapper *wrp, u8 hext_write, in pwrap_init_chip_select_ext() argument
1394 pwrap_writel(wrp, hext_write, PWRAP_CSHEXT_WRITE); in pwrap_init_chip_select_ext()
1395 pwrap_writel(wrp, hext_read, PWRAP_CSHEXT_READ); in pwrap_init_chip_select_ext()
1402 pwrap_writel(wrp, lext_start, PWRAP_CSLEXT_START); in pwrap_init_chip_select_ext()
1403 pwrap_writel(wrp, lext_end, PWRAP_CSLEXT_END); in pwrap_init_chip_select_ext()
1406 static int pwrap_common_init_reg_clock(struct pmic_wrapper *wrp) in pwrap_common_init_reg_clock() argument
1408 switch (wrp->master->type) { in pwrap_common_init_reg_clock()
1410 pwrap_init_chip_select_ext(wrp, 0, 4, 2, 2); in pwrap_common_init_reg_clock()
1413 pwrap_writel(wrp, 0x4, PWRAP_CSHEXT); in pwrap_common_init_reg_clock()
1414 pwrap_init_chip_select_ext(wrp, 0, 4, 0, 0); in pwrap_common_init_reg_clock()
1423 static int pwrap_mt2701_init_reg_clock(struct pmic_wrapper *wrp) in pwrap_mt2701_init_reg_clock() argument
1425 switch (wrp->slave->type) { in pwrap_mt2701_init_reg_clock()
1427 pwrap_writel(wrp, 0xc, PWRAP_RDDMY); in pwrap_mt2701_init_reg_clock()
1428 pwrap_init_chip_select_ext(wrp, 4, 0, 2, 2); in pwrap_mt2701_init_reg_clock()
1432 pwrap_writel(wrp, 0x8, PWRAP_RDDMY); in pwrap_mt2701_init_reg_clock()
1433 pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_RDDMY_NO], in pwrap_mt2701_init_reg_clock()
1435 pwrap_init_chip_select_ext(wrp, 5, 0, 2, 2); in pwrap_mt2701_init_reg_clock()
1444 static bool pwrap_is_cipher_ready(struct pmic_wrapper *wrp) in pwrap_is_cipher_ready() argument
1446 return pwrap_readl(wrp, PWRAP_CIPHER_RDY) & 1; in pwrap_is_cipher_ready()
1449 static bool pwrap_is_pmic_cipher_ready(struct pmic_wrapper *wrp) in pwrap_is_pmic_cipher_ready() argument
1454 ret = pwrap_read(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_RDY], in pwrap_is_pmic_cipher_ready()
1462 static int pwrap_init_cipher(struct pmic_wrapper *wrp) in pwrap_init_cipher() argument
1467 pwrap_writel(wrp, 0x1, PWRAP_CIPHER_SWRST); in pwrap_init_cipher()
1468 pwrap_writel(wrp, 0x0, PWRAP_CIPHER_SWRST); in pwrap_init_cipher()
1469 pwrap_writel(wrp, 0x1, PWRAP_CIPHER_KEY_SEL); in pwrap_init_cipher()
1470 pwrap_writel(wrp, 0x2, PWRAP_CIPHER_IV_SEL); in pwrap_init_cipher()
1472 switch (wrp->master->type) { in pwrap_init_cipher()
1474 pwrap_writel(wrp, 1, PWRAP_CIPHER_LOAD); in pwrap_init_cipher()
1475 pwrap_writel(wrp, 1, PWRAP_CIPHER_START); in pwrap_init_cipher()
1483 pwrap_writel(wrp, 1, PWRAP_CIPHER_EN); in pwrap_init_cipher()
1486 pwrap_writel(wrp, 0, PWRAP_CIPHER_EN); in pwrap_init_cipher()
1493 pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_SWRST], 0x1); in pwrap_init_cipher()
1494 pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_SWRST], 0x0); in pwrap_init_cipher()
1495 pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_KEY_SEL], 0x1); in pwrap_init_cipher()
1496 pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_IV_SEL], 0x2); in pwrap_init_cipher()
1498 switch (wrp->slave->type) { in pwrap_init_cipher()
1500 pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_LOAD], in pwrap_init_cipher()
1502 pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_START], in pwrap_init_cipher()
1508 pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_EN], in pwrap_init_cipher()
1516 ret = pwrap_wait_for_state(wrp, pwrap_is_cipher_ready); in pwrap_init_cipher()
1518 dev_err(wrp->dev, "cipher data ready@AP fail, ret=%d\n", ret); in pwrap_init_cipher()
1523 ret = pwrap_wait_for_state(wrp, pwrap_is_pmic_cipher_ready); in pwrap_init_cipher()
1525 dev_err(wrp->dev, in pwrap_init_cipher()
1531 pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CIPHER_MODE], 0x1); in pwrap_init_cipher()
1532 ret = pwrap_wait_for_state(wrp, pwrap_is_fsm_idle_and_sync_idle); in pwrap_init_cipher()
1534 dev_err(wrp->dev, "cipher mode idle fail, ret=%d\n", ret); in pwrap_init_cipher()
1538 pwrap_writel(wrp, 1, PWRAP_CIPHER_MODE); in pwrap_init_cipher()
1541 if (pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_WRITE_TEST], in pwrap_init_cipher()
1543 pwrap_read(wrp, wrp->slave->dew_regs[PWRAP_DEW_WRITE_TEST], in pwrap_init_cipher()
1546 dev_err(wrp->dev, "rdata=0x%04X\n", rdata); in pwrap_init_cipher()
1553 static int pwrap_init_security(struct pmic_wrapper *wrp) in pwrap_init_security() argument
1558 ret = pwrap_init_cipher(wrp); in pwrap_init_security()
1563 if (pwrap_write(wrp, in pwrap_init_security()
1564 wrp->slave->dew_regs[PWRAP_DEW_CRC_EN], 0x1)) in pwrap_init_security()
1567 pwrap_writel(wrp, 0x1, PWRAP_CRC_EN); in pwrap_init_security()
1568 pwrap_writel(wrp, 0x0, PWRAP_SIG_MODE); in pwrap_init_security()
1569 pwrap_writel(wrp, wrp->slave->dew_regs[PWRAP_DEW_CRC_VAL], in pwrap_init_security()
1571 pwrap_writel(wrp, in pwrap_init_security()
1572 wrp->master->arb_en_all, PWRAP_HIPRIO_ARB_EN); in pwrap_init_security()
1577 static int pwrap_mt8135_init_soc_specific(struct pmic_wrapper *wrp) in pwrap_mt8135_init_soc_specific() argument
1580 pwrap_writel(wrp, 0x1, PWRAP_EVENT_IN_EN); in pwrap_mt8135_init_soc_specific()
1581 pwrap_writel(wrp, 0xffff, PWRAP_EVENT_DST_EN); in pwrap_mt8135_init_soc_specific()
1582 writel(0x7f, wrp->bridge_base + PWRAP_MT8135_BRIDGE_IORD_ARB_EN); in pwrap_mt8135_init_soc_specific()
1583 writel(0x1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_WACS3_EN); in pwrap_mt8135_init_soc_specific()
1584 writel(0x1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_WACS4_EN); in pwrap_mt8135_init_soc_specific()
1585 writel(0x1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_WDT_UNIT); in pwrap_mt8135_init_soc_specific()
1586 writel(0xffff, wrp->bridge_base + PWRAP_MT8135_BRIDGE_WDT_SRC_EN); in pwrap_mt8135_init_soc_specific()
1587 writel(0x1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_TIMER_EN); in pwrap_mt8135_init_soc_specific()
1588 writel(0x7ff, wrp->bridge_base + PWRAP_MT8135_BRIDGE_INT_EN); in pwrap_mt8135_init_soc_specific()
1591 if (pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_EVENT_OUT_EN], in pwrap_mt8135_init_soc_specific()
1593 pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_EVENT_SRC_EN], in pwrap_mt8135_init_soc_specific()
1595 dev_err(wrp->dev, "enable dewrap fail\n"); in pwrap_mt8135_init_soc_specific()
1602 static int pwrap_mt8173_init_soc_specific(struct pmic_wrapper *wrp) in pwrap_mt8173_init_soc_specific() argument
1605 if (pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_EVENT_OUT_EN], in pwrap_mt8173_init_soc_specific()
1607 pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_EVENT_SRC_EN], in pwrap_mt8173_init_soc_specific()
1609 dev_err(wrp->dev, "enable dewrap fail\n"); in pwrap_mt8173_init_soc_specific()
1616 static int pwrap_mt2701_init_soc_specific(struct pmic_wrapper *wrp) in pwrap_mt2701_init_soc_specific() argument
1619 switch (wrp->slave->type) { in pwrap_mt2701_init_soc_specific()
1621 pwrap_writel(wrp, 0x076c, PWRAP_ADC_CMD_ADDR); in pwrap_mt2701_init_soc_specific()
1622 pwrap_writel(wrp, 0x8000, PWRAP_PWRAP_ADC_CMD); in pwrap_mt2701_init_soc_specific()
1623 pwrap_writel(wrp, 0x072c, PWRAP_ADC_RDY_ADDR); in pwrap_mt2701_init_soc_specific()
1624 pwrap_writel(wrp, 0x072e, PWRAP_ADC_RDATA_ADDR1); in pwrap_mt2701_init_soc_specific()
1625 pwrap_writel(wrp, 0x0730, PWRAP_ADC_RDATA_ADDR2); in pwrap_mt2701_init_soc_specific()
1634 static int pwrap_mt7622_init_soc_specific(struct pmic_wrapper *wrp) in pwrap_mt7622_init_soc_specific() argument
1636 pwrap_writel(wrp, 0, PWRAP_STAUPD_PRD); in pwrap_mt7622_init_soc_specific()
1638 pwrap_writel(wrp, 0x8000000, PWRAP_SPI2_CTRL); in pwrap_mt7622_init_soc_specific()
1643 static int pwrap_mt8183_init_soc_specific(struct pmic_wrapper *wrp) in pwrap_mt8183_init_soc_specific() argument
1645 pwrap_writel(wrp, 0xf5, PWRAP_STAUPD_GRPEN); in pwrap_mt8183_init_soc_specific()
1647 pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_CRC_EN], 0x1); in pwrap_mt8183_init_soc_specific()
1648 pwrap_writel(wrp, 1, PWRAP_CRC_EN); in pwrap_mt8183_init_soc_specific()
1649 pwrap_writel(wrp, 0x416, PWRAP_SIG_ADR); in pwrap_mt8183_init_soc_specific()
1650 pwrap_writel(wrp, 0x42e, PWRAP_EINT_STA0_ADR); in pwrap_mt8183_init_soc_specific()
1652 pwrap_writel(wrp, 1, PWRAP_WACS_P2P_EN); in pwrap_mt8183_init_soc_specific()
1653 pwrap_writel(wrp, 1, PWRAP_WACS_MD32_EN); in pwrap_mt8183_init_soc_specific()
1654 pwrap_writel(wrp, 1, PWRAP_INIT_DONE_P2P); in pwrap_mt8183_init_soc_specific()
1655 pwrap_writel(wrp, 1, PWRAP_INIT_DONE_MD32); in pwrap_mt8183_init_soc_specific()
1660 static int pwrap_init(struct pmic_wrapper *wrp) in pwrap_init() argument
1664 if (wrp->rstc) in pwrap_init()
1665 reset_control_reset(wrp->rstc); in pwrap_init()
1666 if (wrp->rstc_bridge) in pwrap_init()
1667 reset_control_reset(wrp->rstc_bridge); in pwrap_init()
1669 if (wrp->master->type == PWRAP_MT8173) { in pwrap_init()
1671 pwrap_writel(wrp, 3, PWRAP_DCM_EN); in pwrap_init()
1672 pwrap_writel(wrp, 0, PWRAP_DCM_DBC_PRD); in pwrap_init()
1675 if (HAS_CAP(wrp->slave->caps, PWRAP_SLV_CAP_SPI)) { in pwrap_init()
1677 ret = pwrap_reset_spislave(wrp); in pwrap_init()
1682 pwrap_writel(wrp, 1, PWRAP_WRAP_EN); in pwrap_init()
1684 pwrap_writel(wrp, wrp->master->arb_en_all, PWRAP_HIPRIO_ARB_EN); in pwrap_init()
1686 pwrap_writel(wrp, 1, PWRAP_WACS2_EN); in pwrap_init()
1688 ret = wrp->master->init_reg_clock(wrp); in pwrap_init()
1692 if (HAS_CAP(wrp->slave->caps, PWRAP_SLV_CAP_SPI)) { in pwrap_init()
1694 ret = pwrap_init_sidly(wrp); in pwrap_init()
1699 if (HAS_CAP(wrp->slave->caps, PWRAP_SLV_CAP_DUALIO)) { in pwrap_init()
1701 ret = pwrap_init_dual_io(wrp); in pwrap_init()
1706 if (HAS_CAP(wrp->slave->caps, PWRAP_SLV_CAP_SECURITY)) { in pwrap_init()
1708 ret = pwrap_init_security(wrp); in pwrap_init()
1713 if (wrp->master->type == PWRAP_MT8135) in pwrap_init()
1714 pwrap_writel(wrp, 0x7, PWRAP_RRARB_EN); in pwrap_init()
1716 pwrap_writel(wrp, 0x1, PWRAP_WACS0_EN); in pwrap_init()
1717 pwrap_writel(wrp, 0x1, PWRAP_WACS1_EN); in pwrap_init()
1718 pwrap_writel(wrp, 0x1, PWRAP_WACS2_EN); in pwrap_init()
1719 pwrap_writel(wrp, 0x5, PWRAP_STAUPD_PRD); in pwrap_init()
1720 pwrap_writel(wrp, 0xff, PWRAP_STAUPD_GRPEN); in pwrap_init()
1722 if (wrp->master->init_soc_specific) { in pwrap_init()
1723 ret = wrp->master->init_soc_specific(wrp); in pwrap_init()
1729 pwrap_writel(wrp, 1, PWRAP_INIT_DONE2); in pwrap_init()
1730 pwrap_writel(wrp, 1, PWRAP_INIT_DONE0); in pwrap_init()
1731 pwrap_writel(wrp, 1, PWRAP_INIT_DONE1); in pwrap_init()
1733 if (HAS_CAP(wrp->master->caps, PWRAP_CAP_BRIDGE)) { in pwrap_init()
1734 writel(1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_INIT_DONE3); in pwrap_init()
1735 writel(1, wrp->bridge_base + PWRAP_MT8135_BRIDGE_INIT_DONE4); in pwrap_init()
1744 struct pmic_wrapper *wrp = dev_id; in pwrap_interrupt() local
1746 rdata = pwrap_readl(wrp, PWRAP_INT_FLG); in pwrap_interrupt()
1747 dev_err(wrp->dev, "unexpected interrupt int=0x%x\n", rdata); in pwrap_interrupt()
1748 pwrap_writel(wrp, 0xffffffff, PWRAP_INT_CLR); in pwrap_interrupt()
1750 if (HAS_CAP(wrp->master->caps, PWRAP_CAP_INT1_EN)) { in pwrap_interrupt()
1751 rdata = pwrap_readl(wrp, PWRAP_INT1_FLG); in pwrap_interrupt()
1752 dev_err(wrp->dev, "unexpected interrupt int1=0x%x\n", rdata); in pwrap_interrupt()
1753 pwrap_writel(wrp, 0xffffffff, PWRAP_INT1_CLR); in pwrap_interrupt()
2025 struct pmic_wrapper *wrp; in pwrap_probe() local
2038 wrp = devm_kzalloc(&pdev->dev, sizeof(*wrp), GFP_KERNEL); in pwrap_probe()
2039 if (!wrp) in pwrap_probe()
2042 platform_set_drvdata(pdev, wrp); in pwrap_probe()
2044 wrp->master = of_device_get_match_data(&pdev->dev); in pwrap_probe()
2045 wrp->slave = of_slave_id->data; in pwrap_probe()
2046 wrp->dev = &pdev->dev; in pwrap_probe()
2049 wrp->base = devm_ioremap_resource(wrp->dev, res); in pwrap_probe()
2050 if (IS_ERR(wrp->base)) in pwrap_probe()
2051 return PTR_ERR(wrp->base); in pwrap_probe()
2053 if (HAS_CAP(wrp->master->caps, PWRAP_CAP_RESET)) { in pwrap_probe()
2054 wrp->rstc = devm_reset_control_get(wrp->dev, "pwrap"); in pwrap_probe()
2055 if (IS_ERR(wrp->rstc)) { in pwrap_probe()
2056 ret = PTR_ERR(wrp->rstc); in pwrap_probe()
2057 dev_dbg(wrp->dev, "cannot get pwrap reset: %d\n", ret); in pwrap_probe()
2062 if (HAS_CAP(wrp->master->caps, PWRAP_CAP_BRIDGE)) { in pwrap_probe()
2065 wrp->bridge_base = devm_ioremap_resource(wrp->dev, res); in pwrap_probe()
2066 if (IS_ERR(wrp->bridge_base)) in pwrap_probe()
2067 return PTR_ERR(wrp->bridge_base); in pwrap_probe()
2069 wrp->rstc_bridge = devm_reset_control_get(wrp->dev, in pwrap_probe()
2071 if (IS_ERR(wrp->rstc_bridge)) { in pwrap_probe()
2072 ret = PTR_ERR(wrp->rstc_bridge); in pwrap_probe()
2073 dev_dbg(wrp->dev, in pwrap_probe()
2079 wrp->clk_spi = devm_clk_get(wrp->dev, "spi"); in pwrap_probe()
2080 if (IS_ERR(wrp->clk_spi)) { in pwrap_probe()
2081 dev_dbg(wrp->dev, "failed to get clock: %ld\n", in pwrap_probe()
2082 PTR_ERR(wrp->clk_spi)); in pwrap_probe()
2083 return PTR_ERR(wrp->clk_spi); in pwrap_probe()
2086 wrp->clk_wrap = devm_clk_get(wrp->dev, "wrap"); in pwrap_probe()
2087 if (IS_ERR(wrp->clk_wrap)) { in pwrap_probe()
2088 dev_dbg(wrp->dev, "failed to get clock: %ld\n", in pwrap_probe()
2089 PTR_ERR(wrp->clk_wrap)); in pwrap_probe()
2090 return PTR_ERR(wrp->clk_wrap); in pwrap_probe()
2093 ret = clk_prepare_enable(wrp->clk_spi); in pwrap_probe()
2097 ret = clk_prepare_enable(wrp->clk_wrap); in pwrap_probe()
2102 if (HAS_CAP(wrp->master->caps, PWRAP_CAP_DCM)) { in pwrap_probe()
2103 pwrap_writel(wrp, 1, PWRAP_DCM_EN); in pwrap_probe()
2104 pwrap_writel(wrp, 0, PWRAP_DCM_DBC_PRD); in pwrap_probe()
2111 if (!pwrap_readl(wrp, PWRAP_INIT_DONE2)) { in pwrap_probe()
2112 ret = pwrap_init(wrp); in pwrap_probe()
2114 dev_dbg(wrp->dev, "init failed with %d\n", ret); in pwrap_probe()
2119 if (!(pwrap_readl(wrp, PWRAP_WACS2_RDATA) & PWRAP_STATE_INIT_DONE0)) { in pwrap_probe()
2120 dev_dbg(wrp->dev, "initialization isn't finished\n"); in pwrap_probe()
2126 pwrap_writel(wrp, 0xf, PWRAP_WDT_UNIT); in pwrap_probe()
2131 pwrap_writel(wrp, wrp->master->wdt_src, PWRAP_WDT_SRC_EN); in pwrap_probe()
2132 if (HAS_CAP(wrp->master->caps, PWRAP_CAP_WDT_SRC1)) in pwrap_probe()
2133 pwrap_writel(wrp, wrp->master->wdt_src, PWRAP_WDT_SRC_EN_1); in pwrap_probe()
2135 pwrap_writel(wrp, 0x1, PWRAP_TIMER_EN); in pwrap_probe()
2136 pwrap_writel(wrp, wrp->master->int_en_all, PWRAP_INT_EN); in pwrap_probe()
2141 if (HAS_CAP(wrp->master->caps, PWRAP_CAP_INT1_EN)) in pwrap_probe()
2142 pwrap_writel(wrp, wrp->master->int1_en_all, PWRAP_INT1_EN); in pwrap_probe()
2145 ret = devm_request_irq(wrp->dev, irq, pwrap_interrupt, in pwrap_probe()
2147 "mt-pmic-pwrap", wrp); in pwrap_probe()
2151 wrp->regmap = devm_regmap_init(wrp->dev, NULL, wrp, wrp->slave->regmap); in pwrap_probe()
2152 if (IS_ERR(wrp->regmap)) { in pwrap_probe()
2153 ret = PTR_ERR(wrp->regmap); in pwrap_probe()
2157 ret = of_platform_populate(np, NULL, NULL, wrp->dev); in pwrap_probe()
2159 dev_dbg(wrp->dev, "failed to create child devices at %pOF\n", in pwrap_probe()
2167 clk_disable_unprepare(wrp->clk_wrap); in pwrap_probe()
2169 clk_disable_unprepare(wrp->clk_spi); in pwrap_probe()