/* Set flash controller owner:I/D AHB or system AHB.  */
__WEAK void ATTR_TCM_SECTION bflb_sf_ctrl_set_owner(uint8_t owner)
/* Set flash controller owner:I/D AHB or system AHB.  */
__WEAK void ATTR_TCM_SECTION bflb_sf_ctrl_set_owner(uint8_t owner)
{
    uint32_t reg_base = 0;
    uint32_t regval = 0;
    uint32_t time_out = 0;
    reg_base = BFLB_SF_CTRL_BASE;
    time_out = SF_CTRL_BUSY_STATE_TIMEOUT;
    while (bflb_sf_ctrl_get_busy_state()) {
        time_out--;
        if (time_out == 0) {
            return;
        }
    }
    regval = getreg32(reg_base + SF_CTRL_1_OFFSET);
    if (owner) {
        regval |= SF_CTRL_SF_IF_FN_SEL;
    } else {
        regval &= ~SF_CTRL_SF_IF_FN_SEL;
    }
    if (owner == SF_CTRL_OWNER_IAHB) {
        regval |= SF_CTRL_SF_AHB2SIF_EN;
    } else {
        regval &= ~SF_CTRL_SF_AHB2SIF_EN;
    }
    putreg32(regval, reg_base+SF_CTRL_1_OFFSET);
}