Re: [U-Boot] [PATCH 03/10] sunxi: Introduce a hidden ARCH_SUN6I Kconfig bool

2015-04-17 Thread Ian Campbell
On Thu, 2015-04-16 at 09:23 +0200, Hans de Goede wrote:
> Hi,
> 
> On 15-04-15 21:47, Ian Campbell wrote:
> > On Wed, 2015-04-15 at 10:45 +0200, Michal Suchanek wrote:
> >> It is not obvious which MACH_SUN?I are ARCH_SUN6I derived. So if you
> >> can come up with a descriptive name for 'a number of things in common,
> >> such as having separate ahb reset registers in the ccm' that's fine
> >> otherwise this obfuscates the code, not clarifies.
> >
> > I don't particularly object to the patch but this occurred to me too. I
> > suppose the rule is "first sunxi to look this way".
> >
> > How about we call groups of similar SoCs a "generation", i.e.
> > ARCH_SUNXI_GEN2 is what is called ARCH_SUN6I here, meaning GEN1 would be
> > SUN4/5/7I.
> 
> I like the GEN idea, but not the numbering as it is a bit too arbitrary
> how about: ARCH_SUNXI_GEN_SUN6I or (better I think) just SUNXI_GEN_SUN6I ?

Works for me (I agree the second is better too).

> 
> I know that does not solve the fact that MACH_SUN7I is SUNXI_GEN_SUN4I
> but we cannot fix that, at least this way it will be explicit.
> 
> Regards,
> 
> Hans
> 


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 03/10] sunxi: Introduce a hidden ARCH_SUN6I Kconfig bool

2015-04-16 Thread Hans de Goede

Hi,

On 15-04-15 21:47, Ian Campbell wrote:

On Wed, 2015-04-15 at 10:45 +0200, Michal Suchanek wrote:

It is not obvious which MACH_SUN?I are ARCH_SUN6I derived. So if you
can come up with a descriptive name for 'a number of things in common,
such as having separate ahb reset registers in the ccm' that's fine
otherwise this obfuscates the code, not clarifies.


I don't particularly object to the patch but this occurred to me too. I
suppose the rule is "first sunxi to look this way".

How about we call groups of similar SoCs a "generation", i.e.
ARCH_SUNXI_GEN2 is what is called ARCH_SUN6I here, meaning GEN1 would be
SUN4/5/7I.


I like the GEN idea, but not the numbering as it is a bit too arbitrary
how about: ARCH_SUNXI_GEN_SUN6I or (better I think) just SUNXI_GEN_SUN6I ?

I know that does not solve the fact that MACH_SUN7I is SUNXI_GEN_SUN4I
but we cannot fix that, at least this way it will be explicit.

Regards,

Hans
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 03/10] sunxi: Introduce a hidden ARCH_SUN6I Kconfig bool

2015-04-15 Thread Ian Campbell
On Wed, 2015-04-15 at 10:45 +0200, Michal Suchanek wrote:
> It is not obvious which MACH_SUN?I are ARCH_SUN6I derived. So if you
> can come up with a descriptive name for 'a number of things in common,
> such as having separate ahb reset registers in the ccm' that's fine
> otherwise this obfuscates the code, not clarifies.

I don't particularly object to the patch but this occurred to me too. I
suppose the rule is "first sunxi to look this way".

How about we call groups of similar SoCs a "generation", i.e.
ARCH_SUNXI_GEN2 is what is called ARCH_SUN6I here, meaning GEN1 would be
SUN4/5/7I.

I've deliberately not considered SUN1/2/3I since I don't know much about
them, and we don't support them AFAIK, but perhaps the generation
numbers I've picked should be larger to accommodate them.

Ian.


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 03/10] sunxi: Introduce a hidden ARCH_SUN6I Kconfig bool

2015-04-15 Thread Michal Suchanek
On 15 April 2015 at 10:07, Hans de Goede  wrote:
> Hi,
>
>
> On 15-04-15 10:01, Michal Suchanek wrote:
>>
>> On 15 April 2015 at 09:35, Hans de Goede  wrote:
>>>
>>> Hi,
>>>
>>>
>>> On 15-04-15 08:51, Michal Suchanek wrote:


 On 14 April 2015 at 18:06, Hans de Goede  wrote:
