Re: [PATCH 7/8 v2] clocksource/drivers/fttmr010: Merge Moxa into FTTMR010

2017-05-25 Thread Daniel Lezcano
On 19/05/2017 15:58, Linus Walleij wrote:
> On Thu, May 18, 2017 at 10:17 PM, Linus Walleij
>  wrote:
> 
>> This merges the Moxa Art timer driver into the Faraday FTTMR010
>> driver and replaces all Kconfig symbols to use the Faraday
>> driver instead. We are now so similar that the drivers can
>> be merged by just adding a few lines to the Faraday timer.
> 
> OK Daniel, the series is tested clear by Joel and Jonas,
> feel free to merge these patches up to and including this #7
> when you feel they look good.
> 
> Patch #8 I will send to the ARM SoC people pronto.

Hi Linus,

patches 1-7 is applied for 4.13.

I assumed V1 Rob's ack applies also for the V2.

Fixed a trivial conflict with the Kconfig.

Thanks!

  -- Daniel

-- 
  Linaro.org │ Open source software for ARM SoCs

Follow Linaro:   Facebook |
 Twitter |
 Blog



Re: [PATCH 7/8 v2] clocksource/drivers/fttmr010: Merge Moxa into FTTMR010

2017-05-25 Thread Daniel Lezcano
On 19/05/2017 15:58, Linus Walleij wrote:
> On Thu, May 18, 2017 at 10:17 PM, Linus Walleij
>  wrote:
> 
>> This merges the Moxa Art timer driver into the Faraday FTTMR010
>> driver and replaces all Kconfig symbols to use the Faraday
>> driver instead. We are now so similar that the drivers can
>> be merged by just adding a few lines to the Faraday timer.
> 
> OK Daniel, the series is tested clear by Joel and Jonas,
> feel free to merge these patches up to and including this #7
> when you feel they look good.
> 
> Patch #8 I will send to the ARM SoC people pronto.

Hi Linus,

patches 1-7 is applied for 4.13.

I assumed V1 Rob's ack applies also for the V2.

Fixed a trivial conflict with the Kconfig.

Thanks!

  -- Daniel

-- 
  Linaro.org │ Open source software for ARM SoCs

Follow Linaro:   Facebook |
 Twitter |
 Blog



Re: [PATCH 7/8 v2] clocksource/drivers/fttmr010: Merge Moxa into FTTMR010

2017-05-19 Thread Linus Walleij
On Thu, May 18, 2017 at 10:17 PM, Linus Walleij
 wrote:

> This merges the Moxa Art timer driver into the Faraday FTTMR010
> driver and replaces all Kconfig symbols to use the Faraday
> driver instead. We are now so similar that the drivers can
> be merged by just adding a few lines to the Faraday timer.

OK Daniel, the series is tested clear by Joel and Jonas,
feel free to merge these patches up to and including this #7
when you feel they look good.

Patch #8 I will send to the ARM SoC people pronto.

Yours,
Linus Walleij


Re: [PATCH 7/8 v2] clocksource/drivers/fttmr010: Merge Moxa into FTTMR010

2017-05-19 Thread Linus Walleij
On Thu, May 18, 2017 at 10:17 PM, Linus Walleij
 wrote:

> This merges the Moxa Art timer driver into the Faraday FTTMR010
> driver and replaces all Kconfig symbols to use the Faraday
> driver instead. We are now so similar that the drivers can
> be merged by just adding a few lines to the Faraday timer.

OK Daniel, the series is tested clear by Joel and Jonas,
feel free to merge these patches up to and including this #7
when you feel they look good.

Patch #8 I will send to the ARM SoC people pronto.

Yours,
Linus Walleij


Re: [PATCH 7/8 v2] clocksource/drivers/fttmr010: Merge Moxa into FTTMR010

2017-05-19 Thread Jonas Jensen
On 18 May 2017 at 22:17, Linus Walleij  wrote:
> ChangeLog v1->v2:
> - As it appears that the Aspeed timers can only count downwards,
>   augment the code to deal with downward counting clockevent,
>   clock source and sched_clock(), and flag the Aspeed for this
>   mode.

Adding another successful spin from me using v2 of the complete series [1].

