summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2016-02-11 11:26:05 +0300
committerJoel Stanley <joel@jms.id.au>2016-02-12 07:38:57 +0300
commitebbb4eea8a7b65d3e8643ad31da2867a993c1d7c (patch)
tree222a73aca70444f3bbbef7017c12350915f406dc
parent5a75991b263a16d994a3f30c5d7f831809dc4894 (diff)
downloadlinux-ebbb4eea8a7b65d3e8643ad31da2867a993c1d7c.tar.xz
serial/aspeed-vuart: Perform enable/disable on driver bind/unbindopenbmc-20160212-1
Rather than exposing an enable sysfs attribute, we can just set the VUART enabled bit when we bind to the device, and clear it on unbind. We don't want to do this on open/release, as the host may be using this bit to configure serial output modes, which is independent of whether the devices has been opened by BMC userspace. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Joel Stanley <joel@jms.id.au>
-rw-r--r--drivers/tty/serial/aspeed-vuart.c53
1 files changed, 14 insertions, 39 deletions
diff --git a/drivers/tty/serial/aspeed-vuart.c b/drivers/tty/serial/aspeed-vuart.c
index 73bb0e74fa0f..020c8159d25d 100644
--- a/drivers/tty/serial/aspeed-vuart.c
+++ b/drivers/tty/serial/aspeed-vuart.c
@@ -35,42 +35,6 @@ struct ast_vuart {
int line;
};
-static ssize_t ast_vuart_show_enabled(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct ast_vuart *vuart = dev_get_drvdata(dev);
- u8 reg;
-
- reg = readb(vuart->regs + AST_VUART_GCRA) & AST_VUART_GCRA_VUART_EN;
-
- return snprintf(buf, PAGE_SIZE - 1, "%u\n", reg ? 1 : 0);
-}
-
-static ssize_t ast_vuart_set_enabled(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct ast_vuart *vuart = dev_get_drvdata(dev);
- unsigned long val;
- int err;
- u8 reg;
-
- err = kstrtoul(buf, 0, &val);
- if (err)
- return err;
-
- reg = readb(vuart->regs + AST_VUART_GCRA);
- reg &= ~AST_VUART_GCRA_VUART_EN;
- if (val)
- reg |= AST_VUART_GCRA_VUART_EN;
- writeb(reg, vuart->regs + AST_VUART_GCRA);
-
- return count;
-}
-
-static DEVICE_ATTR(enabled, S_IWUSR | S_IRUGO,
- ast_vuart_show_enabled, ast_vuart_set_enabled);
-
static ssize_t ast_vuart_show_addr(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -144,6 +108,17 @@ static ssize_t ast_vuart_set_sirq(struct device *dev,
static DEVICE_ATTR(sirq, S_IWUSR | S_IRUGO,
ast_vuart_show_sirq, ast_vuart_set_sirq);
+static void ast_vuart_set_enabled(struct ast_vuart *vuart, bool enabled)
+{
+ u8 reg;
+
+ reg = readb(vuart->regs + AST_VUART_GCRA);
+ reg &= ~AST_VUART_GCRA_VUART_EN;
+ if (enabled)
+ reg |= AST_VUART_GCRA_VUART_EN;
+ writeb(reg, vuart->regs + AST_VUART_GCRA);
+}
+
static void ast_vuart_set_host_tx_discard(struct ast_vuart *vuart, bool discard)
{
u8 reg;
@@ -304,6 +279,7 @@ static int ast_vuart_probe(struct platform_device *pdev)
vuart->line = rc;
+ ast_vuart_set_enabled(vuart, true);
ast_vuart_set_host_tx_discard(vuart, true);
platform_set_drvdata(pdev, vuart);
@@ -314,9 +290,6 @@ static int ast_vuart_probe(struct platform_device *pdev)
rc = device_create_file(&pdev->dev, &dev_attr_sirq);
if (rc)
dev_warn(&pdev->dev, "can't create sirq file\n");
- rc = device_create_file(&pdev->dev, &dev_attr_enabled);
- if (rc)
- dev_warn(&pdev->dev, "can't create enabled file\n");
return 0;
@@ -332,6 +305,8 @@ static int ast_vuart_remove(struct platform_device *pdev)
{
struct ast_vuart *vuart = platform_get_drvdata(pdev);
+ ast_vuart_set_enabled(vuart, false);
+
if (vuart->clk)
clk_disable_unprepare(vuart->clk);
return 0;