Esempio n. 1
0
/**
 * Prototype    : ps_tty_close
 * Description  : called by tty uart when close tty uart from octty
 * input        : tty -> have opened tty
 * output       : not
 * Calls        :
 * Called By    :
 *
 *   History        :
 *   1.Date         : 2012/11/05
 *     Author       : wx144390
 *     Modification : Created function
 *
 */
STATIC void ps_tty_close(struct tty_struct *tty)
{
    struct  ps_core_s *ps_core_d = NULL;

    PS_PRINT_INFO("%s: entered!!!\n", __func__);

    if ((NULL == tty)||(NULL == tty->disc_data))
    {
        PS_PRINT_ERR("tty or tty->disc_data is NULL\n");
        return;
    }
    ps_core_d = tty->disc_data;

    /* Flush any pending characters in the driver and discipline. */
    tty_ldisc_flush(tty);
    tty_driver_flush_buffer(tty);
    ps_core_d->tty = NULL;

    /* signal to complate that N_HW_BFG ldisc is un-installed */
    ps_tty_complete(ps_core_d->pm_data, TTY_LDISC_UNINSTALL);

    PS_PRINT_INFO("uninstall complete done!\n");

    ps_kfree_skb(ps_core_d, TX_HIGH_QUEUE);
    ps_kfree_skb(ps_core_d, TX_LOW_QUEUE);

    PS_PRINT_INFO("free tx sbk buf done!\n");
}
Esempio n. 2
0
STATIC ssize_t store_exception_dbg(struct device *dev, struct kobj_attribute *attr, const char *buf, size_t count)
{
    int32  cmd = 0;
    int32  ret = 0;
    struct ps_core_s *ps_core_d = NULL;
    struct st_exception_info *pst_exception_data = NULL;

    if (NULL == buf)
    {
        PS_PRINT_ERR("buf is NULL\n");
        return -FAILURE;
    }

    get_exception_info_reference(&pst_exception_data);
    if (NULL == pst_exception_data)
    {
        PS_PRINT_ERR("get exception info reference is error\n");
        return 0;
    }

    ps_get_core_reference(&ps_core_d);
    if (NULL == ps_core_d)
    {
        PS_PRINT_ERR("ps_core_d is NULL\n");
        return 0;
    }

    cmd = simple_strtol(buf, NULL, 10);
    PS_PRINT_INFO("cmd:%d\n", cmd);

    ret = prepare_to_visit_node(ps_core_d);
    if (ret < 0)
    {
        PS_PRINT_ERR("prepare work FAIL\n");
        return ret;
    }

    switch (cmd)
    {
        case 1:
            PS_PRINT_INFO("exception debug test: close BT\n");
            ps_tx_sys_cmd(ps_core_d, SYS_MSG, SYS_CFG_CLOSE_BT);
            break;

        case 2:
            PS_PRINT_INFO("exception: set debug beat flag to 0\n");
            pst_exception_data->debug_beat_flag = 0;
            break;

        default:
            PS_PRINT_ERR("unknown cmd %d\n", cmd);
            break;
    }

    post_to_visit_node(ps_core_d);

    return count;
}
Esempio n. 3
0
STATIC void ps_uart_state_print(struct ps_uart_state_s *state)
{
    if (unlikely(NULL == state))
    {
        PS_PRINT_ERR("state is NULL\n");
        return;
    }
    PS_PRINT_INFO(" tty tx:%x    rx:%x\n", state->tty_tx_cnt, state->tty_rx_cnt);
    PS_PRINT_INFO("uart tx:%x    rx:%x\n", state->uart_cnt.tx, state->uart_cnt.rx);
    PS_PRINT_INFO("uart frame:%x,overrun:%x,parity:%x,brk:%x\n", \
                  state->uart_cnt.frame, state->uart_cnt.overrun, state->uart_cnt.parity, state->uart_cnt.brk);
    return;
}
Esempio n. 4
0
/**
 * Prototype    : ps_change_uart_baud_rate
 * Description  : change arm platform uart baud rate to secend
 *                baud rate for high baud rate when download patch
 * input        : ps_core_d
 * output       : no
 * Calls        :
 * Called By    :
 *
 *   History        :
 *   1.Date         : 2012/11/05
 *     Author       : wx144390
 *     Modification : Created function
 *
 */
