From patchwork Wed Jan 23 08:01:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Prisk X-Patchwork-Id: 2022641 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 5D4923FD86 for ; Wed, 23 Jan 2013 08:03:56 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TxvHC-00056O-Vx; Wed, 23 Jan 2013 08:01:42 +0000 Received: from server.prisktech.co.nz ([115.188.14.127]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TxvGg-0004vW-U7; Wed, 23 Jan 2013 08:01:14 +0000 Received: from localhost.localdomain (unknown [192.168.0.102]) by server.prisktech.co.nz (Postfix) with ESMTP id 2A3E4FC0AB1; Wed, 23 Jan 2013 21:01:17 +1300 (NZDT) From: Tony Prisk To: dwmw2@infradead.org Subject: [PATCH v3 1/2] mtd: Add a common JEDEC flash device table Date: Wed, 23 Jan 2013 21:01:07 +1300 Message-Id: <1358928068-12417-2-git-send-email-linux@prisktech.co.nz> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1358928068-12417-1-git-send-email-linux@prisktech.co.nz> References: <1358928068-12417-1-git-send-email-linux@prisktech.co.nz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130123_030111_638688_5870EFC6 X-CRM114-Status: GOOD ( 19.17 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: dedekind1@gmail.com, linux-kernel@vger.kernel.org, Tony Prisk , linux-mtd@lists.infradead.org, vt8500-wm8505-linux-kernel@googlegroups.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch adds a common JEDEC flash device table which can be expanded on as more features are required. A simple match function is also included to query the table for a match based on the JEDEC id. Signed-off-by: Tony Prisk --- drivers/mtd/devices/flash_jedec.c | 96 +++++++++++++++++++++++++++++++++++++ drivers/mtd/devices/flash_jedec.h | 30 ++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 drivers/mtd/devices/flash_jedec.c create mode 100644 drivers/mtd/devices/flash_jedec.h diff --git a/drivers/mtd/devices/flash_jedec.c b/drivers/mtd/devices/flash_jedec.c new file mode 100644 index 0000000..c0b2272 --- /dev/null +++ b/drivers/mtd/devices/flash_jedec.c @@ -0,0 +1,96 @@ +/* + * Copyright Tony Prisk + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include + +#include "flash_jedec.h" + +/* + * Device Manufacturer IDs + * Please keep sorted by manufacturer ID + */ +#define MFR_SPANSION 0X01 +#define MFR_EON 0X1C +#define MFR_ATMEL 0X1F +#define MFR_MICRON 0X20 /* Also Numonyx & STM */ +#define MFR_INTEL 0x89 +#define MFR_FUDAN 0XA1 +#define MFR_SST 0XBF +#define MFR_MXIC 0XC2 +#define MFR_WINBOND 0XEF + +#define _ID(m, d) ((m << 16) | d) + +/* + * Flash device information + * Please keep sorted by manufacturer id, then device id + */ +static struct flash_device_info flash_devices[] = { + /* Spansion */ + { "s25fl016", _ID(MFR_SPANSION, 0x0214), 2048 }, + { "s25fl064", _ID(MFR_SPANSION, 0x0216), 8192 }, + /* EON */ + { "en25p16", _ID(MFR_EON, 0x2015), 2048 }, + { "en25p64", _ID(MFR_EON, 0x2017), 8192 }, + { "en25f40", _ID(MFR_EON, 0x3113), 512 }, + { "en25f16", _ID(MFR_EON, 0x3115), 2048 }, + /* ATMEL */ + { "at25df041a", _ID(MFR_ATMEL, 0x4401), 512 }, + /* Micron, STM & Numonyx */ + { "stm25p16", _ID(MFR_MICRON, 0x2015), 2048 }, + { "stm25p64", _ID(MFR_MICRON, 0x2017), 8192 }, + /* Fudan */ + { "fm25f04", _ID(MFR_FUDAN, 0x3113), 512 }, + /* SST */ + { "sst25vf016b", _ID(MFR_SST, 0x2541), 2048 }, + /* Macronix - MXIC */ + { "mx25l512", _ID(MFR_MXIC, 0x2010), 64 }, + { "mx25l4005", _ID(MFR_MXIC, 0x2013), 512 }, + { "mx25l1605", _ID(MFR_MXIC, 0x2015), 2048 }, + { "mx25l3205", _ID(MFR_MXIC, 0x2016), 4096 }, + { "mx25l6405", _ID(MFR_MXIC, 0x2017), 8192 }, + { "mx25l12805", _ID(MFR_MXIC, 0x2018), 16384 }, + { "mx25l1635", _ID(MFR_MXIC, 0x2415), 2048 }, + { "mx25l3235", _ID(MFR_MXIC, 0x5E16), 4096 }, + /* Winbond */ + { "w25x40", _ID(MFR_WINBOND, 0x3013), 512 }, + { "w25x16", _ID(MFR_WINBOND, 0x3015), 2048 }, + { "w25x32", _ID(MFR_WINBOND, 0x3016), 4096 }, + { "w25x64", _ID(MFR_WINBOND, 0x3017), 8192 }, +}; + +/* + * jedec_match_device - match a jedec id against the flash_devices table + * @jedecid: JEDEC formatted id to match + * bits 16..24: manufacturer id + * bits 0..15: device id + * Returns a valid flash_device_info* or ERR_PTR(-ENODEV) if an entry is + * not found + */ +struct flash_device_info *jedec_match_device(u32 jedec_id) +{ + int i; + for (i = 0; i < ARRAY_SIZE(flash_devices); i++) + if (flash_devices[i].jedec_id == jedec_id) + return &flash_devices[i]; + + return ERR_PTR(-ENODEV); +} diff --git a/drivers/mtd/devices/flash_jedec.h b/drivers/mtd/devices/flash_jedec.h new file mode 100644 index 0000000..27b978a --- /dev/null +++ b/drivers/mtd/devices/flash_jedec.h @@ -0,0 +1,30 @@ +/* + * Copyright Tony Prisk + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __MTD_FLASH_JEDEC +#define __MTD_FLASH_JEDEC + +struct flash_device_info { + const char *name; + u32 jedec_id; + u32 size_kb; +}; + +extern struct flash_device_info *jedec_match_device(u32 jedec_id); + +#endif