[1] 
https://bitbucket.org/Kasreyn/linux-next/commits/78456248df9eeb48c963b574f50c7268713ef0b1
Uncompressing Linux... done, booting the kernel.
[0.00] Booting Linux on physical CPU 0x0
[0.00] Linux version 4.12.0-rc1-next-20170518-00010-g7845624
(i@ildjarn) (gcc version 4.9.1 (crosstool-NG 1.20.0) ) #4486 PREEMPT
Fri May 19 14:04:54 CEST 2017
[0.00] CPU: FA526 [66015261] revision 1 (ARMv4), cr=397f
[0.00] CPU: VIVT data cache, VIVT instruction cache
[0.00] OF: fdt: Machine model: MOXA UC-7112-LX
[0.00] bootconsole [earlycon0] enabled
[0.00] Memory policy: Data cache writeback
[0.00] Built 1 zonelists in Zone order, mobility grouping on.
Total pages: 8128
[0.00] Kernel command line: console=ttyS0,115200n8 earlyprintk
root=/dev/mmcblk0p1 rw rootwait
[0.00] PID hash table entries: 128 (order: -3, 512 bytes)
[0.00] Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
[0.00] Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
[0.00] Memory: 19132K/32768K available (3453K kernel code,
157K rwdata, 728K rodata, 192K init, 8587K bss, 13636K reserved, 0K
cma-reserved)
[0.00] Virtual kernel memory layout:
[0.00] vector  : 0x - 0x1000   (   4 kB)
[0.00] fixmap  : 0xffc0 - 0xfff0   (3072 kB)
[0.00] vmalloc : 0xc280 - 0xff80   ( 976 MB)
[0.00] lowmem  : 0xc000 - 0xc200   (  32 MB)
[0.00]   .text : 0xc0008000 - 0xc0367910   (3455 kB)
[0.00]   .init : 0xc043a000 - 0xc046a000   ( 192 kB)
[0.00]   .data : 0xc046a000 - 0xc0491560   ( 158 kB)
[0.00].bss : 0xc0495cdc - 0xc0cf8c4c   (8588 kB)
[0.00] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[0.00] Running RCU self tests
[0.00] Preemptible hierarchical RCU implementation.
[0.00] RCU lockdep checking is enabled.
[0.00] NR_IRQS:16 nr_irqs:16 16
[0.00] clocksource: FTTMR010-TIMER2: mask: 0x
max_cycles: 0x, max_idle_ns: 39817925974 ns
[0.89] sched_clock: 32 bits at 48MHz, resolution 20ns, wraps
every 44739242997ns
[0.009440] Lock dependency validator: Copyright (c) 2006 Red Hat,
Inc., Ingo Molnar
[0.017790] ... MAX_LOCKDEP_SUBCLASSES:  8
[0.024511] ... MAX_LOCK_DEPTH:  48
[0.029422] ... MAX_LOCKDEP_KEYS:8191
[0.034102] ... CLASSHASH_SIZE:  4096
[0.039125] ... MAX_LOCKDEP_ENTRIES: 32768
[0.043886] ... MAX_LOCKDEP_CHAINS:  65536
[0.048627] ... CHAINHASH_SIZE:  32768
[0.053753]  memory used by lock dependency info: 5167 kB
[0.059859]  per task-struct memory footprint: 1536 bytes
[0.072501] kmemleak: Kernel memory leak detector disabled
[0.090759] kmemleak: Early log buffer exceeded (1229), please
increase DEBUG_KMEMLEAK_EARLY_LOG_SIZE
[0.100997] Calibrating delay loop... 143.76 BogoMIPS (lpj=718848)
[0.175633] pid_max: default: 4096 minimum: 301
[0.183379] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[0.191120] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[0.217285] CPU: Testing write buffer coherency: ok
[0.249546] Setting up static identity map for 0x8200 - 0x8248
[0.261082] Hierarchical SRCU implementation.
[0.329338] devtmpfs: initialized
[0.409206] DMA-API: preallocated 4096 debug entries
[0.414554] DMA-API: debugging enabled by kernel config
[0.445030] kworker/u2:0 (14) used greatest stack depth: 6224 bytes left
[0.455985] clocksource: jiffies: mask: 0x max_cycles:
0x, max_idle_ns: 1911260446275 ns
[0.467884] futex hash table entries: 16 (order: -3, 704 bytes)
[0.497799] NET: Registered protocol family 16
[0.517950] DMA: preallocated 256 KiB pool for atomic coherent allocations
[0.557803] kworker/u2:1 (17) used greatest stack depth: 5856 bytes left
[1.316981] clocksource: Switched to clocksource FTTMR010-TIMER2
[1.415454] NET: Registered protocol family 2
[1.440312] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[1.449574] TCP bind hash table entries: 1024 (order: 3, 36864 bytes)
[1.460123] TCP: Hash tables configured (established 1024 bind 1024)
[1.471541] UDP hash table entries: 128 (order: 1, 10240 bytes)
[1.479360] UDP-Lite hash table entries: 128 (order: 1, 10240 bytes)
[1.493097] NET: Registered protocol family 1
[1.545526] workingset: timestamp_bits=30 max_order=13 bucket_order=0
[2.049607] 

