コード例 #1
0
ファイル: bfgx_low_power.c プロジェクト: fromfuture/Elizium
/**
 * 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);
    }

}
コード例 #2
0
ファイル: bfgx_user_ctrl.c プロジェクト: fromfuture/Elizium
STATIC ssize_t gnss_lowpower_state_store(struct device *dev, struct kobj_attribute *attr, const char *buf, size_t count)
{
    int flag = 0;
    struct pm_drv_data *pm_data = NULL;

    PS_PRINT_DBG("gnss_lowpower_state_store!\n");

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

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

    flag = simple_strtol(buf, NULL, 10);
    /*gnss write the flag to request sleep*/
    if (1 == flag)
    {
        if (BFGX_PM_DISABLE == pm_data->bfgx_lowpower_enable)
        {
            PS_PRINT_WARNING("gnss low power disabled!\n");
            return -FAILURE;
        }
        if (BFGX_SLEEP == pm_data->ps_pm_interface->bfgx_dev_state_get())
        {
            PS_PRINT_WARNING("gnss proc: dev has been sleep, not allow dev slp\n");
            return -FAILURE;
        }
        /*if bt and fm are both shutdown ,we will pull down gpio directly*/
        PS_PRINT_DBG("flag = 1!\n");

        if (!timer_pending(&pm_data->bfg_timer))
        {
            PS_PRINT_SUC("gnss low power request sleep!\n");
            host_allow_bfg_sleep(pm_data->ps_pm_interface->ps_core_data);
        }

        /*set the flag to 1 means gnss request sleep*/
        atomic_set(&pm_data->gnss_sleep_flag, GNSS_AGREE_SLEEP);
    }
    else
    {
        PS_PRINT_ERR("invalid gnss lowpower data!\n");
        return -FAILURE;
    }

    return count;
}
コード例 #3
0
ファイル: plat_uart.c プロジェクト: slade87/HuaweiP9Kernel
/**
 * 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;
}
コード例 #4
0
ファイル: plat_uart.c プロジェクト: fromfuture/Elizium
/**
 * 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);
}
コード例 #5
0
ファイル: plat_uart.c プロジェクト: slade87/HuaweiP9Kernel
STATIC void ps_uart_state_get(struct tty_struct *tty)
{
    struct uart_state *state = NULL;

    if (unlikely((NULL == tty) || (NULL == tty->driver_data)))
    {
        PS_PRINT_DBG("tty_struct or driver_data is NULL\n");
        return;
    }
    state = tty->driver_data;
    if (unlikely(NULL == state->uart_port))
    {
        PS_PRINT_ERR("uart_port is NULL\n");
        return;
    }

    memcpy(&g_uart_state.uart_cnt, &state->uart_port->icount, sizeof(struct uart_icount));
    return;
}
コード例 #6
0
ファイル: bfgx_user_ctrl.c プロジェクト: fromfuture/Elizium
STATIC ssize_t show_gnss_lowpower_state(struct device *dev, struct kobj_attribute *attr, char *buf, size_t count)
{
    struct pm_drv_data *pm_data = pm_get_drvdata();

    PS_PRINT_DBG("show_gnss_lowpower_state!\n");

    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;
    }

    return snprintf(buf, SNPRINT_LIMIT_TO_KERNEL, "%d\n", atomic_read(&pm_data->gnss_sleep_flag));
}
コード例 #7
0
ファイル: bfgx_user_ctrl.c プロジェクト: fromfuture/Elizium
STATIC ssize_t show_wifi_exception_count(struct device *dev, struct kobj_attribute *attr, int8 *buf)
{
    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_PRINT_DBG("exception debug: wifi rst count is %d\n", pst_exception_data->wifi_exception_cnt);
    return snprintf(buf, SNPRINT_LIMIT_TO_KERNEL, "%d\n", pst_exception_data->wifi_exception_cnt);
}
コード例 #8
0
ファイル: bfgx_user_ctrl.c プロジェクト: fromfuture/Elizium
/* show curr bfgx proto yes or not opened state */
STATIC ssize_t show_bfgx_active_state(struct device *dev, struct kobj_attribute *attr, int8 *buf)
{
    struct ps_plat_s *pm_data = NULL;
    uint8 bt_state   = POWER_STATE_SHUTDOWN;
    uint8 fm_state   = POWER_STATE_SHUTDOWN;
    uint8 gnss_state = POWER_STATE_SHUTDOWN;
    uint8 ir_state   = POWER_STATE_SHUTDOWN;
#ifdef HAVE_HISI_NFC
    uint8 nfc_state  = POWER_STATE_SHUTDOWN;
#endif

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

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

    pm_data = dev_get_drvdata(&hw_ps_device->dev);
    if (NULL == pm_data)
    {
        PS_PRINT_ERR("pm_data is NULL!\n");
        return -EFAULT;
    }

    if (true == atomic_read(&pm_data->core_data->bfgx_info[BFGX_BT].subsys_state))
    {
        bt_state = POWER_STATE_OPEN;
    }

    if (true == atomic_read(&pm_data->core_data->bfgx_info[BFGX_FM].subsys_state))
    {
        fm_state = POWER_STATE_OPEN;
    }

    if (true == atomic_read(&pm_data->core_data->bfgx_info[BFGX_GNSS].subsys_state))
    {
        gnss_state = POWER_STATE_OPEN;
    }

    if (g_board_info.have_ir)
    {
        if (true == atomic_read(&pm_data->core_data->bfgx_info[BFGX_IR].subsys_state))
        {
            ir_state = POWER_STATE_OPEN;
        }
    }

#ifdef HAVE_HISI_NFC
    if (true == atomic_read(&pm_data->core_data->bfgx_info[BFGX_NFC].subsys_state))
    {
        nfc_state = POWER_STATE_OPEN;
    }
#endif

    if (g_board_info.have_ir)
    {
#ifdef HAVE_HISI_NFC
    return snprintf(buf, SNPRINT_LIMIT_TO_KERNEL, "bt:%d; fm:%d; gnss:%d; ir:%d; nfc:%d;\n", bt_state, fm_state, gnss_state, ir_state, nfc_state);
#else
    return snprintf(buf, SNPRINT_LIMIT_TO_KERNEL, "bt:%d; fm:%d; gnss:%d; ir:%d;\n", bt_state, fm_state, gnss_state, ir_state);
#endif
    }
    else
    {
#ifdef HAVE_HISI_NFC
     return snprintf(buf, SNPRINT_LIMIT_TO_KERNEL, "bt:%d; fm:%d; gnss:%d; nfc:%d;\n", bt_state, fm_state, gnss_state, nfc_state);
#else
    return snprintf(buf, SNPRINT_LIMIT_TO_KERNEL, "bt:%d; fm:%d; gnss:%d;\n", bt_state, fm_state, gnss_state);
#endif
    }
}