aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNishanth Menon <nm@ti.com>2018-07-16 14:06:07 -0400
committerJassi Brar <jaswinder.singh@linaro.org>2018-08-03 09:27:41 -0400
commita2b79838b891718dd4f0caf86dfa193af789245d (patch)
tree7b05394b54418edc49772fe0df1f8555c67e9c3e
parent0f23a179746c10de8f8fe6ecc4767a0d6c824fa9 (diff)
mailbox: ti-msgmgr: Add support for Secure Proxy
Secure Proxy is another communication scheme in Texas Instrument's devices intended to provide an unique communication path from various processors in the System on Chip(SoC) to a central System Controller. Secure proxy is, in effect, an evolution of current generation Message Manager hardware block found in K2G devices. However the following changes have taken place: Secure Proxy instance exposes "threads" or "proxies" which is primary representation of "a" communication channel. Each thread is preconfigured by System controller configuration based on SoC usage requirements. Secure proxy by itself represents a single "queue" of communication but allows the proxies to be independently operated. Each Secure proxy thread can uniquely have their own error and threshold interrupts allowing for more fine control of IRQ handling. Provide the driver support for Secure Proxy and thread instances. NOTE: Secure proxy configuration is only done by System Controller, hence these are assumed to be pre-configured instances. See AM65x Technical Reference Manual (SPRUID7, April 2018) for further details: http://www.ti.com/lit/pdf/spruid7 Signed-off-by: Nishanth Menon <nm@ti.com> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
-rw-r--r--drivers/mailbox/ti-msgmgr.c233
1 files changed, 205 insertions, 28 deletions
diff --git a/drivers/mailbox/ti-msgmgr.c b/drivers/mailbox/ti-msgmgr.c
index 7167cc708f44..5bceafbf6699 100644
--- a/drivers/mailbox/ti-msgmgr.c
+++ b/drivers/mailbox/ti-msgmgr.c
@@ -25,6 +25,17 @@
25#define Q_STATE_OFFSET(queue) ((queue) * 0x4) 25#define Q_STATE_OFFSET(queue) ((queue) * 0x4)
26#define Q_STATE_ENTRY_COUNT_MASK (0xFFF000) 26#define Q_STATE_ENTRY_COUNT_MASK (0xFFF000)
27 27
28#define SPROXY_THREAD_OFFSET(tid) (0x1000 * (tid))
29#define SPROXY_THREAD_DATA_OFFSET(tid, reg) \
30 (SPROXY_THREAD_OFFSET(tid) + ((reg) * 0x4) + 0x4)
31
32#define SPROXY_THREAD_STATUS_OFFSET(tid) (SPROXY_THREAD_OFFSET(tid))
33
34#define SPROXY_THREAD_STATUS_COUNT_MASK (0xFF)
35
36#define SPROXY_THREAD_CTRL_OFFSET(tid) (0x1000 + SPROXY_THREAD_OFFSET(tid))
37#define SPROXY_THREAD_CTRL_DIR_MASK (0x1 << 31)
38
28/** 39/**
29 * struct ti_msgmgr_valid_queue_desc - SoC valid queues meant for this processor 40 * struct ti_msgmgr_valid_queue_desc - SoC valid queues meant for this processor
30 * @queue_id: Queue Number for this path 41 * @queue_id: Queue Number for this path
@@ -45,12 +56,15 @@ struct ti_msgmgr_valid_queue_desc {
45 * @data_first_reg: First data register for proxy data region 56 * @data_first_reg: First data register for proxy data region
46 * @data_last_reg: Last data register for proxy data region 57 * @data_last_reg: Last data register for proxy data region
47 * @status_cnt_mask: Mask for getting the status value 58 * @status_cnt_mask: Mask for getting the status value
59 * @status_err_mask: Mask for getting the error value, if applicable
48 * @tx_polled: Do I need to use polled mechanism for tx 60 * @tx_polled: Do I need to use polled mechanism for tx
49 * @tx_poll_timeout_ms: Timeout in ms if polled 61 * @tx_poll_timeout_ms: Timeout in ms if polled
50 * @valid_queues: List of Valid queues that the processor can access 62 * @valid_queues: List of Valid queues that the processor can access
51 * @data_region_name: Name of the proxy data region 63 * @data_region_name: Name of the proxy data region
52 * @status_region_name: Name of the proxy status region 64 * @status_region_name: Name of the proxy status region
65 * @ctrl_region_name: Name of the proxy control region
53 * @num_valid_queues: Number of valid queues 66 * @num_valid_queues: Number of valid queues
67 * @is_sproxy: Is this an Secure Proxy instance?
54 * 68 *
55 * This structure is used in of match data to describe how integration 69 * This structure is used in of match data to describe how integration
56 * for a specific compatible SoC is done. 70 * for a specific compatible SoC is done.
@@ -62,12 +76,15 @@ struct ti_msgmgr_desc {
62 u8 data_first_reg; 76 u8 data_first_reg;
63 u8 data_last_reg; 77 u8 data_last_reg;
64 u32 status_cnt_mask; 78 u32 status_cnt_mask;
79 u32 status_err_mask;
65 bool tx_polled; 80 bool tx_polled;
66 int tx_poll_timeout_ms; 81 int tx_poll_timeout_ms;
67 const struct ti_msgmgr_valid_queue_desc *valid_queues; 82 const struct ti_msgmgr_valid_queue_desc *valid_queues;
68 const char *data_region_name; 83 const char *data_region_name;
69 const char *status_region_name; 84 const char *status_region_name;
85 const char *ctrl_region_name;
70 int num_valid_queues; 86 int num_valid_queues;
87 bool is_sproxy;
71}; 88};
72 89
73/** 90/**
@@ -80,6 +97,7 @@ struct ti_msgmgr_desc {
80 * @queue_buff_start: First register of Data Buffer 97 * @queue_buff_start: First register of Data Buffer
81 * @queue_buff_end: Last (or confirmation) register of Data buffer 98 * @queue_buff_end: Last (or confirmation) register of Data buffer
82 * @queue_state: Queue status register 99 * @queue_state: Queue status register
100 * @queue_ctrl: Queue Control register
83 * @chan: Mailbox channel 101 * @chan: Mailbox channel
84 * @rx_buff: Receive buffer pointer allocated at probe, max_message_size 102 * @rx_buff: Receive buffer pointer allocated at probe, max_message_size
85 */ 103 */
@@ -92,6 +110,7 @@ struct ti_queue_inst {
92 void __iomem *queue_buff_start; 110 void __iomem *queue_buff_start;
93 void __iomem *queue_buff_end; 111 void __iomem *queue_buff_end;
94 void __iomem *queue_state; 112 void __iomem *queue_state;
113 void __iomem *queue_ctrl;
95 struct mbox_chan *chan; 114 struct mbox_chan *chan;
96 u32 *rx_buff; 115 u32 *rx_buff;
97}; 116};
@@ -102,6 +121,7 @@ struct ti_queue_inst {
102 * @desc: Description of the SoC integration 121 * @desc: Description of the SoC integration
103 * @queue_proxy_region: Queue proxy region where queue buffers are located 122 * @queue_proxy_region: Queue proxy region where queue buffers are located
104 * @queue_state_debug_region: Queue status register regions 123 * @queue_state_debug_region: Queue status register regions
124 * @queue_ctrl_region: Queue Control register regions
105 * @num_valid_queues: Number of valid queues defined for the processor 125 * @num_valid_queues: Number of valid queues defined for the processor
106 * Note: other queues are probably reserved for other processors 126 * Note: other queues are probably reserved for other processors
107 * in the SoC. 127 * in the SoC.
@@ -114,6 +134,7 @@ struct ti_msgmgr_inst {
114 const struct ti_msgmgr_desc *desc; 134 const struct ti_msgmgr_desc *desc;
115 void __iomem *queue_proxy_region; 135 void __iomem *queue_proxy_region;
116 void __iomem *queue_state_debug_region; 136 void __iomem *queue_state_debug_region;
137 void __iomem *queue_ctrl_region;
117 u8 num_valid_queues; 138 u8 num_valid_queues;
118 struct ti_queue_inst *qinsts; 139 struct ti_queue_inst *qinsts;
119 struct mbox_controller mbox; 140 struct mbox_controller mbox;
@@ -145,6 +166,31 @@ ti_msgmgr_queue_get_num_messages(const struct ti_msgmgr_desc *d,
145} 166}
146 167
147/** 168/**
169 * ti_msgmgr_queue_is_error() - Check to see if there is queue error
170 * @d: Description of message manager
171 * @qinst: Queue instance for which we check the number of pending messages
172 *
173 * Return: true if error, else false
174 */
175static inline bool ti_msgmgr_queue_is_error(const struct ti_msgmgr_desc *d,
176 struct ti_queue_inst *qinst)
177{
178 u32 val;
179
180 /* Msgmgr has no error detection */
181 if (!d->is_sproxy)
182 return false;
183
184 /*
185 * We cannot use relaxed operation here - update may happen
186 * real-time.
187 */
188 val = readl(qinst->queue_state) & d->status_err_mask;
189
190 return val ? true : false;
191}
192
193/**
148 * ti_msgmgr_queue_rx_interrupt() - Interrupt handler for receive Queue 194 * ti_msgmgr_queue_rx_interrupt() - Interrupt handler for receive Queue
149 * @irq: Interrupt number 195 * @irq: Interrupt number
150 * @p: Channel Pointer 196 * @p: Channel Pointer
@@ -178,6 +224,11 @@ static irqreturn_t ti_msgmgr_queue_rx_interrupt(int irq, void *p)
178 } 224 }
179 225
180 desc = inst->desc; 226 desc = inst->desc;
227 if (ti_msgmgr_queue_is_error(desc, qinst)) {
228 dev_err(dev, "Error on Rx channel %s\n", qinst->name);
229 return IRQ_NONE;
230 }
231
181 /* Do I actually have messages to read? */ 232 /* Do I actually have messages to read? */
182 msg_count = ti_msgmgr_queue_get_num_messages(desc, qinst); 233 msg_count = ti_msgmgr_queue_get_num_messages(desc, qinst);
183 if (!msg_count) { 234 if (!msg_count) {
@@ -236,12 +287,18 @@ static bool ti_msgmgr_queue_peek_data(struct mbox_chan *chan)
236 struct ti_queue_inst *qinst = chan->con_priv; 287 struct ti_queue_inst *qinst = chan->con_priv;
237 struct device *dev = chan->mbox->dev; 288 struct device *dev = chan->mbox->dev;
238 struct ti_msgmgr_inst *inst = dev_get_drvdata(dev); 289 struct ti_msgmgr_inst *inst = dev_get_drvdata(dev);
290 const struct ti_msgmgr_desc *desc = inst->desc;
239 int msg_count; 291 int msg_count;
240 292
241 if (qinst->is_tx) 293 if (qinst->is_tx)
242 return false; 294 return false;
243 295
244 msg_count = ti_msgmgr_queue_get_num_messages(inst->desc, qinst); 296 if (ti_msgmgr_queue_is_error(desc, qinst)) {
297 dev_err(dev, "Error on channel %s\n", qinst->name);
298 return false;
299 }
300
301 msg_count = ti_msgmgr_queue_get_num_messages(desc, qinst);
245 302
246 return msg_count ? true : false; 303 return msg_count ? true : false;
247} 304}
@@ -257,12 +314,23 @@ static bool ti_msgmgr_last_tx_done(struct mbox_chan *chan)
257 struct ti_queue_inst *qinst = chan->con_priv; 314 struct ti_queue_inst *qinst = chan->con_priv;
258 struct device *dev = chan->mbox->dev; 315 struct device *dev = chan->mbox->dev;
259 struct ti_msgmgr_inst *inst = dev_get_drvdata(dev); 316 struct ti_msgmgr_inst *inst = dev_get_drvdata(dev);
317 const struct ti_msgmgr_desc *desc = inst->desc;
260 int msg_count; 318 int msg_count;
261 319
262 if (!qinst->is_tx) 320 if (!qinst->is_tx)
263 return false; 321 return false;
264 322
265 msg_count = ti_msgmgr_queue_get_num_messages(inst->desc, qinst); 323 if (ti_msgmgr_queue_is_error(desc, qinst)) {
324 dev_err(dev, "Error on channel %s\n", qinst->name);
325 return false;
326 }
327
328 msg_count = ti_msgmgr_queue_get_num_messages(desc, qinst);
329
330 if (desc->is_sproxy) {
331 /* In secure proxy, msg_count indicates how many we can send */
332 return msg_count ? true : false;
333 }
266 334
267 /* if we have any messages pending.. */ 335 /* if we have any messages pending.. */
268 return msg_count ? false : true; 336 return msg_count ? false : true;
@@ -292,6 +360,11 @@ static int ti_msgmgr_send_data(struct mbox_chan *chan, void *data)
292 } 360 }
293 desc = inst->desc; 361 desc = inst->desc;
294 362
363 if (ti_msgmgr_queue_is_error(desc, qinst)) {
364 dev_err(dev, "Error on channel %s\n", qinst->name);
365 return false;
366 }
367
295 if (desc->max_message_size < message->len) { 368 if (desc->max_message_size < message->len) {
296 dev_err(dev, "Queue %s message length %zu > max %d\n", 369 dev_err(dev, "Queue %s message length %zu > max %d\n",
297 qinst->name, message->len, desc->max_message_size); 370 qinst->name, message->len, desc->max_message_size);
@@ -327,10 +400,12 @@ static int ti_msgmgr_send_data(struct mbox_chan *chan, void *data)
327/** 400/**
328 * ti_msgmgr_queue_rx_irq_req() - RX IRQ request 401 * ti_msgmgr_queue_rx_irq_req() - RX IRQ request
329 * @dev: device pointer 402 * @dev: device pointer
403 * @d: descriptor for ti_msgmgr
330 * @qinst: Queue instance 404 * @qinst: Queue instance
331 * @chan: Channel pointer 405 * @chan: Channel pointer
332 */ 406 */
333static int ti_msgmgr_queue_rx_irq_req(struct device *dev, 407static int ti_msgmgr_queue_rx_irq_req(struct device *dev,
408 const struct ti_msgmgr_desc *d,
334 struct ti_queue_inst *qinst, 409 struct ti_queue_inst *qinst,
335 struct mbox_chan *chan) 410 struct mbox_chan *chan)
336{ 411{
@@ -339,7 +414,7 @@ static int ti_msgmgr_queue_rx_irq_req(struct device *dev,
339 struct device_node *np; 414 struct device_node *np;
340 415
341 snprintf(of_rx_irq_name, sizeof(of_rx_irq_name), 416 snprintf(of_rx_irq_name, sizeof(of_rx_irq_name),
342 "rx_%03d", qinst->queue_id); 417 "rx_%03d", d->is_sproxy ? qinst->proxy_id : qinst->queue_id);
343 418
344 /* Get the IRQ if not found */ 419 /* Get the IRQ if not found */
345 if (qinst->irq < 0) { 420 if (qinst->irq < 0) {
@@ -382,6 +457,24 @@ static int ti_msgmgr_queue_startup(struct mbox_chan *chan)
382 struct ti_queue_inst *qinst = chan->con_priv; 457 struct ti_queue_inst *qinst = chan->con_priv;
383 const struct ti_msgmgr_desc *d = inst->desc; 458 const struct ti_msgmgr_desc *d = inst->desc;
384 int ret; 459 int ret;
460 int msg_count;
461
462 /*
463 * If sproxy is starting and can send messages, we are a Tx thread,
464 * else Rx
465 */
466 if (d->is_sproxy) {
467 qinst->is_tx = (readl(qinst->queue_ctrl) &
468 SPROXY_THREAD_CTRL_DIR_MASK) ? false : true;
469
470 msg_count = ti_msgmgr_queue_get_num_messages(d, qinst);
471
472 if (!msg_count && qinst->is_tx) {
473 dev_err(dev, "%s: Cannot transmit with 0 credits!\n",
474 qinst->name);
475 return -EINVAL;
476 }
477 }
385 478
386 if (!qinst->is_tx) { 479 if (!qinst->is_tx) {
387 /* Allocate usage buffer for rx */ 480 /* Allocate usage buffer for rx */
@@ -389,7 +482,7 @@ static int ti_msgmgr_queue_startup(struct mbox_chan *chan)
389 if (!qinst->rx_buff) 482 if (!qinst->rx_buff)
390 return -ENOMEM; 483 return -ENOMEM;
391 /* Request IRQ */ 484 /* Request IRQ */
392 ret = ti_msgmgr_queue_rx_irq_req(dev, qinst, chan); 485 ret = ti_msgmgr_queue_rx_irq_req(dev, d, qinst, chan);
393 if (ret) { 486 if (ret) {
394 kfree(qinst->rx_buff); 487 kfree(qinst->rx_buff);
395 return ret; 488 return ret;
@@ -427,20 +520,38 @@ static struct mbox_chan *ti_msgmgr_of_xlate(struct mbox_controller *mbox,
427 struct ti_msgmgr_inst *inst; 520 struct ti_msgmgr_inst *inst;
428 int req_qid, req_pid; 521 int req_qid, req_pid;
429 struct ti_queue_inst *qinst; 522 struct ti_queue_inst *qinst;
430 int i; 523 const struct ti_msgmgr_desc *d;
524 int i, ncells;
431 525
432 inst = container_of(mbox, struct ti_msgmgr_inst, mbox); 526 inst = container_of(mbox, struct ti_msgmgr_inst, mbox);
433 if (WARN_ON(!inst)) 527 if (WARN_ON(!inst))
434 return ERR_PTR(-EINVAL); 528 return ERR_PTR(-EINVAL);
435 529
436 /* #mbox-cells is 2 */ 530 d = inst->desc;
437 if (p->args_count != 2) { 531
438 dev_err(inst->dev, "Invalid arguments in dt[%d] instead of 2\n", 532 if (d->is_sproxy)
439 p->args_count); 533 ncells = 1;
534 else
535 ncells = 2;
536 if (p->args_count != ncells) {
537 dev_err(inst->dev, "Invalid arguments in dt[%d]. Must be %d\n",
538 p->args_count, ncells);
440 return ERR_PTR(-EINVAL); 539 return ERR_PTR(-EINVAL);
441 } 540 }
442 req_qid = p->args[0]; 541 if (ncells == 1) {
443 req_pid = p->args[1]; 542 req_qid = 0;
543 req_pid = p->args[0];
544 } else {
545 req_qid = p->args[0];
546 req_pid = p->args[1];
547 }
548
549 if (d->is_sproxy) {
550 if (req_pid > d->num_valid_queues)
551 goto err;
552 qinst = &inst->qinsts[req_pid];
553 return qinst->chan;
554 }
444 555
445 for (qinst = inst->qinsts, i = 0; i < inst->num_valid_queues; 556 for (qinst = inst->qinsts, i = 0; i < inst->num_valid_queues;
446 i++, qinst++) { 557 i++, qinst++) {
@@ -448,6 +559,7 @@ static struct mbox_chan *ti_msgmgr_of_xlate(struct mbox_controller *mbox,
448 return qinst->chan; 559 return qinst->chan;
449 } 560 }
450 561
562err:
451 dev_err(inst->dev, "Queue ID %d, Proxy ID %d is wrong on %s\n", 563 dev_err(inst->dev, "Queue ID %d, Proxy ID %d is wrong on %s\n",
452 req_qid, req_pid, p->np->name); 564 req_qid, req_pid, p->np->name);
453 return ERR_PTR(-ENOENT); 565 return ERR_PTR(-ENOENT);
@@ -474,6 +586,8 @@ static int ti_msgmgr_queue_setup(int idx, struct device *dev,
474 struct ti_queue_inst *qinst, 586 struct ti_queue_inst *qinst,
475 struct mbox_chan *chan) 587 struct mbox_chan *chan)
476{ 588{
589 char *dir;
590
477 qinst->proxy_id = qd->proxy_id; 591 qinst->proxy_id = qd->proxy_id;
478 qinst->queue_id = qd->queue_id; 592 qinst->queue_id = qd->queue_id;
479 593
@@ -483,17 +597,38 @@ static int ti_msgmgr_queue_setup(int idx, struct device *dev,
483 return -ERANGE; 597 return -ERANGE;
484 } 598 }
485 599
486 qinst->is_tx = qd->is_tx; 600 if (d->is_sproxy) {
487 snprintf(qinst->name, sizeof(qinst->name), "%s %s_%03d_%03d", 601 qinst->queue_buff_start = inst->queue_proxy_region +
488 dev_name(dev), qinst->is_tx ? "tx" : "rx", qinst->queue_id, 602 SPROXY_THREAD_DATA_OFFSET(qinst->proxy_id,
489 qinst->proxy_id); 603 d->data_first_reg);
490 604 qinst->queue_buff_end = inst->queue_proxy_region +
491 qinst->queue_buff_start = inst->queue_proxy_region + 605 SPROXY_THREAD_DATA_OFFSET(qinst->proxy_id,
492 Q_DATA_OFFSET(qinst->proxy_id, qinst->queue_id, d->data_first_reg); 606 d->data_last_reg);
493 qinst->queue_buff_end = inst->queue_proxy_region + 607 qinst->queue_state = inst->queue_state_debug_region +
494 Q_DATA_OFFSET(qinst->proxy_id, qinst->queue_id, d->data_last_reg); 608 SPROXY_THREAD_STATUS_OFFSET(qinst->proxy_id);
495 qinst->queue_state = inst->queue_state_debug_region + 609 qinst->queue_ctrl = inst->queue_ctrl_region +
496 Q_STATE_OFFSET(qinst->queue_id); 610 SPROXY_THREAD_CTRL_OFFSET(qinst->proxy_id);
611
612 /* XXX: DONOT read registers here!.. Some may be unusable */
613 dir = "thr";
614 snprintf(qinst->name, sizeof(qinst->name), "%s %s_%03d",
615 dev_name(dev), dir, qinst->proxy_id);
616 } else {
617 qinst->queue_buff_start = inst->queue_proxy_region +
618 Q_DATA_OFFSET(qinst->proxy_id, qinst->queue_id,
619 d->data_first_reg);
620 qinst->queue_buff_end = inst->queue_proxy_region +
621 Q_DATA_OFFSET(qinst->proxy_id, qinst->queue_id,
622 d->data_last_reg);
623 qinst->queue_state =
624 inst->queue_state_debug_region +
625 Q_STATE_OFFSET(qinst->queue_id);
626 qinst->is_tx = qd->is_tx;
627 dir = qinst->is_tx ? "tx" : "rx";
628 snprintf(qinst->name, sizeof(qinst->name), "%s %s_%03d_%03d",
629 dev_name(dev), dir, qinst->queue_id, qinst->proxy_id);
630 }
631
497 qinst->chan = chan; 632 qinst->chan = chan;
498 633
499 /* Setup an error value for IRQ - Lazy allocation */ 634 /* Setup an error value for IRQ - Lazy allocation */
@@ -543,12 +678,29 @@ static const struct ti_msgmgr_desc k2g_desc = {
543 .tx_polled = false, 678 .tx_polled = false,
544 .valid_queues = k2g_valid_queues, 679 .valid_queues = k2g_valid_queues,
545 .num_valid_queues = ARRAY_SIZE(k2g_valid_queues), 680 .num_valid_queues = ARRAY_SIZE(k2g_valid_queues),
681 .is_sproxy = false,
682};
683
684static const struct ti_msgmgr_desc am654_desc = {
685 .queue_count = 190,
686 .num_valid_queues = 190,
687 .max_message_size = 60,
688 .data_region_name = "target_data",
689 .status_region_name = "rt",
690 .ctrl_region_name = "scfg",
691 .data_first_reg = 0,
692 .data_last_reg = 14,
693 .status_cnt_mask = SPROXY_THREAD_STATUS_COUNT_MASK,
694 .tx_polled = false,
695 .is_sproxy = true,
546}; 696};
547 697
548static const struct of_device_id ti_msgmgr_of_match[] = { 698static const struct of_device_id ti_msgmgr_of_match[] = {
549 {.compatible = "ti,k2g-message-manager", .data = &k2g_desc}, 699 {.compatible = "ti,k2g-message-manager", .data = &k2g_desc},
700 {.compatible = "ti,am654-secure-proxy", .data = &am654_desc},
550 { /* Sentinel */ } 701 { /* Sentinel */ }
551}; 702};
703
552MODULE_DEVICE_TABLE(of, ti_msgmgr_of_match); 704MODULE_DEVICE_TABLE(of, ti_msgmgr_of_match);
553 705
554static int ti_msgmgr_probe(struct platform_device *pdev) 706static int ti_msgmgr_probe(struct platform_device *pdev)
@@ -599,6 +751,14 @@ static int ti_msgmgr_probe(struct platform_device *pdev)
599 if (IS_ERR(inst->queue_state_debug_region)) 751 if (IS_ERR(inst->queue_state_debug_region))
600 return PTR_ERR(inst->queue_state_debug_region); 752 return PTR_ERR(inst->queue_state_debug_region);
601 753
754 if (desc->is_sproxy) {
755 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
756 desc->ctrl_region_name);
757 inst->queue_ctrl_region = devm_ioremap_resource(dev, res);
758 if (IS_ERR(inst->queue_ctrl_region))
759 return PTR_ERR(inst->queue_ctrl_region);
760 }
761
602 dev_dbg(dev, "proxy region=%p, queue_state=%p\n", 762 dev_dbg(dev, "proxy region=%p, queue_state=%p\n",
603 inst->queue_proxy_region, inst->queue_state_debug_region); 763 inst->queue_proxy_region, inst->queue_state_debug_region);
604 764
@@ -620,12 +780,29 @@ static int ti_msgmgr_probe(struct platform_device *pdev)
620 return -ENOMEM; 780 return -ENOMEM;
621 inst->chans = chans; 781 inst->chans = chans;
622 782
623 for (i = 0, queue_desc = desc->valid_queues; 783 if (desc->is_sproxy) {
624 i < queue_count; i++, qinst++, chans++, queue_desc++) { 784 struct ti_msgmgr_valid_queue_desc sproxy_desc;
625 ret = ti_msgmgr_queue_setup(i, dev, np, inst, 785
626 desc, queue_desc, qinst, chans); 786 /* All proxies may be valid in Secure Proxy instance */
627 if (ret) 787 for (i = 0; i < queue_count; i++, qinst++, chans++) {
628 return ret; 788 sproxy_desc.queue_id = 0;
789 sproxy_desc.proxy_id = i;
790 ret = ti_msgmgr_queue_setup(i, dev, np, inst,
791 desc, &sproxy_desc, qinst,
792 chans);
793 if (ret)
794 return ret;
795 }
796 } else {
797 /* Only Some proxies are valid in Message Manager */
798 for (i = 0, queue_desc = desc->valid_queues;
799 i < queue_count; i++, qinst++, chans++, queue_desc++) {
800 ret = ti_msgmgr_queue_setup(i, dev, np, inst,
801 desc, queue_desc, qinst,
802 chans);
803 if (ret)
804 return ret;
805 }
629 } 806 }
630 807
631 mbox = &inst->mbox; 808 mbox = &inst->mbox;