Re: [PATCH 7/8 v2] clocksource/drivers/fttmr010: Merge Moxa into FTTMR010

2017-05-19 Thread Jonas Jensen
On 18 May 2017 at 22:17, Linus Walleij  wrote:
> ChangeLog v1->v2:
> - As it appears that the Aspeed timers can only count downwards,
>   augment the code to deal with downward counting clockevent,
>   clock source and sched_clock(), and flag the Aspeed for this
>   mode.

Adding another successful spin from me using v2 of the complete series [1].

[1] 
https://bitbucket.org/Kasreyn/linux-next/commits/78456248df9eeb48c963b574f50c7268713ef0b1
Uncompressing Linux... done, booting the kernel.
[0.00] Booting Linux on physical CPU 0x0
[0.00] Linux version 4.12.0-rc1-next-20170518-00010-g7845624
(i@ildjarn) (gcc version 4.9.1 (crosstool-NG 1.20.0) ) #4486 PREEMPT
Fri May 19 14:04:54 CEST 2017
[0.00] CPU: FA526 [66015261] revision 1 (ARMv4), cr=397f
[0.00] CPU: VIVT data cache, VIVT instruction cache
[0.00] OF: fdt: Machine model: MOXA UC-7112-LX
[0.00] bootconsole [earlycon0] enabled
[0.00] Memory policy: Data cache writeback
[0.00] Built 1 zonelists in Zone order, mobility grouping on.
Total pages: 8128
[0.00] Kernel command line: console=ttyS0,115200n8 earlyprintk
root=/dev/mmcblk0p1 rw rootwait
[0.00] PID hash table entries: 128 (order: -3, 512 bytes)
[0.00] Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
[0.00] Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
[0.00] Memory: 19132K/32768K available (3453K kernel code,
157K rwdata, 728K rodata, 192K init, 8587K bss, 13636K reserved, 0K
cma-reserved)
[0.00] Virtual kernel memory layout:
[0.00] vector  : 0x - 0x1000   (   4 kB)
[0.00] fixmap  : 0xffc0 - 0xfff0   (3072 kB)
[0.00] vmalloc : 0xc280 - 0xff80   ( 976 MB)
[0.00] lowmem  : 0xc000 - 0xc200   (  32 MB)
[0.00]   .text : 0xc0008000 - 0xc0367910   (3455 kB)
[0.00]   .init : 0xc043a000 - 0xc046a000   ( 192 kB)
[0.00]   .data : 0xc046a000 - 0xc0491560   ( 158 kB)
[0.00].bss : 0xc0495cdc - 0xc0cf8c4c   (8588 kB)
[0.00] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[0.00] Running RCU self tests
[0.00] Preemptible hierarchical RCU implementation.
[0.00] RCU lockdep checking is enabled.
[0.00] NR_IRQS:16 nr_irqs:16 16
[0.00] clocksource: FTTMR010-TIMER2: mask: 0x
max_cycles: 0x, max_idle_ns: 39817925974 ns
[0.89] sched_clock: 32 bits at 48MHz, resolution 20ns, wraps
every 44739242997ns
[0.009440] Lock dependency validator: Copyright (c) 2006 Red Hat,
Inc., Ingo Molnar
[0.017790] ... MAX_LOCKDEP_SUBCLASSES:  8
[0.024511] ... MAX_LOCK_DEPTH:  48
[0.029422] ... MAX_LOCKDEP_KEYS:8191
[0.034102] ... CLASSHASH_SIZE:  4096
[0.039125] ... MAX_LOCKDEP_ENTRIES: 32768
[0.043886] ... MAX_LOCKDEP_CHAINS:  65536
[0.048627] ... CHAINHASH_SIZE:  32768
[0.053753]  memory used by lock dependency info: 5167 kB
[0.059859]  per task-struct memory footprint: 1536 bytes
[0.072501] kmemleak: Kernel memory leak detector disabled
[0.090759] kmemleak: Early log buffer exceeded (1229), please
increase DEBUG_KMEMLEAK_EARLY_LOG_SIZE
[0.100997] Calibrating delay loop... 143.76 BogoMIPS (lpj=718848)
[0.175633] pid_max: default: 4096 minimum: 301
[0.183379] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[0.191120] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[0.217285] CPU: Testing write buffer coherency: ok
[0.249546] Setting up static identity map for 0x8200 - 0x8248
[0.261082] Hierarchical SRCU implementation.
[0.329338] devtmpfs: initialized
[0.409206] DMA-API: preallocated 4096 debug entries
[0.414554] DMA-API: debugging enabled by kernel config
[0.445030] kworker/u2:0 (14) used greatest stack depth: 6224 bytes left
[0.455985] clocksource: jiffies: mask: 0x max_cycles:
0x, max_idle_ns: 1911260446275 ns
[0.467884] futex hash table entries: 16 (order: -3, 704 bytes)
[0.497799] NET: Registered protocol family 16
[0.517950] DMA: preallocated 256 KiB pool for atomic coherent allocations
[0.557803] kworker/u2:1 (17) used greatest stack depth: 5856 bytes left
[1.316981] clocksource: Switched to clocksource FTTMR010-TIMER2
[1.415454] NET: Registered protocol family 2
[1.440312] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[1.449574] TCP bind hash table entries: 1024 (order: 3, 36864 bytes)
[1.460123] TCP: Hash tables configured (established 1024 bind 1024)
[1.471541] UDP hash table entries: 128 (order: 1, 10240 bytes)
[1.479360] UDP-Lite hash table entries: 128 (order: 1, 10240 bytes)
[1.493097] NET: Registered protocol family 1
[1.545526] workingset: timestamp_bits=30 max_order=13 bucket_order=0
[2.049607] jffs2: version 2.2. (NAND) 

