From patchwork Fri Mar 13 09:50:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 45758 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 925A8214BF for ; Fri, 13 Mar 2015 09:51:10 +0000 (UTC) Received: by wggx13 with SMTP id x13sf15520503wgg.0 for ; Fri, 13 Mar 2015 02:51:09 -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=3kmXcEwJQoeTgxSDK+Bo94xurrlDeMEdi+rMIs7CDdc=; b=U69VH2AKkduW8oC/wwvKFsGh2XGaxe8IYVrM+9JDIRUzu5AKtMxGURswVPVtZjnX/h ITNXuZJhObI7C6X8b+CTi6z5i2nJ2DTOjINZmEbnUJG6nb7atbnOQ3/g66qNhAfTMk+w uqdFtKjQ8Ni0Jx/VZk3446hGmR54UDF4sXgY/BTdds6XGpWKl3JYrnXCzVTJHrTPcRvT L91lrI0XbRLQhuOSCMjv/s225ac5AWqbMwOigGFRDzUzxZQSUVaQMKTrwnXiMtClSTgJ WRp9oVaoyGr4wBkws2zy8YLMWkLKSWNu3DlohORJ6HzAO/sW18tBul64MTBIsXHqFjtu O4IQ== X-Gm-Message-State: ALoCoQkUYIKqN8jkX5kWdg56kCsuvZsRtKG/X0MMbykJ5Nf9K3yVMAPqimPjxz+MuCSuFvgiLNOP X-Received: by 10.180.80.35 with SMTP id o3mr229154wix.0.1426240269887; Fri, 13 Mar 2015 02:51:09 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.9.137 with SMTP id z9ls360542laa.15.gmail; Fri, 13 Mar 2015 02:51:09 -0700 (PDT) X-Received: by 10.152.36.101 with SMTP id p5mr43353872laj.34.1426240269695; Fri, 13 Mar 2015 02:51:09 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id an4si1007926lac.73.2015.03.13.02.51.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Mar 2015 02:51:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by labgd6 with SMTP id gd6so21368218lab.6 for ; Fri, 13 Mar 2015 02:51:09 -0700 (PDT) X-Received: by 10.112.130.100 with SMTP id od4mr19932855lbb.86.1426240269585; Fri, 13 Mar 2015 02:51:09 -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.35.133 with SMTP id h5csp786361lbj; Fri, 13 Mar 2015 02:51:08 -0700 (PDT) X-Received: by 10.70.89.174 with SMTP id bp14mr17108755pdb.14.1426240261475; Fri, 13 Mar 2015 02:51:01 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fl4si2998048pab.219.2015.03.13.02.51.00; Fri, 13 Mar 2015 02:51:01 -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 S1753164AbbCMJuz (ORCPT + 5 others); Fri, 13 Mar 2015 05:50:55 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:36588 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754459AbbCMJuw (ORCPT ); Fri, 13 Mar 2015 05:50:52 -0400 Received: by wiwh11 with SMTP id h11so4668374wiw.1 for ; Fri, 13 Mar 2015 02:50:51 -0700 (PDT) X-Received: by 10.194.171.100 with SMTP id at4mr71526166wjc.122.1426240251627; Fri, 13 Mar 2015 02:50:51 -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 fy2sm2046767wic.15.2015.03.13.02.50.47 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Mar 2015 02:50:50 -0700 (PDT) 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 , linux-arm-msm@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v2 5/7] eeprom: qfprom: Add Qualcomm QFPROM support. Date: Fri, 13 Mar 2015 09:50:45 +0000 Message-Id: <1426240245-2621-1-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1426240157-2383-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1426240157-2383-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.215.49 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 | 9 ++++- drivers/eeprom/Makefile | 1 + drivers/eeprom/qfprom.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 drivers/eeprom/qfprom.c diff --git a/drivers/eeprom/Kconfig b/drivers/eeprom/Kconfig index fd4fa2f..b77828b 100644 --- a/drivers/eeprom/Kconfig +++ b/drivers/eeprom/Kconfig @@ -23,4 +23,11 @@ config EEPROM_SUNXI_SID This driver can also be built as a module. If so, the module will be called eprom-sunxi-sid. -endif \ No newline at end of file +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 546a27c..9c1bb03 100644 --- a/drivers/eeprom/Makefile +++ b/drivers/eeprom/Makefile @@ -6,3 +6,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..7d9e5e9 --- /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 + +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("GPL v2");