@@ -405,10 +405,18 @@ static const struct arm_smmu_impl qcom_adreno_smmu_impl = {
405405};
406406
407407static struct arm_smmu_device * qcom_smmu_create (struct arm_smmu_device * smmu ,
408- const struct arm_smmu_impl * impl )
408+ const struct qcom_smmu_match_data * data )
409409{
410+ const struct arm_smmu_impl * impl ;
410411 struct qcom_smmu * qsmmu ;
411412
413+ if (!data )
414+ return ERR_PTR (- EINVAL );
415+
416+ impl = data -> impl ;
417+ if (!impl )
418+ return smmu ;
419+
412420 /* Check to make sure qcom_scm has finished probing */
413421 if (!qcom_scm_is_available ())
414422 return ERR_PTR (- EPROBE_DEFER );
@@ -423,24 +431,32 @@ static struct arm_smmu_device *qcom_smmu_create(struct arm_smmu_device *smmu,
423431 return & qsmmu -> smmu ;
424432}
425433
434+ static const struct qcom_smmu_match_data qcom_smmu_data = {
435+ .impl = & qcom_smmu_impl ,
436+ };
437+
438+ static const struct qcom_smmu_match_data qcom_adreno_smmu_data = {
439+ .impl = & qcom_adreno_smmu_impl ,
440+ };
441+
426442static const struct of_device_id __maybe_unused qcom_smmu_impl_of_match [] = {
427- { .compatible = "qcom,msm8998-smmu-v2" },
428- { .compatible = "qcom,qcm2290-smmu-500" },
429- { .compatible = "qcom,qdu1000-smmu-500" },
430- { .compatible = "qcom,sc7180-smmu-500" },
431- { .compatible = "qcom,sc7280-smmu-500" },
432- { .compatible = "qcom,sc8180x-smmu-500" },
433- { .compatible = "qcom,sc8280xp-smmu-500" },
434- { .compatible = "qcom,sdm630-smmu-v2" },
435- { .compatible = "qcom,sdm845-smmu-500" },
436- { .compatible = "qcom,sm6115-smmu-500" },
437- { .compatible = "qcom,sm6125-smmu-500" },
438- { .compatible = "qcom,sm6350-smmu-500" },
439- { .compatible = "qcom,sm6375-smmu-500" },
440- { .compatible = "qcom,sm8150-smmu-500" },
441- { .compatible = "qcom,sm8250-smmu-500" },
442- { .compatible = "qcom,sm8350-smmu-500" },
443- { .compatible = "qcom,sm8450-smmu-500" },
443+ { .compatible = "qcom,msm8998-smmu-v2" , . data = & qcom_smmu_data },
444+ { .compatible = "qcom,qcm2290-smmu-500" , . data = & qcom_smmu_data },
445+ { .compatible = "qcom,qdu1000-smmu-500" , . data = & qcom_smmu_data },
446+ { .compatible = "qcom,sc7180-smmu-500" , . data = & qcom_smmu_data },
447+ { .compatible = "qcom,sc7280-smmu-500" , . data = & qcom_smmu_data },
448+ { .compatible = "qcom,sc8180x-smmu-500" , . data = & qcom_smmu_data },
449+ { .compatible = "qcom,sc8280xp-smmu-500" , . data = & qcom_smmu_data },
450+ { .compatible = "qcom,sdm630-smmu-v2" , . data = & qcom_smmu_data },
451+ { .compatible = "qcom,sdm845-smmu-500" , . data = & qcom_smmu_data },
452+ { .compatible = "qcom,sm6115-smmu-500" , . data = & qcom_smmu_data },
453+ { .compatible = "qcom,sm6125-smmu-500" , . data = & qcom_smmu_data },
454+ { .compatible = "qcom,sm6350-smmu-500" , . data = & qcom_smmu_data },
455+ { .compatible = "qcom,sm6375-smmu-500" , . data = & qcom_smmu_data },
456+ { .compatible = "qcom,sm8150-smmu-500" , . data = & qcom_smmu_data },
457+ { .compatible = "qcom,sm8250-smmu-500" , . data = & qcom_smmu_data },
458+ { .compatible = "qcom,sm8350-smmu-500" , . data = & qcom_smmu_data },
459+ { .compatible = "qcom,sm8450-smmu-500" , . data = & qcom_smmu_data },
444460 { }
445461};
446462
@@ -455,12 +471,13 @@ static struct acpi_platform_list qcom_acpi_platlist[] = {
455471struct arm_smmu_device * qcom_smmu_impl_init (struct arm_smmu_device * smmu )
456472{
457473 const struct device_node * np = smmu -> dev -> of_node ;
474+ const struct of_device_id * match ;
458475
459476#ifdef CONFIG_ACPI
460477 if (np == NULL ) {
461478 /* Match platform for ACPI boot */
462479 if (acpi_match_platform_list (qcom_acpi_platlist ) >= 0 )
463- return qcom_smmu_create (smmu , & qcom_smmu_impl );
480+ return qcom_smmu_create (smmu , & qcom_smmu_data );
464481 }
465482#endif
466483
@@ -471,10 +488,11 @@ struct arm_smmu_device *qcom_smmu_impl_init(struct arm_smmu_device *smmu)
471488 * features if the order is changed.
472489 */
473490 if (of_device_is_compatible (np , "qcom,adreno-smmu" ))
474- return qcom_smmu_create (smmu , & qcom_adreno_smmu_impl );
491+ return qcom_smmu_create (smmu , & qcom_adreno_smmu_data );
475492
476- if (of_match_node (qcom_smmu_impl_of_match , np ))
477- return qcom_smmu_create (smmu , & qcom_smmu_impl );
493+ match = of_match_node (qcom_smmu_impl_of_match , np );
494+ if (match )
495+ return qcom_smmu_create (smmu , match -> data );
478496
479497 return smmu ;
480498}
0 commit comments