All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4 V2] powerpc/85xx: Add support for 85xx cpu type detection
@ 2013-07-10  7:39 ` Haijun Zhang
  0 siblings, 0 replies; 10+ messages in thread
From: Haijun Zhang @ 2013-07-10  7:39 UTC (permalink / raw)
  To: linux-mmc, linuxppc-dev
  Cc: Zhao Chenhui, r39252, AFLEMING, Haijun Zhang, cbouatmailru,
	scottwood, cjb, X.Xie

Add this file to help detect cpu type in runtime.
These macros will be more favorable for driver
to apply errata and workaround to specified cpu type.

Signed-off-by: Haijun Zhang <Haijun.Zhang@freescale.com>
Signed-off-by: Zhao Chenhui <chenhui.zhao@freescale.com>
---
changes v2:
	- Remove inline function
	- Ignore E bit of SOC
	- Add Macro to get current soc version

 arch/powerpc/include/asm/mpc85xx.h | 53 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 arch/powerpc/include/asm/mpc85xx.h

diff --git a/arch/powerpc/include/asm/mpc85xx.h b/arch/powerpc/include/asm/mpc85xx.h
new file mode 100644
index 0000000..20af5e8
--- /dev/null
+++ b/arch/powerpc/include/asm/mpc85xx.h
@@ -0,0 +1,53 @@
+/*
+ * MPC85xx cpu type detection
+ *
+ * Copyright 2011-2012 Freescale Semiconductor, Inc.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __ASM_PPC_MPC85XX_H
+#define __ASM_PPC_MPC85XX_H
+
+#define SVR_REV(svr)	((svr) & 0xFF)		/* SOC design resision */
+#define SVR_MAJ(svr)	(((svr) >>  4) & 0xF)	/* Major revision field*/
+#define SVR_MIN(svr)	(((svr) >>  0) & 0xF)	/* Minor revision field*/
+
+/* Some parts define SVR[0:23] as the SOC version */
+#define SVR_SOC_VER(svr) (((svr) >> 8) & 0xFFF7FF)	/* SOC Version fields */
+
+/* Get current SOC Version */
+#define GET_SVR()	(mfspr(SPRN_SVR))
+
+#define IS_SVR_REV(svr, maj, min) \
+	((SVR_MAJ(svr) == (maj)) && (SVR_MIN(svr) == (min)))
+
+#define SVR_8533	0x803400
+#define SVR_8535	0x803701
+#define SVR_8536	0x803700
+#define SVR_8540	0x803000
+#define SVR_8541	0x807200
+#define SVR_8543	0x803200
+#define SVR_8544	0x803401
+#define SVR_8545	0x803102
+#define SVR_8547	0x803101
+#define SVR_8548	0x803100
+#define SVR_8555	0x807100
+#define SVR_8560	0x807000
+#define SVR_8567	0x807501
+#define SVR_8568	0x807500
+#define SVR_8569	0x808000
+#define SVR_8572	0x80E000
+#define SVR_P1010	0x80f900
+#define SVR_P2041	0x821001
+#define SVR_P3041	0x821103
+#define SVR_P5010	0x822100
+#define SVR_P5020	0x822000
+#define SVR_P5040	0x820400
+#define SVR_T4240	0x824800
+#define SVR_B4860	0x868800
+
+#endif
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 1/4 V2] powerpc/85xx: Add support for 85xx cpu type detection
@ 2013-07-10  7:39 ` Haijun Zhang
  0 siblings, 0 replies; 10+ messages in thread
From: Haijun Zhang @ 2013-07-10  7:39 UTC (permalink / raw)
  To: linux-mmc, linuxppc-dev
  Cc: Zhao Chenhui, r39252, AFLEMING, Haijun Zhang, cbouatmailru,
	scottwood, cjb, X.Xie

Add this file to help detect cpu type in runtime.
These macros will be more favorable for driver
to apply errata and workaround to specified cpu type.

Signed-off-by: Haijun Zhang <Haijun.Zhang@freescale.com>
Signed-off-by: Zhao Chenhui <chenhui.zhao@freescale.com>
---
changes v2:
	- Remove inline function
	- Ignore E bit of SOC
	- Add Macro to get current soc version

 arch/powerpc/include/asm/mpc85xx.h | 53 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 arch/powerpc/include/asm/mpc85xx.h

diff --git a/arch/powerpc/include/asm/mpc85xx.h b/arch/powerpc/include/asm/mpc85xx.h
new file mode 100644
index 0000000..20af5e8
--- /dev/null
+++ b/arch/powerpc/include/asm/mpc85xx.h
@@ -0,0 +1,53 @@
+/*
+ * MPC85xx cpu type detection
+ *
+ * Copyright 2011-2012 Freescale Semiconductor, Inc.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __ASM_PPC_MPC85XX_H
+#define __ASM_PPC_MPC85XX_H
+
+#define SVR_REV(svr)	((svr) & 0xFF)		/* SOC design resision */
+#define SVR_MAJ(svr)	(((svr) >>  4) & 0xF)	/* Major revision field*/
+#define SVR_MIN(svr)	(((svr) >>  0) & 0xF)	/* Minor revision field*/
+
+/* Some parts define SVR[0:23] as the SOC version */
+#define SVR_SOC_VER(svr) (((svr) >> 8) & 0xFFF7FF)	/* SOC Version fields */
+
+/* Get current SOC Version */
+#define GET_SVR()	(mfspr(SPRN_SVR))
+
+#define IS_SVR_REV(svr, maj, min) \
+	((SVR_MAJ(svr) == (maj)) && (SVR_MIN(svr) == (min)))
+
+#define SVR_8533	0x803400
+#define SVR_8535	0x803701
+#define SVR_8536	0x803700
+#define SVR_8540	0x803000
+#define SVR_8541	0x807200
+#define SVR_8543	0x803200
+#define SVR_8544	0x803401
+#define SVR_8545	0x803102
+#define SVR_8547	0x803101
+#define SVR_8548	0x803100
+#define SVR_8555	0x807100
+#define SVR_8560	0x807000
+#define SVR_8567	0x807501
+#define SVR_8568	0x807500
+#define SVR_8569	0x808000
+#define SVR_8572	0x80E000
+#define SVR_P1010	0x80f900
+#define SVR_P2041	0x821001
+#define SVR_P3041	0x821103
+#define SVR_P5010	0x822100
+#define SVR_P5020	0x822000
+#define SVR_P5040	0x820400
+#define SVR_T4240	0x824800
+#define SVR_B4860	0x868800
+
+#endif
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/4 V2] powerpc/85xx: Add support for 85xx cpu type detection
  2013-07-10  7:39 ` Haijun Zhang
@ 2013-07-10 21:48   ` Scott Wood
  -1 siblings, 0 replies; 10+ messages in thread
From: Scott Wood @ 2013-07-10 21:48 UTC (permalink / raw)
  Cc: linux-mmc, linuxppc-dev, cbouatmailru, cjb, AFLEMING, r39252,
	X.Xie, Haijun Zhang, Zhao Chenhui

On 07/10/2013 02:39:01 AM, Haijun Zhang wrote:
> +/* Get current SOC Version */
> +#define GET_SVR()	(mfspr(SPRN_SVR))

Unnecessary parens.  Why do we need GET_SVR(), versus opencoding it?   
Note that U-Boot (which this is patterned after) doesn't have  
GET_SVR(), so code that wants to work on both can't use it anyway.

> +#define IS_SVR_REV(svr, maj, min) \
> +	((SVR_MAJ(svr) == (maj)) && (SVR_MIN(svr) == (min)))

I don't think IS_SVR_REV is needed.  Callers can just do "if  
(SVR_REV(svr) == 0x30)" or whatever, especially since we're relying on  
them to do this for greater/less than comparisons.

-Scott

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/4 V2] powerpc/85xx: Add support for 85xx cpu type detection
@ 2013-07-10 21:48   ` Scott Wood
  0 siblings, 0 replies; 10+ messages in thread
From: Scott Wood @ 2013-07-10 21:48 UTC (permalink / raw)
  To: Haijun Zhang
  Cc: Zhao Chenhui, linux-mmc, r39252, AFLEMING, Haijun Zhang,
	cbouatmailru, cjb, linuxppc-dev, X.Xie

On 07/10/2013 02:39:01 AM, Haijun Zhang wrote:
> +/* Get current SOC Version */
> +#define GET_SVR()	(mfspr(SPRN_SVR))

Unnecessary parens.  Why do we need GET_SVR(), versus opencoding it?  =20
Note that U-Boot (which this is patterned after) doesn't have =20
GET_SVR(), so code that wants to work on both can't use it anyway.

> +#define IS_SVR_REV(svr, maj, min) \
> +	((SVR_MAJ(svr) =3D=3D (maj)) && (SVR_MIN(svr) =3D=3D (min)))

I don't think IS_SVR_REV is needed.  Callers can just do "if =20
(SVR_REV(svr) =3D=3D 0x30)" or whatever, especially since we're relying on =
=20
them to do this for greater/less than comparisons.

-Scott=

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [PATCH 1/4 V2] powerpc/85xx: Add support for 85xx cpu type detection
  2013-07-10 21:48   ` Scott Wood
