diff mbox

[v3,4/6] arm: add basic support for Mediatek MT6589 boards

Message ID 1399938570-11356-5-git-send-email-matthias.bgg@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Matthias Brugger May 12, 2014, 11:49 p.m. UTC
This adds a generic devicetree board file and a dtsi for boards
based on MT6589 SoCs from Mediatek.

Apart from the generic parts (gic, clocks) the only component
currently supported are the timers.

Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
---
 arch/arm/Kconfig                  |  2 +
 arch/arm/Makefile                 |  1 +
 arch/arm/boot/dts/mt6589.dtsi     | 93 +++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-mediatek/Kconfig    |  6 +++
 arch/arm/mach-mediatek/Makefile   |  1 +
 arch/arm/mach-mediatek/mediatek.c | 32 ++++++++++++++
 6 files changed, 135 insertions(+)
 create mode 100644 arch/arm/boot/dts/mt6589.dtsi
 create mode 100644 arch/arm/mach-mediatek/Kconfig
 create mode 100644 arch/arm/mach-mediatek/Makefile
 create mode 100644 arch/arm/mach-mediatek/mediatek.c

Comments

Stephen Boyd May 13, 2014, 10:47 p.m. UTC | #1
On 05/13, Matthias Brugger wrote:
> diff --git a/arch/arm/mach-mediatek/mediatek.c b/arch/arm/mach-mediatek/mediatek.c
> new file mode 100644
> index 0000000..73dfb05
> --- /dev/null
> +++ b/arch/arm/mach-mediatek/mediatek.c
> @@ -0,0 +1,32 @@
> +/*
> + * Device Tree support for Mediatek SoCs
> + *
> + * Copyright (c) 2014 MundoReader S.L.
> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
> + *
> + * This program 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.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/init.h>
> +#include <linux/of_platform.h>
> +#include <linux/irqchip.h>
> +#include <asm/mach/arch.h>
> +#include <asm/mach/map.h>
> +
> +static const char * const mediatek_board_dt_compat[] = {

__initconst?

> +	"mediatek,mt6589",
> +	NULL,
> +};
> +
> +DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
> +	.dt_compat	= mediatek_board_dt_compat,
> +MACHINE_END

You shouldn't need this file at all if the platform is part of
the multi-platform kernel.
Maxime Ripard May 14, 2014, 7 a.m. UTC | #2
Hi Stephen,

On Tue, May 13, 2014 at 03:47:32PM -0700, Stephen Boyd wrote:
> On 05/13, Matthias Brugger wrote:
> > diff --git a/arch/arm/mach-mediatek/mediatek.c b/arch/arm/mach-mediatek/mediatek.c
> > new file mode 100644
> > index 0000000..73dfb05
> > --- /dev/null
> > +++ b/arch/arm/mach-mediatek/mediatek.c
> > @@ -0,0 +1,32 @@
> > +/*
> > + * Device Tree support for Mediatek SoCs
> > + *
> > + * Copyright (c) 2014 MundoReader S.L.
> > + * Author: Matthias Brugger <matthias.bgg@gmail.com>
> > + *
> > + * This program 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.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#include <linux/kernel.h>
> > +#include <linux/init.h>
> > +#include <linux/of_platform.h>
> > +#include <linux/irqchip.h>
> > +#include <asm/mach/arch.h>
> > +#include <asm/mach/map.h>
> > +
> > +static const char * const mediatek_board_dt_compat[] = {
> 
> __initconst?
> 
> > +	"mediatek,mt6589",
> > +	NULL,
> > +};
> > +
> > +DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
> > +	.dt_compat	= mediatek_board_dt_compat,
> > +MACHINE_END
> 
> You shouldn't need this file at all if the platform is part of
> the multi-platform kernel.

From a technical point of view, you don't. But it's interesting to
keep it mostly for two things:
  - You get to see the platform name in /proc/cpuinfo
  - If you ever need to add platform quirks, it's already there

We had a similar discussion two weeks ago for mach-sunxi with Olof and
Arnd, and ended up keeping this minimal machine.

Maxime
Stephen Boyd May 14, 2014, 9:26 p.m. UTC | #3
On 05/14, Maxime Ripard wrote:
> On Tue, May 13, 2014 at 03:47:32PM -0700, Stephen Boyd wrote:
> > On 05/13, Matthias Brugger wrote:
> > > +	"mediatek,mt6589",
> > > +	NULL,
> > > +};
> > > +
> > > +DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
> > > +	.dt_compat	= mediatek_board_dt_compat,
> > > +MACHINE_END
> > 
> > You shouldn't need this file at all if the platform is part of
> > the multi-platform kernel.
> 
> From a technical point of view, you don't. But it's interesting to
> keep it mostly for two things:
>   - You get to see the platform name in /proc/cpuinfo
>   - If you ever need to add platform quirks, it's already there
> 
> We had a similar discussion two weeks ago for mach-sunxi with Olof and
> Arnd, and ended up keeping this minimal machine.
> 

It looks like it's only useful to make /proc/cpuinfo have the
platform name because it really isn't that hard to add this file
if we need to add platform quirks. The downside is we have to
keep adding compatibles when we support new SoCs.

This all leads back to the patch from Rob that removes the .name
field from the DT based machine descriptor[1]. I'm not sure that
thread ever resolved but it looked like a step in the right
direction. At least it matches what arm64 (and what looks like
mips) are doing. The concern there was finding which machine
descriptor was used for the init path. Perhaps we should only use
of_flat_dt_get_machine_name() for the generic machine descriptor
so platforms that are using their own machine descriptor get
their .name field printed and they know that their descriptor was
used (assuming the .name field is unique) but the platforms using
the generic descriptor would get more meaningful information and
we wouldn't need to have these skeleton machine descriptors.

[1] http://thread.gmane.org/gmane.linux.ports.arm.kernel/277536
Arnd Bergmann May 15, 2014, 7:58 a.m. UTC | #4
On Wednesday 14 May 2014 14:26:12 Stephen Boyd wrote:
> On 05/14, Maxime Ripard wrote:
> > On Tue, May 13, 2014 at 03:47:32PM -0700, Stephen Boyd wrote:
> > > On 05/13, Matthias Brugger wrote:
> > > > +	"mediatek,mt6589",
> > > > +	NULL,
> > > > +};
> > > > +
> > > > +DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
> > > > +	.dt_compat	= mediatek_board_dt_compat,
> > > > +MACHINE_END
> > > 
> > > You shouldn't need this file at all if the platform is part of
> > > the multi-platform kernel.
> > 
> > From a technical point of view, you don't. But it's interesting to
> > keep it mostly for two things:
> >   - You get to see the platform name in /proc/cpuinfo
> >   - If you ever need to add platform quirks, it's already there
> > 
> > We had a similar discussion two weeks ago for mach-sunxi with Olof and
> > Arnd, and ended up keeping this minimal machine.
> > 
> 
> It looks like it's only useful to make /proc/cpuinfo have the
> platform name because it really isn't that hard to add this file
> if we need to add platform quirks. The downside is we have to
> keep adding compatibles when we support new SoCs.

We also still add Kconfig entries for each new platform, and I'd like
to leave it at that for the time being. In a lot of cases we end
up adding stuff to the machine descriptor later, e.g. for SMP support
(hopefully no more thanks to your work though).

Once we have a significant number of machines that are actually
usable rather than stubs and that we are confident about never
needing any additional pointers, we can revisit this discussion.

At that point, we should also discuss how to avoid adding a Kconfig
entry for each new platform, which e.g. involves making the
clocksource drivers user selectable. That part has been surprisingly
controversial in the past.

	Arnd
Rob Herring May 15, 2014, 12:37 p.m. UTC | #5
On Wed, May 14, 2014 at 2:00 AM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> Hi Stephen,
>
> On Tue, May 13, 2014 at 03:47:32PM -0700, Stephen Boyd wrote:
>> On 05/13, Matthias Brugger wrote:
>> > diff --git a/arch/arm/mach-mediatek/mediatek.c b/arch/arm/mach-mediatek/mediatek.c
>> > new file mode 100644
>> > index 0000000..73dfb05
>> > --- /dev/null
>> > +++ b/arch/arm/mach-mediatek/mediatek.c
>> > @@ -0,0 +1,32 @@
>> > +/*
>> > + * Device Tree support for Mediatek SoCs
>> > + *
>> > + * Copyright (c) 2014 MundoReader S.L.
>> > + * Author: Matthias Brugger <matthias.bgg@gmail.com>
>> > + *
>> > + * This program 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.
>> > + *
>> > + * This program is distributed in the hope that it will be useful,
>> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> > + * GNU General Public License for more details.
>> > + */
>> > +
>> > +#include <linux/kernel.h>
>> > +#include <linux/init.h>
>> > +#include <linux/of_platform.h>
>> > +#include <linux/irqchip.h>
>> > +#include <asm/mach/arch.h>
>> > +#include <asm/mach/map.h>
>> > +
>> > +static const char * const mediatek_board_dt_compat[] = {
>>
>> __initconst?
>>
>> > +   "mediatek,mt6589",
>> > +   NULL,
>> > +};
>> > +
>> > +DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
>> > +   .dt_compat      = mediatek_board_dt_compat,
>> > +MACHINE_END
>>
>> You shouldn't need this file at all if the platform is part of
>> the multi-platform kernel.
>
> From a technical point of view, you don't. But it's interesting to
> keep it mostly for two things:
>   - You get to see the platform name in /proc/cpuinfo

