Skip to content

Commit 9a0feed

Browse files
committed
remoteproc: qcom: Enable in-kernel sns-reg
Request in-kernel Sensors Registry to be started along with ADSP or SLPI, and release it once DSP is stopped. Once all DSPs are stopped, the Sensors Registry will be stopped too. Signed-off-by: Alexey Minnekhanov <alexeymin@postmarketos.org>
1 parent 05dd9f6 commit 9a0feed

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed

drivers/remoteproc/qcom_common.c

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#define to_smd_subdev(d) container_of(d, struct qcom_rproc_subdev, subdev)
2828
#define to_ssr_subdev(d) container_of(d, struct qcom_rproc_ssr, subdev)
2929
#define to_pdm_subdev(d) container_of(d, struct qcom_rproc_pdm, subdev)
30+
#define to_sns_reg_subdev(d) container_of(d, struct qcom_rproc_sns_reg, subdev)
3031

3132
#define MAX_NUM_OF_SS 10
3233
#define MAX_REGION_NAME_LENGTH 16
@@ -641,5 +642,83 @@ void qcom_remove_pdm_subdev(struct rproc *rproc, struct qcom_rproc_pdm *pdm)
641642
}
642643
EXPORT_SYMBOL_GPL(qcom_remove_pdm_subdev);
643644

645+
static int sns_reg_prepare(struct rproc_subdev *subdev)
646+
{
647+
struct qcom_rproc_sns_reg *sns_reg = to_sns_reg_subdev(subdev);
648+
struct auxiliary_device *adev;
649+
int ret;
650+
651+
adev = kzalloc(sizeof(*adev), GFP_KERNEL);
652+
if (!adev)
653+
return -ENOMEM;
654+
655+
adev->dev.parent = sns_reg->rproc_dev;
656+
/* yes, we can reuse release helper from PDM */
657+
adev->dev.release = pdm_dev_release;
658+
adev->name = "sns-reg";
659+
adev->id = sns_reg->rproc_index;
660+
661+
ret = auxiliary_device_init(adev);
662+
if (ret) {
663+
kfree(adev);
664+
return ret;
665+
}
666+
667+
ret = auxiliary_device_add(adev);
668+
if (ret) {
669+
auxiliary_device_uninit(adev);
670+
return ret;
671+
}
672+
673+
sns_reg->adev = adev;
674+
675+
return 0;
676+
}
677+
678+
static void sns_reg_unprepare(struct rproc_subdev *subdev)
679+
{
680+
struct qcom_rproc_sns_reg *sns_reg = to_sns_reg_subdev(subdev);
681+
682+
if (!sns_reg->adev)
683+
return;
684+
685+
auxiliary_device_delete(sns_reg->adev);
686+
auxiliary_device_uninit(sns_reg->adev);
687+
sns_reg->adev = NULL;
688+
}
689+
690+
/**
691+
* qcom_add_sns_reg_subdev() - register sns-reg subdevice
692+
* @rproc: rproc handle
693+
* @sns_reg: sns-reg subdevice handle
694+
*
695+
* Register @sns_reg so that Sensor Registry service is started when the
696+
* DSP is started.
697+
*/
698+
void qcom_add_sns_reg_subdev(struct rproc *rproc, struct qcom_rproc_sns_reg *sns_reg)
699+
{
700+
sns_reg->rproc_dev = &rproc->dev;
701+
sns_reg->rproc_index = rproc->index;
702+
703+
sns_reg->subdev.prepare = sns_reg_prepare;
704+
sns_reg->subdev.unprepare = sns_reg_unprepare;
705+
706+
rproc_add_subdev(rproc, &sns_reg->subdev);
707+
}
708+
EXPORT_SYMBOL_GPL(qcom_add_sns_reg_subdev);
709+
710+
/**
711+
* qcom_remove_sns_reg_subdev() - remove sns-reg subdevice
712+
* @rproc: rproc handle
713+
* @sns_reg: sns-reg subdevice handle
714+
*
715+
* Remove the Sensor Registry subdevice.
716+
*/
717+
void qcom_remove_sns_reg_subdev(struct rproc *rproc, struct qcom_rproc_sns_reg *sns_reg)
718+
{
719+
rproc_remove_subdev(rproc, &sns_reg->subdev);
720+
}
721+
EXPORT_SYMBOL_GPL(qcom_remove_sns_reg_subdev);
722+
644723
MODULE_DESCRIPTION("Qualcomm Remoteproc helper driver");
645724
MODULE_LICENSE("GPL v2");

drivers/remoteproc/qcom_common.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ struct qcom_rproc_pdm {
4141
struct auxiliary_device *adev;
4242
};
4343

44+
struct qcom_rproc_sns_reg {
45+
struct rproc_subdev subdev;
46+
struct device *rproc_dev;
47+
int rproc_index;
48+
struct auxiliary_device *adev;
49+
};
50+
4451
void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
4552
void (*rproc_dumpfn_t)(struct rproc *rproc,
4653
struct rproc_dump_segment *segment, void *dest, size_t offset,
@@ -62,6 +69,9 @@ void qcom_remove_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr);
6269
void qcom_add_pdm_subdev(struct rproc *rproc, struct qcom_rproc_pdm *pdm);
6370
void qcom_remove_pdm_subdev(struct rproc *rproc, struct qcom_rproc_pdm *pdm);
6471

72+
void qcom_add_sns_reg_subdev(struct rproc *rproc, struct qcom_rproc_sns_reg *sns_reg);
73+
void qcom_remove_sns_reg_subdev(struct rproc *rproc, struct qcom_rproc_sns_reg *sns_reg);
74+
6575
#if IS_ENABLED(CONFIG_QCOM_SYSMON)
6676
struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc,
6777
const char *name,

drivers/remoteproc/qcom_q6v5_pas.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ struct qcom_adsp {
113113
struct qcom_rproc_subdev smd_subdev;
114114
struct qcom_rproc_pdm pdm_subdev;
115115
struct qcom_rproc_ssr ssr_subdev;
116+
struct qcom_rproc_sns_reg sns_reg_subdev;
116117
struct qcom_sysmon *sysmon;
117118

118119
struct qcom_scm_pas_metadata pas_metadata;
@@ -771,6 +772,7 @@ static int adsp_probe(struct platform_device *pdev)
771772
qcom_add_glink_subdev(rproc, &adsp->glink_subdev, desc->ssr_name);
772773
qcom_add_smd_subdev(rproc, &adsp->smd_subdev);
773774
qcom_add_pdm_subdev(rproc, &adsp->pdm_subdev);
775+
qcom_add_sns_reg_subdev(rproc, &adsp->sns_reg_subdev);
774776
adsp->sysmon = qcom_add_sysmon_subdev(rproc,
775777
desc->sysmon_name,
776778
desc->ssctl_id);
@@ -790,6 +792,7 @@ static int adsp_probe(struct platform_device *pdev)
790792
qcom_remove_ssr_subdev(rproc, &adsp->ssr_subdev);
791793
qcom_remove_sysmon_subdev(adsp->sysmon);
792794
deinit_remove_pdm_smd_glink:
795+
qcom_remove_sns_reg_subdev(rproc, &adsp->sns_reg_subdev);
793796
qcom_remove_pdm_subdev(rproc, &adsp->pdm_subdev);
794797
qcom_remove_smd_subdev(rproc, &adsp->smd_subdev);
795798
qcom_remove_glink_subdev(rproc, &adsp->glink_subdev);
@@ -816,6 +819,7 @@ static void adsp_remove(struct platform_device *pdev)
816819
qcom_remove_sysmon_subdev(adsp->sysmon);
817820
qcom_remove_smd_subdev(adsp->rproc, &adsp->smd_subdev);
818821
qcom_remove_pdm_subdev(adsp->rproc, &adsp->pdm_subdev);
822+
qcom_remove_sns_reg_subdev(adsp->rproc, &adsp->sns_reg_subdev);
819823
qcom_remove_ssr_subdev(adsp->rproc, &adsp->ssr_subdev);
820824
adsp_pds_detach(adsp, adsp->proxy_pds, adsp->proxy_pd_count);
821825
device_init_wakeup(adsp->dev, false);

0 commit comments

Comments
 (0)