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: 46292 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2CBB52159D for ; Tue, 24 Mar 2015 22:31:17 +0000 (UTC) Received: by wivz2 with SMTP id z2sf1818195wiv.1 for ; Tue, 24 Mar 2015 15:31:16 -0700 (PDT) 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=GCO7yo7UCbHcM0At9ctHg+Ci6ydCDqSCvn5Jr/x2IoI=; b=HYtcG2BLGgE331m5PGc8RwCV3eg0Yw0x29aDXnLaJIUFdtVXs/zLqlNJ5X9ohMPaaF 6uKh2rI5+zQyL9XADGu5qDOWRp4RYu/4GyEQLnEPKZfKPgZuPex71Bew3nKMGJFAMOpx wjGVWXg7DKs6pc2NYpd6fDnmKngHpc4jBe0en0G4hEOCO8FucGFraX1+weeJUkBqWNrr Yrku2cSn6a1kl90A7Q/j33FqVVwMrxVpZw2A8IkwqZlHlH6RKnzREOZ/V1o8AggjqPf9 l9/X0KFtK71/q/y13YxGOt80DRCELtoISDGTGVga26I7Suf29y8pwLo786koh16IzfH/ 54mA== X-Gm-Message-State: ALoCoQnGmFgSC+Xx8QV68PfuQR0J1tucA1uEuProdapz87Rkz2/f1A9rAmS+GUUwDskfVYYrhGSK X-Received: by 10.180.80.35 with SMTP id o3mr5437665wix.0.1427236276503; Tue, 24 Mar 2015 15:31:16 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.225 with SMTP id n1ls28259lah.52.gmail; Tue, 24 Mar 2015 15:31:16 -0700 (PDT) X-Received: by 10.152.43.3 with SMTP id s3mr5680450lal.101.1427236276343; Tue, 24 Mar 2015 15:31:16 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id l1si443191laa.111.2015.03.24.15.31.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Mar 2015 15:31:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by lbbug6 with SMTP id ug6so5080363lbb.3 for ; Tue, 24 Mar 2015 15:31:16 -0700 (PDT) X-Received: by 10.112.218.5 with SMTP id pc5mr5944781lbc.32.1427236276227; Tue, 24 Mar 2015 15:31:16 -0700 (PDT) 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.57.201 with SMTP id k9csp1732411lbq; Tue, 24 Mar 2015 15:31:15 -0700 (PDT) X-Received: by 10.66.141.42 with SMTP id rl10mr11471672pab.124.1427236274197; Tue, 24 Mar 2015 15:31:14 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r9si778405pdm.117.2015.03.24.15.31.13; Tue, 24 Mar 2015 15:31:14 -0700 (PDT) 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 S1752257AbbCXWbJ (ORCPT + 5 others); Tue, 24 Mar 2015 18:31:09 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:36848 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753442AbbCXWbE (ORCPT ); Tue, 24 Mar 2015 18:31:04 -0400 Received: by wibg7 with SMTP id g7so87630762wib.1 for ; Tue, 24 Mar 2015 15:31:03 -0700 (PDT) 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 Cc: Maxime Ripard , Rob Herring , Kumar Gala , Mark Brown , Greg Kroah-Hartman , linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, arnd@arndb.de, sboyd@codeaurora.org, Srinivas Kandagatla 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> 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.172 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 | 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");