@@ -25,13 +25,8 @@ static irqreturn_t cvs_irq_handler(int irq, void *devid)
2525 if (!icvs || !icvs -> dev )
2626 goto exit ;
2727
28- icvs -> rst_retry = RST_RETRY ;
2928 icvs -> hostwake_event_arg = 1 ;
3029 wake_up_interruptible (& icvs -> hostwake_event );
31-
32- if (icvs -> fw_dl_task_finished == true)
33- hrtimer_start (& icvs -> wdt , ms_to_ktime (WDT_TIMEOUT ),
34- HRTIMER_MODE_REL );
3530 ret = true;
3631exit :
3732 return IRQ_RETVAL (ret );
@@ -54,49 +49,10 @@ static int cvs_init(struct intel_cvs *icvs)
5449 goto exit ;
5550 }
5651
57- icvs -> rst_retry = RST_RETRY ;
58-
5952exit :
6053 return ret ;
6154}
6255
63- static void cvs_wdt_reset_thread (struct work_struct * work )
64- {
65- struct intel_cvs * icvs = container_of (work , struct intel_cvs , rst_task );
66-
67- if (!icvs )
68- return ;
69-
70- dev_info (icvs -> dev , "%s\n" , __func__ );
71- gpiod_set_value_cansleep (icvs -> rst , 0 );
72-
73- if (icvs -> rst_retry -- ) {
74- icvs -> owner = CVS_CAMERA_NONE ;
75- icvs -> ref_count = 0 ;
76- icvs -> int_ref_count = 0 ;
77-
78- msleep (RST_TIME );
79- gpiod_set_value_cansleep (icvs -> rst , 1 );
80- hrtimer_start (& icvs -> wdt , ms_to_ktime (WDT_TIMEOUT ),
81- HRTIMER_MODE_REL );
82- } else
83- dev_err (icvs -> dev , "%s:Device unresponsive!\n" , __func__ );
84- }
85-
86- static enum hrtimer_restart cvs_wdt_reset (struct hrtimer * t )
87- {
88- struct intel_cvs * icvs = container_of (t , struct intel_cvs , wdt );
89-
90- if (!icvs )
91- goto exit ;
92-
93- dev_warn (icvs -> dev , "%s\n" , __func__ );
94- schedule_work (& icvs -> rst_task );
95-
96- exit :
97- return HRTIMER_NORESTART ;
98- }
99-
10056static int find_oem_prod_id (acpi_handle handle , const char * method_name , unsigned long long * value )
10157{
10258 acpi_status status ;
@@ -116,23 +72,24 @@ static int find_oem_prod_id(acpi_handle handle, const char* method_name, unsigne
11672 return 0 ;
11773}
11874
119- static int find_shared_i2c (acpi_handle handle , const char * method_name )
75+ static void find_shared_i2c (acpi_handle handle , const char * method_name , int * i2c_shared )
12076{
121- struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER , NULL };
12277 acpi_status status ;
78+ unsigned long long value = 0 ;
79+ status = acpi_evaluate_integer (handle , (acpi_string )method_name ,
80+ NULL , & value );
12381
124- status = acpi_evaluate_object (handle , (acpi_string )method_name , NULL ,
125- & buffer );
126- if (ACPI_FAILURE (status ))
127- return - ENODEV ;
128-
129- if (!buffer .pointer )
130- return - ENODEV ;
131-
132- ACPI_FREE (buffer .pointer );
133- pr_info ("%s:ACPI method %s found for i2c_shared\n" , __func__ ,
134- method_name );
135- return 0 ;
82+ if (ACPI_FAILURE (status )) {
83+ dev_err (cvs -> dev , "%s: ACPI method %s not found" ,
84+ __func__ , method_name );
85+ * i2c_shared = 0 ;
86+ }
87+
88+ dev_info (cvs -> dev ,
89+ "%s: ACPI method %s returned:0x%llx" ,
90+ __func__ , method_name , value );
91+
92+ * i2c_shared = (value == 0 ) ? 0 : 1 ;
13693}
13794
13895static int cvs_i2c_probe (struct i2c_client * i2c )
@@ -215,15 +172,11 @@ static int cvs_i2c_probe(struct i2c_client *i2c)
215172 goto exit ;
216173 }
217174
218- INIT_WORK (& icvs -> rst_task , cvs_wdt_reset_thread );
219175 INIT_WORK (& icvs -> fw_dl_task , cvs_fw_dl_thread );
220176 init_waitqueue_head (& icvs -> hostwake_event );
221177 init_waitqueue_head (& icvs -> update_complete_event );
222178 icvs -> fw_dl_task_finished = false;
223179
224- hrtimer_init (& icvs -> wdt , CLOCK_REALTIME , HRTIMER_MODE_REL );
225- icvs -> wdt .function = cvs_wdt_reset ;
226-
227180 ret = cvs_init (icvs );
228181 if (ret )
229182 dev_err (icvs -> dev , "Failed to initialize\n" );
@@ -234,7 +187,7 @@ static int cvs_i2c_probe(struct i2c_client *i2c)
234187 dev_err (icvs -> dev , "Failed to get ACPI handle\n" );
235188 goto exit ;
236189 }
237- icvs -> i2c_shared = ( find_shared_i2c (handle , "IICS" ) < 0 ) ? 0 : 1 ;
190+ find_shared_i2c (handle , "IICS" , & icvs -> i2c_shared ) ;
238191
239192 if (icvs -> cap == ICVS_FULLCAP ) {
240193 find_oem_prod_id (handle , "OPID" , & (icvs -> oem_prod_id ));
@@ -256,7 +209,6 @@ static int cvs_i2c_probe(struct i2c_client *i2c)
256209static void cvs_exit (struct intel_cvs * icvs )
257210{
258211 if (icvs && icvs -> dev && icvs -> rst ) {
259- hrtimer_cancel (& icvs -> wdt );
260212 devm_free_irq (icvs -> dev , icvs -> irq , icvs );
261213 gpiod_set_value_cansleep (icvs -> rst , 0 );
262214 }
@@ -272,12 +224,6 @@ static void cvs_i2c_remove(struct i2c_client *i2c)
272224 if (icvs ) {
273225 cvs -> close_fw_dl_task = true;
274226
275- while (cvs -> ref_count ) {
276- pr_info ("%s:Camera is used by IPU. check again after %dms" ,
277- __func__ , WAIT_HOST_RELEASE_MS );
278- mdelay (WAIT_HOST_RELEASE_MS );
279- }
280-
281227 if (icvs -> cap == ICVS_FULLCAP ) {
282228 if (!cvs -> fw_dl_task_finished ) {
283229 pr_info ("%s:signal cvs_fw_dl_thread() to stop" ,
@@ -387,44 +333,6 @@ int cvs_release_camera_sensor_internal(void)
387333 return - EIO ;
388334}
389335
390- int cvs_acquire_camera_sensor (struct cvs_mipi_config * config ,
391- cvs_privacy_callback_t callback , void * handle ,
392- struct cvs_camera_status * status )
393- {
394- int ret ;
395-
396- if (!cvs )
397- return - EINVAL ;
398-
399- ret = cvs_acquire_camera_sensor_internal ();
400- if (!ret ) {
401- spin_lock (& cvs -> lock );
402- cvs -> ref_count ++ ;
403- spin_unlock (& cvs -> lock );
404- }
405- return (ret ) ? ret : 0 ;
406- }
407- EXPORT_SYMBOL_GPL (cvs_acquire_camera_sensor );
408-
409- int cvs_release_camera_sensor (struct cvs_camera_status * status )
410- {
411- int ret ;
412-
413- if (!cvs )
414- return - EINVAL ;
415-
416- ret = cvs_release_camera_sensor_internal ();
417- if (!ret ) {
418- spin_lock (& cvs -> lock );
419- cvs -> ref_count = (cvs -> ref_count > 0 ) ? (cvs -> ref_count - 1 ) : 0 ;
420- cvs -> owner = (cvs -> ref_count == 0 ) ? CVS_CAMERA_CVS :
421- CVS_CAMERA_IPU ;
422- spin_unlock (& cvs -> lock );
423- }
424- return (ret ) ? ret : 0 ;
425- }
426- EXPORT_SYMBOL_GPL (cvs_release_camera_sensor );
427-
428336#ifdef DEBUG_CVS
429337int cvs_exec_cmd (enum cvs_command command )
430338{
@@ -529,29 +437,24 @@ static ssize_t coredump_show(struct device *dev, struct device_attribute *attr,
529437 "CVS VID/PID : 0x%x 0x%x\n"
530438 "CVS Firmware Ver: %d.%d.%d.%d (0x%x.0x%x.0x%x.0x%x)\n"
531439 "CVS Device State: 0x%x (%s)\n"
532- "Reference Count : %d (internal %d) \n"
440+ "Reference Count : %d\n"
533441 "CVS Owner : %s\n"
534442 "I2C Shared : %d\n" ,
535443 cvs -> id .vid , cvs -> id .pid , cvs -> ver .major , cvs -> ver .minor ,
536444 cvs -> ver .hotfix , cvs -> ver .build , cvs -> ver .major , cvs -> ver .minor ,
537445 cvs -> ver .hotfix , cvs -> ver .build , cvs -> cvs_state , stat_name ,
538- cvs -> ref_count , cvs -> int_ref_count ,
446+ cvs -> int_ref_count ,
539447 ((cvs -> owner == CVS_CAMERA_NONE ) ? "NONE" :
540448 (cvs -> owner == CVS_CAMERA_CVS ) ? "CVS" :
541- (cvs -> owner == CVS_CAMERA_IPU && cvs -> ref_count ) ? "IPU" :
542- (cvs -> owner == CVS_CAMERA_IPU && cvs -> int_ref_count ) ? "VDRV" : "UNKNOWN" ),
449+ (cvs -> owner == CVS_CAMERA_IPU ) ? "HOST" : "UNKNOWN" ),
543450 cvs -> i2c_shared );
544451}
545452static DEVICE_ATTR_RO (coredump );
546453
547454static ssize_t cmd_store (struct device * dev , struct device_attribute * attr ,
548455 const char * buf , size_t count )
549456{
550- if (sysfs_streq (buf , "acquire" ))
551- cvs_acquire_camera_sensor (NULL , NULL , NULL , NULL );
552- else if (sysfs_streq (buf , "release" ))
553- cvs_release_camera_sensor (NULL );
554- else if (sysfs_streq (buf , "state" ))
457+ if (sysfs_streq (buf , "state" ))
555458 cvs_exec_cmd (GET_DEVICE_STATE );
556459 else if (sysfs_streq (buf , "version" ))
557460 cvs_exec_cmd (GET_FW_VERSION );
@@ -568,7 +471,7 @@ static ssize_t cmd_show(struct device *dev, struct device_attribute *attr,
568471{
569472 return sysfs_emit (
570473 buf , "command: %s\n" ,
571- "[coredump, acquire, release, state, version, id]" );
474+ "[coredump, state, version, id]" );
572475}
573476static DEVICE_ATTR_RW (cmd );
574477
@@ -586,27 +489,20 @@ static int cvs_suspend(struct device *dev)
586489 struct i2c_client * i2c = container_of (dev , struct i2c_client , dev );
587490 struct intel_cvs * icvs = i2c_get_clientdata (i2c );
588491 int ret = 0 ;
589- u64 timeout ;
590492
591493 dev_info (icvs -> dev , "%s entered\n" , __func__ );
592- /* Wait for FW update complete */
593494 if (icvs -> cap == ICVS_FULLCAP && cvs -> fw_dl_task_finished != true) {
594495 cvs -> close_fw_dl_task = true;
595496 cvs -> hostwake_event_arg = 1 ;
596497 wake_up_interruptible (& cvs -> hostwake_event );
597- timeout = msecs_to_jiffies (WAIT_HOST_WAKE_FLASH_LONG_MS * FW_MAX_RETRY );
598- ret = wait_event_interruptible_timeout (cvs -> update_complete_event ,
599- cvs -> update_complete_event_arg == 1 ,
600- timeout );
601- if (ret <= 0 ) {
602- dev_err (icvs -> dev , "%s: Failed to wait FW update complete\n" , __func__ );
603- ret = - EAGAIN ;
604- }
498+ /* Wait for fw update to cancel */
499+ dev_info (icvs -> dev , "%s: wait for fw update cancel" , __func__ );
500+ flush_work (& icvs -> fw_dl_task );
501+ dev_info (icvs -> dev , "%s: fw update cancelled" , __func__ );
605502 }
606503
607504 if (icvs -> cap == ICVS_FULLCAP ) {
608- /* Disable wdt & IRQ */
609- hrtimer_cancel (& icvs -> wdt );
505+ /* Disable IRQ */
610506 disable_irq (icvs -> irq );
611507 }
612508
@@ -634,7 +530,7 @@ static int cvs_resume(struct device *dev)
634530 icvs -> fw_dl_task_finished = false;
635531 icvs -> close_fw_dl_task = false;
636532
637- /* Restart IRQ and wdt, hrtimer_start would start by fw_dl_task */
533+ /* Restart IRQ & fw_dl thread */
638534 enable_irq (icvs -> irq );
639535 schedule_work (& icvs -> fw_dl_task );
640536 }
0 commit comments