From patchwork Wed Feb 17 17:28:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Perier X-Patchwork-Id: 8341741 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7FBFBC0553 for ; Wed, 17 Feb 2016 17:31:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A271020397 for ; Wed, 17 Feb 2016 17:31:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C8F5F202F2 for ; Wed, 17 Feb 2016 17:31:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aW5ut-0007sF-Qs; Wed, 17 Feb 2016 17:29:31 +0000 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aW5uO-0007ZB-Ie for linux-arm-kernel@lists.infradead.org; Wed, 17 Feb 2016 17:29:02 +0000 Received: by mail-wm0-x232.google.com with SMTP id b205so165870801wmb.1 for ; Wed, 17 Feb 2016 09:28:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GI3vbenPsZFt/Dsjo0hYCVyj/2fVfGiqlfPZBWDRtsc=; b=SwwAPzHEXIOFxNH02GIlDdXD//FMQppX/HjOwaWT2YDUvd+xm/bpV9GqwyvsotAxj1 twAPa5iKBxvAY3lA9I59e4Vvtr0Lxaz50c0wE13drn4tB8hJ+XPFyDhX/5Ugtm18sbQG xbixNQurVlYlf9dFtiOlD9l8p5BRle53Xd6iVW1VoM5yKt2UmM7rfTSKUg0psX1+wMWz 750zIaUp5Rb/4dtDuc/M12jbF4Z6SVMFvMGjqMMeP0Wp7hVhXzhqDjSYHDDjgdqYg1Zm wyBBZzpls+DPQ/EC582ziYjZkyee1AIocrgos5C1NDM0x23s238WA7ziJkDQpiefscFs waFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GI3vbenPsZFt/Dsjo0hYCVyj/2fVfGiqlfPZBWDRtsc=; b=OOa+qgmV11bTbLPfdH2lnF6xB07CrWWd7RXMdGFrdvLPH6Os1ic7vM1/G+UkruvtVG AKrnEOMsc4b2JpqEAVdIwD2dqM8/G1ZgnD7R8wRrGZ5LQymEBa2rth1moCqV5dqIQr6b 0SmIjJxZaL7hv4tYVFzThTjnMX4HpbZGDUSKFKa7b77MD5Ed7DWpS5mYqwHtKSrT5VTN INcX6wkz0pawh2zvUVh9fDPGiDAhU63LrtTU5mdXQUUAA/1Hv9R65zbm6G70X6r5Pme1 UucWLKH/EUkYwZEJihlN9Ve7eWEjjC9tzU/F5C1l62wacFQXlLITcypnsB2PswxnqNqr 5wxg== X-Gm-Message-State: AG10YOT1YhlVU9f46N7rA7rCwrQZKoNN598crryMVYVerHbUC0y9T00GZJMSyXNZYYXXog== X-Received: by 10.194.190.115 with SMTP id gp19mr3162976wjc.19.1455730118841; Wed, 17 Feb 2016 09:28:38 -0800 (PST) Received: from localhost.localdomain (i19-les01-ntr-176-186-2-137.sfr.lns.abo.bbox.fr. [176.186.2.137]) by smtp.gmail.com with ESMTPSA id ks5sm2530147wjb.13.2016.02.17.09.28.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Feb 2016 09:28:37 -0800 (PST) From: Romain Perier To: linux-meson@googlegroups.com Subject: [PATCH 1/2] ARM: meson: Adding support to retrieve serial and SoC revision Date: Wed, 17 Feb 2016 18:28:33 +0100 Message-Id: <1455730114-2547-2-git-send-email-romain.perier@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455730114-2547-1-git-send-email-romain.perier@gmail.com> References: <1455730114-2547-1-git-send-email-romain.perier@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160217_092900_825393_4F507123 X-CRM114-Status: GOOD ( 13.56 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, carlo@endlessm.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This path adds support to get the revision and the serial of the running SoC, on Meson8. On these plaforms, these informations can be found into CBUS registers. To do so, we instanciate a syscon register, then create a soc_device, and finally we expose everything to the system. Signed-off-by: Romain Perier --- arch/arm/mach-meson/meson.c | 55 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/arch/arm/mach-meson/meson.c b/arch/arm/mach-meson/meson.c index 4e23571..2816e30 100644 --- a/arch/arm/mach-meson/meson.c +++ b/arch/arm/mach-meson/meson.c @@ -13,8 +13,16 @@ * */ +#include #include +#include +#include +#include +#include #include +#include + +#define MESON_REVISION_REG (0x45c) static const char * const meson_common_board_compat[] = { "amlogic,meson6", @@ -23,7 +31,54 @@ static const char * const meson_common_board_compat[] = { NULL, }; +static void __init meson_init_machine(void) +{ + struct soc_device_attribute *soc_dev_attr; + struct soc_device *soc_dev; + struct regmap *hwrev; + unsigned int val; + int ret; + + hwrev = syscon_regmap_lookup_by_compatible("amlogic,meson8b-hwrev"); + if (IS_ERR(hwrev)) { + pr_err("hwrev node not found\n"); + return; + } + + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); + if (!soc_dev_attr) + return; + ret = regmap_read(hwrev, 0, &val); + if (ret < 0) { + pr_err("Could not get SoC id\n"); + return; + } + system_serial_high = val << 24; + + ret = regmap_read(hwrev, MESON_REVISION_REG, &val); + if (ret < 0) { + pr_err("Could not get SoC revision\n"); + return; + } + system_rev = val == 0x11111111 ? 0xA : 0xB; + + soc_dev_attr->family = "Amlogic Meson"; + soc_dev_attr->revision = kasprintf(GFP_KERNEL, "0x%x", system_rev); + soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "0x%x", system_serial_high); + + soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR(soc_dev)) { + pr_err("Could not register soc device\n"); + kfree(soc_dev_attr); + return; + } + + pr_info("Amlogic Meson SoC Rev%X (%X:%X)\n", system_rev, system_serial_high, system_rev); + of_platform_populate(NULL, of_default_bus_match_table, NULL, soc_dev); +} + DT_MACHINE_START(MESON, "Amlogic Meson platform") + .init_machine = meson_init_machine, .dt_compat = meson_common_board_compat, .l2c_aux_val = 0, .l2c_aux_mask = ~0,