Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mailbox: tegra-hsp: Add 128-bit shared mailbox support

Add support for 128-bit shared mailboxes found on Tegra234 chips.

Signed-off-by: Kartik <kkartik@nvidia.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>

authored by

Kartik and committed by
Jassi Brar
74c20dd0 58919326

+74 -3
+74 -3
drivers/mailbox/tegra-hsp.c
··· 46 46 #define HSP_SM_SHRD_MBOX_FULL_INT_IE 0x04 47 47 #define HSP_SM_SHRD_MBOX_EMPTY_INT_IE 0x08 48 48 49 + #define HSP_SHRD_MBOX_TYPE1_TAG 0x40 50 + #define HSP_SHRD_MBOX_TYPE1_DATA0 0x48 51 + #define HSP_SHRD_MBOX_TYPE1_DATA1 0x4c 52 + #define HSP_SHRD_MBOX_TYPE1_DATA2 0x50 53 + #define HSP_SHRD_MBOX_TYPE1_DATA3 0x54 54 + 49 55 #define HSP_DB_CCPLEX 1 50 56 #define HSP_DB_BPMP 3 51 57 #define HSP_DB_MAX 7 58 + 59 + #define HSP_MBOX_TYPE_MASK 0xff 52 60 53 61 struct tegra_hsp_channel; 54 62 struct tegra_hsp; ··· 96 88 struct tegra_hsp_soc { 97 89 const struct tegra_hsp_db_map *map; 98 90 bool has_per_mb_ie; 91 + bool has_128_bit_mb; 99 92 }; 100 93 101 94 struct tegra_hsp { ··· 405 396 .recv = tegra_hsp_sm_recv32, 406 397 }; 407 398 399 + static void tegra_hsp_sm_send128(struct tegra_hsp_channel *channel, void *data) 400 + { 401 + u32 value[4]; 402 + 403 + memcpy(value, data, sizeof(value)); 404 + 405 + /* Copy data */ 406 + tegra_hsp_channel_writel(channel, value[0], HSP_SHRD_MBOX_TYPE1_DATA0); 407 + tegra_hsp_channel_writel(channel, value[1], HSP_SHRD_MBOX_TYPE1_DATA1); 408 + tegra_hsp_channel_writel(channel, value[2], HSP_SHRD_MBOX_TYPE1_DATA2); 409 + tegra_hsp_channel_writel(channel, value[3], HSP_SHRD_MBOX_TYPE1_DATA3); 410 + 411 + /* Update tag to mark mailbox full */ 412 + tegra_hsp_channel_writel(channel, HSP_SM_SHRD_MBOX_FULL, 413 + HSP_SHRD_MBOX_TYPE1_TAG); 414 + } 415 + 416 + static void tegra_hsp_sm_recv128(struct tegra_hsp_channel *channel) 417 + { 418 + u32 value[4]; 419 + void *msg; 420 + 421 + value[0] = tegra_hsp_channel_readl(channel, HSP_SHRD_MBOX_TYPE1_DATA0); 422 + value[1] = tegra_hsp_channel_readl(channel, HSP_SHRD_MBOX_TYPE1_DATA1); 423 + value[2] = tegra_hsp_channel_readl(channel, HSP_SHRD_MBOX_TYPE1_DATA2); 424 + value[3] = tegra_hsp_channel_readl(channel, HSP_SHRD_MBOX_TYPE1_DATA3); 425 + 426 + msg = (void *)(unsigned long)value; 427 + mbox_chan_received_data(channel->chan, msg); 428 + 429 + /* 430 + * Clear data registers and tag. 431 + */ 432 + tegra_hsp_channel_writel(channel, 0x0, HSP_SHRD_MBOX_TYPE1_DATA0); 433 + tegra_hsp_channel_writel(channel, 0x0, HSP_SHRD_MBOX_TYPE1_DATA1); 434 + tegra_hsp_channel_writel(channel, 0x0, HSP_SHRD_MBOX_TYPE1_DATA2); 435 + tegra_hsp_channel_writel(channel, 0x0, HSP_SHRD_MBOX_TYPE1_DATA3); 436 + tegra_hsp_channel_writel(channel, 0x0, HSP_SHRD_MBOX_TYPE1_TAG); 437 + } 438 + 439 + static const struct tegra_hsp_sm_ops tegra_hsp_sm_128bit_ops = { 440 + .send = tegra_hsp_sm_send128, 441 + .recv = tegra_hsp_sm_recv128, 442 + }; 443 + 408 444 static int tegra_hsp_mailbox_send_data(struct mbox_chan *chan, void *data) 409 445 { 410 446 struct tegra_hsp_mailbox *mb = chan->con_priv; ··· 625 571 626 572 index = args->args[1] & TEGRA_HSP_SM_MASK; 627 573 628 - if (type != TEGRA_HSP_MBOX_TYPE_SM || !hsp->shared_irqs || 629 - index >= hsp->num_sm) 574 + if ((type & HSP_MBOX_TYPE_MASK) != TEGRA_HSP_MBOX_TYPE_SM || 575 + !hsp->shared_irqs || index >= hsp->num_sm) 630 576 return ERR_PTR(-ENODEV); 631 577 632 578 mb = &hsp->mailboxes[index]; 633 - mb->ops = &tegra_hsp_sm_32bit_ops; 579 + 580 + if (type & TEGRA_HSP_MBOX_TYPE_SM_128BIT) { 581 + if (!hsp->soc->has_128_bit_mb) 582 + return ERR_PTR(-ENODEV); 583 + 584 + mb->ops = &tegra_hsp_sm_128bit_ops; 585 + } else { 586 + mb->ops = &tegra_hsp_sm_32bit_ops; 587 + } 634 588 635 589 if ((args->args[1] & TEGRA_HSP_SM_FLAG_TX) == 0) 636 590 mb->producer = false; ··· 915 853 static const struct tegra_hsp_soc tegra186_hsp_soc = { 916 854 .map = tegra186_hsp_db_map, 917 855 .has_per_mb_ie = false, 856 + .has_128_bit_mb = false, 918 857 }; 919 858 920 859 static const struct tegra_hsp_soc tegra194_hsp_soc = { 921 860 .map = tegra186_hsp_db_map, 922 861 .has_per_mb_ie = true, 862 + .has_128_bit_mb = false, 863 + }; 864 + 865 + static const struct tegra_hsp_soc tegra234_hsp_soc = { 866 + .map = tegra186_hsp_db_map, 867 + .has_per_mb_ie = false, 868 + .has_128_bit_mb = true, 923 869 }; 924 870 925 871 static const struct of_device_id tegra_hsp_match[] = { 926 872 { .compatible = "nvidia,tegra186-hsp", .data = &tegra186_hsp_soc }, 927 873 { .compatible = "nvidia,tegra194-hsp", .data = &tegra194_hsp_soc }, 874 + { .compatible = "nvidia,tegra234-hsp", .data = &tegra234_hsp_soc }, 928 875 { } 929 876 }; 930 877