From patchwork Wed Feb 13 09:00:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 10809385 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4800D1390 for ; Wed, 13 Feb 2019 09:02:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 344852CA0D for ; Wed, 13 Feb 2019 09:02:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 285F42CA19; Wed, 13 Feb 2019 09:02:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 788362CA1A for ; Wed, 13 Feb 2019 09:02:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-ID:In-Reply-To: References:Message-ID:Date:Subject:To:From:Reply-To:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hffWMkXpFi+gRdpITZlUaF2NifuBNzY8oLqumkTkfYY=; b=EdpD1UER9eX3yr O7Jls7SY7++DBqk85Q9rd1929qaTknVJThKYjzhMRLq3c1PM0DBRDlbH7fCx7mWWWvid+tDHLUD/b GjaFwOxYj4/AD3BG9MkzdZl0p6dHxQr7Kf4dHsauLfx8aY/faPVLvqbhfqRuX039wUf07y0bCQsGl XQC2t4ZYCPDTIAxsfuiIariBfhHr5pU2PE390pjUGu8xHNuZy9wrNDlADaOaWekAQ0u+Ym04rGitG Za9wlytArZ0s0BrxCibz1zi0RI1mVKo4mzdhvIrQC996o5saD85806WTsIOtUaTDRry3cOxThSt8D OZo/avbwloVQWXjvei8g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtqR3-0001lz-S9; Wed, 13 Feb 2019 09:02:29 +0000 Received: from esa2.microchip.iphmx.com ([68.232.149.84]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtqOn-00061H-Jv; Wed, 13 Feb 2019 09:00:27 +0000 X-IronPort-AV: E=Sophos;i="5.58,365,1544511600"; d="scan'208";a="26473945" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 13 Feb 2019 02:00:08 -0700 Received: from NAM05-BY2-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.76.108) with Microsoft SMTP Server (TLS) id 14.3.352.0; Wed, 13 Feb 2019 02:00:07 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector1-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nczkVjZQpLKzBXuSAswPvKJaT3FdRaOMyekFqsZSjaA=; b=xfqpZjE5cZxabaZtbN0DJGRKl7cv0hGh54HCLD8Zuq8rz89lJmu7GaZFLlS0AWE8JJ7gZllzZAnz4VwUw0C/3Po/X9aL13+V2eXeFTR1k3NPpFDZQ6IQ42Ujgud21CpkPl0MuRoFWwVHZPHG7RCxaL2uQwI9cqMi5OHoImmBrMQ= Received: from BN6PR11MB1842.namprd11.prod.outlook.com (10.175.98.146) by BN6PR11MB0019.namprd11.prod.outlook.com (10.161.155.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1622.16; Wed, 13 Feb 2019 09:00:05 +0000 Received: from BN6PR11MB1842.namprd11.prod.outlook.com ([fe80::847:4296:13b9:fc9f]) by BN6PR11MB1842.namprd11.prod.outlook.com ([fe80::847:4296:13b9:fc9f%8]) with mapi id 15.20.1601.023; Wed, 13 Feb 2019 09:00:05 +0000 From: To: , , , , , , , , , , , Subject: [PATCH 07/11] mtd: rawnand: atmel: add sam9x60 nand controller support Thread-Topic: [PATCH 07/11] mtd: rawnand: atmel: add sam9x60 nand controller support Thread-Index: AQHUw3qCWFNDodb6ZkCALjA5DxGPkQ== Date: Wed, 13 Feb 2019 09:00:05 +0000 Message-ID: <20190213085930.31578-8-tudor.ambarus@microchip.com> References: <20190213085930.31578-1-tudor.ambarus@microchip.com> In-Reply-To: <20190213085930.31578-1-tudor.ambarus@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR08CA0085.eurprd08.prod.outlook.com (2603:10a6:800:d3::11) To BN6PR11MB1842.namprd11.prod.outlook.com (2603:10b6:404:101::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Tudor.Ambarus@microchip.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.9.5 x-originating-ip: [94.177.32.154] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2de62273-21b2-4a3f-6652-08d69191a534 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(2017052603328)(7153060)(7193020); SRVR:BN6PR11MB0019; x-ms-traffictypediagnostic: BN6PR11MB0019: x-microsoft-exchange-diagnostics: =?utf-8?q?1=3BBN6PR11MB0019=3B23=3A5yAg5DU?= =?utf-8?q?tIfVlGpX1ogKbNfj5uz0VPV2gJjd9g6qSZFfTzAQQzxEdyiWXDnvCFRGVaWYqtqcA?= =?utf-8?q?GOKdcTUXvTqh5XIetjpC/6lm68yl9ecuJQr65xDr4I+/j22pGL3DwuLvjQ+YfVUHK?= =?utf-8?q?/J2lBSg8TI47VTKxy2J41ZTVqEqpXp23dtZjhPcjBbWsUnHoMA5aANW4oRMp2oOMs?= =?utf-8?q?62HDHYwCIvE/+zA1vcOg3CSOoZiNdxSZxrJiTElR36K8csq4G9r7k4N4azmTHK1OS?= =?utf-8?q?MY4uAxA0x5/7IkygsfTF6wBpH3T0O1FdRksRiQ0xePfQwRS2lc8FWRsaBTSQhUyhH?= =?utf-8?q?M0BpijrWVWik23s6TBPFYSxzAQ5V2e7CXe5neontnZr4v0hOMS00Vh7QaQCGKgSKM?= =?utf-8?q?Uqg5nAyKUljfjUf1SWxUq1VaQVNmV8NYvSj0p524s7kaGfW+Zbq17YTa3RJEP9jcB?= =?utf-8?q?CNTI5vY+oGSIoJsv8YbiANUJxc91NOmQ0AXTIFSGMPBVHdIVGEuuBAdXTtdwyPKw4?= =?utf-8?q?M6cUUvC6GOGGhxbjBY+uxppf6xd9HUU1lIgezCGCisIuz1onaRauz8fPTmunBnmvk?= =?utf-8?q?bUdS8/rLyBsc9wCKoJrcRFkgETlOrR0apDirBrIGtHkCtEqJ2lo1/j3XCz0RoBlUP?= =?utf-8?q?9DBKnLKyB9U0I4Y6VM0HPKmtBXXpSojA7wLvFEEsO9TydwmPeSsaKNocfg8/R2Tal?= =?utf-8?q?OD5LlPPBFDALjKKScz3cOVwODSIWdX+9rw13KgGPRGNbyYCrMKVl/JyFB7uYhrPdF?= =?utf-8?q?hIv+O7smjOGy7QzjRMTvVmeSl6QT+/7DFvdr4mWOF//GXGVEsbUE+UUVfIq2U6nUm?= =?utf-8?q?FbQz+EdlzjLxk7tTjjXNFDdYDAqofwFY8aVKWNiHK1E23C09NEM7Cid+MflFwjYRU?= =?utf-8?q?qu1UfjK3nclmwJqrWbfQEuy6mrtRKcCLFW1aAkcXkHgthjtZZNig6t2mqvb4LCPTu?= =?utf-8?q?IaRcEoWioSfcZICF5c5xlW1bvztzPcsyL4Zq3fBnew+mERpCzl4Q9b4ICh1zLlU2C?= =?utf-8?q?xPboSDOLV7h2s3d/O9M1wIorb+IywlOGnKa7Yce/kO658TxqC39XGmf3SuHD0JtOU?= =?utf-8?q?4jGuRqQ/pAtaFCyUzCdb5hPhOpkorXsn2NEL3KslnRopyjkK7DVHgUAzwp60LSl9f?= =?utf-8?q?72Blj6O9PHp3md3QotkQG+vfAR5Q3uGex5hajNNtqS/5Gh63YDdPcX+YZs8LerWX6?= =?utf-8?q?f7MyH/l/9L0Zi24WxWnFXmcHi2deNO8yk4Od3JuUMtLon0M2k3LfvdoOgsSalSrDV?= =?utf-8?q?RDS+8v7Fq98gQsut3xvR70jukao/g6BnWEgKBSYkpwR46TBc1ff/SsBfAbw=3D=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 094700CA91 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(346002)(366004)(136003)(376002)(39860400002)(189003)(199004)(81166006)(50226002)(106356001)(7416002)(6436002)(54906003)(2201001)(1076003)(81156014)(26005)(110136005)(476003)(102836004)(107886003)(8936002)(6512007)(6486002)(4326008)(446003)(2616005)(316002)(8676002)(105586002)(99286004)(66066001)(486006)(6116002)(3846002)(186003)(11346002)(86362001)(2906002)(72206003)(71190400001)(14454004)(76176011)(53936002)(71200400001)(478600001)(68736007)(6506007)(386003)(2501003)(52116002)(97736004)(14444005)(5024004)(7736002)(305945005)(256004)(25786009)(36756003)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR11MB0019; H:BN6PR11MB1842.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: OMmkuYu9THGvM2YyN/hHyTfUXWxbyHxWR1icl2unKg8c2TUqJMbB/YJ/vFKly0lyJg/FcFSAOYiNRc+UtjSY+xf613wAZnomI4NFpCBGHxSKEqM8wm+vfrhTBRzJlMtaDE/m17ad1Jd4caXdBEONQjcHVHoHTd9M8Whc7wiX9ewW8z07npPpJ3MJdw/v5V7kIYldq8N+BznwtX0zabsCL802eoiVWlN+0KncO54EVuDKoFeMDRxaIwsfB3U6+Rbqp4DONUuonslBSTP1VdLX6ejG+52dvyQ22O6gEzblTZ218NJwVm8kwo2tQ0lSQfZQTGpH+2Z4Q7EiHWBF6piHatO2onQSegpLYcrSL0ROlu0UuTv9ELmZzoqXGskuunCmjNSI+4gw7q+M+2o6KufHFEtzKe9Wu8/StX84MTC5lpg= Content-ID: <2279D3538051D24EA42976561F3BD224@namprd11.prod.outlook.com> MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 2de62273-21b2-4a3f-6652-08d69191a534 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Feb 2019 09:00:02.2503 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB0019 X-OriginatorOrg: microchip.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190213_010010_547439_88D526F9 X-CRM114-Status: GOOD ( 15.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tudor.Ambarus@microchip.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tudor Ambarus The sam9x60 board defines the CCFG_EBICSA register under SFR, and not as a MATRIX register, as previous boards do. NAND Flash I/Os are connected to D16–D23, thus SFR_CCFG_EBICSA.NFD0_ON_D16 is set to 1. Signed-off-by: Tudor Ambarus --- drivers/mtd/nand/raw/atmel/nand-controller.c | 86 ++++++++++++++++++++++++---- 1 file changed, 74 insertions(+), 12 deletions(-) diff --git a/drivers/mtd/nand/raw/atmel/nand-controller.c b/drivers/mtd/nand/raw/atmel/nand-controller.c index 6aef98b7338a..ff85be0e2de3 100644 --- a/drivers/mtd/nand/raw/atmel/nand-controller.c +++ b/drivers/mtd/nand/raw/atmel/nand-controller.c @@ -65,6 +65,7 @@ #include #include #include +#include #include "pmecc.h" @@ -232,10 +233,15 @@ to_nand_controller(struct nand_controller *ctl) return container_of(ctl, struct atmel_nand_controller, base); } +struct atmel_smc_nand_ebi_csa_cfg { + u32 offs; + u32 nfd0_on_d16; +}; + struct atmel_smc_nand_controller { struct atmel_nand_controller base; struct regmap *ebi_csa_regmap; - unsigned int ebi_csa_offs; + struct atmel_smc_nand_ebi_csa_cfg *ebi_csa; }; static inline struct atmel_smc_nand_controller * @@ -1513,8 +1519,15 @@ static void atmel_smc_nand_init(struct atmel_nand_controller *nc, /* Attach the CS to the NAND Flash logic. */ for (i = 0; i < nand->numcs; i++) - regmap_update_bits(smc_nc->ebi_csa_regmap, smc_nc->ebi_csa_offs, + regmap_update_bits(smc_nc->ebi_csa_regmap, + smc_nc->ebi_csa->offs, BIT(nand->cs[i].id), BIT(nand->cs[i].id)); + + if (smc_nc->ebi_csa->nfd0_on_d16) + regmap_update_bits(smc_nc->ebi_csa_regmap, + smc_nc->ebi_csa->offs, + smc_nc->ebi_csa->nfd0_on_d16, + smc_nc->ebi_csa->nfd0_on_d16); } static void atmel_hsmc_nand_init(struct atmel_nand_controller *nc, @@ -1834,34 +1847,71 @@ static void atmel_nand_controller_cleanup(struct atmel_nand_controller *nc) clk_put(nc->mck); } +static const struct atmel_smc_nand_ebi_csa_cfg at91sam9260_ebi_csa = { + .offs = AT91SAM9260_MATRIX_EBICSA, +}; + +static const struct atmel_smc_nand_ebi_csa_cfg at91sam9261_ebi_csa = { + .offs = AT91SAM9261_MATRIX_EBICSA, +}; + +static const struct atmel_smc_nand_ebi_csa_cfg at91sam9263_ebi_csa = { + .offs = AT91SAM9263_MATRIX_EBI0CSA, +}; + +static const struct atmel_smc_nand_ebi_csa_cfg at91sam9rl_ebi_csa = { + .offs = AT91SAM9RL_MATRIX_EBICSA, +}; + +static const struct atmel_smc_nand_ebi_csa_cfg at91sam9g45_ebi_csa = { + .offs = AT91SAM9G45_MATRIX_EBICSA, +}; + +static const struct atmel_smc_nand_ebi_csa_cfg at91sam9n12_ebi_csa = { + .offs = AT91SAM9N12_MATRIX_EBICSA, +}; + +static const struct atmel_smc_nand_ebi_csa_cfg at91sam9x5_ebi_csa = { + .offs = AT91SAM9X5_MATRIX_EBICSA, +}; + +static const struct atmel_smc_nand_ebi_csa_cfg sam9x60_ebi_csa = { + .offs = AT91_SFR_CCFG_EBICSA, + .nfd0_on_d16 = AT91_SFR_CCFG_NFD0_ON_D16, +}; + static const struct of_device_id atmel_ebi_csa_regmap_of_ids[] = { { .compatible = "atmel,at91sam9260-matrix", - .data = (void *)AT91SAM9260_MATRIX_EBICSA, + .data = &at91sam9260_ebi_csa, }, { .compatible = "atmel,at91sam9261-matrix", - .data = (void *)AT91SAM9261_MATRIX_EBICSA, + .data = &at91sam9261_ebi_csa, }, { .compatible = "atmel,at91sam9263-matrix", - .data = (void *)AT91SAM9263_MATRIX_EBI0CSA, + .data = &at91sam9263_ebi_csa, }, { .compatible = "atmel,at91sam9rl-matrix", - .data = (void *)AT91SAM9RL_MATRIX_EBICSA, + .data = &at91sam9rl_ebi_csa, }, { .compatible = "atmel,at91sam9g45-matrix", - .data = (void *)AT91SAM9G45_MATRIX_EBICSA, + .data = &at91sam9g45_ebi_csa, }, { .compatible = "atmel,at91sam9n12-matrix", - .data = (void *)AT91SAM9N12_MATRIX_EBICSA, + .data = &at91sam9n12_ebi_csa, }, { .compatible = "atmel,at91sam9x5-matrix", - .data = (void *)AT91SAM9X5_MATRIX_EBICSA, + .data = &at91sam9x5_ebi_csa, + }, + { + .compatible = "microchip,sam9x60-sfr", + .data = &sam9x60_ebi_csa, }, { /* sentinel */ }, }; @@ -2006,15 +2056,15 @@ atmel_smc_nand_controller_init(struct atmel_smc_nand_controller *nc) return ret; } - nc->ebi_csa_offs = (uintptr_t)match->data; + nc->ebi_csa = (struct atmel_smc_nand_ebi_csa_cfg *)match->data; /* * The at91sam9263 has 2 EBIs, if the NAND controller is under EBI1 - * add 4 to ->ebi_csa_offs. + * add 4 to ->ebi_csa->offs. */ if (of_device_is_compatible(dev->parent->of_node, "atmel,at91sam9263-ebi1")) - nc->ebi_csa_offs += 4; + nc->ebi_csa->offs += 4; return 0; } @@ -2377,6 +2427,14 @@ static const struct atmel_nand_controller_caps atmel_sam9g45_nc_caps = { .ops = &atmel_smc_nc_ops, }; +static const struct atmel_nand_controller_caps microchip_sam9x60_nc_caps = { + .has_dma = true, + .ale_offs = BIT(21), + .cle_offs = BIT(22), + .ebi_csa_regmap_name = "microchip,sfr", + .ops = &atmel_smc_nc_ops, +}; + /* Only used to parse old bindings. */ static const struct atmel_nand_controller_caps atmel_rm9200_nand_caps = { .ale_offs = BIT(21), @@ -2421,6 +2479,10 @@ static const struct of_device_id atmel_nand_controller_of_ids[] = { .compatible = "atmel,sama5d3-nand-controller", .data = &atmel_sama5_nc_caps, }, + { + .compatible = "microchip,sam9x60-nand-controller", + .data = µchip_sam9x60_nc_caps, + }, /* Support for old/deprecated bindings: */ { .compatible = "atmel,at91rm9200-nand",