* [RFC PATCH] sparc: fake idprom for leon
@ 2011-01-02 19:40 Sam Ravnborg
2011-01-03 8:55 ` Kristoffer Glembo
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Sam Ravnborg @ 2011-01-02 19:40 UTC (permalink / raw)
To: sparclinux
Hi Kristoffer & David.
Following is a very naive implementation of
a fake idprom for leon.
This is only for inspiration as I hope
that it is possible to find the MAC address
somehow so we present it correct.
One advantage of using a fake idprom is that all places
that do access idprom no longer needs to be ifdeffed out.
Today floppy.h reads idprom unconditionally.
Sam
diff --git a/arch/sparc/prom/misc_32.c b/arch/sparc/prom/misc_32.c
index 4d61c54..ee5fe45 100644
--- a/arch/sparc/prom/misc_32.c
+++ b/arch/sparc/prom/misc_32.c
@@ -10,7 +10,9 @@
#include <linux/sched.h>
#include <linux/module.h>
+#include <asm/machines.h>
#include <asm/openprom.h>
+#include <asm/idprom.h>
#include <asm/oplib.h>
#include <asm/auxio.h>
#include <asm/system.h>
@@ -93,6 +95,42 @@ prom_setsync(sfunc_t funcp)
*romvec->pv_synchook = funcp;
}
+#ifdef CONFIG_SPARC_LEON
+/*
+ * leon do not have idprom support - so fake it.
+ * The machine type is hardcoded to M_LEON
+ * We do not know the ethernet address so it is all-zero.
+ */
+
+/* Calculate the IDPROM checksum (xor of the data bytes). */
+static unsigned char calc_idprom_cksum(struct idprom *idprom)
+{
+ unsigned char cksum, i, *ptr = (unsigned char *)idprom;
+
+ for (i = cksum = 0; i <= 0x0E; i++)
+ cksum ^= *ptr++;
+
+ return cksum;
+}
+
+unsigned char
+prom_get_idprom(char *idbuf, int num_bytes)
+{
+ struct idprom *idprom;
+
+ if (num_bytes < sizeof(struct idprom))
+ return 0xff;
+
+ idprom = (struct idprom *)idbuf;
+ memset(idprom, 0, sizeof(*idprom));
+ idprom->id_format = 0x01;
+ idprom->id_machtype = M_LEON | M_LEON3_SOC;
+ idprom->id_cksum = calc_idprom_cksum(idprom);
+
+ return 0x01;
+}
+
+#else
/* Get the idprom and stuff it into buffer 'idbuf'. Returns the
* format type. 'num_bytes' is the number of bytes that your idbuf
* has space for. Returns 0xff on error.
@@ -109,7 +147,7 @@ prom_get_idprom(char *idbuf, int num_bytes)
return 0xff;
}
-
+#endif
/* Get the major prom version number. */
int
prom_version(void)
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [RFC PATCH] sparc: fake idprom for leon
2011-01-02 19:40 [RFC PATCH] sparc: fake idprom for leon Sam Ravnborg
@ 2011-01-03 8:55 ` Kristoffer Glembo
2011-01-03 9:50 ` Sam Ravnborg
2011-01-03 10:36 ` Kristoffer Glembo
2 siblings, 0 replies; 4+ messages in thread
From: Kristoffer Glembo @ 2011-01-03 8:55 UTC (permalink / raw)
To: sparclinux
Hi Sam,
Thanks for the patch. However we are actually faking the idprom in the bootloader instead. So there is an idprom property.
We have released a new Linux "distribution" for LEON, see this message on the leon_sparc mailing list:
http://tech.groups.yahoo.com/group/leon_sparc/message/19138
It is a work in progress but it is probably of interest to you. It also includes new patches that has not yet been sent to this mailing list but will be soon.
How the get the MAC address is quite implementation dependent though. Our GRETH ethernet driver supports getting it from idprom, OF tree or as a module parameter.
Happy hacking,
Kristoffer
Sam Ravnborg wrote:
> Hi Kristoffer & David.
>
> Following is a very naive implementation of
> a fake idprom for leon.
>
> This is only for inspiration as I hope
> that it is possible to find the MAC address
> somehow so we present it correct.
>
> One advantage of using a fake idprom is that all places
> that do access idprom no longer needs to be ifdeffed out.
> Today floppy.h reads idprom unconditionally.
>
> Sam
>
> diff --git a/arch/sparc/prom/misc_32.c b/arch/sparc/prom/misc_32.c
> index 4d61c54..ee5fe45 100644
> --- a/arch/sparc/prom/misc_32.c
> +++ b/arch/sparc/prom/misc_32.c
> @@ -10,7 +10,9 @@
> #include <linux/sched.h>
> #include <linux/module.h>
>
> +#include <asm/machines.h>
> #include <asm/openprom.h>
> +#include <asm/idprom.h>
> #include <asm/oplib.h>
> #include <asm/auxio.h>
> #include <asm/system.h>
> @@ -93,6 +95,42 @@ prom_setsync(sfunc_t funcp)
> *romvec->pv_synchook = funcp;
> }
>
> +#ifdef CONFIG_SPARC_LEON
> +/*
> + * leon do not have idprom support - so fake it.
> + * The machine type is hardcoded to M_LEON
> + * We do not know the ethernet address so it is all-zero.
> + */
> +
> +/* Calculate the IDPROM checksum (xor of the data bytes). */
> +static unsigned char calc_idprom_cksum(struct idprom *idprom)
> +{
> + unsigned char cksum, i, *ptr = (unsigned char *)idprom;
> +
> + for (i = cksum = 0; i <= 0x0E; i++)
> + cksum ^= *ptr++;
> +
> + return cksum;
> +}
> +
> +unsigned char
> +prom_get_idprom(char *idbuf, int num_bytes)
> +{
> + struct idprom *idprom;
> +
> + if (num_bytes < sizeof(struct idprom))
> + return 0xff;
> +
> + idprom = (struct idprom *)idbuf;
> + memset(idprom, 0, sizeof(*idprom));
> + idprom->id_format = 0x01;
> + idprom->id_machtype = M_LEON | M_LEON3_SOC;
> + idprom->id_cksum = calc_idprom_cksum(idprom);
> +
> + return 0x01;
> +}
> +
> +#else
> /* Get the idprom and stuff it into buffer 'idbuf'. Returns the
> * format type. 'num_bytes' is the number of bytes that your idbuf
> * has space for. Returns 0xff on error.
> @@ -109,7 +147,7 @@ prom_get_idprom(char *idbuf, int num_bytes)
>
> return 0xff;
> }
> -
> +#endif
> /* Get the major prom version number. */
> int
> prom_version(void)
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [RFC PATCH] sparc: fake idprom for leon
2011-01-02 19:40 [RFC PATCH] sparc: fake idprom for leon Sam Ravnborg
2011-01-03 8:55 ` Kristoffer Glembo
@ 2011-01-03 9:50 ` Sam Ravnborg
2011-01-03 10:36 ` Kristoffer Glembo
2 siblings, 0 replies; 4+ messages in thread
From: Sam Ravnborg @ 2011-01-03 9:50 UTC (permalink / raw)
To: sparclinux
Hi Kristoffer!
On Mon, Jan 03, 2011 at 09:55:05AM +0100, Kristoffer Glembo wrote:
> Hi Sam,
>
> Thanks for the patch. However we are actually faking the idprom
> in the bootloader instead. So there is an idprom property.
Much better!
> We have released a new Linux "distribution" for LEON, see this message on the leon_sparc mailing list:
> http://tech.groups.yahoo.com/group/leon_sparc/message/19138
Great stuff. I missed that mail.
I am especially glad to see that you have announced buildroot support :-)
I hope this is the right way to go.
> It is a work in progress but it is probably of interest to you.
> It also includes new patches that has not yet been sent to this mailing list but will be soon.
I will take a look at the stuff I know about.
Do you prefer comments cc: to sparclinux or the leon list for the general kernel stuff?
I will not cross-post as the leon list is subscribers only (IIRC).
Sam
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] sparc: fake idprom for leon
2011-01-02 19:40 [RFC PATCH] sparc: fake idprom for leon Sam Ravnborg
2011-01-03 8:55 ` Kristoffer Glembo
2011-01-03 9:50 ` Sam Ravnborg
@ 2011-01-03 10:36 ` Kristoffer Glembo
2 siblings, 0 replies; 4+ messages in thread
From: Kristoffer Glembo @ 2011-01-03 10:36 UTC (permalink / raw)
To: sparclinux
Hi,
>
>> It is a work in progress but it is probably of interest to you.
>> It also includes new patches that has not yet been sent to this mailing list but will be soon.
> I will take a look at the stuff I know about.
>
> Do you prefer comments cc: to sparclinux or the leon list for the general kernel stuff?
> I will not cross-post as the leon list is subscribers only (IIRC).
>
For general kernel stuff use this list. Please send feedback on all non-kernel stuff to leon_sparc!
Happy new year by the way! (to all you sparclinux readers)
Best regards,
Kristoffer
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-01-03 10:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-02 19:40 [RFC PATCH] sparc: fake idprom for leon Sam Ravnborg
2011-01-03 8:55 ` Kristoffer Glembo
2011-01-03 9:50 ` Sam Ravnborg
2011-01-03 10:36 ` Kristoffer Glembo
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.