From: Gregory CLEMENT <gregory.clement@free-electrons.com>
To: Chris Packham <chris.packham@alliedtelesis.co.nz>
Cc: linux-arm-kernel@lists.infradead.org,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Jason Cooper <jason@lakedaemon.net>, Andrew Lunn <andrew@lunn.ch>,
Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
Russell King <linux@armlinux.org.uk>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 4/6] ARM: mvebu: Add mv98dx3236-soc-id
Date: Wed, 15 Feb 2017 15:52:47 +0100 [thread overview]
Message-ID: <87vasbcxq8.fsf@free-electrons.com> (raw)
In-Reply-To: <20170207202815.20226-5-chris.packham@alliedtelesis.co.nz> (Chris Packham's message of "Wed, 8 Feb 2017 09:28:13 +1300")
Hi Chris,
On mar., févr. 07 2017, Chris Packham <chris.packham@alliedtelesis.co.nz> wrote:
> The DFX server on the 98dx3236 and compatible SoCs has an ID register
> that provides revision information that the PCI based ID register
> doesn't have. Use this if it's available.
>
Could you split this patch in two part: one for device tree and one for
the C code?
Thanks,
Gregory
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
>
> Notes:
> Changes in v2:
> - none
>
> .../bindings/arm/marvell/mv98dx3236-soc-id.txt | 14 +++++++
> arch/arm/boot/dts/armada-xp-98dx3236.dtsi | 5 +++
> arch/arm/mach-mvebu/mvebu-soc-id.c | 43 ++++++++++++++++++++--
> 3 files changed, 59 insertions(+), 3 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/arm/marvell/mv98dx3236-soc-id.txt
>
> diff --git a/Documentation/devicetree/bindings/arm/marvell/mv98dx3236-soc-id.txt b/Documentation/devicetree/bindings/arm/marvell/mv98dx3236-soc-id.txt
> new file mode 100644
> index 000000000000..ed08cb126a83
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/arm/marvell/mv98dx3236-soc-id.txt
> @@ -0,0 +1,14 @@
> +Marvell 98dx3236 SoC ID
> +---------------------------------------------------------------
> +
> +Required properties:
> +
> +- compatible: Should be "marvell,mv98dx3236-soc-id".
> +
> +- reg: should be the register base and length as documented in the
> + datasheet for the Device ID Status
> +
> +soc-id@f8244 {
> + compatible = "marvell,mv98dx3236-soc-id";
> + reg = <0xf8244 0x4>;
> +};
> diff --git a/arch/arm/boot/dts/armada-xp-98dx3236.dtsi b/arch/arm/boot/dts/armada-xp-98dx3236.dtsi
> index cbf5cd0c6429..e4baa97836e7 100644
> --- a/arch/arm/boot/dts/armada-xp-98dx3236.dtsi
> +++ b/arch/arm/boot/dts/armada-xp-98dx3236.dtsi
> @@ -264,6 +264,11 @@
> ranges = <0 MBUS_ID(0x08, 0x00) 0 0x100000>;
> reg = <MBUS_ID(0x08, 0x00) 0 0x100000>;
>
> + soc-id@f8244 {
> + compatible = "marvell,mv98dx3236-soc-id";
> + reg = <0xf8244 0x4>;
> + };
> +
> dfx_coredivclk: corediv-clock@f8268 {
> compatible = "marvell,mv98dx3236-corediv-clock";
> reg = <0xf8268 0xc>;
> diff --git a/arch/arm/mach-mvebu/mvebu-soc-id.c b/arch/arm/mach-mvebu/mvebu-soc-id.c
> index a99434bcee84..b4c94a57f358 100644
> --- a/arch/arm/mach-mvebu/mvebu-soc-id.c
> +++ b/arch/arm/mach-mvebu/mvebu-soc-id.c
> @@ -34,6 +34,9 @@
> #define SOC_ID_MASK 0xFFFF0000
> #define SOC_REV_MASK 0xFF
>
> +#define MV98DX3236_DEV_ID_MASK 0xFF00
> +#define MV98DX3236_REV_MASK 0xF
> +
> static u32 soc_dev_id;
> static u32 soc_rev;
> static bool is_id_valid;
> @@ -45,6 +48,11 @@ static const struct of_device_id mvebu_pcie_of_match_table[] = {
> {},
> };
>
> +static const struct of_device_id mvebu_mv98dx3236_of_match_table[] = {
> + { .compatible = "marvell,mv98dx3236-soc-id", },
> + {},
> +};
> +
> int mvebu_get_soc_id(u32 *dev, u32 *rev)
> {
> if (is_id_valid) {
> @@ -131,15 +139,44 @@ static int __init get_soc_id_by_pci(void)
> return ret;
> }
>
> +static int __init mvebu_dfx_get_soc_id(u32 *dev, u32 *rev)
> +{
> + struct device_node *np;
> + void __iomem *base;
> +
> + np = of_find_matching_node(NULL, mvebu_mv98dx3236_of_match_table);
> + if (!np)
> + return -ENODEV;
> +
> + base = of_iomap(np, 0);
> + if (IS_ERR(base))
> + return PTR_ERR(base);
> +
> + /* SoC ID */
> + *dev = (readl(base) >> 12) & MV98DX3236_DEV_ID_MASK;
> + /* SoC revision */
> + *rev = (readl(base) >> 28) & MV98DX3236_REV_MASK;
> +
> + iounmap(base);
> + of_node_put(np);
> +
> + return 0;
> +}
> +
> static int __init mvebu_soc_id_init(void)
> {
>
> /*
> - * First try to get the ID and the revision by the system
> - * register and use PCI registers only if it is not possible
> + * First try to get the ID and the revision by from system controller
> + * register, then try the DFX register (if applicable), finally read it
> + * from PCI registers.
> */
> - if (!mvebu_system_controller_get_soc_id(&soc_dev_id, &soc_rev)) {
> + if (!mvebu_system_controller_get_soc_id(&soc_dev_id, &soc_rev))
> + is_id_valid = true;
> + else if (!mvebu_dfx_get_soc_id(&soc_dev_id, &soc_rev))
> is_id_valid = true;
> +
> + if (is_id_valid) {
> pr_info("MVEBU SoC ID=0x%X, Rev=0x%X\n", soc_dev_id, soc_rev);
> return 0;
> }
> --
> 2.11.0.24.ge6920cf
>
--
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
next prev parent reply other threads:[~2017-02-15 14:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-07 20:28 [PATCH v2 0/6] Updates for Marvell Switch SoCs Chris Packham
2017-02-07 20:28 ` [PATCH v2 1/6] ARM: dts: Fix typo in armada-xp-98dx4251 Chris Packham
2017-02-15 14:35 ` Gregory CLEMENT
2017-02-07 20:28 ` [PATCH v2 2/6] ARM: dts: armada-xp-98dx3236: combine dfx server nodes Chris Packham
2017-02-15 22:40 ` Rob Herring
2017-02-07 20:28 ` [PATCH v2 3/6] ARM: dts: Use armada-370-xp as a base for armada-xp-98dx3236 Chris Packham
2017-02-07 20:28 ` [PATCH v2 4/6] ARM: mvebu: Add mv98dx3236-soc-id Chris Packham
2017-02-15 14:52 ` Gregory CLEMENT [this message]
2017-02-07 20:28 ` [PATCH v2 5/6] ARM: dts: mvebu: Move mv98dx3236 clock bindings Chris Packham
2017-02-15 22:47 ` Rob Herring
2017-02-07 20:28 ` [PATCH v2 6/6] clk: mvebu: Expand mv98dx3236-core-clock support Chris Packham
2017-02-10 23:27 ` Stephen Boyd
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=87vasbcxq8.fsf@free-electrons.com \
--to=gregory.clement@free-electrons.com \
--cc=andrew@lunn.ch \
--cc=chris.packham@alliedtelesis.co.nz \
--cc=devicetree@vger.kernel.org \
--cc=jason@lakedaemon.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mark.rutland@arm.com \
--cc=robh+dt@kernel.org \
--cc=sebastian.hesselbarth@gmail.com \
/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