Merge "serial: msm_geni_serial: Add Sysfs entry for user commands"
This commit is contained in:
commit
486f331a84
@ -203,6 +203,9 @@ static bool con_enabled = IS_ENABLED(CONFIG_SERIAL_MSM_GENI_CONSOLE_DEFAULT_ENAB
|
||||
|
||||
#define SUSPEND_RETRY_COUNT (50)
|
||||
|
||||
/*1.1 version specifies that is support both ioctl as well as sysfs*/
|
||||
#define HS_UART_DRIVER_VERSION "1.1"
|
||||
|
||||
#define CREATE_TRACE_POINTS
|
||||
#include "serial_trace.h"
|
||||
|
||||
@ -449,6 +452,7 @@ struct msm_geni_serial_port {
|
||||
struct uart_kpi_capture uart_kpi_tx[UART_KPI_TX_RX_INSTANCES];
|
||||
struct uart_kpi_capture uart_kpi_rx[UART_KPI_TX_RX_INSTANCES];
|
||||
enum uart_port_state port_state;
|
||||
int hs_uart_operation;
|
||||
};
|
||||
|
||||
static const struct uart_ops msm_geni_serial_pops;
|
||||
@ -479,6 +483,8 @@ static unsigned char uart_line_id;
|
||||
static int msm_geni_serial_config_baud_rate(struct uart_port *uport,
|
||||
struct ktermios *termios,
|
||||
unsigned int baud);
|
||||
static int msm_geni_serial_ioctl(struct uart_port *uport, unsigned int cmd,
|
||||
unsigned long arg);
|
||||
|
||||
#define GET_DEV_PORT(uport) \
|
||||
container_of(uport, struct msm_geni_serial_port, uport)
|
||||
@ -1039,6 +1045,101 @@ static ssize_t loopback_store(struct device *dev,
|
||||
|
||||
static DEVICE_ATTR_RW(loopback);
|
||||
|
||||
/*
|
||||
* hs_uart_operation_show() - read last uart operation status value.
|
||||
*
|
||||
* @dev: pointer to device dev
|
||||
* @attr: attributes associatd with dev
|
||||
* @buf: output buffer
|
||||
*
|
||||
* Return: Size copied in the buffer
|
||||
*/
|
||||
static ssize_t hs_uart_operation_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
struct msm_geni_serial_port *port = platform_get_drvdata(pdev);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%d\n", port->hs_uart_operation);
|
||||
}
|
||||
|
||||
/*
|
||||
* hs_uart_operation_store() - write command in sysfs which further forward it to ioctl function.
|
||||
*
|
||||
* @dev: pointer to device dev
|
||||
* @attr: attributes associatd with dev
|
||||
* @buf: input buffer
|
||||
* @size: size of the buffer
|
||||
*
|
||||
* Return: Size copied in the buffer
|
||||
*/
|
||||
static ssize_t hs_uart_operation_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf,
|
||||
size_t size)
|
||||
{
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
struct msm_geni_serial_port *port = platform_get_drvdata(pdev);
|
||||
u16 cmd = 0;
|
||||
int ret = -ENOIOCTLCMD;
|
||||
|
||||
if (kstrtou16(buf, 16, &cmd)) {
|
||||
UART_LOG_DBG(port->ipc_log_misc, port->uport.dev, "%s: Invalid input\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
UART_LOG_DBG(port->ipc_log_misc, port->uport.dev, "%s: cmd: %u\n", __func__, cmd);
|
||||
|
||||
ret = msm_geni_serial_ioctl(&port->uport, cmd, 0);
|
||||
|
||||
switch (cmd) {
|
||||
case MSM_GENI_SERIAL_TIOCFAULT:
|
||||
case MSM_GENI_SERIAL_TIOCPMACT:
|
||||
/*
|
||||
* No need to check return value as it returns
|
||||
* status value and it can be non-zero as well
|
||||
*/
|
||||
break;
|
||||
|
||||
default:
|
||||
if (ret) {
|
||||
UART_LOG_DBG(port->ipc_log_misc, port->uport.dev,
|
||||
"%s: Can not perform operation cmd: 0x%x ret: %d\n",
|
||||
__func__, cmd, ret);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
port->hs_uart_operation = ret;
|
||||
return size;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR_RW(hs_uart_operation);
|
||||
|
||||
/*
|
||||
* hs_uart_version_show() - read version of the driver which further defines driver
|
||||
* compatibility of ioctl and/or sysfs.
|
||||
*
|
||||
* @dev: pointer to device dev
|
||||
* @attr: attributes associatd with dev
|
||||
* @buf: output buffer
|
||||
*
|
||||
* Return: Size copied in the buffer
|
||||
*/
|
||||
static ssize_t hs_uart_version_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
struct msm_geni_serial_port *port = platform_get_drvdata(pdev);
|
||||
|
||||
UART_LOG_DBG(port->ipc_log_misc, port->uport.dev, "%s: Version: %s\n",
|
||||
__func__, HS_UART_DRIVER_VERSION);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%s\n", HS_UART_DRIVER_VERSION);
|
||||
}
|
||||
|
||||
static DEVICE_ATTR_RO(hs_uart_version);
|
||||
|
||||
static void dump_ipc(struct uart_port *uport, void *ipc_ctx, char *prefix,
|
||||
char *string, u64 addr, int size)
|
||||
|
||||
@ -5246,6 +5347,8 @@ static int msm_geni_serial_probe(struct platform_device *pdev)
|
||||
device_create_file(uport->dev, &dev_attr_xfer_mode);
|
||||
device_create_file(uport->dev, &dev_attr_ver_info);
|
||||
device_create_file(uport->dev, &dev_attr_capture_kpi);
|
||||
device_create_file(uport->dev, &dev_attr_hs_uart_operation);
|
||||
device_create_file(uport->dev, &dev_attr_hs_uart_version);
|
||||
|
||||
msm_geni_serial_debug_init(uport, is_console);
|
||||
dev_port->port_setup = false;
|
||||
@ -5308,6 +5411,8 @@ static int msm_geni_serial_remove(struct platform_device *pdev)
|
||||
device_remove_file(port->uport.dev, &dev_attr_xfer_mode);
|
||||
device_remove_file(port->uport.dev, &dev_attr_ver_info);
|
||||
device_remove_file(port->uport.dev, &dev_attr_capture_kpi);
|
||||
device_remove_file(port->uport.dev, &dev_attr_hs_uart_version);
|
||||
device_remove_file(port->uport.dev, &dev_attr_hs_uart_operation);
|
||||
debugfs_remove(port->dbg);
|
||||
|
||||
dev_info(&pdev->dev, "%s driver removed %d\n", __func__, true);
|
||||
|
Loading…
Reference in New Issue
Block a user