@@ -400,7 +400,13 @@ enum muxout_select_mode {
400
400
ADF4377_MUXOUT_HIGH = 0x8 ,
401
401
};
402
402
403
+ struct adf4377_chip_info {
404
+ const char * name ;
405
+ bool has_gpio_enclk2 ;
406
+ };
407
+
403
408
struct adf4377_state {
409
+ const struct adf4377_chip_info * chip_info ;
404
410
struct spi_device * spi ;
405
411
struct regmap * regmap ;
406
412
struct clk * clkin ;
@@ -889,11 +895,13 @@ static int adf4377_properties_parse(struct adf4377_state *st)
889
895
return dev_err_probe (& spi -> dev , PTR_ERR (st -> gpio_enclk1 ),
890
896
"failed to get the CE GPIO\n" );
891
897
892
- st -> gpio_enclk2 = devm_gpiod_get_optional (& st -> spi -> dev , "clk2-enable" ,
893
- GPIOD_OUT_LOW );
894
- if (IS_ERR (st -> gpio_enclk2 ))
895
- return dev_err_probe (& spi -> dev , PTR_ERR (st -> gpio_enclk2 ),
896
- "failed to get the CE GPIO\n" );
898
+ if (st -> chip_info -> has_gpio_enclk2 ) {
899
+ st -> gpio_enclk2 = devm_gpiod_get_optional (& st -> spi -> dev , "clk2-enable" ,
900
+ GPIOD_OUT_LOW );
901
+ if (IS_ERR (st -> gpio_enclk2 ))
902
+ return dev_err_probe (& spi -> dev , PTR_ERR (st -> gpio_enclk2 ),
903
+ "failed to get the CE GPIO\n" );
904
+ }
897
905
898
906
ret = device_property_match_property_string (& spi -> dev , "adi,muxout-select" ,
899
907
adf4377_muxout_modes ,
@@ -921,6 +929,16 @@ static int adf4377_freq_change(struct notifier_block *nb, unsigned long action,
921
929
return NOTIFY_OK ;
922
930
}
923
931
932
+ static const struct adf4377_chip_info adf4377_chip_info = {
933
+ .name = "adf4377" ,
934
+ .has_gpio_enclk2 = true,
935
+ };
936
+
937
+ static const struct adf4377_chip_info adf4378_chip_info = {
938
+ .name = "adf4378" ,
939
+ .has_gpio_enclk2 = false,
940
+ };
941
+
924
942
static int adf4377_probe (struct spi_device * spi )
925
943
{
926
944
struct iio_dev * indio_dev ;
@@ -945,6 +963,7 @@ static int adf4377_probe(struct spi_device *spi)
945
963
946
964
st -> regmap = regmap ;
947
965
st -> spi = spi ;
966
+ st -> chip_info = spi_get_device_match_data (spi );
948
967
mutex_init (& st -> lock );
949
968
950
969
ret = adf4377_properties_parse (st );
@@ -964,13 +983,15 @@ static int adf4377_probe(struct spi_device *spi)
964
983
}
965
984
966
985
static const struct spi_device_id adf4377_id [] = {
967
- { "adf4377" , 0 },
986
+ { "adf4377" , (kernel_ulong_t )& adf4377_chip_info },
987
+ { "adf4378" , (kernel_ulong_t )& adf4378_chip_info },
968
988
{}
969
989
};
970
990
MODULE_DEVICE_TABLE (spi , adf4377_id );
971
991
972
992
static const struct of_device_id adf4377_of_match [] = {
973
- { .compatible = "adi,adf4377" },
993
+ { .compatible = "adi,adf4377" , .data = & adf4377_chip_info },
994
+ { .compatible = "adi,adf4378" , .data = & adf4378_chip_info },
974
995
{}
975
996
};
976
997
MODULE_DEVICE_TABLE (of , adf4377_of_match );
0 commit comments