Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/arch/arm/include/asm/arch-apple/rtkit.h b/arch/arm/include/asm/arch-apple/rtkit.h
- index 05a34e1e8f..c3d60323bc 100644
- --- a/arch/arm/include/asm/arch-apple/rtkit.h
- +++ b/arch/arm/include/asm/arch-apple/rtkit.h
- @@ -13,3 +13,5 @@ extern phys_addr_t apple_rtkit_phys_addr;
- int apple_rtkit_init(struct mbox_chan *, int,
- int (*)(void *, phys_addr_t, phys_size_t), void *);
- +
- +int apple_rtkit_shutdown(struct mbox_chan *);
- diff --git a/arch/arm/mach-apple/rtkit.c b/arch/arm/mach-apple/rtkit.c
- index 2f2c1ee9fa..7e998022ee 100644
- --- a/arch/arm/mach-apple/rtkit.c
- +++ b/arch/arm/mach-apple/rtkit.c
- @@ -28,7 +28,7 @@
- #define APPLE_RTKIT_MGMT_STARTEP_EP GENMASK(39, 32)
- #define APPLE_RTKIT_MGMT_STARTEP_FLAG BIT(1)
- -#define APPLE_RTKIT_MGMT_PWR_STATE_ACK 7
- +#define APPLE_RTKIT_MGMT_SET_IOP_PWR_STATE_ACK 7
- #define APPLE_RTKIT_MGMT_EPMAP 8
- #define APPLE_RTKIT_MGMT_EPMAP_LAST BIT(51)
- @@ -77,6 +77,8 @@ int apple_rtkit_init(struct mbox_chan *chan, int wakeup,
- /* EP0_WAIT_HELLO */
- ret = mbox_recv(chan, &msg, 10000);
- + if (ret < 0)
- + return ret;
- endpoint = msg.msg1;
- msgtype = FIELD_GET(APPLE_RTKIT_MGMT_TYPE, msg.msg0);
- @@ -115,6 +117,8 @@ int apple_rtkit_init(struct mbox_chan *chan, int wakeup,
- wait_epmap:
- /* EP0_WAIT_EPMAP */
- ret = mbox_recv(chan, &msg, 10000);
- + if (ret < 0)
- + return ret;
- endpoint = msg.msg1;
- msgtype = FIELD_GET(APPLE_RTKIT_MGMT_TYPE, msg.msg0);
- @@ -135,7 +139,8 @@ wait_epmap:
- }
- /* EP0_SEND_EPACK */
- - reply = FIELD_PREP(APPLE_RTKIT_MGMT_TYPE, APPLE_RTKIT_MGMT_EPMAP_REPLY);
- + reply = FIELD_PREP(APPLE_RTKIT_MGMT_TYPE, APPLE_RTKIT_MGMT_EPMAP_REPLY) |
- + FIELD_PREP(APPLE_RTKIT_MGMT_EPMAP_BASE, base);
- if (msg.msg0 & APPLE_RTKIT_MGMT_EPMAP_LAST)
- reply |= APPLE_RTKIT_MGMT_EPMAP_LAST;
- else
- @@ -213,16 +218,47 @@ wait_epmap:
- printf("%s: unexpected endpoint %d\n", __func__, endpoint);
- return -EINVAL;
- }
- - if (msgtype != APPLE_RTKIT_MGMT_PWR_STATE_ACK) {
- + if (msgtype != APPLE_RTKIT_MGMT_SET_IOP_PWR_STATE_ACK) {
- printf("%s: unexpected message type %d\n", __func__, msgtype);
- return -EINVAL;
- }
- - /* EP0_SEND_PWRACK */
- - msg.msg0 = 0x00b0000000000020;
- - msg.msg1 = APPLE_RTKIT_EP_MGMT;
- - mbox_send(chan, &msg);
- + /* Here we should be sending a message to set the AP power state. But
- + if we do, we can't shut everything back down without crashing RTKit. We
- + don't need it anyway, because we don't start up the syslogs. */
- }
- return 0;
- }
- +
- +int apple_rtkit_shutdown(struct mbox_chan *chan)
- +{
- + struct apple_mbox_msg msg;
- + int ret;
- + int endpoint;
- + int msgtype;
- +
- + msg.msg0 = 0x0060000000000010;
- + msg.msg1 = APPLE_RTKIT_EP_MGMT;
- + mbox_send(chan, &msg);
- +
- + ret = mbox_recv(chan, &msg, 100000);
- + if (ret < 0)
- + return ret;
- +
- + endpoint = msg.msg1;
- + msgtype = FIELD_GET(APPLE_RTKIT_MGMT_TYPE, msg.msg0);
- + if (endpoint != APPLE_RTKIT_EP_MGMT) {
- + printf("%s: unexpected endpoint %d\n", __func__, endpoint);
- + return -EINVAL;
- + }
- + if (msgtype != APPLE_RTKIT_MGMT_SET_IOP_PWR_STATE_ACK) {
- + printf("%s: unexpected message type %d\n", __func__, msgtype);
- + return -EINVAL;
- + }
- +
- + /* Here we should be sending a message to set the AP power state. But
- + since we didn't during init, doing so here would crash RTKit. */
- +
- + return 0;
- +}
- diff --git a/drivers/nvme/nvme_apple.c b/drivers/nvme/nvme_apple.c
- index f25a4c885a..0b4ddfe255 100644
- --- a/drivers/nvme/nvme_apple.c
- +++ b/drivers/nvme/nvme_apple.c
- @@ -137,6 +137,18 @@ static int apple_nvme_probe(struct udevice *dev)
- return nvme_init(dev);
- }
- +static int apple_nvme_remove(struct udevice *dev)
- +{
- + struct apple_nvme_priv *priv = dev_get_priv(dev);
- +
- + int ret = apple_rtkit_shutdown(&priv->chan);
- + if (ret < 0)
- + return ret;
- +
- + return 0;
- +}
- +
- +
- static const struct udevice_id apple_nvme_ids[] = {
- { .compatible = "apple,t8103-ans-nvme" },
- { /* sentinel */ }
- @@ -148,4 +160,6 @@ U_BOOT_DRIVER(apple_nvme) = {
- .of_match = apple_nvme_ids,
- .priv_auto = sizeof(struct apple_nvme_priv),
- .probe = apple_nvme_probe,
- + .remove = apple_nvme_remove,
- + .flags = DM_FLAG_OS_PREPARE,
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement