static int __init tspdrv_init(void) { int nRet, i; /* initialized below */ atomic_set(&g_nDebugLevel, DBL_ERROR); #ifdef VIBE_RUNTIME_RECORD atomic_set(&g_bRuntimeRecord, 0); DbgOut((DBL_ERROR, "*** tspdrv: runtime recorder feature is ON for debugging which should be OFF in release version.\n" "*** tspdrv: please turn off the feature by removing VIBE_RUNTIME_RECODE macro.\n")); #endif DbgOut((DBL_INFO, "tspdrv: init_module.\n")); #ifdef IMPLEMENT_AS_CHAR_DRIVER g_nMajor = register_chrdev(0, MODULE_NAME, &fops); if (g_nMajor < 0) { DbgOut((DBL_ERROR, "tspdrv: can't get major number.\n")); return g_nMajor; } #else nRet = misc_register(&miscdev); if (nRet) { DbgOut((DBL_ERROR, "tspdrv: misc_register failed.\n")); return nRet; } #endif nRet = platform_device_register(&platdev); if (nRet) DbgOut((DBL_ERROR, "tspdrv: platform_device_register failed.\n")); nRet = platform_driver_register(&platdrv); if (nRet) DbgOut((DBL_ERROR, "tspdrv: platform_driver_register failed.\n")); DbgRecorderInit(()); ImmVibeSPI_ForceOut_Initialize(); VibeOSKernelLinuxInitTimer(); ResetOutputData(); /* Get and concatenate device name and initialize data buffer */ g_cchDeviceName = 0; for (i=0; i<NUM_ACTUATORS; i++) { char *szName = g_szDeviceName + g_cchDeviceName; ImmVibeSPI_Device_GetName(i, szName, VIBE_MAX_DEVICE_NAME_LENGTH); /* Append version information and get buffer length */ strcat(szName, VERSION_STR); g_cchDeviceName += strlen(szName); } return 0; }
static void VibeOSKernelLinuxStopTimer(void) { if (g_bTimerStarted) g_bTimerStarted = false; /* Reset samples buffers */ ResetOutputData(); g_bIsPlaying = false; }
static void VibeOSKernelLinuxStopTimer(void) { /* ** Stop the timer. ** The timer is not restarted when the outputdata buffer is empty and it is ** automatically removed from the timer list when it expires so there is no need to ** call del_timer or del_timer_sync in this function. We just mark it as stopped. */ if (g_bTimerStarted) { g_bTimerStarted = false; } /* Reset samples buffers */ ResetOutputData(); g_bIsPlaying = false; }
static int __devinit drv2604_vibrator_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { int nRet, i,error; /* initialized below */ char status; #if SKIP_AUTOCAL == 0 int nCalibrationCount = 0; #endif DbgOut((KERN_INFO "tspdrv: Probe called.\n")); vibrator_drvdata.client = client; if(!(client->dev.of_node)){ DbgOut(KERN_ERR "tspdrv: tspdrv probe failed, DT is NULL"); return -ENODEV; } error = drv2604_parse_dt(&client->dev); if (error) return error; if( gpio_request(vibrator_drvdata.motor_en, "MOTOR_EN") < 0) { return -EINVAL; } gpio_direction_output(vibrator_drvdata.motor_en, 0); gpio_export(vibrator_drvdata.motor_en, 0); nRet = misc_register(&miscdev); if (nRet) { DbgOut((KERN_ERR "tspdrv: misc_register failed.\n")); return nRet; } #if USE_DRV2604_EN_PIN drv2604_set_en(true); #endif #if USE_DRV2604_STANDBY /* Wait 1000 us for chip power to stabilize */ usleep_range(100000, 100000); drv2604_change_mode(MODE_DEVICE_READY); #endif /* Wait 1000 us for chip power to stabilize */ usleep_range(1000, 1000); #if SKIP_AUTOCAL usleep_range(100000, 100000); drv2604_write_reg_val(init_sequence, sizeof(init_sequence)); status = drv2604_read_reg(STATUS_REG); #else /* Run auto-calibration */ do{ drv2604_write_reg_val(autocal_sequence, sizeof(autocal_sequence)); /* Wait until the procedure is done */ drv2604_poll_go_bit(); /* Read status */ status = drv2604_read_reg(STATUS_REG); nCalibrationCount++; } while (((status & DIAG_RESULT_MASK) == AUTO_CAL_FAILED) && (nCalibrationCount < MAX_AUTOCALIBRATION_ATTEMPT)); /* Check result */ if ((status & DIAG_RESULT_MASK) == AUTO_CAL_FAILED) { DbgOut((DBL_ERROR, "drv2604 auto-calibration failed after %d attempts.\n", nCalibrationCount)); } else { /* Read calibration results */ drv2604_read_reg(AUTO_CALI_RESULT_REG); drv2604_read_reg(AUTO_CALI_BACK_EMF_RESULT_REG); drv2604_read_reg(FEEDBACK_CONTROL_REG); } #endif /* Read device ID */ g_nDeviceID = (status & DEV_ID_MASK); switch (g_nDeviceID) { case DRV2605: DbgOut((DBL_INFO, "drv2604 driver found: drv2605.\n")); break; case DRV2604: DbgOut((DBL_INFO, "drv2604 driver found: drv2604.\n")); break; case DRV2604L: DbgOut((DBL_INFO, "drv2604 driver found: drv2604L.\n")); break; case DRV2605L: DbgOut((DBL_INFO, "drv2604 driver found: drv2605L.\n")); break; default: DbgOut((DBL_INFO, "drv2604 driver found: unknown.\n")); break; } #if USE_DRV2604_STANDBY /* Put hardware in standby */ drv2604_change_mode(MODE_STANDBY); #elif USE_DRV2604_EN_PIN /* enable RTP mode that will be toggled on/off with EN pin */ #endif #if USE_DRV2604_EN_PIN /* turn off chip */ drv2604_set_en(false); #endif DbgRecorderInit(()); ImmVibeSPI_ForceOut_Initialize(); VibeOSKernelLinuxInitTimer(); ResetOutputData(); /* Get and concatenate device name and initialize data buffer */ g_cchDeviceName = 0; for (i=0; i<NUM_ACTUATORS; i++) { char *szName = g_szDeviceName + g_cchDeviceName; ImmVibeSPI_Device_GetName(i, szName, VIBE_MAX_DEVICE_NAME_LENGTH); /* Append version information and get buffer length */ strcat(szName, VERSION_STR); g_cchDeviceName += strlen(szName); } vibetonz_start(); return 0; }
static __devinit int tspdrv_tsp5000_probe(struct platform_device *pdev) { int ret = 0, i; /* initialized below */ DbgOut((KERN_INFO "tspdrv: tspdrv_tsp5000_probe.\n")); atomic_set(&g_nDebugLevel, DBL_ERROR); if(!pdev->dev.of_node){ DbgOut(KERN_ERR "tspdrv_tsp5000: tspdrv_tsp5000 probe failed, DT is NULL"); return -ENODEV; } ret = tspdrv_tsp5000_parse_dt(pdev); if(ret) return ret; vibrator_tsp5000_drvdata.power_onoff = NULL; #ifdef IMPLEMENT_AS_CHAR_DRIVER g_nMajor = register_chrdev(0, MODULE_NAME, &fops); if (g_nMajor < 0) { DbgOut((KERN_ERR "tspdrv: can't get major number.\n")); return g_nMajor; } #else ret = misc_register(&miscdev); if (ret) { DbgOut((KERN_ERR "tspdrv: misc_register failed.\n")); goto fail; } #endif DbgRecorderInit(()); vibetonz_ts2665_clk_on(&pdev->dev); ImmVibeSPI_ForceOut_Initialize(); VibeOSKernelLinuxInitTimer(); ResetOutputData(); /* Get and concatenate device name and initialize data buffer */ g_cchDeviceName = 0; for (i = 0; i < NUM_ACTUATORS; i++) { char *szName = g_szDeviceName + g_cchDeviceName; ImmVibeSPI_Device_GetName(i, szName, VIBE_MAX_DEVICE_NAME_LENGTH); /* Append version information and get buffer length */ strlcat(szName, VERSION_STR, sizeof(VERSION_STR)); g_cchDeviceName += strnlen(szName, sizeof(szName)); } wake_lock_init(&vib_wake_lock, WAKE_LOCK_SUSPEND, "vib_present"); vibetonz_start(); return 0; fail: return ret; }
static int __init tspdrv_init(void) { int nRet, i; /* initialized below */ atomic_set(&g_nDebugLevel, DBL_ERROR); #ifdef VIBE_RUNTIME_RECORD atomic_set(&g_bRuntimeRecord, 0); DbgOut((DBL_ERROR, "*** tspdrv: runtime recorder feature is ON for debugging which should be OFF in release version.\n" "*** tspdrv: please turn off the feature by removing VIBE_RUNTIME_RECODE macro.\n")); #endif DbgOut((DBL_INFO, "tspdrv: init_module.\n")); #ifdef IMPLEMENT_AS_CHAR_DRIVER g_nMajor = register_chrdev(0, MODULE_NAME, &fops); if (g_nMajor < 0) { DbgOut((DBL_ERROR, "tspdrv: can't get major number.\n")); return g_nMajor; } #else nRet = misc_register(&miscdev); if (nRet) { DbgOut((DBL_ERROR, "tspdrv: misc_register failed.\n")); return nRet; } #endif nRet = platform_device_register(&platdev); if (nRet) { DbgOut((DBL_ERROR, "tspdrv: platform_device_register failed.\n")); } nRet = platform_driver_register(&platdrv); if (nRet) { DbgOut((DBL_ERROR, "tspdrv: platform_driver_register failed.\n")); } DbgRecorderInit(()); ImmVibeSPI_ForceOut_Initialize(); VibeOSKernelLinuxInitTimer(); ResetOutputData(); /* Get and concatenate device name and initialize data buffer */ g_cchDeviceName = 0; for (i=0; i<NUM_ACTUATORS; i++) { char *szName = g_szDeviceName + g_cchDeviceName; ImmVibeSPI_Device_GetName(i, szName, VIBE_MAX_DEVICE_NAME_LENGTH); /* Append version information and get buffer length */ strcat(szName, VERSION_STR); g_cchDeviceName += strlen(szName); } #if defined (CONFIG_DEBUG_FS) && defined (CONFIG_TSPDRV_HISTORY) { tspdrv_debugfs_dir = kzalloc(sizeof(struct dentry), GFP_KERNEL); if (!tspdrv_debugfs_dir) return -ENOMEM; tspdrv_debugfs_dir = debugfs_create_dir("tspdrv_debug", NULL); if (tspdrv_debugfs_dir) { if (!debugfs_create_file("tspdrv_history", 0644, tspdrv_debugfs_dir, NULL, &tspdrv_debugfs_fops)) pr_err("%s : debugfs_create_file, error\n", __func__); } else pr_err("%s : debugfs_create_dir, error\n", __func__); } #endif return 0; }