From patchwork Thu Mar 5 09:46:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 45449 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 44B2E204BC for ; Thu, 5 Mar 2015 09:47:00 +0000 (UTC) Received: by lbdu14 with SMTP id u14sf7777205lbd.3 for ; Thu, 05 Mar 2015 01:46:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=f3rEfOeITXOQ5e/kYUbr3u33z04HkcRs0EfXvyPmfz0=; b=KUelR+P886cCobZDgBKhGz+35HRDvGtIRLMD4K86hzu2rKz8Xrz4xB7uW9n2S8/DG4 te5bcNF16Hc0mEUORZvaf3GGp6LyN4Pcvwf/yon3r9oV595C8RiVCgZiK5theuEFhH1g J/e27IfDUf1/uuscovwkU5sL4s3wqKZg2eTvswPMQ1Ox/QOhnclew3sQ3V0GckxWwIrO vmGs/g1XXsqD7Z5KEsOoWY5nFkFZK6KmeNJHK6UZ43daqv4+sZuqq9iGut8jMFk3Z08m wzdCBRfcYh1pNT0XFKplimcIkCMQmPHsQxRf674lSX6wJntruK3Rqe6U0fy6rE+LzOCb 9twA== X-Gm-Message-State: ALoCoQmAnYk0sJn3Ltd+x0MZDV7N9tUjc36OHE+N3/sXnUsfXy090puJaBPFbMz5Nq9nQjyEJAhH X-Received: by 10.112.130.70 with SMTP id oc6mr1387546lbb.13.1425548819295; Thu, 05 Mar 2015 01:46:59 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.99 with SMTP id lf3ls307549lac.4.gmail; Thu, 05 Mar 2015 01:46:59 -0800 (PST) X-Received: by 10.152.120.134 with SMTP id lc6mr6976366lab.72.1425548819055; Thu, 05 Mar 2015 01:46:59 -0800 (PST) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id ut6si4132682lbc.85.2015.03.05.01.46.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Mar 2015 01:46:59 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by lbiz12 with SMTP id z12so22205114lbi.12 for ; Thu, 05 Mar 2015 01:46:58 -0800 (PST) X-Received: by 10.152.43.51 with SMTP id t19mr6898512lal.73.1425548818922; Thu, 05 Mar 2015 01:46:58 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp372719lbj; Thu, 5 Mar 2015 01:46:57 -0800 (PST) X-Received: by 10.70.140.104 with SMTP id rf8mr14222208pdb.89.1425548816189; Thu, 05 Mar 2015 01:46:56 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qy2si8700639pbc.98.2015.03.05.01.46.54; Thu, 05 Mar 2015 01:46:56 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932594AbbCEJqg (ORCPT + 28 others); Thu, 5 Mar 2015 04:46:36 -0500 Received: from mail-wg0-f47.google.com ([74.125.82.47]:36977 "EHLO mail-wg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932549AbbCEJq3 (ORCPT ); Thu, 5 Mar 2015 04:46:29 -0500 Received: by wggx13 with SMTP id x13so12007602wgg.4 for ; Thu, 05 Mar 2015 01:46:27 -0800 (PST) X-Received: by 10.180.89.173 with SMTP id bp13mr20775522wib.88.1425548787620; Thu, 05 Mar 2015 01:46:27 -0800 (PST) Received: from srini-ThinkPad-X1-Carbon-2nd.dlink.com (host-89-242-228-249.as13285.net. [89.242.228.249]) by mx.google.com with ESMTPSA id ge8sm9692749wjc.32.2015.03.05.01.46.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Mar 2015 01:46:26 -0800 (PST) From: Srinivas Kandagatla To: linux-arm-kernel@lists.infradead.org Cc: Maxime Ripard , Rob Herring , Pawel Moll , Kumar Gala , linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Stephen Boyd , andrew@lunn.ch, Arnd Bergmann , broonie@kernel.org, Greg Kroah-Hartman , Srinivas Kandagatla Subject: [PATCH v1 5/6] eeprom: qfprom: Add Qualcomm QFPROM support. Date: Thu, 5 Mar 2015 09:46:23 +0000 Message-Id: <1425548783-13110-1-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1425548685-12887-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1425548685-12887-1-git-send-email-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: srinivas.kandagatla@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 | 7 +++++ drivers/eeprom/Makefile | 1 + drivers/eeprom/qfprom.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 drivers/eeprom/qfprom.c diff --git a/drivers/eeprom/Kconfig b/drivers/eeprom/Kconfig index bff8ecb..65325c7 100644 --- a/drivers/eeprom/Kconfig +++ b/drivers/eeprom/Kconfig @@ -28,4 +28,11 @@ config EEPROM_SUNXI_SID This driver can also be built as a module. If so, the module will be called sunxi_sid. +config QCOM_QFPROM + tristate "QCOM QFPROM Support" + depends on EEPROM + 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. endif diff --git a/drivers/eeprom/Makefile b/drivers/eeprom/Makefile index 661422c..f99c824 100644 --- a/drivers/eeprom/Makefile +++ b/drivers/eeprom/Makefile @@ -8,3 +8,4 @@ obj-$(CONFIG_EEPROM) += core.o # Devices obj-$(CONFIG_EEPROM_SUNXI_SID) += eeprom-sunxi-sid.o +obj-$(CONFIG_QCOM_QFPROM) += qfprom.o diff --git a/drivers/eeprom/qfprom.c b/drivers/eeprom/qfprom.c new file mode 100644 index 0000000..371a8c0 --- /dev/null +++ b/drivers/eeprom/qfprom.c @@ -0,0 +1,74 @@ +#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 = { + .stride = 1, + .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; + + 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; + + econfig.regmap = devm_regmap_init_mmio(dev, base, + &qfprom_regmap_config); + if (IS_ERR(econfig.regmap)) { + dev_err(dev, "regmap init failed\n"); + return PTR_ERR(econfig.regmap); + } + econfig.owner = THIS_MODULE; + econfig.dev = dev; + econfig.size = resource_size(res) - 1; + 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("GPL2");