@ 2013-07-11  8:43     ` David Laight
  -1 siblings, 0 replies; 10+ messages in thread
From: David Laight @ 2013-07-11  8:43 UTC (permalink / raw)
  To: Scott Wood
  Cc: Zhao Chenhui, linux-mmc, r39252, AFLEMING, Haijun Zhang,
	cbouatmailru, cjb, linuxppc-dev, X.Xie

> > +#define IS_SVR_REV(svr, maj, min) \
> > +	((SVR_MAJ(svr) == (maj)) && (SVR_MIN(svr) == (min)))
> 
> I don't think IS_SVR_REV is needed.  Callers can just do "if
> (SVR_REV(svr) == 0x30)" or whatever, especially since we're relying on
> them to do this for greater/less than comparisons.

Not only that, I'd guess that 'maj' and 'min' are likely to be
constants - so you'd want to combine them and compare against 'svr'
rather than have two conditionals.

	David




^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [PATCH 1/4 V2] powerpc/85xx: Add support for 85xx cpu type detection
@ 2013-07-11  8:43     ` David Laight
  0 siblings, 0 replies; 10+ messages in thread
From: David Laight @ 2013-07-11  8:43 UTC (permalink / raw)
  To: Scott Wood, Haijun Zhang
  Cc: Zhao Chenhui, linux-mmc, r39252, AFLEMING, X.Xie, cbouatmailru,
	cjb, linuxppc-dev, Haijun Zhang

> > +#define IS_SVR_REV(svr, maj, min) \
> > +	((SVR_MAJ(svr) =3D=3D (maj)) && (SVR_MIN(svr) =3D=3D (min)))
>=20
> I don't think IS_SVR_REV is needed.  Callers can just do "if
> (SVR_REV(svr) =3D=3D 0x30)" or whatever, especially since we're =
relying on
> them to do this for greater/less than comparisons.

Not only that, I'd guess that 'maj' and 'min' are likely to be
constants - so you'd want to combine them and compare against 'svr'
rather than have two conditionals.

	David

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [PATCH 1/4 V2] powerpc/85xx: Add support for 85xx cpu type detection
  2013-07-11  8:43     ` David Laight
@ 2013-07-11  9:02       ` Zhang Haijun-B42677
  -1 siblings, 0 replies; 10+ messages in thread
From: Zhang Haijun-B42677 @ 2013-07-11  9:02 UTC (permalink / raw)
  To: David Laight, Wood Scott-B07421
  Cc: Zhao Chenhui-B35336, linux-mmc, Wrobel Heinz-R39252,
	Fleming Andy-AFLEMING, cbouatmailru, cjb, linuxppc-dev,
	Xie Xiaobo-R63061



Thanks.

Regards
Haijun.


> -----Original Message-----
> From: David Laight [mailto:David.Laight@ACULAB.COM]
> Sent: Thursday, July 11, 2013 4:44 PM
> To: Wood Scott-B07421; Zhang Haijun-B42677
> Cc: Zhao Chenhui-B35336; linux-mmc@vger.kernel.org; Wrobel Heinz-R39252;
> Fleming Andy-AFLEMING; Zhang Haijun-B42677; cbouatmailru@gmail.com;
> cjb@laptop.org; linuxppc-dev@lists.ozlabs.org; Xie Xiaobo-R63061
> Subject: RE: [PATCH 1/4 V2] powerpc/85xx: Add support for 85xx cpu type
> detection
> 
> > > +#define IS_SVR_REV(svr, maj, min) \
> > > +	((SVR_MAJ(svr) == (maj)) && (SVR_MIN(svr) == (min)))
> >
> > I don't think IS_SVR_REV is needed.  Callers can just do "if
> > (SVR_REV(svr) == 0x30)" or whatever, especially since we're relying on
> > them to do this for greater/less than comparisons.
> 
> Not only that, I'd guess that 'maj' and 'min' are likely to be constants
> - so you'd want to combine them and compare against 'svr'
> rather than have two conditionals.
[Haijun Wrote:] yes, e.g: 1.0, 1.1 or 2.0. 'Major revision field' + '.' + 'Minor revision field '
I had resent the patch(V2). I'm not so clear about what you want to express.^_^  
> 
> 	David
> 
> 
> 