Re: [PATCH 7/8 v2] clocksource/drivers/fttmr010: Merge Moxa into FTTMR010

2017-05-18 Thread Joel Stanley
On Fri, May 19, 2017 at 4:17 AM, Linus Walleij  wrote:
> This merges the Moxa Art timer driver into the Faraday FTTMR010
> driver and replaces all Kconfig symbols to use the Faraday
> driver instead. We are now so similar that the drivers can
> be merged by just adding a few lines to the Faraday timer.
>
> Differences:
>
> - The Faraday driver explicitly sets the counter to count
>   upwards for the clocksource, removing the need for the
>   clocksource core to invert the value.
>
> - The Faraday driver also handles sched_clock()
>
> On the Aspeed, the counter can only count downwards, so support
> the timers in downward-counting mode as well, and flag the
> Aspeed to use this mode. This mode was tested on the Gemini so
> I have high hopes that it'll work fine on the Aspeed as well.
>
> After this we have one driver for all three SoCs and a generic
> Faraday FTTMR010 timer driver, which is nice.
>
> Cc: Joel Stanley 
> Cc: Jonas Jensen 
> Signed-off-by: Linus Walleij 
> ---
> ChangeLog v1->v2:
> - As it appears that the Aspeed timers can only count downwards,
>   augment the code to deal with downward counting clockevent,
>   clock source and sched_clock(), and flag the Aspeed for this
>   mode.
>
> ARM SoC folks: please ACK this so it can be merged with in the
> clocksource subsystem once it works.
>
> Joel: it would be super if you can test this. If you have some
> vendor tree or similar that actually indicates where the
> up/down counter bits are it's even better, but I'm hoping that
> this half-assed guesswork will JustWork(TM) (yeah, famous
> last words, sorry...)

I gave it a spin on the ast2500-evb and it worked for me.

I also gave it a read through and it looks good. I'd lowercase the
shouty FTTMR010-TIMER message that pops up during boot, but it's no
biggie.

