Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp11231742imu; Mon, 31 Dec 2018 16:45:24 -0800 (PST) X-Google-Smtp-Source: ALg8bN4VgwooOTr3j8xjOy8nbDA0knz6Tp9Mr5zFpGS6txn/tJBVNmsBlB4w/wCG07pvCrwiIpaP X-Received: by 2002:a17:902:c05:: with SMTP id 5mr39283771pls.155.1546303524414; Mon, 31 Dec 2018 16:45:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546303524; cv=none; d=google.com; s=arc-20160816; b=MbwwWl7LVrjPn0IynGUh3S8gJTDjCqXlOyjz+q3LBsiC3aZE6yrNbhGtp6v4gdPgnv R/RdNKiG/LfagCy6Eg5i72hiJ6yh4ixXdB68ua15M7rMFBRv+zPPM2MwkRnkeK+QdFcM 5BbdwGHRAigVW2o3Oqm2j7dJgUiS8MicAXB92HZDFooVq94GYsmrR4tU+cRM/TUSAnbN jC+OLjIBNL41I3rlam6ix7E2XArAJ/5RVz43J5ghFaZ+xjYU7idc9KVfLenLfHA08mKt 35wYUbRZB7ygMJpJuAXTmyWd/RXfOnDMimlyThMrh7OjvZ2pS7GatHiGot07yTUvG/Ou yzJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=rITVePHL/56oXRysj09iMlQmQaOFNRUc27HDPslO6Mk=; b=ZIc4IVmZTjc8NFIWlJEJRkrh4fqTWrpsiSXIbETELw3OGm9+zULZl+7F36QbEvMi0t 7kw6zvsmNvXlvUpY7KuhIN9rt10UJ2rFP5Qa4jNxhJc2Kt3AOnS154BfaQVXVkcckEUu D5YdwpEFHdmQcUnlR7adp72oD93yNJ9zrNkugrTtPKYjzBd1JzndzzHEx4I4tNShlBZR HRiiDbXHVDP1fDiW7dK7SCH/m7BKTIF6phBRmOZ0VHoVhJeW9xXrwEKFABjOeBGwnAkU PR2rHGxZTZO7blNzkz1VV/RGXdtbBszPPNDC/DhmeFiNZb3z4j116xPtPnCvFTHSMTdU u/pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=LdjwhjP7; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3si15791042pga.297.2018.12.31.16.44.47; Mon, 31 Dec 2018 16:45:24 -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=@broadcom.com header.s=google header.b=LdjwhjP7; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728087AbeLaWoV (ORCPT + 99 others); Mon, 31 Dec 2018 17:44:21 -0500 Received: from mail-yb1-f193.google.com ([209.85.219.193]:44119 "EHLO mail-yb1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727405AbeLaWoU (ORCPT ); Mon, 31 Dec 2018 17:44:20 -0500 Received: by mail-yb1-f193.google.com with SMTP id e1so6431696ybn.11 for ; Mon, 31 Dec 2018 14:44:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=rITVePHL/56oXRysj09iMlQmQaOFNRUc27HDPslO6Mk=; b=LdjwhjP7HN7GjFWjNsSOHzoR1rELyx0FRVFdJ5tr2MuEW7lUxehLghMuQoYrSoz4sd qBpq5DAR+Zpp00wmIXR4ixFBP7zWvq/ts9CxTxOXQ12nAUHsjNcfe0iu2kbZouN3ruEO aa67gdkqt3i3i4TNRqr1qamRCvLTv7rJqS2fw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=rITVePHL/56oXRysj09iMlQmQaOFNRUc27HDPslO6Mk=; b=SgOFzGh3cY+UPTULjmsVJfl/+aR8qQ9uQdm4un4wDOgHRQKmRNo+icCjli57RHY0FF r1jehQTzgeIzhIXVKoT9J7lmz/t+JDen//H2EKgs3dWsPo/5ghqLlrNSx6exzkQ0dD5J 0ZVkDY5OsmXSgbSoZBK/sNah4OliZZ8pNf15TK5VwSk6tzCqLIN9MxuV+jO+ovcHTgVo OtTbUGIoniVvkXxoFyQoc4iqi78hoxi9LZusZ6eFWi0TmAxgtw4DftClbhiUZVzeGi9S nfmnokiicVKEI+j3a+TXuCfK9Pb/WKKCKZbhkubKRzUetFasOkSnP7i8+4rvWm+4OEYu SVRA== X-Gm-Message-State: AJcUukfUI3eXIUw40+8rv4gpM9WwCPxEHyn/7BpeWdY4xDLw+ZgnHO+s KdB8JGBOwf7ytordwfzEDx8Un1ac/yGPfQ== X-Received: by 2002:a5b:352:: with SMTP id q18mr12140522ybp.371.1546296259235; Mon, 31 Dec 2018 14:44:19 -0800 (PST) Received: from [10.136.13.65] ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id l140sm17940235ywe.77.2018.12.31.14.44.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Dec 2018 14:44:18 -0800 (PST) Subject: Re: [PATCH] nvmem: bcm-ocotp: Add ACPI support to BCM OCOTP To: Srinath Mannam , Srinivas Kandagatla , Ray Jui Cc: bcm-kernel-feedback-list@broadcom.com, linux-kernel@vger.kernel.org References: <1545881941-19986-1-git-send-email-srinath.mannam@broadcom.com> From: Scott Branden Message-ID: <483c6309-e3bd-005c-c4c4-6ec04b2c4c02@broadcom.com> Date: Mon, 31 Dec 2018 14:44:15 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <1545881941-19986-1-git-send-email-srinath.mannam@broadcom.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-12-26 7:39 p.m., Srinath Mannam wrote: > 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 > --- > drivers/nvmem/bcm-ocotp.c | 37 ++++++++++++++++++++----------------- > 1 file changed, 20 insertions(+), 17 deletions(-) > > diff --git a/drivers/nvmem/bcm-ocotp.c b/drivers/nvmem/bcm-ocotp.c > index 4159b3f..a809751 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);