From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762326AbbA3OOT (ORCPT ); Fri, 30 Jan 2015 09:14:19 -0500 Received: from mail-we0-f173.google.com ([74.125.82.173]:37927 "EHLO mail-we0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752426AbbA3OOS (ORCPT ); Fri, 30 Jan 2015 09:14:18 -0500 From: Pali =?utf-8?q?Roh=C3=A1r?= To: Rob Herring Subject: Re: [PATCH] ARM: /proc/cpuinfo: DT: Add support for Revision Date: Fri, 30 Jan 2015 15:14:14 +0100 User-Agent: KMail/1.13.7 (Linux/3.13.0-44-generic; KDE/4.14.2; x86_64; ; ) Cc: Russell King , Will Deacon , Ivaylo Dimitrov , Sebastian Reichel , Pavel Machek , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , Tony Lindgren References: <1403110464-29646-1-git-send-email-pali.rohar@gmail.com> <201501262009.45854@pali> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart11478412.EAUJvpqYHK"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201501301514.14884@pali> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --nextPart11478412.EAUJvpqYHK Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Monday 26 January 2015 21:22:27 Rob Herring wrote: > On Mon, Jan 26, 2015 at 1:09 PM, Pali Roh=C3=A1r=20 wrote: > > Ok, here is patch which set Revision field (global variable > > system_rev) in /proc/cpuinfo from DT revision property: > >=20 > > diff --git a/arch/arm/kernel/devtree.c > > b/arch/arm/kernel/devtree.c index 11c54de..9946c1b 100644 > > --- a/arch/arm/kernel/devtree.c > > +++ b/arch/arm/kernel/devtree.c > > @@ -19,6 +19,7 @@ > >=20 > > #include > > #include > > #include > >=20 > > +#include > >=20 > > #include > > #include > >=20 > > @@ -26,6 +27,7 @@ > >=20 > > #include > > #include > > #include > >=20 > > +#include > >=20 > > #ifdef CONFIG_SMP > >=20 > > @@ -204,6 +206,8 @@ static const void * __init > > arch_get_next_mach(const char *const **match) > >=20 > > const struct machine_desc * __init > > setup_machine_fdt(unsigned int dt_phys) { > > =20 > > const struct machine_desc *mdesc, *mdesc_best =3D > > NULL; > >=20 > > + unsigned long dt_root; > > + const u32 *prop; > >=20 > > #ifdef CONFIG_ARCH_MULTIPLATFORM > > =20 > > DT_MACHINE_START(GENERIC_DT, "Generic DT based > > system") > >=20 > > @@ -215,17 +219,16 @@ const struct machine_desc * __init > > setup_machine_fdt(unsigned int dt_phys) > >=20 > > if (!dt_phys || > > !early_init_dt_verify(phys_to_virt(dt_phys))) > > =20 > > return NULL; > >=20 > > + dt_root =3D of_get_flat_dt_root(); > >=20 > > mdesc =3D of_flat_dt_match_machine(mdesc_best, > > arch_get_next_mach); > > =20 > > if (!mdesc) { > > =20 > > const char *prop; > > int size; > >=20 > > - unsigned long dt_root; > >=20 > > early_print("\nError: > > unrecognized/unsupported " > > =20 > > "device tree compatible list:\n[ > > "); > >=20 > > - dt_root =3D of_get_flat_dt_root(); > >=20 > > prop =3D of_get_flat_dt_prop(dt_root, > > "compatible", &size); while (size > 0) { > > =20 > > early_print("'%s' ", prop); > >=20 > > @@ -246,5 +249,10 @@ const struct machine_desc * __init > > setup_machine_fdt(unsigned int dt_phys) > >=20 > > /* Change machine number to match the mdesc we're > > using */ __machine_arch_type =3D mdesc->nr; > >=20 > > + /* Set system revision from DT */ > > + prop =3D of_get_flat_dt_prop(dt_root, "revision", > > NULL); + if (prop) > > + system_rev =3D fdt32_to_cpu(*prop); > > + > >=20 > > return mdesc; > > =20 > > } > >=20 > > And here is patch which convert ATAG revision into DT > > revision property and append it into DT in decompress code: > >=20 > > diff --git a/arch/arm/boot/compressed/atags_to_fdt.c > > b/arch/arm/boot/compressed/atags_to_fdt.c index > > 9448aa0..e7e1cc9 100644 > > --- a/arch/arm/boot/compressed/atags_to_fdt.c > > +++ b/arch/arm/boot/compressed/atags_to_fdt.c > > @@ -171,6 +171,8 @@ int atags_to_fdt(void *atag_list, void > > *fdt, int total_space) > >=20 > > cpu_to_fdt32(atag->u > > .mem.size); > > =20 > > } > >=20 > > + } else if (atag->hdr.tag =3D=3D ATAG_REVISION) { > > + setprop_cell(fdt, "/", "revision", > > atag->u.revision.rev); > >=20 > > } else if (atag->hdr.tag =3D=3D ATAG_INITRD2) { > > =20 > > uint32_t initrd_start, initrd_size; > > initrd_start =3D atag->u.initrd.start; > >=20 > > I tested it on DT booted Nokia N900 and it is working, in > > /proc/cpuinfo is revision from ATAG. > >=20 > > I do not know which DT property to use for storing HW > > Revision, so if "/revision" is not correct one, let me know > > what to use instead. Also you can add my Signed-off-by for > > both patches. >=20 > It is the correct property, but /revision in DT is a string. >=20 > You need to add your own sign-off. >=20 > Rob Any documentation which says that /revision is string? If it is really string, how to store ATAG_REVISON (number) to=20 string? dec or hex? =2D-=20 Pali Roh=C3=A1r pali.rohar@gmail.com --nextPart11478412.EAUJvpqYHK Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEABECAAYFAlTLkbYACgkQi/DJPQPkQ1JllACeKjf147kotuc8AhXpmh24wg5H IQEAnjFcIaA8B1y3wRyZzAfkd/Vay/x/ =GxRw -----END PGP SIGNATURE----- --nextPart11478412.EAUJvpqYHK--