From nobody Fri Apr 3 04:09:03 2026 Received: from mail-dy1-f228.google.com (mail-dy1-f228.google.com [74.125.82.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03C7A2EA151 for ; Tue, 24 Feb 2026 22:04:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.228 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771970685; cv=none; b=AZi8SNb4qFNOjpC2WdWpMAg0l6CWx0Y5KO6EfEVNv8aTs9MbarcE3iUFHPJhK53NPt+MockUnDGN07bbw+DJ5/pS9GeTv6Zb3dY99MWLsz52jt+8yRC9u+Luo4NGlz6xfcHtGkn3uPlxoQCLwV13WR+kGqPeVfAM/K3TSkNTlhQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771970685; c=relaxed/simple; bh=5oVJd2K0SSd/g7EHCAssVRhoQWOkXnnMU02dVY35emo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tbkHLDAPCZGqS2Cwegnife107dEXJXOi1cDyRmPap6VSFYVQz6yKgDzhQsYkCsckFeNPjqfYLRbl3/MkhBuA7y17uJLdOgij41IgjlCg5ToT/6Mk0ZnRXy1bw0jqhaPrWZoBS0ya3gSgZy9Iw9+mx35RsLrDQJYgj5Q1Mm0rFzE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=e/I0dOYC; arc=none smtp.client-ip=74.125.82.228 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="e/I0dOYC" Received: by mail-dy1-f228.google.com with SMTP id 5a478bee46e88-2ba88e53b46so146239eec.1 for ; Tue, 24 Feb 2026 14:04:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771970683; x=1772575483; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ODday1WVPLIDMOZF0cQx8EO46XTC+ThUzCG+rg0DrFk=; b=PrPz7DunnjItrvki9n9R5ACu7RTBD+KXrHzgzFTJV1YBMsJ7HCifW4+3xVZGZvRIxC tVGyhD56ysQiGmCbzoBxOMG39a5K+BbkyJeWWkO6580gw15iB5Fow61UuuOpu+VpBo9V EagMdGaW4u+D9Yw0xWhSuHIEIJDfcKUV0z2T2PZMowR5JP/InjpLkBMwTdOMKYqSzr+w 6fYCQSIQmjFXUtp/3O2vWahxeNeslga5GZ7+MoK0jCeTHAvVomWgiXyRsqa68HMAqNMS UA2frjxXvCRSYhjqGP5/Z2vitj5aQo/ixbqi86GpGAPToeCVYKpKe2ecOMUecS2UmK+F R2Aw== X-Forwarded-Encrypted: i=1; AJvYcCWBMsW8WpKetc5WUKq+wNAzShD4bvWgW/w5ADClnjJZrR7I/wjn9Lyzuv5U6Bt/n8yNPGER/mdq15P30Ts=@vger.kernel.org X-Gm-Message-State: AOJu0YyEEjplAUveT5k+TfHxNdetFEYKw4KJ/3tb2DngjpIViEWqw2Ap hp8GZHoXWfSeltKKefkHITLtHNb7A/P6/h3p4og/qNRZLbN1RaVCK3C+cETS2VE01iEGcDmI24H 2NbEQCMg4NciTDd+zSDZql8LLg2zjg0cg9cEEZmhobEoUd7DpnSeY1oGH4BvgwjtLFaf+lTsHDG YTd9z7z+d1k5O0DWT2fUjyLCa4b5b2sp7rGVWAADftmBxHsSTSAF2cDSRxKEgWo+ESrvf2dS42P uaQ5MhUEuQtN/Jx X-Gm-Gg: ATEYQzxPW1zAj9f/4z/ycfxNTItpc4mGIwqol9WKz9MAvkYrWfEFLEdO7o7osO7+nc+ hLzjuMA0BWZ3xj/hkf5R3v9pBQPVIUeWUUQS/rPz9mTrXGiDYXUPaF6GsnLkH29gRSB3her2X4H C68hGNb6TYalC/FCjNlELJBnOAcvqn3OijuJ0nXNxGTnSE5k+CsWVyFJw2/gnglPnjJKFyOIxkv HbHhq6a64iC8veYhFdW3iqDIXT2ZsXfpSn10gNn2gimMeCreXBRV+fxk+SZvuFzWCWELrCghlwL NtXs5MS6dhqyWqdY/SU/1IJw0eILXpcxyO+zqDhndsE9Cbz07uP8xh4wjgIfrW4nBJRPWLlieOb NPirdT3N1bnAmJ5KiqEhnsQdL3CtHSUxIy5ZV051HM2Pq1y6NkWmA3RgMjCeELoy+8Bs7A42XfG BBLGNLjQPtxCs/zzrt5VPEkv9bN4+29KqGPkiuSHBdw9zCJLKvUon0hh0b X-Received: by 2002:a05:7300:6da4:b0:2ba:76e1:39fe with SMTP id 5a478bee46e88-2bdbc3075f9mr602999eec.6.1771970682791; Tue, 24 Feb 2026 14:04:42 -0800 (PST) Received: from smtp-us-east1-p01-i01-si01.dlp.protect.broadcom.com (address-144-49-247-103.dlp.protect.broadcom.com. [144.49.247.103]) by smtp-relay.gmail.com with ESMTPS id 5a478bee46e88-2bd7d80e8c9sm1318159eec.0.2026.02.24.14.04.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Feb 2026 14:04:42 -0800 (PST) X-Relaying-Domain: broadcom.com X-CFilter-Loop: Reflected Received: by mail-dy1-f200.google.com with SMTP id 5a478bee46e88-2bda35eab74so208366eec.0 for ; Tue, 24 Feb 2026 14:04:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1771970681; x=1772575481; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ODday1WVPLIDMOZF0cQx8EO46XTC+ThUzCG+rg0DrFk=; b=e/I0dOYCtspgdWItPuDsbaxEODJF3Bk3149Zj0BLRIBdgZhXtlwieA6Jd9s/TLwgI4 mUmIOov03WjsuuuBVJNGouCPu3FjDqHcvcCzIEPUgKMRIqqiLsM4ne6UWtcoIwrBukzV ZeRYFAHQJ9YZYRxyGgIz+gsZIeU1goO+0cJ1w= X-Forwarded-Encrypted: i=1; AJvYcCVutjC8JNOSzkBPLGFGVZh873yylCcIwndza5NLZnWbxei7x3W85wHHPA9bA0pn3gJNCRvh27GsPXNc2w8=@vger.kernel.org X-Received: by 2002:a05:7301:7015:b0:2ba:7b2a:6a5f with SMTP id 5a478bee46e88-2bdbc347a89mr507204eec.8.1771970680920; Tue, 24 Feb 2026 14:04:40 -0800 (PST) X-Received: by 2002:a05:7301:7015:b0:2ba:7b2a:6a5f with SMTP id 5a478bee46e88-2bdbc347a89mr507193eec.8.1771970680284; Tue, 24 Feb 2026 14:04:40 -0800 (PST) Received: from mail.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2bdb055507bsm2374822eec.0.2026.02.24.14.04.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Feb 2026 14:04:39 -0800 (PST) From: Kamal Dasu To: andersson@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org Cc: baolin.wang@linux.alibaba.com, florian.fainelli@broadcom.com, bcm-kernel-feedback-list@broadcom.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Kamal Dasu Subject: [PATCH v6 2/3] hwspinlock: brcmstb hardware semaphore support Date: Tue, 24 Feb 2026 17:04:06 -0500 Message-Id: <20260224220407.2351692-3-kamal.dasu@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260224220407.2351692-1-kamal.dasu@broadcom.com> References: <20260224220407.2351692-1-kamal.dasu@broadcom.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-DetectorID-Processed: b00c1d49-9d2e-4205-b15f-d015386d3d5e Content-Type: text/plain; charset="utf-8" Broadcom settop SoCs have common 16 hardware semaphore registers that can be used as part of the kernel hardware spinlock framework. The hardware semaphores are part of the 'sundry' ip block that also has controls like pin/mux controls, SoC identification, drive strength, reset controls, and other misc bits. Adding support for brcmstb_hwspinlock that only maps sundry block registers SUN_TOP_CTRL_SEMAPHORE_[0:15] to implement the hardware spinlock operations. Change allows other Broadcom settop drivers to call hwspin_trylock() and hwspin_unlock() interfaces to make use of hwspinlock framework. Other driver dt nodes just need to provide a reference to the &hwspinlock and lock id to make use of a particular hardware lock. e.g. hwlocks =3D <&hwspinlock0 0>; Signed-off-by: Kamal Dasu --- drivers/hwspinlock/Kconfig | 11 ++- drivers/hwspinlock/Makefile | 1 + drivers/hwspinlock/brcmstb_hwspinlock.c | 96 +++++++++++++++++++++++++ 3 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 drivers/hwspinlock/brcmstb_hwspinlock.c diff --git a/drivers/hwspinlock/Kconfig b/drivers/hwspinlock/Kconfig index 3874d15b0e9b..9b7f7bcce14b 100644 --- a/drivers/hwspinlock/Kconfig +++ b/drivers/hwspinlock/Kconfig @@ -8,6 +8,16 @@ menuconfig HWSPINLOCK =20 if HWSPINLOCK =20 +config HWSPINLOCK_BRCMSTB + tristate "Broadcom Settop Hardware Semaphore functionality" + depends on ARCH_BRCMSTB || COMPILE_TEST + help + Broadcom settop hwspinlock driver. + Say y here to support the Broadcom Hardware Semaphore functionality, wh= ich + provides a synchronisation mechanism on the SoC. + + If unsure, say N. + config HWSPINLOCK_OMAP tristate "OMAP Hardware Spinlock device" depends on ARCH_OMAP4 || SOC_OMAP5 || SOC_DRA7XX || SOC_AM33XX || SOC_AM4= 3XX || ARCH_K3 || COMPILE_TEST @@ -62,5 +72,4 @@ config HSEM_U8500 SoC. =20 If unsure, say N. - endif # HWSPINLOCK diff --git a/drivers/hwspinlock/Makefile b/drivers/hwspinlock/Makefile index a0f16c9aaa82..35f2d94d8ba2 100644 --- a/drivers/hwspinlock/Makefile +++ b/drivers/hwspinlock/Makefile @@ -4,6 +4,7 @@ # =20 obj-$(CONFIG_HWSPINLOCK) +=3D hwspinlock_core.o +obj-$(CONFIG_HWSPINLOCK_BRCMSTB) +=3D brcmstb_hwspinlock.o obj-$(CONFIG_HWSPINLOCK_OMAP) +=3D omap_hwspinlock.o obj-$(CONFIG_HWSPINLOCK_QCOM) +=3D qcom_hwspinlock.o obj-$(CONFIG_HWSPINLOCK_SPRD) +=3D sprd_hwspinlock.o diff --git a/drivers/hwspinlock/brcmstb_hwspinlock.c b/drivers/hwspinlock/b= rcmstb_hwspinlock.c new file mode 100644 index 000000000000..7a5a35e741f3 --- /dev/null +++ b/drivers/hwspinlock/brcmstb_hwspinlock.c @@ -0,0 +1,96 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * brcmstb HWSEM driver + * + * Copyright (C) 2025 Broadcom + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "hwspinlock_internal.h" + +#define BRCMSTB_NUM_SEMAPHORES 16 +#define RESET_SEMAPHORE 0 + +#define HWSPINLOCK_VAL 'L' + +static int brcmstb_hwspinlock_trylock(struct hwspinlock *lock) +{ + void __iomem *lock_addr =3D (void __iomem *)lock->priv; + + writel(HWSPINLOCK_VAL, lock_addr); + + return (readl(lock_addr) =3D=3D HWSPINLOCK_VAL); +} + +static void brcmstb_hwspinlock_unlock(struct hwspinlock *lock) +{ + void __iomem *lock_addr =3D (void __iomem *)lock->priv; + + /* release the lock by writing 0 to it */ + writel(RESET_SEMAPHORE, lock_addr); +} + +static void brcmstb_hwspinlock_relax(struct hwspinlock *lock) +{ + ndelay(50); +} + +static const struct hwspinlock_ops brcmstb_hwspinlock_ops =3D { + .trylock =3D brcmstb_hwspinlock_trylock, + .unlock =3D brcmstb_hwspinlock_unlock, + .relax =3D brcmstb_hwspinlock_relax, +}; + +static int brcmstb_hwspinlock_probe(struct platform_device *pdev) +{ + struct hwspinlock_device *bank; + struct hwspinlock *hwlock; + void __iomem *io_base; + int i, num_locks =3D BRCMSTB_NUM_SEMAPHORES; + + io_base =3D devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(io_base)) { + dev_err(&pdev->dev, "semaphore iobase mapping error\n"); + return PTR_ERR(io_base); + } + + bank =3D devm_kzalloc(&pdev->dev, struct_size(bank, lock, num_locks), + GFP_KERNEL); + if (!bank) + return -ENOMEM; + + for (i =3D 0, hwlock =3D &bank->lock[0]; i < num_locks; i++, hwlock++) + hwlock->priv =3D (void __iomem *)(io_base + sizeof(u32) * i); + + return devm_hwspin_lock_register(&pdev->dev, bank, + &brcmstb_hwspinlock_ops, + 0, num_locks); +} + +static const struct of_device_id brcmstb_hwspinlock_ids[] =3D { + { .compatible =3D "brcm,bcm7038-sun-top-ctrl-semaphore", }, + { /* end */ }, +}; +MODULE_DEVICE_TABLE(of, brcmstb_hwspinlock_ids); + +static struct platform_driver brcmstb_hwspinlock_driver =3D { + .probe =3D brcmstb_hwspinlock_probe, + .driver =3D { + .name =3D "brcmstb_hwspinlock", + .of_match_table =3D brcmstb_hwspinlock_ids, + }, +}; + +module_platform_driver(brcmstb_hwspinlock_driver); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Hardware Spinlock driver for brcmstb"); +MODULE_AUTHOR("Kamal Dasu "); --=20 2.34.1