@@ -495,6 +495,9 @@ struct hi556 {
495
495
496
496
/* Streaming on/off */
497
497
bool streaming ;
498
+
499
+ /* True if the device has been identified */
500
+ bool identified ;
498
501
};
499
502
500
503
static u64 to_pixel_rate (u32 f_index )
@@ -757,12 +760,41 @@ static void hi556_assign_pad_format(const struct hi556_mode *mode,
757
760
fmt -> field = V4L2_FIELD_NONE ;
758
761
}
759
762
763
+ static int hi556_identify_module (struct hi556 * hi556 )
764
+ {
765
+ struct i2c_client * client = v4l2_get_subdevdata (& hi556 -> sd );
766
+ int ret ;
767
+ u32 val ;
768
+
769
+ if (hi556 -> identified )
770
+ return 0 ;
771
+
772
+ ret = hi556_read_reg (hi556 , HI556_REG_CHIP_ID ,
773
+ HI556_REG_VALUE_16BIT , & val );
774
+ if (ret )
775
+ return ret ;
776
+
777
+ if (val != HI556_CHIP_ID ) {
778
+ dev_err (& client -> dev , "chip id mismatch: %x!=%x" ,
779
+ HI556_CHIP_ID , val );
780
+ return - ENXIO ;
781
+ }
782
+
783
+ hi556 -> identified = true;
784
+
785
+ return 0 ;
786
+ }
787
+
760
788
static int hi556_start_streaming (struct hi556 * hi556 )
761
789
{
762
790
struct i2c_client * client = v4l2_get_subdevdata (& hi556 -> sd );
763
791
const struct hi556_reg_list * reg_list ;
764
792
int link_freq_index , ret ;
765
793
794
+ ret = hi556_identify_module (hi556 );
795
+ if (ret )
796
+ return ret ;
797
+
766
798
link_freq_index = hi556 -> cur_mode -> link_freq_index ;
767
799
reg_list = & link_freq_configs [link_freq_index ].reg_list ;
768
800
ret = hi556_write_reg_list (hi556 , reg_list );
@@ -1001,26 +1033,6 @@ static const struct v4l2_subdev_internal_ops hi556_internal_ops = {
1001
1033
.open = hi556_open ,
1002
1034
};
1003
1035
1004
- static int hi556_identify_module (struct hi556 * hi556 )
1005
- {
1006
- struct i2c_client * client = v4l2_get_subdevdata (& hi556 -> sd );
1007
- int ret ;
1008
- u32 val ;
1009
-
1010
- ret = hi556_read_reg (hi556 , HI556_REG_CHIP_ID ,
1011
- HI556_REG_VALUE_16BIT , & val );
1012
- if (ret )
1013
- return ret ;
1014
-
1015
- if (val != HI556_CHIP_ID ) {
1016
- dev_err (& client -> dev , "chip id mismatch: %x!=%x" ,
1017
- HI556_CHIP_ID , val );
1018
- return - ENXIO ;
1019
- }
1020
-
1021
- return 0 ;
1022
- }
1023
-
1024
1036
static int hi556_check_hwcfg (struct device * dev )
1025
1037
{
1026
1038
struct fwnode_handle * ep ;
@@ -1106,6 +1118,7 @@ static int hi556_remove(struct i2c_client *client)
1106
1118
static int hi556_probe (struct i2c_client * client )
1107
1119
{
1108
1120
struct hi556 * hi556 ;
1121
+ bool full_power ;
1109
1122
int ret ;
1110
1123
1111
1124
ret = hi556_check_hwcfg (& client -> dev );
@@ -1120,10 +1133,14 @@ static int hi556_probe(struct i2c_client *client)
1120
1133
return - ENOMEM ;
1121
1134
1122
1135
v4l2_i2c_subdev_init (& hi556 -> sd , client , & hi556_subdev_ops );
1123
- ret = hi556_identify_module (hi556 );
1124
- if (ret ) {
1125
- dev_err (& client -> dev , "failed to find sensor: %d" , ret );
1126
- return ret ;
1136
+
1137
+ full_power = acpi_dev_state_d0 (& client -> dev );
1138
+ if (full_power ) {
1139
+ ret = hi556_identify_module (hi556 );
1140
+ if (ret ) {
1141
+ dev_err (& client -> dev , "failed to find sensor: %d" , ret );
1142
+ return ret ;
1143
+ }
1127
1144
}
1128
1145
1129
1146
mutex_init (& hi556 -> mutex );
@@ -1152,7 +1169,9 @@ static int hi556_probe(struct i2c_client *client)
1152
1169
goto probe_error_media_entity_cleanup ;
1153
1170
}
1154
1171
1155
- pm_runtime_set_active (& client -> dev );
1172
+ /* Set the device's state to active if it's in D0 state. */
1173
+ if (full_power )
1174
+ pm_runtime_set_active (& client -> dev );
1156
1175
pm_runtime_enable (& client -> dev );
1157
1176
pm_runtime_idle (& client -> dev );
1158
1177
@@ -1189,6 +1208,7 @@ static struct i2c_driver hi556_i2c_driver = {
1189
1208
},
1190
1209
.probe_new = hi556_probe ,
1191
1210
.remove = hi556_remove ,
1211
+ .flags = I2C_DRV_ACPI_WAIVE_D0_PROBE ,
1192
1212
};
1193
1213
1194
1214
module_i2c_driver (hi556_i2c_driver );
0 commit comments