>
>
> sun6i and newer (derived) SoCs such as the sun8i-a23, sun8i-a33 and
> sun9i
> have a various things in common, like having separate ahb reset control
> registers, the SID living inside the pmic, custom pmic busses, new
> style
> watchdog, etc.
>
> This commit introduces a new hidden ARCH_SUN6I Kconfig bool which can
> be
> used to check for these features avoiding the need for an ever growing
> list
> of "#if defined CONFIG_MACH_SUN?I" conditionals as we add support for
> more
> "new style" sunxi SoCs.
>
> Signed-off-by: Hans de Goede 
> ---
>arch/arm/cpu/armv7/sunxi/board.c| 18 +-
>arch/arm/cpu/armv7/sunxi/cpu_info.c |  2 +-
>arch/arm/cpu/armv7/sunxi/usbc.c |  4 ++--
>arch/arm/include/asm/arch-sunxi/cpu_sun4i.h | 12 ++--
>arch/arm/include/asm/arch-sunxi/mmc.h   |  3 +--
>arch/arm/include/asm/arch-sunxi/timer.h |  8 
>board/sunxi/Kconfig |  9 +
>board/sunxi/gmac.c  |  6 +++---
>drivers/mmc/sunxi_mmc.c |  3 +--
>drivers/video/sunxi_display.c   | 10 +-
>10 files changed, 41 insertions(+), 34 deletions(-)
>
> diff --git a/arch/arm/cpu/armv7/sunxi/board.c
> b/arch/arm/cpu/armv7/sunxi/board.c
> index 6471c6b..30d5974 100644
> --- a/arch/arm/cpu/armv7/sunxi/board.c
> +++ b/arch/arm/cpu/armv7/sunxi/board.c
> @@ -173,7 +173,15 @@ void board_init_f(ulong dummy)
>
>void reset_cpu(ulong addr)
>{
> -#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN5I) ||
> defined(CONFIG_MACH_SUN7I)
> +#ifdef CONFIG_ARCH_SUN6I



 Hello,

 this looks wrong.

 Either this is ARCH_SUNXI and it coverts all or it's ARCH_SUN6I and
 then SUN4I and SUN5I should still be checked separately.
>>>
>>>
>>>
>>> Look closer, the blocks before / after the #else are swapped to avoid
>>> needing
>>> to use #ifndef without good reason as that is ugly.
>>
>>
>> So you mean that
>>
>> ARCH_SUN6I is
>> !defined(MACH_SUN4I) && !defined(MACH_SUN5I) && !defined(MACH_SUN7I) &&
>> (defined(MACH_SUN6I) || defined(MACH_SUN8I) || defined(MACH_SUN9I))
>>
>> Now that is ugly.
>>
>> This probably needs a better name then.
>
>
> What this needs is less bikeshedding and you to actually take your time
> to properly read the patch.
>
> If you read the help text in the Kconfig file then you will see that
>
> ARCH_SUN6I is set for sun6i derived designs, which all have a number
> of things in common, such as having separate ahb reset registers
> in the ccm.
>

Sorry, I see the code is technically correct.

However, if the purpose of this patch was to make the code clearer
then it fails at that.

It is unclear even reading the commit message, and that is not
included in the code.

It is not obvious which MACH_SUN?I are ARCH_SUN6I derived. So if you
can come up with a descriptive name for 'a number of things in common,
such as having separate ahb reset registers in the ccm' that's fine
otherwise this obfuscates the code, not clarifies.

That's not to say that simplifying the ifdefs does not have some
value. Just expect 'WTH does SUN7I not select SUN6I?' come up from
time to time.

Thanks

Michal
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 03/10] sunxi: Introduce a hidden ARCH_SUN6I Kconfig bool

2015-04-15 Thread Hans de Goede

Hi,

On 15-04-15 10:01, Michal Suchanek wrote:

On 15 April 2015 at 09:35, Hans de Goede  wrote:

Hi,


On 15-04-15 08:51, Michal Suchanek wrote:


On 14 April 2015 at 18:06, Hans de Goede  wrote:


sun6i and newer (derived) SoCs such as the sun8i-a23, sun8i-a33 and sun9i
have a various things in common, like having separate ahb reset control
registers, the SID living inside the pmic, custom pmic busses, new style
watchdog, etc.