int32 ps_change_uart_baud_rate(int64 baud_rate, uint8 enable_flowctl)
{
    struct ps_plat_s *ps_plat_d = NULL;
    struct ps_core_s *ps_core_d;
    uint64 timeleft = 0;

    PS_PRINT_INFO("%s\n", __func__);

    ps_get_plat_reference(&ps_plat_d);
    if (unlikely(NULL == ps_plat_d))
    {
        PS_PRINT_ERR("ps_plat_d is NULL\n");
        return -EINVAL;
    }

    ps_core_d = ps_plat_d->core_data;
    if (likely(NULL != ps_core_d->tty))
    {
        tty_ldisc_flush(ps_core_d->tty);
        tty_driver_flush_buffer(ps_core_d->tty);
    }

    if (!IS_ERR_OR_NULL(ps_core_d->tty))
    {
        if (tty_chars_in_buffer(ps_core_d->tty))
        {
            PS_PRINT_INFO("uart tx buf is not empty\n");
        }
    }

    INIT_COMPLETION(ps_plat_d->ldisc_reconfiged);
    ps_plat_d->flow_cntrl    = enable_flowctl;
    ps_plat_d->baud_rate     = baud_rate;
    ps_plat_d->ldisc_install = TTY_LDISC_RECONFIG;

    PS_PRINT_INFO("ldisc_install = %d\n", TTY_LDISC_RECONFIG);
    sysfs_notify(g_sysfs_hi110x_bfgx, NULL, "install");

    timeleft = wait_for_completion_timeout(&ps_plat_d->ldisc_reconfiged, msecs_to_jiffies(HISI_LDISC_TIME));
    if (!timeleft)
    {
        PS_PRINT_ERR("hisi bfgx ldisc reconfig timeout\n");
        CHR_EXCEPTION(CHR_GNSS_DRV(CHR_GNSS_DRV_EVENT_PLAT, CHR_PLAT_DRV_ERROR_CFG_UART));

        return -EINVAL;
    }

    PS_PRINT_SUC("hisi bfgx ldisc reconfig succ\n");

    return 0;
}
Esempio n. 5
0
void host_allow_bfg_sleep(struct ps_core_s *ps_core_d)
{
    struct pm_drv_data *pm_data = pm_get_drvdata();
    if (NULL == pm_data)
    {
        PS_PRINT_ERR("pm_data is NULL!\n");
        return;
    }

    PS_PRINT_INFO("%s\n", __func__);

    if (false == ps_core_d->tty_have_open)
    {
        PS_PRINT_INFO("tty has closed, not send msg to dev\n");
        return;
    }

    spin_lock(&pm_data->node_timer_spinlock);

    /* if someone is visiting the dev_node */
    if (atomic_read(&ps_core_d->node_visit_flag) > 0 )
    {
        PS_PRINT_INFO("someone visit node, not send allow sleep msg\n");
        spin_unlock(&pm_data->node_timer_spinlock);
        /* gnss write do NOT mod timer */
        mod_timer(&pm_data->bfg_timer, jiffies + BT_SLEEP_TIME * HZ);
        return;
    }

    /* 设置device状态为睡眠态,在host唤醒dev完成之前(或dev唤醒host前)uart不可用 */
    ps_core_d->ps_pm->bfgx_uart_state_set(UART_NOT_READY);
    ps_core_d->ps_pm->bfgx_dev_state_set(BFGX_SLEEP);

    spin_unlock(&pm_data->node_timer_spinlock);

    mod_timer(&pm_data->dev_ack_timer, jiffies + (WAIT_DEVACK_MSEC * HZ / 1000));

    /* we need reinit completion cnt as 0, to prevent such case:
     * 1)host allow dev sleep, dev ack with OK, cnt=1,
     * 2)device wkup host,
     * 3)host allow dev sleep,
     * 4)host wkup dev, it will wait dev_ack succ immediately since cnt==1,
     * 5)dev ack with ok, cnt=2,
     * this case will cause host wait dev_ack invalid.
     */
    INIT_COMPLETION(pm_data->dev_ack_comp);
    ps_tx_sys_cmd(ps_core_d, SYS_MSG, SYS_CFG_ALLOWDEV_SLP);
}
Esempio n. 6
0
/**
 * Prototype    : bfg_timer_expire
 * Description  : bfg timer expired function
 * input        : uint64
 * output       : no
 * Calls        :
 * Called By    :
 *
 *   History        :
 *   1.Date         : 2013/05/09
 *     Author       : wx145522
 *     Modification : Created function
 *
 */
void bfg_timer_expire(uint64 data)
{
    struct ps_core_s *ps_core_d = NULL;
    struct pm_drv_data  *pm_data = (struct pm_drv_data*)data;
    if (unlikely(NULL == pm_data))
    {
        PS_PRINT_ERR("pm_data is null\n");
        return;
    }

    ps_core_d = pm_data->ps_pm_interface->ps_core_data;

    PS_PRINT_INFO("%s\n", __func__);

    if (BFGX_PM_DISABLE == pm_data->bfgx_lowpower_enable)
    {
        PS_PRINT_DBG("lowpower function disabled\n");
        return;
    }
    if (BFGX_SLEEP == pm_data->ps_pm_interface->bfgx_dev_state_get())
    {
        PS_PRINT_DBG("dev has been sleep\n");
        return;
    }

    if (GNSS_AGREE_SLEEP == atomic_read(&pm_data->gnss_sleep_flag))
    {
        host_allow_bfg_sleep(ps_core_d);
    }
    else
    {
        mod_timer(&pm_data->bfg_timer, jiffies + BT_SLEEP_TIME * HZ);
    }

}
Esempio n. 7
0
/**
 * Prototype    : ps_tty_open
 * Description  : called by tty uart itself when open tty uart from octty
 * input        : tty -> have opened tty
 * output       : not
 * Calls        :
 * Called By    :
 *
 *   History        :
 *   1.Date         : 2012/11/05
 *     Author       : wx144390
 *     Modification : Created function
 *
 */
STATIC int32 ps_tty_open(struct tty_struct *tty)
{
    uint8  install;
    struct ps_core_s *ps_core_d = NULL;
    struct ps_plat_s *ps_plat_d = NULL;

    PS_PRINT_INFO("%s enter\n", __func__);

    ps_get_core_reference(&ps_core_d);
    if (unlikely(NULL == ps_core_d))
    {
        PS_PRINT_ERR("ps_core_d is NULL\n");
        return -EINVAL;
    }

    ps_core_d->tty = tty;
    tty->disc_data = ps_core_d;

    /* don't do an wakeup for now */
    clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);

    /* set mem already allocated */
    tty->receive_room = PUBLIC_BUF_MAX;
    /* Flush any pending characters in the driver and discipline. */
    tty_ldisc_flush(tty);
    tty_driver_flush_buffer(tty);

    ps_plat_d = (struct ps_plat_s *)ps_core_d->pm_data;
    install   = ps_plat_d->ldisc_install;
    if (TTY_LDISC_INSTALL == install)
    {
        ps_tty_complete(ps_core_d->pm_data, TTY_LDISC_INSTALL);
        PS_PRINT_INFO("install complete done!\n");
    }
    else if (TTY_LDISC_RECONFIG == install)
    {
        ps_tty_complete(ps_core_d->pm_data, TTY_LDISC_RECONFIG);
        PS_PRINT_INFO("reconfig complete done!\n");
    }
    else
    {
        PS_PRINT_ERR("ldisc_install [%d] is error!\n", install);
    }

    return 0;
}
Esempio n. 8
0
/**
 * Prototype    : ps_tty_flush_buffer
 * Description  : called by tty uart when flush buffer
 * input        : tty   -> have opened tty
 * output       : not
 * Calls        :
 * Called By    :
 *
 *   History        :
 *   1.Date         : 2012/11/05
 *     Author       : wx144390
 *     Modification : Created function
 *
 */
