From patchwork Mon Feb 19 07:24:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 128778 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3200938ljc; Sun, 18 Feb 2018 23:25:03 -0800 (PST) X-Google-Smtp-Source: AH8x226hYyCahYkCUetaKidixUra2qKMAbOz5pWHNs0DE/RfH8PoByzpt9+Kit8/t96u9Sg1Z9u0 X-Received: by 10.101.65.71 with SMTP id x7mr11285919pgp.379.1519025102924; Sun, 18 Feb 2018 23:25:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519025102; cv=none; d=google.com; s=arc-20160816; b=n/qzdiGmXKvK5WIEV/RFiqqBoX1Qu6VWJP4rVGNAKnQnBf/R0X8C1t0GoePXZ10Iv/ TGa6XVKIag+TdQVSk+tYlluaIzvVMvTrZY1lljmZWjDomZRdaJj7573X+LzVwEkQEWCG WlZNEODTYoLpRMnQ3NLmO0NRPFpckk6N+5Ax0wqXVQaXeFpuUWtWB1kS+Q8aD9Yv7LQ+ OPugloy9+T+REKYatfWX3gtpnsiCo3T2LjX8v//THxvb9k62aFSCOBb8j8j2A+/wTJAj pmjdSpxvUHVUmIORInaysAdDHQXOpxSiQ44kkQ72EIDJJe6/q1mzvPZf7xVWoJotjUBm neOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=NwL7A4hTUadKcUHHkqCgS88GiYok4oil6lnWHhgTt2o=; b=DOSrs8NHYitdBWkjnKLFTX2EE5ymMyY1RerIEftrU9SNxgkpmYy7kUzSG61y4/nRy9 bVeyWPtF4XV2IrJKUwUkbkBsJLW5diLEML7MF5h6ycMkfofwH8cxXTFITzJorW9dF/bR lKQX67lXbgkLFjHLCZGg7qmZGZC1Wtc4puVpub1R4fmoWWLOqEBKIKu9q1b1xrLphIM5 lGrqFpcp+Xuy9aujf3xV/oJ8a20BS3nfd+P2RDXPGC+BrnOkWHbKojNnxBPPlfHxzex8 nNrY1IEkgrrGg5p2HV8oMG4fFx8oxS5EPYrqs3FFU7dYdJA7ce1SmnFfb07oEHVcenPH xx7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Fzmv25Ok; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o2si5034662pgc.661.2018.02.18.23.25.02; Sun, 18 Feb 2018 23:25:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Fzmv25Ok; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752073AbeBSHZA (ORCPT + 28 others); Mon, 19 Feb 2018 02:25:00 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:46364 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751467AbeBSHY5 (ORCPT ); Mon, 19 Feb 2018 02:24:57 -0500 Received: by mail-pg0-f66.google.com with SMTP id m1so1478104pgp.13; Sun, 18 Feb 2018 23:24:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=NwL7A4hTUadKcUHHkqCgS88GiYok4oil6lnWHhgTt2o=; b=Fzmv25OkZy2+a9wj3hjFgRFnViOcmfvFblE7vK9JL+OTQvzixBDffY6bhM6jbofBhl IRpAX4UqDTRF2F+/Aefzwcx01MbYr4+fMTbPNIWIU08JGP4r+9+hMr7iA8U3HXHHchl0 HhhSl1o4BhQrhybasi3ZopNlyf1WwtWTNGXezXpyQzslsOb+Ohnxc8nqi1ORrRc3Jegn AtJaN5/+Gz0Ccdh/aGpijgVvnNvvqDCH3rkLvpSmxbgtmu6zXyl8EaQLoKpiusGtCv3k jHms0aAIrKLioDy5TrswxQSY7sBxXbFFd0LKfBH58/nVYWV7cr31qgLKtDbNThOsa/YG Rb6w== 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 :in-reply-to:references; bh=NwL7A4hTUadKcUHHkqCgS88GiYok4oil6lnWHhgTt2o=; b=I6ueypdrnyqMq3I9mMwfBGph4Vex+c6YN3XOiN5yKSC/xa50kOjVFVRdDbD8lOLMZz moro6OF2aqvGlGm6z0rccGcDT27Oi6uynJUih9Cyh4ATpM+bTPaw4EA2fZDx0mSq7/rp E0wEwHXxp7l7HZRsb0wtfv00zXA8SbOTtmFtt2ffwogDC0b8+1RyvU8VrYHM2KaNm8j8 pkYXjGJ+WpaDgSjG6mVDnnhPW2szNmEFrNwX0DxMS+nvXbbgcGk+yozG8MrUxghOwQyq lOpIjNwAQ81OcXmy6U67Xj/+509xXjHPjSXaadMq7J4aXIOXrQpQ8oCHXUtYSaj+rcjT /K/g== X-Gm-Message-State: APf1xPDWCSBw0YJT4ItoZD9XDJn58XyTSLRjTRUyCeMe0dqhuLqckiuA zW5gl005AZR/cyF97mo9Rsk= X-Received: by 10.98.204.69 with SMTP id a66mr6497853pfg.33.1519025096793; Sun, 18 Feb 2018 23:24:56 -0800 (PST) Received: from aurora.jms.id.au ([45.124.203.19]) by smtp.gmail.com with ESMTPSA id n17sm13893843pfj.67.2018.02.18.23.24.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 18 Feb 2018 23:24:56 -0800 (PST) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Mon, 19 Feb 2018 17:54:47 +1030 From: Joel Stanley To: Lee Jones , Greg Kroah-Hartman , Rob Herring , Mark Rutland Cc: Arnd Bergmann , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Jeffery , Cyril Bur , Benjamin Herrenschmidt , Ryan Chen , Lei YU Subject: [PATCH v2 2/3] misc: aspeed-lpc: Request and enable LPC clock Date: Mon, 19 Feb 2018 17:54:21 +1030 Message-Id: <20180219072422.22733-3-joel@jms.id.au> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180219072422.22733-1-joel@jms.id.au> References: <20180219072422.22733-1-joel@jms.id.au> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The LPC device needs to ensure it's clock is enabled before it can do anything. In the past the clock was enabled and left running by u-boot, however Linux now has an upstream clock driver that disables unused clocks. Tested-by: Lei YU Reviewed-by: Andrew Jeffery Signed-off-by: Joel Stanley --- drivers/misc/aspeed-lpc-ctrl.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) -- 2.15.1 diff --git a/drivers/misc/aspeed-lpc-ctrl.c b/drivers/misc/aspeed-lpc-ctrl.c index b5439643f54b..1827b7aa6674 100644 --- a/drivers/misc/aspeed-lpc-ctrl.c +++ b/drivers/misc/aspeed-lpc-ctrl.c @@ -7,6 +7,7 @@ * 2 of the License, or (at your option) any later version. */ +#include #include #include #include @@ -26,6 +27,7 @@ struct aspeed_lpc_ctrl { struct miscdevice miscdev; struct regmap *regmap; + struct clk *clk; phys_addr_t mem_base; resource_size_t mem_size; u32 pnor_size; @@ -221,16 +223,33 @@ static int aspeed_lpc_ctrl_probe(struct platform_device *pdev) return -ENODEV; } + lpc_ctrl->clk = devm_clk_get(dev, NULL); + if (IS_ERR(lpc_ctrl->clk)) { + dev_err(dev, "couldn't get clock\n"); + return PTR_ERR(lpc_ctrl->clk); + } + rc = clk_prepare_enable(lpc_ctrl->clk); + if (rc) { + dev_err(dev, "couldn't enable clock\n"); + return rc; + } + lpc_ctrl->miscdev.minor = MISC_DYNAMIC_MINOR; lpc_ctrl->miscdev.name = DEVICE_NAME; lpc_ctrl->miscdev.fops = &aspeed_lpc_ctrl_fops; lpc_ctrl->miscdev.parent = dev; rc = misc_register(&lpc_ctrl->miscdev); - if (rc) + if (rc) { dev_err(dev, "Unable to register device\n"); - else - dev_info(dev, "Loaded at %pr\n", &resm); + goto err; + } + + dev_info(dev, "Loaded at %pr\n", &resm); + + return 0; +err: + clk_disable_unprepare(lpc_ctrl->clk); return rc; } @@ -239,6 +258,7 @@ static int aspeed_lpc_ctrl_remove(struct platform_device *pdev) struct aspeed_lpc_ctrl *lpc_ctrl = dev_get_drvdata(&pdev->dev); misc_deregister(&lpc_ctrl->miscdev); + clk_disable_unprepare(lpc_ctrl->clk); return 0; } From patchwork Mon Feb 19 07:24:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 128779 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3201047ljc; Sun, 18 Feb 2018 23:25:14 -0800 (PST) X-Google-Smtp-Source: AH8x224z70MFDdMEHvuMTGYi6cr/Eu72QOf0yBXcVZK/eJTvD+FGh6ZQay8j2/KcXi0cbRdC1T9V X-Received: by 10.98.88.1 with SMTP id m1mr13822713pfb.178.1519025114415; Sun, 18 Feb 2018 23:25:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519025114; cv=none; d=google.com; s=arc-20160816; b=0aPATaPVonXylj0Cxe4SCLjXwukJ81ogix30UXhcRHAau+lda47pN2ewT8iYoXTfEH wby/1MHGtJ399mFNP2uQqdRUP/D5IMB+PvezO4V5aXe9JfNrHsA6uOE9eAOy6JOdiP8N W+t2iuXLjTVAJQNYI056wCC5cCOZbGAq0BKOWd8p28ka8hTeRkYLXY+oSpdDEp4WXnJ+ KOUloe2g/9ySAo0fBPygoqyfP/RWlrLAtjexJyjbk5gQ6VGb83zDQyPLHf6UEtgoAiGY iYI3MpgEPC/iy9J2nbbUiJ3nCHDK0jO94YP2hqAZUegwNhE+T2QNqwcQ0s9OhY/+kKeF rfNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=0+y23RNN9DiEUUahCXyZcFMFudK8X0KhRebf3LNpKXs=; b=umrxF4bLgFLgPZYT4IrH+qJTJzuX9BrbzGJrU19nF6gRT4W0uTeeePRaBJWqRg3Qkx BylqZEGUTQLgPeyGeCaOjw6aGHZuAkQiLFWfITCrcsVeSTzyb5dTY/eDR5nfxgq9XBHZ VBLcxsvyr5qyndmf8seT9JWKl5EIadMPTbbgNVJnzXULmRSuFKFG8XLN/Dc1viiiWNhj CsLhR+Hg5mM7wHsnQZInttrgDsiLqxgfBXkyJ6OkK5mX05JkIJZf7aujYF3cv9LFc9td SpNOj5LiakEpUnik3qNQBVFCvU3fm5HpB4AdMuykNZKtFrDkcxl070fpqsJdpG9r5Nfw CQfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=mhAxtisp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 9-v6si8613937ple.367.2018.02.18.23.25.14; Sun, 18 Feb 2018 23:25:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=mhAxtisp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752102AbeBSHZK (ORCPT + 28 others); Mon, 19 Feb 2018 02:25:10 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:34674 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751467AbeBSHZH (ORCPT ); Mon, 19 Feb 2018 02:25:07 -0500 Received: by mail-pf0-f196.google.com with SMTP id g17so1843019pfh.1; Sun, 18 Feb 2018 23:25:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=0+y23RNN9DiEUUahCXyZcFMFudK8X0KhRebf3LNpKXs=; b=mhAxtispq9o8/Bi821GDjKXCNnPUgwQmdLQk+qEyFU6UrpN0qRM+raAmSrjtET2QRj Ri00UPSdycBAy3thmqNWV5RYn3XQ205OZnUxyZ90KaKAKKht6T2IzxOY4zYk6SZu2EsE SVnxAX63hbz73Y2knq+/wHrjNmK0dEPo59adcPoTs3Ko3+J6F37cDo/aa1bcQzLQj9dJ PdElsnDY1Zc2CECi/e6yxSIxKe7PCmERyKaRatWaplnSNXdPYaEIUnpPjD6QjOJfeFNu 2aBh45EHFDFFbyfJ/eTepFQohy4XdlL42UWocj7AGs5VIsU2yyEmn+smvjciHv8Uz6QI dtnA== 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 :in-reply-to:references; bh=0+y23RNN9DiEUUahCXyZcFMFudK8X0KhRebf3LNpKXs=; b=qYD3sG3VcjVJp50RH2g7PNOnQdK+HxJbXfYm+tXAFXlxlM5aQUTgPqs2sYQDImEOXV k1QEYKqOUbUIK1lG9Ohf1eaK5NYEopNUZzyYy+6u4J769st3vhEWQNjYM7ns5w7scmYd XwLCudoYj3oqWP199/vsBRPBaJ3isY97NtCnCqcbfAlgDWn/PH+MN5yqkWlxR3NcH4ER 9mkA3HDbNPSYMPRDEDk87I3mheQGS/qCfastMZ8QxPTFKdCfXA5GrDmw75O/bwyYye9i eyEgpb7S/zpwkprgTMNVL5UxVMd+1Mo+IdBNuWlRhavY2LUPcg9whQEHfs51lwWTSTkS ihsg== X-Gm-Message-State: APf1xPD2svtCjKwCPfiIW0gI2TYKV80bPjdYS/t9i03gYaXfz6n53BwM oS6OPnslmDwWN42cYt0CTzw= X-Received: by 10.99.2.202 with SMTP id 193mr4130832pgc.137.1519025106797; Sun, 18 Feb 2018 23:25:06 -0800 (PST) Received: from aurora.jms.id.au ([45.124.203.19]) by smtp.gmail.com with ESMTPSA id z79sm7221962pfa.139.2018.02.18.23.25.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 18 Feb 2018 23:25:06 -0800 (PST) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Mon, 19 Feb 2018 17:54:57 +1030 From: Joel Stanley To: Lee Jones , Greg Kroah-Hartman , Rob Herring , Mark Rutland Cc: Arnd Bergmann , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Jeffery , Cyril Bur , Benjamin Herrenschmidt , Ryan Chen , Lei YU Subject: [PATCH v2 3/3] misc: aspeed-lpc-ctrl: Enable FWH and A2H bridge cycles Date: Mon, 19 Feb 2018 17:54:22 +1030 Message-Id: <20180219072422.22733-4-joel@jms.id.au> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180219072422.22733-1-joel@jms.id.au> References: <20180219072422.22733-1-joel@jms.id.au> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To date this driver has relied on prevous state from out of tree hacks and vendor u-boot trees in order to have the host be able to access data over the LPC bus. Now we explicitly enable the AHB to LPC bridge and FWH cycles from when the user first configures the address to map. We chose to do this then as before that time there is no way for the kernel to know where it is safe to point the LPC window. Tested-by: Lei YU Reviewed-by: Andrew Jeffery Signed-off-by: Joel Stanley --- drivers/misc/aspeed-lpc-ctrl.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) -- 2.15.1 diff --git a/drivers/misc/aspeed-lpc-ctrl.c b/drivers/misc/aspeed-lpc-ctrl.c index 1827b7aa6674..a024f8042259 100644 --- a/drivers/misc/aspeed-lpc-ctrl.c +++ b/drivers/misc/aspeed-lpc-ctrl.c @@ -21,6 +21,10 @@ #define DEVICE_NAME "aspeed-lpc-ctrl" +#define HICR5 0x0 +#define HICR5_ENL2H BIT(8) +#define HICR5_ENFWH BIT(10) + #define HICR7 0x8 #define HICR8 0xc @@ -155,8 +159,18 @@ static long aspeed_lpc_ctrl_ioctl(struct file *file, unsigned int cmd, if (rc) return rc; - return regmap_write(lpc_ctrl->regmap, HICR8, - (~(map.size - 1)) | ((map.size >> 16) - 1)); + rc = regmap_write(lpc_ctrl->regmap, HICR8, + (~(map.size - 1)) | ((map.size >> 16) - 1)); + if (rc) + return rc; + + /* + * Enable LPC FHW cycles. This is required for the host to + * access the regions specified. + */ + return regmap_update_bits(lpc_ctrl->regmap, HICR5, + HICR5_ENFWH | HICR5_ENL2H, + HICR5_ENFWH | HICR5_ENL2H); } return -EINVAL;