From: Bartlomiej Sieka <tur@semihalf.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] RFC: generic property fixup mechanism for LIBFDT
Date: Thu, 30 Aug 2007 14:49:28 +0200 [thread overview]
Message-ID: <46D6BCD8.8030605@semihalf.com> (raw)
In-Reply-To: <46D6AF58.2060408@gmail.com>
Jerry Van Baren wrote:
> Jerry Van Baren wrote:
>> Grant Likely wrote:
[...]
>>> ft_cpu_setup(void *blob, bd_t *bd)
>>> {
>>> fixup_int_prop(blob, "/cpus/" OF_CPU, "timebase-frequency", OF_TBCLK);
>>> fixup_int_prop(blob, "/cpus/" OF_CPU, "bus-frequency", bd->bi_busfreq);
>>> fixup_int_prop(blob, "/cpus/" OF_CPU, "clock-frequency",
>>> bd->bi_intfreq);
>>> fixup_int_prop(blob, "/cpus/" OF_CPU, "bus-frequency", bd->ipbfreq);
>>> fixup_prop(blob, "/" OF_SOC "/ethernet at 3000", "mac-address",
>>> bd->bi_enetaddr, 6);
> fixup_mac_prop(blob, "/" OF_SOC "/ethernet at 3000", "mac-address",
> bd->bi_enetaddr, 1);
>>> fixup_prop(blob, "/" OF_SOC "/ethernet at 3000", "local-mac-address",
>>> bd->bi_enetaddr, 6);
> fixup_mac_prop(blob, "/" OF_SOC "/ethernet at 3000",
> "local-mac-address", bd->bi_enetaddr, 0);
>>> }
>>>
>>> This adds 2 helper functions instead of 5, and one of them is the same
>>> path for all of the fixups. Drops the table approach entirely due to
>>> the problems with extracting values out of bd. (Which is what I meant
>>> in the third part of my original comment)
>> I think 2 is too optimistic, but it is still possible this approach
>> would be better than the current 5. The above looks better, but I claim
>> only because it is oversimplified - I contend the 2 helper functions
>> will expand to 5 functions that basically are the current "setter"
>> functions. On the other hand, maybe not. It is worth trying.
>
> [more snippage]
>
>>> The 2 new helpers could also be generalized for use by all boards.
>> s/2/n/ (where n is probably 5) and I would agree 100%. :-/
>>
>>> Cheers,
>>> g.
>
> Thinking about it and a quick glance (I'm running remotely), I think we
> could do the job with three "setter" functions based on Grant's
> proposal, which would be a Good Thing[tm].
>
> static int fixup_int_prop(void *fdt, char *node, char *prop, u32 val)
> - Like Grant proposes, note it does a cpu_to_be32()
>
> static int fixup_mac_prop(void *fdt, char *node, char *prop, void *val,
> int force)
> - Note I replaced "size" with "force". We know the size (6). The
> "force" flag (better name, anyone?) would be whether the MAC addr should
> be created if it _doesn't_ exist.
How about having two functions lite this:
static int fixup_int_prop(void *fdt, char *node, char *prop, u32 val,
int create);
static int fixup_str_prop(void *fdt, char *node, char *prop, char *val,
int len, int create)
?
The last argument ('create' i.e., Jerry's 'force') tells whether the
property should be created if it doesn't exist. fixup_str_prop() (a
better name?) takes a len argument just in case we ever wanted to set
properties with length different than the MAC address' length.
The above functions are generic and can be used by all boards; the
following specific code would go into ft_cpu_setup():
fixup_int_prop(blob, "/cpus/" OF_CPU, "timebase-frequency", OF_TBCLK, 1);
fixup_int_prop(blob, "/cpus/" OF_CPU, "bus-frequency", bd->bi_busfreq, 1);
fixup_int_prop(blob, "/cpus/" OF_CPU, "clock-frequency", bd->bi_intfreq, 1);
fixup_int_prop(blob, "/cpus/" OF_CPU, "bus-frequency", bd->ipbfreq, 1);
fixup_str_prop(blob, "/" OF_SOC "/ethernet at 3000", "mac-address",
bd->bi_enetaddr, 6, 0);
fixup_str_prop(blob, "/" OF_SOC "/ethernet at 3000", "local-mac-address",
bd->bi_enetaddr, 6, 0);
If in the future there's a need for setting a property other than int or
char[], a function similar to the two ones above can be added.
Regards,
Bartlomiej
next prev parent reply other threads:[~2007-08-30 12:49 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-02 18:24 [U-Boot-Users] [PATCH] fdt, mpc5xxx: Adapt MPC5xxx to use libfdt in ft_cpu_setup() Bartlomiej Sieka
2007-08-03 9:07 ` [U-Boot-Users] [PATCH CORRECTION] " Bartlomiej Sieka
2007-08-03 14:25 ` Grant Likely
2007-08-22 11:54 ` [U-Boot-Users] [PATCH] RFC: generic property fixup mechanism for LIBFDT Bartlomiej Sieka
2007-08-22 13:18 ` Jerry Van Baren
2007-08-22 21:09 ` Kim Phillips
2007-08-22 23:16 ` Jerry Van Baren
2007-08-23 16:24 ` Kim Phillips
2007-08-23 17:01 ` Jerry Van Baren
2007-08-29 18:01 ` Grant Likely
2007-08-30 2:40 ` Jerry Van Baren
2007-08-30 11:51 ` Jerry Van Baren
2007-08-30 12:49 ` Bartlomiej Sieka [this message]
2007-08-22 23:30 ` Wolfgang Denk
2007-08-23 16:48 ` Kim Phillips
2007-08-23 17:28 ` Jerry Van Baren
2007-08-23 19:25 ` Wolfgang Denk
2007-08-29 10:59 ` [U-Boot-Users] [PATCH CORRECTION] fdt, mpc5xxx: Adapt MPC5xxx to use libfdt in ft_cpu_setup() Wolfgang Denk
2007-08-29 18:23 ` Grant Likely
2007-08-04 21:21 ` [U-Boot-Users] [PATCH] " Jerry Van Baren
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=46D6BCD8.8030605@semihalf.com \
--to=tur@semihalf.com \
--cc=u-boot@lists.denx.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox