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@intel.com>2021-07-14 20:10:33 +0300
commite296d7049f4e899db4fb4918c8f4c4831bed3b1d (patch)
treefdcc005f86d9897e14c3f46eaae0a74bcb61a407
parentb421703ceafe83f6d9ab74bcddefc3aad3f18124 (diff)
downloadlinux-e296d7049f4e899db4fb4918c8f4c4831bed3b1d.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 0f6af0bdc24b..c4a6cdf4dd06 100644
--- a/Documentation/userspace-api/ioctl/ioctl-number.rst
+++ b/Documentation/userspace-api/ioctl/ioctl-number.rst
@@ -319,6 +319,7 @@ Code Seq# Include File Comments
0xA0 all linux/sdp/sdp.h Industrial Device Project
<mailto:kenji@bitgate.com>
0xA1 0 linux/vtpm_proxy.h TPM Emulator Proxy Driver
+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 8dd3345682c7..9f2c15b28890 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)