From patchwork Fri Sep 14 08:06:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 969646 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="MrJi+jkx"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42BSmG4bGpz9s9h for ; Fri, 14 Sep 2018 18:07:10 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 110C8C21FDC; Fri, 14 Sep 2018 08:06:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 21A2CC2200C; Fri, 14 Sep 2018 08:06:37 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id ACC2AC22048; Fri, 14 Sep 2018 08:06:30 +0000 (UTC) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by lists.denx.de (Postfix) with ESMTPS id E9707C2200C for ; Fri, 14 Sep 2018 08:06:26 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id g2-v6so3847926plo.2 for ; Fri, 14 Sep 2018 01:06:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=m7vfyg3dwrnXJo15knoCvf4c4DmD2lqaScI6rcYTrhc=; b=MrJi+jkxi1Hf4yxUbvnDj6XoLNvR1EhdIq1HQikiNpTmPEugD+CATL+JBHgVf8XS6N mQ54Y6WRt1A/lwcfNTCPTAJ1Hib0MHnbxObxRfk0renyC4R+XVnE30IRhtxxFeNgC3pt lT5ves7ArBaZgGfnHmqEdbm6vlKNyLOYl4YqY= 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:in-reply-to :references; bh=m7vfyg3dwrnXJo15knoCvf4c4DmD2lqaScI6rcYTrhc=; b=oAw35Ma3qVeovjQmsB7lEOrTfPall9dRQAFw/VmEO0li89C/MQ0mkY0M2GKXPIJgEb RmzJl9z/9m2pM/ti859xCJbttath9YACNMEgaCe3aK+OOyHy2tDkaSDC+XouuTmCO9we kXr84pX51JWr2jnYfBgk1Qua3+hpPG5yWgmy8NepIbNCWFT2EplVyg8CL1j7PLR0nmCq 3Ac+frDoqrSqj983xzgCnuCty7JTh+gmMntJqN38QGuWvhsAjb8Nwo10cHmyDDpglUcv lkaU22bph8BqQ6Lbrmg7Xe0LGqg80t24F8f5y3+okTD7YayKNm2QnPJWvSiDoKQnpwu6 P7vw== X-Gm-Message-State: APzg51CcnDImQqZxnNL6qV/FKBvt//mKu/Z9kayafmFIQw7NeMmbPWpb 4nMk9UNR/Tn+QaLi47/wlrjbBQ== X-Google-Smtp-Source: ANB0VdYUR7pxdrjG33OCaOBOcVADjkV4fmnIeNk3NWy6Ocf1U9xhG/vMSw0NAIrd3cmS+FINUd90tA== X-Received: by 2002:a17:902:8c82:: with SMTP id t2-v6mr11028604plo.241.1536912385548; Fri, 14 Sep 2018 01:06:25 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id o20-v6sm17376504pfj.35.2018.09.14.01.06.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 01:06:25 -0700 (PDT) From: "Akashi, Takahiro" To: trini@konsulko.com, sjg@chromium.org, tuomas.tynkkynen@iki.fi Date: Fri, 14 Sep 2018 17:06:53 +0900 Message-Id: <20180914080654.29035-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914080654.29035-1-takahiro.akashi@linaro.org> References: <20180914080654.29035-1-takahiro.akashi@linaro.org> Cc: xypron.glpk@gmx.de, agraf@suse.de, u-boot@lists.denx.de Subject: [U-Boot] [PATCH v4 1/2] rtc: pl031: convert the driver to driver model X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: AKASHI Takahiro With this patch, PL031 driver is converted to driver-model-compliant driver. In addition, CONFIG_SYS_RTC_PL031_BASE is no longer valid. Signed-off-by: AKASHI Takahiro --- drivers/rtc/pl031.c | 126 ++++++++++++++++++++++------------- include/configs/qemu-arm.h | 3 - scripts/config_whitelist.txt | 1 - 3 files changed, 80 insertions(+), 50 deletions(-) diff --git a/drivers/rtc/pl031.c b/drivers/rtc/pl031.c index 8955805e3bc1..8bf04f26a375 100644 --- a/drivers/rtc/pl031.c +++ b/drivers/rtc/pl031.c @@ -8,13 +8,11 @@ #include #include +#include +#include #include - -#if defined(CONFIG_CMD_DATE) - -#ifndef CONFIG_SYS_RTC_PL031_BASE -#error CONFIG_SYS_RTC_PL031_BASE is not defined! -#endif +#include +#include /* * Register definitions @@ -30,78 +28,114 @@ #define RTC_CR_START (1 << 0) -#define RTC_WRITE_REG(addr, val) \ - (*(volatile unsigned int *)(CONFIG_SYS_RTC_PL031_BASE + (addr)) = (val)) -#define RTC_READ_REG(addr) \ - (*(volatile unsigned int *)(CONFIG_SYS_RTC_PL031_BASE + (addr))) +struct pl031_platdata { + phys_addr_t base; +}; -static int pl031_initted = 0; +static inline u32 pl031_read_reg(struct udevice *dev, int reg) +{ + struct pl031_platdata *pdata = dev_get_platdata(dev); -/* Enable RTC Start in Control register*/ -void rtc_init(void) + return readl(pdata->base + reg); +} + +static inline u32 pl031_write_reg(struct udevice *dev, int reg, u32 value) { - RTC_WRITE_REG(RTC_CR, RTC_CR_START); + struct pl031_platdata *pdata = dev_get_platdata(dev); - pl031_initted = 1; + return writel(value, pdata->base + reg); } /* - * Reset the RTC. We set the date back to 1970-01-01. + * Probe RTC device + */ +static int pl031_probe(struct udevice *dev) +{ + /* Enable RTC Start in Control register*/ + pl031_write_reg(dev, RTC_CR, RTC_CR_START); + + return 0; +} + +/* + * Get the current time from the RTC */ -void rtc_reset(void) +static int pl031_get(struct udevice *dev, struct rtc_time *tm) { - RTC_WRITE_REG(RTC_LR, 0x00); - if(!pl031_initted) - rtc_init(); + unsigned long tim; + + if (!tm) + return -EINVAL; + + tim = pl031_read_reg(dev, RTC_DR); + + rtc_to_tm(tim, tm); + + debug("Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", + tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_wday, + tm->tm_hour, tm->tm_min, tm->tm_sec); + + return 0; } /* * Set the RTC -*/ -int rtc_set(struct rtc_time *tmp) + */ +static int pl031_set(struct udevice *dev, const struct rtc_time *tm) { unsigned long tim; - if(!pl031_initted) - rtc_init(); + if (!tm) + return -EINVAL; - if (tmp == NULL) { - puts("Error setting the date/time\n"); - return -1; - } + debug("Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", + tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_wday, + tm->tm_hour, tm->tm_min, tm->tm_sec); /* Calculate number of seconds this incoming time represents */ - tim = rtc_mktime(tmp); + tim = rtc_mktime(tm); - RTC_WRITE_REG(RTC_LR, tim); + pl031_write_reg(dev, RTC_LR, tim); - return -1; + return 0; } /* - * Get the current time from the RTC + * Reset the RTC. We set the date back to 1970-01-01. */ -int rtc_get(struct rtc_time *tmp) +static int pl031_reset(struct udevice *dev) { - ulong tim; + pl031_write_reg(dev, RTC_LR, 0); - if(!pl031_initted) - rtc_init(); + return 0; +} - if (tmp == NULL) { - puts("Error getting the date/time\n"); - return -1; - } +static const struct rtc_ops pl031_ops = { + .get = pl031_get, + .set = pl031_set, + .reset = pl031_reset, +}; - tim = RTC_READ_REG(RTC_DR); +static const struct udevice_id pl031_ids[] = { + { .compatible = "arm,pl031" }, + { } +}; - rtc_to_tm(tim, tmp); +static int pl031_ofdata_to_platdata(struct udevice *dev) +{ + struct pl031_platdata *pdata = dev_get_platdata(dev); - debug ( "Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", - tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, - tmp->tm_hour, tmp->tm_min, tmp->tm_sec); + pdata->base = dev_read_addr(dev); return 0; } -#endif +U_BOOT_DRIVER(rtc_pl031) = { + .name = "rtc-pl031", + .id = UCLASS_RTC, + .of_match = pl031_ids, + .probe = pl031_probe, + .ofdata_to_platdata = pl031_ofdata_to_platdata, + .platdata_auto_alloc_size = sizeof(struct pl031_platdata), + .ops = &pl031_ops, +}; diff --git a/include/configs/qemu-arm.h b/include/configs/qemu-arm.h index 913ff4f2636f..ba106247dc6f 100644 --- a/include/configs/qemu-arm.h +++ b/include/configs/qemu-arm.h @@ -23,9 +23,6 @@ /* For block devices, QEMU emulates an ICH9 AHCI controller over PCI */ #define CONFIG_SYS_SCSI_MAX_SCSI_ID 6 -/* QEMU emulates the ARM AMBA PL031 RTC */ -#define CONFIG_SYS_RTC_PL031_BASE 0x09010000 - /* Environment options */ #define CONFIG_ENV_SIZE SZ_64K diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index fc37099cbe0e..6168684daabf 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -4070,7 +4070,6 @@ CONFIG_SYS_RSTC_RMR_VAL CONFIG_SYS_RTC_BUS_NUM CONFIG_SYS_RTC_CNT CONFIG_SYS_RTC_OSCILLATOR -CONFIG_SYS_RTC_PL031_BASE CONFIG_SYS_RTC_REG_BASE_ADDR CONFIG_SYS_RTC_SETUP CONFIG_SYS_RV3029_TCR From patchwork Fri Sep 14 08:06:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 969647 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="GWKU45y4"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42BSmp483yz9s3l for ; Fri, 14 Sep 2018 18:07:38 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 44F97C22010; Fri, 14 Sep 2018 08:07:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id D842BC21FF8; Fri, 14 Sep 2018 08:06:48 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4CA2BC21FFC; Fri, 14 Sep 2018 08:06:38 +0000 (UTC) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by lists.denx.de (Postfix) with ESMTPS id 7C16AC21FBA for ; Fri, 14 Sep 2018 08:06:31 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id h69-v6so3939645pfd.4 for ; Fri, 14 Sep 2018 01:06:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Hm07arBpxZ9ooN8yXJSUQmqOzX70rghtVsuQ97bqD4E=; b=GWKU45y4Ua668c2MnrmcD+37Z9EXD+g2Y87HClIPyO0s+iXHW/sSCSGKJvCmd7FwHl OhnXjkTqM4XRu5aUjJ/0anuO0opADkNtwdGQdq5VwLHKtOJ+9NBBrXctxi2V2PfeCh/j WetF7j4YQshuL9lBNyPk3wfb6xsWrsNleIqIo= 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:in-reply-to :references; bh=Hm07arBpxZ9ooN8yXJSUQmqOzX70rghtVsuQ97bqD4E=; b=Lt/OZYrPHJ0dIe3hGO0FieN9wQstp0llkrzWwHKjQ1muApdYP/2ZGSz7EP2lK0OPlQ y28YuTz2a76rZXQJaSwkJLr2cQL804EavjFNFxkv8jgtVddo92f5lzpvAd8AcTmnIgrh 6JYsqeovG1/cfrS+ktTebEyUOaYHtUlVKNTIS/pR4WncVPDatl/h0gv9JGfP/fyA7MMX 20gKn8Snb9KqPrhnEpJ6kb7RZybRSLc9aJ802u1ONJDEsVhCGc21Gs2ZngfzK0WoMs7b AQTKPS+dTA7QG7+LPhM/l9eS4wkY3uP3ZUU0H0K4jcZG1yJ1YkxQAK0hGd7wZMwfGGda ACBw== X-Gm-Message-State: APzg51AY6nmpcE61gPDqyRbW23uaMBDEy1SX4BWE6/t/AykMAvLAzFdX O4etl8s+Yv7gisxWxQkXYr7+Hw== X-Google-Smtp-Source: ANB0Vdaq4ETKEqaLmUFmmYEBjQN815cqhlaR2FNjNTbETEtao0G9XMYC6v+vUUsw+icM+LdgWdy36g== X-Received: by 2002:a62:9541:: with SMTP id p62-v6mr11342971pfd.194.1536912390166; Fri, 14 Sep 2018 01:06:30 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id h4-v6sm6398564pgp.13.2018.09.14.01.06.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Sep 2018 01:06:29 -0700 (PDT) From: "Akashi, Takahiro" To: trini@konsulko.com, sjg@chromium.org, tuomas.tynkkynen@iki.fi Date: Fri, 14 Sep 2018 17:06:54 +0900 Message-Id: <20180914080654.29035-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180914080654.29035-1-takahiro.akashi@linaro.org> References: <20180914080654.29035-1-takahiro.akashi@linaro.org> Cc: xypron.glpk@gmx.de, agraf@suse.de, u-boot@lists.denx.de Subject: [U-Boot] [PATCH v4 2/2] arm: qemu-arm: enable RTC (PL031) by default X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: AKASHI Takahiro Virtual machine provided by qemu-arm has a ARM PL031 Real Time Clock device. With this patch, the driver is enabled by default. Signed-off-by: AKASHI Takahiro --- arch/arm/Kconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 8a23c76db846..f9fdbabba81b 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -741,6 +741,8 @@ config ARCH_QEMU select OF_CONTROL select PL01X_SERIAL imply CMD_DM + imply DM_RTC + imply RTC_PL031 config ARCH_RMOBILE bool "Renesas ARM SoCs"