Reviewed-by: Joel Stanley 
Tested-by: Joel Stanley 

Cheers,

Joel


Re: [PATCH 7/8 v2] clocksource/drivers/fttmr010: Merge Moxa into FTTMR010

2017-05-18 Thread Joel Stanley
On Fri, May 19, 2017 at 4:17 AM, Linus Walleij  wrote:
> This merges the Moxa Art timer driver into the Faraday FTTMR010
> driver and replaces all Kconfig symbols to use the Faraday
> driver instead. We are now so similar that the drivers can
> be merged by just adding a few lines to the Faraday timer.
>
> Differences:
>
> - The Faraday driver explicitly sets the counter to count
>   upwards for the clocksource, removing the need for the
>   clocksource core to invert the value.
>
> - The Faraday driver also handles sched_clock()
>
> On the Aspeed, the counter can only count downwards, so support
> the timers in downward-counting mode as well, and flag the
> Aspeed to use this mode. This mode was tested on the Gemini so
> I have high hopes that it'll work fine on the Aspeed as well.
>
> After this we have one driver for all three SoCs and a generic
> Faraday FTTMR010 timer driver, which is nice.
>
> Cc: Joel Stanley 
> Cc: Jonas Jensen 
> Signed-off-by: Linus Walleij 
> ---
> ChangeLog v1->v2:
> - As it appears that the Aspeed timers can only count downwards,
>   augment the code to deal with downward counting clockevent,
>   clock source and sched_clock(), and flag the Aspeed for this
>   mode.
>
> ARM SoC folks: please ACK this so it can be merged with in the
> clocksource subsystem once it works.
>
> Joel: it would be super if you can test this. If you have some
> vendor tree or similar that actually indicates where the
> up/down counter bits are it's even better, but I'm hoping that
> this half-assed guesswork will JustWork(TM) (yeah, famous
> last words, sorry...)

I gave it a spin on the ast2500-evb and it worked for me.

I also gave it a read through and it looks good. I'd lowercase the
shouty FTTMR010-TIMER message that pops up during boot, but it's no
biggie.

Reviewed-by: Joel Stanley 
Tested-by: Joel Stanley 

Cheers,

Joel


[PATCH 7/8 v2] clocksource/drivers/fttmr010: Merge Moxa into FTTMR010

2017-05-18 Thread Linus Walleij
This merges the Moxa Art timer driver into the Faraday FTTMR010
driver and replaces all Kconfig symbols to use the Faraday
driver instead. We are now so similar that the drivers can
be merged by just adding a few lines to the Faraday timer.

Differences:

- The Faraday driver explicitly sets the counter to count
  upwards for the clocksource, removing the need for the
  clocksource core to invert the value.

- The Faraday driver also handles sched_clock()

On the Aspeed, the counter can only count downwards, so support
the timers in downward-counting mode as well, and flag the
Aspeed to use this mode. This mode was tested on the Gemini so
I have high hopes that it'll work fine on the Aspeed as well.

After this we have one driver for all three SoCs and a generic
Faraday FTTMR010 timer driver, which is nice.

Cc: Joel Stanley 
Cc: Jonas Jensen 
Signed-off-by: Linus Walleij 
---
ChangeLog v1->v2:
- As it appears that the Aspeed timers can only count downwards,
  augment the code to deal with downward counting clockevent,
  clock source and sched_clock(), and flag the Aspeed for this
  mode.

ARM SoC folks: please ACK this so it can be merged with in the
clocksource subsystem once it works.

Joel: it would be super if you can test this. If you have some
vendor tree or similar that actually indicates where the
up/down counter bits are it's even better, but I'm hoping that
this half-assed guesswork will JustWork(TM) (yeah, famous
last words, sorry...)
---
 arch/arm/mach-aspeed/Kconfig |   2 +-
 arch/arm/mach-moxart/Kconfig |   2 +-
 drivers/clocksource/Kconfig  |   7 -
 drivers/clocksource/Makefile |   1 -
 drivers/clocksource/moxart_timer.c   | 256 ---
 drivers/clocksource/timer-fttmr010.c | 143 ++-
 6 files changed, 108 insertions(+), 303 deletions(-)
 delete mode 100644 drivers/clocksource/moxart_timer.c

