STATIC ssize_t show_country_code(struct device *dev, struct kobj_attribute *attr, char *buf) { int8 *country_code = NULL; int ret; int8 ibuf[COUNTRY_CODE_LEN]={0}; if (NULL == buf) { PS_PRINT_ERR("buf is NULL\n"); return -FAILURE; } country_code = hwifi_get_country_code(); if (strncmp(country_code, "99", strlen("99")) == 0) { ret = get_cust_conf_string(INI_MODU_WIFI, STR_COUNTRY_CODE, ibuf, sizeof(ibuf) - 1); if (ret == INI_SUCC) { strncpy(buf, ibuf, COUNTRY_CODE_LEN); buf[COUNTRY_CODE_LEN-1] = '\0'; return strlen(buf); } else { PS_PRINT_ERR("get dts country_code error\n"); return 0; } } else { return snprintf(buf, COUNTRY_CODE_LEN, "%s", country_code); } }
STATIC ssize_t show_download_mode(struct device *dev, struct kobj_attribute *attr, int8 *buf) { BOARD_INFO* board_info = NULL; if (NULL == buf) { PS_PRINT_ERR("buf is NULL\n"); return -FAILURE; } board_info = get_hi110x_board_info(); if(NULL == board_info) { PS_PRINT_ERR("board_info is null"); return -FAILURE; } if (((board_info->wlan_download_channel) < MODE_DOWNLOAD_BUTT) && (board_info->bfgn_download_channel < MODE_DOWNLOAD_BUTT)) { return snprintf(buf, SNPRINT_LIMIT_TO_KERNEL, "wlan:%s,bfgn:%s\n", device_download_mode_list[board_info->wlan_download_channel].name, device_download_mode_list[board_info->bfgn_download_channel].name); } else { PS_PRINT_ERR("download_firmware_mode:%d error", board_info->wlan_download_channel); return -FAILURE; } }
uint32 ps_uart_state_cur(uint32 index) { struct ps_core_s *ps_core_d = NULL; struct uart_state *state = NULL; ps_get_core_reference(&ps_core_d); if (unlikely((NULL == ps_core_d) || (NULL == ps_core_d->tty) || (NULL == ps_core_d->tty->driver_data))) { PS_PRINT_ERR("ps_core_d ot tty is NULL\n"); return 0; } state = ps_core_d->tty->driver_data; if (unlikely(NULL == state->uart_port)) { PS_PRINT_ERR("uart_port is NULL\n"); return 0; } switch (index) { case STATE_TTY_TX: return g_uart_state.tty_tx_cnt; case STATE_TTY_RX: return g_uart_state.tty_rx_cnt; case STATE_UART_TX: return state->uart_port->icount.tx; case STATE_UART_RX: return state->uart_port->icount.rx; default : PS_PRINT_ERR("not support index\n"); break; } return 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; }
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; }
/** * 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 : 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; }
STATIC ssize_t show_device_board_version(struct device *dev, struct kobj_attribute *attr, int8 *buf) { BOARD_INFO* board_info = NULL; if (NULL == buf) { PS_PRINT_ERR("buf is NULL\n"); return -FAILURE; } board_info = get_hi110x_board_info(); if(NULL == board_info) { PS_PRINT_ERR("board_info is null"); return -FAILURE; } return snprintf(buf, SNPRINT_LIMIT_TO_KERNEL, "%s\n", board_info->chip_type); }
/** * 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); } }
STATIC ssize_t show_wifi_pmdbg(struct device *dev, struct kobj_attribute *attr, int8 *buf) { struct wlan_pm_s *pst_wlan_pm = wlan_pm_get_drv(); oal_int32 ret = 0; if (NULL == buf) { PS_PRINT_ERR("buf is NULL\n"); return -FAILURE; } #ifdef PLATFORM_DEBUG_ENABLE ret += snprintf(buf + ret , PAGE_SIZE - ret, "wifi_pm_debug usage: \n" " 1:dump host info 2:dump device info\n" " 3:open wifi 4:close wifi \n" " 5:enable pm 6:disable pm \n"); #else ret += snprintf(buf + ret , PAGE_SIZE - ret, "wifi_pm_debug usage: \n" " 1:dump host info 2:dump device info\n"); #endif ret += wlan_pm_host_info_print(pst_wlan_pm, buf + ret, PAGE_SIZE - ret); return ret; }
/** * 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"); }
/** * Prototype : ps_tty_complete * Description : to signal completion of line discipline installation * called from PS Core, upon tty_open. * input : ps_plat_d * output : no * Calls : * Called By : * * History : * 1.Date : 2012/11/05 * Author : wx144390 * Modification : Created function * */ int32 ps_tty_complete(void *pm_data, uint8 install) { struct ps_plat_s *ps_plat_d = (struct ps_plat_s *)pm_data; switch(install) { case TTY_LDISC_UNINSTALL: complete(&ps_plat_d->ldisc_uninstalled); break; case TTY_LDISC_INSTALL: complete(&ps_plat_d->ldisc_installed); break; case TTY_LDISC_RECONFIG: complete(&ps_plat_d->ldisc_reconfiged); break; default: PS_PRINT_ERR("unknown install type [%d]\n", install); break; } return 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; }
STATIC ssize_t bfgx_wkup_host_count_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { struct pm_drv_data *pm_data = pm_get_drvdata(); 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", pm_data->bfg_wakeup_host); }
/* functions called from subsystems */ STATIC ssize_t show_version(struct device *dev, struct kobj_attribute *attr, int8 *buf) { if (NULL == buf) { PS_PRINT_ERR("buf is NULL\n"); return -FAILURE; } return snprintf(buf, SNPRINT_LIMIT_TO_KERNEL, "%s\n", g_param_version.param_version); }
STATIC ssize_t show_ini_file_name(struct device *dev, struct kobj_attribute *attr, char *buf) { if (NULL == buf) { PS_PRINT_ERR("buf is NULL\n"); return -FAILURE; } return snprintf(buf, INI_FILE_PATH_LEN, "%s", g_ini_file_name); }
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)); }
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); }
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; }
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); }
STATIC ssize_t show_brcm_nfc_conf_name(struct device *dev, struct kobj_attribute *attr, int8 *buf) { char brcm_nfc_conf_name[BUFF_LEN] = {0}; int32 ret = 0; if (NULL == buf) { PS_PRINT_ERR("buf is NULL\n"); return -FAILURE; } ret = read_nfc_conf_name_from_dts(brcm_nfc_conf_name, sizeof(brcm_nfc_conf_name), DTS_COMP_HISI_NFC_NAME, DTS_COMP_HW_BRCM_NFC_CONFIG_NAME); if (ret < 0) { PS_PRINT_ERR("read_nfc_conf_name_from_dts %s,ret = %d\n", DTS_COMP_HW_BRCM_NFC_CONFIG_NAME, ret); return ret; } return snprintf(buf, sizeof(brcm_nfc_conf_name), "%s", brcm_nfc_conf_name); }
STATIC ssize_t store_wifi_pmdbg(struct device *dev, struct kobj_attribute *attr, const char *buf, size_t count) { struct wlan_pm_s *pst_wlan_pm = wlan_pm_get_drv(); int input = 0; if (NULL == buf) { PS_PRINT_ERR("buf is NULL\n"); return -FAILURE; } input = oal_atoi(buf); if (NULL == pst_wlan_pm) { OAL_IO_PRINT("pm_data is NULL!\n"); return -FAILURE; } switch(input) { case 1: wlan_pm_dump_host_info(); break; case 2: wlan_pm_dump_device_info(); break; #ifdef PLATFORM_DEBUG_ENABLE case 3: wlan_pm_open(); break; case 4: wlan_pm_close(); break; case 5: wlan_pm_enable(); break; case 6: wlan_pm_disable(); break; #endif case 7: frw_timer_sys_start(); break; case 8: frw_timer_sys_stop(); break; default: break; } return count; }
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); }
/* read by octty from hal to decide whether or not use flow cntrl */ STATIC ssize_t show_flow_cntrl(struct device *dev, struct kobj_attribute *attr, int8 *buf) { struct ps_plat_s *pm_data = NULL; PS_PRINT_FUNCTION_NAME; 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 -FAILURE; } return snprintf(buf, SNPRINT_LIMIT_TO_KERNEL, "%d\n", pm_data->flow_cntrl); }
void ps_uart_state_dump(struct tty_struct *tty) { struct ps_core_s *ps_core_d = NULL; struct uart_state *state = 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; } state = tty->driver_data; if (unlikely(NULL == state->uart_port)) { PS_PRINT_ERR("uart_port 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)); PS_PRINT_INFO("uart port mctrl:0x%x\n", state->uart_port->mctrl); PS_PRINT_INFO("DR :0x%x\n", readw(state->uart_port->membase + 0x00)); PS_PRINT_INFO("FR :0x%x\n", readw(state->uart_port->membase + 0x18)); PS_PRINT_INFO("IBRD :0x%x\n", readw(state->uart_port->membase + 0x24)); PS_PRINT_INFO("FBRD :0x%x\n", readw(state->uart_port->membase + 0x28)); PS_PRINT_INFO("LCR_H:0x%x\n", readw(state->uart_port->membase + 0x2C)); PS_PRINT_INFO("CR :0x%x\n", readw(state->uart_port->membase + 0x30)); PS_PRINT_INFO("IFLS :0x%x\n", readw(state->uart_port->membase + 0x34)); PS_PRINT_INFO("IMSC :0x%x\n", readw(state->uart_port->membase + 0x38)); PS_PRINT_INFO("RIS :0x%x\n", readw(state->uart_port->membase + 0x3C)); PS_PRINT_INFO("MIS :0x%x\n", readw(state->uart_port->membase + 0x40)); return; }
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; }
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"); }
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; }
/** * 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); }
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"); }