The AST2500 has two PCI devices embedded. The XDMA engine can use either
device to perform DMA transfers. Users need the capability to choose
which device to use. This commit therefore adds two sysfs files that
toggle the AST2500 and XDMA engine between the two PCI devices.
Signed-off-by: Eddie James <eajames@xxxxxxxxxxxxx>
---
drivers/soc/aspeed/aspeed-xdma.c | 103 +++++++++++++++++++++++++++++++++++++--
1 file changed, 100 insertions(+), 3 deletions(-)
diff --git a/drivers/soc/aspeed/aspeed-xdma.c b/drivers/soc/aspeed/aspeed-xdma.c
index 39f6545..ddd5e1e 100644
--- a/drivers/soc/aspeed/aspeed-xdma.c
+++ b/drivers/soc/aspeed/aspeed-xdma.c
@@ -143,6 +143,7 @@ struct aspeed_xdma {
void *cmdq_vga_virt;
struct gen_pool *vga_pool;
+ char pcidev[4];
struct miscdevice misc;
};
@@ -165,6 +166,10 @@ struct aspeed_xdma_client {
SCU_PCIE_CONF_VGA_EN_IRQ | SCU_PCIE_CONF_VGA_EN_DMA |
SCU_PCIE_CONF_RSVD;
+static char *_pcidev = "vga";
+module_param_named(pcidev, _pcidev, charp, 0600);
+MODULE_PARM_DESC(pcidev, "Default PCI device used by XDMA engine for DMA ops");
+
static void aspeed_scu_pcie_write(struct aspeed_xdma *ctx, u32 conf)
{
u32 v = 0;
@@ -512,7 +517,7 @@ static int aspeed_xdma_release(struct inode *inode, struct file *file)
.release = aspeed_xdma_release,
};
-static int aspeed_xdma_init_mem(struct aspeed_xdma *ctx)
+static int aspeed_xdma_init_mem(struct aspeed_xdma *ctx, u32 conf)
{
int rc;
u32 scu_conf = 0;
@@ -522,7 +527,7 @@ static int aspeed_xdma_init_mem(struct aspeed_xdma *ctx)
const u32 vga_sizes[4] = { 0x800000, 0x1000000, 0x2000000, 0x4000000 };
void __iomem *sdmc_base = ioremap(0x1e6e0000, 0x100);
- aspeed_scu_pcie_write(ctx, aspeed_xdma_vga_pcie_conf);
+ aspeed_scu_pcie_write(ctx, conf);
regmap_read(ctx->scu, SCU_STRAP, &scu_conf);
ctx->vga_size = vga_sizes[FIELD_GET(SCU_STRAP_VGA_MEM, scu_conf)];
@@ -598,10 +603,91 @@ static int aspeed_xdma_init_mem(struct aspeed_xdma *ctx)
return rc;
}
+static int aspeed_xdma_change_pcie_conf(struct aspeed_xdma *ctx, u32 conf)
+{
+ int rc;
+
+ mutex_lock(&ctx->start_lock);
+ rc = wait_event_interruptible_timeout(ctx->wait,
+ !test_bit(XDMA_IN_PRG,
+ &ctx->flags),
+ msecs_to_jiffies(1000));
+ if (rc < 0) {
+ mutex_unlock(&ctx->start_lock);
+ return -EINTR;
+ }
+
+ /* previous op didn't complete, wake up waiters anyway */
+ if (!rc)
+ wake_up_interruptible_all(&ctx->wait);
+
+ reset_control_assert(ctx->reset);
+ msleep(10);
+
+ aspeed_scu_pcie_write(ctx, conf);
+ msleep(10);
+
+ reset_control_deassert(ctx->reset);
+ msleep(10);
+
+ aspeed_xdma_init_eng(ctx);
+
+ mutex_unlock(&ctx->start_lock);
+
+ return 0;
+}
+
+static int aspeed_xdma_pcidev_to_conf(struct aspeed_xdma *ctx,
+ const char *pcidev, u32 *conf)
+{
+ if (!strcasecmp(pcidev, "vga")) {
+ *conf = aspeed_xdma_vga_pcie_conf;
+ return 0;
+ }
+
+ if (!strcasecmp(pcidev, "bmc")) {
+ *conf = aspeed_xdma_bmc_pcie_conf;
+ return 0;
+ }