diff --git a/arch/arm/mach-aspeed/Kconfig b/arch/arm/mach-aspeed/Kconfig
index f3f8c5c658db..2d5570e6e186 100644
--- a/arch/arm/mach-aspeed/Kconfig
+++ b/arch/arm/mach-aspeed/Kconfig
@@ -4,7 +4,7 @@ menuconfig ARCH_ASPEED
select SRAM
select WATCHDOG
select ASPEED_WATCHDOG
-   select MOXART_TIMER
+   select FTTMR010_TIMER
select MFD_SYSCON
select PINCTRL
help
diff --git a/arch/arm/mach-moxart/Kconfig b/arch/arm/mach-moxart/Kconfig
index 70db2abf6163..a4a91f9a3301 100644
--- a/arch/arm/mach-moxart/Kconfig
+++ b/arch/arm/mach-moxart/Kconfig
@@ -4,7 +4,7 @@ menuconfig ARCH_MOXART
select CPU_FA526
select ARM_DMA_MEM_BUFFERABLE
select FARADAY_FTINTC010
-   select MOXART_TIMER
+   select FTTMR010_TIMER
select GPIOLIB
select PHYLIB if NETDEVICES
help
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 545d541ae20e..1b22ade4c8f1 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -188,13 +188,6 @@ config ATLAS7_TIMER
help
  Enables support for the Atlas7 timer.
 
-config MOXART_TIMER
-   bool "Moxart timer driver" if COMPILE_TEST
-   depends on GENERIC_CLOCKEVENTS
-   select CLKSRC_MMIO
-   help
- Enables support for the Moxart timer.
-
 config MXS_TIMER
bool "Mxs timer driver" if COMPILE_TEST
depends on GENERIC_CLOCKEVENTS
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 2b5b56a6f00f..cf0c30b6ec1f 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -26,7 +26,6 @@ obj-$(CONFIG_ORION_TIMER) += time-orion.o
 obj-$(CONFIG_BCM2835_TIMER)+= bcm2835_timer.o
 obj-$(CONFIG_CLPS711X_TIMER)   += clps711x-timer.o
 obj-$(CONFIG_ATLAS7_TIMER) += timer-atlas7.o
-obj-$(CONFIG_MOXART_TIMER) += moxart_timer.o
 obj-$(CONFIG_MXS_TIMER)+= mxs_timer.o
 obj-$(CONFIG_CLKSRC_PXA)   += pxa_timer.o
 obj-$(CONFIG_PRIMA2_TIMER) += timer-prima2.o
diff --git a/drivers/clocksource/moxart_timer.c 
b/drivers/clocksource/moxart_timer.c
deleted file mode 100644
index 7f3430654fbd..
--- a/drivers/clocksource/moxart_timer.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * MOXA ART SoCs timer handling.
- *
- * Copyright (C) 2013 Jonas Jensen
- *
- * Jonas Jensen 
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2.  This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#define TIMER1_BASE0x00
-#define TIMER2_BASE0x10
-#define TIMER3_BASE0x20
-
-#define REG_COUNT  0x0 /* writable */
-#define REG_LOAD   0x4
-#define REG_MATCH1 0x8
-#define REG_MATCH2 0xC
-
-#define 

[PATCH 7/8 v2] clocksource/drivers/fttmr010: Merge Moxa into FTTMR010

2017-05-18 Thread Linus Walleij
This merges the Moxa Art timer driver into the Faraday FTTMR010
driver and replaces all Kconfig symbols to use the Faraday
driver instead. We are now so similar that the drivers can
be merged by just adding a few lines to the Faraday timer.

Differences:

- The Faraday driver explicitly sets the counter to count
  upwards for the clocksource, removing the need for the
  clocksource core to invert the value.

- The Faraday driver also handles sched_clock()

On the Aspeed, the counter can only count downwards, so support
the timers in downward-counting mode as well, and flag the
Aspeed to use this mode. This mode was tested on the Gemini so
I have high hopes that it'll work fine on the Aspeed as well.

After this we have one driver for all three SoCs and a generic
Faraday FTTMR010 timer driver, which is nice.

Cc: Joel Stanley 
Cc: Jonas Jensen 
Signed-off-by: Linus Walleij 
---
ChangeLog v1->v2:
- As it appears that the Aspeed timers can only count downwards,
  augment the code to deal with downward counting clockevent,
  clock source and sched_clock(), and flag the Aspeed for this
  mode.

