static void gps_cdev_rst_cb(
    ENUM_WMTDRV_TYPE_T src, 
    ENUM_WMTDRV_TYPE_T dst, 
    ENUM_WMTMSG_TYPE_T type, 
    void *buf, 
    unsigned int sz){

    /*
        To handle reset procedure please
    */
    ENUM_WMTRSTMSG_TYPE_T rst_msg;

    GPS_INFO_FUNC("sizeof(ENUM_WMTRSTMSG_TYPE_T) = %d\n", sizeof(ENUM_WMTRSTMSG_TYPE_T));
    if(sz <= sizeof(ENUM_WMTRSTMSG_TYPE_T)){ 
        memcpy((char *)&rst_msg, (char *)buf, sz);
        GPS_INFO_FUNC("src = %d, dst = %d, type = %d, buf = 0x%x sz = %d, max = %d\n", src, dst, type, rst_msg, sz, WMTRSTMSG_RESET_MAX);
        if((src==WMTDRV_TYPE_WMT) && 
            (dst == WMTDRV_TYPE_GPS) &&
                (type == WMTMSG_TYPE_RESET)){                
                    if(rst_msg == WMTRSTMSG_RESET_START){
                        GPS_INFO_FUNC("gps restart start!\n");

                        /*reset_start message handling*/
                        
                    } else if(rst_msg == WMTRSTMSG_RESET_END){
                        GPS_INFO_FUNC("gps restart end!\n");

                        /*reset_end message handling*/
                    }
        }
    } else {
        /*message format invalid*/
    }
}
//int GPS_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)
long GPS_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
    int retval = 0;
    ENUM_WMTHWVER_TYPE_T hw_ver_sym = WMTHWVER_INVALID;

    printk("GPS_ioctl(): cmd (%d)\n", cmd);

    switch(cmd)
    {
        case 0: // enable/disable STP
            GPS_INFO_FUNC(KERN_INFO "GPS_ioctl(): disable STP control from GPS dev\n");
            retval = -EINVAL;
#if 1
#else
             /* George: STP is controlled by WMT only */
            mtk_wcn_stp_enable(arg);
#endif
            break;

        case 1: // send raw data
            GPS_INFO_FUNC(KERN_INFO "GPS_ioctl(): disable raw data from GPS dev \n");
            retval = -EINVAL;
            break;

        case COMBO_IOC_GPS_HWVER:             
            /*get combo hw version*/            
            hw_ver_sym = mtk_wcn_wmt_hwver_get();

            GPS_INFO_FUNC(KERN_INFO "GPS_ioctl(): get hw version = %d, sizeof(hw_ver_sym) = %d\n", hw_ver_sym, sizeof(hw_ver_sym));
            if(copy_to_user((int __user *)arg, &hw_ver_sym, sizeof(hw_ver_sym))){
               retval = -EFAULT;
            }
            break;
		case COMBO_IOC_RTC_FLAG:
			
			retval = rtc_GPS_low_power_detected();
			
			GPS_INFO_FUNC(KERN_INFO "GPS_ioctl(): low power flag (%d)\n", retval);
		break;
        default:
            retval = -EFAULT;
            GPS_INFO_FUNC(KERN_INFO "GPS_ioctl(): unknown cmd (%d)\n", cmd);
            break;
    }