This commit introduces a new hidden ARCH_SUN6I Kconfig bool which can be
used to check for these features avoiding the need for an ever growing
list
of "#if defined CONFIG_MACH_SUN?I" conditionals as we add support for
more
"new style" sunxi SoCs.

Signed-off-by: Hans de Goede 
---
   arch/arm/cpu/armv7/sunxi/board.c| 18 +-
   arch/arm/cpu/armv7/sunxi/cpu_info.c |  2 +-
   arch/arm/cpu/armv7/sunxi/usbc.c |  4 ++--
   arch/arm/include/asm/arch-sunxi/cpu_sun4i.h | 12 ++--
   arch/arm/include/asm/arch-sunxi/mmc.h   |  3 +--
   arch/arm/include/asm/arch-sunxi/timer.h |  8 
   board/sunxi/Kconfig |  9 +
   board/sunxi/gmac.c  |  6 +++---
   drivers/mmc/sunxi_mmc.c |  3 +--
   drivers/video/sunxi_display.c   | 10 +-
   10 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/arch/arm/cpu/armv7/sunxi/board.c
b/arch/arm/cpu/armv7/sunxi/board.c
index 6471c6b..30d5974 100644
--- a/arch/arm/cpu/armv7/sunxi/board.c
+++ b/arch/arm/cpu/armv7/sunxi/board.c
@@ -173,7 +173,15 @@ void board_init_f(ulong dummy)

   void reset_cpu(ulong addr)
   {
-#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN5I) ||
defined(CONFIG_MACH_SUN7I)
+#ifdef CONFIG_ARCH_SUN6I



Hello,

this looks wrong.

Either this is ARCH_SUNXI and it coverts all or it's ARCH_SUN6I and
then SUN4I and SUN5I should still be checked separately.



Look closer, the blocks before / after the #else are swapped to avoid
needing
to use #ifndef without good reason as that is ugly.


So you mean that

ARCH_SUN6I is
!defined(MACH_SUN4I) && !defined(MACH_SUN5I) && !defined(MACH_SUN7I) &&
(defined(MACH_SUN6I) || defined(MACH_SUN8I) || defined(MACH_SUN9I))

Now that is ugly.

This probably needs a better name then.


What this needs is less bikeshedding and you to actually take your time
to properly read the patch.

If you read the help text in the Kconfig file then you will see that

ARCH_SUN6I is set for sun6i derived designs, which all have a number
of things in common, such as having separate ahb reset registers
in the ccm.

Regards,

Hans





Thanks

Michal


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 03/10] sunxi: Introduce a hidden ARCH_SUN6I Kconfig bool

2015-04-15 Thread Hans de Goede

Hi,

On 15-04-15 09:00, Michal Suchanek wrote:

On 14 April 2015 at 18:06, Hans de Goede  wrote:


--- a/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h
+++ b/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h
@@ -37,7 +37,7 @@
  #define SUNXI_MMC1_BASE0x01c1
  #define SUNXI_MMC2_BASE0x01c11000
  #define SUNXI_MMC3_BASE0x01c12000
-#if !defined CONFIG_MACH_SUN6I && !defined CONFIG_MACH_SUN8I
+#ifndef CONFIG_ARCH_SUN6I
  #define SUNXI_USB0_BASE0x01c13000
  #define SUNXI_USB1_BASE0x01c14000
  #endif
@@ -45,15 +45,15 @@
  #define SUNXI_HDMI_BASE0x01c16000
  #define SUNXI_SPI2_BASE0x01c17000
  #define SUNXI_SATA_BASE0x01c18000
-#if !defined CONFIG_MACH_SUN6I && !defined CONFIG_MACH_SUN8I
+#ifdef CONFIG_ARCH_SUN6I


Also here #ifndef is changed to #ifdef


And the same here too.

Regards,

Hans
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 03/10] sunxi: Introduce a hidden ARCH_SUN6I Kconfig bool

2015-04-15 Thread Hans de Goede

Hi,

On 15-04-15 08:51, Michal Suchanek wrote:

On 14 April 2015 at 18:06, Hans de Goede  wrote:

sun6i and newer (derived) SoCs such as the sun8i-a23, sun8i-a33 and sun9i
have a various things in common, like having separate ahb reset control
registers, the SID living inside the pmic, custom pmic busses, new style
watchdog, etc.

This commit introduces a new hidden ARCH_SUN6I Kconfig bool which can be
used to check for these features avoiding the need for an ever growing list
of "#if defined CONFIG_MACH_SUN?I" conditionals as we add support for more
"new style" sunxi SoCs.

Signed-off-by: Hans de Goede 
---
  arch/arm/cpu/armv7/sunxi/board.c| 18 +-
  arch/arm/cpu/armv7/sunxi/cpu_info.c |  2 +-
  arch/arm/cpu/armv7/sunxi/usbc.c |  4 ++--
  arch/arm/include/asm/arch-sunxi/cpu_sun4i.h | 12 ++--
  arch/arm/include/asm/arch-sunxi/mmc.h   |  3 +--
  arch/arm/include/asm/arch-sunxi/timer.h |  8 
  board/sunxi/Kconfig |  9 +
  board/sunxi/gmac.c  |  6 +++---
  drivers/mmc/sunxi_mmc.c |  3 +--
  drivers/video/sunxi_display.c   | 10 +-
  10 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c
index 6471c6b..30d5974 100644
--- a/arch/arm/cpu/armv7/sunxi/board.c
+++ b/arch/arm/cpu/armv7/sunxi/board.c
@@ -173,7 +173,15 @@ void board_init_f(ulong dummy)

  void reset_cpu(ulong addr)
  {
-#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN5I) || 
defined(CONFIG_MACH_SUN7I)
+#ifdef CONFIG_ARCH_SUN6I


Hello,

this looks wrong.

Either this is ARCH_SUNXI and it coverts all or it's ARCH_SUN6I and
then SUN4I and SUN5I should still be checked separately.


Look closer, the blocks before / after the #else are swapped to avoid needing
to use #ifndef without good reason as that is ugly.





diff --git a/arch/arm/include/asm/arch-sunxi/timer.h 
b/arch/arm/include/asm/arch-sunxi/timer.h
index 9a5e488..a6cc443 100644
--- a/arch/arm/include/asm/arch-sunxi/timer.h
+++ b/arch/arm/include/asm/arch-sunxi/timer.h
@@ -67,7 +67,10 @@ struct sunxi_timer_reg {
 struct sunxi_timer timer[6];/* We have 6 timers */
 u8 res2[16];
 struct sunxi_avs avs;
-#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN5I) || 
defined(CONFIG_MACH_SUN7I)
+#ifdef CONFIG_ARCH_SUN6I


Same here.

Regards,

Hans
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 03/10] sunxi: Introduce a hidden ARCH_SUN6I Kconfig bool

2015-04-15 Thread Michal Suchanek
On 15 April 2015 at 09:35, Hans de Goede  wrote:
> Hi,
>
>
> On 15-04-15 08:51, Michal Suchanek wrote:
>>
>> On 14 April 2015 at 18:06, Hans de Goede  wrote:
>>>
>>> sun6i and newer (derived) SoCs such as the sun8i-a23, sun8i-a33 and sun9i
>>> have a various things in common, like having separate ahb reset control
>>> registers, the SID living inside the pmic, custom pmic busses, new style
>>> watchdog, etc.
>>>
>>> This commit introduces a new hidden ARCH_SUN6I Kconfig bool which can be
>>> used to check for these features avoiding the need for an ever growing
>>> list
>>> of "#if defined CONFIG_MACH_SUN?I" conditionals as we add support for
>>> more
>>> "new style" sunxi SoCs.
>>>
>>> Signed-off-by: Hans de Goede 
>>> ---
>>>   arch/arm/cpu/armv7/sunxi/board.c| 18 +-
>>>   arch/arm/cpu/armv7/sunxi/cpu_info.c |  2 +-
>>>   arch/arm/cpu/armv7/sunxi/usbc.c |  4 ++--
>>>   arch/arm/include/asm/arch-sunxi/cpu_sun4i.h | 12 ++--
>>>   arch/arm/include/asm/arch-sunxi/mmc.h   |  3 +--
>>>   arch/arm/include/asm/arch-sunxi/timer.h |  8 
>>>   board/sunxi/Kconfig |  9 +
>>>   board/sunxi/gmac.c  |  6 +++---
>>>   drivers/mmc/sunxi_mmc.c |  3 +--
>>>   drivers/video/sunxi_display.c   | 10 +-
>>>   10 files changed, 41 insertions(+), 34 deletions(-)
>>>
>>> diff --git a/arch/arm/cpu/armv7/sunxi/board.c
>>> b/arch/arm/cpu/armv7/sunxi/board.c
>>> index 6471c6b..30d5974 100644
>>> --- a/arch/arm/cpu/armv7/sunxi/board.c
>>> +++ b/arch/arm/cpu/armv7/sunxi/board.c
>>> @@ -173,7 +173,15 @@ void board_init_f(ulong dummy)
>>>
>>>   void reset_cpu(ulong addr)
>>>   {
>>> -#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN5I) ||
>>> defined(CONFIG_MACH_SUN7I)
>>> +#ifdef CONFIG_ARCH_SUN6I
>>
>>
>> Hello,
>>
>> this looks wrong.
>>
>> Either this is ARCH_SUNXI and it coverts all or it's ARCH_SUN6I and
>> then SUN4I and SUN5I should still be checked separately.
>
>
> Look closer, the blocks before / after the #else are swapped to avoid
> needing
> to use #ifndef without good reason as that is ugly.

So you mean that

ARCH_SUN6I is
!defined(MACH_SUN4I) && !defined(MACH_SUN5I) && !defined(MACH_SUN7I) &&
(defined(MACH_SUN6I) || defined(MACH_SUN8I) || defined(MACH_SUN9I))

Now that is ugly.

This probably needs a better name then.

Thanks

Michal
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 03/10] sunxi: Introduce a hidden ARCH_SUN6I Kconfig bool

2015-04-15 Thread Michal Suchanek
On 14 April 2015 at 18:06, Hans de Goede  wrote:
> sun6i and newer (derived) SoCs such as the sun8i-a23, sun8i-a33 and sun9i
> have a various things in common, like having separate ahb reset control
> registers, the SID living inside the pmic, custom pmic busses, new style
> watchdog, etc.
>
> This commit introduces a new hidden ARCH_SUN6I Kconfig bool which can be
> used to check for these features avoiding the need for an ever growing list
> of "#if defined CONFIG_MACH_SUN?I" conditionals as we add support for more
> "new style" sunxi SoCs.
>
> Signed-off-by: Hans de Goede 
> ---
>  arch/arm/cpu/armv7/sunxi/board.c| 18 +-
>  arch/arm/cpu/armv7/sunxi/cpu_info.c |  2 +-
>  arch/arm/cpu/armv7/sunxi/usbc.c |  4 ++--
>  arch/arm/include/asm/arch-sunxi/cpu_sun4i.h | 12 ++--
>  arch/arm/include/asm/arch-sunxi/mmc.h   |  3 +--
>  arch/arm/include/asm/arch-sunxi/timer.h |  8 
>  board/sunxi/Kconfig |  9 +
>  board/sunxi/gmac.c  |  6 +++---
>  drivers/mmc/sunxi_mmc.c |  3 +--
>  drivers/video/sunxi_display.c   | 10 +-
>  10 files changed, 41 insertions(+), 34 deletions(-)
>
> diff --git a/arch/arm/cpu/armv7/sunxi/board.c 
> b/arch/arm/cpu/armv7/sunxi/board.c
> index 6471c6b..30d5974 100644
> --- a/arch/arm/cpu/armv7/sunxi/board.c
> +++ b/arch/arm/cpu/armv7/sunxi/board.c
> @@ -173,7 +173,15 @@ void board_init_f(ulong dummy)
>
>  void reset_cpu(ulong addr)
>  {
> -#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN5I) || 
> defined(CONFIG_MACH_SUN7I)
> +#ifdef CONFIG_ARCH_SUN6I

Hello,

this looks wrong.

Either this is ARCH_SUNXI and it coverts all or it's ARCH_SUN6I and
then SUN4I and SUN5I should still be checked separately.


> diff --git a/arch/arm/include/asm/arch-sunxi/timer.h 
> b/arch/arm/include/asm/arch-sunxi/timer.h
> index 9a5e488..a6cc443 100644
> --- a/arch/arm/include/asm/arch-sunxi/timer.h
> +++ b/arch/arm/include/asm/arch-sunxi/timer.h
> @@ -67,7 +67,10 @@ struct sunxi_timer_reg {
> struct sunxi_timer timer[6];/* We have 6 timers */
> u8 res2[16];
> struct sunxi_avs avs;
> -#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN5I) || 
> defined(CONFIG_MACH_SUN7I)
> +#ifdef CONFIG_ARCH_SUN6I
ditto

Thanks

Michal
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 03/10] sunxi: Introduce a hidden ARCH_SUN6I Kconfig bool

2015-04-15 Thread Michal Suchanek
On 14 April 2015 at 18:06, Hans de Goede  wrote:

> --- a/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h
> +++ b/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h
> @@ -37,7 +37,7 @@
>  #define SUNXI_MMC1_BASE0x01c1
>  #define SUNXI_MMC2_BASE0x01c11000
>  #define SUNXI_MMC3_BASE0x01c12000
> -#if !defined CONFIG_MACH_SUN6I && !defined CONFIG_MACH_SUN8I
> +#ifndef CONFIG_ARCH_SUN6I
>  #define SUNXI_USB0_BASE0x01c13000
>  #define SUNXI_USB1_BASE0x01c14000
>  #endif
> @@ -45,15 +45,15 @@
>  #define SUNXI_HDMI_BASE0x01c16000
>  #define SUNXI_SPI2_BASE0x01c17000
>  #define SUNXI_SATA_BASE0x01c18000
> -#if !defined CONFIG_MACH_SUN6I && !defined CONFIG_MACH_SUN8I
> +#ifdef CONFIG_ARCH_SUN6I

Also here #ifndef is changed to #ifdef

Thanks

Michal
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 03/10] sunxi: Introduce a hidden ARCH_SUN6I Kconfig bool

2015-04-14 Thread Hans de Goede
sun6i and newer (derived) SoCs such as the sun8i-a23, sun8i-a33 and sun9i
have a various things in common, like having separate ahb reset control
registers, the SID living inside the pmic, custom pmic busses, new style
watchdog, etc.

This commit introduces a new hidden ARCH_SUN6I Kconfig bool which can be
used to check for these features avoiding the need for an ever growing list
of "#if defined CONFIG_MACH_SUN?I" conditionals as we add support for more
"new style" sunxi SoCs.

Signed-off-by: Hans de Goede 
---
 arch/arm/cpu/armv7/sunxi/board.c| 18 +-
 arch/arm/cpu/armv7/sunxi/cpu_info.c |  2 +-
 arch/arm/cpu/armv7/sunxi/usbc.c |  4 ++--
 arch/arm/include/asm/arch-sunxi/cpu_sun4i.h | 12 ++--
 arch/arm/include/asm/arch-sunxi/mmc.h   |  3 +--
 arch/arm/include/asm/arch-sunxi/timer.h |  8 
 board/sunxi/Kconfig |  9 +
 board/sunxi/gmac.c  |  6 +++---
 drivers/mmc/sunxi_mmc.c |  3 +--
 drivers/video/sunxi_display.c   | 10 +-
 10 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c
index 6471c6b..30d5974 100644
--- a/arch/arm/cpu/armv7/sunxi/board.c
+++ b/arch/arm/cpu/armv7/sunxi/board.c
@@ -173,7 +173,15 @@ void board_init_f(ulong dummy)
 
 void reset_cpu(ulong addr)
 {
-#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN5I) || 
defined(CONFIG_MACH_SUN7I)
+#ifdef CONFIG_ARCH_SUN6I
+   static const struct sunxi_wdog *wdog =
+((struct sunxi_timer_reg *)SUNXI_TIMER_BASE)->wdog;
+
+   /* Set the watchdog for its shortest interval (.5s) and wait */
+   writel(WDT_CFG_RESET, &wdog->cfg);
+   writel(WDT_MODE_EN, &wdog->mode);
+   writel(WDT_CTRL_KEY | WDT_CTRL_RESTART, &wdog->ctl);
+#else
static const struct sunxi_wdog *wdog =
 &((struct sunxi_timer_reg *)SUNXI_TIMER_BASE)->wdog;
 
@@ -185,14 +193,6 @@ void reset_cpu(ulong addr)
/* sun5i sometimes gets stuck without this */
writel(WDT_MODE_RESET_EN | WDT_MODE_EN, &wdog->mode);
}
-#else /* CONFIG_MACH_SUN6I || CONFIG_MACH_SUN8I || .. */
-   static const struct sunxi_wdog *wdog =
-((struct sunxi_timer_reg *)SUNXI_TIMER_BASE)->wdog;
-
-   /* Set the watchdog for its shortest interval (.5s) and wait */
-   writel(WDT_CFG_RESET, &wdog->cfg);
-   writel(WDT_MODE_EN, &wdog->mode);
-   writel(WDT_CTRL_KEY | WDT_CTRL_RESTART, &wdog->ctl);
 #endif
 }
 
