From patchwork Mon Jan 28 15:54:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 156806 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3692291jaa; Mon, 28 Jan 2019 09:36:35 -0800 (PST) X-Google-Smtp-Source: ALg8bN6fKFAvix/AlitcS1l2E+ViT0qIQwm0IJG8XK5y880Ddj6+UQg2Upc35ceSL7rs6I42Zq+K X-Received: by 2002:a63:5d20:: with SMTP id r32mr20834016pgb.329.1548696995104; Mon, 28 Jan 2019 09:36:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548696995; cv=none; d=google.com; s=arc-20160816; b=V+2Jghf6vwqqnMbKxUnYHZlHJh+Hc8idOb75FOpgipb06dPn6g73Dn+bkhW8bomVGK 0THQYadPOWqsdUhQ7zdiYz8008JA4dfd/TJwq+6Iq06GaIHFoRR4VdYv4+yNVrHXO4o/ +/hd+sbZmUvTIGA5Jjcal6+MUJ6tfGMetxyp72VyUPwBQJXrt01L6hYncMyIvOl7vs7E YS0p56Gc5IqtHeHOxqf8X/prCNN4pEHmt/f7Rvz15V5qF6A7fx4pFmXozWxAg7vkEXRf y6cxMeafmG/rwIVTOZFN9EkSu6S/7OWxq19Pc+5sT8MuDTOoalLJvi2Wjk65l1F2uDeD sHzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SNJ/arubp0NvuRnUSqt6ubxHY3NTyD03p3QIxO+K8Rc=; b=O2eFyALJLAdM6oXUGDAmPCexXHT3R0NlpBEZCcnmeyWJY0uePCtcrVxCzgod6pWuQ8 FJHtjtNPvpzET0YekbPVVYg+o1hICMc5s/mSzAvHwdFmH2kgN0GdxedRrBcomaCB3xqP 5B75k9a2/O3njyxjTt1okITCAZ+SUCb/7reO8W1ZRM/8kgiS2N87z3S6v0iOng5uqLHj wfzZeYnuR0b9FfnjTcVdv912rcYMCHbIoZXjMXcvp3MED8Dp1qTM+77paXGsWxlOyJJP QaXuZLC5B9MrPy3kLO1NCoQqAuQphhyysnYtmQmRD449In9TYucYMmJe2ktaBZ9Lc+VL Qo1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QLkrznzk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b91si14921626plb.11.2019.01.28.09.36.34; Mon, 28 Jan 2019 09:36:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QLkrznzk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729972AbfA1Rgc (ORCPT + 31 others); Mon, 28 Jan 2019 12:36:32 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:36783 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729845AbfA1PzN (ORCPT ); Mon, 28 Jan 2019 10:55:13 -0500 Received: by mail-wm1-f67.google.com with SMTP id p6so14437137wmc.1 for ; Mon, 28 Jan 2019 07:55:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SNJ/arubp0NvuRnUSqt6ubxHY3NTyD03p3QIxO+K8Rc=; b=QLkrznzkM6Wn+F/suJwPVmSazcvjYunEB6SOf3rxu7iFW3rXherfp6L+TY6aPMARAK 6jw8TsGs+NpKnpimc/Dkdru2dRUtNRsyzvVM6Nwqa0Z3BnJIGRLKUIddHOk9D1o/hxWP /pZFXohhOvlFrqffRy2QiPGi8RPxsEFLdt7/4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SNJ/arubp0NvuRnUSqt6ubxHY3NTyD03p3QIxO+K8Rc=; b=NjnerhiQENDmLdyEZOf+6As22UlTUS+1BVvNNINsMj/8jNK30MzqM5w6l6G3HCOq4S aytdyNlI0SXfX+/ezyAi2jZYYWsnw2HLSyFu6T5i2T7X2Hx10tyr8ASlEHx+t7dnIrNX 1akIoe6/TgvwasrjM5JNOjDsyWyJ90HJHa+3NxLy1kPeUjT8mFp/GJV8sM1/WxTPZMnM qsGRNLq33p1gzRO/in3gfl1WAeQkNpaCK7ZzV4HtTTwRY5CnDKCZcRjV6ANn2fRPn1Hg ayFoej/zoGb4BzmsVODv0exP+79p8W0ZRk3ixYHL7962twhCJDUfbZuR5+x/pIak9hC4 H+WA== X-Gm-Message-State: AJcUukfgW0r5Pk3XqJ0kPDIe4jXMUF9QH6a0qgSHVFngmXrYAZV9XWx3 7iDRX20SmaIG9diPaZEBhGxLMs4TqO0= X-Received: by 2002:a1c:8484:: with SMTP id g126mr18421456wmd.117.1548690910820; Mon, 28 Jan 2019 07:55:10 -0800 (PST) Received: from srini-hackbox.lan (cpc89974-aztw32-2-0-cust43.18-1.cable.virginm.net. [86.30.250.44]) by smtp.gmail.com with ESMTPSA id p6sm145140485wrx.50.2019.01.28.07.55.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Jan 2019 07:55:10 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 02/13] nvmem: bcm-ocotp: Add ACPI support to BCM OCOTP Date: Mon, 28 Jan 2019 15:54:55 +0000 Message-Id: <20190128155506.25566-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190128155506.25566-1-srinivas.kandagatla@linaro.org> References: <20190128155506.25566-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Srinath Mannam Add ACPI support to bcm ocotp driver This patch is based on Linux-4.20-rc7. Signed-off-by: Srinath Mannam Acked-by: Scott Branden Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/bcm-ocotp.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) -- 2.20.1 diff --git a/drivers/nvmem/bcm-ocotp.c b/drivers/nvmem/bcm-ocotp.c index 4159b3f41d79..a8097511582a 100644 --- a/drivers/nvmem/bcm-ocotp.c +++ b/drivers/nvmem/bcm-ocotp.c @@ -11,13 +11,14 @@ * GNU General Public License for more details. */ +#include #include #include #include #include #include #include -#include +#include #include /* @@ -78,9 +79,9 @@ static struct otpc_map otp_map_v2 = { }; struct otpc_priv { - struct device *dev; - void __iomem *base; - struct otpc_map *map; + struct device *dev; + void __iomem *base; + const struct otpc_map *map; struct nvmem_config *config; }; @@ -237,16 +238,22 @@ static struct nvmem_config bcm_otpc_nvmem_config = { }; static const struct of_device_id bcm_otpc_dt_ids[] = { - { .compatible = "brcm,ocotp" }, - { .compatible = "brcm,ocotp-v2" }, + { .compatible = "brcm,ocotp", .data = &otp_map }, + { .compatible = "brcm,ocotp-v2", .data = &otp_map_v2 }, { }, }; MODULE_DEVICE_TABLE(of, bcm_otpc_dt_ids); +static const struct acpi_device_id bcm_otpc_acpi_ids[] = { + { .id = "BRCM0700", .driver_data = (kernel_ulong_t)&otp_map }, + { .id = "BRCM0701", .driver_data = (kernel_ulong_t)&otp_map_v2 }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(acpi, bcm_otpc_acpi_ids); + static int bcm_otpc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *dn = dev->of_node; struct resource *res; struct otpc_priv *priv; struct nvmem_device *nvmem; @@ -257,14 +264,9 @@ static int bcm_otpc_probe(struct platform_device *pdev) if (!priv) return -ENOMEM; - if (of_device_is_compatible(dev->of_node, "brcm,ocotp")) - priv->map = &otp_map; - else if (of_device_is_compatible(dev->of_node, "brcm,ocotp-v2")) - priv->map = &otp_map_v2; - else { - dev_err(dev, "%s otpc config map not defined\n", __func__); - return -EINVAL; - } + priv->map = device_get_match_data(dev); + if (!priv->map) + return -ENODEV; /* Get OTP base address register. */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -281,7 +283,7 @@ static int bcm_otpc_probe(struct platform_device *pdev) reset_start_bit(priv->base); /* Read size of memory in words. */ - err = of_property_read_u32(dn, "brcm,ocotp-size", &num_words); + err = device_property_read_u32(dev, "brcm,ocotp-size", &num_words); if (err) { dev_err(dev, "size parameter not specified\n"); return -EINVAL; @@ -294,7 +296,7 @@ static int bcm_otpc_probe(struct platform_device *pdev) bcm_otpc_nvmem_config.dev = dev; bcm_otpc_nvmem_config.priv = priv; - if (of_device_is_compatible(dev->of_node, "brcm,ocotp-v2")) { + if (priv->map == &otp_map_v2) { bcm_otpc_nvmem_config.word_size = 8; bcm_otpc_nvmem_config.stride = 8; } @@ -315,6 +317,7 @@ static struct platform_driver bcm_otpc_driver = { .driver = { .name = "brcm-otpc", .of_match_table = bcm_otpc_dt_ids, + .acpi_match_table = ACPI_PTR(bcm_otpc_acpi_ids), }, }; module_platform_driver(bcm_otpc_driver);