aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKishon Vijay Abraham I2019-03-01 05:19:50 -0600
committerSekhar Nori2019-03-04 04:33:02 -0600
commitb566bb21d554cfd0c8c22dd12257ff82bdc6f610 (patch)
tree855077a6f8450f2f549ed1d9d0f781cc90e342dc
parent5286a95f0cbd661d0c6bad4b17a6d0b1e05399cd (diff)
downloadafd-analog-b566bb21d554cfd0c8c22dd12257ff82bdc6f610.tar.gz
afd-analog-b566bb21d554cfd0c8c22dd12257ff82bdc6f610.tar.xz
afd-analog-b566bb21d554cfd0c8c22dd12257ff82bdc6f610.zip
misc: pci_endpoint_test: Add support to test PCI EP in K2G
TI's K2G EP has the following restrictions: *) BAR_0 of k2g EP is mapped to application registers so pci_endpoint_test cannot use it. (Use BAR_1 instead). (Ref 11.14.4.9.2 Inbound Address Translation in K2G TRM SPRUHY8F January 2016 – Revised May 2017) *) K2G EP requires host buffer addresses to be aligned to 1MB boundary. (Ref: 11.14.4.9.1 Outbound Address Translation in K2G TRM SPRUHY8F January 2016 – Revised May 2017) *) K2G EP requires RC to program the PCI address in PCIE_IB_START_LO/PCIE_IB_START_HI registers. (Ref 11.14.4.9.2 Inbound Address Translation in K2G TRM SPRUHY8F January 2016 – Revised May 2017) Accommodate these restrictions in pci_endpoint_test in order to use it to test K2G EP. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Sekhar Nori <nsekhar@ti.com>
-rw-r--r--drivers/misc/pci_endpoint_test.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
index 46788fe854e4..8ac78e76d54c 100644
--- a/drivers/misc/pci_endpoint_test.c
+++ b/drivers/misc/pci_endpoint_test.c
@@ -76,10 +76,16 @@
76#define PCI_ENDPOINT_TEST_IRQ_NUMBER 0x28 76#define PCI_ENDPOINT_TEST_IRQ_NUMBER 0x28
77 77
78#define PCI_DEVICE_ID_TI_AM654 0xb00c 78#define PCI_DEVICE_ID_TI_AM654 0xb00c
79#define PCI_DEVICE_ID_TI_K2G 0xb00b
79 80
80#define is_am654_pci_dev(pdev) \ 81#define is_am654_pci_dev(pdev) \
81 ((pdev)->device == PCI_DEVICE_ID_TI_AM654) 82 ((pdev)->device == PCI_DEVICE_ID_TI_AM654)
82 83
84#define K2G_IB_START_L0(n) (0x304 + (0x10 * (n)))
85#define K2G_IB_START_HI(n) (0x308 + (0x10 * (n)))
86
87#define is_k2g_pci_dev(pdev) ((pdev)->device == PCI_DEVICE_ID_TI_K2G)
88
83static DEFINE_IDA(pci_endpoint_test_ida); 89static DEFINE_IDA(pci_endpoint_test_ida);
84 90
85#define to_endpoint_test(priv) container_of((priv), struct pci_endpoint_test, \ 91#define to_endpoint_test(priv) container_of((priv), struct pci_endpoint_test, \
@@ -601,7 +607,8 @@ static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd,
601 bar = arg; 607 bar = arg;
602 if (bar < 0 || bar > 5) 608 if (bar < 0 || bar > 5)
603 goto ret; 609 goto ret;
604 if (is_am654_pci_dev(pdev) && bar == BAR_0) 610 if ((is_am654_pci_dev(pdev) || is_k2g_pci_dev(pdev)) &&
611 bar == BAR_0)
605 goto ret; 612 goto ret;
606 ret = pci_endpoint_test_bar(test, bar); 613 ret = pci_endpoint_test_bar(test, bar);
607 break; 614 break;
@@ -639,6 +646,28 @@ static const struct file_operations pci_endpoint_test_fops = {
639 .unlocked_ioctl = pci_endpoint_test_ioctl, 646 .unlocked_ioctl = pci_endpoint_test_ioctl,
640}; 647};
641 648
649static int pci_endpoint_test_k2g_init(struct pci_endpoint_test *test)
650{
651 struct pci_dev *pdev = test->pdev;
652 enum pci_barno bar;
653 resource_size_t start;
654
655 if (!test->bar[0])
656 return -EINVAL;
657
658 for (bar = BAR_1; bar <= BAR_5; bar++) {
659 start = pci_resource_start(pdev, bar);
660 pci_endpoint_test_bar_writel(test, BAR_0,
661 K2G_IB_START_L0(bar - 1),
662 lower_32_bits(start));
663 pci_endpoint_test_bar_writel(test, BAR_0,
664 K2G_IB_START_HI(bar - 1),
665 upper_32_bits(start));
666 }
667
668 return 0;
669}
670
642static int pci_endpoint_test_probe(struct pci_dev *pdev, 671static int pci_endpoint_test_probe(struct pci_dev *pdev,
643 const struct pci_device_id *ent) 672 const struct pci_device_id *ent)
644{ 673{
@@ -717,6 +746,12 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
717 goto err_iounmap; 746 goto err_iounmap;
718 } 747 }
719 748
749 if (is_k2g_pci_dev(pdev)) {
750 err = pci_endpoint_test_k2g_init(test);
751 if (err)
752 goto err_iounmap;
753 }
754
720 pci_set_drvdata(pdev, test); 755 pci_set_drvdata(pdev, test);
721 756
722 id = ida_simple_get(&pci_endpoint_test_ida, 0, 0, GFP_KERNEL); 757 id = ida_simple_get(&pci_endpoint_test_ida, 0, 0, GFP_KERNEL);
@@ -799,6 +834,11 @@ static const struct pci_endpoint_test_data am654_data = {
799 .alignment = SZ_64K, 834 .alignment = SZ_64K,
800}; 835};
801 836
837static const struct pci_endpoint_test_data k2g_data = {
838 .test_reg_bar = BAR_1,
839 .alignment = SZ_1M,
840};
841
802static const struct pci_device_id pci_endpoint_test_tbl[] = { 842static const struct pci_device_id pci_endpoint_test_tbl[] = {
803 { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA74x) }, 843 { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA74x) },
804 { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA72x) }, 844 { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_DRA72x) },
@@ -806,6 +846,9 @@ static const struct pci_device_id pci_endpoint_test_tbl[] = {
806 { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_AM654), 846 { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_AM654),
807 .driver_data = (kernel_ulong_t)&am654_data 847 .driver_data = (kernel_ulong_t)&am654_data
808 }, 848 },
849 { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_K2G),
850 .driver_data = (kernel_ulong_t)&k2g_data
851 },
809 { } 852 { }
810}; 853};
811MODULE_DEVICE_TABLE(pci, pci_endpoint_test_tbl); 854MODULE_DEVICE_TABLE(pci, pci_endpoint_test_tbl);