STATIC void ps_tty_flush_buffer(struct tty_struct *tty)
{
    PS_PRINT_INFO("time to %s\n", __func__);

    reset_uart_rx_buf();

    return;
}
Esempio n. 9
0
STATIC void ps_uart_state_print(struct ps_uart_state_s *state)
{
    if (unlikely(NULL == state))
    {
        PS_PRINT_ERR("state is NULL\n");
        return;
    }

    PS_PRINT_INFO(" tty tx:%x    rx:%x\n", state->tty_tx_cnt, state->tty_rx_cnt);
    PS_PRINT_INFO("uart tx:%x    rx:%x\n", state->uart_cnt.tx, state->uart_cnt.rx);
    PS_PRINT_INFO("stopped:%x  hw_stopped:%x\n", state->tty_stopped, state->tty_hw_stopped);
    PS_PRINT_INFO("uart cts:%x,dsr:%x,rng:%x,dcd:%x,frame:%x,overrun:%x,parity:%x,brk:%x,buf_overrun:%x\n", \
                  state->uart_cnt.cts, state->uart_cnt.dsr, state->uart_cnt.rng, state->uart_cnt.dcd, \
                  state->uart_cnt.frame, state->uart_cnt.overrun, state->uart_cnt.parity, state->uart_cnt.brk, state->uart_cnt.buf_overrun);
    CHR_EXCEPTION(CHR_WIFI_DEV(CHR_WIFI_DEV_EVENT_CHIP, CHR_WIFI_DEV_ERROR_UART));

    return;
}
Esempio n. 10
0
void ps_uart_state_dump(struct tty_struct *tty)
{
    struct ps_core_s *ps_core_d = NULL;
    ps_get_core_reference(&ps_core_d);
    if (unlikely((NULL == ps_core_d) || (NULL == tty)))
    {
        PS_PRINT_ERR("ps_core_d ot tty is NULL\n");
        return;
    }

    PS_PRINT_INFO("===pre uart&tty state===\n");
    ps_uart_state_print(&g_uart_state_pre);
    PS_PRINT_INFO("===cur uart&tty state===\n");
    ps_uart_state_get(tty);
    ps_uart_state_print(&g_uart_state);
    PS_PRINT_INFO("chars in tty tx buf len=%x\n", tty_chars_in_buffer(ps_core_d->tty));

    return;
}
Esempio n. 11
0
STATIC ssize_t store_loglevel(struct device *dev, struct kobj_attribute *attr, const char *buf, size_t count)
{
    int32 loglevel = PLAT_LOG_INFO;

    PS_PRINT_INFO("%s\n", __func__);

    if (NULL == buf)
    {
        PS_PRINT_ERR("buf is NULL\n");
        return -FAILURE;
    }

    /*bug on set*/
    if ('b' == *buf)
    {
        g_bug_on_enable = BUG_ON_ENABLE;
        PS_PRINT_INFO("BUG_ON enable sucess, g_bug_on_enable = %d\n", g_bug_on_enable);
        return count;
    }
    else if ('B' == *buf)
    {
        g_bug_on_enable = BUG_ON_DISABLE;
        PS_PRINT_INFO("BUG_ON disable sucess, g_bug_on_enable = %d\n", g_bug_on_enable);
        return count;
    }

    loglevel = simple_strtol(buf, NULL, 10);
    if(PLAT_LOG_ALERT > loglevel)
    {
        g_plat_loglevel = PLAT_LOG_ALERT;
    }
    else if(PLAT_LOG_DEBUG < loglevel)
    {
        g_plat_loglevel = PLAT_LOG_DEBUG;
    }
    else
    {
        g_plat_loglevel = loglevel;
    }

    return count;
}
Esempio n. 12
0
STATIC ssize_t show_loglevel(struct device *dev, struct kobj_attribute *attr, int8 *buf)
{
    PS_PRINT_INFO("%s\n", __func__);

    if (NULL == buf)
    {
        PS_PRINT_ERR("buf is NULL\n");
        return -FAILURE;
    }

    return snprintf(buf, SNPRINT_LIMIT_TO_KERNEL, "curr loglevel=%d, curr bug_on=%d\nalert:0\nerr:1\nwarning:2\nfunc|succ|info:3\ndebug:4\nbug_on enable:b\nbug_on disable:B\n", g_plat_loglevel, g_bug_on_enable);
}
Esempio n. 13
0
STATIC ssize_t show_uart_rx_dump(struct device *dev, struct kobj_attribute *attr, int8 *buf)
{
    PS_PRINT_INFO("%s\n", __func__);

    if (NULL == buf)
    {
        PS_PRINT_ERR("buf is NULL\n");
        return -FAILURE;
    }

    return snprintf(buf, SNPRINT_LIMIT_TO_KERNEL, "curr uart dump status =%d\n no:0\n yes:1\n", g_uart_rx_dump);
}
Esempio n. 14
0
STATIC ssize_t store_uart_rx_dump(struct device *dev, struct kobj_attribute *attr, const char *buf, size_t count)
{
    if (NULL == buf)
    {
        PS_PRINT_ERR("buf is NULL\n");
        return -FAILURE;
    }

    g_uart_rx_dump = simple_strtol(buf, NULL, 10);
    PS_PRINT_INFO("g_uart_rx_dump aft %d\n", g_uart_rx_dump);
    return count;
}
Esempio n. 15
0
STATIC ssize_t show_dev_test(struct device *dev, struct kobj_attribute *attr, int8 *buf)
{
    PS_PRINT_INFO("%s\n", __func__);

    if (NULL == buf)
    {
        PS_PRINT_ERR("buf is NULL\n");
        return -FAILURE;
    }

    return snprintf(buf, SNPRINT_LIMIT_TO_KERNEL, "cmd  func\n  1  cause bfgx into panic\n  2  enable exception recovery\n  3  enable wifi open bcpu\n"
                                   "  4  pull up power gpio   \n  5  pull down power gpio     \n  6  uart loop test       \n");
}
Esempio n. 16
0
/**
 * Prototype    : open_tty_drv
 * Description  : called from PS Core when BT protocol stack drivers
 *                  registration,or FM/GNSS hal stack open FM/GNSS inode
 * input        : ps_plat_d
 * output       : return 0--> open tty uart is ok
 *                return !0-> open tty uart is false
 * Calls        :
 * Called By    :
 *
 *   History        :
 *   1.Date         : 2012/11/05
 *     Author       : wx144390
 *     Modification : Created function
 *
 */
