All of lore.kernel.org
 help / color / mirror / Atom feed
From: Enric Balletbo i Serra <enric.balletbo@collabora.com>
To: linux-kernel@vger.kernel.org, Olof Johansson <olof@lixom.net>
Cc: Gene Chen <gene.chen@intel.com>,
	Benson Leung <bleung@chromium.org>,
	Aaron Durbin <adurbin@chromium.org>,
	Filipe Brandenburger <filbranden@chromium.org>,
	Ben Zhang <benzh@chromium.org>,
	Olof Johansson <olofj@chromium.org>,
	Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Subject: [PATCHv2 2/3] platform/chrome: pstore: probe for ramoops buffer using acpi
Date: Tue, 16 Feb 2016 08:25:15 +0100	[thread overview]
Message-ID: <1455607516-6142-3-git-send-email-enric.balletbo@collabora.com> (raw)
In-Reply-To: <1455607516-6142-1-git-send-email-enric.balletbo@collabora.com>

From: Aaron Durbin <adurbin@chromium.org>

In order to handle the firmware placing the ramoops buffer
in a different location than the kernel is configured to look
probe for an ACPI device specified by GOOG9999 acpi id. If
no device is found or the first memory resource is not defined
properly fall back to the configured base and length.

Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Signed-off-by: Ben Zhang <benzh@chromium.org>
Signed-off-by: Filipe Brandenburger <filbranden@chromium.org>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Reviewed-by: Olof Johansson <olofj@chromium.org>
---
 drivers/platform/chrome/chromeos_pstore.c | 53 ++++++++++++++++++++++++++++++-
 1 file changed, 52 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/chrome/chromeos_pstore.c b/drivers/platform/chrome/chromeos_pstore.c
index 3474920..ca00192 100644
--- a/drivers/platform/chrome/chromeos_pstore.c
+++ b/drivers/platform/chrome/chromeos_pstore.c
@@ -8,6 +8,7 @@
  *  the Free Software Foundation, version 2 of the License.
  */
 
+#include <linux/acpi.h>
 #include <linux/dmi.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
@@ -71,9 +72,59 @@ static struct platform_device chromeos_ramoops = {
 	},
 };
 
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id cros_ramoops_acpi_match[] = {
+	{ "GOOG9999", 0 },
+	{ }
+};
+MODULE_DEVICE_TABLE(acpi, cros_ramoops_acpi_match);
+
+static struct platform_driver chromeos_ramoops_acpi = {
+	.driver		= {
+		.name	= "chromeos_pstore",
+		.acpi_match_table = ACPI_PTR(cros_ramoops_acpi_match),
+	},
+};
+
+static int __init chromeos_probe_acpi(struct platform_device *pdev)
+{
+	struct resource *res;
+	resource_size_t len;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENOMEM;
+
+	len = resource_size(res);
+	if (!res->start || !len)
+		return -ENOMEM;
+
+	pr_info("chromeos ramoops using acpi device.\n");
+
+	chromeos_ramoops_data.mem_size = len;
+	chromeos_ramoops_data.mem_address = res->start;
+
+	return 0;
+}
+
+static bool __init chromeos_check_acpi(void)
+{
+	if (!platform_driver_probe(&chromeos_ramoops_acpi, chromeos_probe_acpi))
+		return true;
+	return false;
+}
+#else
+static inline bool chromeos_check_acpi(void) { return false; }
+#endif
+
 static int __init chromeos_pstore_init(void)
 {
-	if (dmi_check_system(chromeos_pstore_dmi_table))
+	bool acpi_dev_found;
+
+	/* First check ACPI for non-hardcoded values from firmware. */
+	acpi_dev_found = chromeos_check_acpi();
+
+	if (acpi_dev_found || dmi_check_system(chromeos_pstore_dmi_table))
 		return platform_device_register(&chromeos_ramoops);
 
 	return -ENODEV;
-- 
2.1.0

  parent reply	other threads:[~2016-02-16  7:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-16  7:25 [PATCHv2 0/3] platform/chrome: upstream changes Enric Balletbo i Serra
2016-02-16  7:25 ` [PATCHv2 1/3] platform/chrome: chromeos_laptop: Add Leon Touch Enric Balletbo i Serra
2016-03-06 20:03   ` Olof Johansson
2016-02-16  7:25 ` Enric Balletbo i Serra [this message]
2016-03-06 20:04   ` [PATCHv2 2/3] platform/chrome: pstore: probe for ramoops buffer using acpi Olof Johansson
2016-02-16  7:25 ` [PATCHv2 3/3] platform/chrome: pstore: Move to larger record size Enric Balletbo i Serra
2016-03-06 20:04   ` Olof Johansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1455607516-6142-3-git-send-email-enric.balletbo@collabora.com \
    --to=enric.balletbo@collabora.com \
    --cc=adurbin@chromium.org \
    --cc=benzh@chromium.org \
    --cc=bleung@chromium.org \
    --cc=filbranden@chromium.org \
    --cc=gene.chen@intel.com \
    --cc=gustavo.padovan@collabora.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olof@lixom.net \
    --cc=olofj@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.