/*OUT:*/
    return retval;
}
Exemplo n.º 3
0
//int GPS_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)
long GPS_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
    int retval = 0;
    ENUM_WMTHWVER_TYPE_T hw_ver_sym = WMTHWVER_INVALID;

    GPS_DBG_FUNC("cmd (0x%x)\n", cmd);

    switch (cmd)
    {
    case COMBO_IOC_GPS_HWVER:
        /*get combo hw version*/
        hw_ver_sym = mtk_wcn_wmt_hwver_get();
        GPS_INFO_FUNC("get hw version = %d, sizeof(hw_ver_sym) = %d\n", hw_ver_sym, sizeof(hw_ver_sym));
        if (copy_to_user((int __user *)arg, &hw_ver_sym, sizeof(hw_ver_sym))) {
           retval = -EFAULT;
        }
        break;

    default:
        retval = -EFAULT;
        GPS_DBG_FUNC(KERN_INFO "GPS_ioctl(): unknown cmd (0x%x)\n", cmd);
        break;
    }

    return retval;
}
Exemplo n.º 4
0
static int GPS_close(struct inode *inode, struct file *file)
{
    printk("%s: major %d minor %d (pid %d)\n", __func__,
        imajor(inode),
        iminor(inode),
        current->pid
        );
	if(retflag == 1)
	{
		GPS_WARN_FUNC("whole chip resetting...\n");
		return -EPERM;
	}
    /*Flush Rx Queue*/
    mtk_wcn_stp_register_event_cb(GPS_TASK_INDX, 0x0);  // unregister event callback function
    mtk_wcn_wmt_msgcb_unreg(WMTDRV_TYPE_GPS);
    
    if (MTK_WCN_BOOL_FALSE == mtk_wcn_wmt_func_off(WMTDRV_TYPE_GPS)) {
        GPS_WARN_FUNC("WMT turn off GPS fail!\n");
        return -EIO;    //mostly, native programer does not care this return vlaue, but we still return error code.
    }
    else {       
        GPS_INFO_FUNC("WMT turn off GPS OK!\n");
    }

    return 0;
}
long GPS_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
	long ret;
	GPS_INFO_FUNC("(%d)\n", cmd);
	ret = GPS_unlocked_ioctl(filp, cmd, arg);
	return ret;
}
Exemplo n.º 6
0
static int GPS_open(struct inode *inode, struct file *file)
{
    printk("%s: major %d minor %d (pid %d)\n", __func__,
        imajor(inode),
        iminor(inode),
        current->pid
        );
	if(retflag == 1)
	{
		GPS_WARN_FUNC("whole chip resetting...\n");
		return -EPERM;
	}
#if 1 /* GeorgeKuo: turn on function before check stp ready */
     /* turn on BT */

    if (MTK_WCN_BOOL_FALSE == mtk_wcn_wmt_func_on(WMTDRV_TYPE_GPS)) {
        GPS_WARN_FUNC("WMT turn on GPS fail!\n");
        return -ENODEV;
    } else {
        mtk_wcn_wmt_msgcb_reg(WMTDRV_TYPE_GPS, gps_cdev_rst_cb);
        GPS_INFO_FUNC("WMT turn on GPS OK!\n");
    }
#endif

    if (mtk_wcn_stp_is_ready()) {
#if 0
        if (MTK_WCN_BOOL_FALSE == mtk_wcn_wmt_func_on(WMTDRV_TYPE_GPS)) {
            GPS_WARN_FUNC("WMT turn on GPS fail!\n");
            return -ENODEV;
        }
        GPS_INFO_FUNC("WMT turn on GPS OK!\n");
#endif
        mtk_wcn_stp_register_event_cb(GPS_TASK_INDX, GPS_event_cb);
    }  else {        
        GPS_ERR_FUNC("STP is not ready, Cannot open GPS Devices\n\r");
        
        /*return error code*/
        return -ENODEV;
    }

    //init_MUTEX(&wr_mtx);
    sema_init(&wr_mtx, 1);
    //init_MUTEX(&rd_mtx);
    sema_init(&rd_mtx, 1);
    
    return 0;
}
ssize_t GPS_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
{
    long val = 0;
    int retval;

    down(&rd_mtx);

/*    printk("GPS_read(): count %d pos %lld\n", count, *f_pos);*/

    if(count > MTKSTP_BUFFER_SIZE)
    {
        count = MTKSTP_BUFFER_SIZE;
    }
    
#if GPS_DEBUG_TRACE_GPIO    
    mtk_wcn_stp_debug_gpio_assert(IDX_GPS_RX, DBG_TIE_LOW);
#endif
    retval = mtk_wcn_stp_receive_data(i_buf, count, GPS_TASK_INDX);
#if GPS_DEBUG_TRACE_GPIO
    mtk_wcn_stp_debug_gpio_assert(IDX_GPS_RX, DBG_TIE_HIGH);
#endif

    while(retval == 0) // got nothing, wait for STP's signal
    {
        /*wait_event(GPS_wq, flag != 0);*/ /* George: let signal wake up */
        val = wait_event_interruptible(GPS_wq, flag != 0);
        flag = 0;
            
#if GPS_DEBUG_TRACE_GPIO
        mtk_wcn_stp_debug_gpio_assert(IDX_GPS_RX, DBG_TIE_LOW);
#endif

        retval = mtk_wcn_stp_receive_data(i_buf, count, GPS_TASK_INDX);

#if GPS_DEBUG_TRACE_GPIO
        mtk_wcn_stp_debug_gpio_assert(IDX_GPS_RX, DBG_TIE_HIGH);
#endif
        /* if we are signaled */
        if (val) {
            if (-ERESTARTSYS == val) {
                GPS_INFO_FUNC("signaled by -ERESTARTSYS(%ld) \n ", val);
            }
            else {
                GPS_INFO_FUNC("signaled by %ld \n ", val);
            }
            break;
        }
    }

#if GPS_DEBUG_DUMP    
{   
    unsigned char *buf_ptr = &i_buf[0];        
    int k=0;        
    printk("--[GPS-READ]--");       
    for(k=0; k < 10 ; k++){       
    if(k%16 == 0)  printk("\n");            
    printk("0x%02x ", i_buf[k]);        
    }        
    printk("--\n");    
}
#endif

    if (retval) {
    // we got something from STP driver
        if (copy_to_user(buf, i_buf, retval)) {
        retval = -EFAULT;
        goto OUT;
        }
        else {
            /* success */
        }
    }
    else {
        // we got nothing from STP driver, being signaled
        retval = val;
    }

OUT:
    up(&rd_mtx);
/*    printk("GPS_read(): retval = %d\n", retval);*/
    return (retval);
}
/* int GPS_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) */
long GPS_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
	int retval = 0;
	ENUM_WMTHWVER_TYPE_T hw_ver_sym = WMTHWVER_INVALID;

	pr_debug("GPS_ioctl(): cmd (%d)\n", cmd);

	switch (cmd) {
	case 0:		/* enable/disable STP */
		GPS_INFO_FUNC("disable STP control from GPS dev\n");
		retval = -EINVAL;
#if 1
#else
		/* George: STP is controlled by WMT only */
		mtk_wcn_stp_enable(arg);
#endif
		break;

	case 1:		/* send raw data */
		GPS_INFO_FUNC("disable raw data from GPS dev\n");
		retval = -EINVAL;
		break;

	case COMBO_IOC_GPS_HWVER:
		/*get combo hw version */
		hw_ver_sym = mtk_wcn_wmt_hwver_get();

		GPS_INFO_FUNC("get hw version = %d, sizeof(hw_ver_sym) = %zd\n", hw_ver_sym, sizeof(hw_ver_sym));
		if (copy_to_user((int __user *)arg, &hw_ver_sym, sizeof(hw_ver_sym))) 
			retval = -EFAULT;
		
		break;

	case COMBO_IOC_RTC_FLAG:

		retval = rtc_GPS_low_power_detected();

		GPS_INFO_FUNC("low power flag (%d)\n", retval);
		break;
	case COMBO_IOC_CO_CLOCK_FLAG:
		retval = mtk_wcn_wmt_co_clock_flag_get();
		GPS_INFO_FUNC("GPS co_clock_flag (%d)\n", retval);
		break;
	case COMBO_IOC_D1_EFUSE_GET:
#if defined(CONFIG_ARCH_MT6735)
		do {
			char *addr = ioremap(0x10206198, 0x4);
			retval = *(volatile unsigned int *)addr;
			GPS_INFO_FUNC("D1 efuse (0x%x)\n", retval);
			iounmap(addr);
		} while (0);
#else
		GPS_ERR_FUNC("Read Efuse not supported in this platform\n");
#endif
		break;
	default:
		retval = -EFAULT;
		GPS_INFO_FUNC("unknown cmd (%d)\n", cmd);
		break;
	}