int32 open_tty_drv(void *pm_data)
{
    struct ps_plat_s *ps_plat_d = NULL;
    struct ps_core_s *ps_core_d;
    uint8  retry = OPEN_TTY_RETRY_COUNT;
    uint64 timeleft = 0;

    PS_PRINT_DBG("%s\n", __func__);

    if (unlikely(NULL == pm_data))
    {
        PS_PRINT_ERR("pm_data is NULL\n");
        return -EINVAL;
    }

    ps_plat_d = (struct ps_plat_s *)pm_data;
    ps_core_d = ps_plat_d->core_data;
    if (true == ps_core_d->tty_have_open)
    {
        PS_PRINT_DBG("hisi bfgx line discipline have installed\n");
        return 0;
    }

    reset_uart_rx_buf();

    do {
        INIT_COMPLETION(ps_plat_d->ldisc_installed);
        ps_plat_d->ldisc_install = TTY_LDISC_INSTALL;

        PS_PRINT_INFO("ldisc_install = %d\n", TTY_LDISC_INSTALL);
        sysfs_notify(g_sysfs_hi110x_bfgx, NULL, "install");
        ps_uart_state_pre(ps_core_d->tty);
        timeleft = wait_for_completion_timeout(&ps_plat_d->ldisc_installed, msecs_to_jiffies(HISI_LDISC_TIME));
        if (!timeleft)
        {
            ps_uart_state_dump(ps_core_d->tty);
            PS_PRINT_ERR("hisi bfgx ldisc installation timeout\n");
            PS_BUG_ON(1);
            continue;
        }
        else
        {
            PS_PRINT_SUC("hisi bfgx line discipline install succ\n");
            ps_core_d->tty_have_open = true;
            return 0;
        }

    } while (retry--);

    return -EPERM;
}
/*****************************************************************************
 * Prototype    : get_board_info
 * Description  : get board cfg info
 * Input        : BOARD_INFO_STRU *
 * Output       : no
 * Return       : 0 means succeed, -1 means failed
 * Calls        :
 * Called By    :
 *
 *   History        :
 *   1.Date         : 2014-12-01
 *     Author       : jwx222439
 *     Modification : Created function

*****************************************************************************/
int32 get_board_info(BOARD_INFO_STRU *pboard_info)
{
    int32 l_ret = -BOADR_EFAIL;
    const int8 *rw_sdio_name;
    const int8 *ini_file_name;
    struct device_node *np;

    np = of_find_compatible_node(NULL, NULL, DTS_COMP_HI1101_RW_NAME);
    if (NULL == np)
    {
        PS_PRINT_INFO("Unable to find %s\n",DTS_COMP_HI1101_RW_NAME);
        goto L1;
    }

    if (of_property_read_string(np, "wifi_sdio_rw", &rw_sdio_name))
    {
        PS_PRINT_INFO("%s node doesn't have wifi_sdio_rw property!\n", np->name);
        goto L1;
    }

    PS_PRINT_INFO("read from dts sdio name{%s}\n", rw_sdio_name);
    snprintf(pboard_info->rw_file_name, SDIO_RW_NAME_LEN, "%s%s", RW_SDIO_PATH, rw_sdio_name);

    if (of_property_read_string(np, "hisi_cfg_ini_file", &ini_file_name))
    {
        PS_PRINT_INFO("%s node doesn't have hisi_cfg_ini_file property!\n", np->name);
		pboard_info->ini_file_name[0] = '\0';
        goto L1;
    }

    PS_PRINT_INFO("read from dts ini file name{%s}\n", ini_file_name);
    snprintf(pboard_info->ini_file_name, INI_NAME_LEN, "%s", ini_file_name);

    l_ret = BOARD_SUCC;
L1:

    return l_ret;
}
Esempio n. 18
0
STATIC ssize_t show_exception_dbg(struct device *dev, struct kobj_attribute *attr, int8 *buf)
{
    PS_PRINT_INFO("%s\n", __func__);

    if (NULL == buf)
    {
        PS_PRINT_ERR("buf is NULL\n");
        return -FAILURE;
    }

    return snprintf(buf, SNPRINT_LIMIT_TO_KERNEL, "cmd  func             \n"
                        " 1  close bt          \n"
                        " 2  set beat flat to 0\n");
}
Esempio n. 19
0
/**
 * Prototype    : ps_tty_receive
 * Description  : called by tty uart when recive data from tty uart
 * input        : tty   -> have opened tty
 *                data -> recive data ptr
 *                count-> recive data count
 * output       : not
 * Calls        :
 * Called By    :
 *
 *   History        :
 *   1.Date         : 2012/11/05
 *     Author       : wx144390
 *     Modification : Created function
 *
 */