We should be getting this string from model or top-level compatible
string in the dtb. I did a patch to do just this [1], but people did
not like removing this string. We should really decide if getting rid
of machine descriptors is a goal or not.

We should at least make things such that the cpuinfo string does not
change on new platforms based on whether they have a machine desc or
not.

>   - If you ever need to add platform quirks, it's already there

That is a weak argument when usually we add things as they are needed.

Rob

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2013-November/208878.html
Rob Herring May 15, 2014, 1 p.m. UTC | #6
On Thu, May 15, 2014 at 2:58 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Wednesday 14 May 2014 14:26:12 Stephen Boyd wrote:
>> On 05/14, Maxime Ripard wrote:
>> > On Tue, May 13, 2014 at 03:47:32PM -0700, Stephen Boyd wrote:
>> > > On 05/13, Matthias Brugger wrote:
>> > > > +       "mediatek,mt6589",
>> > > > +       NULL,
>> > > > +};
>> > > > +
>> > > > +DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
>> > > > +       .dt_compat      = mediatek_board_dt_compat,
>> > > > +MACHINE_END
>> > >
>> > > You shouldn't need this file at all if the platform is part of
>> > > the multi-platform kernel.
>> >
>> > From a technical point of view, you don't. But it's interesting to
>> > keep it mostly for two things:
>> >   - You get to see the platform name in /proc/cpuinfo
>> >   - If you ever need to add platform quirks, it's already there
>> >
>> > We had a similar discussion two weeks ago for mach-sunxi with Olof and
>> > Arnd, and ended up keeping this minimal machine.
>> >
>>
>> It looks like it's only useful to make /proc/cpuinfo have the
>> platform name because it really isn't that hard to add this file
>> if we need to add platform quirks. The downside is we have to
>> keep adding compatibles when we support new SoCs.
>
> We also still add Kconfig entries for each new platform, and I'd like
> to leave it at that for the time being. In a lot of cases we end
> up adding stuff to the machine descriptor later, e.g. for SMP support
> (hopefully no more thanks to your work though).
>
> Once we have a significant number of machines that are actually
> usable rather than stubs and that we are confident about never
> needing any additional pointers, we can revisit this discussion.
>
> At that point, we should also discuss how to avoid adding a Kconfig
> entry for each new platform, which e.g. involves making the
> clocksource drivers user selectable. That part has been surprisingly
> controversial in the past.

