From patchwork Mon Jul 6 20:01:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1323908 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=Pbx8KgLW; 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 4B0xKj2nD4z9sR4 for ; Tue, 7 Jul 2020 06:01:43 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D100F81B8B; Mon, 6 Jul 2020 22:01:33 +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="Pbx8KgLW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5CE6981B80; Mon, 6 Jul 2020 22:01:32 +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=-1.0 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-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on20719.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e1b::719]) (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 E07668006D for ; Mon, 6 Jul 2020 22:01:28 +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=ej+Vi71KPyhyRAk6sLATvvEqStjz1cni6ZWN3/sCyf74A0bOXMStOq3hChI70Za1GmFfFYkOUL0mBaH8k4cnCO0YxKf7DL6cV4GND+LtcQXEr1odtPnk2srN74qqjYWiUtb1jSwKqC2X4I2wM03Wuuly/JjuDCT3fZ0ugmAs5c3x1kg7+9UUBWNq0TomEka6y4KXTycPShZSob3d/OScldUFje4EDgbdCHbuuCCv9Sx81q4jD+D9vwOZCAjkyXU/xVRz6w2vDEVS/Gz9W+dOm0bs4GBqwyIsrGesR4eV3W3bJH0Hox5chQ4wvojkRBBQm45Oqb7B4LbmzxTRyp9syQ== 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=V1bS/Ilmf/hx7kUvbWBEcXLQ4tid1ZsLMuMN0Fc0o2g=; b=a6yos4ybM6Sq7rVKvpfbzILJdhxuJIggDdg4YFmgly+B20k5wRMu5RcyQ3W48Ns+MfPHKajTFigEes5+l56NgYvl0gkklaaLS/7f02bMAZyHZi2GHuleVI2EXueooZ6UDGvH8wLqZrqPnZBf7CZMjUyW5vMo8fO3tpNPNZJP4KkO6p7ZAGQKxu6tc+D5CLBCsYy1LuBz3ITCs8aVGgSUcQKvW2EOlOF3KT1np9V0ndAgMVVMTu40fk638iB7OCZ4rmlxilAXZMxgntlqKIT/otIDdSX6mRCd7WLbw5LNyCGhiA1cEoChyyNJ4uVShQcbrd9sc8Y5a2q+VciyB9R0PQ== 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=V1bS/Ilmf/hx7kUvbWBEcXLQ4tid1ZsLMuMN0Fc0o2g=; b=Pbx8KgLWztGFmS1GCmZlgfj0YTBoL82ys0Q2AIg16vvnsH9tYWig/CAZ+DyJT38NpBRjiJ8FTzUDqD62l8fNGmYbKGFfP1RiF7hw8i5fuvRZ9y/NY0NMO4Jeu3wGEzTTYdfEEU2yVR81jCVGZ8+i4UNC4Wje635jjcL+j6GxAH8= 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 AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:3f::10) by AM0PR10MB3587.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:144::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.20; Mon, 6 Jul 2020 20:01:27 +0000 Received: from AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM ([fe80::91fd:aebc:e8cb:a663]) by AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM ([fe80::91fd:aebc:e8cb:a663%7]) with mapi id 15.20.3153.029; Mon, 6 Jul 2020 20:01:27 +0000 From: Rasmus Villemoes To: u-boot@lists.denx.de Cc: Simon Glass , Heiko Schocher , Biwen Li , Rasmus Villemoes Subject: [PATCH v4 00/11] new rtc methods, rtc command, and tests Date: Mon, 6 Jul 2020 22:01:09 +0200 Message-Id: <20200706200120.23093-1-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.23.0 X-ClientProxiedBy: AM6PR0502CA0046.eurprd05.prod.outlook.com (2603:10a6:20b:56::23) To AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:3f::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from prevas-ravi.prevas.se (5.186.112.31) by AM6PR0502CA0046.eurprd05.prod.outlook.com (2603:10a6:20b:56::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.20 via Frontend Transport; Mon, 6 Jul 2020 20:01:27 +0000 X-Mailer: git-send-email 2.23.0 X-Originating-IP: [5.186.112.31] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b22331a0-04a5-4897-0786-08d821e75e3d X-MS-TrafficTypeDiagnostic: AM0PR10MB3587: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-Forefront-PRVS: 04569283F9 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7Lp+/DLnbXqUTcbs3knFPpaebi1S6fQV5A0RQEaq5cshhZuWgG5R3KCl6AR3Aj6l1z9EMVaET58AcLTFuKC5uaLrv5CW8IY052727ySlaohMo43X7zcVK8uIAuWYM50YrOaAQLfuCsGoX/LnjX+j/i3jnwaiANEAA6Gj1biroFUUvAJ5esJgD26CGUEYgB3bzQc4uTotHCSUkvxbri4l5Uqr48HUgzQI6VbxvtWX/8pxHlSZl/d1Ojn39G0boub7QEzneL7/VFodSYRt2Tp9hpun9u6ehXlr6EValRsTOXumZv829Dp871CxIqEbWtb2jweZHIpoPGFgkr9cgM8FKg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFTY:; SFS:(39850400004)(346002)(136003)(396003)(376002)(366004)(5660300002)(6506007)(6666004)(26005)(54906003)(66476007)(36756003)(8976002)(8936002)(6512007)(66556008)(66946007)(52116002)(478600001)(44832011)(86362001)(1076003)(107886003)(2906002)(186003)(6486002)(8676002)(16526019)(956004)(4326008)(83380400001)(316002)(2616005)(6916009); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: TILlQkNuloRQWN9Xj1EzvMjNjxgqFfCud7i7XEllz7ctymmHsTHJ3QxGqCF9pmz+MGF18FMznwARjBzZsgrCGL5HgwbfdLa4K5eVHyqbmWkKajDF+poPd/TNkoLKF5jf1ccxictXLsCdLlLTeC5qZWJMfJSDrXMxo4Rx/+74/lQIAjGJ1ADapQHCJYJ5C6BUH/ydczzSPRjDAbUpa4LpZVho44j5B+90csBKuFsQV4dhoBplX5O5d0pLckuOG9vTpXheatHPLOzZ/0oDU0BlljDEzGmo7rxys3S5G+s+Bi3rI41H2exT+ZvfvQBpSPG2w/F2O0w7iYEdGSVJWhdLMgWOW5j/cXIEc+RTU6RiGHeil3qymxMVALLlr4Czsxhf7bzf+mmQZB7yB8l0pEFoLFU/oO+xgy6tamkNxlIhshrx4vz9AAPCm1utTW8k+jh2FSo/wGbr+2v96/WTeFm3OnBL1j37lPfWkSVKuDx5qi0= X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: b22331a0-04a5-4897-0786-08d821e75e3d X-MS-Exchange-CrossTenant-AuthSource: AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2020 20:01:27.6724 (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: sGKovcJTHjHa4sFCIVbHTXzZAWK1S2HrowdNIomxs2vPEj68LWwKYHXD3p3kj9q46Mo5CH/QGWdRrmCAanYPND3wfEK32g8ZowDkmOlP0cU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR10MB3587 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.3 at phobos.denx.de X-Virus-Status: Clean I need access to registers other than just the timekeeping ones of the pcf2127, so I wanted to implement ->read8 and ->write8. But for testing these it appeared there was no convenient way to invoke those from the shell, so I also ended up adding such a command. Also, it seemed more natural to provide array variants that can read or write several registers at once, so rtc_ops is expanded a bit. Changes in v4: - Add CONFIG_CMD_RTC to sandbox defconfigs (new patch 10/11). Not quite sure exactly which it needed to be added to, but at least sandbox and sandbox_flattree showed CI failures. - Add Heiko's R-B to the 10 v3 patches (1-9 + 11), and Simon's R-B to 6/11. - Fix some checkpatch warnings - I don't really agree with most of them - e.g. having to add an empty line in int foo = something(); if (foo < 0) return foo; return something_else(foo); doesn't make the code more readable IMO. The remaining checkpatch blurps are things I really don't think warrant "fixing", e.g. "WARNING: ENOSYS means 'invalid syscall nr' and nothing else" seems irrelevant in context of U-Boot, and in any case I've only copied existing practice. For "WARNING: please write a paragraph that describes the config symbol fully", that seems to be a false positive, there's certainly a full help text for CMD_RTC. Changes in v3: - Call the functions dm_rtc_read/dm_rtc_write rather than just rtc_read/rtc_write, since the latter names are used for local helpers by a number of drivers. That also matches the existing dm_rtc_set/dm_rtc_get (though then not the existing rtc_read{8,16,32}). - Update the rtc command (patch 6) as per Simon's feedback (parse input as hex, avoid overlong lines, use print_buffer()). - Update the tests (patches 9 and 10) according to these changes. Changes in v2: - Use simply "read" and "write" instead of "read8_array", "write8_array", both for functions and methods, as suggested by Simon. - The rtc command's interface has been simplified a bit (no separate read/readm; the number of arguments determines whether the user wants the result on the console or to a memory address) - Add tests, both of rtc_{read,write}() and of the shell command, fixing a few things I stumbled on. Rasmus Villemoes (11): rtc: add dm_rtc_read helper and ->read method rtc: add dm_rtc_write() helper rtc: fall back to ->{read,write} if ->{read,write}8 are not provided rtc: pcf2127: provide ->read method rtc: pcf2127: provide ->write method rtc: add rtc command rtc: sandbox-rtc: fix set method rtc: i2c_rtc_emul: catch any write to the "reset" register test: dm: rtc: add test of dm_rtc_read, dm_rtc_write sandbox: add rtc command to defconfigs test: dm: rtc: add tests of rtc shell command arch/sandbox/include/asm/rtc.h | 5 + cmd/Kconfig | 6 ++ cmd/Makefile | 1 + cmd/rtc.c | 167 +++++++++++++++++++++++++++++ configs/sandbox64_defconfig | 1 + configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + drivers/rtc/i2c_rtc_emul.c | 3 +- drivers/rtc/pcf2127.c | 13 ++- drivers/rtc/rtc-uclass.c | 59 +++++++++- drivers/rtc/sandbox_rtc.c | 65 +++++------ include/rtc.h | 47 ++++++++ test/dm/rtc.c | 118 +++++++++++++++++++- 13 files changed, 437 insertions(+), 50 deletions(-) create mode 100644 cmd/rtc.c