From patchwork Mon May 4 21:20:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1283016 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.a=rsa-sha256 header.s=selector1 header.b=eA9Lj8JJ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49GG4d14GGz9sSc for ; Tue, 5 May 2020 07:21:21 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2D14581FBF; Mon, 4 May 2020 23:20:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.b="eA9Lj8JJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 149AB8201A; Mon, 4 May 2020 23:20:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03on0730.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0a::730]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2372181F9B for ; Mon, 4 May 2020 23:20:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rasmus.villemoes@prevas.dk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kp0h556BBuwms0irnryxEaXomABejsvl9YMdVOJmqA6Fr6DWGjatHN5tEYP/tkIQu1JWJmSgI/2SqLSOBLTOaV907IHJDpUILYUxtqcKhdiRozruPw+XpCebCSVNWrd3wtPxW2Y1cBupZRm3MCRKTwxG4maC0yWzI7xGjUiTv1LPyigrtOf4wQUB9ureuDGp3c8yDfEmbDOSpSoMy6Uood04IBkomUPzUsJdleS9XK+Q98AkDab5qXy1U8IpZG+dJrewjZR5Hzk2VwsBM+PKexNngN9BKQqqwEF2AHDQ58rxSpSKc4IXqFWuAcW141b5WUgURVrbHV3PE3vN4OdAUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R2jlvc5VORg1QfUBH+BkY0XZN08GEHVnAsn7+2PP+tQ=; b=k1TFcTo1ijf1yFrzgjXTmnM7hk6pkRuoJZNGjSGPvxoXycvSQqbr2x9Lcy0NYr9NtJghcnKXiuhbKVInaLIP2OF6uyRPRzAfkiWgIObxt/7DH9kbdFS3CrcO4lr4uJMHRd8AykCVRJqnkMuB6neOVXGZd8e91KpjvSaVL4TVKLR2njy4pXjWPhvovu1w3UhRCekQ+iV5gWw+hsjcZFhhYwPQbzU90J32/V3bgavBue5zbIzHiq10jT0Oay2ghrNStx3xy6DBH9xdOAN3vHHOD99J3KsdehXUTKkq98heDJvTiDtdW5u+I6DgoHN0Tqe9TDzFao+v8yjHzclbdCsC6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R2jlvc5VORg1QfUBH+BkY0XZN08GEHVnAsn7+2PP+tQ=; b=eA9Lj8JJPTY74JHEAQPyO3bqeuqdbR/PBmHqQjXIVjGGzHEN8h8JNXBoO+p+45bXQCacobKgvvGIpbSeG3G2BapTgtTbqIo9kgxfHkXQJlnhspcKaEdhq9hcREzzBvOh/djwPSMRwdsTwqVqgvboT538qWyN4MNoqhRt1j+/FTo= Authentication-Results: lists.denx.de; dkim=none (message not signed) header.d=none;lists.denx.de; dmarc=none action=none header.from=prevas.dk; Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) by VI1PR10MB1598.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:802:31::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.29; Mon, 4 May 2020 21:20:42 +0000 Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::f0ac:4e97:2536:faa]) by VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::f0ac:4e97:2536:faa%7]) with mapi id 15.20.2958.030; Mon, 4 May 2020 21:20:42 +0000 From: Rasmus Villemoes To: u-boot@lists.denx.de Cc: Simon Glass , Heiko Schocher , Lukasz Majewski , Biwen Li , Rasmus Villemoes Subject: [PATCH 1/6] rtc: add rtc_read8_array helper and ->read8_array method Date: Mon, 4 May 2020 23:20:27 +0200 Message-Id: <20200504212032.3759-2-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200504212032.3759-1-rasmus.villemoes@prevas.dk> References: <20200504212032.3759-1-rasmus.villemoes@prevas.dk> X-ClientProxiedBy: AM6PR02CA0018.eurprd02.prod.outlook.com (2603:10a6:20b:6e::31) To VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from prevas-ravi.prevas.se (5.186.116.45) by AM6PR02CA0018.eurprd02.prod.outlook.com (2603:10a6:20b:6e::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.20 via Frontend Transport; Mon, 4 May 2020 21:20:41 +0000 X-Mailer: git-send-email 2.23.0 X-Originating-IP: [5.186.116.45] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5863ae36-6a9b-4a26-5cb5-08d7f071000e X-MS-TrafficTypeDiagnostic: VI1PR10MB1598: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-Forefront-PRVS: 03932714EB X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PkbicyYWe6MvlaiZ+x6tn69r8F8i7gIqCwxLgTt/tdOK1ktIsJnApqfzlYYHS1xHIAal2IV5LfJ99P4+LcKpitWMRyajEPvfNoJ8dGDYGivXpFLiLMSlwO05Mkpp9Kw5dXvGxqH/eqPWOZwBhnpxbDccW27IBq/bwMb/F+J5n0DAIOl5sqCaE8fPDZUseb1o66k34ht5iPm3zeoJZ/Etn4grcK2s6ukk6FpIAAXx9hWt2seRMcWMsSqi4RD2JEQg+QaYxX+866bA2Gwnv5OWKAQwYPC9g7Xr5sv0bSn1PNsm9EaB/MTJ3qHeHSBHiTJDvjq77lUz+WbnzkkrePuWyXy09oqxotcrt993mHfjzyusM5SNl4iTr7tWXeV2794oznheXnXKmc2bEXowYykK66XKPEmG/p9lKv4UKrT8eP9RQWr4xilPJNEklH9YyGEP X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFTY:; SFS:(346002)(376002)(136003)(366004)(396003)(39850400004)(54906003)(6512007)(2616005)(956004)(8676002)(8936002)(8976002)(66556008)(36756003)(66946007)(5660300002)(66476007)(4326008)(6486002)(316002)(44832011)(1076003)(6916009)(86362001)(478600001)(6666004)(107886003)(26005)(16526019)(52116002)(6506007)(2906002)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: JVVwdL3DDWt26QIwGcuQP80qx8M+JyHzvhp6OroHtRV1MVNBCc1OCA0H13blu/LUTkv49HHVr1kJb/E360TjiGBJLbq5lB/zl38C1U/HjMkkbwgQ1Z1IJTmZwx50KBkiKTEo77LjbhO+fdBrtqTu5dxazjJAsERcJeTu1QydNHysTycPG98KDqsG9XFBSpoxUmbwNuW+50rYuNZmCCZh53PifhqeMxjl9R0jcXFOZAAsTTjZbktE8oLsjQT3gO7FTlrFmkPQDCITbeow6MOvzAjbhLA48QAW/cqACV6hlQNjrRbAtNbIZF4ZRXCmdtRFkC54+nIgfOBsapu3g3dhQbrvSNqcRfIOPoqI94dqGWjG16PxoZjiFdIWNj70vwn1wkMeeFmHZ4jVpZm5fmhPI8CRPHwoaH3m9IRwJGfJsNYbHgLy1ITkzVJPIgMxXqhR3XKPWouMAwL0lFd4vqT8+Z4Qw0TL2OeqgjjDtEY/RFGKfkkD3m+BlMyo8z6rUrZ8I+ANKD5CYwPRJxya6A5SwkrY/mKyx+sOPb/DSAddCWShe+sNpvWKVCKILGYS0n0igdq3NPG67xkPfA8rGET4YJYTfw3jt2pG6PvPkG8oHURy1QVQgwbseqgE6ji2UdzPCXiVe+mrVqyT5WvOlUvLCmTPsNdiaeim5PV0HQzYZxqFF559vvtl9gwYH/dj0tsbg/9CeRk1c4j7XuPhC3NISJGDGyUFSWI6nYx3ztmH+umEz9S4jEvOQn1lZ8bgkNWMJb2qVnsXk8Eg55dyNe7z8/ZnmaJqJqn2pG/0yHqOXMs= X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 5863ae36-6a9b-4a26-5cb5-08d7f071000e X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2020 21:20:42.2574 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GfuPk6ylP3s90eDc449yCC0BjXKWd1PSR3qIRkExaJsipZk4+eigCycrzKYvB5nP1eieP4skwJo4nXe2mkPtgato2NU37nEgs+Bf9BSdyyM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB1598 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Some users may want to read multiple consecutive 8-bit registers. Instead of each caller having to implement the loop, provide a rtc_read8_array() helper. Also, allow a driver to provide a read8_array method, which can be more efficient than reading one register at a time. Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass --- drivers/rtc/rtc-uclass.c | 19 +++++++++++++++++++ include/rtc.h | 24 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/drivers/rtc/rtc-uclass.c b/drivers/rtc/rtc-uclass.c index a0a238aedd..5070fb416d 100644 --- a/drivers/rtc/rtc-uclass.c +++ b/drivers/rtc/rtc-uclass.c @@ -49,6 +49,25 @@ int rtc_read8(struct udevice *dev, unsigned int reg) return ops->read8(dev, reg); } +int rtc_read8_array(struct udevice *dev, unsigned int reg, + u8 *buf, unsigned int len) +{ + struct rtc_ops *ops = rtc_get_ops(dev); + + assert(ops); + if (ops->read8_array) + return ops->read8_array(dev, reg, buf, len); + if (!ops->read8) + return -ENOSYS; + while (len--) { + int ret = ops->read8(dev, reg++); + if (ret < 0) + return ret; + *buf++ = ret; + } + return 0; +} + int rtc_write8(struct udevice *dev, unsigned int reg, int val) { struct rtc_ops *ops = rtc_get_ops(dev); diff --git a/include/rtc.h b/include/rtc.h index 8aabfc1162..f7f622c1db 100644 --- a/include/rtc.h +++ b/include/rtc.h @@ -64,6 +64,18 @@ struct rtc_ops { */ int (*read8)(struct udevice *dev, unsigned int reg); + /** + * read8_array() - Read multiple 8-bit registers + * + * @dev: Device to read from + * @reg: First register to read + * @buf: Output buffer + * @len: Number of registers to read + * @return 0 if OK, -ve on error + */ + int (*read8_array)(struct udevice *dev, unsigned int reg, + u8 *buf, unsigned int len); + /** * write8() - Write an 8-bit register * @@ -118,6 +130,18 @@ int dm_rtc_reset(struct udevice *dev); */ int rtc_read8(struct udevice *dev, unsigned int reg); +/** + * rtc_read8_array() - Read multiple 8-bit registers + * + * @dev: Device to read from + * @reg: First register to read + * @buf: Output buffer + * @len: Number of registers to read + * @return 0 if OK, -ve on error + */ +int rtc_read8_array(struct udevice *dev, unsigned int reg, + u8 *buf, unsigned int len); + /** * rtc_write8() - Write an 8-bit register * From patchwork Mon May 4 21:20:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1283017 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.a=rsa-sha256 header.s=selector1 header.b=TT4RQt6d; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49GG4z4JBdz9sRf for ; Tue, 5 May 2020 07:21:39 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C0BD88204D; Mon, 4 May 2020 23:20:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.b="TT4RQt6d"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1D3EA81FD6; Mon, 4 May 2020 23:20:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03on0730.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0a::730]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5CBB781FBE for ; Mon, 4 May 2020 23:20:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rasmus.villemoes@prevas.dk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=atve1Wvf6LUXwQFAIOdVrYV1VHFh4b65p1Mz/Hc+QOp1wnklel0f3ir8QLjyQIJT9HEMvSIXR8jkfKs+ozt5Tqo1EtRN4bT+omJa/1fgX2Yr4Rj/rbsL53YYaE5Cj5xC+EGh23za6WYWFFA4wjJUjF0vLzhFPEbwI+MY98OtCUX9Pys/lrGFxJxtXHOukF43aQj2BIRfDYZ3Vc2yhAuYvxdjkoFBcy5rKO2qSael5BYgmgjEXb2Zf3eFbsFlOoCALpifCqHx1ylDud9PpDuhn6LqfoF16hSbaAnIFmYGJZOd5AgOqhwSCAvEqZ9ZDWUiNV+l1cTvMZkShbv1kVXP4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oqdWSpQgVm1bwFWAKC5nX/OvjjAJozsHhU5jBAr8Imk=; b=k5q9CeVpWUY/ULsPPGl8jvOezmC6KkYHAy6N/AnD9OvSgvxZZiAtJzEncixgpER1wlObGN5AetCgIEN1GcnYNOwN/OHgKcH8vvqDZI73ZFU8+nFCAGGJ7BduWt6scmtMvTcaXuli01Q0CxrMxqJQjkRxyiohW1jUXo0lllrrXcpzdx8GfvQW+dBcjBUxEa+0JtYwXv6SkHaAUXMFPRA8NOD7PmamT6rC3u6WfDdFuPUzXLCoaRx2wyCokN6kXkTOm7lq17Lcu3JBTetuM60amBfKrky0JgfnwXI41sc1dVsUGh7ppHhUBVa9hu/i8JzBRdRv47CtslkJ13SEY8SpCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oqdWSpQgVm1bwFWAKC5nX/OvjjAJozsHhU5jBAr8Imk=; b=TT4RQt6dUKftliDcJ5LhHlapO94vvBVAR+aprcnxrWhzmOSeNRsm7bBZdFBD1zQhWt9bw0Uayemo06JHxE1c7ubU4vWvmR1S1LnAE5D/k4D3QLUA1w/2B6Jj7/GaexXS7EWEC5gXcG6ZAZUqgN1BBhm9LxHKF0U/eN8C1P75h70= Authentication-Results: lists.denx.de; dkim=none (message not signed) header.d=none;lists.denx.de; dmarc=none action=none header.from=prevas.dk; Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) by VI1PR10MB1598.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:802:31::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.29; Mon, 4 May 2020 21:20:43 +0000 Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::f0ac:4e97:2536:faa]) by VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::f0ac:4e97:2536:faa%7]) with mapi id 15.20.2958.030; Mon, 4 May 2020 21:20:42 +0000 From: Rasmus Villemoes To: u-boot@lists.denx.de Cc: Simon Glass , Heiko Schocher , Lukasz Majewski , Biwen Li , Rasmus Villemoes Subject: [PATCH 2/6] rtc: add rtc_write8_array() helper Date: Mon, 4 May 2020 23:20:28 +0200 Message-Id: <20200504212032.3759-3-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200504212032.3759-1-rasmus.villemoes@prevas.dk> References: <20200504212032.3759-1-rasmus.villemoes@prevas.dk> X-ClientProxiedBy: AM6PR02CA0018.eurprd02.prod.outlook.com (2603:10a6:20b:6e::31) To VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from prevas-ravi.prevas.se (5.186.116.45) by AM6PR02CA0018.eurprd02.prod.outlook.com (2603:10a6:20b:6e::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.20 via Frontend Transport; Mon, 4 May 2020 21:20:42 +0000 X-Mailer: git-send-email 2.23.0 X-Originating-IP: [5.186.116.45] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1c472671-f857-46ef-0de1-08d7f0710091 X-MS-TrafficTypeDiagnostic: VI1PR10MB1598: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-Forefront-PRVS: 03932714EB X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dY2orYTgdTt8ERG68IQb2ZIElqPx/3y8M4mudESLPd5QeEvxPI2h4k/duxkjog/QfI9YE0ZLmzekCpT6NBNXxQRQXZwDLIo+FMNEObPQH5MCSqVCW5/UAfg8HN4ntpkQJTu+EF66ew3LaINfiecJFDOEvnIklAWjiFjYIF3Fsugjld/NP97tLgme3vzoVqwZH/CJpiqxc8zzCAOAuWxXBcbLBAw3Ig/cpUAci1YGeVDsA9r8FZ/Ze1NrlSV5brenFSZlBbz/g9nlNyUPFuUK8vymLzm4tmzLD2gvfvMA2oa1SXketRYtdDbwQPd+UetrePfQ2/LpMMONEMvu7fwt04O7pteSud0LxSw35Zn3CL6euF56JRwFFWYWg+PxR20YKB/rsDTyicVUDvKC3ZlRTgxZaQ1blrYIibv8fPft7fEsbiSYNxpQwSgNhQLvp2P1 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFTY:; SFS:(346002)(376002)(136003)(366004)(396003)(39850400004)(54906003)(6512007)(2616005)(956004)(8676002)(8936002)(8976002)(66556008)(36756003)(66946007)(5660300002)(66476007)(4326008)(6486002)(316002)(44832011)(1076003)(6916009)(86362001)(478600001)(6666004)(107886003)(26005)(16526019)(52116002)(6506007)(2906002)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: FVa8RYZRT8RgQpEDL2DfQ34r5SoyoCe2YzpMF1CnZZ5+TSxFBZgs2RGQI0XLj8x/AZxDEOXnVOHhqyvYUhXFR2CGNqFwYenpefqZPzvAWZA8qxPk2QckRS7GwA5ulS4WQ5CUoPcrVbPyYuCWbiqW64eQ8nBUvGzpaBzvpfg/YYc29FPtpiFnKntn1No160NRLepyAp7hOs20LCuqbFwfrgttEv4NegKhqYCYnNwJB/ijbjNHBL05yah2CgiH10fmsG1S/vQqMzGNyWYaXJYvQ2uf0sPGEm/zQ6Jen5YlmjlhRnuTJL7sgGgV1kKAwMXUtKhvOaEYsrMtlYEINsitOTqdAd1E6qvCBSoqRXeV2HERp4ehqymQuYcQeXpfMtjJOE1aIzprErBJrQf8thcuQ+bIWUih3eC1Dn/T6WL25zbPWdYrfp5yeves3cBvBYeW2hswh1dlP4sGgijPfu8lig4pQNtLSIkSULYBy7R1jIzZvFfpmbeXdU3TlN6LyPR85MLQeX1sFKYzspfgFkyqAtzb68ClNMWDcBdEYx9lfUBH4J7n65I/mjxlh6M0NCG13v0tvYDgAdnQ00ZUjRrDaZMBx96ZGJ2gpk6ejvtBKyuvrAfukzhqK2EypX688A3RNGY7KK8Tt1CXpexdUfj9qxucoLviL98MLZxkSNHiWCVV/LHIbRrViMoxzLK81OCR5VWBCzadQb94b2xK/4kseoPSoSqgAgt8tAipi+NPrjlAGpErsEQzPgqet74NGsFB8Gf3aFiKEFY+l0YsmMip3oqaSYybWwCYmFDwF90bOJU= X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 1c472671-f857-46ef-0de1-08d7f0710091 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2020 21:20:42.9330 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CGjORCsD7brhrsHzvUivWy87SbLdX7hCJzHdSIDG8lfydCIhLrFk4E+wDVDvIqR79CLsjzgfSqPGmsh7wmRgKlqF4pREDePVDPBfyfMcsnM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB1598 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Similar to the rtc_read8_array(), introduce a helper that allows the caller to write multiple consecutive 8-bit registers with one call. If the driver provides the ->write8_array method, use that, otherwise loop using ->write8. Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass --- drivers/rtc/rtc-uclass.c | 18 ++++++++++++++++++ include/rtc.h | 24 ++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/drivers/rtc/rtc-uclass.c b/drivers/rtc/rtc-uclass.c index 5070fb416d..56490a876f 100644 --- a/drivers/rtc/rtc-uclass.c +++ b/drivers/rtc/rtc-uclass.c @@ -78,6 +78,24 @@ int rtc_write8(struct udevice *dev, unsigned int reg, int val) return ops->write8(dev, reg, val); } +int rtc_write8_array(struct udevice *dev, unsigned int reg, + const u8 *buf, unsigned int len) +{ + struct rtc_ops *ops = rtc_get_ops(dev); + + assert(ops); + if (ops->write8_array) + return ops->write8_array(dev, reg, buf, len); + if (!ops->write8) + return -ENOSYS; + while (len--) { + int ret = ops->write8(dev, reg++, *buf++); + if (ret < 0) + return ret; + } + return 0; +} + int rtc_read16(struct udevice *dev, unsigned int reg, u16 *valuep) { u16 value = 0; diff --git a/include/rtc.h b/include/rtc.h index f7f622c1db..08b2a00567 100644 --- a/include/rtc.h +++ b/include/rtc.h @@ -85,6 +85,18 @@ struct rtc_ops { * @return 0 if OK, -ve on error */ int (*write8)(struct udevice *dev, unsigned int reg, int val); + + /** + * write8_array() - Write multiple 8-bit registers + * + * @dev: Device to write to + * @reg: First register to write + * @buf: Input buffer + * @len: Number of registers to write + * @return 0 if OK, -ve on error + */ + int (*write8_array)(struct udevice *dev, unsigned int reg, + const u8 *buf, unsigned int len); }; /* Access the operations for an RTC device */ @@ -152,6 +164,18 @@ int rtc_read8_array(struct udevice *dev, unsigned int reg, */ int rtc_write8(struct udevice *dev, unsigned int reg, int val); +/** + * rtc_write8_array() - Write multiple 8-bit registers + * + * @dev: Device to write to + * @reg: First register to write + * @buf: Input buffer + * @len: Number of registers to write + * @return 0 if OK, -ve on error + */ +int rtc_write8_array(struct udevice *dev, unsigned int reg, + const u8 *buf, unsigned int len); + /** * rtc_read16() - Read a 16-bit value from the RTC * From patchwork Mon May 4 21:20:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1283019 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.a=rsa-sha256 header.s=selector1 header.b=EwUdJKP+; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49GG5R6Lz5z9sRf for ; Tue, 5 May 2020 07:22:03 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D0F2982039; Mon, 4 May 2020 23:21:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.b="EwUdJKP+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1761082038; Mon, 4 May 2020 23:20:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03on0730.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0a::730]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B339E81FBF for ; Mon, 4 May 2020 23:20:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rasmus.villemoes@prevas.dk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QfLm8WGofrRweFsdpWEXr0AGmXeqobwruX6cLlUsnx35IlEvXaiThUcZ2Uh8ZslRQlE35qRSq9fWIWM4sxVHXG+UlYSEHDXv4j2BR39Zfu14x8brVIOBAa6CwErJla0EBGRKIhkMbWDsYYStmTshF/cOflOgp5qV4IZXuK2o+hvo80Z+RZFkfAA7HMEHKO+jia/w1kBSGoYGJTTCO52GGT1CGUEJs32soERyOueiqg9uSgBacjIYvzHBPY92cc7203+BnYv93V6zsYpwJQJ8rOcb4t5i7WoM9jwUgrnBkyGp8Q1hiSeAZkiYYps10UQDyjHZ6iO4U83u6C4SVAE4kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=37cRInrH7vvmC1vDKpBpA35WO4PUxxHDZBcSiVM2cZI=; b=IAlNcYjW3W78PuOHy2s12HHtKlBiaKSRqFvztF2Cx4s5NgOOz8KiCbCQH7Ew1JurahHIq7Nd75dJb1TAfDT3rQk5RNYGzKx2uF/rrunDOG+mwRkKjInxtaufvpVFq9C2KfCArL07FvzljuEmIgwMDaJTA0npMxNM3+ipHkZ5txrLRxqTmPBg66UBii2luLyjIpRPuTsC1CPAf7Eq2FgLDZE9AYD0kw5/Lc+bAVghcmoW0FDyShqHsAbIR9p1RMxCwrdsRtKyXv0zGJs6u5q3haqqczzUciZqK0aEJ0Q6Boyy7fOre4N3ImU6Hgwc2lmnBmAWdasRksOfNUM6ySn/bA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=37cRInrH7vvmC1vDKpBpA35WO4PUxxHDZBcSiVM2cZI=; b=EwUdJKP+A39SlzVUBiK/MndiR8DbFpPoy30aUvLKAv70SuAmwIxcF8jLw2TtTbI4qdI0/aqKXbWOcERiWVNtdT6k1HVqc0Np4rJxda+Z+8E3rdIFSY6i064c1mvSke0r+Eb9E7fPxQyBJLN+BdD50GlRQBFeaWrA53y64twFl9E= Authentication-Results: lists.denx.de; dkim=none (message not signed) header.d=none;lists.denx.de; dmarc=none action=none header.from=prevas.dk; Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) by VI1PR10MB1598.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:802:31::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.29; Mon, 4 May 2020 21:20:43 +0000 Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::f0ac:4e97:2536:faa]) by VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::f0ac:4e97:2536:faa%7]) with mapi id 15.20.2958.030; Mon, 4 May 2020 21:20:43 +0000 From: Rasmus Villemoes To: u-boot@lists.denx.de Cc: Simon Glass , Heiko Schocher , Lukasz Majewski , Biwen Li , Rasmus Villemoes Subject: [PATCH 3/6] rtc: fall back to ->{read, write}8_array if ->{read, write}8 are not provided Date: Mon, 4 May 2020 23:20:29 +0200 Message-Id: <20200504212032.3759-4-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200504212032.3759-1-rasmus.villemoes@prevas.dk> References: <20200504212032.3759-1-rasmus.villemoes@prevas.dk> X-ClientProxiedBy: AM6PR02CA0018.eurprd02.prod.outlook.com (2603:10a6:20b:6e::31) To VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from prevas-ravi.prevas.se (5.186.116.45) by AM6PR02CA0018.eurprd02.prod.outlook.com (2603:10a6:20b:6e::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.20 via Frontend Transport; Mon, 4 May 2020 21:20:43 +0000 X-Mailer: git-send-email 2.23.0 X-Originating-IP: [5.186.116.45] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: df2c9d8f-4f7c-4de4-476a-08d7f07100fa X-MS-TrafficTypeDiagnostic: VI1PR10MB1598: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-Forefront-PRVS: 03932714EB X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CF/aUxJPmIFhz2XqU9vc8Xk3HWd71qaL1rElxh892phqW6w+l14GJ6R16m88sY2StgxmV9Trs+5vw5PjN0OYBIruvvHel8IJ3Lw41p9lY0ebgRRP1QtPdJrXE/kO9EbTwmJa6YuCi/SJnSulC2bE51HiMyO4NaahjFSCzhYALx4Son5SVT+Ov40f8u7r81YCePa7EIegx1rTHiLNnQAX425Ot+CDwzwXpFYpGIFU7CW4ILcq2Ym3ktWH/aebqoJZRROyjAGH69j/EyJ3atRTDAtNxZSqshyafkULPtAk50wy7ZPstz5qjdkUGw5d7YcSqr/Q3ZnsFWl/jatd/2zkOoftgdaI5wt9Cv40ZBH6FGQWRFFTtZWX7Fag7In9ubVPGrcu+uXUannLHIr5H/UxslkUmfY8giZay0pF3v6Lrj1Yt61xcn+bJ0Pi7Ki1/HxbJebCJbBOI7qGlx1jWrZZmHtHrXZt/wZfEd10yzn69VrCXr3QYgZ6HGpz6LTKL2bi X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFTY:; SFS:(346002)(376002)(136003)(366004)(396003)(39850400004)(54906003)(6512007)(2616005)(956004)(8676002)(8936002)(8976002)(66556008)(36756003)(66946007)(5660300002)(66476007)(4326008)(6486002)(316002)(44832011)(1076003)(6916009)(86362001)(478600001)(6666004)(107886003)(26005)(16526019)(52116002)(6506007)(2906002)(186003)(142933001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 1QnWQ67h7E7AhdxgRDNi5aSuPz0CiTNMi7czPhUzUObvJiepEq/3HVCA36fDl3BNZnWZV0LqSm1JDPYHLquP59FTYZ6qR5Lb3aBC5A674G1Pqlv2S5B8Dq1YEha+2jNd95RpNtxIn6wZNOX0LHjnT1cpA32G9lTTOtIJo9X7ta8CVjvdVUulbf8B6ZLrcVroWqB8ODfRaPbl/oNgaD0QTVE/kNQkpGyipLEwbs78o4+xnjBI97/SKvOWLAK0p0Wz1dtl0GU58EtNb3XLuxW9JAnEVwvbc2dfwKOLoIZnV9pE2goVWlWrq51CHASksb88PVeYzybMOLvlAEvyZTa7E+MW1NXCM9GS/epgDk8idW3+gwdlhr0mQwjpWaCqP5YQeEilkJegaUXr7BJf92ohuxY8K+t7ulwoF+pu1RJ+tC/Bq54dvGN51sejKgBEGtyCKDTbrD32NaCYNygh/ozH29yN16gWi/6IUuZ55f5NSLR4ftRQipr2eUahZH1pkYGUXgNFrhn8sFMz4dDXJIVJm1ggIH5vG2iM2lc7kJ2e0t0uj33D6OFoz/5t4ETnCWig7egk61keUKO63yoVO2JKc7cuNH9uJ4D7dyCdyyetWX0/H9kxAc6bbUy1KlunYMf0YirKCor8WLG8K0N0AFnrI64H8KhasuR4ykfwHqLl+p3kXhoTxQGWveO+yjYkCwkqEpD4JQPGYzjVVWzT1GJlu/3wrV29xalvs1dVvQYvtXFzB0R92iK4nz6QPd78GbiQfP8/KLrG2NuCI/CnyElXtjjOK6sUEEKpTg4h6QQ3paM= X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: df2c9d8f-4f7c-4de4-476a-08d7f07100fa X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2020 21:20:43.6946 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uqG0vvYiPDwLJhVDf4eQqXuDcVLH4BAC4iGUATdxHPugoZXzRwqMZ7P6Ldaf027fxRl41QacUazdENX6MeZVb+rxhE9vVfP/s65r2kjaGkQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB1598 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Similar to how the rtc_{read,write}8_array functions fall back to using the {read,write}8 methods, do the opposite in the rtc_{read,write}8 functions. This way, each driver only needs to provide either ->read8 or ->read8_array to make both rtc_read8() and rtc_read8_array() work - without this, a driver that provides rtc_read8_array() would most likely just duplicate the logic here for implementing a ->read8() method in term of its ->read8_array() method. The same remarks of course apply to the write case. Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass --- drivers/rtc/rtc-uclass.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/rtc/rtc-uclass.c b/drivers/rtc/rtc-uclass.c index 56490a876f..6bf964f937 100644 --- a/drivers/rtc/rtc-uclass.c +++ b/drivers/rtc/rtc-uclass.c @@ -44,9 +44,17 @@ int rtc_read8(struct udevice *dev, unsigned int reg) struct rtc_ops *ops = rtc_get_ops(dev); assert(ops); - if (!ops->read8) - return -ENOSYS; - return ops->read8(dev, reg); + if (ops->read8) + return ops->read8(dev, reg); + if (ops->read8_array) { + u8 buf[1]; + int ret = ops->read8_array(dev, reg, buf, 1); + + if (ret < 0) + return ret; + return buf[0]; + } + return -ENOSYS; } int rtc_read8_array(struct udevice *dev, unsigned int reg, @@ -73,9 +81,13 @@ int rtc_write8(struct udevice *dev, unsigned int reg, int val) struct rtc_ops *ops = rtc_get_ops(dev); assert(ops); - if (!ops->write8) - return -ENOSYS; - return ops->write8(dev, reg, val); + if (ops->write8) + return ops->write8(dev, reg, val); + if (ops->write8_array) { + u8 buf[1] = { val }; + return ops->write8_array(dev, reg, buf, 1); + } + return -ENOSYS; } int rtc_write8_array(struct udevice *dev, unsigned int reg, From patchwork Mon May 4 21:20:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1283018 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.a=rsa-sha256 header.s=selector1 header.b=jB7DqBfh; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49GG5D5Vs4z9sRf for ; Tue, 5 May 2020 07:21:52 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DB0D482025; Mon, 4 May 2020 23:21:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.b="jB7DqBfh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AC68A82043; Mon, 4 May 2020 23:20:51 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03on0730.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0a::730]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 098D781FD6 for ; Mon, 4 May 2020 23:20:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rasmus.villemoes@prevas.dk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fdSOhe3cv6wCr/4Ugppj2L2yBHkpLOykeebNYKBbImPGR/8n/D3XqsxECVHtM8Av+0TKDyFKvqIuMps0wyZnxXc01ukeKrypD6dwE41Ou9jc9RXoVp78TjGCnyn3+sG1WaLajGDm6HP8Vp1YmAjmPaEjHtPo1CL6Q+K8gOoEAuJbed59kCfyJhOjxlPj/i0rWsLgAEB3PcaNbv/pCiomRQRVgZM/zPnl5tXDBs5Dk7sc07S0ooJgpxCKoRZAXrwIgDRpO4H4zq2zB1wBJ9vKO4yqLQApOSH5RtWPMA1jZ9StLtJUm4xpEnWTbGGzkwPTML5xCPmMiUfK6qp5cX06yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ksiOhLNLm77jIsNnWaKT4JXPx5TjTyhQaMUjA/NOI7M=; b=Bird51o6eDNgWQsGZBY5t5Pgklx4TGqGky68sZlcQ3qU0JXd+nltIo88oeHzc6BfB1cv2TeLzbMtkBcRXvW8LTY4eNvcMa+mtu0xUz1U9S/pt9iV0xlv+8QnsyNWi/WKEPnaOnSe96dxmiv7CyF/tmixl2bOsLWwCahB86BmyhzSaAJaI48y7Jq43YEFctxJVrb1AfI8IGNQM4qpDTF8yiBh9B5wv9NPRITKDpMRNqe0ld2/5NkHoLp2Nui6qXxbmNsfrJstTKApTohW0KuQgLJi/OIHp1rH1AO9lo/ETlfNBws5FYdYZEoMTE1zjm/b/L8IrghbjbosEZNdCEOgCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ksiOhLNLm77jIsNnWaKT4JXPx5TjTyhQaMUjA/NOI7M=; b=jB7DqBfh/T+uZFeNAQfgSDKGhQVnwx765Ie4NhRfdxrm6y48pRF3lt7c29eYA3Apb6n4A0+O7rxS8fcX3PzGG9AaeLTZg0lhWmJBpDTxfe16Q4HpzJd28MhQa1pUJt3b6MaqBfNry5D4sdgVdX7aujR1VhtYMCfOOl1ElQI3cwM= Authentication-Results: lists.denx.de; dkim=none (message not signed) header.d=none;lists.denx.de; dmarc=none action=none header.from=prevas.dk; Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) by VI1PR10MB1598.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:802:31::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.29; Mon, 4 May 2020 21:20:44 +0000 Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::f0ac:4e97:2536:faa]) by VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::f0ac:4e97:2536:faa%7]) with mapi id 15.20.2958.030; Mon, 4 May 2020 21:20:44 +0000 From: Rasmus Villemoes To: u-boot@lists.denx.de Cc: Simon Glass , Heiko Schocher , Lukasz Majewski , Biwen Li , Rasmus Villemoes Subject: [PATCH 4/6] rtc: pcf2127: provide ->read8_array method Date: Mon, 4 May 2020 23:20:30 +0200 Message-Id: <20200504212032.3759-5-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200504212032.3759-1-rasmus.villemoes@prevas.dk> References: <20200504212032.3759-1-rasmus.villemoes@prevas.dk> X-ClientProxiedBy: AM6PR02CA0018.eurprd02.prod.outlook.com (2603:10a6:20b:6e::31) To VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from prevas-ravi.prevas.se (5.186.116.45) by AM6PR02CA0018.eurprd02.prod.outlook.com (2603:10a6:20b:6e::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.20 via Frontend Transport; Mon, 4 May 2020 21:20:43 +0000 X-Mailer: git-send-email 2.23.0 X-Originating-IP: [5.186.116.45] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: baded2ad-e3fc-4de8-06ab-08d7f071016e X-MS-TrafficTypeDiagnostic: VI1PR10MB1598: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1728; X-Forefront-PRVS: 03932714EB X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AcZ/jEMxYxK0u/cCnsbTf6kuyjTc7Gc3Y42ig6O1IExEbIRWdBV9kWQzK3KNSAyxUjB+O4NqQ5/q+HqhDhGnk09TiPKD/Il0FLYRzqJ3Hzn6e8SckKrvDpsorTaIQLhGyfqZEOvRIJXTVnH5rfrtmhusI+FSIYrNBmdQzBMK7dSQIk8kvsO2gUkjWSCUhF50psi0MzpAIfrz5LIoglJetKkFsGWAjDw9kMKOurs/h/eVrN5aZv8eSSzlPNfZM5iBalqBuvFEFR5kcm+ktKE5v8Bne6LMPaVLE7fEnN7Ze7Y0ski7PHwPNEfnVNBbLjg3jO5XqAnckb8jlo76Kqt5mR8lR/ry/UDf+F2VODwYF1oUxsXE12fx69d/qaUtUrMc+KnZPCdxy1djut0TMOxGH2KN+xvCFHTe/rQzPuY27qT9bDzxw2RI5g6kRFkuwXDh X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFTY:; SFS:(346002)(376002)(136003)(366004)(396003)(39850400004)(54906003)(6512007)(2616005)(956004)(8676002)(8936002)(8976002)(66556008)(36756003)(66946007)(5660300002)(66476007)(4326008)(6486002)(316002)(44832011)(1076003)(6916009)(86362001)(478600001)(6666004)(107886003)(26005)(16526019)(52116002)(6506007)(2906002)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: hC9AN8tHJQE6MSLJXAr+sgfxcl6iGNxU174IBU40Frvrw80BIMAaW8jqlcGLtx3ZOGi33rKqlkRuZQnnXGii4x7oRtbwvi9MDh0AYFZUKqFFI1BB394C1KKEvb6KA6M/LmUJegy0iiHKW2AqwzrYE/oNYEeMh3TDqKgIxAcdBuFPjKu7LNSJ4q8P11qe8ylfd0O5FE+ibR56i8ujSsd3QAKq12xhCluLFTn0rhhJmkTD4SmbF+YZwkOJQoTyDVspH5BZ1UQ7OX9F3pzfuws7TV78foseD8YVGqA3RMndn/5geXaDHF6P4sQkNojmUGqGFFS9oc5rhzlWQ+8Re2NexE3n9yQ2+fMKx7rBoK1IcpbZn4531zPo6Yw7FKqf8g4GxlMVwevhs5zgodJHeQIPr775Mab8RNIdHDb2Z1N4RkwXLNlGvw2c7l2ic5ftL3rovoViCkmw84t9jpfn7EeAC8SP5LPVJfU1izLICqywblBJ3siM1BPGWtOEkyV4nXMKa7crPr9DTsK/KNyrhwlylOrgR+kVVjk38Pag1279j4qiHH3OSFjoSvzCqBW0sEBh/kYNVfP7MVUF7L10UIWWPKBly16VAGnSrz7JLXuJQqami/Dm3CFV2lFwtb6pLTqOvnkF63JvSyg2TwqUww0vd+QwTeGC9DairnRFkJk+fuYf5PDXn5oHZnhI7d07H5qXd9GgmC/LS+Z4h+Dz2sOLhznz9sMnyIFE3Q8IoM11qepYhcQ4+1/Xp/uJyJjbYANaP4mseJImpWo7ezgQU04/4BqCV/u0b6Wi5YUYrCO5V78= X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: baded2ad-e3fc-4de8-06ab-08d7f071016e X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2020 21:20:44.6990 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: K3l/YIRuhOtoHDzaqz3Zq4pG9XK8HF6SeD/EhK3mJoJqTEKze1UFuio0xE/VTook11d6NaGtmOZvRfKCzPbefMvQPS6NnSIfM4n4xrehtkM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB1598 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean This simply consists of renaming the existing pcf2127_read_reg() helper to follow the naming of the other methods (i.e. pcf2127_rtc_) and changing the type of its "len" parameter. Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass --- drivers/rtc/pcf2127.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/rtc/pcf2127.c b/drivers/rtc/pcf2127.c index b34ed63bf0..b3f6de8496 100644 --- a/drivers/rtc/pcf2127.c +++ b/drivers/rtc/pcf2127.c @@ -22,8 +22,8 @@ #define PCF2127_REG_MO 0x08 #define PCF2127_REG_YR 0x09 -static int pcf2127_read_reg(struct udevice *dev, uint offset, - u8 *buffer, int len) +static int pcf2127_rtc_read8_array(struct udevice *dev, uint offset, + u8 *buffer, uint len) { struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); struct i2c_msg msg; @@ -72,7 +72,7 @@ static int pcf2127_rtc_get(struct udevice *dev, struct rtc_time *tm) int ret = 0; uchar buf[10] = { PCF2127_REG_CTRL1 }; - ret = pcf2127_read_reg(dev, PCF2127_REG_CTRL1, buf, sizeof(buf)); + ret = pcf2127_rtc_read8_array(dev, PCF2127_REG_CTRL1, buf, sizeof(buf)); if (ret < 0) return ret; @@ -109,6 +109,7 @@ static const struct rtc_ops pcf2127_rtc_ops = { .get = pcf2127_rtc_get, .set = pcf2127_rtc_set, .reset = pcf2127_rtc_reset, + .read8_array = pcf2127_rtc_read8_array, }; static const struct udevice_id pcf2127_rtc_ids[] = { From patchwork Mon May 4 21:20:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1283020 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.a=rsa-sha256 header.s=selector1 header.b=ZTn0EbZs; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49GG5f0K5bz9sRf for ; Tue, 5 May 2020 07:22:13 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 95EA882052; Mon, 4 May 2020 23:21:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.b="ZTn0EbZs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 33A0082039; Mon, 4 May 2020 23:20:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03on0730.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0a::730]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4D10C81FFF for ; Mon, 4 May 2020 23:20:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rasmus.villemoes@prevas.dk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=juAbKyQOWsyRIfE8vpaJeHX8VqfnlPv6RyF4qhgkxXXrwtJNnDGXpFIB5Mb3xK8i0LywRCAoanNinvKz7zNDXwWucZK/20PMkpfsvSaMUhvw8Q5P7fq99WL89X5NMs4orns092T3FFrwsx610jRiwC23c03CZuYgZ9MlfRFmmb87hYrVJKUUQK08g0DnZn47Eon0zChRk4fv9JWvNQw5gj4Wf94TM7PSUfeuVJGcu68onZWVAVfI3cK8AAXH/+tdRbM8agFjjf/5N6qXQZ0kK4o0AgDmTFdYXiQtp1IQxxi9h/Hrx/FL5gCDcIwe0p5ci8/mZG3784sa9MPSfsz8aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dmnUJX7zH6Ut/3EKqULmle1afS1he62XYk1oIzmOWlM=; b=cFf98SuGP/CHiDsoTdzYfjwEankfS0mTLc3PUC9ZSlhF2EsrG5LqhmHuOUTeefoInSUFBbqXhKgeVX5UyLSo5RZK0OPvuAyz0ZVmSAjz7DQF3zFMaemORqLHYI06tKrKfn6LSiCYjH8RbUDvqSffo4ydtRjACf4H3ORvkl7BdrJhyZgLb4I4DsaIX/ASbK6yA2kLO0z7QWUW7bG0zS2UjcgxRngaDEvGhhsmwd+1cVjHSi7PqE28f1/TZV/0o1A1L0RJg33M1OcFKEseDN7/Ri36kFaP/1lV9lUj4iAXe3UokDorwoTA6zPYlEYQAbS4q1UiXZHO9weGrVaTFuW09Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dmnUJX7zH6Ut/3EKqULmle1afS1he62XYk1oIzmOWlM=; b=ZTn0EbZsprWxLJyEOlQm/Pd2frSvHGfUrLZIf7mRbc5eHl05cO399iGUDpgetpAaPSNXNl05jqfv26GRODWtnICplrpRYZFJLFYb0Ol2UPhiaDuMOoa01sZ0ao81kJQBqiD5b6aU7+yGRQb/TpapkjWvg9a9JPlXWy7q96v2BE0= Authentication-Results: lists.denx.de; dkim=none (message not signed) header.d=none;lists.denx.de; dmarc=none action=none header.from=prevas.dk; Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) by VI1PR10MB1598.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:802:31::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.29; Mon, 4 May 2020 21:20:45 +0000 Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::f0ac:4e97:2536:faa]) by VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::f0ac:4e97:2536:faa%7]) with mapi id 15.20.2958.030; Mon, 4 May 2020 21:20:45 +0000 From: Rasmus Villemoes To: u-boot@lists.denx.de Cc: Simon Glass , Heiko Schocher , Lukasz Majewski , Biwen Li , Rasmus Villemoes Subject: [PATCH 5/6] rtc: pcf2127: provide ->write8_array method Date: Mon, 4 May 2020 23:20:31 +0200 Message-Id: <20200504212032.3759-6-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200504212032.3759-1-rasmus.villemoes@prevas.dk> References: <20200504212032.3759-1-rasmus.villemoes@prevas.dk> X-ClientProxiedBy: AM6PR02CA0018.eurprd02.prod.outlook.com (2603:10a6:20b:6e::31) To VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from prevas-ravi.prevas.se (5.186.116.45) by AM6PR02CA0018.eurprd02.prod.outlook.com (2603:10a6:20b:6e::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.20 via Frontend Transport; Mon, 4 May 2020 21:20:45 +0000 X-Mailer: git-send-email 2.23.0 X-Originating-IP: [5.186.116.45] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f13616ce-2358-47a2-5352-08d7f0710237 X-MS-TrafficTypeDiagnostic: VI1PR10MB1598: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:296; X-Forefront-PRVS: 03932714EB X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R4lc2ixU60FrWObc/hwEOZZ/B3080BkEn8dBt6jQse+TWZ7fdERSbSqX9/gUUxnreqgsyK3bcOpMtG+gxapacGB/Q9V9SMGtpcyce7Rzqhdr8PH9T0ISdSJRSuoJMVm5LJ3aVZ6vT8PmfF5CA2BZzsvrB+EuCiGZ6+EBMiAmsnzwNzAINsHflklTW2ChHjjy7IwbuSV3CqVP+kZm6qmuE2nOijlCmnJVnn8m5cwt1N05nrjz2aSZZVuEztiQGcfrqM7MST5p+a7TjD4h7TpTs6tTEidLHN3nQiCb/V7N0fJjXGrTOQREmK7GAivDzXh9cvsy2xuQTtHbiE0hh9imSpJYrxrYhj8r9F4jvv005Eqy9hiqQYpSSSazd70jJy6xS3Zw+ItRv+1c0vVjyj/X3eYivBqJzlqlewMvGrM6euGeFJ8MpCMZ4SXgPJvMhV8a X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFTY:; SFS:(346002)(376002)(136003)(366004)(396003)(39850400004)(54906003)(6512007)(2616005)(956004)(8676002)(8936002)(8976002)(66556008)(36756003)(66946007)(5660300002)(66476007)(4326008)(6486002)(316002)(44832011)(1076003)(6916009)(4744005)(86362001)(478600001)(6666004)(107886003)(26005)(16526019)(52116002)(6506007)(2906002)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: kyx/KnFKeDlkJ0IoK8qeql0AKznHNODS09KbtBVaW/Ccmmgt4HODuKNkp2KfuOXRyeOZLE+Dy+YskeTDoDpX47OYXO02uV2TNs81ADNZAv06sAxFoHx9e5I2G7zghzqClGECl8MOug/sAY8zYfT0OWTKx+kLRNC7chd7vn+xLtzxiLSHBljBWw0Tg5DKhHxGUHYtK/rp4/STEA34B6k0fbY52/TUN1BcEonFWblXZmxPS6prCLZzqoqCixc10JWR78F3cJS7WeuzLb6Z2Gai/R9cmdpOQPlAlpbdMznRhUeRtOFgmTJ01NbNL9xO/sjDZ3bYjRHr2n9pj0BKjxkmE06ib2eUMGUr/n/USb3pfGuwlUe9jrbty8ljIvupmoDppZRMRJMsDlv3gXw9qZx7k33QhHL203wgD9U/oUl6Wt/TAdZBSmWw+MP5n37XlhdC1n1sKAXvZoLJHta8ERm0rM/vv7tRr+P3WA5FJWZLoUa7iv+EjGWt4jDY0MG7QdJYKgaDkRcYl5ANKHsxHPcqF5CR2En/Md232X6LWx2aq+md7tEwhPBofVybG5efG98a38RIBc/Z6qGNCss8eDzw4wER7EJdn3Ayr5PGOAl2sr5pSgeyWZQ9wFJiKaw77WS64lv7JFSCZDz80PHiRgu+OKeulwRP5Yo7ICJDmcIyxjP3QV0E+Z8/GFqcj/N4lXdR/NO9wobgZzxIANDzVy6BLZVq9y0xroOVRRTXsdCIavGAxyj3/zE9KLYW2kc4t6egh10jSeTrTnvnhlDhbryWW02a1nmjKqi6bClWvrXr3HU= X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: f13616ce-2358-47a2-5352-08d7f0710237 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2020 21:20:45.8303 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PljBEkXoqrDoZqpJcEFbtAJCtZAnIrBeGwux+jRN6se2gmzRPqQ7t8flcbPaDrsO22s1xW3M9Rwiarxy2AA+GysTcj0H8oFdmzRWfTOl6Mw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB1598 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass --- drivers/rtc/pcf2127.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/rtc/pcf2127.c b/drivers/rtc/pcf2127.c index b3f6de8496..227ab09880 100644 --- a/drivers/rtc/pcf2127.c +++ b/drivers/rtc/pcf2127.c @@ -43,6 +43,12 @@ static int pcf2127_rtc_read8_array(struct udevice *dev, uint offset, return dm_i2c_xfer(dev, &msg, 1); } +static int pcf2127_rtc_write8_array(struct udevice *dev, uint offset, + const u8 *buffer, uint len) +{ + return dm_i2c_write(dev, offset, buffer, len); +} + static int pcf2127_rtc_set(struct udevice *dev, const struct rtc_time *tm) { uchar buf[7] = {0}; @@ -110,6 +116,7 @@ static const struct rtc_ops pcf2127_rtc_ops = { .set = pcf2127_rtc_set, .reset = pcf2127_rtc_reset, .read8_array = pcf2127_rtc_read8_array, + .write8_array = pcf2127_rtc_write8_array, }; static const struct udevice_id pcf2127_rtc_ids[] = { From patchwork Mon May 4 21:20:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1283021 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.a=rsa-sha256 header.s=selector1 header.b=dBLA/lGD; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49GG5r0LQcz9sSc for ; Tue, 5 May 2020 07:22:23 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7C51481FB6; Mon, 4 May 2020 23:21:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.b="dBLA/lGD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 972008203F; Mon, 4 May 2020 23:20:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on20704.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::704]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CA68D82025 for ; Mon, 4 May 2020 23:20:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rasmus.villemoes@prevas.dk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KFEX2LxyBXQfHz+/NyRCTPi3kjnVk+Q6b9ttzyHL9GmuZv1Zk+LXelcontENQ3TBtm3w7ZgzFJcBfSnPULBPMM4Yxuy/4Ya/v6hHLhDSLgqNL0aJjWQEf9AwIOdaxJ3uCrm0oyoEReAvMTLi+lpblukE9nPCNiKm3+Tp/BySTa4IVooxmph8wM+8SmsZLxHTRWIV0PHFUNuPOxKP2EwVtGNNnztZPGEABEgN7OHo4rBr0d1Mh3votrKAtfA3wz3HFT5tBhveaJv7xmNc6bCQHMLMZiwN5nvX0YrrgDv9TBfhtPdl6Uh9k/j64mTn/fT1tTYRuIBif0BfJGXLXr3ftQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EHTN4ohyBmKKeO7j+hwu/CRq1DBo4gW5dv1xfZr3siw=; b=TbfwsYX0xWCgEN9fw4e2qJjpNrlBwrLVBFxU2synWVN+xQFfs9egbvHdWK78/jAXGk+/4XYAX3HB4jfVQG6YTVag/Phg+5V3VvYnCBgjpiQVnNvacSouWcmxRtE7/gCk6j0yOQJnUhb5zUM+HkQbLRKLn5Um6tN8jWIfyf2f3xtLBk3Yk8RVxk/eqvCJING7DFFJzwyxQM3O3ApOIB7q7Sns6yRzmvT6nE9Ve+5BamXlAOZYm4yTVBK4gGkC9hrBsKGVqaB46l+C1h36HoESa0duXDdJxGBILilnuWa5ZEd5qKRX9dQI2q9I83+YpetXvbegXIx4hQuyy5T3pM/a+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EHTN4ohyBmKKeO7j+hwu/CRq1DBo4gW5dv1xfZr3siw=; b=dBLA/lGDESYEPwV7CVGETtB1OpvJ7+3lA68KJJzDEpaugYGsfSyFWloeMOVP4xDuWwJXD42XpYLA75dwwdXkZqW78WdkeNEPJX7NRbh0HwLVx0cBJxzneMWsUA/EEIn54S5dFVgUC6NQxWddFHr4M43BXCwh6rCmGlU4yDFApOo= Authentication-Results: lists.denx.de; dkim=none (message not signed) header.d=none;lists.denx.de; dmarc=none action=none header.from=prevas.dk; Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) by VI1PR10MB1598.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:802:31::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.29; Mon, 4 May 2020 21:20:46 +0000 Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::f0ac:4e97:2536:faa]) by VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::f0ac:4e97:2536:faa%7]) with mapi id 15.20.2958.030; Mon, 4 May 2020 21:20:46 +0000 From: Rasmus Villemoes To: u-boot@lists.denx.de Cc: Simon Glass , Heiko Schocher , Lukasz Majewski , Biwen Li , Rasmus Villemoes Subject: [PATCH 6/6] rtc: add rtc command Date: Mon, 4 May 2020 23:20:32 +0200 Message-Id: <20200504212032.3759-7-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200504212032.3759-1-rasmus.villemoes@prevas.dk> References: <20200504212032.3759-1-rasmus.villemoes@prevas.dk> X-ClientProxiedBy: AM6PR02CA0018.eurprd02.prod.outlook.com (2603:10a6:20b:6e::31) To VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from prevas-ravi.prevas.se (5.186.116.45) by AM6PR02CA0018.eurprd02.prod.outlook.com (2603:10a6:20b:6e::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.20 via Frontend Transport; Mon, 4 May 2020 21:20:46 +0000 X-Mailer: git-send-email 2.23.0 X-Originating-IP: [5.186.116.45] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 36efa7de-e49d-45cc-1e1a-08d7f07102c0 X-MS-TrafficTypeDiagnostic: VI1PR10MB1598: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:565; X-Forefront-PRVS: 03932714EB X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 27Mj6UkLP1Wt7cNFVcl4loA/rpqs5Grqau2lL2CGAeHULeUX2QOKKVhzV9zuihOY3L04DAdH+L/MpRvNLZxmUXm3aPH2573AcmHxg/TY2dqMmn7BQG7zKKSHG2TYUSz1RdrFLtj87wFCZpYmR4Usv87Lg7NTqeWuppwFYuEQ+ToF/HLFPPi5v4XUQ1xoQWtlQgIam+OKbicJthwV6giCwYvbgpfmcRB3qQ/C5qMVcQtAAzFc32n3u/Omam+VNdezKZlvenc5gIddWnV8MXIYPy0nvdKaED7NUI0uiyHumQpALumkeOw/c8D071Zzn25zC0B0SQ0r6++D+OUzaxSbBmweAA+OOV3Gp1OWh1gqP7xhWk9NOGm0GvPbwLq97VaoiBcg5WwgUCWjXGuUfvVXdrejMpKDIbNFaZb5s0q/pC1Mgg62LccOhppty/mgCzOg X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFTY:; SFS:(346002)(376002)(136003)(366004)(396003)(39850400004)(54906003)(6512007)(2616005)(956004)(8676002)(8936002)(8976002)(66556008)(36756003)(66946007)(5660300002)(66476007)(4326008)(6486002)(316002)(44832011)(1076003)(6916009)(86362001)(478600001)(6666004)(107886003)(26005)(16526019)(52116002)(6506007)(2906002)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: u6GJygfVGQnReSYZmjTmg6vVzAxUikE4nzFNY4Ar/olOyAIQ+cOf7m55yMG5BerwExOZ8sg+rj1aH5cZJiVEONAGO5OrbPQFN5LuESWd+BYIcpNWfRasumdK1XndqEv0w+Gm6FYcqybkJNLrreEmzTQc0NEpml37cv0so5SEss6PZwIovdLuej3wSe/6hc1WNu+CR2qHFptSsWZO/Wwm0cgKFT3LDM0F+elloP/skaCGLqQDMLfgXlD8uw/OcYpkxZIn3UKP42ylk6NJyRxnq5nlskTG72Z3pYsEmH0ZDiYS5xXXam20w3XzyRDFuU/hWJJxNKhZ0K9l4vxE+gUVeiq4BH7m+PzP0wWeA38E6Gi0B3LVCYzL0zJ4nR7ZKgkrHsLo2UVcV/zLRXxVMNCo3XyYAiKq5Wy7wafwwDOWNliKxvtctlQ7/bIsbcWaObs4/qSvxptywktUgoD4V5u+cv7fEx8o90ipg8b2LkR7rHNa7/mtkeUoHTeEOxBF2fR0CA6CCTDBd726FVsON15ojTtEU09F6CAkPYT8WJ+4ng9Sr2TgB5sV0M4ChrRI0FGS7p7/xDnBFSN+5fLvyziEVbQ8OHABKO2yxEo4Har09HoXDfHP4x5dYWCn21zJo8Y+58aoqTubEla07WGeuihTs1x8C5d0Fmeml4TxoWeHgscthFAXM2gnnS+CzJqc71671HZjI5AitOj2s/FDB7mn34kiDpcHY+xC5iZMX/cMus+y5ksxUEtsqulaR2VoEZIIDrzvR8i53v4gm8LOSj1MkexobFl2ub9H4zLMVdzeHHI= X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 36efa7de-e49d-45cc-1e1a-08d7f07102c0 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2020 21:20:46.6219 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2WoZeNx9KTDFcAkUa7e47J5iLiauF52doai8sF/AnAXdWYWW8QA9FjtcwhgZzuX9edxJkOEHqBSnhLIKPXAsQf9cdyGjNQhDBkv98Vemhkc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB1598 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Mostly as an aid for debugging RTC drivers, provide a command that can be used to read/write arbitrary registers (assuming the driver provides the read8/write8 methods or their _array variants). Signed-off-by: Rasmus Villemoes --- cmd/Kconfig | 6 ++ cmd/Makefile | 1 + cmd/rtc.c | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 160 insertions(+) create mode 100644 cmd/rtc.c diff --git a/cmd/Kconfig b/cmd/Kconfig index 6403bc45a5..e5d0e7f7c3 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1673,6 +1673,12 @@ config CMD_DATE Enable the 'date' command for getting/setting the time/date in RTC devices. +config CMD_RTC + bool "rtc" + depends on DM_RTC + help + Enable the 'rtc' command for low-level access to RTC devices. + config CMD_TIME bool "time" help diff --git a/cmd/Makefile b/cmd/Makefile index f1dd513a4b..871b07f7b2 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -119,6 +119,7 @@ obj-$(CONFIG_CMD_REISER) += reiser.o obj-$(CONFIG_CMD_REMOTEPROC) += remoteproc.o obj-$(CONFIG_CMD_RNG) += rng.o obj-$(CONFIG_CMD_ROCKUSB) += rockusb.o +obj-$(CONFIG_CMD_RTC) += rtc.o obj-$(CONFIG_SANDBOX) += host.o obj-$(CONFIG_CMD_SATA) += sata.o obj-$(CONFIG_CMD_NVME) += nvme.o diff --git a/cmd/rtc.c b/cmd/rtc.c new file mode 100644 index 0000000000..d48c0333fa --- /dev/null +++ b/cmd/rtc.c @@ -0,0 +1,153 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include +#include +#include +#include +#include +#include + +#define MAX_RTC_BYTES 32 + +static int do_rtc_read(struct udevice *dev, int argc, char * const argv[], int mem) +{ + u8 buf[MAX_RTC_BYTES]; + int reg, len, ret; + u8 *addr; + + if (argc != 2 + mem) + return CMD_RET_USAGE; + + if (mem) { + addr = (void*)simple_strtoul(argv[0], NULL, 16); + argv++; + argv--; + } else { + addr = buf; + } + reg = simple_strtoul(argv[0], NULL, 0); + len = simple_strtoul(argv[1], NULL, 0); + + if (!mem && len > sizeof(buf)) { + printf("can read at most %d registers at a time\n", MAX_RTC_BYTES); + return CMD_RET_FAILURE; + } + ret = rtc_read8_array(dev, reg, buf, len); + if (ret) { + printf("rtc_read8_array() failed: %d\n", ret); + return CMD_RET_FAILURE; + } + if (!mem) { + while (len--) + printf("%d: 0x%02x\n", reg++, *addr++); + } + return CMD_RET_SUCCESS; +} + +static int do_rtc_write(struct udevice *dev, int argc, char * const argv[], int mem) +{ + u8 buf[MAX_RTC_BYTES]; + u8 *addr; + int reg, len, ret; + + if (argc != 2 + mem) + return CMD_RET_USAGE; + + if (mem) { + addr = (void*)simple_strtoul(argv[0], NULL, 16); + argv++; + argv--; + } else { + addr = buf; + } + + reg = simple_strtoul(argv[0], NULL, 0); + if (mem) { + len = simple_strtoul(argv[1], NULL, 0); + } else { + /* Convert hexstring, bail out if too long. */ + const char *s = argv[1]; + + len = strlen(s); + if (len > 2*MAX_RTC_BYTES) { + printf("hex string too long, can write at most %d bytes\n", MAX_RTC_BYTES); + return CMD_RET_FAILURE; + } + len /= 2; + if (hex2bin(addr, s, len)) { + printf("invalid hex string\n"); + return CMD_RET_FAILURE; + } + } + + ret = rtc_write8_array(dev, reg, buf, len); + if (ret) { + printf("rtc_write8_array() failed: %d\n", ret); + return CMD_RET_FAILURE; + } + return CMD_RET_SUCCESS; +} + +int do_rtc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + static int curr_rtc = 0; + struct udevice *dev; + int ret, idx; + + if (argc < 2) + return CMD_RET_USAGE; + + argc--; + argv++; + + if (!strcmp(argv[0], "list")) { + struct uclass *uc; + idx = 0; + + uclass_id_foreach_dev(UCLASS_RTC, dev, uc) { + printf("RTC #%d - %s\n", idx++, dev->name); + } + if (!idx) { + printf("*** no RTC devices available ***\n"); + return CMD_RET_FAILURE; + } + return CMD_RET_SUCCESS; + } + + idx = curr_rtc; + if (!strcmp(argv[0], "dev") && argc >= 2) + idx = simple_strtoul(argv[1], NULL, 10); + + ret = uclass_get_device(UCLASS_RTC, idx, &dev); + if (ret) { + printf("Cannot find RTC #%d: err=%d\n", idx, ret); + return CMD_RET_FAILURE; + } + + if (!strcmp(argv[0], "dev")) { + /* Show the existing or newly selected RTC */ + if (argc >= 2) + curr_rtc = idx; + printf("RTC #%d - %s\n", idx, dev->name); + return CMD_RET_SUCCESS; + } + + if (!strcmp(argv[0], "read") || !strcmp(argv[0], "readm")) + return do_rtc_read(dev, argc - 1, argv + 1, !strcmp(argv[0], "readm")); + + if (!strcmp(argv[0], "write") || !strcmp(argv[0], "writem")) + return do_rtc_write(dev, argc - 1, argv + 1, !strcmp(argv[0], "writem")); + + return CMD_RET_USAGE; +} + +U_BOOT_CMD( + rtc, 5, 0, do_rtc, + "RTC subsystem", + "list - show available rtc devices\n" + "rtc dev [n] - show or set current rtc device\n" + "rtc read - read and display 8-bit registers starting at \n" + "rtc readm - read 8-bit registers starting at to memory\n" + "rtc write - write 8-bit registers starting at \n" + "rtc writem - write memory to 8-bit registers starting at \n" +);