^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [PATCH 1/4 V2] powerpc/85xx: Add support for 85xx cpu type detection
@ 2013-07-11  9:02       ` Zhang Haijun-B42677
  0 siblings, 0 replies; 10+ messages in thread
From: Zhang Haijun-B42677 @ 2013-07-11  9:02 UTC (permalink / raw)
  To: David Laight, Wood Scott-B07421
  Cc: Xie Xiaobo-R63061, Zhao Chenhui-B35336, linux-mmc,
	Wrobel Heinz-R39252, Fleming Andy-AFLEMING, cbouatmailru, cjb,
	linuxppc-dev



Thanks.

Regards
Haijun.


> -----Original Message-----
> From: David Laight [mailto:David.Laight@ACULAB.COM]
> Sent: Thursday, July 11, 2013 4:44 PM
> To: Wood Scott-B07421; Zhang Haijun-B42677
> Cc: Zhao Chenhui-B35336; linux-mmc@vger.kernel.org; Wrobel Heinz-R39252;
> Fleming Andy-AFLEMING; Zhang Haijun-B42677; cbouatmailru@gmail.com;
> cjb@laptop.org; linuxppc-dev@lists.ozlabs.org; Xie Xiaobo-R63061
> Subject: RE: [PATCH 1/4 V2] powerpc/85xx: Add support for 85xx cpu type
> detection
>=20
> > > +#define IS_SVR_REV(svr, maj, min) \
> > > +	((SVR_MAJ(svr) =3D=3D (maj)) && (SVR_MIN(svr) =3D=3D (min)))
> >
> > I don't think IS_SVR_REV is needed.  Callers can just do "if
> > (SVR_REV(svr) =3D=3D 0x30)" or whatever, especially since we're relying=
 on
> > them to do this for greater/less than comparisons.
>=20
> Not only that, I'd guess that 'maj' and 'min' are likely to be constants
> - so you'd want to combine them and compare against 'svr'
> rather than have two conditionals.
[Haijun Wrote:] yes, e.g: 1.0, 1.1 or 2.0. 'Major revision field' + '.' + '=
Minor revision field '
I had resent the patch(V2). I'm not so clear about what you want to express=
.^_^ =20
>=20
> 	David
>=20
>=20
>=20

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/4 V2] powerpc/85xx: Add support for 85xx cpu type detection
  2013-07-11  8:43     ` David Laight
@ 2013-07-11 14:15       ` Scott Wood
  -1 siblings, 0 replies; 10+ messages in thread
From: Scott Wood @ 2013-07-11 14:15 UTC (permalink / raw)
  To: David Laight; +Cc: Haijun Zhang, Zhao Chenhui, linux-mmc, r39252, AFLEMING

On 07/11/2013 03:43:35 AM, David Laight wrote:
> > > +#define IS_SVR_REV(svr, maj, min) \
> > > +	((SVR_MAJ(svr) == (maj)) && (SVR_MIN(svr) == (min)))
> >
> > I don't think IS_SVR_REV is needed.  Callers can just do "if
> > (SVR_REV(svr) == 0x30)" or whatever, especially since we're relying  
> on
> > them to do this for greater/less than comparisons.
> 
> Not only that, I'd guess that 'maj' and 'min' are likely to be
> constants - so you'd want to combine them and compare against 'svr'
> rather than have two conditionals.

Yes, that's what I meant -- 0x30 would represent revision 3.0.

-Scott

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/4 V2] powerpc/85xx: Add support for 85xx cpu type detection
@ 2013-07-11 14:15       ` Scott Wood
  0 siblings, 0 replies; 10+ messages in thread
From: Scott Wood @ 2013-07-11 14:15 UTC (permalink / raw)
  To: David Laight
  Cc: Zhao Chenhui, linux-mmc, r39252, AFLEMING, X.Xie, cbouatmailru,
	cjb, linuxppc-dev, Haijun Zhang

On 07/11/2013 03:43:35 AM, David Laight wrote:
> > > +#define IS_SVR_REV(svr, maj, min) \
> > > +	((SVR_MAJ(svr) =3D=3D (maj)) && (SVR_MIN(svr) =3D=3D (min)))
> >
> > I don't think IS_SVR_REV is needed.  Callers can just do "if
> > (SVR_REV(svr) =3D=3D 0x30)" or whatever, especially since we're relying=
 =20
> on
> > them to do this for greater/less than comparisons.
>=20
> Not only that, I'd guess that 'maj' and 'min' are likely to be
> constants - so you'd want to combine them and compare against 'svr'
> rather than have two conditionals.

Yes, that's what I meant -- 0x30 would represent revision 3.0.

-Scott=

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-07-11 14:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-10  7:39 [PATCH 1/4 V2] powerpc/85xx: Add support for 85xx cpu type detection Haijun Zhang
2013-07-10  7:39 ` Haijun Zhang
2013-07-10 21:48 ` Scott Wood
2013-07-10 21:48   ` Scott Wood
2013-07-11  8:43   ` David Laight
2013-07-11  8:43     ` David Laight
2013-07-11  9:02     ` Zhang Haijun-B42677
2013-07-11  9:02       ` Zhang Haijun-B42677
2013-07-11 14:15     ` Scott Wood
2013-07-11 14:15       ` Scott Wood

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.