From patchwork Wed Nov 30 22:08:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 1710685 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=uuYII3xz; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=IFdzc3kD; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NMtf84VMYz23pF for ; Thu, 1 Dec 2022 09:09:20 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LpuVs0q8T3/tXBW4kRUnUTw+EN1YbzaQaiulbSHUKis=; b=uuYII3xzXlaN/s 0GhgO9K1t/TFu5YlcTiezJ3fFrT/+kuvvsa8+gYdjnga2B8qxn40OIF+70BsNRjYmoiRH95eRecg8 KZQv++/PuOITz8i0JZd493t0Pa1E/hYPPcBbh7vi23U1xoLvHZhfB3hICryD+HB79Q8Qdo8yDBC0y f5JLzeSclTbHJmL27qtDTaRX966zbLMbAeGaWJNIS5iJWf6hb6cY3JIx8WXsJdJDHgOo22cEJDGF/ 8fD4a4DqNFkgO3UHrLt/w1VfheXPQjtm15UHbxyHxnxhu6ZI7HjMWv6ERbggMWUPxg3BNOA0wXGeW DKoW0ZGj3cqG7/1Z4/SA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0VGH-002wJq-PD; Wed, 30 Nov 2022 22:09:01 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0VGD-002wH1-Me for opensbi@lists.infradead.org; Wed, 30 Nov 2022 22:08:59 +0000 Received: by mail-wm1-x331.google.com with SMTP id o30so14209471wms.2 for ; Wed, 30 Nov 2022 14:08:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=QEF7QXiEqLTmiBpGUzWZXfwrwRzLVYYNCFZXTuVXuSk=; b=IFdzc3kDIUT/K/YN/Zd46FxHc7m/1aDEWUjWYZ9qOhrJwRWWNvtWywC1buTLm81rGZ /QX5DtgtDNlTMRptsyQtAFogG5wAhCKvU6uOHwDmj1hdvla5mSY0PBU2DxiuPmJ+iJ7N BtPj5d5+w2RmvA1QKpryf+7Vh3DAnJNeNWvryIAuJ2YEOAMs+ced63vnK0oCsjBh6Ww6 8kPsygLG4iVehGb7ErIU1XBKdo3QHoEUWrZAzqYLHInTGFkFn155Rya/yn94oi14LhNb JuxKMj+4vfsgM1maavoTWJNNfECOT64RvYkZ0zE3Rm15BH8lV5ZUlJJdbGz6N5p+FoLV oq/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QEF7QXiEqLTmiBpGUzWZXfwrwRzLVYYNCFZXTuVXuSk=; b=7zga3wRuT3y1s4tR6+GpYbOoiSSIN/xMQxtt0mSFumKSq1ktkzqD8URK6g8lsd8CqL iXsCsGLlhyTryDpZ5D5t0AgdZiYoZUO6e2+tKTo77OY3DqQKOuU6EN/ITEdSAVHOtjxF LlAD/Nxhv+NxbGQNWPiZ5nAxzuC5wFV1FSuUGwaRMieGSQTj48/mzJa5X2lG5t8GLMHc KPEF7DlDgXisN/n9bzYVB9YYHek47WGz7sPrja0Tadr5JW5ibav03l997zS9ZJgPbGPv HNJ86Fa/C4Wi5ebTi2285mjyzFt+csbAfSsDq6WdRUu1p29204SBYTntz2g3i1eVC6lP +cQA== X-Gm-Message-State: ANoB5plKHtunjuvQ4M2v4n/bkxzwQBxhuwt1C9G8lfp+XExBdGdRgYFh DtOUeZbgZcfbEHYOQGuEllM= X-Google-Smtp-Source: AA0mqf6SbvZWVXxrjymg12awRaLqChKvud/AyTmHf8X2/203SlDBBo5PHG8YUfuf/7hpqMpnZ6kiHg== X-Received: by 2002:a05:600c:ac1:b0:3c6:d18b:304b with SMTP id c1-20020a05600c0ac100b003c6d18b304bmr33596892wmr.142.1669846134518; Wed, 30 Nov 2022 14:08:54 -0800 (PST) Received: from prasmi.home ([2a00:23c8:2501:c701:a876:e68e:5e5f:704e]) by smtp.gmail.com with ESMTPSA id co16-20020a0560000a1000b00241b6d27ef1sm2722567wrb.104.2022.11.30.14.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 14:08:53 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Anup Patel , Atish Patra , opensbi@lists.infradead.org Cc: Yu Chien Peter Lin , Bin Meng , Andrew Jones , Prabhakar , Biju Das , Chris Paterson , Lad Prabhakar Subject: [PATCH v3 2/6] lib: utils: serial: Add FDT driver for Renesas SCIF Date: Wed, 30 Nov 2022 22:08:21 +0000 Message-Id: <20221130220825.193693-3-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221130220825.193693-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20221130220825.193693-1-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221130_140857_792067_6A0AE3BB X-CRM114-Status: GOOD ( 16.22 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Lad Prabhakar Add FDT driver for Renesas SCIF. dts example: Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [prabhakar.csengg[at]gmail.com] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:331 listed in] [list.dnswl.org] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's 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.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Lad Prabhakar Add FDT driver for Renesas SCIF. dts example: soc: soc { .... scif0: serial@1004b800 { compatible = "renesas,scif-r9a07g043", "renesas,scif-r9a07g044"; reg = <0 0x1004b800 0 0x400>; interrupts = <412 IRQ_TYPE_LEVEL_HIGH>, <414 IRQ_TYPE_LEVEL_HIGH>, <415 IRQ_TYPE_LEVEL_HIGH>, <413 IRQ_TYPE_LEVEL_HIGH>, <416 IRQ_TYPE_LEVEL_HIGH>, <416 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "eri", "rxi", "txi", "bri", "dri", "tei"; clocks = <&cpg CPG_MOD R9A07G043_SCIF0_CLK_PCK>; clock-names = "fck"; power-domains = <&cpg>; resets = <&cpg R9A07G043_SCIF0_RST_SYSTEM_N>; status = "disabled"; }; .... }; Signed-off-by: Lad Prabhakar Reviewed-by: Anup Patel --- v2->v3 * No change RFC->v2 * Dropped DEFAULT_RENESAS_SCIF_REG_SHIFT and DEFAULT_RENESAS_SCIF_REG_IO_WIDTH macros. DT binding [0]. [0] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/Documentation/devicetree/bindings/serial/renesas,scif.yaml?h=next-20221111#n80 --- include/sbi_utils/fdt/fdt_helper.h | 3 +++ lib/utils/fdt/fdt_helper.c | 11 ++++++++ lib/utils/serial/Kconfig | 5 ++++ lib/utils/serial/fdt_serial_renesas_scif.c | 31 ++++++++++++++++++++++ lib/utils/serial/objects.mk | 3 +++ 5 files changed, 53 insertions(+) create mode 100644 lib/utils/serial/fdt_serial_renesas_scif.c diff --git a/include/sbi_utils/fdt/fdt_helper.h b/include/sbi_utils/fdt/fdt_helper.h index c39f77a..09f3095 100644 --- a/include/sbi_utils/fdt/fdt_helper.h +++ b/include/sbi_utils/fdt/fdt_helper.h @@ -59,6 +59,9 @@ int fdt_parse_timebase_frequency(void *fdt, unsigned long *freq); int fdt_parse_gaisler_uart_node(void *fdt, int nodeoffset, struct platform_uart_data *uart); +int fdt_parse_renesas_scif_node(void *fdt, int nodeoffset, + struct platform_uart_data *uart); + int fdt_parse_shakti_uart_node(void *fdt, int nodeoffset, struct platform_uart_data *uart); diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c index d4b38dc..48bc2fe 100644 --- a/lib/utils/fdt/fdt_helper.c +++ b/lib/utils/fdt/fdt_helper.c @@ -23,6 +23,9 @@ #define DEFAULT_UART_REG_IO_WIDTH 1 #define DEFAULT_UART_REG_OFFSET 0 +#define DEFAULT_RENESAS_SCIF_FREQ 100000000 +#define DEFAULT_RENESAS_SCIF_BAUD 115200 + #define DEFAULT_SIFIVE_UART_FREQ 0 #define DEFAULT_SIFIVE_UART_BAUD 115200 @@ -355,6 +358,14 @@ int fdt_parse_gaisler_uart_node(void *fdt, int nodeoffset, DEFAULT_UART_BAUD); } +int fdt_parse_renesas_scif_node(void *fdt, int nodeoffset, + struct platform_uart_data *uart) +{ + return fdt_parse_uart_node_common(fdt, nodeoffset, uart, + DEFAULT_RENESAS_SCIF_FREQ, + DEFAULT_RENESAS_SCIF_BAUD); +} + int fdt_parse_shakti_uart_node(void *fdt, int nodeoffset, struct platform_uart_data *uart) { diff --git a/lib/utils/serial/Kconfig b/lib/utils/serial/Kconfig index f6ed803..e3589ca 100644 --- a/lib/utils/serial/Kconfig +++ b/lib/utils/serial/Kconfig @@ -24,6 +24,11 @@ config FDT_SERIAL_HTIF select SYS_HTIF default n +config FDT_SERIAL_RENESAS_SCIF + bool "Renesas SCIF FDT driver" + select SERIAL_RENESAS_SCIF + default n + config FDT_SERIAL_SHAKTI bool "Shakti UART FDT driver" select SERIAL_SHAKTI diff --git a/lib/utils/serial/fdt_serial_renesas_scif.c b/lib/utils/serial/fdt_serial_renesas_scif.c new file mode 100644 index 0000000..c331ca1 --- /dev/null +++ b/lib/utils/serial/fdt_serial_renesas_scif.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: BSD-2-Clause +/* + * Copyright (C) 2022 Renesas Electronics Corporation + */ + +#include +#include +#include + +static int serial_renesas_scif_init(void *fdt, int nodeoff, + const struct fdt_match *match) +{ + struct platform_uart_data uart = { 0 }; + int ret; + + ret = fdt_parse_renesas_scif_node(fdt, nodeoff, &uart); + if (ret) + return ret; + + return renesas_scif_init(uart.addr, uart.freq, uart.baud); +} + +static const struct fdt_match serial_renesas_scif_match[] = { + { .compatible = "renesas,scif-r9a07g043" }, + { /* sentinel */ } +}; + +struct fdt_serial fdt_serial_renesas_scif = { + .match_table = serial_renesas_scif_match, + .init = serial_renesas_scif_init +}; diff --git a/lib/utils/serial/objects.mk b/lib/utils/serial/objects.mk index 6520424..1e6bd2e 100644 --- a/lib/utils/serial/objects.mk +++ b/lib/utils/serial/objects.mk @@ -19,6 +19,9 @@ libsbiutils-objs-$(CONFIG_FDT_SERIAL_GAISLER) += serial/fdt_serial_gaisler.o carray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_HTIF) += fdt_serial_htif libsbiutils-objs-$(CONFIG_FDT_SERIAL_HTIF) += serial/fdt_serial_htif.o +carray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_RENESAS_SCIF) += fdt_serial_renesas_scif +libsbiutils-objs-$(CONFIG_FDT_SERIAL_RENESAS_SCIF) += serial/fdt_serial_renesas_scif.o + carray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_SHAKTI) += fdt_serial_shakti libsbiutils-objs-$(CONFIG_FDT_SERIAL_SHAKTI) += serial/fdt_serial_shakti.o