From: geoffrey.levand@am.sony.com
To: paulus@samba.org
Cc: linuxppc-dev@ozlabs.org
Subject: [patch 5/6] PS3: Save os-area params to device tree
Date: Sat, 06 Oct 2007 14:35:47 -0700 [thread overview]
Message-ID: <20071006213542.867445085@am.sony.com> (raw)
In-Reply-To: 20071006213542.311447584@am.sony.com
Add the PS3 os-area startup params to the device tree. This allows
a second stage kernel loaded with kexec to use these values.
Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
---
arch/powerpc/platforms/ps3/os-area.c | 104 +++++++++++++++++++++++++++++++++-
arch/powerpc/platforms/ps3/platform.h | 1
arch/powerpc/platforms/ps3/setup.c | 1
3 files changed, 104 insertions(+), 2 deletions(-)
--- a/arch/powerpc/platforms/ps3/os-area.c
+++ b/arch/powerpc/platforms/ps3/os-area.c
@@ -119,10 +119,65 @@ struct os_area_params {
*/
struct saved_params {
+ unsigned int valid;
s64 rtc_diff;
unsigned int av_multi_out;
} static saved_params;
+static struct property property_rtc_diff = {
+ .name = "linux,rtc_diff",
+ .length = sizeof(saved_params.rtc_diff),
+ .value = &saved_params.rtc_diff,
+};
+
+static struct property property_av_multi_out = {
+ .name = "linux,av_multi_out",
+ .length = sizeof(saved_params.av_multi_out),
+ .value = &saved_params.av_multi_out,
+};
+
+/**
+ * os_area_set_property - Add or overwrite a saved_params value to the device tree.
+ *
+ * Overwrites an existing property.
+ */
+
+static void os_area_set_property(struct device_node *node,
+ struct property *prop)
+{
+ int result;
+ struct property *tmp = of_find_property(node, prop->name, NULL);
+
+ if (tmp) {
+ pr_debug("%s:%d found %s\n", __func__, __LINE__, prop->name);
+ prom_remove_property(node, tmp);
+ }
+
+ result = prom_add_property(node, prop);
+
+ if (result)
+ pr_debug("%s:%d prom_set_property failed\n", __func__,
+ __LINE__);
+}
+
+/**
+ * os_area_get_property - Get a saved_params value from the device tree.
+ *
+ */
+
+static void __init os_area_get_property(struct device_node *node,
+ struct property *prop)
+{
+ const struct property *tmp = of_find_property(node, prop->name, NULL);
+
+ if (tmp) {
+ BUG_ON(prop->length != tmp->length);
+ memcpy(prop->value, tmp->value, prop->length);
+ } else
+ pr_debug("%s:%d not found %s\n", __func__, __LINE__,
+ prop->name);
+}
+
#define dump_header(_a) _dump_header(_a, __func__, __LINE__)
static void _dump_header(const struct os_area_header *h, const char *func,
int line)
@@ -196,8 +251,19 @@ static int __init verify_header(const st
static void os_area_queue_work_handler(struct work_struct *work)
{
+ struct device_node *node;
+
pr_debug(" -> %s:%d\n", __func__, __LINE__);
+ node = of_find_node_by_path("/");
+
+ if (node) {
+ os_area_set_property(node, &property_rtc_diff);
+ of_node_put(node);
+ } else
+ pr_debug("%s:%d of_find_node_by_path failed\n",
+ __func__, __LINE__);
+
pr_debug(" <- %s:%d\n", __func__, __LINE__);
}
@@ -244,6 +310,8 @@ void __init ps3_os_area_save_params(void
result = verify_header(header);
if (result) {
+ /* Second stage kernels exit here. */
+
pr_debug("%s:%d verify_header failed\n", __func__, __LINE__);
dump_header(header);
return;
@@ -254,6 +322,7 @@ void __init ps3_os_area_save_params(void
saved_params.rtc_diff = params->rtc_diff;
saved_params.av_multi_out = params->av_multi_out;
+ saved_params.valid = 1;
memset(header, 0, sizeof(*header));
@@ -261,13 +330,44 @@ void __init ps3_os_area_save_params(void
}
/**
+ * ps3_os_area_init - Setup os area device tree properties as needed.
+ */
+
+void __init ps3_os_area_init(void)
+{
+ struct device_node *node;
+
+ pr_debug(" -> %s:%d\n", __func__, __LINE__);
+
+ node = of_find_node_by_path("/");
+
+ if (!saved_params.valid && node) {
+ /* Second stage kernels should have a dt entry. */
+ os_area_get_property(node, &property_rtc_diff);
+ os_area_get_property(node, &property_av_multi_out);
+ }
+
+ if(!saved_params.rtc_diff)
+ saved_params.rtc_diff = SECONDS_FROM_1970_TO_2000;
+
+ if (node) {
+ os_area_set_property(node, &property_rtc_diff);
+ os_area_set_property(node, &property_av_multi_out);
+ of_node_put(node);
+ } else
+ pr_debug("%s:%d of_find_node_by_path failed\n",
+ __func__, __LINE__);
+
+ pr_debug(" <- %s:%d\n", __func__, __LINE__);
+}
+
+/**
* ps3_os_area_get_rtc_diff - Returns the rtc diff value.
*/
u64 ps3_os_area_get_rtc_diff(void)
{
- return saved_params.rtc_diff ? saved_params.rtc_diff
- : SECONDS_FROM_1970_TO_2000;
+ return saved_params.rtc_diff;
}
/**
--- a/arch/powerpc/platforms/ps3/platform.h
+++ b/arch/powerpc/platforms/ps3/platform.h
@@ -63,6 +63,7 @@ int ps3_set_rtc_time(struct rtc_time *ti
/* os area */
void __init ps3_os_area_save_params(void);
+void __init ps3_os_area_init(void);
u64 ps3_os_area_get_rtc_diff(void);
void ps3_os_area_set_rtc_diff(u64 rtc_diff);
--- a/arch/powerpc/platforms/ps3/setup.c
+++ b/arch/powerpc/platforms/ps3/setup.c
@@ -206,6 +206,7 @@ static void __init ps3_setup_arch(void)
prealloc_ps3flash_bounce_buffer();
ppc_md.power_save = ps3_power_save;
+ ps3_os_area_init();
DBG(" <- %s:%d\n", __func__, __LINE__);
}
--
next prev parent reply other threads:[~2007-10-06 21:38 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-06 21:35 [patch 0/6] PS3 os area patches for 2.6.24 geoffrey.levand
2007-10-06 21:35 ` [patch 1/6] PS3: Cleanup of os-area.c geoffrey.levand
2007-10-06 21:35 ` [patch 2/6] PS3: Remove unused os-area params geoffrey.levand
2007-10-08 14:00 ` Ranulf Doswell
2007-10-08 17:53 ` Geoff Levand
2007-10-08 22:38 ` Ranulf Doswell
2007-10-08 22:50 ` Geoff Levand
2007-10-06 21:35 ` [patch 3/6] PS3: os-area workqueue processing geoffrey.levand
2007-10-06 21:35 ` [patch 4/6] PS3: Add os-area rtc_diff set/get routines geoffrey.levand
2007-10-06 21:35 ` geoffrey.levand [this message]
2007-10-06 21:35 ` [patch 6/6] PS3: Add os-area database routines geoffrey.levand
2007-10-08 8:27 ` Geert Uytterhoeven
2007-10-09 1:08 ` Geoff Levand
2007-10-08 12:16 ` Geert Uytterhoeven
2007-10-09 1:12 ` Geoff Levand
2007-10-08 13:48 ` Ranulf Doswell
2007-10-08 17:52 ` Geoff Levand
2007-10-08 22:59 ` Ranulf Doswell
2007-10-08 23:36 ` Geoff Levand
2007-10-09 9:35 ` Geert Uytterhoeven
2007-10-09 12:23 ` Ranulf Doswell
2007-10-09 1:07 ` [patch v2] " Geoff Levand
2007-10-09 11:38 ` Geert Uytterhoeven
2007-10-09 17:15 ` Linas Vepstas
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=20071006213542.867445085@am.sony.com \
--to=geoffrey.levand@am.sony.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.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.