blob: b0640d9feca504d3d3ef5a8993f09aa230b0751f [file] [log] [blame]
Allen.Wang4a0948d2021-12-15 13:41:18 +08001SUMMARY = "Bletchley Motor control"
2PR = "r1"
3LICENSE = "Apache-2.0"
4LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
5
6inherit obmc-phosphor-systemd
7
8RDEPENDS:${PN} += "bash"
Allen.Wang4a0948d2021-12-15 13:41:18 +08009RDEPENDS:${PN} += "i2c-tools"
Patrick Williamsb068a532022-01-19 10:27:13 -060010RDEPENDS:${PN} += "libgpiod-tools"
Potin Laidc251662022-04-01 11:16:50 +080011RDEPENDS:${PN} += "mdio-util"
Allen.Wang4a0948d2021-12-15 13:41:18 +080012
13S = "${WORKDIR}"
Patrick Williamsb068a532022-01-19 10:27:13 -060014SRC_URI += " \
15 file://motor-ctrl \
16 file://motor-init \
17 file://power-ctrl \
18 "
Allen.Wang4a0948d2021-12-15 13:41:18 +080019
20do_install() {
21 install -d ${D}${sbindir}
22 install -m 0755 ${WORKDIR}/power-ctrl ${D}${sbindir}
23
24 install -d ${D}${libexecdir}
Allen.Wang4a0948d2021-12-15 13:41:18 +080025 install -m 0755 ${WORKDIR}/motor-ctrl ${D}${libexecdir}
Patrick Williamsb068a532022-01-19 10:27:13 -060026 install -m 0755 ${WORKDIR}/motor-init ${D}${libexecdir}
Allen.Wang4a0948d2021-12-15 13:41:18 +080027}
28
Allen.Wang89418182022-01-26 10:54:09 +080029TGT = "${SYSTEMD_DEFAULT_TARGET}"
30MOTOR_INIT_INSTFMT="../motor-init-calibration@.service:${TGT}.wants/motor-init-calibration@{0}.service"
Allen.Wang4a0948d2021-12-15 13:41:18 +080031PWR_ON_INSTFMT="host-poweron@.service:host-poweron@{0}.service"
32PWR_OFF_INSTFMT="host-poweroff@.service:host-poweroff@{0}.service"
Allen.Wang89418182022-01-26 10:54:09 +080033AC_ON_INSTFMT="../host-ac-on@.service:${TGT}.wants/host-ac-on@{0}.service"
Potin Lai016db312022-01-17 22:32:02 +080034AC_OFF_INSTFMT="host-ac-off@.service:host-ac-off@{0}.service"
Allen.Wang4a0948d2021-12-15 13:41:18 +080035
Patrick Williamsb068a532022-01-19 10:27:13 -060036SYSTEMD_SERVICE:${PN} += "motor-init-calibration@.service"
37SYSTEMD_LINK:${PN} += "${@compose_list(d, 'MOTOR_INIT_INSTFMT', 'OBMC_HOST_INSTANCES')}"
Allen.Wang4a0948d2021-12-15 13:41:18 +080038
Patrick Williamsb068a532022-01-19 10:27:13 -060039SYSTEMD_SERVICE:${PN} += "host-poweron@.service"
Allen.Wang4a0948d2021-12-15 13:41:18 +080040SYSTEMD_LINK:${PN} += "${@compose_list(d, 'PWR_ON_INSTFMT', 'OBMC_HOST_INSTANCES')}"
41
Patrick Williamsb068a532022-01-19 10:27:13 -060042SYSTEMD_SERVICE:${PN} += "host-poweroff@.service"
Allen.Wang4a0948d2021-12-15 13:41:18 +080043SYSTEMD_LINK:${PN} += "${@compose_list(d, 'PWR_OFF_INSTFMT', 'OBMC_HOST_INSTANCES')}"
Potin Lai016db312022-01-17 22:32:02 +080044
Patrick Williamsb068a532022-01-19 10:27:13 -060045SYSTEMD_SERVICE:${PN} += "host-ac-on@.service"
46SYSTEMD_LINK:${PN} += "${@compose_list(d, 'AC_ON_INSTFMT', 'OBMC_HOST_INSTANCES')}"
Potin Lai016db312022-01-17 22:32:02 +080047
Patrick Williamsb068a532022-01-19 10:27:13 -060048SYSTEMD_SERVICE:${PN} += "host-ac-off@.service"
Potin Lai016db312022-01-17 22:32:02 +080049SYSTEMD_LINK:${PN} += "${@compose_list(d, 'AC_OFF_INSTFMT', 'OBMC_HOST_INSTANCES')}"
Potin Lai807e2b22022-04-13 11:24:00 +080050
51# Host on requires these chassis on
52START_TMPL_CTRL = "obmc-chassis-poweron@.target"
53START_TGTFMT_CTRL = "obmc-host-startmin@{0}.target"
54START_INSTFMT_CTRL = "obmc-chassis-poweron@{0}.target"
55START_FMT_CTRL = "../${START_TMPL_CTRL}:${START_TGTFMT_CTRL}.requires/${START_INSTFMT_CTRL}"
56SYSTEMD_LINK:${PN} += "${@compose_list_zip(d, 'START_FMT_CTRL', 'OBMC_HOST_INSTANCES')}"
57
58# Chassis off requires host off
59STOP_TMPL_CTRL = "obmc-host-stop@.target"
60STOP_TGTFMT_CTRL = "obmc-chassis-poweroff@{0}.target"
61STOP_INSTFMT_CTRL = "obmc-host-stop@{0}.target"
62STOP_FMT_CTRL = "../${STOP_TMPL_CTRL}:${STOP_TGTFMT_CTRL}.requires/${STOP_INSTFMT_CTRL}"
63SYSTEMD_LINK:${PN} += "${@compose_list_zip(d, 'STOP_FMT_CTRL', 'OBMC_HOST_INSTANCES')}"
64
65# Hard power off requires chassis off
66HARD_OFF_TMPL_CTRL = "obmc-chassis-poweroff@.target"
67HARD_OFF_TGTFMT_CTRL = "obmc-chassis-hard-poweroff@{0}.target"
68HARD_OFF_INSTFMT_CTRL = "obmc-chassis-poweroff@{0}.target"
69HARD_OFF_FMT_CTRL = "../${HARD_OFF_TMPL_CTRL}:${HARD_OFF_TGTFMT_CTRL}.requires/${HARD_OFF_INSTFMT_CTRL}"
70SYSTEMD_LINK:${PN} += "${@compose_list_zip(d, 'HARD_OFF_FMT_CTRL', 'OBMC_HOST_INSTANCES')}"
71
72# Host on unit configurations
73HOST_ON_OVERRIDE_CONF_FMT = "host-poweron.conf:host-poweron@{0}.service.d/host-poweron.conf"
74SYSTEMD_OVERRIDE:${PN}:bletchley += "${@compose_list_zip(d, 'HOST_ON_OVERRIDE_CONF_FMT', 'OBMC_HOST_INSTANCES')}"
75
76# Host off unit configurations
77HOST_OFF_OVERRIDE_CONF_FMT = "host-poweroff.conf:host-poweroff@{0}.service.d/host-poweroff.conf"
78SYSTEMD_OVERRIDE:${PN}:bletchley += "${@compose_list_zip(d, 'HOST_OFF_OVERRIDE_CONF_FMT', 'OBMC_HOST_INSTANCES')}"
79