/*OUT:*/
	return retval;
}
Exemplo n.º 9
0
/* int GPS_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) */
long GPS_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
	INT32 retval = 0;
	ENUM_WMTHWVER_TYPE_T hw_ver_sym = WMTHWVER_INVALID;
	UINT32 hw_version = 0;
	UINT32 fw_version = 0;
	pr_warn("GPS_ioctl(): cmd (%d)\n", cmd);

	switch (cmd) {
	case 0:		/* enable/disable STP */
		GPS_INFO_FUNC(KERN_INFO "GPS_ioctl(): disable STP control from GPS dev\n");
		retval = -EINVAL;
#if 1
#else
		/* George: STP is controlled by WMT only */
		mtk_wcn_stp_enable(arg);
#endif
		break;

	case 1:		/* send raw data */
		GPS_INFO_FUNC(KERN_INFO "GPS_ioctl(): disable raw data from GPS dev\n");
		retval = -EINVAL;
		break;

	case COMBO_IOC_GPS_HWVER:
		/*get combo hw version */
		hw_ver_sym = mtk_wcn_wmt_hwver_get();

		GPS_INFO_FUNC(KERN_INFO
			      "GPS_ioctl(): get hw version = %d, sizeof(hw_ver_sym) = %zd\n",
			      hw_ver_sym, sizeof(hw_ver_sym));
		if (copy_to_user((int __user *)arg, &hw_ver_sym, sizeof(hw_ver_sym))) 
			retval = -EFAULT;
		
		break;
	case COMBO_IOC_GPS_IC_HW_VERSION:
		/*get combo hw version from ic,  without wmt mapping */
		hw_version = mtk_wcn_wmt_ic_info_get(WMTCHIN_HWVER);

		GPS_INFO_FUNC(KERN_INFO "GPS_ioctl(): get hw version = 0x%x\n", hw_version);
		if (copy_to_user((int __user *)arg, &hw_version, sizeof(hw_version))) 
			retval = -EFAULT;
		
		break;

	case COMBO_IOC_GPS_IC_FW_VERSION:
		/*get combo fw version from ic, without wmt mapping */
		fw_version = mtk_wcn_wmt_ic_info_get(WMTCHIN_FWVER);

		GPS_INFO_FUNC(KERN_INFO "GPS_ioctl(): get fw version = 0x%x\n", fw_version);
		if (copy_to_user((int __user *)arg, &fw_version, sizeof(fw_version))) 
			retval = -EFAULT;
		
		break;
	default:
		retval = -EFAULT;
		GPS_INFO_FUNC(KERN_INFO "GPS_ioctl(): unknown cmd (%d)\n", cmd);
		break;
	}

/*OUT:*/
	return retval;
}