@@ -252,6 +252,32 @@ static int tpg_register_cpas_client(struct cam_tpg_device *tpg_dev,
252252 return rc ;
253253}
254254
255+ static int cam_tpg_hw_queue_init (struct cam_tpg_device * tpg_dev )
256+ {
257+ /* Initialize only the essential components needed for safe operation */
258+
259+ /* Initialize locks */
260+ spin_lock_init (& tpg_dev -> tpg_hw .hw_state_lock );
261+ mutex_init (& tpg_dev -> tpg_hw .mutex );
262+
263+ /* Set TPG initial state */
264+ tpg_dev -> tpg_hw .state = TPG_HW_STATE_HW_DISABLED ;
265+
266+ /* Initialize completion */
267+ init_completion (& tpg_dev -> tpg_hw .complete_rup );
268+
269+ /* Initialize queues */
270+ INIT_LIST_HEAD (& (tpg_dev -> tpg_hw .waiting_request_q ));
271+ INIT_LIST_HEAD (& (tpg_dev -> tpg_hw .active_request_q ));
272+ tpg_dev -> tpg_hw .waiting_request_q_depth = 0 ;
273+ tpg_dev -> tpg_hw .active_request_q_depth = 0 ;
274+ tpg_dev -> tpg_hw .settings_update = 0 ;
275+ tpg_dev -> tpg_hw .tpg_clock = 0 ;
276+
277+ return 0 ;
278+ }
279+
280+
255281static int cam_tpg_hw_layer_init (struct cam_tpg_device * tpg_dev ,
256282 struct device * dev )
257283{
@@ -270,17 +296,8 @@ static int cam_tpg_hw_layer_init(struct cam_tpg_device *tpg_dev,
270296 tpg_dev -> tpg_hw .hw_info = (struct tpg_hw_info * )match_dev -> data ;
271297 tpg_dev -> tpg_hw .soc_info = & tpg_dev -> soc_info ;
272298 tpg_dev -> tpg_hw .cpas_handle = tpg_dev -> cpas_handle ;
273- spin_lock_init (& tpg_dev -> tpg_hw .hw_state_lock );
274- tpg_dev -> tpg_hw .state = TPG_HW_STATE_HW_DISABLED ;
275- mutex_init (& tpg_dev -> tpg_hw .mutex );
276- init_completion (& tpg_dev -> tpg_hw .complete_rup );
277- /*Initialize the waiting queue and active queues*/
278- INIT_LIST_HEAD (& (tpg_dev -> tpg_hw .waiting_request_q ));
279- INIT_LIST_HEAD (& (tpg_dev -> tpg_hw .active_request_q ));
280- tpg_dev -> tpg_hw .waiting_request_q_depth = 0 ;
281- tpg_dev -> tpg_hw .active_request_q_depth = 0 ;
282- tpg_dev -> tpg_hw .settings_update = 0 ;
283- tpg_dev -> tpg_hw .tpg_clock = 0 ;
299+
300+ /* Call layer_init */
284301 tpg_dev -> tpg_hw .hw_info -> layer_init (& tpg_dev -> tpg_hw );
285302 return 0 ;
286303}
@@ -305,9 +322,9 @@ static int cam_tpg_component_bind(struct device *dev,
305322 tpg_dev -> tpg_subdev .pdev = pdev ;
306323 tpg_dev -> state = CAM_TPG_STATE_INIT ;
307324
308- rc = cam_tpg_hw_layer_init (tpg_dev , dev );
325+ rc = cam_tpg_hw_queue_init (tpg_dev );
309326 if (rc < 0 ) {
310- CAM_ERR (CAM_TPG , "Hw layer init failed" );
327+ CAM_ERR (CAM_TPG , "Mutex and queue init failed" );
311328 goto bind_error_exit ;
312329 }
313330
@@ -328,8 +345,15 @@ static int cam_tpg_component_bind(struct device *dev,
328345 CAM_ERR (CAM_TPG , "cpas register failed" );
329346 goto release_subdev ;
330347 }
348+
331349 tpg_crm_intf_init (tpg_dev );
332350
351+ rc = cam_tpg_hw_layer_init (tpg_dev , dev );
352+ if (rc < 0 ) {
353+ CAM_ERR (CAM_TPG , "Hw layer init failed" );
354+ goto release_subdev ;
355+ }
356+
333357 platform_set_drvdata (pdev , tpg_dev );
334358
335359 return rc ;
@@ -354,6 +378,9 @@ static void cam_tpg_component_unbind(struct device *dev,
354378 return ;
355379 }
356380
381+ /* Clean up debugfs entries */
382+ tpg_hw_debugfs_cleanup (& tpg_dev -> tpg_hw );
383+
357384 CAM_INFO (CAM_TPG , "Unbind TPG component" );
358385 cam_cpas_unregister_client (tpg_dev -> cpas_handle );
359386 cam_soc_util_release_platform_resource (& tpg_dev -> soc_info );
0 commit comments