From patchwork Mon Dec 2 22:05:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 180653 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp610376ile; Mon, 2 Dec 2019 14:05:52 -0800 (PST) X-Google-Smtp-Source: APXvYqxeNyTv0s6Dw22i3XfX+Mq8kAVgWNSReimP2G4VbwQpsCvBfKMm6NIGcp5wS/vhhZL0abs1 X-Received: by 2002:aa7:db55:: with SMTP id n21mr1594383edt.31.1575324352739; Mon, 02 Dec 2019 14:05:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575324352; cv=none; d=google.com; s=arc-20160816; b=CSJU7vQ5b480DfNWgE4TjIS8LkzttXvLBOwOeqByMzr/7qO3Tu/xKrYzWGzu/Bc+X9 MjjqAEiWmtlNCWdHTPpbUVHGwHDiWHw3PS0yQyJcS7uKGPXJYFBVsPjnA8DByCJZEdBY OGd5r8ZcuYLTnybW59oxkDMj/MLxvZjbNxVN9kjTRMLEvnz8dt6ErGpQJrKdsNdLDyHo yBVs6LHkV6tSE3uDJt6u+FuqjUZnOn0+tdUEV7Ddb2EI4xa6no/+RFpHuLy4OgoZgrY0 vJ41FQnTz1cSpOfP5+RSjDjp/thZRrhyS5EnkynMvKkuliFbfhXGLTh0zy+ABAGZh8kp KhSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=bIvSNKxywYCzsgLuA0tW2v/Nc9rkoq3VSAFz+AiYIuw=; b=eGFpLsX4G89zkL3HkingAHbmVMwB+ofM6gEgHrOvWL+JgBnAXYnUpEX0rHsT6DP1mz evWjfEYj8G6eAAGF/6OUMlsGWiCGSS0BGdQkERXp+GaGDa4x/BC6k05k+1h5pO9+cAE8 wBthTpuuVA+9niHAymvnlyK8VxBCNiPwlSSM7i7fN5QaNfvQR2gxEDBhOudGWeR5O4IA RRgowUaW//nL26v0NG3Vnz2G54UWzUAhe3in8M7jjLeVGT9mcFs7mmePTo7BEJ9Lt+Ri Vpm19oHdU5Zo45LG34LEXD+wHTCb7GryiCzmlcjFVYrEHLB67S8XKq06dBDtsx2hk0WA WSEA== ARC-Authentication-Results: i=1; mx.google.com; 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 f13si660455edq.71.2019.12.02.14.05.52; Mon, 02 Dec 2019 14:05:52 -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; 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 S1726804AbfLBWFu (ORCPT + 27 others); Mon, 2 Dec 2019 17:05:50 -0500 Received: from mx2.suse.de ([195.135.220.15]:49136 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726645AbfLBWFs (ORCPT ); Mon, 2 Dec 2019 17:05:48 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B9492B2ED; Mon, 2 Dec 2019 22:05:45 +0000 (UTC) From: =?utf-8?q?Andreas_F=C3=A4rber?= To: linux-realtek-soc@lists.infradead.org Cc: Cheng-Yu Lee , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, =?utf-8?q?Andreas_F=C3=A4rber?= , Ohad Ben-Cohen , Bjorn Andersson , linux-remoteproc@vger.kernel.org Subject: [RFC 2/5] hwspinlock: Add Realtek RTD1195 SB2 Date: Mon, 2 Dec 2019 23:05:32 +0100 Message-Id: <20191202220535.6208-3-afaerber@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20191202220535.6208-1-afaerber@suse.de> References: <20191202220535.6208-1-afaerber@suse.de> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implement a driver for hardware semaphores found in RTD1195 SoC. It allows for both per-register instances (SB2_HD_SEM) as well as contiguous register ranges (SB2_HD_SEM_NEW[0-7]). While these registers are part of the SB2 syscon, this implementation does not use syscon, to allow assigning one as SB2 syscon's hwlock. Cc: Cheng-Yu Lee Signed-off-by: Andreas Färber --- drivers/hwspinlock/Kconfig | 11 ++++ drivers/hwspinlock/Makefile | 1 + drivers/hwspinlock/rtd1195_sb2_sem.c | 101 +++++++++++++++++++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 drivers/hwspinlock/rtd1195_sb2_sem.c -- 2.16.4 diff --git a/drivers/hwspinlock/Kconfig b/drivers/hwspinlock/Kconfig index 37740e992cfa..9c26c436d399 100644 --- a/drivers/hwspinlock/Kconfig +++ b/drivers/hwspinlock/Kconfig @@ -28,6 +28,17 @@ config HWSPINLOCK_QCOM If unsure, say N. +config HWSPINLOCK_RTD1195_SB2 + tristate "Realtek RTD1195 SB2 Hardware Spinlock device" + depends on HWSPINLOCK + depends on ARCH_REALTEK || COMPILE_TEST + default ARCH_REALTEK + help + Say y here to support the Realtek Hardware Semaphore functionality, + found on the RTD1195 and later SoC families. + + If unsure, say N. + config HWSPINLOCK_SIRF tristate "SIRF Hardware Spinlock device" depends on HWSPINLOCK diff --git a/drivers/hwspinlock/Makefile b/drivers/hwspinlock/Makefile index ed053e3f02be..d5bd59412468 100644 --- a/drivers/hwspinlock/Makefile +++ b/drivers/hwspinlock/Makefile @@ -6,6 +6,7 @@ obj-$(CONFIG_HWSPINLOCK) += hwspinlock_core.o obj-$(CONFIG_HWSPINLOCK_OMAP) += omap_hwspinlock.o obj-$(CONFIG_HWSPINLOCK_QCOM) += qcom_hwspinlock.o +obj-$(CONFIG_HWSPINLOCK_RTD1195_SB2) += rtd1195_sb2_sem.o obj-$(CONFIG_HWSPINLOCK_SIRF) += sirf_hwspinlock.o obj-$(CONFIG_HWSPINLOCK_SPRD) += sprd_hwspinlock.o obj-$(CONFIG_HWSPINLOCK_STM32) += stm32_hwspinlock.o diff --git a/drivers/hwspinlock/rtd1195_sb2_sem.c b/drivers/hwspinlock/rtd1195_sb2_sem.c new file mode 100644 index 000000000000..ae925d057874 --- /dev/null +++ b/drivers/hwspinlock/rtd1195_sb2_sem.c @@ -0,0 +1,101 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * RTD1195 SB2 hardware semaphore + * + * Copyright (c) 2019 Andreas Färber + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "hwspinlock_internal.h" + +struct rtd1195_sb2_sem { + struct platform_device *pdev; + void __iomem *base; + int base_id; + struct hwspinlock_device lockdev; +}; + +static DEFINE_IDR(rtd1195_sb2_sem_idr); + +static int rtd1195_sb2_sem_trylock(struct hwspinlock *lock) +{ + void __iomem *reg = (void __iomem *)lock->priv; + + return readl_relaxed(reg) & BIT(0); +} + +static void rtd1195_sb2_sem_unlock(struct hwspinlock *lock) +{ + void __iomem *reg = (void __iomem *)lock->priv; + + writel_relaxed(0, reg); +} + +static const struct hwspinlock_ops rtd1195_sb2_sem_hwspinlock_ops = { + .trylock = rtd1195_sb2_sem_trylock, + .unlock = rtd1195_sb2_sem_unlock, +}; + +static int rtd1195_sb2_sem_probe(struct platform_device *pdev) +{ + struct rtd1195_sb2_sem *sem; + struct hwspinlock *lock; + struct resource *res; + int i, num; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -ENOMEM; + + num = resource_size(res) / 4; + + sem = devm_kzalloc(&pdev->dev, sizeof(*sem) + num * sizeof(*lock), + GFP_KERNEL); + if (!sem) + return -ENOMEM; + + sem->pdev = pdev; + + sem->base = of_iomap(pdev->dev.of_node, 0); + if (!sem->base) + return -ENOMEM; + + for (i = 0; i < num; i++) { + lock = &sem->lockdev.lock[i]; + lock->priv = sem->base + i * 4; + } + + platform_set_drvdata(pdev, sem); + + sem->base_id = idr_alloc(&rtd1195_sb2_sem_idr, sem, 0, 0, GFP_KERNEL); + + return devm_hwspin_lock_register(&pdev->dev, &sem->lockdev, + &rtd1195_sb2_sem_hwspinlock_ops, sem->base_id, num); +} + +static const struct of_device_id rtd1195_sb2_sem_dt_ids[] = { + { .compatible = "realtek,rtd1195-sb2-sem" }, + { } +}; +MODULE_DEVICE_TABLE(of, rtd1195_sb2_sem_dt_ids); + +static struct platform_driver rtd1195_sb2_sem_platform_driver = { + .driver = { + .name = "rtd1195-sb2-sem", + .of_match_table = rtd1195_sb2_sem_dt_ids, + }, + .probe = rtd1195_sb2_sem_probe, +}; +module_platform_driver(rtd1195_sb2_sem_platform_driver); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Hardware spinlock driver for Realtek RTD1195 SB2"); +MODULE_AUTHOR("Andreas Färber "); From patchwork Mon Dec 2 22:05:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 180655 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp610658ile; Mon, 2 Dec 2019 14:06:06 -0800 (PST) X-Google-Smtp-Source: APXvYqz4xZQ1pUXbD2Gjnv18jHtPAQoXpWap9MtH1n+OWIv10qrC3u/dZyLKrNAWxPD7f+8xlyI2 X-Received: by 2002:a50:9b10:: with SMTP id o16mr1544730edi.117.1575324366317; Mon, 02 Dec 2019 14:06:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575324366; cv=none; d=google.com; s=arc-20160816; b=JaAiOPBClrOWwEFOsaS9Q/iLkUL5mUgE83RIelhdLLqAZKHoortaYsgqn8q+TDr5YS UM8qgtDmFwQzA8mflluL6cjuUt5PlCnmA9KTYit8xA73RXGMr61U62vAcnoAIH0dmTfM kkxOWL1L3LOLp1OfiEWr0TrNAUf+m/1iCOUAxAEEcReJ7YR7HQ4UZFm60EzcopyOtoKD nqR5A/aXdpOgVZUaOEvPAvhO41FDQEHnl8Ee8A+C3KXRlgOaNi8p4rg9VzcdZiOX8a0j 2cnOqM81FoakbO4QZhv86uOmCM03dGR+4QZ5ctE4edwoKdEtK7tukHNalYGaG1GdfvS4 pH7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=UNd7Ah1PivNA0SFpJuJ6d8XzSxVHwc3sKrf37kqCLR4=; b=0L64cE3lf5WLwTFMFV/QFa0sZ+258BmtETLFWEcHsWipBX3oTBHuyZhkrbyEc0X2GJ GZi83NS+D9HZmDeeUHwYOWVFhbYymT+L4MQnFLCEoCGX8KT/3CFH6okLCEvZaeWEuKup +YGY3EoW+gkuXc/5TV2TeFDcHnj4auy+lIJNze0xY64m65PeqnSdFsL/HoqFKn17pDbs GzFa36ZnYOj8fW5X8BzHy+xH4/8+ev2kKr66zsx6W7hrBrlZSlU9N4u0FVqGbfaadBps Ji2vxSpkvLKI/HtA/+9zP+JXubuFGu9fgCjLtlBYSWya/MhqJ4yx5NfR9QBIA16M4IKq RXjw== ARC-Authentication-Results: i=1; mx.google.com; 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 e4si648511ejr.210.2019.12.02.14.06.06; Mon, 02 Dec 2019 14:06:06 -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; 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 S1727327AbfLBWGD (ORCPT + 27 others); Mon, 2 Dec 2019 17:06:03 -0500 Received: from mx2.suse.de ([195.135.220.15]:49150 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726741AbfLBWFr (ORCPT ); Mon, 2 Dec 2019 17:05:47 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 2973CB2F0; Mon, 2 Dec 2019 22:05:46 +0000 (UTC) From: =?utf-8?q?Andreas_F=C3=A4rber?= To: linux-realtek-soc@lists.infradead.org Cc: Cheng-Yu Lee , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, =?utf-8?q?Andreas_F=C3=A4rber?= , Rob Herring , Mark Rutland , devicetree@vger.kernel.org Subject: [RFC 3/5] ARM: dts: rtd1195: Add SB2 sem nodes Date: Mon, 2 Dec 2019 23:05:33 +0100 Message-Id: <20191202220535.6208-4-afaerber@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20191202220535.6208-1-afaerber@suse.de> References: <20191202220535.6208-1-afaerber@suse.de> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add DT nodes to SB2 for hardware semaphores on RTD1195 SoC. Signed-off-by: Andreas Färber --- arch/arm/boot/dts/rtd1195.dtsi | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.16.4 diff --git a/arch/arm/boot/dts/rtd1195.dtsi b/arch/arm/boot/dts/rtd1195.dtsi index 21897210d9d0..6fd12a2d766e 100644 --- a/arch/arm/boot/dts/rtd1195.dtsi +++ b/arch/arm/boot/dts/rtd1195.dtsi @@ -215,3 +215,17 @@ status = "disabled"; }; }; + +&sb2 { + sb2_hd_sem: hwspinlock@0 { + compatible = "realtek,rtd1195-sb2-sem"; + reg = <0x0 0x4>; + #hwlock-cells = <0>; + }; + + sb2_hd_sem_new: hwspinlock@620 { + compatible = "realtek,rtd1195-sb2-sem"; + reg = <0x620 0x20>; + #hwlock-cells = <1>; + }; +}; From patchwork Mon Dec 2 22:05:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 180654 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp610476ile; Mon, 2 Dec 2019 14:05:58 -0800 (PST) X-Google-Smtp-Source: APXvYqxsrgdTo8/IbSPlLx0U6MUnk82EmoRzSrrtE8AvK9lwPGkaPuIpHY7Q/MarDCLcLnwIhaya X-Received: by 2002:a05:600c:1051:: with SMTP id 17mr30533895wmx.49.1575324358349; Mon, 02 Dec 2019 14:05:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575324358; cv=none; d=google.com; s=arc-20160816; b=fEc3Ai3MetW/hbydWPxogSmZz438SFerYCUNiJk2Dm373Q+XpMlm1kUfRCJbmpRtbp 3wULfr6nKdLqPbuSxRpaaRhjNcpqou9eoXTtXn6n+5XCoBIKSDz699XihkPLbWaGSRI6 vSJlcf0o1pqFxCNnP8vwjoavjgLF4csQFBs88qw+3K/IDht2hS6NEZRGWbpExlE21epm yQ7AlOqBCt8i1KwxAqLNCpbOYC9H3eIXjh/NHujlBcowaVyS55Ru43bvS7Gol6FCfaNq ctx/1Y6y0niPHf97dty5lCndD+uf+e41w9bgbWK32mYTKRLX/KaEkohEhieVWb+Ze83I sViQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=A9tT/ylhTFyMTHhLtsKap537BDwm1vLMDYo4yPNKrxc=; b=aXBxmSHxn/VDkEVS7ttyt/m480QrotTiKQnlWx7hMs+ecKVHFhrbZztCWGgTXQWbFY RCRVWdy6qYk7gW/csfQSwwmmvdLufWnk0h0jfZkTA7KBAvWRpU6Hw4nuE4bfC/OQEIDD xdKvRcSZOOeLG4YaODIWFAsKEaOeaAEPX1b1juvHainl6zgfx7D2leafy/84Plt6ctfv LS6NwSuQYtq5+2/XE0U7SfcyuZQxd2xHFAmhrBnNeokSfkMuHptoB26TAWFW+Aig2HfS nDm7tY9jLKTN9RHLyrPMZZg7MEZ09KzOExnfVXkAhFgQeqaQkIGmuv223Syqsf1iGp1q gM2A== ARC-Authentication-Results: i=1; mx.google.com; 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 f12si640149ejx.166.2019.12.02.14.05.58; Mon, 02 Dec 2019 14:05:58 -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; 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 S1727313AbfLBWFz (ORCPT + 27 others); Mon, 2 Dec 2019 17:05:55 -0500 Received: from mx2.suse.de ([195.135.220.15]:49170 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726422AbfLBWFs (ORCPT ); Mon, 2 Dec 2019 17:05:48 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 9523AB2F1; Mon, 2 Dec 2019 22:05:46 +0000 (UTC) From: =?utf-8?q?Andreas_F=C3=A4rber?= To: linux-realtek-soc@lists.infradead.org Cc: Cheng-Yu Lee , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, =?utf-8?q?Andreas_F=C3=A4rber?= , Rob Herring , Mark Rutland , devicetree@vger.kernel.org Subject: [RFC 4/5] arm64: dts: realtek: rtd129x: Add SB2 sem nodes Date: Mon, 2 Dec 2019 23:05:34 +0100 Message-Id: <20191202220535.6208-5-afaerber@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20191202220535.6208-1-afaerber@suse.de> References: <20191202220535.6208-1-afaerber@suse.de> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add DT nodes to SB2 for hardware sempaphores in RTD1295 SoC family. Signed-off-by: Andreas Färber --- arch/arm64/boot/dts/realtek/rtd129x.dtsi | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.16.4 diff --git a/arch/arm64/boot/dts/realtek/rtd129x.dtsi b/arch/arm64/boot/dts/realtek/rtd129x.dtsi index 39aefe66a794..93ab6fdd03d4 100644 --- a/arch/arm64/boot/dts/realtek/rtd129x.dtsi +++ b/arch/arm64/boot/dts/realtek/rtd129x.dtsi @@ -193,3 +193,17 @@ status = "disabled"; }; }; + +&sb2 { + sb2_hd_sem: hwspinlock@0 { + compatible = "realtek,rtd1195-sb2-sem"; + reg = <0x0 0x4>; + #hwlock-cells = <0>; + }; + + sb2_hd_sem_new: hwspinlock@620 { + compatible = "realtek,rtd1195-sb2-sem"; + reg = <0x620 0x20>; + #hwlock-cells = <1>; + }; +};