diff options
Diffstat (limited to 'drivers/remoteproc/omap_remoteproc.c')
-rw-r--r-- | drivers/remoteproc/omap_remoteproc.c | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/drivers/remoteproc/omap_remoteproc.c b/drivers/remoteproc/omap_remoteproc.c index 51689721ea7a..cf92f6e7c5dc 100644 --- a/drivers/remoteproc/omap_remoteproc.c +++ b/drivers/remoteproc/omap_remoteproc.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/platform_device.h> | 27 | #include <linux/platform_device.h> |
28 | #include <linux/dma-mapping.h> | 28 | #include <linux/dma-mapping.h> |
29 | #include <linux/remoteproc.h> | 29 | #include <linux/remoteproc.h> |
30 | #include <linux/mailbox_client.h> | ||
30 | #include <linux/omap-mailbox.h> | 31 | #include <linux/omap-mailbox.h> |
31 | 32 | ||
32 | #include <linux/platform_data/remoteproc-omap.h> | 33 | #include <linux/platform_data/remoteproc-omap.h> |
@@ -36,20 +37,19 @@ | |||
36 | 37 | ||
37 | /** | 38 | /** |
38 | * struct omap_rproc - omap remote processor state | 39 | * struct omap_rproc - omap remote processor state |
39 | * @mbox: omap mailbox handle | 40 | * @mbox: mailbox channel handle |
40 | * @nb: notifier block that will be invoked on inbound mailbox messages | 41 | * @client: mailbox client to request the mailbox channel |
41 | * @rproc: rproc handle | 42 | * @rproc: rproc handle |
42 | */ | 43 | */ |
43 | struct omap_rproc { | 44 | struct omap_rproc { |
44 | struct omap_mbox *mbox; | 45 | struct mbox_chan *mbox; |
45 | struct notifier_block nb; | 46 | struct mbox_client client; |
46 | struct rproc *rproc; | 47 | struct rproc *rproc; |
47 | }; | 48 | }; |
48 | 49 | ||
49 | /** | 50 | /** |
50 | * omap_rproc_mbox_callback() - inbound mailbox message handler | 51 | * omap_rproc_mbox_callback() - inbound mailbox message handler |
51 | * @this: notifier block | 52 | * @client: mailbox client pointer used for requesting the mailbox channel |
52 | * @index: unused | ||
53 | * @data: mailbox payload | 53 | * @data: mailbox payload |
54 | * | 54 | * |
55 | * This handler is invoked by omap's mailbox driver whenever a mailbox | 55 | * This handler is invoked by omap's mailbox driver whenever a mailbox |
@@ -61,13 +61,13 @@ struct omap_rproc { | |||
61 | * that indicates different events. Those values are deliberately very | 61 | * that indicates different events. Those values are deliberately very |
62 | * big so they don't coincide with virtqueue indices. | 62 | * big so they don't coincide with virtqueue indices. |
63 | */ | 63 | */ |
64 | static int omap_rproc_mbox_callback(struct notifier_block *this, | 64 | static void omap_rproc_mbox_callback(struct mbox_client *client, void *data) |
65 | unsigned long index, void *data) | ||
66 | { | 65 | { |
67 | mbox_msg_t msg = (mbox_msg_t) data; | 66 | struct omap_rproc *oproc = container_of(client, struct omap_rproc, |
68 | struct omap_rproc *oproc = container_of(this, struct omap_rproc, nb); | 67 | client); |
69 | struct device *dev = oproc->rproc->dev.parent; | 68 | struct device *dev = oproc->rproc->dev.parent; |
70 | const char *name = oproc->rproc->name; | 69 | const char *name = oproc->rproc->name; |
70 | u32 msg = (u32)data; | ||
71 | 71 | ||
72 | dev_dbg(dev, "mbox msg: 0x%x\n", msg); | 72 | dev_dbg(dev, "mbox msg: 0x%x\n", msg); |
73 | 73 | ||
@@ -84,8 +84,6 @@ static int omap_rproc_mbox_callback(struct notifier_block *this, | |||
84 | if (rproc_vq_interrupt(oproc->rproc, msg) == IRQ_NONE) | 84 | if (rproc_vq_interrupt(oproc->rproc, msg) == IRQ_NONE) |
85 | dev_dbg(dev, "no message was found in vqid %d\n", msg); | 85 | dev_dbg(dev, "no message was found in vqid %d\n", msg); |
86 | } | 86 | } |
87 | |||
88 | return NOTIFY_DONE; | ||
89 | } | 87 | } |
90 | 88 | ||
91 | /* kick a virtqueue */ | 89 | /* kick a virtqueue */ |
@@ -96,8 +94,8 @@ static void omap_rproc_kick(struct rproc *rproc, int vqid) | |||
96 | int ret; | 94 | int ret; |
97 | 95 | ||
98 | /* send the index of the triggered virtqueue in the mailbox payload */ | 96 | /* send the index of the triggered virtqueue in the mailbox payload */ |
99 | ret = omap_mbox_msg_send(oproc->mbox, vqid); | 97 | ret = mbox_send_message(oproc->mbox, (void *)vqid); |
100 | if (ret) | 98 | if (ret < 0) |
101 | dev_err(dev, "omap_mbox_msg_send failed: %d\n", ret); | 99 | dev_err(dev, "omap_mbox_msg_send failed: %d\n", ret); |
102 | } | 100 | } |
103 | 101 | ||
@@ -115,17 +113,22 @@ static int omap_rproc_start(struct rproc *rproc) | |||
115 | struct platform_device *pdev = to_platform_device(dev); | 113 | struct platform_device *pdev = to_platform_device(dev); |
116 | struct omap_rproc_pdata *pdata = pdev->dev.platform_data; | 114 | struct omap_rproc_pdata *pdata = pdev->dev.platform_data; |
117 | int ret; | 115 | int ret; |
116 | struct mbox_client *client = &oproc->client; | ||
118 | 117 | ||
119 | if (pdata->set_bootaddr) | 118 | if (pdata->set_bootaddr) |
120 | pdata->set_bootaddr(rproc->bootaddr); | 119 | pdata->set_bootaddr(rproc->bootaddr); |
121 | 120 | ||
122 | oproc->nb.notifier_call = omap_rproc_mbox_callback; | 121 | client->dev = dev; |
122 | client->tx_done = NULL; | ||
123 | client->rx_callback = omap_rproc_mbox_callback; | ||
124 | client->tx_block = false; | ||
125 | client->knows_txdone = false; | ||
123 | 126 | ||
124 | /* every omap rproc is assigned a mailbox instance for messaging */ | 127 | oproc->mbox = omap_mbox_request_channel(client, pdata->mbox_name); |
125 | oproc->mbox = omap_mbox_get(pdata->mbox_name, &oproc->nb); | ||
126 | if (IS_ERR(oproc->mbox)) { | 128 | if (IS_ERR(oproc->mbox)) { |
127 | ret = PTR_ERR(oproc->mbox); | 129 | ret = -EBUSY; |
128 | dev_err(dev, "omap_mbox_get failed: %d\n", ret); | 130 | dev_err(dev, "mbox_request_channel failed: %ld\n", |
131 | PTR_ERR(oproc->mbox)); | ||
129 | return ret; | 132 | return ret; |
130 | } | 133 | } |
131 | 134 | ||
@@ -136,9 +139,9 @@ static int omap_rproc_start(struct rproc *rproc) | |||
136 | * Note that the reply will _not_ arrive immediately: this message | 139 | * Note that the reply will _not_ arrive immediately: this message |
137 | * will wait in the mailbox fifo until the remote processor is booted. | 140 | * will wait in the mailbox fifo until the remote processor is booted. |
138 | */ | 141 | */ |
139 | ret = omap_mbox_msg_send(oproc->mbox, RP_MBOX_ECHO_REQUEST); | 142 | ret = mbox_send_message(oproc->mbox, (void *)RP_MBOX_ECHO_REQUEST); |
140 | if (ret) { | 143 | if (ret < 0) { |
141 | dev_err(dev, "omap_mbox_get failed: %d\n", ret); | 144 | dev_err(dev, "mbox_send_message failed: %d\n", ret); |
142 | goto put_mbox; | 145 | goto put_mbox; |
143 | } | 146 | } |
144 | 147 | ||
@@ -151,7 +154,7 @@ static int omap_rproc_start(struct rproc *rproc) | |||
151 | return 0; | 154 | return 0; |
152 | 155 | ||
153 | put_mbox: | 156 | put_mbox: |
154 | omap_mbox_put(oproc->mbox, &oproc->nb); | 157 | mbox_free_channel(oproc->mbox); |
155 | return ret; | 158 | return ret; |
156 | } | 159 | } |
157 | 160 | ||
@@ -168,7 +171,7 @@ static int omap_rproc_stop(struct rproc *rproc) | |||
168 | if (ret) | 171 | if (ret) |
169 | return ret; | 172 | return ret; |
170 | 173 | ||
171 | omap_mbox_put(oproc->mbox, &oproc->nb); | 174 | mbox_free_channel(oproc->mbox); |
172 | 175 | ||
173 | return 0; | 176 | return 0; |
174 | } | 177 | } |