2 * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 #include <linux/delay.h>
15 #include <linux/interrupt.h>
17 #include <linux/mailbox_controller.h>
19 #include <linux/of_device.h>
20 #include <linux/platform_device.h>
22 #include <linux/slab.h>
24 #include <dt-bindings/mailbox/tegra186-hsp.h>
28 #define HSP_INT_IE(x) (0x100 + ((x) * 4))
29 #define HSP_INT_IV 0x300
30 #define HSP_INT_IR 0x304
32 #define HSP_INT_EMPTY_SHIFT 0
33 #define HSP_INT_EMPTY_MASK 0xff
34 #define HSP_INT_FULL_SHIFT 8
35 #define HSP_INT_FULL_MASK 0xff
37 #define HSP_INT_DIMENSIONING 0x380
38 #define HSP_nSM_SHIFT 0
39 #define HSP_nSS_SHIFT 4
40 #define HSP_nAS_SHIFT 8
41 #define HSP_nDB_SHIFT 12
42 #define HSP_nSI_SHIFT 16
43 #define HSP_nINT_MASK 0xf
45 #define HSP_DB_TRIGGER 0x0
46 #define HSP_DB_ENABLE 0x4
47 #define HSP_DB_RAW 0x8
48 #define HSP_DB_PENDING 0xc
50 #define HSP_SM_SHRD_MBOX 0x0
51 #define HSP_SM_SHRD_MBOX_FULL BIT(31)
52 #define HSP_SM_SHRD_MBOX_FULL_INT_IE 0x04
53 #define HSP_SM_SHRD_MBOX_EMPTY_INT_IE 0x08
55 #define HSP_DB_CCPLEX 1
59 struct tegra_hsp_channel
;
62 struct tegra_hsp_channel
{
63 struct tegra_hsp
*hsp
;
64 struct mbox_chan
*chan
;
68 struct tegra_hsp_doorbell
{
69 struct tegra_hsp_channel channel
;
70 struct list_head list
;
76 struct tegra_hsp_mailbox
{
77 struct tegra_hsp_channel channel
;
82 struct tegra_hsp_db_map
{
88 struct tegra_hsp_soc
{
89 const struct tegra_hsp_db_map
*map
;
95 const struct tegra_hsp_soc
*soc
;
96 struct mbox_controller mbox_db
;
97 struct mbox_controller mbox_sm
;
99 unsigned int doorbell_irq
;
100 unsigned int *shared_irqs
;
101 unsigned int shared_irq
;
109 struct list_head doorbells
;
110 struct tegra_hsp_mailbox
*mailboxes
;
115 static inline u32
tegra_hsp_readl(struct tegra_hsp
*hsp
, unsigned int offset
)
117 return readl(hsp
->regs
+ offset
);
120 static inline void tegra_hsp_writel(struct tegra_hsp
*hsp
, u32 value
,
123 writel(value
, hsp
->regs
+ offset
);
126 static inline u32
tegra_hsp_channel_readl(struct tegra_hsp_channel
*channel
,
129 return readl(channel
->regs
+ offset
);
132 static inline void tegra_hsp_channel_writel(struct tegra_hsp_channel
*channel
,
133 u32 value
, unsigned int offset
)
135 writel(value
, channel
->regs
+ offset
);
138 static bool tegra_hsp_doorbell_can_ring(struct tegra_hsp_doorbell
*db
)
142 value
= tegra_hsp_channel_readl(&db
->channel
, HSP_DB_ENABLE
);
144 return (value
& BIT(TEGRA_HSP_DB_MASTER_CCPLEX
)) != 0;
147 static struct tegra_hsp_doorbell
*
148 __tegra_hsp_doorbell_get(struct tegra_hsp
*hsp
, unsigned int master
)
150 struct tegra_hsp_doorbell
*entry
;
152 list_for_each_entry(entry
, &hsp
->doorbells
, list
)
153 if (entry
->master
== master
)
159 static struct tegra_hsp_doorbell
*
160 tegra_hsp_doorbell_get(struct tegra_hsp
*hsp
, unsigned int master
)
162 struct tegra_hsp_doorbell
*db
;
165 spin_lock_irqsave(&hsp
->lock
, flags
);
166 db
= __tegra_hsp_doorbell_get(hsp
, master
);
167 spin_unlock_irqrestore(&hsp
->lock
, flags
);
172 static irqreturn_t
tegra_hsp_doorbell_irq(int irq
, void *data
)
174 struct tegra_hsp
*hsp
= data
;
175 struct tegra_hsp_doorbell
*db
;
176 unsigned long master
, value
;
178 db
= tegra_hsp_doorbell_get(hsp
, TEGRA_HSP_DB_MASTER_CCPLEX
);
182 value
= tegra_hsp_channel_readl(&db
->channel
, HSP_DB_PENDING
);
183 tegra_hsp_channel_writel(&db
->channel
, value
, HSP_DB_PENDING
);
185 spin_lock(&hsp
->lock
);
187 for_each_set_bit(master
, &value
, hsp
->mbox_db
.num_chans
) {
188 struct tegra_hsp_doorbell
*db
;
190 db
= __tegra_hsp_doorbell_get(hsp
, master
);
192 * Depending on the bootloader chain, the CCPLEX doorbell will
193 * have some doorbells enabled, which means that requesting an
194 * interrupt will immediately fire.
196 * In that case, db->channel.chan will still be NULL here and
197 * cause a crash if not properly guarded.
199 * It remains to be seen if ignoring the doorbell in that case
200 * is the correct solution.
202 if (db
&& db
->channel
.chan
)
203 mbox_chan_received_data(db
->channel
.chan
, NULL
);
206 spin_unlock(&hsp
->lock
);
211 static irqreturn_t
tegra_hsp_shared_irq(int irq
, void *data
)
213 struct tegra_hsp
*hsp
= data
;
214 unsigned long bit
, mask
;
218 status
= tegra_hsp_readl(hsp
, HSP_INT_IR
) & hsp
->mask
;
220 /* process EMPTY interrupts first */
221 mask
= (status
>> HSP_INT_EMPTY_SHIFT
) & HSP_INT_EMPTY_MASK
;
223 for_each_set_bit(bit
, &mask
, hsp
->num_sm
) {
224 struct tegra_hsp_mailbox
*mb
= &hsp
->mailboxes
[bit
];
228 * Disable EMPTY interrupts until data is sent with
229 * the next message. These interrupts are level-
230 * triggered, so if we kept them enabled they would
231 * constantly trigger until we next write data into
234 spin_lock(&hsp
->lock
);
236 hsp
->mask
&= ~BIT(HSP_INT_EMPTY_SHIFT
+ mb
->index
);
237 tegra_hsp_writel(hsp
, hsp
->mask
,
238 HSP_INT_IE(hsp
->shared_irq
));
240 spin_unlock(&hsp
->lock
);
242 mbox_chan_txdone(mb
->channel
.chan
, 0);
246 /* process FULL interrupts */
247 mask
= (status
>> HSP_INT_FULL_SHIFT
) & HSP_INT_FULL_MASK
;
249 for_each_set_bit(bit
, &mask
, hsp
->num_sm
) {
250 struct tegra_hsp_mailbox
*mb
= &hsp
->mailboxes
[bit
];
253 value
= tegra_hsp_channel_readl(&mb
->channel
,
255 value
&= ~HSP_SM_SHRD_MBOX_FULL
;
256 msg
= (void *)(unsigned long)value
;
257 mbox_chan_received_data(mb
->channel
.chan
, msg
);
260 * Need to clear all bits here since some producers,
261 * such as TCU, depend on fields in the register
262 * getting cleared by the consumer.
264 * The mailbox API doesn't give the consumers a way
265 * of doing that explicitly, so we have to make sure
266 * we cover all possible cases.
268 tegra_hsp_channel_writel(&mb
->channel
, 0x0,
276 static struct tegra_hsp_channel
*
277 tegra_hsp_doorbell_create(struct tegra_hsp
*hsp
, const char *name
,
278 unsigned int master
, unsigned int index
)
280 struct tegra_hsp_doorbell
*db
;
284 db
= devm_kzalloc(hsp
->dev
, sizeof(*db
), GFP_KERNEL
);
286 return ERR_PTR(-ENOMEM
);
288 offset
= (1 + (hsp
->num_sm
/ 2) + hsp
->num_ss
+ hsp
->num_as
) * SZ_64K
;
289 offset
+= index
* 0x100;
291 db
->channel
.regs
= hsp
->regs
+ offset
;
292 db
->channel
.hsp
= hsp
;
294 db
->name
= devm_kstrdup_const(hsp
->dev
, name
, GFP_KERNEL
);
298 spin_lock_irqsave(&hsp
->lock
, flags
);
299 list_add_tail(&db
->list
, &hsp
->doorbells
);
300 spin_unlock_irqrestore(&hsp
->lock
, flags
);
305 static int tegra_hsp_doorbell_send_data(struct mbox_chan
*chan
, void *data
)
307 struct tegra_hsp_doorbell
*db
= chan
->con_priv
;
309 tegra_hsp_channel_writel(&db
->channel
, 1, HSP_DB_TRIGGER
);
314 static int tegra_hsp_doorbell_startup(struct mbox_chan
*chan
)
316 struct tegra_hsp_doorbell
*db
= chan
->con_priv
;
317 struct tegra_hsp
*hsp
= db
->channel
.hsp
;
318 struct tegra_hsp_doorbell
*ccplex
;
322 if (db
->master
>= chan
->mbox
->num_chans
) {
323 dev_err(chan
->mbox
->dev
,
324 "invalid master ID %u for HSP channel\n",
329 ccplex
= tegra_hsp_doorbell_get(hsp
, TEGRA_HSP_DB_MASTER_CCPLEX
);
333 if (!tegra_hsp_doorbell_can_ring(db
))
336 spin_lock_irqsave(&hsp
->lock
, flags
);
338 value
= tegra_hsp_channel_readl(&ccplex
->channel
, HSP_DB_ENABLE
);
339 value
|= BIT(db
->master
);
340 tegra_hsp_channel_writel(&ccplex
->channel
, value
, HSP_DB_ENABLE
);
342 spin_unlock_irqrestore(&hsp
->lock
, flags
);
347 static void tegra_hsp_doorbell_shutdown(struct mbox_chan
*chan
)
349 struct tegra_hsp_doorbell
*db
= chan
->con_priv
;
350 struct tegra_hsp
*hsp
= db
->channel
.hsp
;
351 struct tegra_hsp_doorbell
*ccplex
;
355 ccplex
= tegra_hsp_doorbell_get(hsp
, TEGRA_HSP_DB_MASTER_CCPLEX
);
359 spin_lock_irqsave(&hsp
->lock
, flags
);
361 value
= tegra_hsp_channel_readl(&ccplex
->channel
, HSP_DB_ENABLE
);
362 value
&= ~BIT(db
->master
);
363 tegra_hsp_channel_writel(&ccplex
->channel
, value
, HSP_DB_ENABLE
);
365 spin_unlock_irqrestore(&hsp
->lock
, flags
);
368 static const struct mbox_chan_ops tegra_hsp_db_ops
= {
369 .send_data
= tegra_hsp_doorbell_send_data
,
370 .startup
= tegra_hsp_doorbell_startup
,
371 .shutdown
= tegra_hsp_doorbell_shutdown
,
374 static int tegra_hsp_mailbox_send_data(struct mbox_chan
*chan
, void *data
)
376 struct tegra_hsp_mailbox
*mb
= chan
->con_priv
;
377 struct tegra_hsp
*hsp
= mb
->channel
.hsp
;
381 if (WARN_ON(!mb
->producer
))
384 /* copy data and mark mailbox full */
385 value
= (u32
)(unsigned long)data
;
386 value
|= HSP_SM_SHRD_MBOX_FULL
;
388 tegra_hsp_channel_writel(&mb
->channel
, value
, HSP_SM_SHRD_MBOX
);
390 /* enable EMPTY interrupt for the shared mailbox */
391 spin_lock_irqsave(&hsp
->lock
, flags
);
393 hsp
->mask
|= BIT(HSP_INT_EMPTY_SHIFT
+ mb
->index
);
394 tegra_hsp_writel(hsp
, hsp
->mask
, HSP_INT_IE(hsp
->shared_irq
));
396 spin_unlock_irqrestore(&hsp
->lock
, flags
);
401 static int tegra_hsp_mailbox_flush(struct mbox_chan
*chan
,
402 unsigned long timeout
)
404 struct tegra_hsp_mailbox
*mb
= chan
->con_priv
;
405 struct tegra_hsp_channel
*ch
= &mb
->channel
;
408 timeout
= jiffies
+ msecs_to_jiffies(timeout
);
410 while (time_before(jiffies
, timeout
)) {
411 value
= tegra_hsp_channel_readl(ch
, HSP_SM_SHRD_MBOX
);
412 if ((value
& HSP_SM_SHRD_MBOX_FULL
) == 0) {
413 mbox_chan_txdone(chan
, 0);
423 static int tegra_hsp_mailbox_startup(struct mbox_chan
*chan
)
425 struct tegra_hsp_mailbox
*mb
= chan
->con_priv
;
426 struct tegra_hsp_channel
*ch
= &mb
->channel
;
427 struct tegra_hsp
*hsp
= mb
->channel
.hsp
;
430 chan
->txdone_method
= TXDONE_BY_IRQ
;
433 * Shared mailboxes start out as consumers by default. FULL and EMPTY
434 * interrupts are coalesced at the same shared interrupt.
436 * Keep EMPTY interrupts disabled at startup and only enable them when
437 * the mailbox is actually full. This is required because the FULL and
438 * EMPTY interrupts are level-triggered, so keeping EMPTY interrupts
439 * enabled all the time would cause an interrupt storm while mailboxes
443 spin_lock_irqsave(&hsp
->lock
, flags
);
446 hsp
->mask
&= ~BIT(HSP_INT_EMPTY_SHIFT
+ mb
->index
);
448 hsp
->mask
|= BIT(HSP_INT_FULL_SHIFT
+ mb
->index
);
450 tegra_hsp_writel(hsp
, hsp
->mask
, HSP_INT_IE(hsp
->shared_irq
));
452 spin_unlock_irqrestore(&hsp
->lock
, flags
);
454 if (hsp
->soc
->has_per_mb_ie
) {
456 tegra_hsp_channel_writel(ch
, 0x0,
457 HSP_SM_SHRD_MBOX_EMPTY_INT_IE
);
459 tegra_hsp_channel_writel(ch
, 0x1,
460 HSP_SM_SHRD_MBOX_FULL_INT_IE
);
466 static void tegra_hsp_mailbox_shutdown(struct mbox_chan
*chan
)
468 struct tegra_hsp_mailbox
*mb
= chan
->con_priv
;
469 struct tegra_hsp_channel
*ch
= &mb
->channel
;
470 struct tegra_hsp
*hsp
= mb
->channel
.hsp
;
473 if (hsp
->soc
->has_per_mb_ie
) {
475 tegra_hsp_channel_writel(ch
, 0x0,
476 HSP_SM_SHRD_MBOX_EMPTY_INT_IE
);
478 tegra_hsp_channel_writel(ch
, 0x0,
479 HSP_SM_SHRD_MBOX_FULL_INT_IE
);
482 spin_lock_irqsave(&hsp
->lock
, flags
);
485 hsp
->mask
&= ~BIT(HSP_INT_EMPTY_SHIFT
+ mb
->index
);
487 hsp
->mask
&= ~BIT(HSP_INT_FULL_SHIFT
+ mb
->index
);
489 tegra_hsp_writel(hsp
, hsp
->mask
, HSP_INT_IE(hsp
->shared_irq
));
491 spin_unlock_irqrestore(&hsp
->lock
, flags
);
494 static const struct mbox_chan_ops tegra_hsp_sm_ops
= {
495 .send_data
= tegra_hsp_mailbox_send_data
,
496 .flush
= tegra_hsp_mailbox_flush
,
497 .startup
= tegra_hsp_mailbox_startup
,
498 .shutdown
= tegra_hsp_mailbox_shutdown
,
501 static struct mbox_chan
*tegra_hsp_db_xlate(struct mbox_controller
*mbox
,
502 const struct of_phandle_args
*args
)
504 struct tegra_hsp
*hsp
= container_of(mbox
, struct tegra_hsp
, mbox_db
);
505 unsigned int type
= args
->args
[0], master
= args
->args
[1];
506 struct tegra_hsp_channel
*channel
= ERR_PTR(-ENODEV
);
507 struct tegra_hsp_doorbell
*db
;
508 struct mbox_chan
*chan
;
512 if (type
!= TEGRA_HSP_MBOX_TYPE_DB
|| !hsp
->doorbell_irq
)
513 return ERR_PTR(-ENODEV
);
515 db
= tegra_hsp_doorbell_get(hsp
, master
);
517 channel
= &db
->channel
;
520 return ERR_CAST(channel
);
522 spin_lock_irqsave(&hsp
->lock
, flags
);
524 for (i
= 0; i
< mbox
->num_chans
; i
++) {
525 chan
= &mbox
->chans
[i
];
526 if (!chan
->con_priv
) {
527 channel
->chan
= chan
;
535 spin_unlock_irqrestore(&hsp
->lock
, flags
);
537 return chan
?: ERR_PTR(-EBUSY
);
540 static struct mbox_chan
*tegra_hsp_sm_xlate(struct mbox_controller
*mbox
,
541 const struct of_phandle_args
*args
)
543 struct tegra_hsp
*hsp
= container_of(mbox
, struct tegra_hsp
, mbox_sm
);
544 unsigned int type
= args
->args
[0], index
;
545 struct tegra_hsp_mailbox
*mb
;
547 index
= args
->args
[1] & TEGRA_HSP_SM_MASK
;
549 if (type
!= TEGRA_HSP_MBOX_TYPE_SM
|| !hsp
->shared_irqs
||
550 index
>= hsp
->num_sm
)
551 return ERR_PTR(-ENODEV
);
553 mb
= &hsp
->mailboxes
[index
];
555 if ((args
->args
[1] & TEGRA_HSP_SM_FLAG_TX
) == 0)
556 mb
->producer
= false;
560 return mb
->channel
.chan
;
563 static int tegra_hsp_add_doorbells(struct tegra_hsp
*hsp
)
565 const struct tegra_hsp_db_map
*map
= hsp
->soc
->map
;
566 struct tegra_hsp_channel
*channel
;
569 channel
= tegra_hsp_doorbell_create(hsp
, map
->name
,
570 map
->master
, map
->index
);
572 return PTR_ERR(channel
);
580 static int tegra_hsp_add_mailboxes(struct tegra_hsp
*hsp
, struct device
*dev
)
584 hsp
->mailboxes
= devm_kcalloc(dev
, hsp
->num_sm
, sizeof(*hsp
->mailboxes
),
589 for (i
= 0; i
< hsp
->num_sm
; i
++) {
590 struct tegra_hsp_mailbox
*mb
= &hsp
->mailboxes
[i
];
594 mb
->channel
.hsp
= hsp
;
595 mb
->channel
.regs
= hsp
->regs
+ SZ_64K
+ i
* SZ_32K
;
596 mb
->channel
.chan
= &hsp
->mbox_sm
.chans
[i
];
597 mb
->channel
.chan
->con_priv
= mb
;
603 static int tegra_hsp_request_shared_irq(struct tegra_hsp
*hsp
)
605 unsigned int i
, irq
= 0;
608 for (i
= 0; i
< hsp
->num_si
; i
++) {
609 irq
= hsp
->shared_irqs
[i
];
613 err
= devm_request_irq(hsp
->dev
, irq
, tegra_hsp_shared_irq
, 0,
614 dev_name(hsp
->dev
), hsp
);
616 dev_err(hsp
->dev
, "failed to request interrupt: %d\n",
623 /* disable all interrupts */
624 tegra_hsp_writel(hsp
, 0, HSP_INT_IE(hsp
->shared_irq
));
626 dev_dbg(hsp
->dev
, "interrupt requested: %u\n", irq
);
631 if (i
== hsp
->num_si
) {
632 dev_err(hsp
->dev
, "failed to find available interrupt\n");
639 static int tegra_hsp_probe(struct platform_device
*pdev
)
641 struct tegra_hsp
*hsp
;
642 struct resource
*res
;
647 hsp
= devm_kzalloc(&pdev
->dev
, sizeof(*hsp
), GFP_KERNEL
);
651 hsp
->dev
= &pdev
->dev
;
652 hsp
->soc
= of_device_get_match_data(&pdev
->dev
);
653 INIT_LIST_HEAD(&hsp
->doorbells
);
654 spin_lock_init(&hsp
->lock
);
656 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
657 hsp
->regs
= devm_ioremap_resource(&pdev
->dev
, res
);
658 if (IS_ERR(hsp
->regs
))
659 return PTR_ERR(hsp
->regs
);
661 value
= tegra_hsp_readl(hsp
, HSP_INT_DIMENSIONING
);
662 hsp
->num_sm
= (value
>> HSP_nSM_SHIFT
) & HSP_nINT_MASK
;
663 hsp
->num_ss
= (value
>> HSP_nSS_SHIFT
) & HSP_nINT_MASK
;
664 hsp
->num_as
= (value
>> HSP_nAS_SHIFT
) & HSP_nINT_MASK
;
665 hsp
->num_db
= (value
>> HSP_nDB_SHIFT
) & HSP_nINT_MASK
;
666 hsp
->num_si
= (value
>> HSP_nSI_SHIFT
) & HSP_nINT_MASK
;
668 err
= platform_get_irq_byname(pdev
, "doorbell");
670 hsp
->doorbell_irq
= err
;
672 if (hsp
->num_si
> 0) {
673 unsigned int count
= 0;
675 hsp
->shared_irqs
= devm_kcalloc(&pdev
->dev
, hsp
->num_si
,
676 sizeof(*hsp
->shared_irqs
),
678 if (!hsp
->shared_irqs
)
681 for (i
= 0; i
< hsp
->num_si
; i
++) {
684 name
= kasprintf(GFP_KERNEL
, "shared%u", i
);
688 err
= platform_get_irq_byname(pdev
, name
);
690 hsp
->shared_irqs
[i
] = err
;
698 devm_kfree(&pdev
->dev
, hsp
->shared_irqs
);
699 hsp
->shared_irqs
= NULL
;
703 /* setup the doorbell controller */
704 hsp
->mbox_db
.of_xlate
= tegra_hsp_db_xlate
;
705 hsp
->mbox_db
.num_chans
= 32;
706 hsp
->mbox_db
.dev
= &pdev
->dev
;
707 hsp
->mbox_db
.ops
= &tegra_hsp_db_ops
;
709 hsp
->mbox_db
.chans
= devm_kcalloc(&pdev
->dev
, hsp
->mbox_db
.num_chans
,
710 sizeof(*hsp
->mbox_db
.chans
),
712 if (!hsp
->mbox_db
.chans
)
715 if (hsp
->doorbell_irq
) {
716 err
= tegra_hsp_add_doorbells(hsp
);
718 dev_err(&pdev
->dev
, "failed to add doorbells: %d\n",
724 err
= devm_mbox_controller_register(&pdev
->dev
, &hsp
->mbox_db
);
726 dev_err(&pdev
->dev
, "failed to register doorbell mailbox: %d\n",
731 /* setup the shared mailbox controller */
732 hsp
->mbox_sm
.of_xlate
= tegra_hsp_sm_xlate
;
733 hsp
->mbox_sm
.num_chans
= hsp
->num_sm
;
734 hsp
->mbox_sm
.dev
= &pdev
->dev
;
735 hsp
->mbox_sm
.ops
= &tegra_hsp_sm_ops
;
737 hsp
->mbox_sm
.chans
= devm_kcalloc(&pdev
->dev
, hsp
->mbox_sm
.num_chans
,
738 sizeof(*hsp
->mbox_sm
.chans
),
740 if (!hsp
->mbox_sm
.chans
)
743 if (hsp
->shared_irqs
) {
744 err
= tegra_hsp_add_mailboxes(hsp
, &pdev
->dev
);
746 dev_err(&pdev
->dev
, "failed to add mailboxes: %d\n",
752 err
= devm_mbox_controller_register(&pdev
->dev
, &hsp
->mbox_sm
);
754 dev_err(&pdev
->dev
, "failed to register shared mailbox: %d\n",
759 platform_set_drvdata(pdev
, hsp
);
761 if (hsp
->doorbell_irq
) {
762 err
= devm_request_irq(&pdev
->dev
, hsp
->doorbell_irq
,
763 tegra_hsp_doorbell_irq
, IRQF_NO_SUSPEND
,
764 dev_name(&pdev
->dev
), hsp
);
767 "failed to request doorbell IRQ#%u: %d\n",
768 hsp
->doorbell_irq
, err
);
773 if (hsp
->shared_irqs
) {
774 err
= tegra_hsp_request_shared_irq(hsp
);
782 static int tegra_hsp_resume(struct device
*dev
)
784 struct tegra_hsp
*hsp
= dev_get_drvdata(dev
);
787 for (i
= 0; i
< hsp
->num_sm
; i
++) {
788 struct tegra_hsp_mailbox
*mb
= &hsp
->mailboxes
[i
];
790 if (mb
->channel
.chan
->cl
)
791 tegra_hsp_mailbox_startup(mb
->channel
.chan
);
797 static SIMPLE_DEV_PM_OPS(tegra_hsp_pm_ops
, NULL
, tegra_hsp_resume
);
799 static const struct tegra_hsp_db_map tegra186_hsp_db_map
[] = {
800 { "ccplex", TEGRA_HSP_DB_MASTER_CCPLEX
, HSP_DB_CCPLEX
, },
801 { "bpmp", TEGRA_HSP_DB_MASTER_BPMP
, HSP_DB_BPMP
, },
805 static const struct tegra_hsp_soc tegra186_hsp_soc
= {
806 .map
= tegra186_hsp_db_map
,
807 .has_per_mb_ie
= false,
810 static const struct tegra_hsp_soc tegra194_hsp_soc
= {
811 .map
= tegra186_hsp_db_map
,
812 .has_per_mb_ie
= true,
815 static const struct of_device_id tegra_hsp_match
[] = {
816 { .compatible
= "nvidia,tegra186-hsp", .data
= &tegra186_hsp_soc
},
817 { .compatible
= "nvidia,tegra194-hsp", .data
= &tegra194_hsp_soc
},
821 static struct platform_driver tegra_hsp_driver
= {
824 .of_match_table
= tegra_hsp_match
,
825 .pm
= &tegra_hsp_pm_ops
,
827 .probe
= tegra_hsp_probe
,
830 static int __init
tegra_hsp_init(void)
832 return platform_driver_register(&tegra_hsp_driver
);
834 core_initcall(tegra_hsp_init
);