summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun P. Mohanan <arun.p.m@linux.intel.com>2021-03-18 13:18:09 +0300
committerJae Hyun Yoo <jae.hyun.yoo@linux.intel.com>2021-11-05 10:22:15 +0300
commitce5e97f06c185fd6896fa9273c44fcfe6bf550b0 (patch)
tree9d6dbfc97ac14d4dc6b68fd3ebe45c3a78409bf6
parent17857adb5c4644cb75e0c362745cd89ae9767774 (diff)
downloadlinux-ce5e97f06c185fd6896fa9273c44fcfe6bf550b0.tar.xz
mailbox: ioctl to fetch mailbox size
The size of mailbox differ from AST2500, AST2600 A0 and A1. Add an ioctl support to fetch the mailbox size. Tested: Verfied ioctl call returns mailbox size as expected. Change-Id: I4e261aaf8aa3fb108d6ad152d30a17b114d70ccd Signed-off-by: Arun P. Mohanan <arun.p.m@linux.intel.com>
-rw-r--r--Documentation/userspace-api/ioctl/ioctl-number.rst1
-rw-r--r--drivers/soc/aspeed/aspeed-lpc-mbox.c20
-rw-r--r--include/uapi/linux/aspeed-lpc-mbox.h11
3 files changed, 32 insertions, 0 deletions
diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst b/Documentation/userspace-api/ioctl/ioctl-number.rst
index 85b4b2020787..fa1a8521a09a 100644
--- a/Documentation/userspace-api/ioctl/ioctl-number.rst
+++ b/Documentation/userspace-api/ioctl/ioctl-number.rst
@@ -321,6 +321,7 @@ Code Seq# Include File Comments
<mailto:kenji@bitgate.com>
0xA1 0 linux/vtpm_proxy.h TPM Emulator Proxy Driver
0xA2 all uapi/linux/acrn.h ACRN hypervisor
+0xA3 00 include/uapi/linux/aspeed-lpc-mbox.h
0xA3 80-8F Port ACL in development:
<mailto:tlewis@mindspring.com>
0xA3 90-9F linux/dtlk.h
diff --git a/drivers/soc/aspeed/aspeed-lpc-mbox.c b/drivers/soc/aspeed/aspeed-lpc-mbox.c
index d9030f986fe4..76f0c7933bf7 100644
--- a/drivers/soc/aspeed/aspeed-lpc-mbox.c
+++ b/drivers/soc/aspeed/aspeed-lpc-mbox.c
@@ -2,6 +2,7 @@
// Copyright 2017 IBM Corporation
// TODO: Rewrite this driver
+#include <linux/aspeed-lpc-mbox.h>
#include <linux/clk.h>
#include <linux/interrupt.h>
#include <linux/mfd/syscon.h>
@@ -260,6 +261,24 @@ static int aspeed_mbox_release(struct inode *inode, struct file *file)
return 0;
}
+static long aspeed_mbox_ioctl(struct file *file, unsigned int cmd,
+ unsigned long param)
+{
+ struct aspeed_mbox *mbox = file_mbox(file);
+ struct aspeed_mbox_ioctl_data data;
+ long ret;
+
+ switch (cmd) {
+ case ASPEED_MBOX_SIZE:
+ data.data = mbox->configs.num_regs;
+ ret = copy_to_user((void __user *)param, &data, sizeof(data));
+ break;
+ default:
+ ret = -ENOTTY;
+ }
+ return ret;
+}
+
static const struct file_operations aspeed_mbox_fops = {
.owner = THIS_MODULE,
.llseek = no_seek_end_llseek,
@@ -268,6 +287,7 @@ static const struct file_operations aspeed_mbox_fops = {
.open = aspeed_mbox_open,
.release = aspeed_mbox_release,
.poll = aspeed_mbox_poll,
+ .unlocked_ioctl = aspeed_mbox_ioctl,
};
static irqreturn_t aspeed_mbox_irq(int irq, void *arg)
diff --git a/include/uapi/linux/aspeed-lpc-mbox.h b/include/uapi/linux/aspeed-lpc-mbox.h
new file mode 100644
index 000000000000..dbb8a7f24222
--- /dev/null
+++ b/include/uapi/linux/aspeed-lpc-mbox.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later WITH Linux-syscall-note */
+/* Copyright (c) 2021 Intel Corporation */
+
+struct aspeed_mbox_ioctl_data {
+ unsigned int data;
+};
+
+#define ASPEED_MBOX_IOCTL_BASE 0xA3
+
+#define ASPEED_MBOX_SIZE \
+ _IOR(ASPEED_MBOX_IOCTL_BASE, 0, struct aspeed_mbox_ioctl_data)