The kconfig part doesn't really worry me. The cpuinfo string is
something we should decide now because it leaks to userspace. There
are 3 possible positions I can think of:

1) The name is part of the ABI and we can never remove/change the string.

2) The name is not an ABI and either:
a) we don't care if it changes with matching a machine desc or not.
b) we still want it to be consistent independent of matching

2a is what we have today. I'm in favor of 2b and therefore should get
the name from DT. It is similar to names in /sys/bus/platform/ which
are not considered part of the ABI. The string already changed moving
platforms to DT and that did not seem to cause any issues that I heard
of.

Rob
diff mbox

Patch

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index db3c541..0fc8acd 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -997,6 +997,8 @@  source "arch/arm/mach-mv78xx0/Kconfig"
 
 source "arch/arm/mach-imx/Kconfig"
 
+source "arch/arm/mach-mediatek/Kconfig"
+
 source "arch/arm/mach-mxs/Kconfig"
 
 source "arch/arm/mach-netx/Kconfig"
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 41c1931..8ce9774 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -170,6 +170,7 @@  machine-$(CONFIG_ARCH_MSM)		+= msm
 machine-$(CONFIG_ARCH_MV78XX0)		+= mv78xx0
 machine-$(CONFIG_ARCH_MVEBU)		+= mvebu
 machine-$(CONFIG_ARCH_MXC)		+= imx
