Re: [PATCH v5 1/8] ARM: brcmstb: add infrastructure for ARM-based Broadcom STB SoCs

2014-01-24 Thread Marc C
Hi Mark,

>> +static void __init brcmstb_init_early(void)
>> +{
>> +   add_preferred_console("ttyS", 0, "115200");
>> +}
>
> Is this really required?

I think I can drop this. It was a holdover from our older kernels.

>> +   /*
>> +   * set the reset vector to point to the secondary_startup
>> +   * routine
>> +   */
>> +   cpu_set_boot_addr(cpu, virt_to_phys(brcmstb_secondary_startup));
>> +
>> +   flush_cache_all();
>
> Why? What does the new CPU need before its caches are coherent and up?

Absolutely nothing! I should be able to drop this as well.

Regarding the CPU power-down sequence, I'll review it and make sure it follows 
the
"Processor power domain" sequence in the A15 TRM. For any deviations, I'll 
double-check
with our H/W designers to ensure there aren't any magic requirements 
unaccounted for.

Thank you for taking a deep-dive into the code! I'll make the appropriate 
modifications
per your suggestions.

Regards,
Marc C


On 01/24/2014 02:14 AM, Mark Rutland wrote:
> On Wed, Jan 22, 2014 at 03:30:45AM +, Marc Carino wrote:
>> The BCM7xxx series of Broadcom SoCs are used primarily in set-top boxes.
>>
>> This patch adds machine support for the ARM-based Broadcom SoCs.
>>
>> Signed-off-by: Marc Carino 
>> Acked-by: Florian Fainelli 
>> ---
>>  arch/arm/configs/multi_v7_defconfig |1 +
>>  arch/arm/mach-bcm/Kconfig   |   14 ++
>>  arch/arm/mach-bcm/Makefile  |4 +
>>  arch/arm/mach-bcm/brcmstb.c |  110 
>>  arch/arm/mach-bcm/brcmstb.h |   38 
>>  arch/arm/mach-bcm/headsmp-brcmstb.S |   34 
>>  arch/arm/mach-bcm/hotplug-brcmstb.c |  334 
>> +++
>>  7 files changed, 535 insertions(+), 0 deletions(-)
>>  create mode 100644 arch/arm/mach-bcm/brcmstb.c
>>  create mode 100644 arch/arm/mach-bcm/brcmstb.h
>>  create mode 100644 arch/arm/mach-bcm/headsmp-brcmstb.S
>>  create mode 100644 arch/arm/mach-bcm/hotplug-brcmstb.c
>>
>> diff --git a/arch/arm/configs/multi_v7_defconfig 
>> b/arch/arm/configs/multi_v7_defconfig
>> index c1df4e9..7028d11 100644
>> --- a/arch/arm/configs/multi_v7_defconfig
>> +++ b/arch/arm/configs/multi_v7_defconfig
>> @@ -7,6 +7,7 @@ CONFIG_MACH_ARMADA_370=y
>>  CONFIG_MACH_ARMADA_XP=y
>>  CONFIG_ARCH_BCM=y
>>  CONFIG_ARCH_BCM_MOBILE=y
>> +CONFIG_ARCH_BRCMSTB=y
>>  CONFIG_GPIO_PCA953X=y
>>  CONFIG_ARCH_HIGHBANK=y
>>  CONFIG_ARCH_KEYSTONE=y
>> diff --git a/arch/arm/mach-bcm/Kconfig b/arch/arm/mach-bcm/Kconfig
>> index 9fe6d88..2c1ae83 100644
>> --- a/arch/arm/mach-bcm/Kconfig
>> +++ b/arch/arm/mach-bcm/Kconfig
>> @@ -31,6 +31,20 @@ config ARCH_BCM_MOBILE
>>   BCM11130, BCM11140, BCM11351, BCM28145 and
>>   BCM28155 variants.
>>
>> +config ARCH_BRCMSTB
>> +   bool "Broadcom BCM7XXX based boards" if ARCH_MULTI_V7
>> +   depends on MMU
>> +   select ARM_GIC
>> +   select MIGHT_HAVE_PCI
>> +   select HAVE_SMP
>> +   select HAVE_ARM_ARCH_TIMER
>> +   help
>> + Say Y if you intend to run the kernel on a Broadcom ARM-based STB
>> + chipset.
>> +
>> + This enables support for Broadcom ARM-based set-top box chipsets,
>> + including the 7445 family of chips.
>> +
>>  endmenu
>>
>>  endif
>> diff --git a/arch/arm/mach-bcm/Makefile b/arch/arm/mach-bcm/Makefile
>> index c2ccd5a..b744a12 100644
>> --- a/arch/arm/mach-bcm/Makefile
>> +++ b/arch/arm/mach-bcm/Makefile
>> @@ -13,3 +13,7 @@
>>  obj-$(CONFIG_ARCH_BCM_MOBILE)  := board_bcm281xx.o bcm_kona_smc.o 
>> bcm_kona_smc_asm.o kona.o
>>  plus_sec := $(call as-instr,.arch_extension sec,+sec)
>>  AFLAGS_bcm_kona_smc_asm.o  :=-Wa,-march=armv7-a$(plus_sec)
>> +
>> +obj-$(CONFIG_ARCH_BRCMSTB) := brcmstb.o
>> +obj-$(CONFIG_SMP)  += headsmp-brcmstb.o
>> +obj-$(CONFIG_HOTPLUG_CPU)  += hotplug-brcmstb.o
>> diff --git a/arch/arm/mach-bcm/brcmstb.c b/arch/arm/mach-bcm/brcmstb.c
>> new file mode 100644
>> index 000..7a6093d
>> --- /dev/null
>> +++ b/arch/arm/mach-bcm/brcmstb.c
>> @@ -0,0 +1,110 @@
>> +/*
>> + * Copyright (C) 2013 Broadcom Corporation
>> + *
>> + * 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 version 2.
>> + *
>> + * This program is distributed "as is" WITHOUT ANY WARRANTY of any
>> + * kind, whether express or implied; without even the implied warranty
>> + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include "brcmstb.h"
>> +
>> +/***
>> + * STB

Re: [PATCH v5 1/8] ARM: brcmstb: add infrastructure for ARM-based Broadcom STB SoCs

2014-01-24 Thread Mark Rutland
On Wed, Jan 22, 2014 at 03:30:45AM +, Marc Carino wrote:
> The BCM7xxx series of Broadcom SoCs are used primarily in set-top boxes.
> 
> This patch adds machine support for the ARM-based Broadcom SoCs.
> 
> Signed-off-by: Marc Carino 
> Acked-by: Florian Fainelli 
> ---
>  arch/arm/configs/multi_v7_defconfig |1 +
>  arch/arm/mach-bcm/Kconfig   |   14 ++
>  arch/arm/mach-bcm/Makefile  |4 +
>  arch/arm/mach-bcm/brcmstb.c |  110 
>  arch/arm/mach-bcm/brcmstb.h |   38 
>  arch/arm/mach-bcm/headsmp-brcmstb.S |   34 
>  arch/arm/mach-bcm/hotplug-brcmstb.c |  334 
> +++
>  7 files changed, 535 insertions(+), 0 deletions(-)
>  create mode 100644 arch/arm/mach-bcm/brcmstb.c
>  create mode 100644 arch/arm/mach-bcm/brcmstb.h
>  create mode 100644 arch/arm/mach-bcm/headsmp-brcmstb.S
>  create mode 100644 arch/arm/mach-bcm/hotplug-brcmstb.c
> 
> diff --git a/arch/arm/configs/multi_v7_defconfig 
> b/arch/arm/configs/multi_v7_defconfig
> index c1df4e9..7028d11 100644
> --- a/arch/arm/configs/multi_v7_defconfig
> +++ b/arch/arm/configs/multi_v7_defconfig
> @@ -7,6 +7,7 @@ CONFIG_MACH_ARMADA_370=y
>  CONFIG_MACH_ARMADA_XP=y
>  CONFIG_ARCH_BCM=y
>  CONFIG_ARCH_BCM_MOBILE=y
> +CONFIG_ARCH_BRCMSTB=y
>  CONFIG_GPIO_PCA953X=y
>  CONFIG_ARCH_HIGHBANK=y
>  CONFIG_ARCH_KEYSTONE=y
> diff --git a/arch/arm/mach-bcm/Kconfig b/arch/arm/mach-bcm/Kconfig
> index 9fe6d88..2c1ae83 100644
> --- a/arch/arm/mach-bcm/Kconfig
> +++ b/arch/arm/mach-bcm/Kconfig
> @@ -31,6 +31,20 @@ config ARCH_BCM_MOBILE
>   BCM11130, BCM11140, BCM11351, BCM28145 and
>   BCM28155 variants.
> 
> +config ARCH_BRCMSTB
> +   bool "Broadcom BCM7XXX based boards" if ARCH_MULTI_V7
> +   depends on MMU
> +   select ARM_GIC
> +   select MIGHT_HAVE_PCI
> +   select HAVE_SMP
> +   select HAVE_ARM_ARCH_TIMER
> +   help
> + Say Y if you intend to run the kernel on a Broadcom ARM-based STB
> + chipset.
> +
> + This enables support for Broadcom ARM-based set-top box chipsets,
> + including the 7445 family of chips.
> +
>  endmenu
> 
>  endif
> diff --git a/arch/arm/mach-bcm/Makefile b/arch/arm/mach-bcm/Makefile
> index c2ccd5a..b744a12 100644
> --- a/arch/arm/mach-bcm/Makefile
> +++ b/arch/arm/mach-bcm/Makefile
> @@ -13,3 +13,7 @@
>  obj-$(CONFIG_ARCH_BCM_MOBILE)  := board_bcm281xx.o bcm_kona_smc.o 
> bcm_kona_smc_asm.o kona.o
>  plus_sec := $(call as-instr,.arch_extension sec,+sec)
>  AFLAGS_bcm_kona_smc_asm.o  :=-Wa,-march=armv7-a$(plus_sec)
> +
> +obj-$(CONFIG_ARCH_BRCMSTB) := brcmstb.o
> +obj-$(CONFIG_SMP)  += headsmp-brcmstb.o
> +obj-$(CONFIG_HOTPLUG_CPU)  += hotplug-brcmstb.o
> diff --git a/arch/arm/mach-bcm/brcmstb.c b/arch/arm/mach-bcm/brcmstb.c
> new file mode 100644
> index 000..7a6093d
> --- /dev/null
> +++ b/arch/arm/mach-bcm/brcmstb.c
> @@ -0,0 +1,110 @@
> +/*
> + * Copyright (C) 2013 Broadcom Corporation
> + *
> + * 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 version 2.
> + *
> + * This program is distributed "as is" WITHOUT ANY WARRANTY of any
> + * kind, whether express or implied; without even the implied warranty
> + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "brcmstb.h"
> +
> +/***
> + * STB CPU (main application processor)
> + ***/
> +
> +static const char *brcmstb_match[] __initconst = {
> +   "brcm,bcm7445",
> +   "brcm,brcmstb",
> +   NULL
> +};
> +
> +static void __init brcmstb_init_early(void)
> +{
> +   add_preferred_console("ttyS", 0, "115200");
> +}