STATIC void ps_tty_receive(struct tty_struct *tty, const uint8 *data,
               int8 *tty_flags, int32 count)
{
#ifdef PLATFORM_DEBUG_ENABLE
    struct timeval tv;
    struct rtc_time tm;
    uint64  tmp;
    char filename[60] = {0};
#endif
    struct  ps_core_s *ps_core_d = NULL;

    PS_PRINT_FUNCTION_NAME;

    if (unlikely((NULL == tty)||(NULL == tty->disc_data)||(NULL == tty_recv)))
    {
        PS_PRINT_ERR("tty or tty->disc_data or tty_recv is NULL\n");
        return;
    }
    ps_core_d = tty->disc_data;
    spin_lock(&ps_core_d->rx_lock);
#ifdef PLATFORM_DEBUG_ENABLE
    if(g_uart_rx_dump)
    {
        ps_core_d->curr_time = jiffies;
        tmp = ps_core_d->curr_time - ps_core_d->pre_time;
        if ((tmp > DBG_FILE_TIME * HZ)||(0 == ps_core_d->pre_time))
        {
            if (NULL != ps_core_d->rx_data_fp)
            {
                filp_close(ps_core_d->rx_data_fp, NULL);
            }
            do_gettimeofday(&tv);
            rtc_time_to_tm(tv.tv_sec, &tm);
            snprintf(filename, sizeof(filename) - 1, "/data/hwlogdir/uart_rx/uart_rx-%04d-%02d-%02d:%02d-%02d-%02d",
                    tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
            PS_PRINT_INFO("filename = %s",filename);

            ps_core_d->rx_data_fp = filp_open(filename, O_RDWR | O_CREAT, 0777);
            ps_core_d->pre_time = ps_core_d->curr_time;
        }
    }
#endif

	PS_PRINT_DBG("RX:data[0] = %x, data[1] = %x, data[2] = %x, data[3] = %x, data[4] = %x, data[count-1] = %x\n",
			  data[0],data[1],data[2],data[3],data[4],data[count-1]);
    ps_uart_tty_rx_add(count);
    tty_recv(tty->disc_data, data, count);

    spin_unlock(&ps_core_d->rx_lock);
}
Esempio n. 20
0
/*****************************************************************************
 函 数 名  : show_bfgx_dump
 功能描述  : 显示SDIO上报BFGX的reg
 输入参数  :
 输出参数  :
 返 回 值  : void
 调用函数  :
 被调函数  :

 修改历史      :
  1.日    期   : 2015年12月2日
    作    者   : c00351912
    修改内容   : 新生成函数

*****************************************************************************/
STATIC ssize_t show_bfgx_dump(struct device *dev, struct kobj_attribute *attr, int8 *buf)
{
    PS_PRINT_INFO("%s\n", __func__);

    if (NULL == buf)
    {
        PS_PRINT_ERR("buf is NULL\n");
        return -FAILURE;
    }

    return snprintf(buf,SNPRINT_LIMIT_TO_KERNEL, "cmd           func            \n"
                        " 1    sdio read bcpu pub reg  \n"
                        " 2    sdio read bcpu priv reg \n"
                        " 3    sdio read bcpu mem      \n"
                        " 4    equal cmd 1+2+3         \n");
}
Esempio n. 21
0
STATIC ssize_t show_wifi_mem_dump(struct device *dev, struct kobj_attribute *attr, int8 *buf)
{
    PS_PRINT_INFO("%s\n", __func__);

    if (NULL == buf)
    {
        PS_PRINT_ERR("buf is NULL\n");
        return -FAILURE;
    }

    return snprintf(buf, SNPRINT_LIMIT_TO_KERNEL, "cmd         func             \n"
                        " 1    uart halt wcpu         \n"
                        " 2    uart read wifi pub reg \n"
                        " 3    uart read wifi priv reg\n"
                        " 4    uart read wifi mem     \n"
                        " 5    equal cmd 1+2+3+4      \n");
}
Esempio n. 22
0
STATIC ssize_t show_bfgx_pmdbg(struct device *dev, struct kobj_attribute *attr, int8 *buf)
{
    PS_PRINT_INFO("%s\n", __func__);

    if (NULL == buf)
    {
        PS_PRINT_ERR("buf is NULL\n");
        return -FAILURE;
    }

    return snprintf(buf, SNPRINT_LIMIT_TO_KERNEL, "cmd       func     \n"
                        "  1  plat pm enable\n  2  plat pm disable\n"
                        "  3   bt  pm enable\n  4   bt  pm disable\n"
                        "  5  gnss pm enable\n  6  gnss pm disable\n"
                        "  7   nfc pm enable\n  8   nfc pm disable\n"
                        "  9  pm ctrl enable\n  10 pm ctrl disable\n");
}
Esempio n. 23
0
STATIC ssize_t show_ir_mode(struct device *dev, struct kobj_attribute *attr, int8 *buf)
{
    struct pm_drv_data *pm_data = pm_get_drvdata();
    if (NULL == pm_data)
    {
        PS_PRINT_ERR("pm_data is NULL!\n");
        return -FAILURE;
    }

    if (!g_board_info.have_ir) {
        PS_PRINT_ERR("board have no ir module");
        return -FAILURE;
    }

    PS_PRINT_INFO("%s\n", __func__);

    if (NULL == buf)
    {
        PS_PRINT_ERR("buf is NULL\n");
        return -FAILURE;
    }

    if (!isAsic())
    {
        PS_PRINT_ERR("HI1102 FPGA VERSION, ir contral gpio not exist\n");
        return -FAILURE;
    }

    if (IR_GPIO_CTRL == g_board_info.irled_power_type)
    {
        return snprintf(buf, SNPRINT_LIMIT_TO_KERNEL, "%d\n", gpio_get_value(pm_data->board->bfgn_ir_ctrl_gpio));
    }
    else if (IR_LDO_CTRL == g_board_info.irled_power_type)
    {
        return snprintf(buf, SNPRINT_LIMIT_TO_KERNEL, "%d\n",(regulator_is_enabled(pm_data->board->bfgn_ir_ctrl_ldo)) > 0 ? 1:0);
    }

    return -FAILURE;
}
Esempio n. 24
0
STATIC ssize_t store_dev_test(struct device *dev, struct kobj_attribute *attr, const char *buf, size_t count)
{
    int32 cmd;
    int32 ret;
    struct ps_core_s *ps_core_d = NULL;
    struct st_exception_info *pst_exception_data = NULL;

    PS_PRINT_INFO("%s\n", __func__);

    if (NULL == buf)
    {
        PS_PRINT_ERR("buf is NULL\n");
        return -FAILURE;
    }

    get_exception_info_reference(&pst_exception_data);
    if (NULL == pst_exception_data)
    {
        PS_PRINT_ERR("get exception info reference is error\n");
        return 0;
    }

    ps_get_core_reference(&ps_core_d);
    if (unlikely(NULL == ps_core_d))
    {
        PS_PRINT_ERR("ps_core_d is NULL\n");
        return -EINVAL;
    }

    cmd = simple_strtol(buf, NULL, 10);
    switch (cmd)
    {
        case 1:
            ret = prepare_to_visit_node(ps_core_d);
            if (ret < 0)
            {
                PS_PRINT_ERR("prepare work FAIL\n");
                return ret;
            }

            PS_PRINT_INFO("bfgx test cmd %d, cause device panic\n", cmd);
            ps_tx_sys_cmd(ps_core_d, SYS_MSG, SYS_CFG_DEV_PANIC);

            post_to_visit_node(ps_core_d);
            break;
        case 2:
            PS_PRINT_INFO("cmd %d,enable platform dfr\n", cmd);
            pst_exception_data->exception_reset_enable = PLAT_EXCEPTION_ENABLE;
            break;
        case 3:
            PS_PRINT_INFO("cmd %d,enable wifi open bcpu\n", cmd);
            wifi_open_bcpu_set(1);
            break;
        case 4:
            PS_PRINT_INFO("cmd %d,test pull up power gpio\n", cmd);
            switch(g_device_subchip_type)
            {
                case BOARD_VERSION_HI1102:
                    board_power_on(WLAN_POWER);
                    break;
                case BOARD_VERSION_HI1103:
                    board_power_on(WLAN_POWER);
                    board_power_on(BFGX_POWER);
                    break;
                default:
                    PS_PRINT_ERR("g_device_subchip_type =%d error\n", g_device_subchip_type);
                    break;
            }
            break;
        case 5:
            PS_PRINT_INFO("cmd %d,test pull down power gpio\n", cmd);
            switch(g_device_subchip_type)
            {
                case BOARD_VERSION_HI1102:
                    board_power_off(WLAN_POWER);
                    break;
                case BOARD_VERSION_HI1103:
                    board_power_off(WLAN_POWER);
                    board_power_off(BFGX_POWER);
                    break;
                default:
                    PS_PRINT_ERR("g_device_subchip_type =%d error\n", g_device_subchip_type);
                    break;
            }
            break;
        case 6:
            PS_PRINT_INFO("cmd %d,start uart loop test\n", cmd);
            uart_loop_test();
            break;

        default:
            PS_PRINT_ERR("unknown cmd %d\n", cmd);
            break;
    }

    return count;
}
Esempio n. 25
0
/**
 * Prototype    : release_tty_drv
 * Description  : called from PS Core when BT protocol stack drivers
 *                  unregistration,or FM/GNSS hal stack close FM/GNSS inode
 * input        : ps_plat_d
 * output       : return 0--> open tty uart is ok
 *                return !0-> open tty uart is false
 * Calls        :
 * Called By    :
 *
 *   History        :
 *   1.Date         : 2012/11/05
 *     Author       : wx144390
 *     Modification : Created function
 *
 */
int32 release_tty_drv(void *pm_data)
{
    int32  error;
    struct ps_plat_s *ps_plat_d = NULL;
    struct tty_struct *tty = NULL;
    struct ps_core_s *ps_core_d;
    uint64 timeleft = 0;
    uint8  delay_times = RELEASE_DELAT_TIMES;

    PS_PRINT_INFO("%s\n", __func__);

    if (unlikely(NULL == pm_data))
    {
        PS_PRINT_ERR("pm_data is NULL");
        return -EINVAL;
    }

    ps_plat_d = (struct ps_plat_s *)pm_data;
    ps_core_d = ps_plat_d->core_data;
    tty = ps_core_d->tty;

    if (false == ps_core_d->tty_have_open)
    {
        PS_PRINT_INFO("hisi bfgx line discipline have uninstalled, ignored\n");
        return 0;
    }

    /* clean all tx sk_buff */
    while(((ps_core_d->tx_high_seq.qlen)||(ps_core_d->tx_low_seq.qlen))&&(delay_times))
    {
        msleep(100);
        delay_times --;
    }
    msleep(200);

    if (tty)
    {   /* can be called before ldisc is installed */
        /* Flush any pending characters in the driver and discipline. */
        PS_PRINT_INFO(" %s--> into flush_buffer\n", __func__);
        tty_ldisc_flush(tty);
        tty_driver_flush_buffer(tty);
    }

    INIT_COMPLETION(ps_plat_d->ldisc_uninstalled);
    ps_plat_d->ldisc_install = TTY_LDISC_UNINSTALL;

    PS_PRINT_INFO("ldisc_install = %d\n", TTY_LDISC_UNINSTALL);
    sysfs_notify(g_sysfs_hi110x_bfgx, NULL, "install");

    ps_uart_state_pre(ps_core_d->tty);
    timeleft = wait_for_completion_timeout(&ps_plat_d->ldisc_uninstalled, msecs_to_jiffies(HISI_LDISC_TIME));
    if (!timeleft)
    {
        ps_uart_state_dump(ps_core_d->tty);
        PS_PRINT_ERR("hisi bfgx ldisc uninstall timeout\n");
        error = -ETIMEDOUT;
    }
    else
    {
        PS_PRINT_SUC("hisi bfgx line discipline uninstall succ\n");
        error = 0;
    }

    ps_core_d->tty_have_open = false;
    ps_plat_d->flow_cntrl    = FLOW_CTRL_ENABLE;
    ps_plat_d->baud_rate     = DEFAULT_BAUD_RATE;

    return error;
}
Esempio n. 26
0
STATIC ssize_t store_wifi_mem_dump(struct device *dev, struct kobj_attribute *attr, const char *buf, size_t count)
{
    int32 cmd;
    int32 ret;
    struct ps_core_s *ps_core_d = NULL;
    struct st_exception_info *pst_exception_data = NULL;

    PS_PRINT_INFO("%s\n", __func__);

    if (NULL == buf)
    {
        PS_PRINT_ERR("buf is NULL\n");
        return -FAILURE;
    }

    get_exception_info_reference(&pst_exception_data);
    if (NULL == pst_exception_data)
    {
        PS_PRINT_ERR("get exception info reference is error\n");
        return 0;
    }

    ps_get_core_reference(&ps_core_d);
    if (unlikely(NULL == ps_core_d))
    {
        PS_PRINT_ERR("ps_core_d is NULL\n");
        return -EINVAL;
    }

    ret = prepare_to_visit_node(ps_core_d);
    if (ret < 0)
    {
        PS_PRINT_ERR("prepare work FAIL\n");
        return ret;
    }

    cmd = simple_strtol(buf, NULL, 10);
    switch (cmd)
    {
        case 1:
            PS_PRINT_INFO("wifi mem dump cmd %d, halt wcpu\n", cmd);
            uart_halt_wcpu();
            break;
        case 2:
            PS_PRINT_INFO("wifi mem dump cmd %d, read wifi public register\n", cmd);
            plat_wait_last_rotate_finish();
            if (EXCEPTION_SUCCESS == uart_read_wifi_mem(WIFI_PUB_REG))
            {
                /*send cmd to oam_hisi to rotate file*/
                plat_send_rotate_cmd_2_app(CMD_READM_WIFI_UART);
            }
            else
            {
                plat_rotate_finish_set();
            };
            break;
        case 3:
            PS_PRINT_INFO("wifi mem dump cmd %d, read wifi priv register\n", cmd);
            plat_wait_last_rotate_finish();
            if (EXCEPTION_SUCCESS == uart_read_wifi_mem(WIFI_PRIV_REG))
            {
                /*send cmd to oam_hisi to rotate file*/
                plat_send_rotate_cmd_2_app(CMD_READM_WIFI_UART);
            }
            else
            {
                plat_rotate_finish_set();
            };
            break;
        case 4:
            PS_PRINT_INFO("wifi mem dump cmd %d, read wifi mem\n", cmd);
            plat_wait_last_rotate_finish();
            if (EXCEPTION_SUCCESS == uart_read_wifi_mem(WIFI_MEM))
            {
                /*send cmd to oam_hisi to rotate file*/
                plat_send_rotate_cmd_2_app(CMD_READM_WIFI_UART);
            }
            else
            {
                plat_rotate_finish_set();
            };
            break;
        case 5:
            PS_PRINT_INFO("wifi mem dump cmd %d\n", cmd);
            debug_uart_read_wifi_mem(1);
            break;
        default:
            PS_PRINT_ERR("error cmd:[%d]\n", cmd);
            break;
    }

    post_to_visit_node(ps_core_d);

    return count;
}
Esempio n. 27
0
/*****************************************************************************
 函 数 名  : store_bfgx_reg_and_reg_dump
 功能描述  : SDIO上报BFGX的reg
 输入参数  :

 输出参数  :
 返 回 值  : void
 调用函数  :
 被调函数  :

 修改历史      :
  1.日    期   : 2015年12月2日
    作    者   : c00351912
    修改内容   : 新生成函数

*****************************************************************************/
STATIC ssize_t store_bfgx_reg_and_reg_dump(struct device *dev, struct kobj_attribute *attr, const char *buf, size_t count)
{
    int32 cmd;
    int32 ret;
    struct ps_core_s *ps_core_d = NULL;
    struct st_exception_info *pst_exception_data = NULL;

    PS_PRINT_INFO("%s\n", __func__);

    if (NULL == buf)
    {
        PS_PRINT_ERR("buf is NULL\n");
        return -FAILURE;
    }

    get_exception_info_reference(&pst_exception_data);
    if (NULL == pst_exception_data)
    {
        PS_PRINT_ERR("get exception info reference is error\n");
        return 0;
    }

    ps_get_core_reference(&ps_core_d);
    if (unlikely(NULL == ps_core_d))
    {
        PS_PRINT_ERR("ps_core_d is NULL\n");
        return -EINVAL;
    }

    ret = prepare_to_visit_node(ps_core_d);
    if (ret < 0)
    {
        PS_PRINT_ERR("prepare work FAIL\n");
        return ret;
    }

    cmd = simple_strtol(buf, NULL, 10);
    switch (cmd)
    {
        case 1:
            PS_PRINT_INFO("bfgx mem dump cmd %d,sdio read bcpu pub reg\n", cmd);
            debug_sdio_read_bfgx_reg_and_mem(BFGX_PUB_REG);
            break;
        case 2:
            PS_PRINT_INFO("bfgx mem dump cmd %d, sdio read bcpu priv reg\n", cmd);
            debug_sdio_read_bfgx_reg_and_mem(BFGX_PRIV_REG);
            break;
        case 3:
            PS_PRINT_INFO("bfgx mem dump cmd %d, sdio read bcpu mem\n", cmd);
            debug_sdio_read_bfgx_reg_and_mem(BFGX_MEM);
            break;
        case 4:
            PS_PRINT_INFO("bfgx mem dump cmd %d, sdio read bcpu reg and mem\n", cmd);
            debug_sdio_read_bfgx_reg_and_mem(SDIO_BFGX_MEM_DUMP_BOTTOM);
            break;
        default:
            PS_PRINT_ERR("error cmd:[%d]\n", cmd);
            break;
    }

    post_to_visit_node(ps_core_d);

    return count;
}
Esempio n. 28
0
int32 bfgx_user_ctrl_init(void)
{
    int status;
    struct kobject *pst_root_object = NULL;

    pst_root_object = oal_get_sysfs_root_object();
    if(NULL == pst_root_object)
    {
        PS_PRINT_ERR("[E]get root sysfs object failed!\n");
        return -EFAULT;
    }

    g_sysfs_hisi_pmdbg = kobject_create_and_add("pmdbg", pst_root_object);
    if (NULL == g_sysfs_hisi_pmdbg)
    {
        PS_PRINT_ERR("Failed to creat g_sysfs_hisi_pmdbg !!!\n ");
		goto fail_g_sysfs_hisi_pmdbg;
    }

    status = sysfs_create_group(g_sysfs_hisi_pmdbg, &pmdbg_attr_grp);
    if (status)
    {
		PS_PRINT_ERR("failed to create g_sysfs_hisi_pmdbg sysfs entries\n");
		goto fail_create_pmdbg_group;
    }

    g_sysfs_hi110x_bfgx = kobject_create_and_add("hi110x_ps", NULL);
    if (NULL == g_sysfs_hi110x_bfgx)
    {
        PS_PRINT_ERR("Failed to creat g_sysfs_hi110x_ps !!!\n ");
		goto fail_g_sysfs_hi110x_bfgx;
    }

    status = sysfs_create_group(g_sysfs_hi110x_bfgx, &bfgx_attr_grp);
    if (status)
    {
		PS_PRINT_ERR("failed to create g_sysfs_hi110x_bfgx sysfs entries\n");
		goto fail_create_bfgx_group;
    }

#ifdef PLATFORM_DEBUG_ENABLE
    g_sysfs_hi110x_debug = kobject_create_and_add("hi110x_debug", NULL);
    if (NULL == g_sysfs_hi110x_debug)
    {
        PS_PRINT_ERR("Failed to creat g_sysfs_hi110x_debug !!!\n ");
        goto fail_g_sysfs_hi110x_debug;
    }

    status = sysfs_create_group(g_sysfs_hi110x_debug, &hi110x_debug_attr_grp);
    if (status)
    {
        PS_PRINT_ERR("failed to create g_sysfs_hi110x_debug sysfs entries\n");
        goto fail_create_hi110x_debug_group;
    }
#endif

#ifdef HAVE_HISI_NFC
    if (!is_my_nfc_chip())
    {
        PS_PRINT_ERR("cfg dev board nfc chip type is not match, skip driver init\n");
    }
    else
    {
        PS_PRINT_INFO("cfg dev board nfc type is matched with hisi_nfc, continue\n");
        g_sysfs_hisi_nfc = kobject_create_and_add("nfc", NULL);
        if (NULL == g_sysfs_hisi_nfc)
        {
            PS_PRINT_ERR("Failed to creat g_sysfs_hisi_nfc !!!\n ");
            goto fail_g_sysfs_hisi_nfc;
        }

        status = sysfs_create_group(g_sysfs_hisi_nfc, &hisi_nfc_attr_grp);
        if (status)
        {
            PS_PRINT_ERR("failed to create g_sysfs_hisi_nfc sysfs entries\n");
            goto fail_create_hisi_nfc_group;
        }
    }
#endif

    return 0;


#ifdef HAVE_HISI_NFC
fail_create_hisi_nfc_group:
    kobject_put(g_sysfs_hisi_nfc);
fail_g_sysfs_hisi_nfc:
#endif

#ifdef PLATFORM_DEBUG_ENABLE
    sysfs_remove_group(g_sysfs_hi110x_debug, &hi110x_debug_attr_grp);
fail_create_hi110x_debug_group:
    kobject_put(g_sysfs_hi110x_debug);
fail_g_sysfs_hi110x_debug:
#endif
    sysfs_remove_group(g_sysfs_hi110x_bfgx, &bfgx_attr_grp);
fail_create_bfgx_group:
    kobject_put(g_sysfs_hi110x_bfgx);
fail_g_sysfs_hi110x_bfgx:
    sysfs_remove_group(g_sysfs_hisi_pmdbg, &pmdbg_attr_grp);
fail_create_pmdbg_group:
    kobject_put(g_sysfs_hisi_pmdbg);
fail_g_sysfs_hisi_pmdbg:
    return -EFAULT;
}
Esempio n. 29
0
STATIC ssize_t store_bfgx_pmdbg(struct device *dev, struct kobj_attribute *attr, const char *buf, size_t count)
{
    struct pm_drv_data *pm_data = NULL;
    int32  cmd = 0;

    if (NULL == buf)
    {
        PS_PRINT_ERR("buf is NULL\n");
        return -FAILURE;
    }

    cmd = simple_strtol(buf, NULL, 10);
    PS_PRINT_INFO("cmd:%d\n", cmd);

    pm_data = pm_get_drvdata();
    if (NULL == pm_data)
    {
        PS_PRINT_ERR("pm_data is NULL!\n");
        return -FAILURE;
    }

    switch (cmd)
    {
        case 1: /* disable plat lowpower function */
            pm_data->bfgx_lowpower_enable = BFGX_PM_ENABLE;
            break;
        case 2: /* enable plat lowpower function */
            pm_data->bfgx_lowpower_enable = BFGX_PM_DISABLE;
            break;
        case 3: /* enable bt lowpower function */
            pm_data->bfgx_bt_lowpower_enable = BFGX_PM_ENABLE;
            break;
        case 4: /* disable bt lowpower function */
            pm_data->bfgx_bt_lowpower_enable = BFGX_PM_DISABLE;
            break;
        case 5: /* enable gnss lowpower function */
            pm_data->bfgx_gnss_lowpower_enable = BFGX_PM_ENABLE;
            break;
        case 6: /* disable gnss lowpower function */
            pm_data->bfgx_gnss_lowpower_enable = BFGX_PM_DISABLE;
            break;
        case 7: /* enable nfc lowpower function */
            pm_data->bfgx_nfc_lowpower_enable = BFGX_PM_ENABLE;
            break;
        case 8: /* disable nfc lowpower function */
            pm_data->bfgx_nfc_lowpower_enable = BFGX_PM_DISABLE;
            break;
        case 9:
            pm_data->bfgx_pm_ctrl_enable = BFGX_PM_ENABLE;
            break;
        case 10:
            pm_data->bfgx_pm_ctrl_enable = BFGX_PM_DISABLE;
            break;

        default:
            PS_PRINT_ERR("unknown cmd %d\n", cmd);
            break;
    }

    return count;
}
Esempio n. 30
0
STATIC ssize_t store_ir_mode(struct device *dev, struct kobj_attribute *attr, const char *buf, size_t count)
{
    int32 ir_ctrl_level;
    int ret;

    struct pm_drv_data *pm_data = pm_get_drvdata();
    PS_PRINT_INFO("into %s,irled_power_type is %d\n", __func__, pm_data->board->irled_power_type);
    if (NULL == buf)
    {
        PS_PRINT_ERR("buf is NULL\n");
        return -FAILURE;
    }
    if (NULL == pm_data)
    {
        PS_PRINT_ERR("pm_data is NULL!\n");
        return -FAILURE;
    }

    if (!g_board_info.have_ir)
    {
        PS_PRINT_ERR("board have no ir module");
        return -FAILURE;
    }

    if (IR_GPIO_CTRL == pm_data->board->irled_power_type)
    {
        if (!isAsic())
        {
            PS_PRINT_ERR("HI1102 FPGA VERSION, ignore ir contral gpio\n");
            return count;
        }

        ir_ctrl_level = simple_strtol(buf, NULL, 10);
        if (GPIO_LOWLEVEL == ir_ctrl_level)
        {
            gpio_direction_output(pm_data->board->bfgn_ir_ctrl_gpio, GPIO_LOWLEVEL);
        }
        else if (GPIO_HIGHLEVEL == ir_ctrl_level)
        {
            gpio_direction_output(pm_data->board->bfgn_ir_ctrl_gpio, GPIO_HIGHLEVEL);
        }
        else
        {
            PS_PRINT_ERR("gpio level should be 0 or 1, cur value is [%d]\n", ir_ctrl_level);
            return -FAILURE;
        }
    }
    else if (IR_LDO_CTRL == pm_data->board->irled_power_type)
    {
        if (IS_ERR(pm_data->board->bfgn_ir_ctrl_ldo))
        {
            PS_PRINT_ERR("ir_ctrl get ird ldo failed\n");
            return -FAILURE;
        }

        ir_ctrl_level = simple_strtol(buf, NULL, 10);
        if (GPIO_LOWLEVEL == ir_ctrl_level)
        {
            ret = regulator_disable(pm_data->board->bfgn_ir_ctrl_ldo);
            if (ret)
            {
                PS_PRINT_ERR("ir_ctrl disable ldo failed\n");
            }
        }
        else if (GPIO_HIGHLEVEL == ir_ctrl_level)
        {
            ret = regulator_enable(pm_data->board->bfgn_ir_ctrl_ldo);
            if (ret)
            {
                PS_PRINT_ERR("ir_ctrl enable ldo failed\n");
            }
        }
        else
        {
            PS_PRINT_ERR("ir_ctrl level should be 0 or 1, cur value is [%d]\n", ir_ctrl_level);
            return -FAILURE;
        }
    }
    else
    {
        PS_PRINT_ERR("get ir_ldo_type error! ir_ldo_type is %d!\n", pm_data->board->irled_power_type);
        return -FAILURE;
    }
    PS_PRINT_INFO("set ir ctrl mode as %d!\n", (int)ir_ctrl_level);
    return count;
}