From patchwork Mon Dec 21 16:08:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1419126 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D04Cb2yKfz9sVm for ; Tue, 22 Dec 2020 03:08:59 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=oqYpgIvC; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4D04Cb181xzDqQ9 for ; Tue, 22 Dec 2020 03:08:59 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::633; helo=mail-pl1-x633.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=oqYpgIvC; dkim-atps=neutral Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4D04CT5X7tzDqPj for ; Tue, 22 Dec 2020 03:08:47 +1100 (AEDT) Received: by mail-pl1-x633.google.com with SMTP id v3so5821229plz.13 for ; Mon, 21 Dec 2020 08:08:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+KGiKwFyqA4q8THJV9iHd+VlDZ7w0TZTFq60/hcjUME=; b=oqYpgIvCMPu2hbKQjJcrkLEP10jNBnpcAdOa3KAjNoW510pq8Fsxf+sDoO+fBaTXOc 5OwifJdOJtt0E53GXJLwDWUiIq/TOhjA1hZOmsw0fwoyKFnUz0VXok6Np5ss4GJ7zRd5 mlSkVFIdl3FgS0aZQwsHUtyO5Z/vpJywh2z16Mg0TD/6a16SE1r+GRC+1D+dTKv83DqG lvwtIk04FQ1RloPIEwt58W4bMc9mjiYUJhWoxya3LFK+RdrXDqGvx8kFajxJkqQrkP3W 0ghaIXB8gTl7t+fIH1KFyH3pJE2uYFCLfaaHQf/A6Kz5hBDfQBs3yJnPtTbqQrMGKArQ V0SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+KGiKwFyqA4q8THJV9iHd+VlDZ7w0TZTFq60/hcjUME=; b=MIinMMy84XptusCo8xZzY58CQ4BGprxjWkVU4i9gtjL3Hayriboo+cnHLiv7rrd4hC e2C1PSOz3IfdMyyPIAAFNLqut1BCL6TOxXJQrhIpHbSIvar0iiej8aIzg8ziOsGmhYTr 5mAnCxBb/W9NmYZFJRfwqVLq2tWmVd7ehQCMgWju2F615PppHO0/rxiT3KRAghxLqUtN 5UDgPpEVgdupiY3iCO3dZiTNRQkuBhpaCoQwcf+8ohkyWq7gG5Z8R5c3K5bFLagexF45 O5LwC9gLNj2jiIyfc2ycpv/BfcQaW3qhd2MyD4ZUih5d5dNkfuUMFYQAyxCvDBb6gLdk f9Cg== X-Gm-Message-State: AOAM532FH/62qmAyMUa6dt7nIiJ5tNFTumtmSg1kJ+LNlReeEE+a8I/0 o1JZ8xf97z5ez4CtNqvbY2NMc71v+Y4= X-Google-Smtp-Source: ABdhPJwpkuLFjaCkyqK+VK3k5mfO1PDpCX6G4WwmNGI+L9/rHAQjRnp2nbuwxSPtBq7DLPVN8y5gJw== X-Received: by 2002:a17:90a:1182:: with SMTP id e2mr17627490pja.152.1608566924019; Mon, 21 Dec 2020 08:08:44 -0800 (PST) Received: from bobo.ibm.com (193-116-97-30.tpgi.com.au. [193.116.97.30]) by smtp.gmail.com with ESMTPSA id i184sm17687786pfe.126.2020.12.21.08.08.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Dec 2020 08:08:43 -0800 (PST) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Tue, 22 Dec 2020 02:08:37 +1000 Message-Id: <20201221160837.943881-1-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Subject: [Skiboot] [PATCH] mambo: add a mambo rtc_write X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This just keeps the requested delta and uses it to adjust subsequent rtc_read calls. Signed-off-by: Nicholas Piggin --- platforms/mambo/mambo.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/platforms/mambo/mambo.c b/platforms/mambo/mambo.c index 0c96100ed..a1e0488c8 100644 --- a/platforms/mambo/mambo.c +++ b/platforms/mambo/mambo.c @@ -173,6 +173,8 @@ static void bogus_disk_flash_init(void) } } +static int64_t time_delta = 0; + static int64_t mambo_rtc_read(__be32 *ymd, __be64 *hmsm) { int64_t mambo_time; @@ -186,6 +188,7 @@ static int64_t mambo_rtc_read(__be32 *ymd, __be64 *hmsm) mambo_time = callthru0(SIM_GET_TIME_CODE); mt = mambo_time >> 32; + mt += time_delta; gmtime_r(&mt, &t); tm_to_datetime(&t, &__ymd, &__hmsm); @@ -195,12 +198,30 @@ static int64_t mambo_rtc_read(__be32 *ymd, __be64 *hmsm) return OPAL_SUCCESS; } +static int64_t mambo_rtc_write(uint32_t ymd, uint64_t hmsm) +{ + int64_t mambo_time; + struct tm tm; + time_t mt, new_mt; + + mambo_time = callthru0(SIM_GET_TIME_CODE); + mt = mambo_time >> 32; + + datetime_to_tm(ymd, hmsm, &tm); + new_mt = mktime(&tm); + + time_delta = new_mt - mt; + + return OPAL_SUCCESS; +} + static void mambo_rtc_init(void) { struct dt_node *np = dt_new(opal_node, "rtc"); dt_add_property_strings(np, "compatible", "ibm,opal-rtc"); opal_register(OPAL_RTC_READ, mambo_rtc_read, 2); + opal_register(OPAL_RTC_WRITE, mambo_rtc_write, 2); } static void mambo_system_reset_cpu(struct cpu_thread *cpu)