From patchwork Wed Nov 14 09:00:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 10682207 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF949139B for ; Wed, 14 Nov 2018 09:01:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE7182ADBB for ; Wed, 14 Nov 2018 09:01:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DB312ADD5; Wed, 14 Nov 2018 09:01:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8C7152ADBF for ; Wed, 14 Nov 2018 09:01:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To: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:List-Owner; bh=CU30bYO2qAzht982W2RDzels66xu9sxhLcvLe5L4c0E=; b=herO26mmpEk2GgLrEouR+qdW5P HNpqKn0h75dOPovAzIQQGY0WeNKynRj3Zgv6lb/JQz+zVjP33W3avCBLMgIAhrqLfBH4vfny0cFoQ 4CAhFXZOxdsSxq6s056S+vweSUKbLstnFz3y3j90xuqcNkNzS+AqI8HnknLz2Ys3/GOnfmVbEbtfw 0frY0r9r2v8nMKjdyNBnrlN0awTSZp/R20BWevj9kCvkonaR3HPYl53gFlTT5ouk2J28wxPsew+PE vQFMKYI4Md64aeMZa+5zdJtugJ39HqfCYYfBBXj8/BiAcs/bqzO/wpwvR7jrkjyo2QR44uG7OBVrU Q24yP4gg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMr2t-0003Tj-SY; Wed, 14 Nov 2018 09:01:12 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMr2a-0003Ap-JY for linux-arm-kernel@lists.infradead.org; Wed, 14 Nov 2018 09:00:54 +0000 Received: by mail-wm1-x344.google.com with SMTP id 124-v6so14695218wmw.0 for ; Wed, 14 Nov 2018 01:00:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NVMx9s0p6eS3mdR74Q8qaGNUdHlTjWWP5rB6sIuitXE=; b=ZDK1/+/FRKEwwPawhs+yyhdyNtZFMlja8+roKGKMxAb1QHb6QEGreUk7SwGCC1DsDN lhBJ+CpAlNELO9d4CJqDokjD/GXQ2R60qT4auHuDgUnzwZI4S1gk9M7qKIfRtFwnAJht ZcfjzRJv3peFKuEZ8QS4vAIcHNvCQPSUzGO2w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NVMx9s0p6eS3mdR74Q8qaGNUdHlTjWWP5rB6sIuitXE=; b=nkkDZkMslZ8GAHF8sFN3APxkJka8kceUGwnK7L6ECDdeJL50/bbFazNeBefCeP7XQj PxUCLlUGu/3ms+9jU80a66AucNysluTHxxdmkZPclc4Bid/rgkQSd1mOsX0ixYPtfxQp W3G7sfN8L2Wqg4g/fIcs0NR9TzjLIbLYDzcjaPzkiVpbBhOTiW8pxN16M9f1vg6h/sCh iC4WW/TVA7zZ6fg1yB6DIgC0ehSGMy1cNkOEcS5KT4034VPYFS8+9s5S+2dxDlKj2wBj Kqxo76cX0TjEwAhch+1Aj3g2dalk5EDkOmAgSOq9ZGVmH92REOrwOyB1nXSiIrHmj1rB 6/lw== X-Gm-Message-State: AGRZ1gKe+wqfeU2d7cKi9KbyNo5ZmrLiy6a66B+WQGJgq5oKnxOJug7O clKvCgQnZIJ1Xo7CIMFYdCGkHg== X-Google-Smtp-Source: AJdET5eaE6wWngOfToyeWHX5LFNPjYG0JB2ezHRD6TDE5muhGdzlgTrkzgcYIpx/cPs3onlNv2XJmA== X-Received: by 2002:a1c:3a8d:: with SMTP id h135-v6mr1119470wma.92.1542186040945; Wed, 14 Nov 2018 01:00:40 -0800 (PST) Received: from lmecxl0911.lme.st.com ([2a04:cec0:1088:2b4c:4d39:8b22:d570:822a]) by smtp.gmail.com with ESMTPSA id n7-v6sm16951441wrt.60.2018.11.14.01.00.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Nov 2018 01:00:40 -0800 (PST) From: Benjamin Gaignard To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, alexandre.torgue@st.com Subject: [PATCH v4 1/4] dt-bindings: hwlock: Document STM32 hwspinlock bindings Date: Wed, 14 Nov 2018 10:00:24 +0100 Message-Id: <20181114090027.7580-2-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20181114090027.7580-1-benjamin.gaignard@linaro.org> References: <20181114090027.7580-1-benjamin.gaignard@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181114_010052_638270_6AFFA19D X-CRM114-Status: GOOD ( 13.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Benjamin Gaignard , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Gaignard , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Benjamin Gaignard Add bindings for STM32 hardware spinlock device Signed-off-by: Benjamin Gaignard Signed-off-by: Benjamin Gaignard Reviewed-by: Rob Herring --- version 4: - add Linaro SoB version 3 : - fix clock name in properties description version 2 : - change clock name from hwspinlock to hsem to be align with hardware documentation .../bindings/hwlock/st,stm32-hwspinlock.txt | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwlock/st,stm32-hwspinlock.txt diff --git a/Documentation/devicetree/bindings/hwlock/st,stm32-hwspinlock.txt b/Documentation/devicetree/bindings/hwlock/st,stm32-hwspinlock.txt new file mode 100644 index 000000000000..adf4f000ea3d --- /dev/null +++ b/Documentation/devicetree/bindings/hwlock/st,stm32-hwspinlock.txt @@ -0,0 +1,23 @@ +STM32 Hardware Spinlock Device Binding +------------------------------------- + +Required properties : +- compatible : should be "st,stm32-hwspinlock". +- reg : the register address of hwspinlock. +- #hwlock-cells : hwlock users only use the hwlock id to represent a specific + hwlock, so the number of cells should be <1> here. +- clock-names : Must contain "hsem". +- clocks : Must contain a phandle entry for the clock in clock-names, see the + common clock bindings. + +Please look at the generic hwlock binding for usage information for consumers, +"Documentation/devicetree/bindings/hwlock/hwlock.txt" + +Example of hwlock provider: + hwspinlock@4c000000 { + compatible = "st,stm32-hwspinlock"; + #hwlock-cells = <1>; + reg = <0x4c000000 0x400>; + clocks = <&rcc HSEM>; + clock-names = "hsem"; + }; From patchwork Wed Nov 14 09:00:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 10682209 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D62FD14E2 for ; Wed, 14 Nov 2018 09:01:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C64382ADA2 for ; Wed, 14 Nov 2018 09:01:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B92702ADDC; Wed, 14 Nov 2018 09:01:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2D9182ADA2 for ; Wed, 14 Nov 2018 09:01:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To: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:List-Owner; bh=fGM4B6SxBlr0iZZOoleuc/dkv2nZzQl9YZU4bWEy2uA=; b=Iq6MnVLxWuqf+LvuavNwRLuNrS Nt20K5NVAHV2DF1HUNAhsCEQdKs/+eYbElh1t6GDeFKFs6t8M3lENRKG4nkbTT/KSF91ulr8CiNgQ SWOsqvVySo+LhLNVC00/P3iPAKbkH7YAAJFb41XFmNH4ZBu+tV657S+tRmwioW+2Q5sF5i9zCwpF/ I1q8Y/4XXsRW1irdiphAioeF3kUC/InpT+RmHajvnU0g5JjJJEMSq3SPvzSWOCSqE/3vzUnfMegYS YIHIma3zpg8eBk09lFMugpcaE57zu9W51rSKEIr6U8rYn3S7Z4QDiJiGVA/UXDWchvsQ9UuoACmL7 y5/hW3GQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMr37-0003qA-Cz; Wed, 14 Nov 2018 09:01:25 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMr2d-0003Ar-5Q for linux-arm-kernel@lists.infradead.org; Wed, 14 Nov 2018 09:00:58 +0000 Received: by mail-wm1-x341.google.com with SMTP id 124-v6so14695376wmw.0 for ; Wed, 14 Nov 2018 01:00:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Cw/K1SBDEn5L1Ca0s15yo5xPQT5iLoDouJnTbDSOJFo=; b=TgYxxRQAF9MJBhn0TF7EBA5swl+SSQHJjoGjtfkZH+0fSgAvqGZBpUskK8iYSIih5o iBtXQibZW0avDxAYG43cscoiCOKRVkT6ptpjXGRjvXTw8ETovZ3trmgK9qes6v7/lYv4 nhB97RFeTxyxv7DmGkiA+uhmMXeGzo6GoCh7g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Cw/K1SBDEn5L1Ca0s15yo5xPQT5iLoDouJnTbDSOJFo=; b=Jr1Aq+zrKIeqKzC0heOUsnPTY/oHf8o07ukrpiSMLREeA3Al7EmzZ6rNBEm6dXynnK uJ+4s8J/gDGLJyLt8KjaPPzzgmfNTighY+JeNTcemzukLxVSgIsA2r+yM6L2heSa1sHY Fj8TSgsH0oqPNkN5ZirYF9qAIygzyXxn5TNqXCLJYLKk+GzcaMpKTso80JIGqfrwcGza 4/FewvbFqhf1QL9+6N2wlTgZ0vc0hMQD8VTd5HgIfxFvKTUI76pWNz3hKfmwC/21cJyI Y8GR73ChVMtVBIlZBkHS7IWvae4tAM9g5d77OF2c30XrW+dT83agvmIEFQesiwiRg0DZ sX0g== X-Gm-Message-State: AGRZ1gLQ8CW46Eb8dmVGdeINsdiDk4+Et/NSS47Lb77iad4Jw6b0wmoQ 8ha7T7ZaFpm+LpELa8JVVQw+Og== X-Google-Smtp-Source: AJdET5c7SKSVybAywbqC+w6OtokwXu9y07JuaMp1HWwXxHGpYXhoWaJxqNBEQMofR5EDQbn0AEVmCw== X-Received: by 2002:a1c:9c85:: with SMTP id f127-v6mr1046143wme.73.1542186043440; Wed, 14 Nov 2018 01:00:43 -0800 (PST) Received: from lmecxl0911.lme.st.com ([2a04:cec0:1088:2b4c:4d39:8b22:d570:822a]) by smtp.gmail.com with ESMTPSA id n7-v6sm16951441wrt.60.2018.11.14.01.00.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Nov 2018 01:00:42 -0800 (PST) From: Benjamin Gaignard To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, alexandre.torgue@st.com Subject: [PATCH v4 2/4] hwspinlock: add STM32 hwspinlock device Date: Wed, 14 Nov 2018 10:00:25 +0100 Message-Id: <20181114090027.7580-3-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20181114090027.7580-1-benjamin.gaignard@linaro.org> References: <20181114090027.7580-1-benjamin.gaignard@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181114_010055_210396_901E2EB3 X-CRM114-Status: GOOD ( 19.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Benjamin Gaignard , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Gaignard , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Benjamin Gaignard This patch adds support of hardware semaphores for stm32mp1 SoC. The hardware block provides 32 semaphores. Signed-off-by: Benjamin Gaignard Signed-off-by: Benjamin Gaignard --- version 4: - add Linaro SoB version 3 : - use postcore_initcall() instead of module_platform_driver() version 2 : - change clock name from hwspinlock to hsem to be align with hardware documentation - remove useless licence terms from header - fix alphabetic order issues - do not abort remove function if hwspin_lock_unregister() failed drivers/hwspinlock/Kconfig | 9 ++ drivers/hwspinlock/Makefile | 1 + drivers/hwspinlock/stm32_hwspinlock.c | 156 ++++++++++++++++++++++++++++++++++ 3 files changed, 166 insertions(+) create mode 100644 drivers/hwspinlock/stm32_hwspinlock.c diff --git a/drivers/hwspinlock/Kconfig b/drivers/hwspinlock/Kconfig index e895d29500ee..7869c67e5b6b 100644 --- a/drivers/hwspinlock/Kconfig +++ b/drivers/hwspinlock/Kconfig @@ -49,6 +49,15 @@ config HWSPINLOCK_SPRD If unsure, say N. +config HWSPINLOCK_STM32 + tristate "STM32 Hardware Spinlock device" + depends on MACH_STM32MP157 + depends on HWSPINLOCK + help + Say y here to support the STM32 Hardware Spinlock device. + + If unsure, say N. + config HSEM_U8500 tristate "STE Hardware Semaphore functionality" depends on HWSPINLOCK diff --git a/drivers/hwspinlock/Makefile b/drivers/hwspinlock/Makefile index b87c01a506a4..ed053e3f02be 100644 --- a/drivers/hwspinlock/Makefile +++ b/drivers/hwspinlock/Makefile @@ -8,4 +8,5 @@ obj-$(CONFIG_HWSPINLOCK_OMAP) += omap_hwspinlock.o obj-$(CONFIG_HWSPINLOCK_QCOM) += qcom_hwspinlock.o obj-$(CONFIG_HWSPINLOCK_SIRF) += sirf_hwspinlock.o obj-$(CONFIG_HWSPINLOCK_SPRD) += sprd_hwspinlock.o +obj-$(CONFIG_HWSPINLOCK_STM32) += stm32_hwspinlock.o obj-$(CONFIG_HSEM_U8500) += u8500_hsem.o diff --git a/drivers/hwspinlock/stm32_hwspinlock.c b/drivers/hwspinlock/stm32_hwspinlock.c new file mode 100644 index 000000000000..34a8e009dc93 --- /dev/null +++ b/drivers/hwspinlock/stm32_hwspinlock.c @@ -0,0 +1,156 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) STMicroelectronics SA 2018 + * Author: Benjamin Gaignard for STMicroelectronics. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "hwspinlock_internal.h" + +#define STM32_MUTEX_COREID BIT(8) +#define STM32_MUTEX_LOCK_BIT BIT(31) +#define STM32_MUTEX_NUM_LOCKS 32 + +struct stm32_hwspinlock { + struct clk *clk; + struct hwspinlock_device bank; +}; + +static int stm32_hwspinlock_trylock(struct hwspinlock *lock) +{ + void __iomem *lock_addr = lock->priv; + u32 status; + + writel(STM32_MUTEX_LOCK_BIT | STM32_MUTEX_COREID, lock_addr); + status = readl(lock_addr); + + return status == (STM32_MUTEX_LOCK_BIT | STM32_MUTEX_COREID); +} + +static void stm32_hwspinlock_unlock(struct hwspinlock *lock) +{ + void __iomem *lock_addr = lock->priv; + + writel(STM32_MUTEX_COREID, lock_addr); +} + +static const struct hwspinlock_ops stm32_hwspinlock_ops = { + .trylock = stm32_hwspinlock_trylock, + .unlock = stm32_hwspinlock_unlock, +}; + +static int stm32_hwspinlock_probe(struct platform_device *pdev) +{ + struct stm32_hwspinlock *hw; + void __iomem *io_base; + struct resource *res; + size_t array_size; + int i, ret; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + io_base = devm_ioremap_resource(&pdev->dev, res); + if (!io_base) + return -ENOMEM; + + array_size = STM32_MUTEX_NUM_LOCKS * sizeof(struct hwspinlock); + hw = devm_kzalloc(&pdev->dev, sizeof(*hw) + array_size, GFP_KERNEL); + if (!hw) + return -ENOMEM; + + hw->clk = devm_clk_get(&pdev->dev, "hsem"); + if (IS_ERR(hw->clk)) + return PTR_ERR(hw->clk); + + for (i = 0; i < STM32_MUTEX_NUM_LOCKS; i++) + hw->bank.lock[i].priv = io_base + i * sizeof(u32); + + platform_set_drvdata(pdev, hw); + pm_runtime_enable(&pdev->dev); + + ret = hwspin_lock_register(&hw->bank, &pdev->dev, &stm32_hwspinlock_ops, + 0, STM32_MUTEX_NUM_LOCKS); + + if (ret) + pm_runtime_disable(&pdev->dev); + + return ret; +} + +static int stm32_hwspinlock_remove(struct platform_device *pdev) +{ + struct stm32_hwspinlock *hw = platform_get_drvdata(pdev); + int ret; + + ret = hwspin_lock_unregister(&hw->bank); + if (ret) + dev_err(&pdev->dev, "%s failed: %d\n", __func__, ret); + + pm_runtime_disable(&pdev->dev); + + return 0; +} + +static int __maybe_unused stm32_hwspinlock_runtime_suspend(struct device *dev) +{ + struct stm32_hwspinlock *hw = dev_get_drvdata(dev); + + clk_disable_unprepare(hw->clk); + + return 0; +} + +static int __maybe_unused stm32_hwspinlock_runtime_resume(struct device *dev) +{ + struct stm32_hwspinlock *hw = dev_get_drvdata(dev); + + clk_prepare_enable(hw->clk); + + return 0; +} + +static const struct dev_pm_ops stm32_hwspinlock_pm_ops = { + SET_RUNTIME_PM_OPS(stm32_hwspinlock_runtime_suspend, + stm32_hwspinlock_runtime_resume, + NULL) +}; + +static const struct of_device_id stm32_hwpinlock_ids[] = { + { .compatible = "st,stm32-hwspinlock", }, + {}, +}; +MODULE_DEVICE_TABLE(of, stm32_hwpinlock_ids); + +static struct platform_driver stm32_hwspinlock_driver = { + .probe = stm32_hwspinlock_probe, + .remove = stm32_hwspinlock_remove, + .driver = { + .name = "stm32_hwspinlock", + .of_match_table = stm32_hwpinlock_ids, + .pm = &stm32_hwspinlock_pm_ops, + }, +}; + +static int __init stm32_hwspinlock_init(void) +{ + return platform_driver_register(&stm32_hwspinlock_driver); +} +/* board init code might need to reserve hwspinlocks for predefined purposes */ +postcore_initcall(stm32_hwspinlock_init); + +static void __exit stm32_hwspinlock_exit(void) +{ + platform_driver_unregister(&stm32_hwspinlock_driver); +} +module_exit(stm32_hwspinlock_exit); + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("Hardware spinlock driver for STM32 SoCs"); +MODULE_AUTHOR("Benjamin Gaignard "); From patchwork Wed Nov 14 09:00:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 10682211 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F0A03139B for ; Wed, 14 Nov 2018 09:01:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFEFF2ADA2 for ; Wed, 14 Nov 2018 09:01:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1F642ADBF; Wed, 14 Nov 2018 09:01:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 543BB2ADA2 for ; Wed, 14 Nov 2018 09:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To: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:List-Owner; bh=p7zRyYEgOv7aVthIrCyB7Sk+5vwELicByf1Vfp5xCDk=; b=pEP8v+oexl65hU7BfrTBaq6X7o NDwMb0US1NAita70/ACBuqgWyjheuE+uk6Vhv3n0qQi/x+Eiz49lXNDv2HrnPabJTRUpQEaw41/uH 91IyL3j1BRvl2NCVBQQtYvpm15V35GlEomL842oYdP7OvP+s7riDJ8w6ym2WbLFpeZH3QzoN2FG2T jCd9HyOA/P6uqjwbERDVkWH8XwnCY6mm7dJzWlKelr/aZrwWYULCG3U2NAjDWbqBjTHaVfWeEvR/P ZMvsOmJ3l5Fcvy+F3Il7K4eZ3lFtKnxGCtZpTkbJGX1iB9vzP8HNqwAEHZw4cMPLaOF0HhHCzc4Hz CNa3mmMg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMr3Q-0004AY-KO; Wed, 14 Nov 2018 09:01:44 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMr2f-0003BD-KX for linux-arm-kernel@lists.infradead.org; Wed, 14 Nov 2018 09:00:59 +0000 Received: by mail-wr1-x443.google.com with SMTP id u9-v6so16355045wrr.0 for ; Wed, 14 Nov 2018 01:00:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ksJ+8XjL23kMtQWv2Hf9iBBlF+Q91Ku8huwPUBKghB4=; b=RP//3U7prQwfBC8rFgQpxhZ5HbU7aRgKzhlUvzGUTnk8YO21iLJidGCbdUItzpTa4R tzwmqd2C2EVg/OJEpTmLiu0ey3ZdrMuXMuvVHknR3qJOHb9yMkPCOv0zXFnmNxMpqZpS +5otPP1mDiMpDri7dIu6AAc8XSmpoii6fAEEM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ksJ+8XjL23kMtQWv2Hf9iBBlF+Q91Ku8huwPUBKghB4=; b=o8KRCjlD3ooQVTHt/dSA25DW5F3I/vJLxdsNVxovKSsrMRuyG4Ie113G6061aTeb9Y zmSu8VI0xDf9sOk8FV3lwkz0zZ/0a6Y50Fjjb3s7vwxChG/irHOMIjeEMmCPxWLaoC5n 4+eUXcp85kDfvItc8NtEShA+CJL8jrqxyXpxkOwO6/Zq8UyN/z72JLptNdlQAgurjEC/ lWuIzp1h1gtfdLFTCj2GZSNWnCDVydHG9vjZMUw9GFm9RVwHFRnGc5kPB4bTlNgbw0kY ssmxSTlGQJpnKDPAUG6wInX71JfQBWoMFTy8iYpJ97c3BC3Cm6Z4PMuIHqoRMqSM7mzO dFIA== X-Gm-Message-State: AGRZ1gJIUhIRgO85DfD6HPv34HlhZLDGF/E2QWYWtDns3i9JClDOemAu i849W1nVzpdSkmMTfVaRaakpa3FSEa4afA== X-Google-Smtp-Source: AJdET5f00Ir3Iyybptx8ZoNjwZdF8DFlROHkpR4Om/q0myorMmY53MRqM889DSemLM42VLwPho4dnQ== X-Received: by 2002:adf:b716:: with SMTP id l22-v6mr1053636wre.157.1542186046010; Wed, 14 Nov 2018 01:00:46 -0800 (PST) Received: from lmecxl0911.lme.st.com ([2a04:cec0:1088:2b4c:4d39:8b22:d570:822a]) by smtp.gmail.com with ESMTPSA id n7-v6sm16951441wrt.60.2018.11.14.01.00.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Nov 2018 01:00:45 -0800 (PST) From: Benjamin Gaignard To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, alexandre.torgue@st.com Subject: [PATCH v4 3/4] ARM: dts: stm32: Add hwspinlock node for stm32mp157 SoC Date: Wed, 14 Nov 2018 10:00:26 +0100 Message-Id: <20181114090027.7580-4-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20181114090027.7580-1-benjamin.gaignard@linaro.org> References: <20181114090027.7580-1-benjamin.gaignard@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181114_010057_712359_9E2F8B39 X-CRM114-Status: GOOD ( 12.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Benjamin Gaignard , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Gaignard , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Benjamin Gaignard Declare hwspinlock device for stm32mp157 SoC Signed-off-by: Benjamin Gaignard Signed-off-by: Benjamin Gaignard --- arch/arm/boot/dts/stm32mp157c.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm/boot/dts/stm32mp157c.dtsi b/arch/arm/boot/dts/stm32mp157c.dtsi index 185541a5b69f..98f824d8b0f0 100644 --- a/arch/arm/boot/dts/stm32mp157c.dtsi +++ b/arch/arm/boot/dts/stm32mp157c.dtsi @@ -803,6 +803,15 @@ status = "disabled"; }; + hsem: hwspinlock@4c000000 { + compatible = "st,stm32-hwspinlock"; + #hwlock-cells = <1>; + reg = <0x4c000000 0x400>; + clocks = <&rcc HSEM>; + clock-names = "hwsem"; + status = "disabled"; + }; + rcc: rcc@50000000 { compatible = "st,stm32mp1-rcc", "syscon"; reg = <0x50000000 0x1000>; From patchwork Wed Nov 14 09:00:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 10682205 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E8EC414E2 for ; Wed, 14 Nov 2018 09:01:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCB612ADBB for ; Wed, 14 Nov 2018 09:01:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D10BD2ADED; Wed, 14 Nov 2018 09:01:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 22F922ADD5 for ; Wed, 14 Nov 2018 09:01:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To: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:List-Owner; bh=U1SHQXDAwDB9g0boHfKe9xL5DCYyzSvB0sSnUbvWKd0=; b=KEzySHt6vpDHtl34KZUTNw1Fb0 p5OLqZNF7kfsBGXbHJwxBOcspNkMpUx7vQEUBL3l4liqhMyd+XocYtjNB/MbZoxHjSUe4Cy5qljBV z9scruczsgPXAUOkbZgB5nvwyNiK4x80r4A0dDqUHpJPNu/zODsDWEk4QeECsJpk6xxyeuhgFAEvp cjkA2Fw/eUiY4vxJVBe43KU6fFZNpIpIP/2deoOoA8DFjKR6m+6XdF+HFdBgJ07ZBVZsDvPtp6rSW NKWb0x+RU4qFCuG71h/0jhAVJnKHKVF/78LyPOhJmbgXQmYk7fnqJJH8feJ61uk/hioI31nFycKQF +AeRZ1tQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMr2j-0003K4-5U; Wed, 14 Nov 2018 09:01:01 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMr2a-0003Ba-JW for linux-arm-kernel@lists.infradead.org; Wed, 14 Nov 2018 09:00:54 +0000 Received: by mail-wm1-x344.google.com with SMTP id 124-v6so14695620wmw.0 for ; Wed, 14 Nov 2018 01:00:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6m0CH9mIIg1HDofUPyfAueceCWtH5wTcJRcojQSCMGM=; b=g4z38SjkyjLKeo5V4lsEdgeExeXnHVS5EIfT+46S7mLy97IXnQ05/I5BXN5mZeAwcW 23wyPi65Psn8IPmQF4zO3UHe5hsQlcryYZlSFgGPQAfCEHqp9eHrCKxVQUIQY6ibnoeH Q9GUeunN7Rcf4QvEA9mNxTm/uI7SdRkvFXMNQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6m0CH9mIIg1HDofUPyfAueceCWtH5wTcJRcojQSCMGM=; b=CgFqRQowYyOVXkl01IcyKQQRpEMflpeL/C4vbE2/GS0GTpWhLu/6vUXAbWolfBxyGo seyI5Y+rLiSki9KyFl2vJ/j/kVQ+BxO+oUfQYYPvWPj074Lb+K1vdkwny78mGCVyHjAe ix/TIc7mVUcaebKEdJSHwvWVKlSrQV9v6tuhxfpm0Up6PqPTxnZSQf27f0JLA4F0mvzL 1OdLQNadPhWzQLBKjwzgr2Z6xxSghy5w3h+1C0iU5WhQa4uqnFfjUaRCZsEjPe+rVYEw Gz0LbRmg6IlnINc6DdAm7MqmhlwWL99YzLLPkr78gh6CbhqQ0djoIrNeTHtoPktdC7Ow 8ZGQ== X-Gm-Message-State: AGRZ1gK+jk9/V/bi2N0H5EpNGb3V66zXw1B/EB5BULq1k/ah0iuJ3PJT 8BLR6o9El711Yf10CGYAe5kxUw== X-Google-Smtp-Source: AJdET5fR6fMimlj3bxEbiK+BbfJmV+sSxIwOEaE1FswYudlJhKy/DVBiS12ITrTCTo/ajDSqtj8haQ== X-Received: by 2002:a1c:80c4:: with SMTP id b187-v6mr1072965wmd.97.1542186048039; Wed, 14 Nov 2018 01:00:48 -0800 (PST) Received: from lmecxl0911.lme.st.com ([2a04:cec0:1088:2b4c:4d39:8b22:d570:822a]) by smtp.gmail.com with ESMTPSA id n7-v6sm16951441wrt.60.2018.11.14.01.00.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Nov 2018 01:00:47 -0800 (PST) From: Benjamin Gaignard To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, alexandre.torgue@st.com Subject: [PATCH v4 4/4] ARM: dts: stm32: enable hwspinlock on stm32mp157c-ed1 Date: Wed, 14 Nov 2018 10:00:27 +0100 Message-Id: <20181114090027.7580-5-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20181114090027.7580-1-benjamin.gaignard@linaro.org> References: <20181114090027.7580-1-benjamin.gaignard@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181114_010052_639037_3794388E X-CRM114-Status: GOOD ( 10.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Benjamin Gaignard , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Gaignard , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Benjamin Gaignard Signed-off-by: Benjamin Gaignard Signed-off-by: Benjamin Gaignard --- arch/arm/boot/dts/stm32mp157c-ed1.dts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/boot/dts/stm32mp157c-ed1.dts b/arch/arm/boot/dts/stm32mp157c-ed1.dts index f77bea49c079..158a337b3129 100644 --- a/arch/arm/boot/dts/stm32mp157c-ed1.dts +++ b/arch/arm/boot/dts/stm32mp157c-ed1.dts @@ -94,3 +94,7 @@ vdda1v1-supply = <®11>; vdda1v8-supply = <®18>; }; + +&hsem { + status = "okay"; +};