From patchwork Tue Mar 24 22:30:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 6086681 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 79DAD9F399 for ; Tue, 24 Mar 2015 22:37:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 824242017D for ; Tue, 24 Mar 2015 22:37:47 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8091920173 for ; Tue, 24 Mar 2015 22:37:46 +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 1YaXPM-00081V-QF; Tue, 24 Mar 2015 22:34:48 +0000 Received: from mail-wi0-f176.google.com ([209.85.212.176]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YaXM5-0005sU-K0 for linux-arm-kernel@lists.infradead.org; Tue, 24 Mar 2015 22:31:26 +0000 Received: by wibbg6 with SMTP id bg6so1409340wib.0 for ; Tue, 24 Mar 2015 15:31:03 -0700 (PDT) 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=etbBwfhi9DisvI4y219ZlWiyuHbxqgQn9tAnQCsQzfM=; b=R1N4tddrh7RMUG36auo2GBqVSiZOaLYgoyAn4ddwe38jN+dL1b03mgB1uDQ0GQk1Rd cybIDeWMeZ+qn5/OFyLIKTJskReQ6beBjKzmlmfdTqpyOCHMIJW/dSf2ZScqU41d5Ol/ 3ee/oCbPS5hOlzErkNe9lgNi/Eo5r7tZE1aTU4MqzGoGPtv6gI7h5zQgK4/MnkdkoMUX tRj/OPHOnsDNW2R5T6nfQmPDqzlPBxGbbYVyfedBz0I/IzneIwH3mAffnSHWwEuF4MKs P1HLfwb7su10rs8QCp/38VzFtHZgtF/bB6t5WIxlRinQmJ9foHrG324xIhwlQceBpdZO Fihw== X-Gm-Message-State: ALoCoQlB6aV17CmnngsyzhwQcuy2WIiKBS6h/ljM0s1NCPwlvX43R4/Lp77ngcrzFUOLFIAXSUpX X-Received: by 10.180.206.83 with SMTP id lm19mr32679943wic.41.1427236263093; Tue, 24 Mar 2015 15:31:03 -0700 (PDT) Received: from srini-ThinkPad-X1-Carbon-2nd.dlink.com (host-2-99-228-8.as13285.net. [2.99.228.8]) by mx.google.com with ESMTPSA id fm10sm1446517wib.7.2015.03.24.15.30.59 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Mar 2015 15:31:02 -0700 (PDT) From: Srinivas Kandagatla To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 7/9] eeprom: qfprom: Add Qualcomm QFPROM support. Date: Tue, 24 Mar 2015 22:30:55 +0000 Message-Id: <1427236255-18840-1-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1427236116-18531-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1427236116-18531-1-git-send-email-srinivas.kandagatla@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150324_153125_890135_51ACC3D5 X-CRM114-Status: GOOD ( 15.31 ) X-Spam-Score: -0.7 (/) Cc: devicetree@vger.kernel.org, arnd@arndb.de, Greg Kroah-Hartman , Mark Brown , Kumar Gala , sboyd@codeaurora.org, linux-kernel@vger.kernel.org, Rob Herring , Srinivas Kandagatla , linux-api@vger.kernel.org, Maxime Ripard , linux-arm-msm@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, 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 patch adds QFPROM support driver which is used by other drivers like thermal sensor and cpufreq. On MSM parts there are some efuses (called qfprom) these fuses store things like calibration data, speed bins.. etc. Drivers like cpufreq, thermal sensors would read out this data for configuring the driver. Signed-off-by: Srinivas Kandagatla --- drivers/eeprom/Kconfig | 11 +++++++ drivers/eeprom/Makefile | 2 ++ drivers/eeprom/qfprom.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 drivers/eeprom/qfprom.c diff --git a/drivers/eeprom/Kconfig b/drivers/eeprom/Kconfig index ad396c1..8fc14d3 100644 --- a/drivers/eeprom/Kconfig +++ b/drivers/eeprom/Kconfig @@ -23,4 +23,15 @@ config EEPROM_SUNXI_SID This driver can also be built as a module. If so, the module will be called eeprom-sunxi-sid. +config QCOM_QFPROM + tristate "QCOM QFPROM Support" + depends on ARCH_QCOM + select REGMAP_MMIO + help + Say y here to enable QFPROM support. The QFPROM provides access + functions for QFPROM data to rest of the drivers via eeprom interface. + + This driver can also be built as a module. If so, the module + will be called eeprom-qfprom. + endif diff --git a/drivers/eeprom/Makefile b/drivers/eeprom/Makefile index 184aa53..4ac437e 100644 --- a/drivers/eeprom/Makefile +++ b/drivers/eeprom/Makefile @@ -8,3 +8,5 @@ eeprom_core-y := core.o # Devices obj-$(CONFIG_EEPROM_SUNXI_SID) += eeprom-sunxi-sid.o eeprom-sunxi-sid-y := sunxi-sid.o +obj-$(CONFIG_QCOM_QFPROM) += eeprom_qfprom.o +eeprom_qfprom-y := qfprom.o diff --git a/drivers/eeprom/qfprom.c b/drivers/eeprom/qfprom.c new file mode 100644 index 0000000..8d5d4d8 --- /dev/null +++ b/drivers/eeprom/qfprom.c @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2015 Srinivas Kandagatla + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only 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. + */ + +#include +#include +#include +#include +#include +#include +#include + +static struct regmap_config qfprom_regmap_config = { + .reg_bits = 32, + .val_bits = 8, + .reg_stride = 1, +}; + +static struct eeprom_config econfig = { + .name = "qfprom", +}; + +static int qfprom_remove(struct platform_device *pdev) +{ + struct eeprom_device *eeprom = platform_get_drvdata(pdev); + + return eeprom_unregister(eeprom); +} + +static int qfprom_probe(struct platform_device *pdev) +{ + struct resource *res; + void __iomem *base; + struct device *dev = &pdev->dev; + struct eeprom_device *eeprom; + struct regmap *regmap; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + base = devm_ioremap_resource(dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); + + qfprom_regmap_config.max_register = resource_size(res) - 1; + + regmap = devm_regmap_init_mmio(dev, base, + &qfprom_regmap_config); + if (IS_ERR(regmap)) { + dev_err(dev, "regmap init failed\n"); + return PTR_ERR(regmap); + } + econfig.owner = THIS_MODULE; + econfig.dev = dev; + eeprom = eeprom_register(&econfig); + if (IS_ERR(eeprom)) + return PTR_ERR(eeprom); + + platform_set_drvdata(pdev, eeprom); + return 0; +} + +static const struct of_device_id qfprom_of_match[] = { + { .compatible = "qcom,qfprom"}, + {/* sentinel */}, +}; +MODULE_DEVICE_TABLE(of, qfprom_of_match); + +static struct platform_driver qfprom_driver = { + .probe = qfprom_probe, + .remove = qfprom_remove, + .driver = { + .name = "qcom,qfprom", + .of_match_table = qfprom_of_match, + }, +}; +module_platform_driver(qfprom_driver); +MODULE_AUTHOR("Srinivas Kandagatla "); +MODULE_DESCRIPTION("Qualcomm QFPROM driver"); +MODULE_LICENSE("GPL v2");