Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964877AbcDTL02 (ORCPT ); Wed, 20 Apr 2016 07:26:28 -0400 Received: from mail-am1on0128.outbound.protection.outlook.com ([157.56.112.128]:33618 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933747AbcDTL00 (ORCPT ); Wed, 20 Apr 2016 07:26:26 -0400 X-Greylist: delayed 915 seconds by postgrey-1.27 at vger.kernel.org; Wed, 20 Apr 2016 07:26:25 EDT Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=gomspace.com; From: Jeppe Ledet-Pedersen To: , , , , , , , , , CC: , , , Jeppe Ledet-Pedersen Subject: [PATCH 2/3] misc: eeprom: add Cypress FM33256B FRAM driver Date: Wed, 20 Apr 2016 13:07:50 +0200 Message-ID: <1461150471-23163-3-git-send-email-jlp@gomspace.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1461150471-23163-1-git-send-email-jlp@gomspace.com> References: <1461150471-23163-1-git-send-email-jlp@gomspace.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [77.243.61.136] X-ClientProxiedBy: VI1PR02CA0003.eurprd02.prod.outlook.com (10.162.7.141) To DB4PR04MB0637.eurprd04.prod.outlook.com (10.242.221.15) X-MS-Office365-Filtering-Correlation-Id: 1d3c094a-d54b-47cf-fb4b-08d3690c8639 X-Microsoft-Exchange-Diagnostics: 1;DB4PR04MB0637;2:dMR09UPSiTZ32+GeMjB+ciSIndqBrzlkRCAZY7Mjq04GcqEnk/BTr6qHtoxppDjCaI6RmBNuwU5K+E5gNXSgBjxsveK+f6mz8dGviEgrzhNpyr839Odmw9atfbq/9l8LnwH5BY0NXmhwR2p2gsLnuCXQ6BIggm7IWXVL2NtgiFwFBrRyeOC137En+94WA9cZ;3:U6dV9vEhSsv5G0wqmxVUp1O+dyV8iTw7ZCi2CR/CCu7wKHZTLfPkyfvg30eGVBctKfBhW+uQzyALxMsQPnCrMAnSl8ppvwqffY55DHGe9jgX50glg3oxkymm4PKzyUB+ X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB4PR04MB0637; X-Microsoft-Exchange-Diagnostics: 1;DB4PR04MB0637;25:MhKc36H58qtHhce8K1/uOyndivRAGfeYlPt11gKI7+iksK+aa0neK3gp9KODniEb8W3tf0j7yL4kfa7m+hHvvGWI75ZAnqEAf827HBNK8g4D9XgU+BvlDvfbxXreV2zM/A2fs5pEmhJUQ63BWunC6rOgdiyw5kAoy2tB4aZt1qMnzHP+yj40Drafepzct4ALXwP4XtI2TTURYGbE1u2RL7GOaHs/uzyvwXDpuNV/Yv7ICPMzvh4wCqEYX8ut4uxND20k8D6CVl6pqQiDJCBkG/O9JqYE3BoU3hn116K+wfd8+tMV+JFZmr/fEw+wgiR6wSxGkKQ5w36I3MOA16kaaJt/R17EZzzDKiyPJin2YQvpxEDkkmbzTBG8inXIZ+Chz2RmiHnZQ/D53Tppz5+6PgWjj1HQnshuHuKcQY5/qYh+H+08uL6elZCjysi8anLNAHv8jB5u8Fu5HfL7vbk7t9I7Xg/yyT8TbqSGBqxmpltOmxz1/ONxa9wp9U0XD2TLOqhc6ynCEpk11PlD4JUDwGgCUqaMNf9z+01G0emZWsKIs2bsEOM/jbuGABu9PCbOoUvpvis9gnrTbQj5QUscLGORq8pFr6vUc/KGVdt5pn7qXdIdBFNlLMENsPOEiTT4hmcv9IKT0xAxA79/le5CYPPc71JV2frtNXfhHwbxgZTGPjp4+KYYMSgQGgYvpwG2HKTQOis6ySs25/sqnKapI+bPG+piXOv5H/B8/2dEHRU= X-Microsoft-Exchange-Diagnostics: 1;DB4PR04MB0637;20:/oSsM0y98VPG7IWrxH0RjSKX0SQ/Qvmfj0mIdkhGs+5OOr7VYaIdH2JA1gooad8jSCwM1/0raHs1LhzhNk3nFKTqMbfgbnH/Zp1F8VCNXCmqStgYvFDISLVglwob2myKmNKkdwzIqpSSRJUdRRltlZ3MAtcqTfjtlikbQmkO+cPoF021/CiVirlG6O47tMMTKqeX/ALEHfw5okzjJcW/g39rv0mMG8KW0Y6+MF7TMotA09CkMBZuIdvd9BjmohBzXN6mHx91S5MRhhefYIWcLkLIojuP0fQgEbiUSLBMReRVv4bx6dPX2PFpwO4BOxSgoev9TFrCzRgnDcOr+DqJpTsIjvXBdw7h+h9Sufj0JaLxi9Qf1PrcGJw7OTyoig+sZ603+bnUJMtwRxUVxohUGUP1Bp02svFEg6MXbDA/UVoPhDejXPSSZIrZXlXZ2GIP;4:KTBkLLo2N7QR81Wv52XFPh5Z1A4kRX3tP0BFfQEyF1sirQ8tv1AYjGg8tJpV55jsjvIf7MHFtIoFICr/V/cGVQpHquBR/FHHy6PUA8VkOFkWgZMHiROFW2xE6X6g1+28XGK5iqLHRFIMxO48YVY31JZqXe2yi1tF3xB+jkFY5HGvDUtzlVczOIs7oaiTNm7DDTfp4KX7XoZg7oUSgnx2SITJgOowJPFNtCnHvYzLdhZHMKMW7JiHSj1JOXosniAQVJYjJsFVlMHUsGP7TSDrqz88S00N/kN06/QUp0tt+UeabUsUPhIarjmTHRGJI48N5mX/dMmaARMQv3sYlnthDadtK16sVfLF1LFVrhtMKz7k3kW3IcMzH2D9VkaNIzoWPJJ9ILQY0QFzsZesjVLe6ULrfKg2uIuF3qT8JNLvDSTOfVcWmuVp4kDG/2TSfka+oeAcVcvYcksSSyvb048VzQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(9101521026)(6040130)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6041046)(6043046);SRVR:DB4PR04MB0637;BCL:0;PCL:0;RULEID:;SRVR:DB4PR04MB0637; X-Forefront-PRVS: 0918748D70 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6069001)(6009001)(4001430100002)(92566002)(36756003)(229853001)(5003940100001)(2950100001)(2201001)(33646002)(19580395003)(1096002)(4326007)(15975445007)(6116002)(77096005)(5001770100001)(50226001)(189998001)(42186005)(19580405001)(50986999)(76176999)(5004730100002)(47776003)(48376002)(2906002)(586003)(86362001)(107886002)(3846002)(5008740100001)(50466002)(81166005)(575784001)(66066001)(2004002)(921003)(83996005)(2101003)(1121003);DIR:OUT;SFP:1102;SCL:1;SRVR:DB4PR04MB0637;H:localhost.localdomain;FPR:;SPF:None;MLV:nov;PTR:InfoNoRecords;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DB4PR04MB0637;23:5UmVnQefzRaGwjan+ODl/IYO8yW61F0/CO3yEteqg?= =?us-ascii?Q?Rb29IuK+SQrlOdpmaCdXDcAC/GBs7818V2abdYlEfrPj8FQ7z7CrSe6b1FM2?= =?us-ascii?Q?OH+M5SwIBXOOupeFM4Xk1EvAbGR6easB6xLMZDzNYURWfG4YRnAI3Qn/ulCv?= =?us-ascii?Q?hHS2y2rVKYxxG+xe0gRSs190fCl7ZPnuoKmEkBV4kTcP4Qq1EEy4aObpUOgF?= =?us-ascii?Q?wzQTo1oiURV6P7SWmlNXXoM5+MAawjfRQU8FWC59vSDi1CiZ+6zhqz1D4nm2?= =?us-ascii?Q?R6EKEmYNsbFiRxBbHv7dr2mNcck8adoIcDugepB20QztMKVt9BlXIy5Qsxug?= =?us-ascii?Q?XzDR695yConHgf9uxQFheLQDTGZ99Xlz218I1jSG6v4gqhJPDAqLAOd9mr+q?= =?us-ascii?Q?e3VgMBBPGd6/rwBTjWFr7wl6gTOpOMl3SPed17LZ2P9/usMGdDmpHcMJU5Bn?= =?us-ascii?Q?3DdnaSWoiKWh7uHUA+XviirCEQus+IYyGigQu7racbhjQSOGcWgh7KvASqef?= =?us-ascii?Q?K39Acb+ipU1Ur1fqhzJFkUxGajDQqs8QvrU97iPVJeH7PA2Y0WLcO7VckKp6?= =?us-ascii?Q?V0YbB7EpzIB2FFWGkkkjEf28I0tGWPbQZMTKaAafoEClou5bWKuTFlVjBCck?= =?us-ascii?Q?r+Wy5px1xDjNZf2ciO/fvk3BFERQs41gY96jnHXlBE0xw91sbvb9dTztQxbc?= =?us-ascii?Q?wimKnyX5LUWvITu5wLF3dV2/fIn/+ePtDayhf9Ob2IPkC1TIQXXs0bynPOQ6?= =?us-ascii?Q?v7EFXyfudY4KilTxjC5MRcwe84ARMUOHF2n6v4zob6FuGIw7H9EdsauNqnT+?= =?us-ascii?Q?9Hkq5VcdGzvHq39uwVPAMOaL6Kfo8Z7piS5yFIF7/KhJXmojD52VCj00KQwD?= =?us-ascii?Q?wd50vndkEqZAtoQTFXkgA2UfAYw0RVuEyfkIeU/bB+QKwdVPnR5N8JBrJ6G2?= =?us-ascii?Q?5DLom+vXrUfzIx3qduGJOMZSlpZ7OX4FanXHHMnxjnfjzFeho67lUZ+IDw0b?= =?us-ascii?Q?EoRNBaqNf3HOmjGq+lT4Nx0iAE9mLbZmPLwR/1WElauVF9Jzmh3f3/zfoOnp?= =?us-ascii?Q?UvpTcysl3CA/cF1P+boobUtJD5h94rGeaf/7SgM+PPQVoFLeyN6OU5yAyHpW?= =?us-ascii?Q?RyadtNN7pk=3D?= X-Microsoft-Exchange-Diagnostics: 1;DB4PR04MB0637;5:DHORhu2MkSex4La8ftkC7Z8ZKmbDAeTkfPiRYTC1XGNNBQFjH9at+fayC3OUuLSxhCoHRlIohlbAWN2Si1Sxp9233rJrFlkPYy9Fnbrt8rs7ibobOXtC4p2MxjNWV794Eupv0CwuyMaGHBPpv7jNEQ==;24:ADU9mHOdTLJly25GRd3cHI4+Ph39WrYQZpf1dMD1+WkNoOBnSWgIY5r4y99eUFyo9aVOERNKFH76DwJlCsGZ6dH8J7Q0f5Qjmg5bTTNHVc0= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: gomspace.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2016 11:11:29.0123 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR04MB0637 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5050 Lines: 169 Signed-off-by: Jeppe Ledet-Pedersen --- MAINTAINERS | 1 + drivers/misc/eeprom/Kconfig | 12 ++++ drivers/misc/eeprom/Makefile | 1 + drivers/misc/eeprom/fm33256b-fram.c | 110 ++++++++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+) create mode 100644 drivers/misc/eeprom/fm33256b-fram.c diff --git a/MAINTAINERS b/MAINTAINERS index 87b5023..a8b71d8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3387,6 +3387,7 @@ M: Jeppe Ledet-Pedersen S: Maintained F: include/linux/mfd/fm33256b.h F: drivers/mfd/fm33256b.c +F: drivers/misc/eeprom/fm33256b-fram.c CYTTSP TOUCHSCREEN DRIVER M: Ferruh Yigit diff --git a/drivers/misc/eeprom/Kconfig b/drivers/misc/eeprom/Kconfig index cfc493c..2c0c26a3 100644 --- a/drivers/misc/eeprom/Kconfig +++ b/drivers/misc/eeprom/Kconfig @@ -102,4 +102,16 @@ config EEPROM_DIGSY_MTC_CFG If unsure, say N. +config EEPROM_FM33256B + tristate "Cypress FM33256B FRAM support" + depends on MFD_FM33256B + help + This is a driver for the FRAM found in the Cypress FM33256B Processor + Companion. + + The FRAM is exported as a binary sysfs file. + + This driver can also be built as a module. If so, the module + will be called fm33256b-fram. + endmenu diff --git a/drivers/misc/eeprom/Makefile b/drivers/misc/eeprom/Makefile index fc1e81d..f991f0f 100644 --- a/drivers/misc/eeprom/Makefile +++ b/drivers/misc/eeprom/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_EEPROM_MAX6875) += max6875.o obj-$(CONFIG_EEPROM_93CX6) += eeprom_93cx6.o obj-$(CONFIG_EEPROM_93XX46) += eeprom_93xx46.o obj-$(CONFIG_EEPROM_DIGSY_MTC_CFG) += digsy_mtc_eeprom.o +obj-$(CONFIG_EEPROM_FM33256B) += fm33256b-fram.o diff --git a/drivers/misc/eeprom/fm33256b-fram.c b/drivers/misc/eeprom/fm33256b-fram.c new file mode 100644 index 0000000..fd3c2c9 --- /dev/null +++ b/drivers/misc/eeprom/fm33256b-fram.c @@ -0,0 +1,110 @@ +/* + * Cypress FM33256B Processor Companion FRAM Driver + * + * Copyright (C) 2016 GomSpace ApS + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * 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, see . + */ + +#include +#include +#include +#include + +static ssize_t fm33256b_fram_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buf, loff_t off, size_t count) +{ + int ret; + struct device *dev = container_of(kobj, struct device, kobj); + struct fm33256b *fm33256b = dev_get_drvdata(dev->parent); + + ret = regmap_bulk_read(fm33256b->regmap_fram, off, buf, count); + if (ret < 0) + return ret; + + return count; +} + +static ssize_t fm33256b_fram_write(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buf, loff_t off, size_t count) +{ + int ret; + struct device *dev = container_of(kobj, struct device, kobj); + struct fm33256b *fm33256b = dev_get_drvdata(dev->parent); + + ret = regmap_bulk_write(fm33256b->regmap_fram, off, buf, count); + if (ret < 0) + return ret; + + return count; +} + +static struct bin_attribute fm33256b_fram_attr = { + .attr = { + .name = "fram", + .mode = S_IWUSR | S_IRUGO, + }, + .size = FM33256B_MAX_FRAM, + .read = fm33256b_fram_read, + .write = fm33256b_fram_write, +}; + +static int fm33256b_fram_probe(struct platform_device *pdev) +{ + int ret; + struct device *dev = &pdev->dev; + struct fm33256b *fm33256b; + + fm33256b = dev_get_drvdata(dev->parent); + + ret = sysfs_create_bin_file(&(dev->kobj), &fm33256b_fram_attr); + if (ret < 0) + return ret; + + return 0; +} + +static int fm33256b_fram_remove(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct fm33256b *fm33256b; + + fm33256b = dev_get_drvdata(dev->parent); + + sysfs_remove_bin_file(&(dev->kobj), &fm33256b_fram_attr); + + return 0; +} + +static const struct of_device_id fm33256b_fram_dt_ids[] = { + { .compatible = "cypress,fm33256b-fram" }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, fm33256b_fram_dt_ids); + +static struct platform_driver fm33256b_fram_driver = { + .driver = { + .name = "fm33256b-fram", + .of_match_table = fm33256b_fram_dt_ids, + }, + .probe = fm33256b_fram_probe, + .remove = fm33256b_fram_remove, +}; +module_platform_driver(fm33256b_fram_driver); + +MODULE_ALIAS("platform:fm33256b-fram"); +MODULE_AUTHOR("Jeppe Ledet-Pedersen "); +MODULE_DESCRIPTION("Cypress FM33256B Processor Companion FRAM Driver"); +MODULE_LICENSE("GPL v2"); -- 2.1.4