Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp848979img; Fri, 22 Mar 2019 09:50:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwoNIwmLVhd3NCQTzx58JS+QRpv3TnuPh0ErRUqbK1PUuC5sC3rxRyHPd/pPD/XK7M/VrkJ X-Received: by 2002:a62:54c5:: with SMTP id i188mr9992701pfb.188.1553273432739; Fri, 22 Mar 2019 09:50:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553273432; cv=none; d=google.com; s=arc-20160816; b=Z6UEYV9/QpGJCh/nsqf+DlQnEGKzGKLtlNskQOWpdD9DiBzgSKoYwQhKrRlP+aXqJF OThsaviLnTd8Pe5xbi4TkFafZF/EsyaBxCzJ2DYvS74ItjSOw9t2AwSmR1atNwRYsA9E oleKHPMW1M8vnCX5uv85SLmnWXS7B5oddotBERo2EcoOMmsi7cA2SFpCr/vd5ySwHZMC oZHUsTFZD3ruZarRlDoTK8YmxYoiGyq7M3qGoy7xwUazkQNnkaubm+1iy5Rsmp9I9uwR xHZ8iDN61QosDLtfU8IYSyPaWZ482NPpPsiwNmPLU7yW706NAzGEAVesgv/ifFYZEGSA cVtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature; bh=gBhMaMMiQLfs0Af+kpXApAY7Cuzq7AOincseW0P03AM=; b=FKcKK/RM42pdw12OBU/oENI2PU9zqzbNKjxMPV4GZh6gWpeckqMSI5Dguj0gRPJTHb 2DcL3Xrb7HhfPTz53Gq7R5H07YJB4n6mxojna7DpC0AwV4dVDRER9yVPKcAJQR6lz6P4 6Wlh7fH/7AKrtD4uuTCFmx678ce9+aug1UrvPRiwwN7fOMrAmD32BB0bsjEjcA6BNZ6v ZqC49zctiFf9+yaw0U7/4qLea9YXk8QbejdmxSpUF5eaW3xODnwMjEcMNF9QfSifJTRm oy4qQA+xLqaVSeT5NrelxhJzMiKWRifq7VYpaRODT+30l99o0S7iPAWPEBnzn71CgY5j 59/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=o23isgtS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k18si7144628pfi.224.2019.03.22.09.50.17; Fri, 22 Mar 2019 09:50:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=o23isgtS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727797AbfCVQtZ (ORCPT + 99 others); Fri, 22 Mar 2019 12:49:25 -0400 Received: from mail-eopbgr00062.outbound.protection.outlook.com ([40.107.0.62]:43590 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726023AbfCVQtZ (ORCPT ); Fri, 22 Mar 2019 12:49:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gBhMaMMiQLfs0Af+kpXApAY7Cuzq7AOincseW0P03AM=; b=o23isgtShOXt9GV+uyrCdF0nAPnv6BTYpyelC6SMaJ7AXGLPdMD5B89EgALhNx+Ap54MH7YgFvVFNfPRvHwjwEq3/yKAwNCD0JnjlwMWKViPJ8AWsuvKjOOG4iggCCPQIaXm8F6rBQ8RSneerdRTS/iLXLA7eaFVcAGs0MgtSL0= Received: from AM0PR04MB5779.eurprd04.prod.outlook.com (20.178.202.151) by AM0PR04MB4883.eurprd04.prod.outlook.com (20.176.215.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1709.14; Fri, 22 Mar 2019 16:49:20 +0000 Received: from AM0PR04MB5779.eurprd04.prod.outlook.com ([fe80::9579:32ab:898e:6769]) by AM0PR04MB5779.eurprd04.prod.outlook.com ([fe80::9579:32ab:898e:6769%2]) with mapi id 15.20.1709.017; Fri, 22 Mar 2019 16:49:20 +0000 From: Abel Vesa To: Shawn Guo , Sascha Hauer , Fabio Estevam , Lucas Stach , Rob Herring CC: dl-linux-imx , Linux Kernel Mailing List , "linux-arm-kernel@lists.infradead.org" , Abel Vesa Subject: [RESEND v2] soc: imx: Add generic i.MX8 SoC driver Thread-Topic: [RESEND v2] soc: imx: Add generic i.MX8 SoC driver Thread-Index: AQHU4M8x51owZIDO7UOOFQ/teNRhvw== Date: Fri, 22 Mar 2019 16:49:20 +0000 Message-ID: <1553273350-28852-1-git-send-email-abel.vesa@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0502CA0031.eurprd05.prod.outlook.com (2603:10a6:803:1::44) To AM0PR04MB5779.eurprd04.prod.outlook.com (2603:10a6:208:131::23) x-originating-ip: [212.146.100.6] authentication-results: spf=none (sender IP is ) smtp.mailfrom=abel.vesa@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 043b0ca2-d642-42f1-cbae-08d6aee65447 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020);SRVR:AM0PR04MB4883; x-ms-traffictypediagnostic: AM0PR04MB4883: x-microsoft-antispam-prvs: x-forefront-prvs: 09840A4839 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39860400002)(376002)(136003)(396003)(346002)(366004)(189003)(199004)(36756003)(6486002)(486006)(2906002)(476003)(54906003)(2616005)(3846002)(81156014)(8936002)(81166006)(102836004)(386003)(305945005)(6506007)(66066001)(68736007)(256004)(71200400001)(6436002)(71190400001)(25786009)(478600001)(316002)(106356001)(105586002)(186003)(7736002)(50226002)(97736004)(99286004)(14454004)(6116002)(26005)(44832011)(5660300002)(53936002)(52116002)(110136005)(8676002)(86362001)(6512007)(4326008)(41533002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB4883;H:AM0PR04MB5779.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 61XRgljERh8S+Q/jTPhgz9fHaY3XwjDzIgSA6t2LTPcyOOV2nWWTi7LDG7KpnctgV1Z1cy6pnxrn48wFrrJDXPtyMsmdgt6MlJJZU8q9JRKOY/Wg3DGtt5pIeLmai0UVjddigu1E4xXcNd0krjJz5oFzlffuCnHex5lqRKuOY9UasvWJryE9rcKbuOsq709XuCXsPwtbaX8bHRMWpg88/MQPAUx3AbbUgQ2gIkIK09W2cBm+rAlKlnJXSFcimdZcBK4b8gSmqn64bSGuLd6bfqPjkTIEcIMv1aSWbrfp7riW+Lt2XxIf+kLaUpLizHmjZw6bzmk7PK21gVis/Ex4qybYlXqsFqZz6owm85D29t91MusZuDeGrxLcQ8Li5sakhFPZFD0EfV612KvksvCraefBXYgXofyElyE/wDFkfzE= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 043b0ca2-d642-42f1-cbae-08d6aee65447 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Mar 2019 16:49:20.1447 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4883 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add generic i.MX8 SoC driver along with the i.MX8MQ SoC specific code. For now, only i.MX8MQ revision B1 is supported. For any other, i.MX8MQ revision it will print 'unknown'. Signed-off-by: Abel Vesa --- drivers/soc/imx/Makefile | 1 + drivers/soc/imx/soc-imx8.c | 115 +++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 116 insertions(+) create mode 100644 drivers/soc/imx/soc-imx8.c diff --git a/drivers/soc/imx/Makefile b/drivers/soc/imx/Makefile index 506a6f3..d6b529e0 100644 --- a/drivers/soc/imx/Makefile +++ b/drivers/soc/imx/Makefile @@ -1,2 +1,3 @@ obj-$(CONFIG_HAVE_IMX_GPC) +=3D gpc.o obj-$(CONFIG_IMX_GPCV2_PM_DOMAINS) +=3D gpcv2.o +obj-$(CONFIG_ARCH_MXC) +=3D soc-imx8.o diff --git a/drivers/soc/imx/soc-imx8.c b/drivers/soc/imx/soc-imx8.c new file mode 100644 index 0000000..fc6429f --- /dev/null +++ b/drivers/soc/imx/soc-imx8.c @@ -0,0 +1,115 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2019 NXP. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define REV_B1 0x21 + +#define IMX8MQ_SW_INFO_B1 0x40 +#define IMX8MQ_SW_MAGIC_B1 0xff0055aa + +struct imx8_soc_data { + char *name; + u32 (*soc_revision)(void); +}; + +static u32 __init imx8mq_soc_revision(void) +{ + struct device_node *np; + void __iomem *ocotp_base; + u32 magic; + u32 rev =3D 0; + + np =3D of_find_compatible_node(NULL, NULL, "fsl,imx8mq-ocotp"); + if (!np) + goto out; + + ocotp_base =3D of_iomap(np, 0); + WARN_ON(!ocotp_base); + + magic =3D readl_relaxed(ocotp_base + IMX8MQ_SW_INFO_B1); + if (magic =3D=3D IMX8MQ_SW_MAGIC_B1) + rev =3D REV_B1; + + iounmap(ocotp_base); + +out: + of_node_put(np); + return rev; +} + +static const struct imx8_soc_data imx8mq_soc_data =3D { + .name =3D "i.MX8MQ", + .soc_revision =3D imx8mq_soc_revision, +}; + +static const struct of_device_id imx8_soc_match[] =3D { + { .compatible =3D "fsl,imx8mq", .data =3D &imx8mq_soc_data, }, + { } +}; + +#define imx8_revision(soc_rev) \ + soc_rev ? \ + kasprintf(GFP_KERNEL, "%d.%d", (soc_rev >> 4) & 0xf, soc_rev & 0xf) : \ + "unknown" + +static int __init imx8_soc_init(void) +{ + struct soc_device_attribute *soc_dev_attr; + struct soc_device *soc_dev; + struct device_node *root; + const struct of_device_id *id; + u32 soc_rev =3D 0; + const struct imx8_soc_data *data; + int ret; + + soc_dev_attr =3D kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); + if (!soc_dev_attr) + return -ENODEV; + + soc_dev_attr->family =3D "Freescale i.MX"; + + root =3D of_find_node_by_path("/"); + ret =3D of_property_read_string(root, "model", &soc_dev_attr->machine); + if (ret) + goto free_soc; + + id =3D of_match_node(imx8_soc_match, root); + if (!id) + goto free_soc; + + of_node_put(root); + + data =3D id->data; + if (data) { + soc_dev_attr->soc_id =3D data->name; + if (data->soc_revision) + soc_rev =3D data->soc_revision(); + } + + soc_dev_attr->revision =3D imx8_revision(soc_rev); + if (!soc_dev_attr->revision) + goto free_soc; + + soc_dev =3D soc_device_register(soc_dev_attr); + if (IS_ERR(soc_dev)) + goto free_rev; + + return 0; + +free_rev: + kfree(soc_dev_attr->revision); +free_soc: + kfree(soc_dev_attr); + of_node_put(root); + return -ENODEV; +} +device_initcall(imx8_soc_init); --=20 2.7.4