ARM SoC folks: please ACK this so it can be merged with in the
clocksource subsystem once it works.

Joel: it would be super if you can test this. If you have some
vendor tree or similar that actually indicates where the
up/down counter bits are it's even better, but I'm hoping that
this half-assed guesswork will JustWork(TM) (yeah, famous
last words, sorry...)
---
 arch/arm/mach-aspeed/Kconfig |   2 +-
 arch/arm/mach-moxart/Kconfig |   2 +-
 drivers/clocksource/Kconfig  |   7 -
 drivers/clocksource/Makefile |   1 -
 drivers/clocksource/moxart_timer.c   | 256 ---
 drivers/clocksource/timer-fttmr010.c | 143 ++-
 6 files changed, 108 insertions(+), 303 deletions(-)
 delete mode 100644 drivers/clocksource/moxart_timer.c

diff --git a/arch/arm/mach-aspeed/Kconfig b/arch/arm/mach-aspeed/Kconfig
index f3f8c5c658db..2d5570e6e186 100644
--- a/arch/arm/mach-aspeed/Kconfig
+++ b/arch/arm/mach-aspeed/Kconfig
@@ -4,7 +4,7 @@ menuconfig ARCH_ASPEED
select SRAM
select WATCHDOG
select ASPEED_WATCHDOG
-   select MOXART_TIMER
+   select FTTMR010_TIMER
select MFD_SYSCON
select PINCTRL
help
diff --git a/arch/arm/mach-moxart/Kconfig b/arch/arm/mach-moxart/Kconfig
index 70db2abf6163..a4a91f9a3301 100644
--- a/arch/arm/mach-moxart/Kconfig
+++ b/arch/arm/mach-moxart/Kconfig
@@ -4,7 +4,7 @@ menuconfig ARCH_MOXART
select CPU_FA526
select ARM_DMA_MEM_BUFFERABLE
select FARADAY_FTINTC010
-   select MOXART_TIMER
+   select FTTMR010_TIMER
select GPIOLIB
select PHYLIB if NETDEVICES
help
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 545d541ae20e..1b22ade4c8f1 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -188,13 +188,6 @@ config ATLAS7_TIMER
help
  Enables support for the Atlas7 timer.
 
-config MOXART_TIMER
-   bool "Moxart timer driver" if COMPILE_TEST
-   depends on GENERIC_CLOCKEVENTS
-   select CLKSRC_MMIO
-   help
- Enables support for the Moxart timer.
-
 config MXS_TIMER
bool "Mxs timer driver" if COMPILE_TEST
depends on GENERIC_CLOCKEVENTS
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 2b5b56a6f00f..cf0c30b6ec1f 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -26,7 +26,6 @@ obj-$(CONFIG_ORION_TIMER) += time-orion.o
 obj-$(CONFIG_BCM2835_TIMER)+= bcm2835_timer.o
 obj-$(CONFIG_CLPS711X_TIMER)   += clps711x-timer.o
 obj-$(CONFIG_ATLAS7_TIMER) += timer-atlas7.o
-obj-$(CONFIG_MOXART_TIMER) += moxart_timer.o
 obj-$(CONFIG_MXS_TIMER)+= mxs_timer.o
 obj-$(CONFIG_CLKSRC_PXA)   += pxa_timer.o
 obj-$(CONFIG_PRIMA2_TIMER) += timer-prima2.o
diff --git a/drivers/clocksource/moxart_timer.c 
b/drivers/clocksource/moxart_timer.c
deleted file mode 100644
index 7f3430654fbd..
--- a/drivers/clocksource/moxart_timer.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * MOXA ART SoCs timer handling.
- *
- * Copyright (C) 2013 Jonas Jensen
- *
- * Jonas Jensen 
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2.  This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#define TIMER1_BASE0x00
-#define TIMER2_BASE0x10
-#define TIMER3_BASE0x20
-
-#define REG_COUNT  0x0 /* writable */
-#define REG_LOAD   0x4
-#define REG_MATCH1 0x8
-#define REG_MATCH2 0xC
-
-#define TIMER_CR   0x30
-#define TIMER_INTR_STATE   0x34
-#define TIMER_INTR_MASK