From patchwork Wed Sep 16 08:34:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 312231 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp251933ilg; Wed, 16 Sep 2020 01:34:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3Qh0uOnGTA27XoDzLsKcOnfqy1B50Hs5hMaqL2hhZ7v5Bpf5woBjeQZXCGiZHyOQw4TxL X-Received: by 2002:a62:3146:0:b029:13e:d13d:a13a with SMTP id x67-20020a6231460000b029013ed13da13amr21091173pfx.34.1600245268381; Wed, 16 Sep 2020 01:34:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600245268; cv=none; d=google.com; s=arc-20160816; b=VLLjvUNfTQ+HjxHw9oOvX6FHpXveGGDjMdZKh/SLoRKBOsjR96pemB0Q0lRRqT+EJ0 uDW8hKlw2fRgW8i/3cxAwCXSAdkEJKNUvcjcqJBosKvdZa8SsuQhPwbneJ/zU8fZVUsA xjzEvtsfn9686hMirGALYkX8nmAhGoX7AGeCkNAtLYDNwPvFJ5YqR0wQS4mLQi9zzMkt JP1EHNv0ijNnE9AD6HI3QZuNud8hJ4yWmYTmLWXrj0afnVGlBKweJnc/QeQC/2lQ8zrR H6eQ/jURJNFRF45fNC10AW2NQ8J5yepb7NYSm+76txH6dvnWY5lF84L5XHRj0jnai75U V0+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:message-id:date:subject:to:from :dkim-signature:delivered-to; bh=FRCGkhqc0Az5Th7TJq00UdskxxR720PwqODMJ/CfUuc=; b=zcGccyuaBN32HMJevzECp4G0z5DJRNHIN63CwULmH1GLiXnwnLaC+Qk8JbqlPw/NPa vkFJRBrWwqns2Atnj/Qet4ui2l+UILKBXMNDojcN7CQ6I8n7BPFNK9a8uKKPhZARaFHS bFNzqyrEYShlwL2KXsj4QmZdNiVAI2j+uSmldFFrYxvLeSl83W8XUukOed+4rqlMoPxt zwIIEpenXaXpDduwkGF08s9+CkjGNktqLeyDp7vDNnPyZmWmWwMuJhLsfItWu7IpIA2E RAiJV2fPgTm67et6L1sth5UY4UE7pyBeAqQLv4NAYV5laNIVB0pp5APQA7xj8noqhIdd vGBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=MlmerPIq; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id d12si13042054pfd.299.2020.09.16.01.34.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 01:34:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=MlmerPIq; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 39F726E388; Wed, 16 Sep 2020 08:34:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4CC396E384 for ; Wed, 16 Sep 2020 08:34:24 +0000 (UTC) Received: by mail-pj1-x1044.google.com with SMTP id b17so1172417pji.1 for ; Wed, 16 Sep 2020 01:34:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vcKxZphnJRmQ71TIoliF/aQqaJ43RnyH3JVqst80hzY=; b=MlmerPIqUhxTvZFzwst6kBbKun5we9SveOnWePFa45PYAFh/Vti+wbUkXBSLkfOrq2 g/lKhHx/ar0xPs8myAu/r9z5KqH1THnE6g/Sdj7Tef0Ms5kEWcGepxPDFJdW7awiM6wx YNM2sDdG9yGU0hzZ96nOQxrL+/wC5xGykSEDArB/tnQV1v+FwVq0qoGieza1eXFC1AxZ Py+NPbvAFv4+7C5OnKeG3WYms87LkgIfHadkyt/q54JYYgWdrGGTUvsZjXFIYewoVSaV uefDkxAsnP3AbbP1jORnCQ3pNNkYJQWJXPwFBKKNCYEOtXUFo7GnsrbsVijgy2ii3niW qI2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=vcKxZphnJRmQ71TIoliF/aQqaJ43RnyH3JVqst80hzY=; b=RJHugJmwUiyLrpNtyY/1pjOlXUDbYvsUTWE3yVmlKOVBlXHfpYDMgplxJjOGAgtZ2z BRXu8d3oN74latI896djh5/cBE3pnlfNchgRcO6KqZ6IkjIHdF6ZmRRFovOYdgZQG0N4 IR3dgl70WAYDs8BlTXuvcsKc0OKvRI6/Af4BzTyS87udAHVquuKARhXPAwm7x7WfIcqa MezLZUqtD/zEtWlIKS0cXHasIrGCCetaPfIrC5AMZx62g5Lq1/Uo4uGlrBQGKE+R4Zia 7grUUdHwfsS6F8FI4sKNlvk55bq4eD1OnPdMgVYnSdLaivz3kRM4QDl+FGnn37G7grSu CzBQ== X-Gm-Message-State: AOAM532SNTCYWigjbZFJ0VJXK2YqgylpkSa4w027oEA4yWznJ18Uzs4c fLDBeZqOPAdi4gDSHVQ3cT4= X-Received: by 2002:a17:90a:e02:: with SMTP id v2mr2950760pje.6.1600245263856; Wed, 16 Sep 2020 01:34:23 -0700 (PDT) Received: from localhost.localdomain ([45.124.203.18]) by smtp.gmail.com with ESMTPSA id fz22sm1858130pjb.46.2020.09.16.01.34.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 01:34:22 -0700 (PDT) From: Joel Stanley To: David Airlie , Daniel Vetter , Andrew Jeffery Subject: [PATCH] drm/aspeed: Add sysfs for output settings Date: Wed, 16 Sep 2020 18:04:13 +0930 Message-Id: <20200916083413.777307-1-joel@jms.id.au> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-aspeed@lists.ozlabs.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" These settings are used by an ASPEED BMC to determine when the host is trying to drive the display over PCIe (vga_pw) and to switch the output between PCIe and the internal graphics device (dac_mux). The valid values for the dac mux are: 00: VGA mode (default, aka PCIe) 01: Graphics CRT (aka BMC internal graphics, this driver) 10: Pass through mode from video input port A 11: Pass through mode from video input port B Values for the read-only vga password register are: 1: Host driving the display 0: Host not driving the display Signed-off-by: Joel Stanley --- drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 71 +++++++++++++++++++++++++ 1 file changed, 71 insertions(+) -- 2.28.0 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel Reviewed-by: Andrew Jeffery diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c index 903f4f304647..9e06a3683f8a 100644 --- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c @@ -205,6 +205,69 @@ static const struct of_device_id aspeed_gfx_match[] = { { } }; +#define ASPEED_SCU_VGA0 0x50 +#define ASPEED_SCU_MISC_CTRL 0x2c + +static ssize_t dac_mux_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct aspeed_gfx *priv = dev_get_drvdata(dev); + u32 val; + int rc; + + rc = kstrtou32(buf, 0, &val); + if (rc) + return rc; + + if (val < 0 || val > 3) + return -EINVAL; + + rc = regmap_update_bits(priv->scu, ASPEED_SCU_MISC_CTRL, 0x30000, val << 16); + if (rc < 0) + return 0; + + return count; +} + +static ssize_t dac_mux_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct aspeed_gfx *priv = dev_get_drvdata(dev); + u32 reg; + int rc; + + rc = regmap_read(priv->scu, ASPEED_SCU_MISC_CTRL, ®); + if (rc) + return rc; + + return sprintf(buf, "%u\n", (reg >> 16) & 0x3); +} +static DEVICE_ATTR_RW(dac_mux); + +static ssize_t +vga_pw_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct aspeed_gfx *priv = dev_get_drvdata(dev); + u32 reg; + int rc; + + rc = regmap_read(priv->scu, ASPEED_SCU_VGA0, ®); + if (rc) + return rc; + + return sprintf(buf, "%u\n", reg & 1); +} +static DEVICE_ATTR_RO(vga_pw); + +static struct attribute *aspeed_sysfs_entries[] = { + &dev_attr_vga_pw.attr, + &dev_attr_dac_mux.attr, + NULL, +}; + +static struct attribute_group aspeed_sysfs_attr_group = { + .attrs = aspeed_sysfs_entries, +}; + static int aspeed_gfx_probe(struct platform_device *pdev) { struct aspeed_gfx *priv; @@ -219,6 +282,12 @@ static int aspeed_gfx_probe(struct platform_device *pdev) if (ret) return ret; + dev_set_drvdata(&pdev->dev, priv); + + ret = sysfs_create_group(&pdev->dev.kobj, &aspeed_sysfs_attr_group); + if (ret) + return ret; + ret = drm_dev_register(&priv->drm, 0); if (ret) goto err_unload; @@ -227,6 +296,7 @@ static int aspeed_gfx_probe(struct platform_device *pdev) return 0; err_unload: + sysfs_remove_group(&pdev->dev.kobj, &aspeed_sysfs_attr_group); aspeed_gfx_unload(&priv->drm); return ret; @@ -236,6 +306,7 @@ static int aspeed_gfx_remove(struct platform_device *pdev) { struct drm_device *drm = platform_get_drvdata(pdev); + sysfs_remove_group(&pdev->dev.kobj, &aspeed_sysfs_attr_group); drm_dev_unregister(drm); aspeed_gfx_unload(drm);