From patchwork Thu Feb 19 17:08:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 44847 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 081EC21553 for ; Thu, 19 Feb 2015 17:09:12 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id r20sf6519539wiv.3 for ; Thu, 19 Feb 2015 09:09:11 -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=4BW8nHOOHrvhTa4RFTXB+1m+bNDvDdBzB2St4K2ltS8=; b=AYr8NTuEzQV3ty4KJNOl7dOs84R9SidfIg5F2GiSlrseuz/p41/0dVGQkD6gDkj2Qb nj3ZCQDT1i/S2ch09d/qG779LNyAXPSC527naYgXlURAGDkMtXqResoGZHMVkFme7RJS jOnrV+DO1+iBF4UfmXLrL1xBKYUOlRnRjcPBy2lLCFIv3YVgUJ+uHK5YjBeWZYEUziEp 8TkKp/uPLQEGaikZQvo9MAKcTcbiPAPNIPmZgkhn6iRprOWldkrv4++qHI3TlL6UejWM sm3ukCB+XjBSF/bhd/xbNEMf8Y/7MELxHblav9wLHlKuS5YGdHBWdrFtBOCuM4vOMW11 3JKQ== X-Gm-Message-State: ALoCoQluCpj3/6G4kQvgE2OUPoqIDzaxTykAerPW0bLZNXksgldvP3T7YFKP4o+ZLCtsTG2suEpf X-Received: by 10.152.28.137 with SMTP id b9mr740338lah.8.1424365751298; Thu, 19 Feb 2015 09:09:11 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.166 with SMTP id t6ls197792lat.89.gmail; Thu, 19 Feb 2015 09:09:11 -0800 (PST) X-Received: by 10.112.46.201 with SMTP id x9mr4819508lbm.65.1424365751130; Thu, 19 Feb 2015 09:09:11 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id f3si16129198lae.35.2015.02.19.09.09.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Feb 2015 09:09:11 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbiz12 with SMTP id z12so1073741lbi.11 for ; Thu, 19 Feb 2015 09:09:11 -0800 (PST) X-Received: by 10.112.42.225 with SMTP id r1mr1389484lbl.72.1424365751025; Thu, 19 Feb 2015 09:09:11 -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 h5csp624527lbj; Thu, 19 Feb 2015 09:09:09 -0800 (PST) X-Received: by 10.67.10.227 with SMTP id ed3mr9113363pad.91.1424365749058; Thu, 19 Feb 2015 09:09:09 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xp2si1819867pbc.47.2015.02.19.09.09.05; Thu, 19 Feb 2015 09:09:09 -0800 (PST) Received-SPF: none (google.com: devicetree-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 S1753371AbbBSRJA (ORCPT + 5 others); Thu, 19 Feb 2015 12:09:00 -0500 Received: from mail-wi0-f169.google.com ([209.85.212.169]:35664 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753368AbbBSRI7 (ORCPT ); Thu, 19 Feb 2015 12:08:59 -0500 Received: by mail-wi0-f169.google.com with SMTP id em10so1610858wid.0 for ; Thu, 19 Feb 2015 09:08:57 -0800 (PST) X-Received: by 10.194.83.98 with SMTP id p2mr10558136wjy.125.1424365737624; Thu, 19 Feb 2015 09:08:57 -0800 (PST) Received: from srini-ThinkPad-X1-Carbon-2nd.dlink.com (host-2-96-88-56.as13285.net. [2.96.88.56]) by mx.google.com with ESMTPSA id cb14sm31012848wib.22.2015.02.19.09.08.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Feb 2015 09:08:56 -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 , Arnd Bergmann , broonie@kernel.org, Greg Kroah-Hartman , Srinivas Kandagatla Subject: [RFC PATCH 3/3] eeprom: qfprom: Add Qualcomm QFPROM support. Date: Thu, 19 Feb 2015 17:08:51 +0000 Message-Id: <1424365731-26768-1-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1424365639-26634-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1424365639-26634-1-git-send-email-srinivas.kandagatla@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@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.177 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 | 6 ++++ drivers/eeprom/Makefile | 1 + drivers/eeprom/qfprom.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 drivers/eeprom/qfprom.c diff --git a/drivers/eeprom/Kconfig b/drivers/eeprom/Kconfig index 39235a9..b0c94cb 100644 --- a/drivers/eeprom/Kconfig +++ b/drivers/eeprom/Kconfig @@ -26,4 +26,10 @@ 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 + 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..da31b36 --- /dev/null +++ b/drivers/eeprom/qfprom.c @@ -0,0 +1,75 @@ +#include +#include +#include +#include +#include +#include + +static struct regmap_config qfprom_regmap_config = { + .reg_bits = 32, + .val_bits = 8, + .reg_stride = 1, +}; + +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; + int rval; + + eeprom = devm_kzalloc(dev, sizeof(*eeprom), GFP_KERNEL); + if (!eeprom) + return -ENOMEM; + + 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; + + eeprom->regmap = devm_regmap_init_mmio(dev, base, + &qfprom_regmap_config); + if (IS_ERR(eeprom->regmap)) { + dev_err(dev, "regmap init failed\n"); + return PTR_ERR(eeprom->regmap); + } + + eeprom->dev = dev; + eeprom->stride = qfprom_regmap_config.reg_stride; + eeprom->size = resource_size(res) - 1; + rval = eeprom_register(eeprom); + if (rval) + return rval; + + 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");