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: 11779317 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AF24E6CA for ; Wed, 16 Sep 2020 08:34:43 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7C2FB206DC for ; Wed, 16 Sep 2020 08:34:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ua2rNqN2"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MlmerPIq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C2FB206DC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=rm7UZS+R0G4zJT6Ux5mosM6Pmwod/syJDpSJ7RDgYMs=; b=Ua2rNqN2aXqA0eY+OXFVGse6Bn tv2H9t+OKEw5tcCy+xXSUBRDsO3l6S3JhUZN9hY2cpWryoog809+G+psQLAbIdHtAn9zsqdhwuFVX DNUGTfsATPMLrxIcAi7JjEoeqfk7fNysxi1bxfBZWYemxGKw7EXZNUxSi69J0T6P29fh0+fWEZeRL BvnbdxAjohLdF2b2yzX8XvMkFS7w/x5JWCwBl1OmltcBWn3Cv4KOezqzJC2mgXfhtxYmwBmN1OkIS AMuFhvll3Tm7nCJGKPHVyocd6ZSABFeHGD/qN2RJP9Dxom/OG3jQbihYglN+WktU6SWFRxm0HEYBM 4koFk4Kg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIStb-0001oP-VR; Wed, 16 Sep 2020 08:34:32 +0000 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIStZ-0001ma-1N for linux-arm-kernel@lists.infradead.org; Wed, 16 Sep 2020 08:34:30 +0000 Received: by mail-pj1-x1044.google.com with SMTP id t7so1203252pjd.3 for ; Wed, 16 Sep 2020 01:34:25 -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=RT9nmjGwrtJZuE93eiP7fhhxa21vpsXEEeVjo3ZlufaA5DKRaAkfm80cMOmOg0WBXN 1HU9aEJMZeB+PbYsvOL8ZyxD0eKKWnLctp3u8+Fv2lnBQfDrXgn+wRxuGaSgd8mwaFh1 u7ujkUVYZce6VmeiKLUaYj95r7LayhOVJmRGYQVua3jrp2M6rO0Duk7xOvJsqiJVoZuM +m8t3PnwXMOLssKk27/GfIv0YS9LoV8f24Ucpc8S5vwXZFm7a8Mi/AwkTVDlCqeU5Fo2 At045oehV1LlPr33FDMnjrwdICzRU1+v6z+QHZEAP7el3GEA2Nlp7XDvuv3VYiidzIJS +fow== X-Gm-Message-State: AOAM532uerhEAfmU59tdhXkeLCGxfN9vHj7UjfZi8x5OcrZlKw7dFYZm pYsbD/DAXvURndYOkqq2Gm8= X-Google-Smtp-Source: ABdhPJzzWAP3ZfSvWviU9rH+tjW3d5iTK3iLmx4IbOy+KeeGv/o8U159fEb6jML5S5XeJGB1VcgxZg== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200916_043429_122031_CD39F8F0 X-CRM114-Status: GOOD ( 16.75 ) X-Spam-Score: 0.4 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1044 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [joel.stan[at]gmail.com] 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 Reviewed-by: Andrew Jeffery --- drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 71 +++++++++++++++++++++++++ 1 file changed, 71 insertions(+) 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);