Ejemplo n.º 1
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;

    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;
		case COMBO_IOC_CO_CLOCK_FLAG:
			retval = mtk_wcn_wmt_co_clock_flag_get();
			GPS_INFO_FUNC(KERN_INFO "GPS_ioctl(): GPS co_clock_flag (%d)\n", retval);
		break;
        default:
            retval = -EFAULT;
            GPS_INFO_FUNC(KERN_INFO "GPS_ioctl(): unknown cmd (%d)\n", cmd);
            break;
    }

/*OUT:*/
    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;
}