Merge tag 'char-misc-5.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregk...
[linux-2.6-microblaze.git] / drivers / bus / mhi / pci_generic.c
index 4dd1077..59a4896 100644 (file)
@@ -32,6 +32,7 @@
  * @edl: emergency download mode firmware path (if any)
  * @bar_num: PCI base address register to use for MHI MMIO register space
  * @dma_data_width: DMA transfer word size (32 or 64 bits)
+ * @mru_default: default MRU size for MBIM network packets
  * @sideband_wake: Devices using dedicated sideband GPIO for wakeup instead
  *                of inband wake support (such as sdx24)
  */
@@ -42,6 +43,7 @@ struct mhi_pci_dev_info {
        const char *edl;
        unsigned int bar_num;
        unsigned int dma_data_width;
+       unsigned int mru_default;
        bool sideband_wake;
 };
 
@@ -272,6 +274,7 @@ static const struct mhi_pci_dev_info mhi_qcom_sdx55_info = {
        .config = &modem_qcom_v1_mhiv_config,
        .bar_num = MHI_PCI_DEFAULT_BAR_NUM,
        .dma_data_width = 32,
+       .mru_default = 32768,
        .sideband_wake = false,
 };
 
@@ -366,6 +369,40 @@ static const struct mhi_pci_dev_info mhi_foxconn_sdx55_info = {
        .sideband_wake = false,
 };
 
+static const struct mhi_channel_config mhi_mv31_channels[] = {
+       MHI_CHANNEL_CONFIG_UL(0, "LOOPBACK", 64, 0),
+       MHI_CHANNEL_CONFIG_DL(1, "LOOPBACK", 64, 0),
+       /* MBIM Control Channel */
+       MHI_CHANNEL_CONFIG_UL(12, "MBIM", 64, 0),
+       MHI_CHANNEL_CONFIG_DL(13, "MBIM", 64, 0),
+       /* MBIM Data Channel */
+       MHI_CHANNEL_CONFIG_HW_UL(100, "IP_HW0_MBIM", 512, 2),
+       MHI_CHANNEL_CONFIG_HW_DL(101, "IP_HW0_MBIM", 512, 3),
+};
+
+static struct mhi_event_config mhi_mv31_events[] = {
+       MHI_EVENT_CONFIG_CTRL(0, 256),
+       MHI_EVENT_CONFIG_DATA(1, 256),
+       MHI_EVENT_CONFIG_HW_DATA(2, 1024, 100),
+       MHI_EVENT_CONFIG_HW_DATA(3, 1024, 101),
+};
+
+static const struct mhi_controller_config modem_mv31_config = {
+       .max_channels = 128,
+       .timeout_ms = 20000,
+       .num_channels = ARRAY_SIZE(mhi_mv31_channels),
+       .ch_cfg = mhi_mv31_channels,
+       .num_events = ARRAY_SIZE(mhi_mv31_events),
+       .event_cfg = mhi_mv31_events,
+};
+
+static const struct mhi_pci_dev_info mhi_mv31_info = {
+       .name = "cinterion-mv31",
+       .config = &modem_mv31_config,
+       .bar_num = MHI_PCI_DEFAULT_BAR_NUM,
+       .dma_data_width = 32,
+};
+
 static const struct pci_device_id mhi_pci_id_table[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_QCOM, 0x0306),
                .driver_data = (kernel_ulong_t) &mhi_qcom_sdx55_info },
@@ -386,6 +423,9 @@ static const struct pci_device_id mhi_pci_id_table[] = {
        /* DW5930e (sdx55), Non-eSIM, It's also T99W175 */
        { PCI_DEVICE(PCI_VENDOR_ID_FOXCONN, 0xe0b1),
                .driver_data = (kernel_ulong_t) &mhi_foxconn_sdx55_info },
+       /* MV31-W (Cinterion) */
+       { PCI_DEVICE(0x1269, 0x00b3),
+               .driver_data = (kernel_ulong_t) &mhi_mv31_info },
        {  }
 };
 MODULE_DEVICE_TABLE(pci, mhi_pci_id_table);
@@ -487,6 +527,7 @@ static int mhi_pci_claim(struct mhi_controller *mhi_cntrl,
                return err;
        }
        mhi_cntrl->regs = pcim_iomap_table(pdev)[bar_num];
+       mhi_cntrl->reg_len = pci_resource_len(pdev, bar_num);
 
        err = pci_set_dma_mask(pdev, dma_mask);
        if (err) {
@@ -664,6 +705,7 @@ static int mhi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        mhi_cntrl->status_cb = mhi_pci_status_cb;
        mhi_cntrl->runtime_get = mhi_pci_runtime_get;
        mhi_cntrl->runtime_put = mhi_pci_runtime_put;
+       mhi_cntrl->mru = info->mru_default;
 
        if (info->sideband_wake) {
                mhi_cntrl->wake_get = mhi_pci_wake_get_nop;