Is this really required?

> +
> +/***
> + * SMP boot
> + ***/
> +
> +#ifdef CONFIG_SMP
> +static DEFINE_SPINLOCK(boot_lock);
> +
> +static void __cpuinit brcmstb_secondary_init(unsigned int cpu)
> +{
> +   /*
> +* Synchronise with the boot thread.
> +*/
> +   spin_lock(&boot_lock);
> +   spin_unlock(&boot_lock);
> +}
> +
> +static int __cpuinit brcmstb_boot_secondary(unsigned int cpu,
> +   struct task_struct *idle)
> +{
> +   /*
> +* set synchronisation state between this boot processor
> +* and the secondary one
> +*/
> +   spin_lock(

[PATCH v5 1/8] ARM: brcmstb: add infrastructure for ARM-based Broadcom STB SoCs

2014-01-21 Thread Marc Carino
The BCM7xxx series of Broadcom SoCs are used primarily in set-top boxes.

This patch adds machine support for the ARM-based Broadcom SoCs.

Signed-off-by: Marc Carino 
Acked-by: Florian Fainelli 
---
 arch/arm/configs/multi_v7_defconfig |1 +
 arch/arm/mach-bcm/Kconfig   |   14 ++
 arch/arm/mach-bcm/Makefile  |4 +
 arch/arm/mach-bcm/brcmstb.c |  110 
 arch/arm/mach-bcm/brcmstb.h |   38 
 arch/arm/mach-bcm/headsmp-brcmstb.S |   34 
 arch/arm/mach-bcm/hotplug-brcmstb.c |  334 +++
 7 files changed, 535 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-bcm/brcmstb.c
 create mode 100644 arch/arm/mach-bcm/brcmstb.h
 create mode 100644 arch/arm/mach-bcm/headsmp-brcmstb.S
 create mode 100644 arch/arm/mach-bcm/hotplug-brcmstb.c

diff --git a/arch/arm/configs/multi_v7_defconfig 
b/arch/arm/configs/multi_v7_defconfig
index c1df4e9..7028d11 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -7,6 +7,7 @@ CONFIG_MACH_ARMADA_370=y
 CONFIG_MACH_ARMADA_XP=y
 CONFIG_ARCH_BCM=y
 CONFIG_ARCH_BCM_MOBILE=y
+CONFIG_ARCH_BRCMSTB=y
 CONFIG_GPIO_PCA953X=y
 CONFIG_ARCH_HIGHBANK=y
 CONFIG_ARCH_KEYSTONE=y
diff --git a/arch/arm/mach-bcm/Kconfig b/arch/arm/mach-bcm/Kconfig
index 9fe6d88..2c1ae83 100644
--- a/arch/arm/mach-bcm/Kconfig
+++ b/arch/arm/mach-bcm/Kconfig
@@ -31,6 +31,20 @@ config ARCH_BCM_MOBILE
  BCM11130, BCM11140, BCM11351, BCM28145 and
  BCM28155 variants.
 
+config ARCH_BRCMSTB
+   bool "Broadcom BCM7XXX based boards" if ARCH_MULTI_V7
+   depends on MMU
+   select ARM_GIC
+   select MIGHT_HAVE_PCI
+   select HAVE_SMP
+   select HAVE_ARM_ARCH_TIMER
+   help
+ Say Y if you intend to run the kernel on a Broadcom ARM-based STB
+ chipset.
+
+ This enables support for Broadcom ARM-based set-top box chipsets,
+ including the 7445 family of chips.
+
 endmenu
 
 endif
diff --git a/arch/arm/mach-bcm/Makefile b/arch/arm/mach-bcm/Makefile
index c2ccd5a..b744a12 100644
--- a/arch/arm/mach-bcm/Makefile
+++ b/arch/arm/mach-bcm/Makefile
@@ -13,3 +13,7 @@
 obj-$(CONFIG_ARCH_BCM_MOBILE)  := board_bcm281xx.o bcm_kona_smc.o 
bcm_kona_smc_asm.o kona.o
 plus_sec := $(call as-instr,.arch_extension sec,+sec)
 AFLAGS_bcm_kona_smc_asm.o  :=-Wa,-march=armv7-a$(plus_sec)
+
+obj-$(CONFIG_ARCH_BRCMSTB) := brcmstb.o
+obj-$(CONFIG_SMP)  += headsmp-brcmstb.o
+obj-$(CONFIG_HOTPLUG_CPU)  += hotplug-brcmstb.o
diff --git a/arch/arm/mach-bcm/brcmstb.c b/arch/arm/mach-bcm/brcmstb.c
new file mode 100644
index 000..7a6093d
--- /dev/null
+++ b/arch/arm/mach-bcm/brcmstb.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2013 Broadcom Corporation
+ *
+ * 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 version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "brcmstb.h"
+
+/***
+ * STB CPU (main application processor)
+ ***/
+
+static const char *brcmstb_match[] __initconst = {
+   "brcm,bcm7445",
+   "brcm,brcmstb",
+   NULL
+};
+
+static void __init brcmstb_init_early(void)
+{
+   add_preferred_console("ttyS", 0, "115200");
+}
+
+/***
+ * SMP boot
+ ***/
+
+#ifdef CONFIG_SMP
+static DEFINE_SPINLOCK(boot_lock);
+
+static void __cpuinit brcmstb_secondary_init(unsigned int cpu)
+{
+   /*
+* Synchronise with the boot thread.
+*/
+   spin_lock(&boot_lock);
+   spin_unlock(&boot_lock);
+}
+
+static int __cpuinit brcmstb_boot_secondary(unsigned int cpu,
+   struct task_struct *idle)
+{
+   /*
+* set synchronisation state between this boot processor
+* and the secondary one
+*/
+   spin_lock(&boot_lock);
+
+   /* Bring up power to the core if necessary */
+   if (brcmstb_cpu_get_power_state(cpu) == 0)
+   brcmstb_cpu_power_on(cpu);
+
+   brcmstb_cpu_boot(cpu);
+
+   /*
+* now the secondary core is starting up let it run its
+* calibrations, then wait for it to finish
+*/
+   spin_unlock(&boot_lock);
+
+   return 0;
+}
+