diff --git a/arch/arm/cpu/armv7/sunxi/cpu_info.c 
b/arch/arm/cpu/armv7/sunxi/cpu_info.c
index b6cb9de..c3ec20d 100644
--- a/arch/arm/cpu/armv7/sunxi/cpu_info.c
+++ b/arch/arm/cpu/armv7/sunxi/cpu_info.c
@@ -76,7 +76,7 @@ int print_cpuinfo(void)
 
 int sunxi_get_sid(unsigned int *sid)
 {
-#if defined CONFIG_MACH_SUN6I || defined CONFIG_MACH_SUN8I
+#ifdef CONFIG_ARCH_SUN6I
 #ifdef CONFIG_AXP221_POWER
return axp221_get_sid(sid);
 #else
diff --git a/arch/arm/cpu/armv7/sunxi/usbc.c b/arch/arm/cpu/armv7/sunxi/usbc.c
index 80e4fc9..85b3448 100644
--- a/arch/arm/cpu/armv7/sunxi/usbc.c
+++ b/arch/arm/cpu/armv7/sunxi/usbc.c
@@ -218,7 +218,7 @@ void sunxi_usbc_enable(int index)
 
setbits_le32(&ccm->usb_clk_cfg, sunxi_usbc->usb_rst_mask);
setbits_le32(&ccm->ahb_gate0, sunxi_usbc->ahb_clk_mask);
-#if defined CONFIG_MACH_SUN6I || defined CONFIG_MACH_SUN8I
+#ifdef CONFIG_ARCH_SUN6I
setbits_le32(&ccm->ahb_reset0_cfg, sunxi_usbc->ahb_clk_mask);
 #endif
 
@@ -238,7 +238,7 @@ void sunxi_usbc_disable(int index)
if (sunxi_usbc->id != 0)
sunxi_usb_passby(sunxi_usbc, !SUNXI_USB_PASSBY_EN);
 
-#if defined CONFIG_MACH_SUN6I || defined CONFIG_MACH_SUN8I
+#ifdef CONFIG_ARCH_SUN6I
clrbits_le32(&ccm->ahb_reset0_cfg, sunxi_usbc->ahb_clk_mask);
 #endif
clrbits_le32(&ccm->ahb_gate0, sunxi_usbc->ahb_clk_mask);
diff --git a/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h 
b/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h
index dae6069..3360e87 100644
--- a/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h
+++ b/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h
@@ -37,7 +37,7 @@
 #define SUNXI_MMC1_BASE0x01c1
 #define SUNXI_MMC2_BASE0x01c11000
 #define SUNXI_MMC3_BASE0x01c12000
-#if !defined CONFIG_MACH_SUN6I && !defined CONFIG_MACH_SUN8I
+#ifndef CONFIG_ARCH_SUN6I
 #define SUNXI_USB0_BASE0x01c13000
 #define SUNXI_USB1_BASE0x01c14000
 #endif
@@ -45,15 +45,15 @@
 #define SUNXI_HDMI_BASE0x01c16000
 #define SUNXI_SPI2_BASE0x01c17000
 #define SUNXI_SATA_BASE0x01c18000
-#if !defined CONFIG_MACH_SUN6I && !defined CONFIG_MACH_SUN8I
+#ifdef CONFIG_ARCH_SUN6I
+#define SUNXI_USB0_BASE0x01c19000
+#define SUNXI_USB1_BASE