/* Change Logs: Date Author Notes  weety first version  */
void psc_change_state(int id, int state)
/* Change Logs: Date Author Notes  weety first version  */
void psc_change_state(int id, int state)
{
    rt_uint32_t mdstat, mdctl;
    if (id > DAVINCI_DM365_LPSC_KALEIDO)
        return;
    mdstat = PSC_MDSTAT_BASE + (id * 4);
    mdctl = PSC_MDCTL_BASE + (id * 4);
    if ((readl(mdstat) & 0x1f) == state)
        return;
    while (readl(PSC_PTSTAT) & 1) ;
    writel(readl(mdctl) & (~0x1f), mdctl);
    writel(readl(mdctl) | state, mdctl);
    writel(readl(PSC_PTCMD) | 1, PSC_PTCMD);
    while (readl(PSC_PTSTAT) & 1) ;
}