+machine-$(CONFIG_ARCH_MEDIATEK)		+= mediatek
 machine-$(CONFIG_ARCH_MXS)		+= mxs
 machine-$(CONFIG_ARCH_NETX)		+= netx
 machine-$(CONFIG_ARCH_NOMADIK)		+= nomadik
diff --git a/arch/arm/boot/dts/mt6589.dtsi b/arch/arm/boot/dts/mt6589.dtsi
new file mode 100644
index 0000000..ab554e8
--- /dev/null
+++ b/arch/arm/boot/dts/mt6589.dtsi
@@ -0,0 +1,93 @@ 
+/*
+ * Copyright (c) 2014 MundoReader S.L.
+ * Author: Matthias Brugger <matthias.bgg@gmail.com>
+ *
+ * This program 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+#include "skeleton.dtsi"
+
+/ {
+	compatible = "mediatek,mt6589";
+	interrupt-parent = <&gic>;
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu@0 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a7";
+			reg = <0x0>;
+		};
+		cpu@1 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a7";
+			reg = <0x1>;
+		};
+		cpu@2 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a7";
+			reg = <0x2>;
+		};
+		cpu@3 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a7";
+			reg = <0x3>;
+		};
+
+	};
+
+	clocks {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		dummy13m: dummy13m {
+			compatible = "fixed-clock";
+			clock-frequency = <13000000>;
+			#clock-cells = <0>;
+		};
+
+		dummy32k: dummy32k {
+			compatible = "fixed-clock";
+			clock-frequency = <32000>;
+			#clock-cells = <0>;
+		};
+	};
+
+	soc {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "simple-bus";
+		clock-ranges;
+		ranges;
+
+		timer: timer@10008000 {
+			compatible = "mediatek,mtk6589-timer";
+			reg = <0x10008000 0x80>;
+			interrupts = <GIC_SPI 113 IRQ_TYPE_EDGE_RISING>;
+			clocks = <&dummy13m>, <&dummy32k>;
+		};
+
+		gic: interrupt-controller@10212000 {
+			compatible = "arm,cortex-a15-gic";
+			interrupt-controller;
+			#interrupt-cells = <3>;
+			reg = <0x10211000 0x1000>,
+			      <0x10212000 0x1000>,
+			      <0x10214000 0x2000>,
+			      <0x10216000 0x2000>;
+		};
+	};
+};
diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
new file mode 100644
index 0000000..2c043a2
--- /dev/null
+++ b/arch/arm/mach-mediatek/Kconfig
@@ -0,0 +1,6 @@ 
+config ARCH_MEDIATEK
+	bool "Mediatek MT6589 SoC" if ARCH_MULTI_V7
+	select ARM_GIC
+	select MTK_TIMER
+	help
+	  Support for Mediatek Cortex-A7 Quad-Core-SoC MT6589.
diff --git a/arch/arm/mach-mediatek/Makefile b/arch/arm/mach-mediatek/Makefile
new file mode 100644
index 0000000..43e619f
--- /dev/null
+++ b/arch/arm/mach-mediatek/Makefile
@@ -0,0 +1 @@ 
+obj-$(CONFIG_ARCH_MEDIATEK) += mediatek.o
diff --git a/arch/arm/mach-mediatek/mediatek.c b/arch/arm/mach-mediatek/mediatek.c
new file mode 100644
index 0000000..73dfb05
--- /dev/null
+++ b/arch/arm/mach-mediatek/mediatek.c
@@ -0,0 +1,32 @@ 
+/*
+ * Device Tree support for Mediatek SoCs
+ *
+ * Copyright (c) 2014 MundoReader S.L.
+ * Author: Matthias Brugger <matthias.bgg@gmail.com>
+ *
+ * This program 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/of_platform.h>
+#include <linux/irqchip.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+
+static const char * const mediatek_board_dt_compat[] = {
+	"mediatek,mt6589",
+	NULL,
+};
+
+DT_MACHINE_START(MEDIATEK_DT, "Mediatek Cortex-A7 (Device Tree)")
+	.dt_compat	= mediatek_board_dt_compat,
+MACHINE_END