All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/58] ARM: at91: rework Atmel TCB drivers
@ 2017-05-30 21:50 ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Antoine Aubert, Daniel Lezcano, devicetree,
	Douglas Gilbert, Fabio Porcedda, Gregory CLEMENT,
	Gregory Hermant, Joachim Eastwood, linux-pwm, Marek Vasut,
	Martin Reimann, Peter Rosin, Raashid Muhammed, Rob Herring,
	Rodolfo Giometti, Sergio Tanzilli, Thierry Reding,
	Thomas Gleixner, Tim Schendekehl

Hi,

This series reworks the Atmel Timer counter Block drivers. Those blocks
each have 3 counters with 2 channels each and can be used for
multiple functions:
 - timers
 - PWMs
 - Quadrature decoders
 - Stepper motor counters

Up until now, each TCB was fully used by each driver, possibly wasting
counters/channels.

There is a second issue motivating that rework. Until now, the PIT is
still used to boot then later in the boot sequence, the clocksource is
switched to the TCB. This ends up not working well with preempt-rt
because on some SoCs, the PIT interrupt is shared with the DBGU uart.
When using preempt-rt the interrupt flags for the PIT and the DBGU end
up being incompatible.

The rework breaks the DT ABI. Backward compatibility can be kept by
keeping tcb_clksrc and atmel_tclib but as AVR32 is now gone from the
kernel, I don't think it makes much sense to keep them.

Also, there is no other choice than breaking the mainly unused
pwm-atmel-tcb binding. Only the kizbox is actually using it.

I think the bindings are now ok and I hope we can take the DT changes
for 4.13.

Cc: Antoine Aubert <a.aubert@overkiz.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: devicetree@vger.kernel.org
Cc: Douglas Gilbert <dgilbert@interlog.com>
Cc: Fabio Porcedda <fabio.porcedda@gmail.com>
Cc: Gregory CLEMENT <gregory.clement@free-electrons.com>
Cc: Gregory Hermant <gregory.hermant@calao-systems.com>
Cc: Joachim Eastwood <manabian@gmail.com>
Cc: linux-pwm@vger.kernel.org
Cc: Marek Vasut <marex@denx.de>
Cc: Martin Reimann <martin.reimann@egnite.de>
Cc: Peter Rosin <peda@axentia.se>
Cc: Raashid Muhammed <raashidmuhammed@zilogic.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Rodolfo Giometti <giometti@linux.it>
Cc: Sergio Tanzilli <tanzilli@acmesystems.it>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tim Schendekehl <tim.schendekehl@egnite.de>

Alexandre Belloni (58):
  ARM: at91: Document new TCB bindings
  ARM: dts: at91: at91rm9200: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91rm9200ek: use TCB0 as clocksource
  ARM: dts: at91: mpa1600: use TCB0 as clocksource
  ARM: dts: at91: at91sam9260: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9260ek: use TCB0 as clocksource
  ARM: dts: at91: sam9_l9260: use TCB0 as clocksource
  ARM: dts: at91: ethernut5: use TCB0 as clocksource
  ARM: dts: at91: foxg20: use TCB0 as clocksource
  ARM: dts: at91: animeo_ip: use TCB0 as clocksource
  ARM: dts: at91: kizbox: use TCB0 as clocksource
  ARM: dts: at91: at91sam9g20ek: use TCB0 as clocksource
  ARM: dts: at91: ge863-pro3: use TCB0 as clocksource
  ARM: dts: at91: at91sam9261: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9261ek: use TCB0 as clocksource
  ARM: dts: at91: at91sam9263: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9263ek: use TCB0 as clocksource
  ARM: dts: at91: calao: use TCB0 as clocksource
  ARM: dts: at91: at91sam9g45: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9m10g45ek: use TCB0 as clocksource
  ARM: dts: at91: pm9g45: use TCB0 as clocksource
  ARM: dts: at91: at91sam9rl: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9rlek: use TCB0 as clocksource
  ARM: dts: at91: at91sam9n12: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9n12ek: use TCB0 as clocksource
  ARM: dts: at91: at91sam9x5: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9x5cm: use TCB0 as clocksource
  ARM: dts: at91: acme/g25: use TCB0 as clocksource
  ARM: dts: at91: cosino: use TCB0 as clocksource
  ARM: dts: at91: kizboxmini: use TCB0 as clocksource
  ARM: dts: at91: sama5d3: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: sama5d3xek: use TCB0 as clocksource
  ARM: dts: at91: sama5d3 Xplained: use TCB0 as clocksource
  ARM: dts: at91: kizbox2: use TCB0 as clocksource
  ARM: dts: at91: sama5d3xek_cmp: use TCB0 as clocksource
  ARM: dts: at91: linea/tse850-3: use TCB0 as clocksource
  ARM: dts: at91: sama5d4: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: sama5d4: Add TCB2
  ARM: dts: at91: sama5d4ek: use TCB2 as clocksource
  ARM: dts: at91: sama5d4 Xplained: use TCB2 as clocksource
  ARM: dts: at91: ma5d4: use TCB2 as clocksource
  ARM: dts: at91: vinco: use TCB2 as clocksource
  ARM: dts: at91: sama5d2: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: sama5d2 Xplained: use TCB0 as clocksource
  ARM: at91: add TCB registers definitions
  clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  clocksource/drivers: timer-atmel-tcbclksrc: add clockevent device
  clocksource/drivers: timer-atmel-tcbclksrc: add clockevent device on
    separate channel
  clocksource/drivers: atmel-pit: allow unselecting ATMEL_PIT
  ARM: at91/defconfig: sama5: unselect ATMEL_PIT
  ARM: at91/defconfig: at91_dt unselect ATMEL_PIT
  PWM: atmel-tcb: switch to new binding
  ARM: dts: at91: kizbox: switch to new pwm-atmel-tcb binding
  clocksource/drivers: remove tcb_clksrc
  misc: remove atmel_tclib.c
  ARM: configs: at91: remove ATMEL_TCLIB
  ARM: multi_v7_defconfig: Remove ATMEL_TCLIB Kconfig symbol
  ARM: multi_v5_defconfig: Remove ATMEL_TCLIB Kconfig symbol

 .../devicetree/bindings/arm/atmel-at91.txt         |  32 --
 .../devicetree/bindings/mfd/atmel-tcb.txt          |  58 +++
 .../devicetree/bindings/pwm/atmel-tcb-pwm.txt      |  12 +-
 arch/arm/boot/dts/animeo_ip.dts                    |  12 +
 arch/arm/boot/dts/at91-ariag25.dts                 |  12 +
 arch/arm/boot/dts/at91-ariettag25.dts              |  12 +
 arch/arm/boot/dts/at91-cosino.dtsi                 |  12 +
 arch/arm/boot/dts/at91-foxg20.dts                  |  12 +
 arch/arm/boot/dts/at91-kizbox.dts                  |  54 ++-
 arch/arm/boot/dts/at91-kizbox2.dts                 |  12 +
 arch/arm/boot/dts/at91-kizboxmini.dts              |  12 +
 arch/arm/boot/dts/at91-linea.dtsi                  |  12 +
 arch/arm/boot/dts/at91-qil_a9260.dts               |  12 +
 arch/arm/boot/dts/at91-sam9_l9260.dts              |  12 +
 arch/arm/boot/dts/at91-sama5d2_xplained.dts        |  12 +
 arch/arm/boot/dts/at91-sama5d3_xplained.dts        |  12 +
 arch/arm/boot/dts/at91-sama5d4_ma5d4.dtsi          |  12 +
 arch/arm/boot/dts/at91-sama5d4_xplained.dts        |  12 +
 arch/arm/boot/dts/at91-sama5d4ek.dts               |  12 +
 arch/arm/boot/dts/at91-vinco.dts                   |  12 +
 arch/arm/boot/dts/at91rm9200.dtsi                  |   8 +-
 arch/arm/boot/dts/at91rm9200ek.dts                 |  12 +
 arch/arm/boot/dts/at91sam9260.dtsi                 |   8 +-
 arch/arm/boot/dts/at91sam9260ek.dts                |  12 +
 arch/arm/boot/dts/at91sam9261.dtsi                 |   4 +-
 arch/arm/boot/dts/at91sam9261ek.dts                |  12 +
 arch/arm/boot/dts/at91sam9263.dtsi                 |   4 +-
 arch/arm/boot/dts/at91sam9263ek.dts                |  12 +
 arch/arm/boot/dts/at91sam9g20ek_common.dtsi        |  12 +
 arch/arm/boot/dts/at91sam9g45.dtsi                 |   8 +-
 arch/arm/boot/dts/at91sam9m10g45ek.dts             |  12 +
 arch/arm/boot/dts/at91sam9n12.dtsi                 |   8 +-
 arch/arm/boot/dts/at91sam9n12ek.dts                |  12 +
 arch/arm/boot/dts/at91sam9rl.dtsi                  |   4 +-
 arch/arm/boot/dts/at91sam9rlek.dts                 |  12 +
 arch/arm/boot/dts/at91sam9x5.dtsi                  |   8 +-
 arch/arm/boot/dts/at91sam9x5cm.dtsi                |  12 +
 arch/arm/boot/dts/ethernut5.dts                    |  12 +
 arch/arm/boot/dts/ge863-pro3.dtsi                  |  12 +
 arch/arm/boot/dts/mpa1600.dts                      |  12 +
 arch/arm/boot/dts/pm9g45.dts                       |  12 +
 arch/arm/boot/dts/sama5d2.dtsi                     |   8 +-
 arch/arm/boot/dts/sama5d3.dtsi                     |   4 +-
 arch/arm/boot/dts/sama5d3_tcb1.dtsi                |   4 +-
 arch/arm/boot/dts/sama5d3xcm.dtsi                  |  12 +
 arch/arm/boot/dts/sama5d3xcm_cmp.dtsi              |  12 +
 arch/arm/boot/dts/sama5d4.dtsi                     |  18 +-
 arch/arm/boot/dts/tny_a9260_common.dtsi            |  12 +
 arch/arm/boot/dts/tny_a9263.dts                    |  12 +
 arch/arm/boot/dts/usb_a9260_common.dtsi            |  12 +
 arch/arm/boot/dts/usb_a9263.dts                    |  12 +
 arch/arm/configs/at91_dt_defconfig                 |   2 +-
 arch/arm/configs/multi_v5_defconfig                |   1 -
 arch/arm/configs/multi_v7_defconfig                |   1 -
 arch/arm/configs/sama5_defconfig                   |   2 +-
 drivers/clocksource/Kconfig                        |  22 +-
 drivers/clocksource/Makefile                       |   2 +-
 drivers/clocksource/tcb_clksrc.c                   | 381 ----------------
 drivers/clocksource/timer-atmel-tcbclksrc.c        | 502 +++++++++++++++++++++
 drivers/misc/Kconfig                               |  33 --
 drivers/misc/Makefile                              |   1 -
 drivers/misc/atmel_tclib.c                         | 198 --------
 drivers/pwm/Kconfig                                |   3 +-
 drivers/pwm/pwm-atmel-tcb.c                        | 221 ++++-----
 include/linux/atmel_tc.h                           |   9 -
 include/soc/at91/atmel_tcb.h                       | 229 ++++++++++
 66 files changed, 1468 insertions(+), 801 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/atmel-tcb.txt
 delete mode 100644 drivers/clocksource/tcb_clksrc.c
 create mode 100644 drivers/clocksource/timer-atmel-tcbclksrc.c
 delete mode 100644 drivers/misc/atmel_tclib.c
 create mode 100644 include/soc/at91/atmel_tcb.h

-- 
2.11.0

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 00/58] ARM: at91: rework Atmel TCB drivers
@ 2017-05-30 21:50 ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Alexandre Belloni,
	Antoine Aubert, Daniel Lezcano,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Douglas Gilbert,
	Fabio Porcedda, Gregory CLEMENT, Gregory Hermant,
	Joachim Eastwood, linux-pwm-u79uwXL29TY76Z2rM5mHXA, Marek Vasut,
	Martin Reimann, Peter Rosin, Raashid Muhammed, Rob Herring,
	Rodolfo Giometti

Hi,

This series reworks the Atmel Timer counter Block drivers. Those blocks
each have 3 counters with 2 channels each and can be used for
multiple functions:
 - timers
 - PWMs
 - Quadrature decoders
 - Stepper motor counters

Up until now, each TCB was fully used by each driver, possibly wasting
counters/channels.

There is a second issue motivating that rework. Until now, the PIT is
still used to boot then later in the boot sequence, the clocksource is
switched to the TCB. This ends up not working well with preempt-rt
because on some SoCs, the PIT interrupt is shared with the DBGU uart.
When using preempt-rt the interrupt flags for the PIT and the DBGU end
up being incompatible.

The rework breaks the DT ABI. Backward compatibility can be kept by
keeping tcb_clksrc and atmel_tclib but as AVR32 is now gone from the
kernel, I don't think it makes much sense to keep them.

Also, there is no other choice than breaking the mainly unused
pwm-atmel-tcb binding. Only the kizbox is actually using it.

I think the bindings are now ok and I hope we can take the DT changes
for 4.13.

Cc: Antoine Aubert <a.aubert-ZNYIgs0QAGpBDgjK7y7TUQ@public.gmane.org>
Cc: Daniel Lezcano <daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Douglas Gilbert <dgilbert-qazKcTl6WRFWk0Htik3J/w@public.gmane.org>
Cc: Fabio Porcedda <fabio.porcedda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Gregory CLEMENT <gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Cc: Gregory Hermant <gregory.hermant-WVCdZa36k+6/3pe1ocb+swC/G2K4zDHf@public.gmane.org>
Cc: Joachim Eastwood <manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-pwm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>
Cc: Martin Reimann <martin.reimann-inJ12LbcDfezQB+pC5nmwQ@public.gmane.org>
Cc: Peter Rosin <peda-koto5C5qi+TLoDKTGw+V6w@public.gmane.org>
Cc: Raashid Muhammed <raashidmuhammed-1MQmoylvZ5VBDgjK7y7TUQ@public.gmane.org>
Cc: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Rodolfo Giometti <giometti-k2GhghHVRtY@public.gmane.org>
Cc: Sergio Tanzilli <tanzilli-ryiEoTCBuMXrBCbmRaR9Nw@public.gmane.org>
Cc: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Cc: Tim Schendekehl <tim.schendekehl-inJ12LbcDfezQB+pC5nmwQ@public.gmane.org>

Alexandre Belloni (58):
  ARM: at91: Document new TCB bindings
  ARM: dts: at91: at91rm9200: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91rm9200ek: use TCB0 as clocksource
  ARM: dts: at91: mpa1600: use TCB0 as clocksource
  ARM: dts: at91: at91sam9260: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9260ek: use TCB0 as clocksource
  ARM: dts: at91: sam9_l9260: use TCB0 as clocksource
  ARM: dts: at91: ethernut5: use TCB0 as clocksource
  ARM: dts: at91: foxg20: use TCB0 as clocksource
  ARM: dts: at91: animeo_ip: use TCB0 as clocksource
  ARM: dts: at91: kizbox: use TCB0 as clocksource
  ARM: dts: at91: at91sam9g20ek: use TCB0 as clocksource
  ARM: dts: at91: ge863-pro3: use TCB0 as clocksource
  ARM: dts: at91: at91sam9261: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9261ek: use TCB0 as clocksource
  ARM: dts: at91: at91sam9263: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9263ek: use TCB0 as clocksource
  ARM: dts: at91: calao: use TCB0 as clocksource
  ARM: dts: at91: at91sam9g45: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9m10g45ek: use TCB0 as clocksource
  ARM: dts: at91: pm9g45: use TCB0 as clocksource
  ARM: dts: at91: at91sam9rl: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9rlek: use TCB0 as clocksource
  ARM: dts: at91: at91sam9n12: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9n12ek: use TCB0 as clocksource
  ARM: dts: at91: at91sam9x5: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9x5cm: use TCB0 as clocksource
  ARM: dts: at91: acme/g25: use TCB0 as clocksource
  ARM: dts: at91: cosino: use TCB0 as clocksource
  ARM: dts: at91: kizboxmini: use TCB0 as clocksource
  ARM: dts: at91: sama5d3: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: sama5d3xek: use TCB0 as clocksource
  ARM: dts: at91: sama5d3 Xplained: use TCB0 as clocksource
  ARM: dts: at91: kizbox2: use TCB0 as clocksource
  ARM: dts: at91: sama5d3xek_cmp: use TCB0 as clocksource
  ARM: dts: at91: linea/tse850-3: use TCB0 as clocksource
  ARM: dts: at91: sama5d4: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: sama5d4: Add TCB2
  ARM: dts: at91: sama5d4ek: use TCB2 as clocksource
  ARM: dts: at91: sama5d4 Xplained: use TCB2 as clocksource
  ARM: dts: at91: ma5d4: use TCB2 as clocksource
  ARM: dts: at91: vinco: use TCB2 as clocksource
  ARM: dts: at91: sama5d2: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: sama5d2 Xplained: use TCB0 as clocksource
  ARM: at91: add TCB registers definitions
  clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  clocksource/drivers: timer-atmel-tcbclksrc: add clockevent device
  clocksource/drivers: timer-atmel-tcbclksrc: add clockevent device on
    separate channel
  clocksource/drivers: atmel-pit: allow unselecting ATMEL_PIT
  ARM: at91/defconfig: sama5: unselect ATMEL_PIT
  ARM: at91/defconfig: at91_dt unselect ATMEL_PIT
  PWM: atmel-tcb: switch to new binding
  ARM: dts: at91: kizbox: switch to new pwm-atmel-tcb binding
  clocksource/drivers: remove tcb_clksrc
  misc: remove atmel_tclib.c
  ARM: configs: at91: remove ATMEL_TCLIB
  ARM: multi_v7_defconfig: Remove ATMEL_TCLIB Kconfig symbol
  ARM: multi_v5_defconfig: Remove ATMEL_TCLIB Kconfig symbol

 .../devicetree/bindings/arm/atmel-at91.txt         |  32 --
 .../devicetree/bindings/mfd/atmel-tcb.txt          |  58 +++
 .../devicetree/bindings/pwm/atmel-tcb-pwm.txt      |  12 +-
 arch/arm/boot/dts/animeo_ip.dts                    |  12 +
 arch/arm/boot/dts/at91-ariag25.dts                 |  12 +
 arch/arm/boot/dts/at91-ariettag25.dts              |  12 +
 arch/arm/boot/dts/at91-cosino.dtsi                 |  12 +
 arch/arm/boot/dts/at91-foxg20.dts                  |  12 +
 arch/arm/boot/dts/at91-kizbox.dts                  |  54 ++-
 arch/arm/boot/dts/at91-kizbox2.dts                 |  12 +
 arch/arm/boot/dts/at91-kizboxmini.dts              |  12 +
 arch/arm/boot/dts/at91-linea.dtsi                  |  12 +
 arch/arm/boot/dts/at91-qil_a9260.dts               |  12 +
 arch/arm/boot/dts/at91-sam9_l9260.dts              |  12 +
 arch/arm/boot/dts/at91-sama5d2_xplained.dts        |  12 +
 arch/arm/boot/dts/at91-sama5d3_xplained.dts        |  12 +
 arch/arm/boot/dts/at91-sama5d4_ma5d4.dtsi          |  12 +
 arch/arm/boot/dts/at91-sama5d4_xplained.dts        |  12 +
 arch/arm/boot/dts/at91-sama5d4ek.dts               |  12 +
 arch/arm/boot/dts/at91-vinco.dts                   |  12 +
 arch/arm/boot/dts/at91rm9200.dtsi                  |   8 +-
 arch/arm/boot/dts/at91rm9200ek.dts                 |  12 +
 arch/arm/boot/dts/at91sam9260.dtsi                 |   8 +-
 arch/arm/boot/dts/at91sam9260ek.dts                |  12 +
 arch/arm/boot/dts/at91sam9261.dtsi                 |   4 +-
 arch/arm/boot/dts/at91sam9261ek.dts                |  12 +
 arch/arm/boot/dts/at91sam9263.dtsi                 |   4 +-
 arch/arm/boot/dts/at91sam9263ek.dts                |  12 +
 arch/arm/boot/dts/at91sam9g20ek_common.dtsi        |  12 +
 arch/arm/boot/dts/at91sam9g45.dtsi                 |   8 +-
 arch/arm/boot/dts/at91sam9m10g45ek.dts             |  12 +
 arch/arm/boot/dts/at91sam9n12.dtsi                 |   8 +-
 arch/arm/boot/dts/at91sam9n12ek.dts                |  12 +
 arch/arm/boot/dts/at91sam9rl.dtsi                  |   4 +-
 arch/arm/boot/dts/at91sam9rlek.dts                 |  12 +
 arch/arm/boot/dts/at91sam9x5.dtsi                  |   8 +-
 arch/arm/boot/dts/at91sam9x5cm.dtsi                |  12 +
 arch/arm/boot/dts/ethernut5.dts                    |  12 +
 arch/arm/boot/dts/ge863-pro3.dtsi                  |  12 +
 arch/arm/boot/dts/mpa1600.dts                      |  12 +
 arch/arm/boot/dts/pm9g45.dts                       |  12 +
 arch/arm/boot/dts/sama5d2.dtsi                     |   8 +-
 arch/arm/boot/dts/sama5d3.dtsi                     |   4 +-
 arch/arm/boot/dts/sama5d3_tcb1.dtsi                |   4 +-
 arch/arm/boot/dts/sama5d3xcm.dtsi                  |  12 +
 arch/arm/boot/dts/sama5d3xcm_cmp.dtsi              |  12 +
 arch/arm/boot/dts/sama5d4.dtsi                     |  18 +-
 arch/arm/boot/dts/tny_a9260_common.dtsi            |  12 +
 arch/arm/boot/dts/tny_a9263.dts                    |  12 +
 arch/arm/boot/dts/usb_a9260_common.dtsi            |  12 +
 arch/arm/boot/dts/usb_a9263.dts                    |  12 +
 arch/arm/configs/at91_dt_defconfig                 |   2 +-
 arch/arm/configs/multi_v5_defconfig                |   1 -
 arch/arm/configs/multi_v7_defconfig                |   1 -
 arch/arm/configs/sama5_defconfig                   |   2 +-
 drivers/clocksource/Kconfig                        |  22 +-
 drivers/clocksource/Makefile                       |   2 +-
 drivers/clocksource/tcb_clksrc.c                   | 381 ----------------
 drivers/clocksource/timer-atmel-tcbclksrc.c        | 502 +++++++++++++++++++++
 drivers/misc/Kconfig                               |  33 --
 drivers/misc/Makefile                              |   1 -
 drivers/misc/atmel_tclib.c                         | 198 --------
 drivers/pwm/Kconfig                                |   3 +-
 drivers/pwm/pwm-atmel-tcb.c                        | 221 ++++-----
 include/linux/atmel_tc.h                           |   9 -
 include/soc/at91/atmel_tcb.h                       | 229 ++++++++++
 66 files changed, 1468 insertions(+), 801 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/atmel-tcb.txt
 delete mode 100644 drivers/clocksource/tcb_clksrc.c
 create mode 100644 drivers/clocksource/timer-atmel-tcbclksrc.c
 delete mode 100644 drivers/misc/atmel_tclib.c
 create mode 100644 include/soc/at91/atmel_tcb.h

-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 00/58] ARM: at91: rework Atmel TCB drivers
@ 2017-05-30 21:50 ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

This series reworks the Atmel Timer counter Block drivers. Those blocks
each have 3 counters with 2 channels each and can be used for
multiple functions:
 - timers
 - PWMs
 - Quadrature decoders
 - Stepper motor counters

Up until now, each TCB was fully used by each driver, possibly wasting
counters/channels.

There is a second issue motivating that rework. Until now, the PIT is
still used to boot then later in the boot sequence, the clocksource is
switched to the TCB. This ends up not working well with preempt-rt
because on some SoCs, the PIT interrupt is shared with the DBGU uart.
When using preempt-rt the interrupt flags for the PIT and the DBGU end
up being incompatible.

The rework breaks the DT ABI. Backward compatibility can be kept by
keeping tcb_clksrc and atmel_tclib but as AVR32 is now gone from the
kernel, I don't think it makes much sense to keep them.

Also, there is no other choice than breaking the mainly unused
pwm-atmel-tcb binding. Only the kizbox is actually using it.

I think the bindings are now ok and I hope we can take the DT changes
for 4.13.

Cc: Antoine Aubert <a.aubert@overkiz.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: devicetree at vger.kernel.org
Cc: Douglas Gilbert <dgilbert@interlog.com>
Cc: Fabio Porcedda <fabio.porcedda@gmail.com>
Cc: Gregory CLEMENT <gregory.clement@free-electrons.com>
Cc: Gregory Hermant <gregory.hermant@calao-systems.com>
Cc: Joachim Eastwood <manabian@gmail.com>
Cc: linux-pwm at vger.kernel.org
Cc: Marek Vasut <marex@denx.de>
Cc: Martin Reimann <martin.reimann@egnite.de>
Cc: Peter Rosin <peda@axentia.se>
Cc: Raashid Muhammed <raashidmuhammed@zilogic.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Rodolfo Giometti <giometti@linux.it>
Cc: Sergio Tanzilli <tanzilli@acmesystems.it>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tim Schendekehl <tim.schendekehl@egnite.de>

Alexandre Belloni (58):
  ARM: at91: Document new TCB bindings
  ARM: dts: at91: at91rm9200: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91rm9200ek: use TCB0 as clocksource
  ARM: dts: at91: mpa1600: use TCB0 as clocksource
  ARM: dts: at91: at91sam9260: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9260ek: use TCB0 as clocksource
  ARM: dts: at91: sam9_l9260: use TCB0 as clocksource
  ARM: dts: at91: ethernut5: use TCB0 as clocksource
  ARM: dts: at91: foxg20: use TCB0 as clocksource
  ARM: dts: at91: animeo_ip: use TCB0 as clocksource
  ARM: dts: at91: kizbox: use TCB0 as clocksource
  ARM: dts: at91: at91sam9g20ek: use TCB0 as clocksource
  ARM: dts: at91: ge863-pro3: use TCB0 as clocksource
  ARM: dts: at91: at91sam9261: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9261ek: use TCB0 as clocksource
  ARM: dts: at91: at91sam9263: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9263ek: use TCB0 as clocksource
  ARM: dts: at91: calao: use TCB0 as clocksource
  ARM: dts: at91: at91sam9g45: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9m10g45ek: use TCB0 as clocksource
  ARM: dts: at91: pm9g45: use TCB0 as clocksource
  ARM: dts: at91: at91sam9rl: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9rlek: use TCB0 as clocksource
  ARM: dts: at91: at91sam9n12: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9n12ek: use TCB0 as clocksource
  ARM: dts: at91: at91sam9x5: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: at91sam9x5cm: use TCB0 as clocksource
  ARM: dts: at91: acme/g25: use TCB0 as clocksource
  ARM: dts: at91: cosino: use TCB0 as clocksource
  ARM: dts: at91: kizboxmini: use TCB0 as clocksource
  ARM: dts: at91: sama5d3: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: sama5d3xek: use TCB0 as clocksource
  ARM: dts: at91: sama5d3 Xplained: use TCB0 as clocksource
  ARM: dts: at91: kizbox2: use TCB0 as clocksource
  ARM: dts: at91: sama5d3xek_cmp: use TCB0 as clocksource
  ARM: dts: at91: linea/tse850-3: use TCB0 as clocksource
  ARM: dts: at91: sama5d4: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: sama5d4: Add TCB2
  ARM: dts: at91: sama5d4ek: use TCB2 as clocksource
  ARM: dts: at91: sama5d4 Xplained: use TCB2 as clocksource
  ARM: dts: at91: ma5d4: use TCB2 as clocksource
  ARM: dts: at91: vinco: use TCB2 as clocksource
  ARM: dts: at91: sama5d2: TC blocks are also simple-mfd and syscon
    devices
  ARM: dts: at91: sama5d2 Xplained: use TCB0 as clocksource
  ARM: at91: add TCB registers definitions
  clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  clocksource/drivers: timer-atmel-tcbclksrc: add clockevent device
  clocksource/drivers: timer-atmel-tcbclksrc: add clockevent device on
    separate channel
  clocksource/drivers: atmel-pit: allow unselecting ATMEL_PIT
  ARM: at91/defconfig: sama5: unselect ATMEL_PIT
  ARM: at91/defconfig: at91_dt unselect ATMEL_PIT
  PWM: atmel-tcb: switch to new binding
  ARM: dts: at91: kizbox: switch to new pwm-atmel-tcb binding
  clocksource/drivers: remove tcb_clksrc
  misc: remove atmel_tclib.c
  ARM: configs: at91: remove ATMEL_TCLIB
  ARM: multi_v7_defconfig: Remove ATMEL_TCLIB Kconfig symbol
  ARM: multi_v5_defconfig: Remove ATMEL_TCLIB Kconfig symbol

 .../devicetree/bindings/arm/atmel-at91.txt         |  32 --
 .../devicetree/bindings/mfd/atmel-tcb.txt          |  58 +++
 .../devicetree/bindings/pwm/atmel-tcb-pwm.txt      |  12 +-
 arch/arm/boot/dts/animeo_ip.dts                    |  12 +
 arch/arm/boot/dts/at91-ariag25.dts                 |  12 +
 arch/arm/boot/dts/at91-ariettag25.dts              |  12 +
 arch/arm/boot/dts/at91-cosino.dtsi                 |  12 +
 arch/arm/boot/dts/at91-foxg20.dts                  |  12 +
 arch/arm/boot/dts/at91-kizbox.dts                  |  54 ++-
 arch/arm/boot/dts/at91-kizbox2.dts                 |  12 +
 arch/arm/boot/dts/at91-kizboxmini.dts              |  12 +
 arch/arm/boot/dts/at91-linea.dtsi                  |  12 +
 arch/arm/boot/dts/at91-qil_a9260.dts               |  12 +
 arch/arm/boot/dts/at91-sam9_l9260.dts              |  12 +
 arch/arm/boot/dts/at91-sama5d2_xplained.dts        |  12 +
 arch/arm/boot/dts/at91-sama5d3_xplained.dts        |  12 +
 arch/arm/boot/dts/at91-sama5d4_ma5d4.dtsi          |  12 +
 arch/arm/boot/dts/at91-sama5d4_xplained.dts        |  12 +
 arch/arm/boot/dts/at91-sama5d4ek.dts               |  12 +
 arch/arm/boot/dts/at91-vinco.dts                   |  12 +
 arch/arm/boot/dts/at91rm9200.dtsi                  |   8 +-
 arch/arm/boot/dts/at91rm9200ek.dts                 |  12 +
 arch/arm/boot/dts/at91sam9260.dtsi                 |   8 +-
 arch/arm/boot/dts/at91sam9260ek.dts                |  12 +
 arch/arm/boot/dts/at91sam9261.dtsi                 |   4 +-
 arch/arm/boot/dts/at91sam9261ek.dts                |  12 +
 arch/arm/boot/dts/at91sam9263.dtsi                 |   4 +-
 arch/arm/boot/dts/at91sam9263ek.dts                |  12 +
 arch/arm/boot/dts/at91sam9g20ek_common.dtsi        |  12 +
 arch/arm/boot/dts/at91sam9g45.dtsi                 |   8 +-
 arch/arm/boot/dts/at91sam9m10g45ek.dts             |  12 +
 arch/arm/boot/dts/at91sam9n12.dtsi                 |   8 +-
 arch/arm/boot/dts/at91sam9n12ek.dts                |  12 +
 arch/arm/boot/dts/at91sam9rl.dtsi                  |   4 +-
 arch/arm/boot/dts/at91sam9rlek.dts                 |  12 +
 arch/arm/boot/dts/at91sam9x5.dtsi                  |   8 +-
 arch/arm/boot/dts/at91sam9x5cm.dtsi                |  12 +
 arch/arm/boot/dts/ethernut5.dts                    |  12 +
 arch/arm/boot/dts/ge863-pro3.dtsi                  |  12 +
 arch/arm/boot/dts/mpa1600.dts                      |  12 +
 arch/arm/boot/dts/pm9g45.dts                       |  12 +
 arch/arm/boot/dts/sama5d2.dtsi                     |   8 +-
 arch/arm/boot/dts/sama5d3.dtsi                     |   4 +-
 arch/arm/boot/dts/sama5d3_tcb1.dtsi                |   4 +-
 arch/arm/boot/dts/sama5d3xcm.dtsi                  |  12 +
 arch/arm/boot/dts/sama5d3xcm_cmp.dtsi              |  12 +
 arch/arm/boot/dts/sama5d4.dtsi                     |  18 +-
 arch/arm/boot/dts/tny_a9260_common.dtsi            |  12 +
 arch/arm/boot/dts/tny_a9263.dts                    |  12 +
 arch/arm/boot/dts/usb_a9260_common.dtsi            |  12 +
 arch/arm/boot/dts/usb_a9263.dts                    |  12 +
 arch/arm/configs/at91_dt_defconfig                 |   2 +-
 arch/arm/configs/multi_v5_defconfig                |   1 -
 arch/arm/configs/multi_v7_defconfig                |   1 -
 arch/arm/configs/sama5_defconfig                   |   2 +-
 drivers/clocksource/Kconfig                        |  22 +-
 drivers/clocksource/Makefile                       |   2 +-
 drivers/clocksource/tcb_clksrc.c                   | 381 ----------------
 drivers/clocksource/timer-atmel-tcbclksrc.c        | 502 +++++++++++++++++++++
 drivers/misc/Kconfig                               |  33 --
 drivers/misc/Makefile                              |   1 -
 drivers/misc/atmel_tclib.c                         | 198 --------
 drivers/pwm/Kconfig                                |   3 +-
 drivers/pwm/pwm-atmel-tcb.c                        | 221 ++++-----
 include/linux/atmel_tc.h                           |   9 -
 include/soc/at91/atmel_tcb.h                       | 229 ++++++++++
 66 files changed, 1468 insertions(+), 801 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/atmel-tcb.txt
 delete mode 100644 drivers/clocksource/tcb_clksrc.c
 create mode 100644 drivers/clocksource/timer-atmel-tcbclksrc.c
 delete mode 100644 drivers/misc/atmel_tclib.c
 create mode 100644 include/soc/at91/atmel_tcb.h

-- 
2.11.0

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 01/58] ARM: at91: Document new TCB bindings
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:50   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Daniel Lezcano, Thierry Reding, linux-pwm,
	Rob Herring, devicetree

The current binding for the TCB is not flexible enough for some use cases
and prevents proper utilization of all the channels.

Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-pwm@vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 .../devicetree/bindings/arm/atmel-at91.txt         | 32 ------------
 .../devicetree/bindings/mfd/atmel-tcb.txt          | 58 ++++++++++++++++++++++
 .../devicetree/bindings/pwm/atmel-tcb-pwm.txt      | 12 +++--
 3 files changed, 65 insertions(+), 37 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/atmel-tcb.txt

diff --git a/Documentation/devicetree/bindings/arm/atmel-at91.txt b/Documentation/devicetree/bindings/arm/atmel-at91.txt
index 799af90dd75b..44798554e855 100644
--- a/Documentation/devicetree/bindings/arm/atmel-at91.txt
+++ b/Documentation/devicetree/bindings/arm/atmel-at91.txt
@@ -60,38 +60,6 @@ System Timer (ST) required properties:
 Its subnodes can be:
 - watchdog: compatible should be "atmel,at91rm9200-wdt"
 
-TC/TCLIB Timer required properties:
-- compatible: Should be "atmel,<chip>-tcb".
-  <chip> can be "at91rm9200" or "at91sam9x5"
-- reg: Should contain registers location and length
-- interrupts: Should contain all interrupts for the TC block
-  Note that you can specify several interrupt cells if the TC
-  block has one interrupt per channel.
-- clock-names: tuple listing input clock names.
-	Required elements: "t0_clk", "slow_clk"
-	Optional elements: "t1_clk", "t2_clk"
-- clocks: phandles to input clocks.
-
-Examples:
-
-One interrupt per TC block:
-	tcb0: timer@fff7c000 {
-		compatible = "atmel,at91rm9200-tcb";
-		reg = <0xfff7c000 0x100>;
-		interrupts = <18 4>;
-		clocks = <&tcb0_clk>;
-		clock-names = "t0_clk";
-	};
-
-One interrupt per TC channel in a TC block:
-	tcb1: timer@fffdc000 {
-		compatible = "atmel,at91rm9200-tcb";
-		reg = <0xfffdc000 0x100>;
-		interrupts = <26 4 27 4 28 4>;
-		clocks = <&tcb1_clk>;
-		clock-names = "t0_clk";
-	};
-
 RSTC Reset Controller required properties:
 - compatible: Should be "atmel,<chip>-rstc".
   <chip> can be "at91sam9260" or "at91sam9g45" or "sama5d3"
diff --git a/Documentation/devicetree/bindings/mfd/atmel-tcb.txt b/Documentation/devicetree/bindings/mfd/atmel-tcb.txt
new file mode 100644
index 000000000000..693c7361e1ba
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/atmel-tcb.txt
@@ -0,0 +1,58 @@
+* Device tree bindings for Atmel Timer Counter Blocks
+- compatible: Should be "atmel,<chip>-tcb", "simple-mfd", "syscon".
+  <chip> can be "at91rm9200" or "at91sam9x5"
+- reg: Should contain registers location and length
+- #address-cells: has to be 1
+- #size-cells: has to be 0
+- interrupts: Should contain all interrupts for the TC block
+  Note that you can specify several interrupt cells if the TC
+  block has one interrupt per channel.
+- clock-names: tuple listing input clock names.
+	Required elements: "t0_clk", "slow_clk"
+	Optional elements: "t1_clk", "t2_clk"
+- clocks: phandles to input clocks.
+
+The TCB can expose multiple subdevices:
+ * a timer
+   - compatible: Should be "atmel,tcb-timer"
+   - reg: Should contain the TCB channels to be used. If the
+     counter width is 16 bits (at91rm9200-tcb), two consecutive
+     channels are needed. Else, only one channel will be used.
+
+ * a PWM chip: see ../pwm/atmel-tcb-pwm.txt
+
+Examples:
+
+One interrupt per TC block:
+	tcb0: timer@fff7c000 {
+		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <0xfff7c000 0x100>;
+		interrupts = <18 4>;
+		clocks = <&tcb0_clk>, <&clk32k>;
+		clock-names = "t0_clk", "slow_clk";
+
+		timer@0 {
+			compatible = "atmel,tcb-timer";
+			reg = <0>, <1>;
+		};
+
+		timer@2 {
+			compatible = "atmel,tcb-timer";
+			reg = <2>;
+		};
+	};
+
+One interrupt per TC channel in a TC block:
+	tcb1: timer@fffdc000 {
+		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <0xfffdc000 0x100>;
+		interrupts = <26 4>, <27 4>, <28 4>;
+		clocks = <&tcb1_clk>, <&clk32k>;
+		clock-names = "t0_clk", "slow_clk";
+	};
+
+
diff --git a/Documentation/devicetree/bindings/pwm/atmel-tcb-pwm.txt b/Documentation/devicetree/bindings/pwm/atmel-tcb-pwm.txt
index 8031148bcf85..ab8fbd5ba184 100644
--- a/Documentation/devicetree/bindings/pwm/atmel-tcb-pwm.txt
+++ b/Documentation/devicetree/bindings/pwm/atmel-tcb-pwm.txt
@@ -2,15 +2,17 @@ Atmel TCB PWM controller
 
 Required properties:
 - compatible: should be "atmel,tcb-pwm"
+- reg: tcb channel to use. Each channel can export 2 PWMs
 - #pwm-cells: should be 3. See pwm.txt in this directory for a description of
   the cells format. The only third cell flag supported by this binding is
   PWM_POLARITY_INVERTED.
-- tc-block: The Timer Counter block to use as a PWM chip.
 
 Example:
 
-pwm {
-	compatible = "atmel,tcb-pwm";
-	#pwm-cells = <3>;
-	tc-block = <1>;
+tcb0: timer@f800c000 {
+	pwm@0 {
+		compatible = "atmel,tcb-pwm";
+		reg = <0>;
+		#pwm-cells = <3>;
+	};
 };
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 01/58] ARM: at91: Document new TCB bindings
@ 2017-05-30 21:50   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

The current binding for the TCB is not flexible enough for some use cases
and prevents proper utilization of all the channels.

Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-pwm at vger.kernel.org
Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree at vger.kernel.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 .../devicetree/bindings/arm/atmel-at91.txt         | 32 ------------
 .../devicetree/bindings/mfd/atmel-tcb.txt          | 58 ++++++++++++++++++++++
 .../devicetree/bindings/pwm/atmel-tcb-pwm.txt      | 12 +++--
 3 files changed, 65 insertions(+), 37 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/atmel-tcb.txt

diff --git a/Documentation/devicetree/bindings/arm/atmel-at91.txt b/Documentation/devicetree/bindings/arm/atmel-at91.txt
index 799af90dd75b..44798554e855 100644
--- a/Documentation/devicetree/bindings/arm/atmel-at91.txt
+++ b/Documentation/devicetree/bindings/arm/atmel-at91.txt
@@ -60,38 +60,6 @@ System Timer (ST) required properties:
 Its subnodes can be:
 - watchdog: compatible should be "atmel,at91rm9200-wdt"
 
-TC/TCLIB Timer required properties:
-- compatible: Should be "atmel,<chip>-tcb".
-  <chip> can be "at91rm9200" or "at91sam9x5"
-- reg: Should contain registers location and length
-- interrupts: Should contain all interrupts for the TC block
-  Note that you can specify several interrupt cells if the TC
-  block has one interrupt per channel.
-- clock-names: tuple listing input clock names.
-	Required elements: "t0_clk", "slow_clk"
-	Optional elements: "t1_clk", "t2_clk"
-- clocks: phandles to input clocks.
-
-Examples:
-
-One interrupt per TC block:
-	tcb0: timer at fff7c000 {
-		compatible = "atmel,at91rm9200-tcb";
-		reg = <0xfff7c000 0x100>;
-		interrupts = <18 4>;
-		clocks = <&tcb0_clk>;
-		clock-names = "t0_clk";
-	};
-
-One interrupt per TC channel in a TC block:
-	tcb1: timer at fffdc000 {
-		compatible = "atmel,at91rm9200-tcb";
-		reg = <0xfffdc000 0x100>;
-		interrupts = <26 4 27 4 28 4>;
-		clocks = <&tcb1_clk>;
-		clock-names = "t0_clk";
-	};
-
 RSTC Reset Controller required properties:
 - compatible: Should be "atmel,<chip>-rstc".
   <chip> can be "at91sam9260" or "at91sam9g45" or "sama5d3"
diff --git a/Documentation/devicetree/bindings/mfd/atmel-tcb.txt b/Documentation/devicetree/bindings/mfd/atmel-tcb.txt
new file mode 100644
index 000000000000..693c7361e1ba
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/atmel-tcb.txt
@@ -0,0 +1,58 @@
+* Device tree bindings for Atmel Timer Counter Blocks
+- compatible: Should be "atmel,<chip>-tcb", "simple-mfd", "syscon".
+  <chip> can be "at91rm9200" or "at91sam9x5"
+- reg: Should contain registers location and length
+- #address-cells: has to be 1
+- #size-cells: has to be 0
+- interrupts: Should contain all interrupts for the TC block
+  Note that you can specify several interrupt cells if the TC
+  block has one interrupt per channel.
+- clock-names: tuple listing input clock names.
+	Required elements: "t0_clk", "slow_clk"
+	Optional elements: "t1_clk", "t2_clk"
+- clocks: phandles to input clocks.
+
+The TCB can expose multiple subdevices:
+ * a timer
+   - compatible: Should be "atmel,tcb-timer"
+   - reg: Should contain the TCB channels to be used. If the
+     counter width is 16 bits (at91rm9200-tcb), two consecutive
+     channels are needed. Else, only one channel will be used.
+
+ * a PWM chip: see ../pwm/atmel-tcb-pwm.txt
+
+Examples:
+
+One interrupt per TC block:
+	tcb0: timer at fff7c000 {
+		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <0xfff7c000 0x100>;
+		interrupts = <18 4>;
+		clocks = <&tcb0_clk>, <&clk32k>;
+		clock-names = "t0_clk", "slow_clk";
+
+		timer at 0 {
+			compatible = "atmel,tcb-timer";
+			reg = <0>, <1>;
+		};
+
+		timer at 2 {
+			compatible = "atmel,tcb-timer";
+			reg = <2>;
+		};
+	};
+
+One interrupt per TC channel in a TC block:
+	tcb1: timer at fffdc000 {
+		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		reg = <0xfffdc000 0x100>;
+		interrupts = <26 4>, <27 4>, <28 4>;
+		clocks = <&tcb1_clk>, <&clk32k>;
+		clock-names = "t0_clk", "slow_clk";
+	};
+
+
diff --git a/Documentation/devicetree/bindings/pwm/atmel-tcb-pwm.txt b/Documentation/devicetree/bindings/pwm/atmel-tcb-pwm.txt
index 8031148bcf85..ab8fbd5ba184 100644
--- a/Documentation/devicetree/bindings/pwm/atmel-tcb-pwm.txt
+++ b/Documentation/devicetree/bindings/pwm/atmel-tcb-pwm.txt
@@ -2,15 +2,17 @@ Atmel TCB PWM controller
 
 Required properties:
 - compatible: should be "atmel,tcb-pwm"
+- reg: tcb channel to use. Each channel can export 2 PWMs
 - #pwm-cells: should be 3. See pwm.txt in this directory for a description of
   the cells format. The only third cell flag supported by this binding is
   PWM_POLARITY_INVERTED.
-- tc-block: The Timer Counter block to use as a PWM chip.
 
 Example:
 
-pwm {
-	compatible = "atmel,tcb-pwm";
-	#pwm-cells = <3>;
-	tc-block = <1>;
+tcb0: timer at f800c000 {
+	pwm at 0 {
+		compatible = "atmel,tcb-pwm";
+		reg = <0>;
+		#pwm-cells = <3>;
+	};
 };
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 02/58] ARM: dts: at91: at91rm9200: TC blocks are also simple-mfd and syscon devices
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:50   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allows to use
regmap instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91rm9200.dtsi | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/at91rm9200.dtsi b/arch/arm/boot/dts/at91rm9200.dtsi
index f057e0b15a6f..9392171c7544 100644
--- a/arch/arm/boot/dts/at91rm9200.dtsi
+++ b/arch/arm/boot/dts/at91rm9200.dtsi
@@ -375,7 +375,9 @@
 			};
 
 			tcb0: timer@fffa0000 {
-				compatible = "atmel,at91rm9200-tcb";
+				compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xfffa0000 0x100>;
 				interrupts = <17 IRQ_TYPE_LEVEL_HIGH 0
 					      18 IRQ_TYPE_LEVEL_HIGH 0
@@ -385,7 +387,9 @@
 			};
 
 			tcb1: timer@fffa4000 {
-				compatible = "atmel,at91rm9200-tcb";
+				compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xfffa4000 0x100>;
 				interrupts = <20 IRQ_TYPE_LEVEL_HIGH 0
 					      21 IRQ_TYPE_LEVEL_HIGH 0
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 02/58] ARM: dts: at91: at91rm9200: TC blocks are also simple-mfd and syscon devices
@ 2017-05-30 21:50   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allows to use
regmap instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91rm9200.dtsi | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/at91rm9200.dtsi b/arch/arm/boot/dts/at91rm9200.dtsi
index f057e0b15a6f..9392171c7544 100644
--- a/arch/arm/boot/dts/at91rm9200.dtsi
+++ b/arch/arm/boot/dts/at91rm9200.dtsi
@@ -375,7 +375,9 @@
 			};
 
 			tcb0: timer at fffa0000 {
-				compatible = "atmel,at91rm9200-tcb";
+				compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xfffa0000 0x100>;
 				interrupts = <17 IRQ_TYPE_LEVEL_HIGH 0
 					      18 IRQ_TYPE_LEVEL_HIGH 0
@@ -385,7 +387,9 @@
 			};
 
 			tcb1: timer@fffa4000 {
-				compatible = "atmel,at91rm9200-tcb";
+				compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xfffa4000 0x100>;
 				interrupts = <20 IRQ_TYPE_LEVEL_HIGH 0
 					      21 IRQ_TYPE_LEVEL_HIGH 0
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 03/58] ARM: dts: at91: at91rm9200ek: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:50   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Tested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91rm9200ek.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91rm9200ek.dts b/arch/arm/boot/dts/at91rm9200ek.dts
index f90e1c2d3caa..a446e12cbaa8 100644
--- a/arch/arm/boot/dts/at91rm9200ek.dts
+++ b/arch/arm/boot/dts/at91rm9200ek.dts
@@ -32,6 +32,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer@fffa0000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer@2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			usb1: gadget@fffb0000 {
 				atmel,vbus-gpio = <&pioD 4 GPIO_ACTIVE_HIGH>;
 				atmel,pullup-gpio = <&pioD 5 GPIO_ACTIVE_HIGH>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 03/58] ARM: dts: at91: at91rm9200ek: use TCB0 as clocksource
@ 2017-05-30 21:50   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Tested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91rm9200ek.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91rm9200ek.dts b/arch/arm/boot/dts/at91rm9200ek.dts
index f90e1c2d3caa..a446e12cbaa8 100644
--- a/arch/arm/boot/dts/at91rm9200ek.dts
+++ b/arch/arm/boot/dts/at91rm9200ek.dts
@@ -32,6 +32,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer at fffa0000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer at 2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			usb1: gadget at fffb0000 {
 				atmel,vbus-gpio = <&pioD 4 GPIO_ACTIVE_HIGH>;
 				atmel,pullup-gpio = <&pioD 5 GPIO_ACTIVE_HIGH>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 04/58] ARM: dts: at91: mpa1600: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:50   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Joachim Eastwood

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Cc: Joachim Eastwood <manabian@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/mpa1600.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/mpa1600.dts b/arch/arm/boot/dts/mpa1600.dts
index 116ce78bea4f..383bc604ec2a 100644
--- a/arch/arm/boot/dts/mpa1600.dts
+++ b/arch/arm/boot/dts/mpa1600.dts
@@ -32,6 +32,18 @@
 				status = "okay";
 			};
 
+			tcb0: timer@fffa0000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer@2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			macb0: ethernet@fffbc000 {
 				phy-mode = "rmii";
 				status = "okay";
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 04/58] ARM: dts: at91: mpa1600: use TCB0 as clocksource
@ 2017-05-30 21:50   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Cc: Joachim Eastwood <manabian@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/mpa1600.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/mpa1600.dts b/arch/arm/boot/dts/mpa1600.dts
index 116ce78bea4f..383bc604ec2a 100644
--- a/arch/arm/boot/dts/mpa1600.dts
+++ b/arch/arm/boot/dts/mpa1600.dts
@@ -32,6 +32,18 @@
 				status = "okay";
 			};
 
+			tcb0: timer at fffa0000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer at 2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			macb0: ethernet at fffbc000 {
 				phy-mode = "rmii";
 				status = "okay";
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 05/58] ARM: dts: at91: at91sam9260: TC blocks are also simple-mfd and syscon devices
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:50   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allows to use
regmap instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9260.dtsi | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi
index 9e035b21e1b6..9873dfc6bdff 100644
--- a/arch/arm/boot/dts/at91sam9260.dtsi
+++ b/arch/arm/boot/dts/at91sam9260.dtsi
@@ -376,7 +376,9 @@
 			};
 
 			tcb0: timer@fffa0000 {
-				compatible = "atmel,at91rm9200-tcb";
+				compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xfffa0000 0x100>;
 				interrupts = <17 IRQ_TYPE_LEVEL_HIGH 0
 					      18 IRQ_TYPE_LEVEL_HIGH 0
@@ -386,7 +388,9 @@
 			};
 
 			tcb1: timer@fffdc000 {
-				compatible = "atmel,at91rm9200-tcb";
+				compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xfffdc000 0x100>;
 				interrupts = <26 IRQ_TYPE_LEVEL_HIGH 0
 					      27 IRQ_TYPE_LEVEL_HIGH 0
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 05/58] ARM: dts: at91: at91sam9260: TC blocks are also simple-mfd and syscon devices
@ 2017-05-30 21:50   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allows to use
regmap instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9260.dtsi | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi
index 9e035b21e1b6..9873dfc6bdff 100644
--- a/arch/arm/boot/dts/at91sam9260.dtsi
+++ b/arch/arm/boot/dts/at91sam9260.dtsi
@@ -376,7 +376,9 @@
 			};
 
 			tcb0: timer at fffa0000 {
-				compatible = "atmel,at91rm9200-tcb";
+				compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xfffa0000 0x100>;
 				interrupts = <17 IRQ_TYPE_LEVEL_HIGH 0
 					      18 IRQ_TYPE_LEVEL_HIGH 0
@@ -386,7 +388,9 @@
 			};
 
 			tcb1: timer@fffdc000 {
-				compatible = "atmel,at91rm9200-tcb";
+				compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xfffdc000 0x100>;
 				interrupts = <26 IRQ_TYPE_LEVEL_HIGH 0
 					      27 IRQ_TYPE_LEVEL_HIGH 0
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 06/58] ARM: dts: at91: at91sam9260ek: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:50   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9260ek.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91sam9260ek.dts b/arch/arm/boot/dts/at91sam9260ek.dts
index b2578feceb08..e16c706d91ef 100644
--- a/arch/arm/boot/dts/at91sam9260ek.dts
+++ b/arch/arm/boot/dts/at91sam9260ek.dts
@@ -69,6 +69,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer@fffa0000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer@2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			usb1: gadget@fffa4000 {
 				atmel,vbus-gpio = <&pioC 5 GPIO_ACTIVE_HIGH>;
 				status = "okay";
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 06/58] ARM: dts: at91: at91sam9260ek: use TCB0 as clocksource
@ 2017-05-30 21:50   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9260ek.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91sam9260ek.dts b/arch/arm/boot/dts/at91sam9260ek.dts
index b2578feceb08..e16c706d91ef 100644
--- a/arch/arm/boot/dts/at91sam9260ek.dts
+++ b/arch/arm/boot/dts/at91sam9260ek.dts
@@ -69,6 +69,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer at fffa0000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer at 2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			usb1: gadget at fffa4000 {
 				atmel,vbus-gpio = <&pioC 5 GPIO_ACTIVE_HIGH>;
 				status = "okay";
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 07/58] ARM: dts: at91: sam9_l9260: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:50   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Raashid Muhammed

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Cc: Raashid Muhammed <raashidmuhammed@zilogic.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-sam9_l9260.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-sam9_l9260.dts b/arch/arm/boot/dts/at91-sam9_l9260.dts
index 171243ca4f2f..70cb36f7a9d7 100644
--- a/arch/arm/boot/dts/at91-sam9_l9260.dts
+++ b/arch/arm/boot/dts/at91-sam9_l9260.dts
@@ -32,6 +32,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer@fffa0000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer@2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			mmc0: mmc@fffa8000 {
 				pinctrl-0 = <
 					&pinctrl_board_mmc0
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 07/58] ARM: dts: at91: sam9_l9260: use TCB0 as clocksource
@ 2017-05-30 21:50   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Cc: Raashid Muhammed <raashidmuhammed@zilogic.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-sam9_l9260.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-sam9_l9260.dts b/arch/arm/boot/dts/at91-sam9_l9260.dts
index 171243ca4f2f..70cb36f7a9d7 100644
--- a/arch/arm/boot/dts/at91-sam9_l9260.dts
+++ b/arch/arm/boot/dts/at91-sam9_l9260.dts
@@ -32,6 +32,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer at fffa0000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer at 2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			mmc0: mmc at fffa8000 {
 				pinctrl-0 = <
 					&pinctrl_board_mmc0
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 08/58] ARM: dts: at91: ethernut5: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:50   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Martin Reimann, Tim Schendekehl

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Cc: Martin Reimann <martin.reimann@egnite.de>
Cc: Tim Schendekehl <tim.schendekehl@egnite.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/ethernut5.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/ethernut5.dts b/arch/arm/boot/dts/ethernut5.dts
index 4687229a3ab9..51be8859cb7f 100644
--- a/arch/arm/boot/dts/ethernut5.dts
+++ b/arch/arm/boot/dts/ethernut5.dts
@@ -36,6 +36,18 @@
 				status = "okay";
 			};
 
+			tcb0: timer@fffa0000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer@2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			usart0: serial@fffb0000 {
 				status = "okay";
 			};
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 08/58] ARM: dts: at91: ethernut5: use TCB0 as clocksource
@ 2017-05-30 21:50   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Cc: Martin Reimann <martin.reimann@egnite.de>
Cc: Tim Schendekehl <tim.schendekehl@egnite.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/ethernut5.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/ethernut5.dts b/arch/arm/boot/dts/ethernut5.dts
index 4687229a3ab9..51be8859cb7f 100644
--- a/arch/arm/boot/dts/ethernut5.dts
+++ b/arch/arm/boot/dts/ethernut5.dts
@@ -36,6 +36,18 @@
 				status = "okay";
 			};
 
+			tcb0: timer at fffa0000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer at 2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			usart0: serial at fffb0000 {
 				status = "okay";
 			};
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 09/58] ARM: dts: at91: foxg20: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:50   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Sergio Tanzilli, Douglas Gilbert

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Cc: Sergio Tanzilli <tanzilli@acmesystems.it>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-foxg20.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-foxg20.dts b/arch/arm/boot/dts/at91-foxg20.dts
index 50d5e719b451..d413e2d9abdf 100644
--- a/arch/arm/boot/dts/at91-foxg20.dts
+++ b/arch/arm/boot/dts/at91-foxg20.dts
@@ -34,6 +34,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer@fffa0000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer@2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			usb1: gadget@fffa4000 {
 				atmel,vbus-gpio = <&pioC 6 GPIO_ACTIVE_HIGH>;
 				status = "okay";
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 09/58] ARM: dts: at91: foxg20: use TCB0 as clocksource
@ 2017-05-30 21:50   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Cc: Sergio Tanzilli <tanzilli@acmesystems.it>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-foxg20.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-foxg20.dts b/arch/arm/boot/dts/at91-foxg20.dts
index 50d5e719b451..d413e2d9abdf 100644
--- a/arch/arm/boot/dts/at91-foxg20.dts
+++ b/arch/arm/boot/dts/at91-foxg20.dts
@@ -34,6 +34,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer at fffa0000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer at 2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			usb1: gadget at fffa4000 {
 				atmel,vbus-gpio = <&pioC 6 GPIO_ACTIVE_HIGH>;
 				status = "okay";
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 10/58] ARM: dts: at91: animeo_ip: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:50   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/animeo_ip.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/animeo_ip.dts b/arch/arm/boot/dts/animeo_ip.dts
index 9cc372b9fb9b..710a6f17bc28 100644
--- a/arch/arm/boot/dts/animeo_ip.dts
+++ b/arch/arm/boot/dts/animeo_ip.dts
@@ -43,6 +43,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer@fffa0000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer@2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			usart0: serial@fffb0000 {
 				pinctrl-0 = <&pinctrl_usart0 &pinctrl_usart0_rts>;
 				linux,rs485-enabled-at-boot-time;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 10/58] ARM: dts: at91: animeo_ip: use TCB0 as clocksource
@ 2017-05-30 21:50   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/animeo_ip.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/animeo_ip.dts b/arch/arm/boot/dts/animeo_ip.dts
index 9cc372b9fb9b..710a6f17bc28 100644
--- a/arch/arm/boot/dts/animeo_ip.dts
+++ b/arch/arm/boot/dts/animeo_ip.dts
@@ -43,6 +43,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer at fffa0000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer at 2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			usart0: serial at fffb0000 {
 				pinctrl-0 = <&pinctrl_usart0 &pinctrl_usart0_rts>;
 				linux,rs485-enabled-at-boot-time;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 11/58] ARM: dts: at91: kizbox: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:50   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Antoine Aubert

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Cc: Antoine Aubert <a.aubert@overkiz.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-kizbox.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-kizbox.dts b/arch/arm/boot/dts/at91-kizbox.dts
index b4f147c193fd..c6bf08f8201e 100644
--- a/arch/arm/boot/dts/at91-kizbox.dts
+++ b/arch/arm/boot/dts/at91-kizbox.dts
@@ -31,6 +31,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer@fffa0000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer@2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			macb0: ethernet@fffc4000 {
 				phy-mode = "mii";
 				pinctrl-0 = <&pinctrl_macb_rmii
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 11/58] ARM: dts: at91: kizbox: use TCB0 as clocksource
@ 2017-05-30 21:50   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Cc: Antoine Aubert <a.aubert@overkiz.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-kizbox.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-kizbox.dts b/arch/arm/boot/dts/at91-kizbox.dts
index b4f147c193fd..c6bf08f8201e 100644
--- a/arch/arm/boot/dts/at91-kizbox.dts
+++ b/arch/arm/boot/dts/at91-kizbox.dts
@@ -31,6 +31,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer at fffa0000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer at 2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			macb0: ethernet at fffc4000 {
 				phy-mode = "mii";
 				pinctrl-0 = <&pinctrl_macb_rmii
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 12/58] ARM: dts: at91: at91sam9g20ek: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:50   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9g20ek_common.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
index 27847a47c108..792f879ebe3d 100644
--- a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
+++ b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
@@ -51,6 +51,18 @@
 				status = "okay";
 			};
 
+			tcb0: timer@fffa0000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer@2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			usart0: serial@fffb0000 {
 				pinctrl-0 =
 					<&pinctrl_usart0
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 12/58] ARM: dts: at91: at91sam9g20ek: use TCB0 as clocksource
@ 2017-05-30 21:50   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9g20ek_common.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
index 27847a47c108..792f879ebe3d 100644
--- a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
+++ b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
@@ -51,6 +51,18 @@
 				status = "okay";
 			};
 
+			tcb0: timer at fffa0000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer at 2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			usart0: serial at fffb0000 {
 				pinctrl-0 =
 					<&pinctrl_usart0
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 13/58] ARM: dts: at91: ge863-pro3: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:50   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Fabio Porcedda

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Cc: Fabio Porcedda <fabio.porcedda@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/ge863-pro3.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/ge863-pro3.dtsi b/arch/arm/boot/dts/ge863-pro3.dtsi
index 4aee5cc75fa4..eef2303806bc 100644
--- a/arch/arm/boot/dts/ge863-pro3.dtsi
+++ b/arch/arm/boot/dts/ge863-pro3.dtsi
@@ -18,6 +18,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer@fffa0000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer@2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			dbgu: serial@fffff200 {
 				status = "okay";
 			};
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 13/58] ARM: dts: at91: ge863-pro3: use TCB0 as clocksource
@ 2017-05-30 21:50   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Cc: Fabio Porcedda <fabio.porcedda@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/ge863-pro3.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/ge863-pro3.dtsi b/arch/arm/boot/dts/ge863-pro3.dtsi
index 4aee5cc75fa4..eef2303806bc 100644
--- a/arch/arm/boot/dts/ge863-pro3.dtsi
+++ b/arch/arm/boot/dts/ge863-pro3.dtsi
@@ -18,6 +18,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer at fffa0000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer at 2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			dbgu: serial at fffff200 {
 				status = "okay";
 			};
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 14/58] ARM: dts: at91: at91sam9261: TC blocks are also simple-mfd and syscon devices
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:50   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allows to use regmap
instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9261.dtsi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/at91sam9261.dtsi b/arch/arm/boot/dts/at91sam9261.dtsi
index 7e80acda8f69..d877ab19f5c5 100644
--- a/arch/arm/boot/dts/at91sam9261.dtsi
+++ b/arch/arm/boot/dts/at91sam9261.dtsi
@@ -114,7 +114,9 @@
 			ranges;
 
 			tcb0: timer@fffa0000 {
-				compatible = "atmel,at91rm9200-tcb";
+				compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xfffa0000 0x100>;
 				interrupts = <17 IRQ_TYPE_LEVEL_HIGH 0>,
 					     <18 IRQ_TYPE_LEVEL_HIGH 0>,
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 14/58] ARM: dts: at91: at91sam9261: TC blocks are also simple-mfd and syscon devices
@ 2017-05-30 21:50   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allows to use regmap
instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9261.dtsi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/at91sam9261.dtsi b/arch/arm/boot/dts/at91sam9261.dtsi
index 7e80acda8f69..d877ab19f5c5 100644
--- a/arch/arm/boot/dts/at91sam9261.dtsi
+++ b/arch/arm/boot/dts/at91sam9261.dtsi
@@ -114,7 +114,9 @@
 			ranges;
 
 			tcb0: timer at fffa0000 {
-				compatible = "atmel,at91rm9200-tcb";
+				compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xfffa0000 0x100>;
 				interrupts = <17 IRQ_TYPE_LEVEL_HIGH 0>,
 					     <18 IRQ_TYPE_LEVEL_HIGH 0>,
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 15/58] ARM: dts: at91: at91sam9261ek: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:50   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9261ek.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91sam9261ek.dts b/arch/arm/boot/dts/at91sam9261ek.dts
index 55bd51f07fa6..91ce8648e2ce 100644
--- a/arch/arm/boot/dts/at91sam9261ek.dts
+++ b/arch/arm/boot/dts/at91sam9261ek.dts
@@ -106,6 +106,18 @@
 		};
 
 		apb {
+			tcb0: timer@fffa0000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer@1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			usb1: gadget@fffa4000 {
 				atmel,vbus-gpio = <&pioB 29 GPIO_ACTIVE_HIGH>;
 				status = "okay";
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 15/58] ARM: dts: at91: at91sam9261ek: use TCB0 as clocksource
@ 2017-05-30 21:50   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9261ek.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91sam9261ek.dts b/arch/arm/boot/dts/at91sam9261ek.dts
index 55bd51f07fa6..91ce8648e2ce 100644
--- a/arch/arm/boot/dts/at91sam9261ek.dts
+++ b/arch/arm/boot/dts/at91sam9261ek.dts
@@ -106,6 +106,18 @@
 		};
 
 		apb {
+			tcb0: timer at fffa0000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer at 1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			usb1: gadget at fffa4000 {
 				atmel,vbus-gpio = <&pioB 29 GPIO_ACTIVE_HIGH>;
 				status = "okay";
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 16/58] ARM: dts: at91: at91sam9263: TC blocks are also simple-mfd and syscon devices
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:50   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allows to use regmap
instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9263.dtsi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/at91sam9263.dtsi b/arch/arm/boot/dts/at91sam9263.dtsi
index a1888f6d892b..99c67a9618ef 100644
--- a/arch/arm/boot/dts/at91sam9263.dtsi
+++ b/arch/arm/boot/dts/at91sam9263.dtsi
@@ -374,7 +374,9 @@
 			};
 
 			tcb0: timer@fff7c000 {
-				compatible = "atmel,at91rm9200-tcb";
+				compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xfff7c000 0x100>;
 				interrupts = <19 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb_clk>, <&slow_xtal>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 16/58] ARM: dts: at91: at91sam9263: TC blocks are also simple-mfd and syscon devices
@ 2017-05-30 21:50   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allows to use regmap
instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9263.dtsi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/at91sam9263.dtsi b/arch/arm/boot/dts/at91sam9263.dtsi
index a1888f6d892b..99c67a9618ef 100644
--- a/arch/arm/boot/dts/at91sam9263.dtsi
+++ b/arch/arm/boot/dts/at91sam9263.dtsi
@@ -374,7 +374,9 @@
 			};
 
 			tcb0: timer at fff7c000 {
-				compatible = "atmel,at91rm9200-tcb";
+				compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xfff7c000 0x100>;
 				interrupts = <19 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb_clk>, <&slow_xtal>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 17/58] ARM: dts: at91: at91sam9263ek: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:50   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9263ek.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91sam9263ek.dts b/arch/arm/boot/dts/at91sam9263ek.dts
index 127cc42e9e29..33f73ea26686 100644
--- a/arch/arm/boot/dts/at91sam9263ek.dts
+++ b/arch/arm/boot/dts/at91sam9263ek.dts
@@ -37,6 +37,18 @@
 				status = "okay";
 			};
 
+			tcb0: timer@fff7c000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer@2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			usart0: serial@fff8c000 {
 				pinctrl-0 = <
 					&pinctrl_usart0
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 17/58] ARM: dts: at91: at91sam9263ek: use TCB0 as clocksource
@ 2017-05-30 21:50   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9263ek.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91sam9263ek.dts b/arch/arm/boot/dts/at91sam9263ek.dts
index 127cc42e9e29..33f73ea26686 100644
--- a/arch/arm/boot/dts/at91sam9263ek.dts
+++ b/arch/arm/boot/dts/at91sam9263ek.dts
@@ -37,6 +37,18 @@
 				status = "okay";
 			};
 
+			tcb0: timer at fff7c000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer at 2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			usart0: serial at fff8c000 {
 				pinctrl-0 = <
 					&pinctrl_usart0
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 18/58] ARM: dts: at91: calao: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:50   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Gregory Hermant

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Cc: Gregory Hermant <gregory.hermant@calao-systems.com>
[tested on usb_a9g20 and usb_a9263]
Tested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-qil_a9260.dts    | 12 ++++++++++++
 arch/arm/boot/dts/tny_a9260_common.dtsi | 12 ++++++++++++
 arch/arm/boot/dts/tny_a9263.dts         | 12 ++++++++++++
 arch/arm/boot/dts/usb_a9260_common.dtsi | 12 ++++++++++++
 arch/arm/boot/dts/usb_a9263.dts         | 12 ++++++++++++
 5 files changed, 60 insertions(+)

diff --git a/arch/arm/boot/dts/at91-qil_a9260.dts b/arch/arm/boot/dts/at91-qil_a9260.dts
index 8f019184fccf..3a7286c38b5a 100644
--- a/arch/arm/boot/dts/at91-qil_a9260.dts
+++ b/arch/arm/boot/dts/at91-qil_a9260.dts
@@ -31,6 +31,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer@fffa0000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer@2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			usb1: gadget@fffa4000 {
 				atmel,vbus-gpio = <&pioC 5 GPIO_ACTIVE_HIGH>;
 				status = "okay";
diff --git a/arch/arm/boot/dts/tny_a9260_common.dtsi b/arch/arm/boot/dts/tny_a9260_common.dtsi
index f9dc463b9e48..4cc4d900312c 100644
--- a/arch/arm/boot/dts/tny_a9260_common.dtsi
+++ b/arch/arm/boot/dts/tny_a9260_common.dtsi
@@ -27,6 +27,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer@fffa0000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer@2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			dbgu: serial@fffff200 {
 				status = "okay";
 			};
diff --git a/arch/arm/boot/dts/tny_a9263.dts b/arch/arm/boot/dts/tny_a9263.dts
index 9161cd9889b4..52bde3ec3ec3 100644
--- a/arch/arm/boot/dts/tny_a9263.dts
+++ b/arch/arm/boot/dts/tny_a9263.dts
@@ -36,6 +36,18 @@
 				status = "okay";
 			};
 
+			tcb0: timer@fff7c000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer@2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			usb1: gadget@fff78000 {
 				atmel,vbus-gpio = <&pioB 11 GPIO_ACTIVE_HIGH>;
 				status = "okay";
diff --git a/arch/arm/boot/dts/usb_a9260_common.dtsi b/arch/arm/boot/dts/usb_a9260_common.dtsi
index 7514b347cdd2..03416f792d35 100644
--- a/arch/arm/boot/dts/usb_a9260_common.dtsi
+++ b/arch/arm/boot/dts/usb_a9260_common.dtsi
@@ -23,6 +23,18 @@
 				status = "okay";
 			};
 
+			tcb0: timer@fffa0000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer@2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			macb0: ethernet@fffc4000 {
 				phy-mode = "rmii";
 				status = "okay";
diff --git a/arch/arm/boot/dts/usb_a9263.dts b/arch/arm/boot/dts/usb_a9263.dts
index bfc48a272417..b7f0c14c8099 100644
--- a/arch/arm/boot/dts/usb_a9263.dts
+++ b/arch/arm/boot/dts/usb_a9263.dts
@@ -36,6 +36,18 @@
 				status = "okay";
 			};
 
+			tcb0: timer@fff7c000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer@2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			macb0: ethernet@fffbc000 {
 				phy-mode = "rmii";
 				status = "okay";
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 18/58] ARM: dts: at91: calao: use TCB0 as clocksource
@ 2017-05-30 21:50   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Cc: Gregory Hermant <gregory.hermant@calao-systems.com>
[tested on usb_a9g20 and usb_a9263]
Tested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-qil_a9260.dts    | 12 ++++++++++++
 arch/arm/boot/dts/tny_a9260_common.dtsi | 12 ++++++++++++
 arch/arm/boot/dts/tny_a9263.dts         | 12 ++++++++++++
 arch/arm/boot/dts/usb_a9260_common.dtsi | 12 ++++++++++++
 arch/arm/boot/dts/usb_a9263.dts         | 12 ++++++++++++
 5 files changed, 60 insertions(+)

diff --git a/arch/arm/boot/dts/at91-qil_a9260.dts b/arch/arm/boot/dts/at91-qil_a9260.dts
index 8f019184fccf..3a7286c38b5a 100644
--- a/arch/arm/boot/dts/at91-qil_a9260.dts
+++ b/arch/arm/boot/dts/at91-qil_a9260.dts
@@ -31,6 +31,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer at fffa0000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer at 2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			usb1: gadget at fffa4000 {
 				atmel,vbus-gpio = <&pioC 5 GPIO_ACTIVE_HIGH>;
 				status = "okay";
diff --git a/arch/arm/boot/dts/tny_a9260_common.dtsi b/arch/arm/boot/dts/tny_a9260_common.dtsi
index f9dc463b9e48..4cc4d900312c 100644
--- a/arch/arm/boot/dts/tny_a9260_common.dtsi
+++ b/arch/arm/boot/dts/tny_a9260_common.dtsi
@@ -27,6 +27,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer at fffa0000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer at 2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			dbgu: serial at fffff200 {
 				status = "okay";
 			};
diff --git a/arch/arm/boot/dts/tny_a9263.dts b/arch/arm/boot/dts/tny_a9263.dts
index 9161cd9889b4..52bde3ec3ec3 100644
--- a/arch/arm/boot/dts/tny_a9263.dts
+++ b/arch/arm/boot/dts/tny_a9263.dts
@@ -36,6 +36,18 @@
 				status = "okay";
 			};
 
+			tcb0: timer at fff7c000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer at 2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			usb1: gadget at fff78000 {
 				atmel,vbus-gpio = <&pioB 11 GPIO_ACTIVE_HIGH>;
 				status = "okay";
diff --git a/arch/arm/boot/dts/usb_a9260_common.dtsi b/arch/arm/boot/dts/usb_a9260_common.dtsi
index 7514b347cdd2..03416f792d35 100644
--- a/arch/arm/boot/dts/usb_a9260_common.dtsi
+++ b/arch/arm/boot/dts/usb_a9260_common.dtsi
@@ -23,6 +23,18 @@
 				status = "okay";
 			};
 
+			tcb0: timer at fffa0000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer at 2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			macb0: ethernet at fffc4000 {
 				phy-mode = "rmii";
 				status = "okay";
diff --git a/arch/arm/boot/dts/usb_a9263.dts b/arch/arm/boot/dts/usb_a9263.dts
index bfc48a272417..b7f0c14c8099 100644
--- a/arch/arm/boot/dts/usb_a9263.dts
+++ b/arch/arm/boot/dts/usb_a9263.dts
@@ -36,6 +36,18 @@
 				status = "okay";
 			};
 
+			tcb0: timer at fff7c000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer at 2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			macb0: ethernet at fffbc000 {
 				phy-mode = "rmii";
 				status = "okay";
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 19/58] ARM: dts: at91: at91sam9g45: TC blocks are also simple-mfd and syscon devices
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allows to use regmap
instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9g45.dtsi | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index e567d5fd3f9d..edb4d80e295a 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -405,7 +405,9 @@
 			};
 
 			tcb0: timer@fff7c000 {
-				compatible = "atmel,at91rm9200-tcb";
+				compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xfff7c000 0x100>;
 				interrupts = <18 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb0_clk>, <&tcb0_clk>, <&tcb0_clk>, <&clk32k>;
@@ -413,7 +415,9 @@
 			};
 
 			tcb1: timer@fffd4000 {
-				compatible = "atmel,at91rm9200-tcb";
+				compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xfffd4000 0x100>;
 				interrupts = <18 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb0_clk>, <&tcb0_clk>, <&tcb0_clk>, <&clk32k>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 19/58] ARM: dts: at91: at91sam9g45: TC blocks are also simple-mfd and syscon devices
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allows to use regmap
instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9g45.dtsi | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index e567d5fd3f9d..edb4d80e295a 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -405,7 +405,9 @@
 			};
 
 			tcb0: timer at fff7c000 {
-				compatible = "atmel,at91rm9200-tcb";
+				compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xfff7c000 0x100>;
 				interrupts = <18 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb0_clk>, <&tcb0_clk>, <&tcb0_clk>, <&clk32k>;
@@ -413,7 +415,9 @@
 			};
 
 			tcb1: timer at fffd4000 {
-				compatible = "atmel,at91rm9200-tcb";
+				compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xfffd4000 0x100>;
 				interrupts = <18 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb0_clk>, <&tcb0_clk>, <&tcb0_clk>, <&clk32k>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 20/58] ARM: dts: at91: at91sam9m10g45ek: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Tested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9m10g45ek.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts
index 2400c99134f7..618c04c1dff5 100644
--- a/arch/arm/boot/dts/at91sam9m10g45ek.dts
+++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts
@@ -39,6 +39,18 @@
 				status = "okay";
 			};
 
+			tcb0: timer@fff7c000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer@2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			usart1: serial@fff90000 {
 				pinctrl-0 =
 					<&pinctrl_usart1
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 20/58] ARM: dts: at91: at91sam9m10g45ek: use TCB0 as clocksource
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Tested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9m10g45ek.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts
index 2400c99134f7..618c04c1dff5 100644
--- a/arch/arm/boot/dts/at91sam9m10g45ek.dts
+++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts
@@ -39,6 +39,18 @@
 				status = "okay";
 			};
 
+			tcb0: timer at fff7c000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer at 2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			usart1: serial at fff90000 {
 				pinctrl-0 =
 					<&pinctrl_usart1
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 21/58] ARM: dts: at91: pm9g45: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/pm9g45.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/pm9g45.dts b/arch/arm/boot/dts/pm9g45.dts
index 0abd7bf17568..b372e7b2f3df 100644
--- a/arch/arm/boot/dts/pm9g45.dts
+++ b/arch/arm/boot/dts/pm9g45.dts
@@ -54,6 +54,18 @@
 				};
 			};
 
+			tcb0: timer@fff7c000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer@2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			mmc0: mmc@fff80000 {
 				pinctrl-0 = <
 					&pinctrl_board_mmc
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 21/58] ARM: dts: at91: pm9g45: use TCB0 as clocksource
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/pm9g45.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/pm9g45.dts b/arch/arm/boot/dts/pm9g45.dts
index 0abd7bf17568..b372e7b2f3df 100644
--- a/arch/arm/boot/dts/pm9g45.dts
+++ b/arch/arm/boot/dts/pm9g45.dts
@@ -54,6 +54,18 @@
 				};
 			};
 
+			tcb0: timer at fff7c000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer at 2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			mmc0: mmc at fff80000 {
 				pinctrl-0 = <
 					&pinctrl_board_mmc
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 22/58] ARM: dts: at91: at91sam9rl: TC blocks are also simple-mfd and syscon devices
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allows to use regmap
instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9rl.dtsi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/at91sam9rl.dtsi b/arch/arm/boot/dts/at91sam9rl.dtsi
index f4c129a98f17..b77c5fbb8d9d 100644
--- a/arch/arm/boot/dts/at91sam9rl.dtsi
+++ b/arch/arm/boot/dts/at91sam9rl.dtsi
@@ -116,7 +116,9 @@
 			ranges;
 
 			tcb0: timer@fffa0000 {
-				compatible = "atmel,at91rm9200-tcb";
+				compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xfffa0000 0x100>;
 				interrupts = <16 IRQ_TYPE_LEVEL_HIGH 0>,
 					     <17 IRQ_TYPE_LEVEL_HIGH 0>,
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 22/58] ARM: dts: at91: at91sam9rl: TC blocks are also simple-mfd and syscon devices
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allows to use regmap
instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9rl.dtsi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/at91sam9rl.dtsi b/arch/arm/boot/dts/at91sam9rl.dtsi
index f4c129a98f17..b77c5fbb8d9d 100644
--- a/arch/arm/boot/dts/at91sam9rl.dtsi
+++ b/arch/arm/boot/dts/at91sam9rl.dtsi
@@ -116,7 +116,9 @@
 			ranges;
 
 			tcb0: timer at fffa0000 {
-				compatible = "atmel,at91rm9200-tcb";
+				compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xfffa0000 0x100>;
 				interrupts = <16 IRQ_TYPE_LEVEL_HIGH 0>,
 					     <17 IRQ_TYPE_LEVEL_HIGH 0>,
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 23/58] ARM: dts: at91: at91sam9rlek: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9rlek.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91sam9rlek.dts b/arch/arm/boot/dts/at91sam9rlek.dts
index 2e567d90fba8..b8bd1a594a3e 100644
--- a/arch/arm/boot/dts/at91sam9rlek.dts
+++ b/arch/arm/boot/dts/at91sam9rlek.dts
@@ -101,6 +101,18 @@
 		};
 
 		apb {
+			tcb0: timer@fffa0000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer@2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			mmc0: mmc@fffa4000 {
 				pinctrl-0 = <
 					&pinctrl_board_mmc0
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 23/58] ARM: dts: at91: at91sam9rlek: use TCB0 as clocksource
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9rlek.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91sam9rlek.dts b/arch/arm/boot/dts/at91sam9rlek.dts
index 2e567d90fba8..b8bd1a594a3e 100644
--- a/arch/arm/boot/dts/at91sam9rlek.dts
+++ b/arch/arm/boot/dts/at91sam9rlek.dts
@@ -101,6 +101,18 @@
 		};
 
 		apb {
+			tcb0: timer at fffa0000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>, <1>;
+				};
+
+				timer at 2 {
+					compatible = "atmel,tcb-timer";
+					reg = <2>;
+				};
+			};
+
 			mmc0: mmc at fffa4000 {
 				pinctrl-0 = <
 					&pinctrl_board_mmc0
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 24/58] ARM: dts: at91: at91sam9n12: TC blocks are also simple-mfd and syscon devices
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allows to use regmap
instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9n12.dtsi | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi b/arch/arm/boot/dts/at91sam9n12.dtsi
index f43d7695352d..d86f35fecdb8 100644
--- a/arch/arm/boot/dts/at91sam9n12.dtsi
+++ b/arch/arm/boot/dts/at91sam9n12.dtsi
@@ -430,7 +430,9 @@
 			};
 
 			tcb0: timer@f8008000 {
-				compatible = "atmel,at91sam9x5-tcb";
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xf8008000 0x100>;
 				interrupts = <17 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb_clk>, <&clk32k>;
@@ -438,7 +440,9 @@
 			};
 
 			tcb1: timer@f800c000 {
-				compatible = "atmel,at91sam9x5-tcb";
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xf800c000 0x100>;
 				interrupts = <17 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb_clk>, <&clk32k>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 24/58] ARM: dts: at91: at91sam9n12: TC blocks are also simple-mfd and syscon devices
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allows to use regmap
instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9n12.dtsi | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi b/arch/arm/boot/dts/at91sam9n12.dtsi
index f43d7695352d..d86f35fecdb8 100644
--- a/arch/arm/boot/dts/at91sam9n12.dtsi
+++ b/arch/arm/boot/dts/at91sam9n12.dtsi
@@ -430,7 +430,9 @@
 			};
 
 			tcb0: timer at f8008000 {
-				compatible = "atmel,at91sam9x5-tcb";
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xf8008000 0x100>;
 				interrupts = <17 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb_clk>, <&clk32k>;
@@ -438,7 +440,9 @@
 			};
 
 			tcb1: timer at f800c000 {
-				compatible = "atmel,at91sam9x5-tcb";
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xf800c000 0x100>;
 				interrupts = <17 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb_clk>, <&clk32k>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 25/58] ARM: dts: at91: at91sam9n12ek: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9n12ek.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91sam9n12ek.dts b/arch/arm/boot/dts/at91sam9n12ek.dts
index 626c67d66626..9adda0ca1557 100644
--- a/arch/arm/boot/dts/at91sam9n12ek.dts
+++ b/arch/arm/boot/dts/at91sam9n12ek.dts
@@ -42,6 +42,18 @@
 				status = "okay";
 			};
 
+			tcb0: timer@f8008000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer@1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			i2c0: i2c@f8010000 {
 				status = "okay";
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 25/58] ARM: dts: at91: at91sam9n12ek: use TCB0 as clocksource
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9n12ek.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91sam9n12ek.dts b/arch/arm/boot/dts/at91sam9n12ek.dts
index 626c67d66626..9adda0ca1557 100644
--- a/arch/arm/boot/dts/at91sam9n12ek.dts
+++ b/arch/arm/boot/dts/at91sam9n12ek.dts
@@ -42,6 +42,18 @@
 				status = "okay";
 			};
 
+			tcb0: timer at f8008000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer at 1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			i2c0: i2c at f8010000 {
 				status = "okay";
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 26/58] ARM: dts: at91: at91sam9x5: TC blocks are also simple-mfd and syscon devices
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allows to use regmap
instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9x5.dtsi | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index f66bae925705..b27c716e9091 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -417,7 +417,9 @@
 			};
 
 			tcb0: timer@f8008000 {
-				compatible = "atmel,at91sam9x5-tcb";
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xf8008000 0x100>;
 				interrupts = <17 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb0_clk>, <&clk32k>;
@@ -425,7 +427,9 @@
 			};
 
 			tcb1: timer@f800c000 {
-				compatible = "atmel,at91sam9x5-tcb";
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xf800c000 0x100>;
 				interrupts = <17 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb0_clk>, <&clk32k>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 26/58] ARM: dts: at91: at91sam9x5: TC blocks are also simple-mfd and syscon devices
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allows to use regmap
instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9x5.dtsi | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index f66bae925705..b27c716e9091 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -417,7 +417,9 @@
 			};
 
 			tcb0: timer at f8008000 {
-				compatible = "atmel,at91sam9x5-tcb";
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xf8008000 0x100>;
 				interrupts = <17 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb0_clk>, <&clk32k>;
@@ -425,7 +427,9 @@
 			};
 
 			tcb1: timer at f800c000 {
-				compatible = "atmel,at91sam9x5-tcb";
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xf800c000 0x100>;
 				interrupts = <17 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb0_clk>, <&clk32k>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 27/58] ARM: dts: at91: at91sam9x5cm: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

[tested on at91sam9x25ek and at91sam9x35ek]
Tested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9x5cm.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91sam9x5cm.dtsi b/arch/arm/boot/dts/at91sam9x5cm.dtsi
index b098ad8cd93a..9110bcafb322 100644
--- a/arch/arm/boot/dts/at91sam9x5cm.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5cm.dtsi
@@ -24,6 +24,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer@f8008000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer@1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			pinctrl@fffff400 {
 				1wire_cm {
 					pinctrl_1wire_cm: 1wire_cm-0 {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 27/58] ARM: dts: at91: at91sam9x5cm: use TCB0 as clocksource
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

[tested on at91sam9x25ek and at91sam9x35ek]
Tested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91sam9x5cm.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91sam9x5cm.dtsi b/arch/arm/boot/dts/at91sam9x5cm.dtsi
index b098ad8cd93a..9110bcafb322 100644
--- a/arch/arm/boot/dts/at91sam9x5cm.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5cm.dtsi
@@ -24,6 +24,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer at f8008000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer at 1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			pinctrl at fffff400 {
 				1wire_cm {
 					pinctrl_1wire_cm: 1wire_cm-0 {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 28/58] ARM: dts: at91: acme/g25: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Sergio Tanzilli, Douglas Gilbert

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Cc: Sergio Tanzilli <tanzilli@acmesystems.it>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-ariag25.dts    | 12 ++++++++++++
 arch/arm/boot/dts/at91-ariettag25.dts | 12 ++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/arch/arm/boot/dts/at91-ariag25.dts b/arch/arm/boot/dts/at91-ariag25.dts
index 4da011a7a698..42bce451dba1 100644
--- a/arch/arm/boot/dts/at91-ariag25.dts
+++ b/arch/arm/boot/dts/at91-ariag25.dts
@@ -58,6 +58,18 @@
 				};
 			};
 
+			tcb0: timer@f8008000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer@1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			i2c0: i2c@f8010000 {
 				status = "okay";
 			};
diff --git a/arch/arm/boot/dts/at91-ariettag25.dts b/arch/arm/boot/dts/at91-ariettag25.dts
index c514502081d2..898e8fadc577 100644
--- a/arch/arm/boot/dts/at91-ariettag25.dts
+++ b/arch/arm/boot/dts/at91-ariettag25.dts
@@ -45,6 +45,18 @@
 				};
 			};
 
+			tcb0: timer@f8008000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer@1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			usb2: gadget@f803c000 {
 				status = "okay";
 			};
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 28/58] ARM: dts: at91: acme/g25: use TCB0 as clocksource
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Cc: Sergio Tanzilli <tanzilli@acmesystems.it>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-ariag25.dts    | 12 ++++++++++++
 arch/arm/boot/dts/at91-ariettag25.dts | 12 ++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/arch/arm/boot/dts/at91-ariag25.dts b/arch/arm/boot/dts/at91-ariag25.dts
index 4da011a7a698..42bce451dba1 100644
--- a/arch/arm/boot/dts/at91-ariag25.dts
+++ b/arch/arm/boot/dts/at91-ariag25.dts
@@ -58,6 +58,18 @@
 				};
 			};
 
+			tcb0: timer at f8008000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer at 1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			i2c0: i2c at f8010000 {
 				status = "okay";
 			};
diff --git a/arch/arm/boot/dts/at91-ariettag25.dts b/arch/arm/boot/dts/at91-ariettag25.dts
index c514502081d2..898e8fadc577 100644
--- a/arch/arm/boot/dts/at91-ariettag25.dts
+++ b/arch/arm/boot/dts/at91-ariettag25.dts
@@ -45,6 +45,18 @@
 				};
 			};
 
+			tcb0: timer at f8008000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer at 1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			usb2: gadget at f803c000 {
 				status = "okay";
 			};
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 29/58] ARM: dts: at91: cosino: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Rodolfo Giometti

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Cc: Rodolfo Giometti <giometti@linux.it>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-cosino.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-cosino.dtsi b/arch/arm/boot/dts/at91-cosino.dtsi
index 02d8ef43de3a..9dcee7095c06 100644
--- a/arch/arm/boot/dts/at91-cosino.dtsi
+++ b/arch/arm/boot/dts/at91-cosino.dtsi
@@ -37,6 +37,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer@f8008000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer@1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			mmc0: mmc@f0008000 {
 				pinctrl-0 = <
 					&pinctrl_board_mmc0
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 29/58] ARM: dts: at91: cosino: use TCB0 as clocksource
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Cc: Rodolfo Giometti <giometti@linux.it>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-cosino.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-cosino.dtsi b/arch/arm/boot/dts/at91-cosino.dtsi
index 02d8ef43de3a..9dcee7095c06 100644
--- a/arch/arm/boot/dts/at91-cosino.dtsi
+++ b/arch/arm/boot/dts/at91-cosino.dtsi
@@ -37,6 +37,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer at f8008000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer at 1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			mmc0: mmc at f0008000 {
 				pinctrl-0 = <
 					&pinctrl_board_mmc0
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 30/58] ARM: dts: at91: kizboxmini: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Antoine Aubert

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Cc: Antoine Aubert <a.aubert@overkiz.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-kizboxmini.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-kizboxmini.dts b/arch/arm/boot/dts/at91-kizboxmini.dts
index 9682d105d4d8..fedc2f5c38d9 100644
--- a/arch/arm/boot/dts/at91-kizboxmini.dts
+++ b/arch/arm/boot/dts/at91-kizboxmini.dts
@@ -34,6 +34,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer@f8008000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer@1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			usart0: serial@f801c000 {
 				status = "okay";
 			};
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 30/58] ARM: dts: at91: kizboxmini: use TCB0 as clocksource
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in at91_dt_defconfig.

Cc: Antoine Aubert <a.aubert@overkiz.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-kizboxmini.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-kizboxmini.dts b/arch/arm/boot/dts/at91-kizboxmini.dts
index 9682d105d4d8..fedc2f5c38d9 100644
--- a/arch/arm/boot/dts/at91-kizboxmini.dts
+++ b/arch/arm/boot/dts/at91-kizboxmini.dts
@@ -34,6 +34,18 @@
 
 	ahb {
 		apb {
+			tcb0: timer at f8008000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer at 1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			usart0: serial at f801c000 {
 				status = "okay";
 			};
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 31/58] ARM: dts: at91: sama5d3: TC blocks are also simple-mfd and syscon devices
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allows to use
regmap instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/sama5d3.dtsi      | 4 +++-
 arch/arm/boot/dts/sama5d3_tcb1.dtsi | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/sama5d3.dtsi b/arch/arm/boot/dts/sama5d3.dtsi
index b06448ba6649..d026470c10e7 100644
--- a/arch/arm/boot/dts/sama5d3.dtsi
+++ b/arch/arm/boot/dts/sama5d3.dtsi
@@ -142,7 +142,9 @@
 			};
 
 			tcb0: timer@f0010000 {
-				compatible = "atmel,at91sam9x5-tcb";
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xf0010000 0x100>;
 				interrupts = <26 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb0_clk>, <&clk32k>;
diff --git a/arch/arm/boot/dts/sama5d3_tcb1.dtsi b/arch/arm/boot/dts/sama5d3_tcb1.dtsi
index 801f9745e82f..cb30bdb1a9ca 100644
--- a/arch/arm/boot/dts/sama5d3_tcb1.dtsi
+++ b/arch/arm/boot/dts/sama5d3_tcb1.dtsi
@@ -28,7 +28,9 @@
 			};
 
 			tcb1: timer@f8014000 {
-				compatible = "atmel,at91sam9x5-tcb";
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xf8014000 0x100>;
 				interrupts = <27 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb1_clk>, <&clk32k>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 31/58] ARM: dts: at91: sama5d3: TC blocks are also simple-mfd and syscon devices
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allows to use
regmap instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/sama5d3.dtsi      | 4 +++-
 arch/arm/boot/dts/sama5d3_tcb1.dtsi | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/sama5d3.dtsi b/arch/arm/boot/dts/sama5d3.dtsi
index b06448ba6649..d026470c10e7 100644
--- a/arch/arm/boot/dts/sama5d3.dtsi
+++ b/arch/arm/boot/dts/sama5d3.dtsi
@@ -142,7 +142,9 @@
 			};
 
 			tcb0: timer at f0010000 {
-				compatible = "atmel,at91sam9x5-tcb";
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xf0010000 0x100>;
 				interrupts = <26 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb0_clk>, <&clk32k>;
diff --git a/arch/arm/boot/dts/sama5d3_tcb1.dtsi b/arch/arm/boot/dts/sama5d3_tcb1.dtsi
index 801f9745e82f..cb30bdb1a9ca 100644
--- a/arch/arm/boot/dts/sama5d3_tcb1.dtsi
+++ b/arch/arm/boot/dts/sama5d3_tcb1.dtsi
@@ -28,7 +28,9 @@
 			};
 
 			tcb1: timer at f8014000 {
-				compatible = "atmel,at91sam9x5-tcb";
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xf8014000 0x100>;
 				interrupts = <27 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb1_clk>, <&clk32k>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 32/58] ARM: dts: at91: sama5d3xek: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Use tcb0 as the clocksource like previously selected in sama5_defconfig.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/sama5d3xcm.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d3xcm.dtsi b/arch/arm/boot/dts/sama5d3xcm.dtsi
index b5e111b29da1..ac583c36b542 100644
--- a/arch/arm/boot/dts/sama5d3xcm.dtsi
+++ b/arch/arm/boot/dts/sama5d3xcm.dtsi
@@ -34,6 +34,18 @@
 			spi0: spi@f0004000 {
 				cs-gpios = <&pioD 13 0>, <0>, <0>, <0>;
 			};
+
+			tcb0: timer@f0010000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer@1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
 		};
 
 		nand0: nand@60000000 {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 32/58] ARM: dts: at91: sama5d3xek: use TCB0 as clocksource
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in sama5_defconfig.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/sama5d3xcm.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d3xcm.dtsi b/arch/arm/boot/dts/sama5d3xcm.dtsi
index b5e111b29da1..ac583c36b542 100644
--- a/arch/arm/boot/dts/sama5d3xcm.dtsi
+++ b/arch/arm/boot/dts/sama5d3xcm.dtsi
@@ -34,6 +34,18 @@
 			spi0: spi at f0004000 {
 				cs-gpios = <&pioD 13 0>, <0>, <0>, <0>;
 			};
+
+			tcb0: timer at f0010000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer at 1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
 		};
 
 		nand0: nand at 60000000 {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 33/58] ARM: dts: at91: sama5d3 Xplained: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Use tcb0 as the clocksource like previously selected in sama5_defconfig.

Tested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-sama5d3_xplained.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-sama5d3_xplained.dts b/arch/arm/boot/dts/at91-sama5d3_xplained.dts
index 5a53fcf542ab..33bec1e9f22e 100644
--- a/arch/arm/boot/dts/at91-sama5d3_xplained.dts
+++ b/arch/arm/boot/dts/at91-sama5d3_xplained.dts
@@ -65,6 +65,18 @@
 				status = "okay";
 			};
 
+			tcb0: timer@f0010000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer@1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			i2c0: i2c@f0014000 {
 				pinctrl-0 = <&pinctrl_i2c0_pu>;
 				status = "okay";
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 33/58] ARM: dts: at91: sama5d3 Xplained: use TCB0 as clocksource
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in sama5_defconfig.

Tested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-sama5d3_xplained.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-sama5d3_xplained.dts b/arch/arm/boot/dts/at91-sama5d3_xplained.dts
index 5a53fcf542ab..33bec1e9f22e 100644
--- a/arch/arm/boot/dts/at91-sama5d3_xplained.dts
+++ b/arch/arm/boot/dts/at91-sama5d3_xplained.dts
@@ -65,6 +65,18 @@
 				status = "okay";
 			};
 
+			tcb0: timer at f0010000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer at 1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			i2c0: i2c at f0014000 {
 				pinctrl-0 = <&pinctrl_i2c0_pu>;
 				status = "okay";
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 34/58] ARM: dts: at91: kizbox2: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Antoine Aubert

Use tcb0 as the clocksource like previously selected in sama5_defconfig.

Cc: Antoine Aubert <a.aubert@overkiz.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-kizbox2.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-kizbox2.dts b/arch/arm/boot/dts/at91-kizbox2.dts
index 50a14568f094..4fd5d1c996d6 100644
--- a/arch/arm/boot/dts/at91-kizbox2.dts
+++ b/arch/arm/boot/dts/at91-kizbox2.dts
@@ -94,6 +94,18 @@
 				};
 			};
 
+			tcb0: timer@f0010000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer@1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			usart0: serial@f001c000 {
 				status = "okay";
 			};
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 34/58] ARM: dts: at91: kizbox2: use TCB0 as clocksource
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in sama5_defconfig.

Cc: Antoine Aubert <a.aubert@overkiz.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-kizbox2.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-kizbox2.dts b/arch/arm/boot/dts/at91-kizbox2.dts
index 50a14568f094..4fd5d1c996d6 100644
--- a/arch/arm/boot/dts/at91-kizbox2.dts
+++ b/arch/arm/boot/dts/at91-kizbox2.dts
@@ -94,6 +94,18 @@
 				};
 			};
 
+			tcb0: timer at f0010000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer at 1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			usart0: serial at f001c000 {
 				status = "okay";
 			};
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 35/58] ARM: dts: at91: sama5d3xek_cmp: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Use tcb0 as the clocksource like previously selected in sama5_defconfig.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/sama5d3xcm_cmp.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d3xcm_cmp.dtsi b/arch/arm/boot/dts/sama5d3xcm_cmp.dtsi
index dc7572bc7ff0..2908879e84cf 100644
--- a/arch/arm/boot/dts/sama5d3xcm_cmp.dtsi
+++ b/arch/arm/boot/dts/sama5d3xcm_cmp.dtsi
@@ -69,6 +69,18 @@
 				cs-gpios = <&pioD 13 0>, <0>, <0>, <0>;
 			};
 
+			tcb0: timer@f0010000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer@1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			macb0: ethernet@f0028000 {
 				phy-mode = "rgmii";
 				#address-cells = <1>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 35/58] ARM: dts: at91: sama5d3xek_cmp: use TCB0 as clocksource
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in sama5_defconfig.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/sama5d3xcm_cmp.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d3xcm_cmp.dtsi b/arch/arm/boot/dts/sama5d3xcm_cmp.dtsi
index dc7572bc7ff0..2908879e84cf 100644
--- a/arch/arm/boot/dts/sama5d3xcm_cmp.dtsi
+++ b/arch/arm/boot/dts/sama5d3xcm_cmp.dtsi
@@ -69,6 +69,18 @@
 				cs-gpios = <&pioD 13 0>, <0>, <0>, <0>;
 			};
 
+			tcb0: timer at f0010000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer at 1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			macb0: ethernet at f0028000 {
 				phy-mode = "rgmii";
 				#address-cells = <1>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 36/58] ARM: dts: at91: linea/tse850-3: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Peter Rosin

Use tcb0 as the clocksource like previously selected in sama5_defconfig.

Cc: Peter Rosin <peda@axentia.se>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-linea.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-linea.dtsi b/arch/arm/boot/dts/at91-linea.dtsi
index 0721c8472509..7f73e98e223f 100644
--- a/arch/arm/boot/dts/at91-linea.dtsi
+++ b/arch/arm/boot/dts/at91-linea.dtsi
@@ -27,6 +27,18 @@
 	clock-frequency = <12000000>;
 };
 
+&tcb0 {
+	timer@0 {
+		compatible = "atmel,tcb-timer";
+		reg = <0>;
+	};
+
+	timer@1 {
+		compatible = "atmel,tcb-timer";
+		reg = <1>;
+	};
+};
+
 &i2c0 {
 	status = "okay";
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 36/58] ARM: dts: at91: linea/tse850-3: use TCB0 as clocksource
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in sama5_defconfig.

Cc: Peter Rosin <peda@axentia.se>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-linea.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-linea.dtsi b/arch/arm/boot/dts/at91-linea.dtsi
index 0721c8472509..7f73e98e223f 100644
--- a/arch/arm/boot/dts/at91-linea.dtsi
+++ b/arch/arm/boot/dts/at91-linea.dtsi
@@ -27,6 +27,18 @@
 	clock-frequency = <12000000>;
 };
 
+&tcb0 {
+	timer at 0 {
+		compatible = "atmel,tcb-timer";
+		reg = <0>;
+	};
+
+	timer at 1 {
+		compatible = "atmel,tcb-timer";
+		reg = <1>;
+	};
+};
+
 &i2c0 {
 	status = "okay";
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 37/58] ARM: dts: at91: sama5d4: TC blocks are also simple-mfd and syscon devices
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allow sto reuse
regmap instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/sama5d4.dtsi | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/sama5d4.dtsi b/arch/arm/boot/dts/sama5d4.dtsi
index d3889c9d25a9..73d38326cc43 100644
--- a/arch/arm/boot/dts/sama5d4.dtsi
+++ b/arch/arm/boot/dts/sama5d4.dtsi
@@ -954,7 +954,9 @@
 			};
 
 			tcb0: timer@f801c000 {
-				compatible = "atmel,at91sam9x5-tcb";
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xf801c000 0x100>;
 				interrupts = <40 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb0_clk>, <&clk32k>;
@@ -1182,7 +1184,9 @@
 			};
 
 			tcb1: timer@fc020000 {
-				compatible = "atmel,at91sam9x5-tcb";
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xfc020000 0x100>;
 				interrupts = <41 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb1_clk>, <&clk32k>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 37/58] ARM: dts: at91: sama5d4: TC blocks are also simple-mfd and syscon devices
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allow sto reuse
regmap instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/sama5d4.dtsi | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/sama5d4.dtsi b/arch/arm/boot/dts/sama5d4.dtsi
index d3889c9d25a9..73d38326cc43 100644
--- a/arch/arm/boot/dts/sama5d4.dtsi
+++ b/arch/arm/boot/dts/sama5d4.dtsi
@@ -954,7 +954,9 @@
 			};
 
 			tcb0: timer at f801c000 {
-				compatible = "atmel,at91sam9x5-tcb";
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xf801c000 0x100>;
 				interrupts = <40 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb0_clk>, <&clk32k>;
@@ -1182,7 +1184,9 @@
 			};
 
 			tcb1: timer at fc020000 {
-				compatible = "atmel,at91sam9x5-tcb";
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xfc020000 0x100>;
 				interrupts = <41 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb1_clk>, <&clk32k>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 38/58] ARM: dts: at91: sama5d4: Add TCB2
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

The third TC block is missing from the dtsi. It has no output pins but can
still be used as a clocksource/clockevents device as the IRQ is wired.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/sama5d4.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d4.dtsi b/arch/arm/boot/dts/sama5d4.dtsi
index 73d38326cc43..1ff956ad159d 100644
--- a/arch/arm/boot/dts/sama5d4.dtsi
+++ b/arch/arm/boot/dts/sama5d4.dtsi
@@ -1193,6 +1193,16 @@
 				clock-names = "t0_clk", "slow_clk";
 			};
 
+			tcb2: timer@fc024000 {
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
+				reg = <0xfc024000 0x100>;
+				interrupts = <42 IRQ_TYPE_LEVEL_HIGH 0>;
+				clocks = <&tcb2_clk>, <&clk32k>;
+				clock-names = "t0_clk", "slow_clk";
+			};
+
 			macb1: ethernet@fc028000 {
 				compatible = "atmel,sama5d4-gem";
 				reg = <0xfc028000 0x100>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 38/58] ARM: dts: at91: sama5d4: Add TCB2
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

The third TC block is missing from the dtsi. It has no output pins but can
still be used as a clocksource/clockevents device as the IRQ is wired.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/sama5d4.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm/boot/dts/sama5d4.dtsi b/arch/arm/boot/dts/sama5d4.dtsi
index 73d38326cc43..1ff956ad159d 100644
--- a/arch/arm/boot/dts/sama5d4.dtsi
+++ b/arch/arm/boot/dts/sama5d4.dtsi
@@ -1193,6 +1193,16 @@
 				clock-names = "t0_clk", "slow_clk";
 			};
 
+			tcb2: timer at fc024000 {
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
+				reg = <0xfc024000 0x100>;
+				interrupts = <42 IRQ_TYPE_LEVEL_HIGH 0>;
+				clocks = <&tcb2_clk>, <&clk32k>;
+				clock-names = "t0_clk", "slow_clk";
+			};
+
 			macb1: ethernet at fc028000 {
 				compatible = "atmel,sama5d4-gem";
 				reg = <0xfc028000 0x100>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 39/58] ARM: dts: at91: sama5d4ek: use TCB2 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

As TCB2 doesn't have any output pins, use it as a clocksource.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-sama5d4ek.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-sama5d4ek.dts b/arch/arm/boot/dts/at91-sama5d4ek.dts
index f8b96cef5e1a..61f90333438b 100644
--- a/arch/arm/boot/dts/at91-sama5d4ek.dts
+++ b/arch/arm/boot/dts/at91-sama5d4ek.dts
@@ -174,6 +174,18 @@
 				status = "okay";
 			};
 
+			tcb2: timer@fc024000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer@1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			watchdog@fc068640 {
 				status = "okay";
 			};
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 39/58] ARM: dts: at91: sama5d4ek: use TCB2 as clocksource
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

As TCB2 doesn't have any output pins, use it as a clocksource.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-sama5d4ek.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-sama5d4ek.dts b/arch/arm/boot/dts/at91-sama5d4ek.dts
index f8b96cef5e1a..61f90333438b 100644
--- a/arch/arm/boot/dts/at91-sama5d4ek.dts
+++ b/arch/arm/boot/dts/at91-sama5d4ek.dts
@@ -174,6 +174,18 @@
 				status = "okay";
 			};
 
+			tcb2: timer at fc024000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer at 1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			watchdog at fc068640 {
 				status = "okay";
 			};
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 40/58] ARM: dts: at91: sama5d4 Xplained: use TCB2 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

As TCB2 doesn't have any output pins, use it as a clocksource.

Tested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-sama5d4_xplained.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-sama5d4_xplained.dts b/arch/arm/boot/dts/at91-sama5d4_xplained.dts
index 5ab14cedb1db..9d2824540e95 100644
--- a/arch/arm/boot/dts/at91-sama5d4_xplained.dts
+++ b/arch/arm/boot/dts/at91-sama5d4_xplained.dts
@@ -130,6 +130,18 @@
 				status = "okay";
 			};
 
+			tcb2: timer@fc024000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer@1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			adc0: adc@fc034000 {
 				pinctrl-names = "default";
 				pinctrl-0 = <
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 40/58] ARM: dts: at91: sama5d4 Xplained: use TCB2 as clocksource
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

As TCB2 doesn't have any output pins, use it as a clocksource.

Tested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-sama5d4_xplained.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-sama5d4_xplained.dts b/arch/arm/boot/dts/at91-sama5d4_xplained.dts
index 5ab14cedb1db..9d2824540e95 100644
--- a/arch/arm/boot/dts/at91-sama5d4_xplained.dts
+++ b/arch/arm/boot/dts/at91-sama5d4_xplained.dts
@@ -130,6 +130,18 @@
 				status = "okay";
 			};
 
+			tcb2: timer at fc024000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer at 1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			adc0: adc at fc034000 {
 				pinctrl-names = "default";
 				pinctrl-0 = <
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 41/58] ARM: dts: at91: ma5d4: use TCB2 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Marek Vasut

As TCB2 doesn't have any output pins, use it as a clocksource.

Cc: Marek Vasut <marex@denx.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-sama5d4_ma5d4.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-sama5d4_ma5d4.dtsi b/arch/arm/boot/dts/at91-sama5d4_ma5d4.dtsi
index b5a5a91bc2ef..cfe1d21ed4db 100644
--- a/arch/arm/boot/dts/at91-sama5d4_ma5d4.dtsi
+++ b/arch/arm/boot/dts/at91-sama5d4_ma5d4.dtsi
@@ -89,6 +89,18 @@
 				};
 			};
 
+			tcb2: timer@fc024000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer@1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			adc0: adc@fc034000 {
 				pinctrl-names = "default";
 				pinctrl-0 = <
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 41/58] ARM: dts: at91: ma5d4: use TCB2 as clocksource
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

As TCB2 doesn't have any output pins, use it as a clocksource.

Cc: Marek Vasut <marex@denx.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-sama5d4_ma5d4.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-sama5d4_ma5d4.dtsi b/arch/arm/boot/dts/at91-sama5d4_ma5d4.dtsi
index b5a5a91bc2ef..cfe1d21ed4db 100644
--- a/arch/arm/boot/dts/at91-sama5d4_ma5d4.dtsi
+++ b/arch/arm/boot/dts/at91-sama5d4_ma5d4.dtsi
@@ -89,6 +89,18 @@
 				};
 			};
 
+			tcb2: timer at fc024000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer at 1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			adc0: adc at fc034000 {
 				pinctrl-names = "default";
 				pinctrl-0 = <
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 42/58] ARM: dts: at91: vinco: use TCB2 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Gregory CLEMENT

As TCB2 doesn't have any output pins, use it as a clocksource.

Cc: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-vinco.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-vinco.dts b/arch/arm/boot/dts/at91-vinco.dts
index e0c0b2897a49..d495a5e2aeac 100644
--- a/arch/arm/boot/dts/at91-vinco.dts
+++ b/arch/arm/boot/dts/at91-vinco.dts
@@ -151,6 +151,18 @@
 				status = "okay";
 			};
 
+			tcb2: timer@fc024000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer@1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			macb1: ethernet@fc028000 {
 				phy-mode = "rmii";
 				status = "okay";
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 42/58] ARM: dts: at91: vinco: use TCB2 as clocksource
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

As TCB2 doesn't have any output pins, use it as a clocksource.

Cc: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-vinco.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-vinco.dts b/arch/arm/boot/dts/at91-vinco.dts
index e0c0b2897a49..d495a5e2aeac 100644
--- a/arch/arm/boot/dts/at91-vinco.dts
+++ b/arch/arm/boot/dts/at91-vinco.dts
@@ -151,6 +151,18 @@
 				status = "okay";
 			};
 
+			tcb2: timer at fc024000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer at 1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			macb1: ethernet at fc028000 {
 				phy-mode = "rmii";
 				status = "okay";
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 43/58] ARM: dts: at91: sama5d2: TC blocks are also simple-mfd and syscon devices
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allows to use
regmap instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/sama5d2.dtsi | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/sama5d2.dtsi b/arch/arm/boot/dts/sama5d2.dtsi
index 8067c71c3a38..8e104d78c061 100644
--- a/arch/arm/boot/dts/sama5d2.dtsi
+++ b/arch/arm/boot/dts/sama5d2.dtsi
@@ -971,7 +971,9 @@
 			};
 
 			tcb0: timer@f800c000 {
-				compatible = "atmel,at91sam9x5-tcb";
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xf800c000 0x100>;
 				interrupts = <35 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb0_clk>, <&clk32k>;
@@ -979,7 +981,9 @@
 			};
 
 			tcb1: timer@f8010000 {
-				compatible = "atmel,at91sam9x5-tcb";
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xf8010000 0x100>;
 				interrupts = <36 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb1_clk>, <&clk32k>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 43/58] ARM: dts: at91: sama5d2: TC blocks are also simple-mfd and syscon devices
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Add simple-mfd and syscon to the TC blocks to allow to register one of the
channels as clocksource properly at boot time. It also allows to use
regmap instead of tclib.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/sama5d2.dtsi | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/sama5d2.dtsi b/arch/arm/boot/dts/sama5d2.dtsi
index 8067c71c3a38..8e104d78c061 100644
--- a/arch/arm/boot/dts/sama5d2.dtsi
+++ b/arch/arm/boot/dts/sama5d2.dtsi
@@ -971,7 +971,9 @@
 			};
 
 			tcb0: timer at f800c000 {
-				compatible = "atmel,at91sam9x5-tcb";
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xf800c000 0x100>;
 				interrupts = <35 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb0_clk>, <&clk32k>;
@@ -979,7 +981,9 @@
 			};
 
 			tcb1: timer at f8010000 {
-				compatible = "atmel,at91sam9x5-tcb";
+				compatible = "atmel,at91sam9x5-tcb", "simple-mfd", "syscon";
+				#address-cells = <1>;
+				#size-cells = <0>;
 				reg = <0xf8010000 0x100>;
 				interrupts = <36 IRQ_TYPE_LEVEL_HIGH 0>;
 				clocks = <&tcb1_clk>, <&clk32k>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 44/58] ARM: dts: at91: sama5d2 Xplained: use TCB0 as clocksource
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Use tcb0 as the clocksource like previously selected in sama5_defconfig.

Tested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-sama5d2_xplained.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-sama5d2_xplained.dts b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
index 0bef9e0b89c6..6301d50b8443 100644
--- a/arch/arm/boot/dts/at91-sama5d2_xplained.dts
+++ b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
@@ -135,6 +135,18 @@
 				};
 			};
 
+			tcb0: timer@f800c000 {
+				timer@0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer@1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			pdmic@f8018000 {
 				pinctrl-names = "default";
 				pinctrl-0 = <&pinctrl_pdmic_default>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 44/58] ARM: dts: at91: sama5d2 Xplained: use TCB0 as clocksource
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Use tcb0 as the clocksource like previously selected in sama5_defconfig.

Tested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-sama5d2_xplained.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/at91-sama5d2_xplained.dts b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
index 0bef9e0b89c6..6301d50b8443 100644
--- a/arch/arm/boot/dts/at91-sama5d2_xplained.dts
+++ b/arch/arm/boot/dts/at91-sama5d2_xplained.dts
@@ -135,6 +135,18 @@
 				};
 			};
 
+			tcb0: timer at f800c000 {
+				timer at 0 {
+					compatible = "atmel,tcb-timer";
+					reg = <0>;
+				};
+
+				timer at 1 {
+					compatible = "atmel,tcb-timer";
+					reg = <1>;
+				};
+			};
+
 			pdmic at f8018000 {
 				pinctrl-names = "default";
 				pinctrl-0 = <&pinctrl_pdmic_default>;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 45/58] ARM: at91: add TCB registers definitions
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

Add registers and bits definitions for the timer counter blocks found on
Atmel ARM SoCs.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 include/soc/at91/atmel_tcb.h | 229 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 229 insertions(+)
 create mode 100644 include/soc/at91/atmel_tcb.h

diff --git a/include/soc/at91/atmel_tcb.h b/include/soc/at91/atmel_tcb.h
new file mode 100644
index 000000000000..f48e60f8ab92
--- /dev/null
+++ b/include/soc/at91/atmel_tcb.h
@@ -0,0 +1,229 @@
+/*
+ * Copyright (C) 2016 Atmel
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __SOC_ATMEL_TCB_H
+#define __SOC_ATMEL_TCB_H
+
+/* Channel registers */
+#define ATMEL_TC_COFFS(c)		((c) * 0x40)
+#define ATMEL_TC_CCR(c)			ATMEL_TC_COFFS(c)
+#define ATMEL_TC_CMR(c)			(ATMEL_TC_COFFS(c) + 0x4)
+#define ATMEL_TC_SMMR(c)		(ATMEL_TC_COFFS(c) + 0x8)
+#define ATMEL_TC_RAB(c)			(ATMEL_TC_COFFS(c) + 0xc)
+#define ATMEL_TC_CV(c)			(ATMEL_TC_COFFS(c) + 0x10)
+#define ATMEL_TC_RA(c)			(ATMEL_TC_COFFS(c) + 0x14)
+#define ATMEL_TC_RB(c)			(ATMEL_TC_COFFS(c) + 0x18)
+#define ATMEL_TC_RC(c)			(ATMEL_TC_COFFS(c) + 0x1c)
+#define ATMEL_TC_SR(c)			(ATMEL_TC_COFFS(c) + 0x20)
+#define ATMEL_TC_IER(c)			(ATMEL_TC_COFFS(c) + 0x24)
+#define ATMEL_TC_IDR(c)			(ATMEL_TC_COFFS(c) + 0x28)
+#define ATMEL_TC_IMR(c)			(ATMEL_TC_COFFS(c) + 0x2c)
+#define ATMEL_TC_EMR(c)			(ATMEL_TC_COFFS(c) + 0x30)
+
+/* Block registers */
+#define ATMEL_TC_BCR			0xc0
+#define ATMEL_TC_BMR			0xc4
+#define ATMEL_TC_QIER			0xc8
+#define ATMEL_TC_QIDR			0xcc
+#define ATMEL_TC_QIMR			0xd0
+#define ATMEL_TC_QISR			0xd4
+#define ATMEL_TC_FMR			0xd8
+#define ATMEL_TC_WPMR			0xe4
+
+/* CCR fields */
+#define ATMEL_TC_CCR_CLKEN		BIT(0)
+#define ATMEL_TC_CCR_CLKDIS		BIT(1)
+#define ATMEL_TC_CCR_SWTRG		BIT(2)
+
+/* Common CMR fields */
+#define ATMEL_TC_CMR_TCLKS_MSK		GENMASK(2, 0)
+#define ATMEL_TC_CMR_TCLK(x)		(x)
+#define ATMEL_TC_CMR_XC(x)		((x) + 5)
+#define ATMEL_TC_CMR_CLKI		BIT(3)
+#define ATMEL_TC_CMR_BURST_MSK		GENMASK(5, 4)
+#define ATMEL_TC_CMR_BURST_XC(x)	(((x) + 1) << 4)
+#define ATMEL_TC_CMR_WAVE		BIT(15)
+
+/* Capture mode CMR fields */
+#define ATMEL_TC_CMR_LDBSTOP		BIT(6)
+#define ATMEL_TC_CMR_LDBDIS		BIT(7)
+#define ATMEL_TC_CMR_ETRGEDG_MSK	GENMASK(9, 8)
+#define ATMEL_TC_CMR_ETRGEDG_NONE	(0 << 8)
+#define ATMEL_TC_CMR_ETRGEDG_RISING	(1 << 8)
+#define ATMEL_TC_CMR_ETRGEDG_FALLING	(2 << 8)
+#define ATMEL_TC_CMR_ETRGEDG_BOTH	(3 << 8)
+#define ATMEL_TC_CMR_ABETRG		BIT(10)
+#define ATMEL_TC_CMR_CPCTRG		BIT(14)
+#define ATMEL_TC_CMR_LDRA_MSK		GENMASK(17, 16)
+#define ATMEL_TC_CMR_LDRA_NONE		(0 << 16)
+#define ATMEL_TC_CMR_LDRA_RISING	(1 << 16)
+#define ATMEL_TC_CMR_LDRA_FALLING	(2 << 16)
+#define ATMEL_TC_CMR_LDRA_BOTH		(3 << 16)
+#define ATMEL_TC_CMR_LDRB_MSK		GENMASK(19, 18)
+#define ATMEL_TC_CMR_LDRB_NONE		(0 << 18)
+#define ATMEL_TC_CMR_LDRB_RISING	(1 << 18)
+#define ATMEL_TC_CMR_LDRB_FALLING	(2 << 18)
+#define ATMEL_TC_CMR_LDRB_BOTH		(3 << 18)
+#define ATMEL_TC_CMR_SBSMPLR_MSK	GENMASK(22, 20)
+#define ATMEL_TC_CMR_SBSMPLR(x)		((x) << 20)
+
+/* Waveform mode CMR fields */
+#define ATMEL_TC_CMR_CPCSTOP		BIT(6)
+#define ATMEL_TC_CMR_CPCDIS		BIT(7)
+#define ATMEL_TC_CMR_EEVTEDG_MSK	GENMASK(9, 8)
+#define ATMEL_TC_CMR_EEVTEDG_NONE	(0 << 8)
+#define ATMEL_TC_CMR_EEVTEDG_RISING	(1 << 8)
+#define ATMEL_TC_CMR_EEVTEDG_FALLING	(2 << 8)
+#define ATMEL_TC_CMR_EEVTEDG_BOTH	(3 << 8)
+#define ATMEL_TC_CMR_EEVT_MSK		GENMASK(11, 10)
+#define ATMEL_TC_CMR_EEVT_XC(x)		(((x) + 1) << 10)
+#define ATMEL_TC_CMR_ENETRG		BIT(12)
+#define ATMEL_TC_CMR_WAVESEL_MSK	GENMASK(14, 13)
+#define ATMEL_TC_CMR_WAVESEL_UP		(0 << 13)
+#define ATMEL_TC_CMR_WAVESEL_UPDOWN	(1 << 13)
+#define ATMEL_TC_CMR_WAVESEL_UPRC	(2 << 13)
+#define ATMEL_TC_CMR_WAVESEL_UPDOWNRC	(3 << 13)
+#define ATMEL_TC_CMR_ACPA_MSK		GENMASK(17, 16)
+#define ATMEL_TC_CMR_ACPA(a)		(ATMEL_TC_CMR_ACTION_##a << 16)
+#define ATMEL_TC_CMR_ACPC_MSK		GENMASK(19, 18)
+#define ATMEL_TC_CMR_ACPC(a)		(ATMEL_TC_CMR_ACTION_##a << 18)
+#define ATMEL_TC_CMR_AEEVT_MSK		GENMASK(21, 20)
+#define ATMEL_TC_CMR_AEEVT(a)		(ATMEL_TC_CMR_ACTION_##a << 20)
+#define ATMEL_TC_CMR_ASWTRG_MSK		GENMASK(23, 22)
+#define ATMEL_TC_CMR_ASWTRG(a)		(ATMEL_TC_CMR_ACTION_##a << 22)
+#define ATMEL_TC_CMR_BCPB_MSK		GENMASK(25, 24)
+#define ATMEL_TC_CMR_BCPB(a)		(ATMEL_TC_CMR_ACTION_##a << 24)
+#define ATMEL_TC_CMR_BCPC_MSK		GENMASK(27, 26)
+#define ATMEL_TC_CMR_BCPC(a)		(ATMEL_TC_CMR_ACTION_##a << 26)
+#define ATMEL_TC_CMR_BEEVT_MSK		GENMASK(29, 28)
+#define ATMEL_TC_CMR_BEEVT(a)		(ATMEL_TC_CMR_ACTION_##a << 28)
+#define ATMEL_TC_CMR_BSWTRG_MSK		GENMASK(31, 30)
+#define ATMEL_TC_CMR_BSWTRG(a)		(ATMEL_TC_CMR_ACTION_##a << 30)
+#define ATMEL_TC_CMR_ACTION_NONE	0
+#define ATMEL_TC_CMR_ACTION_SET		1
+#define ATMEL_TC_CMR_ACTION_CLEAR	2
+#define ATMEL_TC_CMR_ACTION_TOGGLE	3
+
+/* SMMR fields */
+#define ATMEL_TC_SMMR_GCEN		BIT(0)
+#define ATMEL_TC_SMMR_DOWN		BIT(1)
+
+/* SR/IER/IDR/IMR fields */
+#define ATMEL_TC_COVFS			BIT(0)
+#define ATMEL_TC_LOVRS			BIT(1)
+#define ATMEL_TC_CPAS			BIT(2)
+#define ATMEL_TC_CPBS			BIT(3)
+#define ATMEL_TC_CPCS			BIT(4)
+#define ATMEL_TC_LDRAS			BIT(5)
+#define ATMEL_TC_LDRBS			BIT(6)
+#define ATMEL_TC_ETRGS			BIT(7)
+#define ATMEL_TC_CLKSTA			BIT(16)
+#define ATMEL_TC_MTIOA			BIT(17)
+#define ATMEL_TC_MTIOB			BIT(18)
+
+/* EMR fields */
+#define ATMEL_TC_EMR_TRIGSRCA_MSK	GENMASK(1, 0)
+#define ATMEL_TC_EMR_TRIGSRCA_TIOA	0
+#define ATMEL_TC_EMR_TRIGSRCA_PWMX	1
+#define ATMEL_TC_EMR_TRIGSRCB_MSK	GENMASK(5, 4)
+#define ATMEL_TC_EMR_TRIGSRCB_TIOB	(0 << 4)
+#define ATMEL_TC_EMR_TRIGSRCB_PWM	(1 << 4)
+#define ATMEL_TC_EMR_NOCLKDIV		BIT(8)
+
+/* BCR fields */
+#define ATMEL_TC_BCR_SYNC		BIT(0)
+
+/* BMR fields */
+#define ATMEL_TC_BMR_TCXC_MSK(c)	GENMASK(((c) * 2) + 1, (c) * 2)
+#define ATMEL_TC_BMR_TCXC(x, c)		((x) << (2 * (c)))
+#define ATMEL_TC_BMR_QDEN		BIT(8)
+#define ATMEL_TC_BMR_POSEN		BIT(9)
+#define ATMEL_TC_BMR_SPEEDEN		BIT(10)
+#define ATMEL_TC_BMR_QDTRANS		BIT(11)
+#define ATMEL_TC_BMR_EDGPHA		BIT(12)
+#define ATMEL_TC_BMR_INVA		BIT(13)
+#define ATMEL_TC_BMR_INVB		BIT(14)
+#define ATMEL_TC_BMR_INVIDX		BIT(15)
+#define ATMEL_TC_BMR_SWAP		BIT(16)
+#define ATMEL_TC_BMR_IDXPHB		BIT(17)
+#define ATMEL_TC_BMR_AUTOC		BIT(18)
+#define ATMEL_TC_MAXFILT_MSK		GENMASK(25, 20)
+#define ATMEL_TC_MAXFILT(x)		(((x) - 1) << 20)
+#define ATMEL_TC_MAXCMP_MSK		GENMASK(29, 26)
+#define ATMEL_TC_MAXCMP(x)		((x) << 26)
+
+/* QEDC fields */
+#define ATMEL_TC_QEDC_IDX		BIT(0)
+#define ATMEL_TC_QEDC_DIRCHG		BIT(1)
+#define ATMEL_TC_QEDC_QERR		BIT(2)
+#define ATMEL_TC_QEDC_MPE		BIT(3)
+#define ATMEL_TC_QEDC_DIR		BIT(8)
+
+/* FMR fields */
+#define ATMEL_TC_FMR_ENCF(x)		BIT(x)
+
+/* WPMR fields */
+#define ATMEL_TC_WPMR_WPKEY		(0x54494d << 8)
+#define ATMEL_TC_WPMR_WPEN		BIT(0)
+
+static inline struct clk *tcb_clk_get(struct device_node *node, int channel)
+{
+	struct clk *clk;
+	char clk_name[] = "t0_clk";
+
+	clk_name[1] += channel;
+	clk = of_clk_get_by_name(node->parent, clk_name);
+	if (!IS_ERR(clk))
+		return clk;
+
+	return of_clk_get_by_name(node->parent, "t0_clk");
+}
+
+static inline int tcb_irq_get(struct device_node *node, int channel)
+{
+	int irq;
+
+	irq = of_irq_get(node->parent, channel);
+	if (irq > 0)
+		return irq;
+
+	return of_irq_get(node->parent, 0);
+}
+
+static const u8 atmel_tc_divisors[5] = { 2, 8, 32, 128, 0, };
+
+struct atmel_tcb_info {
+	int bits;
+};
+
+static const struct atmel_tcb_info atmel_tcb_infos[] = {
+	{ .bits = 16 },
+	{ .bits = 32 },
+};
+
+static const struct of_device_id atmel_tcb_dt_ids[] = {
+	{
+		.compatible = "atmel,at91rm9200-tcb",
+		.data = &atmel_tcb_infos[0],
+	}, {
+		.compatible = "atmel,at91sam9x5-tcb",
+		.data = &atmel_tcb_infos[1],
+	}, {
+		/* sentinel */
+	}
+};
+
+#endif /* __SOC_ATMEL_TCB_H */
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 45/58] ARM: at91: add TCB registers definitions
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Add registers and bits definitions for the timer counter blocks found on
Atmel ARM SoCs.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 include/soc/at91/atmel_tcb.h | 229 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 229 insertions(+)
 create mode 100644 include/soc/at91/atmel_tcb.h

diff --git a/include/soc/at91/atmel_tcb.h b/include/soc/at91/atmel_tcb.h
new file mode 100644
index 000000000000..f48e60f8ab92
--- /dev/null
+++ b/include/soc/at91/atmel_tcb.h
@@ -0,0 +1,229 @@
+/*
+ * Copyright (C) 2016 Atmel
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __SOC_ATMEL_TCB_H
+#define __SOC_ATMEL_TCB_H
+
+/* Channel registers */
+#define ATMEL_TC_COFFS(c)		((c) * 0x40)
+#define ATMEL_TC_CCR(c)			ATMEL_TC_COFFS(c)
+#define ATMEL_TC_CMR(c)			(ATMEL_TC_COFFS(c) + 0x4)
+#define ATMEL_TC_SMMR(c)		(ATMEL_TC_COFFS(c) + 0x8)
+#define ATMEL_TC_RAB(c)			(ATMEL_TC_COFFS(c) + 0xc)
+#define ATMEL_TC_CV(c)			(ATMEL_TC_COFFS(c) + 0x10)
+#define ATMEL_TC_RA(c)			(ATMEL_TC_COFFS(c) + 0x14)
+#define ATMEL_TC_RB(c)			(ATMEL_TC_COFFS(c) + 0x18)
+#define ATMEL_TC_RC(c)			(ATMEL_TC_COFFS(c) + 0x1c)
+#define ATMEL_TC_SR(c)			(ATMEL_TC_COFFS(c) + 0x20)
+#define ATMEL_TC_IER(c)			(ATMEL_TC_COFFS(c) + 0x24)
+#define ATMEL_TC_IDR(c)			(ATMEL_TC_COFFS(c) + 0x28)
+#define ATMEL_TC_IMR(c)			(ATMEL_TC_COFFS(c) + 0x2c)
+#define ATMEL_TC_EMR(c)			(ATMEL_TC_COFFS(c) + 0x30)
+
+/* Block registers */
+#define ATMEL_TC_BCR			0xc0
+#define ATMEL_TC_BMR			0xc4
+#define ATMEL_TC_QIER			0xc8
+#define ATMEL_TC_QIDR			0xcc
+#define ATMEL_TC_QIMR			0xd0
+#define ATMEL_TC_QISR			0xd4
+#define ATMEL_TC_FMR			0xd8
+#define ATMEL_TC_WPMR			0xe4
+
+/* CCR fields */
+#define ATMEL_TC_CCR_CLKEN		BIT(0)
+#define ATMEL_TC_CCR_CLKDIS		BIT(1)
+#define ATMEL_TC_CCR_SWTRG		BIT(2)
+
+/* Common CMR fields */
+#define ATMEL_TC_CMR_TCLKS_MSK		GENMASK(2, 0)
+#define ATMEL_TC_CMR_TCLK(x)		(x)
+#define ATMEL_TC_CMR_XC(x)		((x) + 5)
+#define ATMEL_TC_CMR_CLKI		BIT(3)
+#define ATMEL_TC_CMR_BURST_MSK		GENMASK(5, 4)
+#define ATMEL_TC_CMR_BURST_XC(x)	(((x) + 1) << 4)
+#define ATMEL_TC_CMR_WAVE		BIT(15)
+
+/* Capture mode CMR fields */
+#define ATMEL_TC_CMR_LDBSTOP		BIT(6)
+#define ATMEL_TC_CMR_LDBDIS		BIT(7)
+#define ATMEL_TC_CMR_ETRGEDG_MSK	GENMASK(9, 8)
+#define ATMEL_TC_CMR_ETRGEDG_NONE	(0 << 8)
+#define ATMEL_TC_CMR_ETRGEDG_RISING	(1 << 8)
+#define ATMEL_TC_CMR_ETRGEDG_FALLING	(2 << 8)
+#define ATMEL_TC_CMR_ETRGEDG_BOTH	(3 << 8)
+#define ATMEL_TC_CMR_ABETRG		BIT(10)
+#define ATMEL_TC_CMR_CPCTRG		BIT(14)
+#define ATMEL_TC_CMR_LDRA_MSK		GENMASK(17, 16)
+#define ATMEL_TC_CMR_LDRA_NONE		(0 << 16)
+#define ATMEL_TC_CMR_LDRA_RISING	(1 << 16)
+#define ATMEL_TC_CMR_LDRA_FALLING	(2 << 16)
+#define ATMEL_TC_CMR_LDRA_BOTH		(3 << 16)
+#define ATMEL_TC_CMR_LDRB_MSK		GENMASK(19, 18)
+#define ATMEL_TC_CMR_LDRB_NONE		(0 << 18)
+#define ATMEL_TC_CMR_LDRB_RISING	(1 << 18)
+#define ATMEL_TC_CMR_LDRB_FALLING	(2 << 18)
+#define ATMEL_TC_CMR_LDRB_BOTH		(3 << 18)
+#define ATMEL_TC_CMR_SBSMPLR_MSK	GENMASK(22, 20)
+#define ATMEL_TC_CMR_SBSMPLR(x)		((x) << 20)
+
+/* Waveform mode CMR fields */
+#define ATMEL_TC_CMR_CPCSTOP		BIT(6)
+#define ATMEL_TC_CMR_CPCDIS		BIT(7)
+#define ATMEL_TC_CMR_EEVTEDG_MSK	GENMASK(9, 8)
+#define ATMEL_TC_CMR_EEVTEDG_NONE	(0 << 8)
+#define ATMEL_TC_CMR_EEVTEDG_RISING	(1 << 8)
+#define ATMEL_TC_CMR_EEVTEDG_FALLING	(2 << 8)
+#define ATMEL_TC_CMR_EEVTEDG_BOTH	(3 << 8)
+#define ATMEL_TC_CMR_EEVT_MSK		GENMASK(11, 10)
+#define ATMEL_TC_CMR_EEVT_XC(x)		(((x) + 1) << 10)
+#define ATMEL_TC_CMR_ENETRG		BIT(12)
+#define ATMEL_TC_CMR_WAVESEL_MSK	GENMASK(14, 13)
+#define ATMEL_TC_CMR_WAVESEL_UP		(0 << 13)
+#define ATMEL_TC_CMR_WAVESEL_UPDOWN	(1 << 13)
+#define ATMEL_TC_CMR_WAVESEL_UPRC	(2 << 13)
+#define ATMEL_TC_CMR_WAVESEL_UPDOWNRC	(3 << 13)
+#define ATMEL_TC_CMR_ACPA_MSK		GENMASK(17, 16)
+#define ATMEL_TC_CMR_ACPA(a)		(ATMEL_TC_CMR_ACTION_##a << 16)
+#define ATMEL_TC_CMR_ACPC_MSK		GENMASK(19, 18)
+#define ATMEL_TC_CMR_ACPC(a)		(ATMEL_TC_CMR_ACTION_##a << 18)
+#define ATMEL_TC_CMR_AEEVT_MSK		GENMASK(21, 20)
+#define ATMEL_TC_CMR_AEEVT(a)		(ATMEL_TC_CMR_ACTION_##a << 20)
+#define ATMEL_TC_CMR_ASWTRG_MSK		GENMASK(23, 22)
+#define ATMEL_TC_CMR_ASWTRG(a)		(ATMEL_TC_CMR_ACTION_##a << 22)
+#define ATMEL_TC_CMR_BCPB_MSK		GENMASK(25, 24)
+#define ATMEL_TC_CMR_BCPB(a)		(ATMEL_TC_CMR_ACTION_##a << 24)
+#define ATMEL_TC_CMR_BCPC_MSK		GENMASK(27, 26)
+#define ATMEL_TC_CMR_BCPC(a)		(ATMEL_TC_CMR_ACTION_##a << 26)
+#define ATMEL_TC_CMR_BEEVT_MSK		GENMASK(29, 28)
+#define ATMEL_TC_CMR_BEEVT(a)		(ATMEL_TC_CMR_ACTION_##a << 28)
+#define ATMEL_TC_CMR_BSWTRG_MSK		GENMASK(31, 30)
+#define ATMEL_TC_CMR_BSWTRG(a)		(ATMEL_TC_CMR_ACTION_##a << 30)
+#define ATMEL_TC_CMR_ACTION_NONE	0
+#define ATMEL_TC_CMR_ACTION_SET		1
+#define ATMEL_TC_CMR_ACTION_CLEAR	2
+#define ATMEL_TC_CMR_ACTION_TOGGLE	3
+
+/* SMMR fields */
+#define ATMEL_TC_SMMR_GCEN		BIT(0)
+#define ATMEL_TC_SMMR_DOWN		BIT(1)
+
+/* SR/IER/IDR/IMR fields */
+#define ATMEL_TC_COVFS			BIT(0)
+#define ATMEL_TC_LOVRS			BIT(1)
+#define ATMEL_TC_CPAS			BIT(2)
+#define ATMEL_TC_CPBS			BIT(3)
+#define ATMEL_TC_CPCS			BIT(4)
+#define ATMEL_TC_LDRAS			BIT(5)
+#define ATMEL_TC_LDRBS			BIT(6)
+#define ATMEL_TC_ETRGS			BIT(7)
+#define ATMEL_TC_CLKSTA			BIT(16)
+#define ATMEL_TC_MTIOA			BIT(17)
+#define ATMEL_TC_MTIOB			BIT(18)
+
+/* EMR fields */
+#define ATMEL_TC_EMR_TRIGSRCA_MSK	GENMASK(1, 0)
+#define ATMEL_TC_EMR_TRIGSRCA_TIOA	0
+#define ATMEL_TC_EMR_TRIGSRCA_PWMX	1
+#define ATMEL_TC_EMR_TRIGSRCB_MSK	GENMASK(5, 4)
+#define ATMEL_TC_EMR_TRIGSRCB_TIOB	(0 << 4)
+#define ATMEL_TC_EMR_TRIGSRCB_PWM	(1 << 4)
+#define ATMEL_TC_EMR_NOCLKDIV		BIT(8)
+
+/* BCR fields */
+#define ATMEL_TC_BCR_SYNC		BIT(0)
+
+/* BMR fields */
+#define ATMEL_TC_BMR_TCXC_MSK(c)	GENMASK(((c) * 2) + 1, (c) * 2)
+#define ATMEL_TC_BMR_TCXC(x, c)		((x) << (2 * (c)))
+#define ATMEL_TC_BMR_QDEN		BIT(8)
+#define ATMEL_TC_BMR_POSEN		BIT(9)
+#define ATMEL_TC_BMR_SPEEDEN		BIT(10)
+#define ATMEL_TC_BMR_QDTRANS		BIT(11)
+#define ATMEL_TC_BMR_EDGPHA		BIT(12)
+#define ATMEL_TC_BMR_INVA		BIT(13)
+#define ATMEL_TC_BMR_INVB		BIT(14)
+#define ATMEL_TC_BMR_INVIDX		BIT(15)
+#define ATMEL_TC_BMR_SWAP		BIT(16)
+#define ATMEL_TC_BMR_IDXPHB		BIT(17)
+#define ATMEL_TC_BMR_AUTOC		BIT(18)
+#define ATMEL_TC_MAXFILT_MSK		GENMASK(25, 20)
+#define ATMEL_TC_MAXFILT(x)		(((x) - 1) << 20)
+#define ATMEL_TC_MAXCMP_MSK		GENMASK(29, 26)
+#define ATMEL_TC_MAXCMP(x)		((x) << 26)
+
+/* QEDC fields */
+#define ATMEL_TC_QEDC_IDX		BIT(0)
+#define ATMEL_TC_QEDC_DIRCHG		BIT(1)
+#define ATMEL_TC_QEDC_QERR		BIT(2)
+#define ATMEL_TC_QEDC_MPE		BIT(3)
+#define ATMEL_TC_QEDC_DIR		BIT(8)
+
+/* FMR fields */
+#define ATMEL_TC_FMR_ENCF(x)		BIT(x)
+
+/* WPMR fields */
+#define ATMEL_TC_WPMR_WPKEY		(0x54494d << 8)
+#define ATMEL_TC_WPMR_WPEN		BIT(0)
+
+static inline struct clk *tcb_clk_get(struct device_node *node, int channel)
+{
+	struct clk *clk;
+	char clk_name[] = "t0_clk";
+
+	clk_name[1] += channel;
+	clk = of_clk_get_by_name(node->parent, clk_name);
+	if (!IS_ERR(clk))
+		return clk;
+
+	return of_clk_get_by_name(node->parent, "t0_clk");
+}
+
+static inline int tcb_irq_get(struct device_node *node, int channel)
+{
+	int irq;
+
+	irq = of_irq_get(node->parent, channel);
+	if (irq > 0)
+		return irq;
+
+	return of_irq_get(node->parent, 0);
+}
+
+static const u8 atmel_tc_divisors[5] = { 2, 8, 32, 128, 0, };
+
+struct atmel_tcb_info {
+	int bits;
+};
+
+static const struct atmel_tcb_info atmel_tcb_infos[] = {
+	{ .bits = 16 },
+	{ .bits = 32 },
+};
+
+static const struct of_device_id atmel_tcb_dt_ids[] = {
+	{
+		.compatible = "atmel,at91rm9200-tcb",
+		.data = &atmel_tcb_infos[0],
+	}, {
+		.compatible = "atmel,at91sam9x5-tcb",
+		.data = &atmel_tcb_infos[1],
+	}, {
+		/* sentinel */
+	}
+};
+
+#endif /* __SOC_ATMEL_TCB_H */
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Daniel Lezcano, Thomas Gleixner

Add a driver for the Atmel Timer Counter Blocks. This driver provides a
clocksource and a clockevent device. The clockevent device is linked to the
clocksource counter and so it will run at the same frequency.

This driver uses regmap and syscon to be able to probe early in the boot
and avoid having to switch on the TCB clocksource later. Using regmap also
means that unused TCB channels may be used by other drivers (PWM for
example).

Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/clocksource/Kconfig                 |  13 ++
 drivers/clocksource/Makefile                |   3 +-
 drivers/clocksource/timer-atmel-tcbclksrc.c | 252 ++++++++++++++++++++++++++++
 3 files changed, 267 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clocksource/timer-atmel-tcbclksrc.c

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 545d541ae20e..cbd710db3c09 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -418,6 +418,19 @@ config ATMEL_ST
 	help
 	  Support for the Atmel ST timer.
 
+config ATMEL_ARM_TCB_CLKSRC
+	bool "TC Block Clocksource"
+	select REGMAP_MMIO
+	depends on GENERIC_CLOCKEVENTS
+	depends on SOC_AT91RM9200 || SOC_AT91SAM9 || SOC_SAMA5 || COMPILE_TEST
+	default SOC_AT91RM9200 || SOC_AT91SAM9 || SOC_SAMA5
+	help
+	  Select this to get a high precision clocksource based on a
+	  TC block with a 5+ MHz base clock rate.
+	  On platforms with 16-bit counters, two timer channels are combined
+	  to make a single 32-bit timer.
+	  It can also be used as a clock event device supporting oneshot mode.
+
 config CLKSRC_METAG_GENERIC
 	def_bool y if METAG
 	help
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 2b5b56a6f00f..53a0b40e0db2 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -2,7 +2,8 @@ obj-$(CONFIG_CLKSRC_PROBE)	+= clksrc-probe.o
 obj-$(CONFIG_CLKEVT_PROBE)	+= clkevt-probe.o
 obj-$(CONFIG_ATMEL_PIT)		+= timer-atmel-pit.o
 obj-$(CONFIG_ATMEL_ST)		+= timer-atmel-st.o
-obj-$(CONFIG_ATMEL_TCB_CLKSRC)	+= tcb_clksrc.o
+obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o
+obj-$(CONFIG_ATMEL_ARM_TCB_CLKSRC)	+= timer-atmel-tcbclksrc.o
 obj-$(CONFIG_X86_PM_TIMER)	+= acpi_pm.o
 obj-$(CONFIG_SCx200HR_TIMER)	+= scx200_hrt.o
 obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC)	+= cs5535-clockevt.o
diff --git a/drivers/clocksource/timer-atmel-tcbclksrc.c b/drivers/clocksource/timer-atmel-tcbclksrc.c
new file mode 100644
index 000000000000..f18d177bfdea
--- /dev/null
+++ b/drivers/clocksource/timer-atmel-tcbclksrc.c
@@ -0,0 +1,252 @@
+#include <linux/clk.h>
+#include <linux/clockchips.h>
+#include <linux/clocksource.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/mfd/syscon.h>
+#include <linux/of_irq.h>
+#include <linux/regmap.h>
+#include <linux/sched_clock.h>
+#include <soc/at91/atmel_tcb.h>
+
+static struct atmel_tcb_clksrc {
+	char name[20];
+	struct clocksource clksrc;
+	struct regmap *regmap;
+	struct clk *clk[2];
+	int channels[2];
+	int bits;
+	int irq;
+	bool registered;
+} tc = {
+	.clksrc = {
+		.rating		= 200,
+		.mask		= CLOCKSOURCE_MASK(32),
+		.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	},
+};
+
+static u64 tc_get_cycles(struct clocksource *cs)
+{
+	u32		lower, upper, tmp;
+
+	do {
+		regmap_read(tc.regmap, ATMEL_TC_CV(1), &upper);
+		regmap_read(tc.regmap, ATMEL_TC_CV(0), &lower);
+		regmap_read(tc.regmap, ATMEL_TC_CV(1), &tmp);
+	} while (upper != tmp);
+
+	return (upper << 16) | lower;
+}
+
+static u64 tc_get_cycles32(struct clocksource *cs)
+{
+	u32 val;
+
+	regmap_read(tc.regmap, ATMEL_TC_CV(tc.channels[0]), &val);
+
+	return val;
+}
+
+static u64 notrace tc_sched_clock_read(void)
+{
+	return tc_get_cycles(&tc.clksrc);
+}
+
+static u64 notrace tc_sched_clock_read32(void)
+{
+	return tc_get_cycles32(&tc.clksrc);
+}
+
+static void __init tcb_setup_dual_chan(struct atmel_tcb_clksrc *tc,
+				       int mck_divisor_idx)
+{
+	/* first channel: waveform mode, input mclk/8, clock TIOA on overflow */
+	regmap_write(tc->regmap, ATMEL_TC_CMR(tc->channels[0]),
+		     mck_divisor_idx	/* likely divide-by-8 */
+			| ATMEL_TC_CMR_WAVE
+			| ATMEL_TC_CMR_WAVESEL_UP	/* free-run */
+			| ATMEL_TC_CMR_ACPA(SET)	/* TIOA rises at 0 */
+			| ATMEL_TC_CMR_ACPC(CLEAR));	/* (duty cycle 50%) */
+	regmap_write(tc->regmap, ATMEL_TC_RA(tc->channels[0]), 0x0000);
+	regmap_write(tc->regmap, ATMEL_TC_RC(tc->channels[0]), 0x8000);
+	regmap_write(tc->regmap, ATMEL_TC_IDR(tc->channels[0]), 0xff);	/* no irqs */
+	regmap_write(tc->regmap, ATMEL_TC_CCR(tc->channels[0]),
+		     ATMEL_TC_CCR_CLKEN);
+
+	/* second channel: waveform mode, input TIOA */
+	regmap_write(tc->regmap, ATMEL_TC_CMR(tc->channels[1]),
+		     ATMEL_TC_CMR_XC(tc->channels[1])	/* input: TIOA */
+		     | ATMEL_TC_CMR_WAVE
+		     | ATMEL_TC_CMR_WAVESEL_UP);	/* free-run */
+	regmap_write(tc->regmap, ATMEL_TC_IDR(tc->channels[1]), 0xff);	/* no irqs */
+	regmap_write(tc->regmap, ATMEL_TC_CCR(tc->channels[1]),
+		     ATMEL_TC_CCR_CLKEN);
+
+	/* chain both channel, we assume the previous channel */
+	regmap_write(tc->regmap, ATMEL_TC_BMR,
+		     ATMEL_TC_BMR_TCXC(1 + tc->channels[1], tc->channels[1]));
+	/* then reset all the timers */
+	regmap_write(tc->regmap, ATMEL_TC_BCR, ATMEL_TC_BCR_SYNC);
+}
+
+static void __init tcb_setup_single_chan(struct atmel_tcb_clksrc *tc,
+					 int mck_divisor_idx)
+{
+	/* channel 0:  waveform mode, input mclk/8 */
+	regmap_write(tc->regmap, ATMEL_TC_CMR(tc->channels[0]),
+		     mck_divisor_idx	/* likely divide-by-8 */
+			| ATMEL_TC_CMR_WAVE
+			| ATMEL_TC_CMR_WAVESEL_UP	/* free-run */
+			);
+	regmap_write(tc->regmap, ATMEL_TC_IDR(tc->channels[0]), 0xff);	/* no irqs */
+	regmap_write(tc->regmap, ATMEL_TC_CCR(tc->channels[0]),
+		     ATMEL_TC_CCR_CLKEN);
+
+	/* then reset all the timers */
+	regmap_write(tc->regmap, ATMEL_TC_BCR, ATMEL_TC_BCR_SYNC);
+}
+
+static int __init tcb_clksrc_register(struct device_node *node,
+				      struct regmap *regmap, int channel,
+				      int channel1, int irq, int bits)
+{
+	u32 rate, divided_rate = 0;
+	int best_divisor_idx = -1;
+	int i, err = -1;
+	u64 (*tc_sched_clock)(void);
+
+	tc.regmap = regmap;
+	tc.channels[0] = channel;
+	tc.channels[1] = channel1;
+	tc.irq = irq;
+	tc.bits = bits;
+
+	tc.clk[0] = tcb_clk_get(node, tc.channels[0]);
+	if (IS_ERR(tc.clk[0]))
+		return PTR_ERR(tc.clk[0]);
+	err = clk_prepare_enable(tc.clk[0]);
+	if (err) {
+		pr_debug("can't enable T0 clk\n");
+		goto err_clk;
+	}
+
+	/* How fast will we be counting?  Pick something over 5 MHz.  */
+	rate = (u32)clk_get_rate(tc.clk[0]);
+	for (i = 0; i < 5; i++) {
+		unsigned int divisor = atmel_tc_divisors[i];
+		unsigned int tmp;
+
+		if (!divisor)
+			continue;
+
+		tmp = rate / divisor;
+		pr_debug("TC: %u / %-3u [%d] --> %u\n", rate, divisor, i, tmp);
+		if (best_divisor_idx > 0) {
+			if (tmp < 5 * 1000 * 1000)
+				continue;
+		}
+		divided_rate = tmp;
+		best_divisor_idx = i;
+	}
+
+	if (tc.bits == 32) {
+		tc.clksrc.read = tc_get_cycles32;
+		tcb_setup_single_chan(&tc, best_divisor_idx);
+		tc_sched_clock = tc_sched_clock_read32;
+		snprintf(tc.name, sizeof(tc.name), "%s:%d",
+			 kbasename(node->parent->full_name), tc.channels[0]);
+	} else {
+		tc.clk[1] = tcb_clk_get(node, tc.channels[1]);
+		if (IS_ERR(tc.clk[1]))
+			goto err_disable_t0;
+
+		err = clk_prepare_enable(tc.clk[1]);
+		if (err) {
+			pr_debug("can't enable T1 clk\n");
+			goto err_clk1;
+		}
+		tc.clksrc.read = tc_get_cycles,
+		tcb_setup_dual_chan(&tc, best_divisor_idx);
+		tc_sched_clock = tc_sched_clock_read;
+		snprintf(tc.name, sizeof(tc.name), "%s:%d,%d",
+			 kbasename(node->parent->full_name), tc.channels[0],
+			 tc.channels[1]);
+	}
+
+	pr_debug("%s at %d.%03d MHz\n", tc.name,
+		 divided_rate / 1000000,
+		 ((divided_rate + 500000) % 1000000) / 1000);
+
+	tc.clksrc.name = tc.name;
+
+	err = clocksource_register_hz(&tc.clksrc, divided_rate);
+	if (err)
+		goto err_disable_t1;
+
+	sched_clock_register(tc_sched_clock, 32, divided_rate);
+
+	tc.registered = true;
+
+	return 0;
+
+err_disable_t1:
+	if (tc.bits == 16)
+		clk_disable_unprepare(tc.clk[1]);
+
+err_clk1:
+	if (tc.bits == 16)
+		clk_put(tc.clk[1]);
+
+err_disable_t0:
+	clk_disable_unprepare(tc.clk[0]);
+
+err_clk:
+	clk_put(tc.clk[0]);
+
+	pr_err("%s: unable to register clocksource/clockevent\n",
+	       tc.clksrc.name);
+
+	return err;
+}
+
+static int __init tcb_clksrc_init(struct device_node *node)
+{
+	const struct of_device_id *match;
+	const struct atmel_tcb_info *tcb_info;
+	struct regmap *regmap;
+	u32 channel;
+	int bits, irq, err, chan1 = -1;
+
+	if (tc.registered)
+		return -ENODEV;
+
+	regmap = syscon_node_to_regmap(node->parent);
+	if (IS_ERR(regmap))
+		return PTR_ERR(regmap);
+
+	match = of_match_node(atmel_tcb_dt_ids, node->parent);
+	tcb_info = match->data;
+	bits = tcb_info->bits;
+
+	err = of_property_read_u32_index(node, "reg", 0, &channel);
+	if (err)
+		return err;
+
+	irq = tcb_irq_get(node, channel);
+	if (irq < 0)
+		return irq;
+
+	if (bits == 16) {
+		of_property_read_u32_index(node, "reg", 1, &chan1);
+		if (chan1 == -1) {
+			pr_err("%s: clocksource needs two channels\n",
+			       node->parent->full_name);
+			return -EINVAL;
+		}
+	}
+
+	return tcb_clksrc_register(node, regmap, channel, chan1, irq, bits);
+}
+CLOCKSOURCE_OF_DECLARE(atmel_tcb_clksrc, "atmel,tcb-timer",
+		       tcb_clksrc_init);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Add a driver for the Atmel Timer Counter Blocks. This driver provides a
clocksource and a clockevent device. The clockevent device is linked to the
clocksource counter and so it will run at the same frequency.

This driver uses regmap and syscon to be able to probe early in the boot
and avoid having to switch on the TCB clocksource later. Using regmap also
means that unused TCB channels may be used by other drivers (PWM for
example).

Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/clocksource/Kconfig                 |  13 ++
 drivers/clocksource/Makefile                |   3 +-
 drivers/clocksource/timer-atmel-tcbclksrc.c | 252 ++++++++++++++++++++++++++++
 3 files changed, 267 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clocksource/timer-atmel-tcbclksrc.c

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 545d541ae20e..cbd710db3c09 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -418,6 +418,19 @@ config ATMEL_ST
 	help
 	  Support for the Atmel ST timer.
 
+config ATMEL_ARM_TCB_CLKSRC
+	bool "TC Block Clocksource"
+	select REGMAP_MMIO
+	depends on GENERIC_CLOCKEVENTS
+	depends on SOC_AT91RM9200 || SOC_AT91SAM9 || SOC_SAMA5 || COMPILE_TEST
+	default SOC_AT91RM9200 || SOC_AT91SAM9 || SOC_SAMA5
+	help
+	  Select this to get a high precision clocksource based on a
+	  TC block with a 5+ MHz base clock rate.
+	  On platforms with 16-bit counters, two timer channels are combined
+	  to make a single 32-bit timer.
+	  It can also be used as a clock event device supporting oneshot mode.
+
 config CLKSRC_METAG_GENERIC
 	def_bool y if METAG
 	help
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 2b5b56a6f00f..53a0b40e0db2 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -2,7 +2,8 @@ obj-$(CONFIG_CLKSRC_PROBE)	+= clksrc-probe.o
 obj-$(CONFIG_CLKEVT_PROBE)	+= clkevt-probe.o
 obj-$(CONFIG_ATMEL_PIT)		+= timer-atmel-pit.o
 obj-$(CONFIG_ATMEL_ST)		+= timer-atmel-st.o
-obj-$(CONFIG_ATMEL_TCB_CLKSRC)	+= tcb_clksrc.o
+obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o
+obj-$(CONFIG_ATMEL_ARM_TCB_CLKSRC)	+= timer-atmel-tcbclksrc.o
 obj-$(CONFIG_X86_PM_TIMER)	+= acpi_pm.o
 obj-$(CONFIG_SCx200HR_TIMER)	+= scx200_hrt.o
 obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC)	+= cs5535-clockevt.o
diff --git a/drivers/clocksource/timer-atmel-tcbclksrc.c b/drivers/clocksource/timer-atmel-tcbclksrc.c
new file mode 100644
index 000000000000..f18d177bfdea
--- /dev/null
+++ b/drivers/clocksource/timer-atmel-tcbclksrc.c
@@ -0,0 +1,252 @@
+#include <linux/clk.h>
+#include <linux/clockchips.h>
+#include <linux/clocksource.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/mfd/syscon.h>
+#include <linux/of_irq.h>
+#include <linux/regmap.h>
+#include <linux/sched_clock.h>
+#include <soc/at91/atmel_tcb.h>
+
+static struct atmel_tcb_clksrc {
+	char name[20];
+	struct clocksource clksrc;
+	struct regmap *regmap;
+	struct clk *clk[2];
+	int channels[2];
+	int bits;
+	int irq;
+	bool registered;
+} tc = {
+	.clksrc = {
+		.rating		= 200,
+		.mask		= CLOCKSOURCE_MASK(32),
+		.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	},
+};
+
+static u64 tc_get_cycles(struct clocksource *cs)
+{
+	u32		lower, upper, tmp;
+
+	do {
+		regmap_read(tc.regmap, ATMEL_TC_CV(1), &upper);
+		regmap_read(tc.regmap, ATMEL_TC_CV(0), &lower);
+		regmap_read(tc.regmap, ATMEL_TC_CV(1), &tmp);
+	} while (upper != tmp);
+
+	return (upper << 16) | lower;
+}
+
+static u64 tc_get_cycles32(struct clocksource *cs)
+{
+	u32 val;
+
+	regmap_read(tc.regmap, ATMEL_TC_CV(tc.channels[0]), &val);
+
+	return val;
+}
+
+static u64 notrace tc_sched_clock_read(void)
+{
+	return tc_get_cycles(&tc.clksrc);
+}
+
+static u64 notrace tc_sched_clock_read32(void)
+{
+	return tc_get_cycles32(&tc.clksrc);
+}
+
+static void __init tcb_setup_dual_chan(struct atmel_tcb_clksrc *tc,
+				       int mck_divisor_idx)
+{
+	/* first channel: waveform mode, input mclk/8, clock TIOA on overflow */
+	regmap_write(tc->regmap, ATMEL_TC_CMR(tc->channels[0]),
+		     mck_divisor_idx	/* likely divide-by-8 */
+			| ATMEL_TC_CMR_WAVE
+			| ATMEL_TC_CMR_WAVESEL_UP	/* free-run */
+			| ATMEL_TC_CMR_ACPA(SET)	/* TIOA rises at 0 */
+			| ATMEL_TC_CMR_ACPC(CLEAR));	/* (duty cycle 50%) */
+	regmap_write(tc->regmap, ATMEL_TC_RA(tc->channels[0]), 0x0000);
+	regmap_write(tc->regmap, ATMEL_TC_RC(tc->channels[0]), 0x8000);
+	regmap_write(tc->regmap, ATMEL_TC_IDR(tc->channels[0]), 0xff);	/* no irqs */
+	regmap_write(tc->regmap, ATMEL_TC_CCR(tc->channels[0]),
+		     ATMEL_TC_CCR_CLKEN);
+
+	/* second channel: waveform mode, input TIOA */
+	regmap_write(tc->regmap, ATMEL_TC_CMR(tc->channels[1]),
+		     ATMEL_TC_CMR_XC(tc->channels[1])	/* input: TIOA */
+		     | ATMEL_TC_CMR_WAVE
+		     | ATMEL_TC_CMR_WAVESEL_UP);	/* free-run */
+	regmap_write(tc->regmap, ATMEL_TC_IDR(tc->channels[1]), 0xff);	/* no irqs */
+	regmap_write(tc->regmap, ATMEL_TC_CCR(tc->channels[1]),
+		     ATMEL_TC_CCR_CLKEN);
+
+	/* chain both channel, we assume the previous channel */
+	regmap_write(tc->regmap, ATMEL_TC_BMR,
+		     ATMEL_TC_BMR_TCXC(1 + tc->channels[1], tc->channels[1]));
+	/* then reset all the timers */
+	regmap_write(tc->regmap, ATMEL_TC_BCR, ATMEL_TC_BCR_SYNC);
+}
+
+static void __init tcb_setup_single_chan(struct atmel_tcb_clksrc *tc,
+					 int mck_divisor_idx)
+{
+	/* channel 0:  waveform mode, input mclk/8 */
+	regmap_write(tc->regmap, ATMEL_TC_CMR(tc->channels[0]),
+		     mck_divisor_idx	/* likely divide-by-8 */
+			| ATMEL_TC_CMR_WAVE
+			| ATMEL_TC_CMR_WAVESEL_UP	/* free-run */
+			);
+	regmap_write(tc->regmap, ATMEL_TC_IDR(tc->channels[0]), 0xff);	/* no irqs */
+	regmap_write(tc->regmap, ATMEL_TC_CCR(tc->channels[0]),
+		     ATMEL_TC_CCR_CLKEN);
+
+	/* then reset all the timers */
+	regmap_write(tc->regmap, ATMEL_TC_BCR, ATMEL_TC_BCR_SYNC);
+}
+
+static int __init tcb_clksrc_register(struct device_node *node,
+				      struct regmap *regmap, int channel,
+				      int channel1, int irq, int bits)
+{
+	u32 rate, divided_rate = 0;
+	int best_divisor_idx = -1;
+	int i, err = -1;
+	u64 (*tc_sched_clock)(void);
+
+	tc.regmap = regmap;
+	tc.channels[0] = channel;
+	tc.channels[1] = channel1;
+	tc.irq = irq;
+	tc.bits = bits;
+
+	tc.clk[0] = tcb_clk_get(node, tc.channels[0]);
+	if (IS_ERR(tc.clk[0]))
+		return PTR_ERR(tc.clk[0]);
+	err = clk_prepare_enable(tc.clk[0]);
+	if (err) {
+		pr_debug("can't enable T0 clk\n");
+		goto err_clk;
+	}
+
+	/* How fast will we be counting?  Pick something over 5 MHz.  */
+	rate = (u32)clk_get_rate(tc.clk[0]);
+	for (i = 0; i < 5; i++) {
+		unsigned int divisor = atmel_tc_divisors[i];
+		unsigned int tmp;
+
+		if (!divisor)
+			continue;
+
+		tmp = rate / divisor;
+		pr_debug("TC: %u / %-3u [%d] --> %u\n", rate, divisor, i, tmp);
+		if (best_divisor_idx > 0) {
+			if (tmp < 5 * 1000 * 1000)
+				continue;
+		}
+		divided_rate = tmp;
+		best_divisor_idx = i;
+	}
+
+	if (tc.bits == 32) {
+		tc.clksrc.read = tc_get_cycles32;
+		tcb_setup_single_chan(&tc, best_divisor_idx);
+		tc_sched_clock = tc_sched_clock_read32;
+		snprintf(tc.name, sizeof(tc.name), "%s:%d",
+			 kbasename(node->parent->full_name), tc.channels[0]);
+	} else {
+		tc.clk[1] = tcb_clk_get(node, tc.channels[1]);
+		if (IS_ERR(tc.clk[1]))
+			goto err_disable_t0;
+
+		err = clk_prepare_enable(tc.clk[1]);
+		if (err) {
+			pr_debug("can't enable T1 clk\n");
+			goto err_clk1;
+		}
+		tc.clksrc.read = tc_get_cycles,
+		tcb_setup_dual_chan(&tc, best_divisor_idx);
+		tc_sched_clock = tc_sched_clock_read;
+		snprintf(tc.name, sizeof(tc.name), "%s:%d,%d",
+			 kbasename(node->parent->full_name), tc.channels[0],
+			 tc.channels[1]);
+	}
+
+	pr_debug("%s at %d.%03d MHz\n", tc.name,
+		 divided_rate / 1000000,
+		 ((divided_rate + 500000) % 1000000) / 1000);
+
+	tc.clksrc.name = tc.name;
+
+	err = clocksource_register_hz(&tc.clksrc, divided_rate);
+	if (err)
+		goto err_disable_t1;
+
+	sched_clock_register(tc_sched_clock, 32, divided_rate);
+
+	tc.registered = true;
+
+	return 0;
+
+err_disable_t1:
+	if (tc.bits == 16)
+		clk_disable_unprepare(tc.clk[1]);
+
+err_clk1:
+	if (tc.bits == 16)
+		clk_put(tc.clk[1]);
+
+err_disable_t0:
+	clk_disable_unprepare(tc.clk[0]);
+
+err_clk:
+	clk_put(tc.clk[0]);
+
+	pr_err("%s: unable to register clocksource/clockevent\n",
+	       tc.clksrc.name);
+
+	return err;
+}
+
+static int __init tcb_clksrc_init(struct device_node *node)
+{
+	const struct of_device_id *match;
+	const struct atmel_tcb_info *tcb_info;
+	struct regmap *regmap;
+	u32 channel;
+	int bits, irq, err, chan1 = -1;
+
+	if (tc.registered)
+		return -ENODEV;
+
+	regmap = syscon_node_to_regmap(node->parent);
+	if (IS_ERR(regmap))
+		return PTR_ERR(regmap);
+
+	match = of_match_node(atmel_tcb_dt_ids, node->parent);
+	tcb_info = match->data;
+	bits = tcb_info->bits;
+
+	err = of_property_read_u32_index(node, "reg", 0, &channel);
+	if (err)
+		return err;
+
+	irq = tcb_irq_get(node, channel);
+	if (irq < 0)
+		return irq;
+
+	if (bits == 16) {
+		of_property_read_u32_index(node, "reg", 1, &chan1);
+		if (chan1 == -1) {
+			pr_err("%s: clocksource needs two channels\n",
+			       node->parent->full_name);
+			return -EINVAL;
+		}
+	}
+
+	return tcb_clksrc_register(node, regmap, channel, chan1, irq, bits);
+}
+CLOCKSOURCE_OF_DECLARE(atmel_tcb_clksrc, "atmel,tcb-timer",
+		       tcb_clksrc_init);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 47/58] clocksource/drivers: timer-atmel-tcbclksrc: add clockevent device
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

It is possible to compare and get interrupts on the channel that is used
for the clocksource. Enable that to have a solution using only one TCB
channel.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/clocksource/timer-atmel-tcbclksrc.c | 81 +++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/drivers/clocksource/timer-atmel-tcbclksrc.c b/drivers/clocksource/timer-atmel-tcbclksrc.c
index f18d177bfdea..462b04e9fed8 100644
--- a/drivers/clocksource/timer-atmel-tcbclksrc.c
+++ b/drivers/clocksource/timer-atmel-tcbclksrc.c
@@ -12,6 +12,7 @@
 static struct atmel_tcb_clksrc {
 	char name[20];
 	struct clocksource clksrc;
+	struct clock_event_device clkevt;
 	struct regmap *regmap;
 	struct clk *clk[2];
 	int channels[2];
@@ -24,6 +25,11 @@ static struct atmel_tcb_clksrc {
 		.mask		= CLOCKSOURCE_MASK(32),
 		.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 	},
+	.clkevt	= {
+		.features	= CLOCK_EVT_FEAT_ONESHOT,
+		/* Should be lower than at91rm9200's system timer */
+		.rating		= 125,
+	},
 };
 
 static u64 tc_get_cycles(struct clocksource *cs)
@@ -58,6 +64,72 @@ static u64 notrace tc_sched_clock_read32(void)
 	return tc_get_cycles32(&tc.clksrc);
 }
 
+static int tcb_clkevt_next_event(unsigned long delta,
+				 struct clock_event_device *d)
+{
+	u32 old, next, cur;
+
+
+	regmap_read(tc.regmap, ATMEL_TC_CV(tc.channels[0]), &old);
+	next = old + delta;
+	regmap_write(tc.regmap, ATMEL_TC_RC(tc.channels[0]), next);
+	regmap_read(tc.regmap, ATMEL_TC_CV(tc.channels[0]), &cur);
+
+	/* check whether the delta elapsed while setting the register */
+	if ((next < old && cur < old && cur > next) ||
+	    (next > old && (cur < old || cur > next))) {
+		/*
+		 * Clear the CPCS bit in the status register to avoid
+		 * generating a spurious interrupt next time a valid
+		 * timer event is configured.
+		 */
+		regmap_read(tc.regmap, ATMEL_TC_SR(tc.channels[0]), &old);
+		return -ETIME;
+	}
+
+	regmap_write(tc.regmap, ATMEL_TC_IER(tc.channels[0]), ATMEL_TC_CPCS);
+
+	return 0;
+}
+
+static irqreturn_t tc_clkevt_irq(int irq, void *handle)
+{
+	unsigned int sr;
+
+	regmap_read(tc.regmap, ATMEL_TC_SR(tc.channels[0]), &sr);
+	if (sr & ATMEL_TC_CPCS) {
+		tc.clkevt.event_handler(&tc.clkevt);
+		return IRQ_HANDLED;
+	}
+
+	return IRQ_NONE;
+}
+
+static int tcb_clkevt_oneshot(struct clock_event_device *dev)
+{
+	if (clockevent_state_oneshot(dev))
+		return 0;
+
+	/*
+	 * Because both clockevent devices may share the same IRQ, we don't want
+	 * the less likely one to stay requested
+	 */
+	return request_irq(tc.irq, tc_clkevt_irq, IRQF_TIMER | IRQF_SHARED,
+			   tc.name, &tc);
+}
+
+static int tcb_clkevt_shutdown(struct clock_event_device *dev)
+{
+	regmap_write(tc.regmap, ATMEL_TC_IDR(tc.channels[0]), 0xff);
+	if (tc.bits == 16)
+		regmap_write(tc.regmap, ATMEL_TC_IDR(tc.channels[1]), 0xff);
+
+	if (!clockevent_state_detached(dev))
+		free_irq(tc.irq, &tc);
+
+	return 0;
+}
+
 static void __init tcb_setup_dual_chan(struct atmel_tcb_clksrc *tc,
 				       int mck_divisor_idx)
 {
@@ -188,6 +260,15 @@ static int __init tcb_clksrc_register(struct device_node *node,
 
 	tc.registered = true;
 
+	/* Set up and register clockevents */
+	tc.clkevt.name = tc.name;
+	tc.clkevt.cpumask = cpumask_of(0);
+	tc.clkevt.set_next_event = tcb_clkevt_next_event;
+	tc.clkevt.set_state_oneshot = tcb_clkevt_oneshot;
+	tc.clkevt.set_state_shutdown = tcb_clkevt_shutdown;
+	clockevents_config_and_register(&tc.clkevt, divided_rate, 1,
+					BIT(tc.bits) - 1);
+
 	return 0;
 
 err_disable_t1:
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 47/58] clocksource/drivers: timer-atmel-tcbclksrc: add clockevent device
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

It is possible to compare and get interrupts on the channel that is used
for the clocksource. Enable that to have a solution using only one TCB
channel.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/clocksource/timer-atmel-tcbclksrc.c | 81 +++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/drivers/clocksource/timer-atmel-tcbclksrc.c b/drivers/clocksource/timer-atmel-tcbclksrc.c
index f18d177bfdea..462b04e9fed8 100644
--- a/drivers/clocksource/timer-atmel-tcbclksrc.c
+++ b/drivers/clocksource/timer-atmel-tcbclksrc.c
@@ -12,6 +12,7 @@
 static struct atmel_tcb_clksrc {
 	char name[20];
 	struct clocksource clksrc;
+	struct clock_event_device clkevt;
 	struct regmap *regmap;
 	struct clk *clk[2];
 	int channels[2];
@@ -24,6 +25,11 @@ static struct atmel_tcb_clksrc {
 		.mask		= CLOCKSOURCE_MASK(32),
 		.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 	},
+	.clkevt	= {
+		.features	= CLOCK_EVT_FEAT_ONESHOT,
+		/* Should be lower than at91rm9200's system timer */
+		.rating		= 125,
+	},
 };
 
 static u64 tc_get_cycles(struct clocksource *cs)
@@ -58,6 +64,72 @@ static u64 notrace tc_sched_clock_read32(void)
 	return tc_get_cycles32(&tc.clksrc);
 }
 
+static int tcb_clkevt_next_event(unsigned long delta,
+				 struct clock_event_device *d)
+{
+	u32 old, next, cur;
+
+
+	regmap_read(tc.regmap, ATMEL_TC_CV(tc.channels[0]), &old);
+	next = old + delta;
+	regmap_write(tc.regmap, ATMEL_TC_RC(tc.channels[0]), next);
+	regmap_read(tc.regmap, ATMEL_TC_CV(tc.channels[0]), &cur);
+
+	/* check whether the delta elapsed while setting the register */
+	if ((next < old && cur < old && cur > next) ||
+	    (next > old && (cur < old || cur > next))) {
+		/*
+		 * Clear the CPCS bit in the status register to avoid
+		 * generating a spurious interrupt next time a valid
+		 * timer event is configured.
+		 */
+		regmap_read(tc.regmap, ATMEL_TC_SR(tc.channels[0]), &old);
+		return -ETIME;
+	}
+
+	regmap_write(tc.regmap, ATMEL_TC_IER(tc.channels[0]), ATMEL_TC_CPCS);
+
+	return 0;
+}
+
+static irqreturn_t tc_clkevt_irq(int irq, void *handle)
+{
+	unsigned int sr;
+
+	regmap_read(tc.regmap, ATMEL_TC_SR(tc.channels[0]), &sr);
+	if (sr & ATMEL_TC_CPCS) {
+		tc.clkevt.event_handler(&tc.clkevt);
+		return IRQ_HANDLED;
+	}
+
+	return IRQ_NONE;
+}
+
+static int tcb_clkevt_oneshot(struct clock_event_device *dev)
+{
+	if (clockevent_state_oneshot(dev))
+		return 0;
+
+	/*
+	 * Because both clockevent devices may share the same IRQ, we don't want
+	 * the less likely one to stay requested
+	 */
+	return request_irq(tc.irq, tc_clkevt_irq, IRQF_TIMER | IRQF_SHARED,
+			   tc.name, &tc);
+}
+
+static int tcb_clkevt_shutdown(struct clock_event_device *dev)
+{
+	regmap_write(tc.regmap, ATMEL_TC_IDR(tc.channels[0]), 0xff);
+	if (tc.bits == 16)
+		regmap_write(tc.regmap, ATMEL_TC_IDR(tc.channels[1]), 0xff);
+
+	if (!clockevent_state_detached(dev))
+		free_irq(tc.irq, &tc);
+
+	return 0;
+}
+
 static void __init tcb_setup_dual_chan(struct atmel_tcb_clksrc *tc,
 				       int mck_divisor_idx)
 {
@@ -188,6 +260,15 @@ static int __init tcb_clksrc_register(struct device_node *node,
 
 	tc.registered = true;
 
+	/* Set up and register clockevents */
+	tc.clkevt.name = tc.name;
+	tc.clkevt.cpumask = cpumask_of(0);
+	tc.clkevt.set_next_event = tcb_clkevt_next_event;
+	tc.clkevt.set_state_oneshot = tcb_clkevt_oneshot;
+	tc.clkevt.set_state_shutdown = tcb_clkevt_shutdown;
+	clockevents_config_and_register(&tc.clkevt, divided_rate, 1,
+					BIT(tc.bits) - 1);
+
 	return 0;
 
 err_disable_t1:
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 48/58] clocksource/drivers: timer-atmel-tcbclksrc: add clockevent device on separate channel
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Daniel Lezcano, Thomas Gleixner

Add an other clockevent device that uses a separate TCB channel when
available.

Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/clocksource/timer-atmel-tcbclksrc.c | 177 +++++++++++++++++++++++++++-
 1 file changed, 173 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/timer-atmel-tcbclksrc.c b/drivers/clocksource/timer-atmel-tcbclksrc.c
index 462b04e9fed8..e117c11b4d1c 100644
--- a/drivers/clocksource/timer-atmel-tcbclksrc.c
+++ b/drivers/clocksource/timer-atmel-tcbclksrc.c
@@ -32,6 +32,167 @@ static struct atmel_tcb_clksrc {
 	},
 };
 
+static struct tc_clkevt_device {
+	char name[20];
+	struct clock_event_device clkevt;
+	struct regmap *regmap;
+	struct clk *slow_clk;
+	struct clk *clk;
+	int channel;
+	int irq;
+	bool registered;
+} tce = {
+	.clkevt	= {
+		.features		= CLOCK_EVT_FEAT_PERIODIC |
+					  CLOCK_EVT_FEAT_ONESHOT,
+		/*
+		 * Should be lower than at91rm9200's system timer
+		 * but higher than tc.clkevt.rating
+		 */
+		.rating			= 140,
+	},
+};
+
+static int tc_clkevt2_shutdown(struct clock_event_device *d)
+{
+	regmap_write(tce.regmap, ATMEL_TC_IDR(tce.channel), 0xff);
+	regmap_write(tce.regmap, ATMEL_TC_CCR(tce.channel),
+		     ATMEL_TC_CCR_CLKDIS);
+	if (!clockevent_state_detached(d))
+		clk_disable(tce.clk);
+
+	return 0;
+}
+
+/* For now, we always use the 32K clock ... this optimizes for NO_HZ,
+ * because using one of the divided clocks would usually mean the
+ * tick rate can never be less than several dozen Hz (vs 0.5 Hz).
+ *
+ * A divided clock could be good for high resolution timers, since
+ * 30.5 usec resolution can seem "low".
+ */
+static int tc_clkevt2_set_oneshot(struct clock_event_device *d)
+{
+	if (clockevent_state_oneshot(d) || clockevent_state_periodic(d))
+		tc_clkevt2_shutdown(d);
+
+	clk_enable(tce.clk);
+
+	/* slow clock, count up to RC, then irq and stop */
+	regmap_write(tce.regmap, ATMEL_TC_CMR(tce.channel),
+		     ATMEL_TC_CMR_TCLK(4) | ATMEL_TC_CMR_CPCSTOP |
+		     ATMEL_TC_CMR_WAVE | ATMEL_TC_CMR_WAVESEL_UPRC);
+	regmap_write(tce.regmap, ATMEL_TC_IER(tce.channel),
+		     ATMEL_TC_CPCS);
+
+	return 0;
+}
+
+static int tc_clkevt2_set_periodic(struct clock_event_device *d)
+{
+	if (clockevent_state_oneshot(d) || clockevent_state_periodic(d))
+		tc_clkevt2_shutdown(d);
+
+	/* By not making the gentime core emulate periodic mode on top
+	 * of oneshot, we get lower overhead and improved accuracy.
+	 */
+	clk_enable(tce.clk);
+
+	/* slow clock, count up to RC, then irq and restart */
+	regmap_write(tce.regmap, ATMEL_TC_CMR(tce.channel),
+		     ATMEL_TC_CMR_TCLK(4) | ATMEL_TC_CMR_WAVE |
+		     ATMEL_TC_CMR_WAVESEL_UPRC);
+	regmap_write(tce.regmap, ATMEL_TC_RC(tce.channel),
+		     (32768 + HZ / 2) / HZ);
+
+	/* Enable clock and interrupts on RC compare */
+	regmap_write(tce.regmap, ATMEL_TC_IER(tce.channel), ATMEL_TC_CPCS);
+	regmap_write(tce.regmap, ATMEL_TC_CCR(tce.channel),
+		     ATMEL_TC_CCR_CLKEN | ATMEL_TC_CCR_SWTRG);
+
+	return 0;
+}
+
+static int tc_clkevt2_next_event(unsigned long delta, struct clock_event_device *d)
+{
+	regmap_write(tce.regmap, ATMEL_TC_RC(tce.channel), delta);
+	regmap_write(tce.regmap, ATMEL_TC_CCR(tce.channel),
+		     ATMEL_TC_CCR_CLKEN | ATMEL_TC_CCR_SWTRG);
+
+	return 0;
+}
+
+static irqreturn_t tc_clkevt2_irq(int irq, void *handle)
+{
+	unsigned int sr;
+
+	regmap_read(tce.regmap, ATMEL_TC_SR(tce.channel), &sr);
+	if (sr & ATMEL_TC_CPCS) {
+		tce.clkevt.event_handler(&tce.clkevt);
+		return IRQ_HANDLED;
+	}
+
+	return IRQ_NONE;
+}
+
+static int __init tc_clkevt_register(struct device_node *node,
+				     struct regmap *regmap, int channel,
+				     int irq, int bits)
+{
+	int ret;
+
+	tce.regmap = regmap;
+	tce.channel = channel;
+	tce.irq = irq;
+
+	tce.slow_clk = of_clk_get_by_name(node->parent, "slow_clk");
+	if (IS_ERR(tce.slow_clk))
+		return PTR_ERR(tce.slow_clk);
+
+	ret = clk_prepare_enable(tce.slow_clk);
+	if (ret)
+		return ret;
+
+	tce.clk = tcb_clk_get(node, tce.channel);
+	if (IS_ERR(tce.clk)) {
+		ret = PTR_ERR(tce.clk);
+		goto err_slow;
+	}
+
+	snprintf(tce.name, sizeof(tce.name), "%s:%d",
+		 kbasename(node->parent->full_name), channel);
+	tce.clkevt.cpumask = cpumask_of(0);
+	tce.clkevt.name = tce.name;
+	tce.clkevt.set_next_event = tc_clkevt2_next_event,
+	tce.clkevt.set_state_shutdown = tc_clkevt2_shutdown,
+	tce.clkevt.set_state_periodic = tc_clkevt2_set_periodic,
+	tce.clkevt.set_state_oneshot = tc_clkevt2_set_oneshot,
+
+	/* try to enable clk to avoid future errors in mode change */
+	ret = clk_prepare_enable(tce.clk);
+	if (ret)
+		goto err_slow;
+	clk_disable(tce.clk);
+
+	clockevents_config_and_register(&tce.clkevt, 32768, 1, bits - 1);
+
+	ret = request_irq(tce.irq, tc_clkevt2_irq, IRQF_TIMER | IRQF_SHARED,
+			  tce.clkevt.name, &tce);
+	if (ret)
+		goto err_clk;
+
+	tce.registered = true;
+
+	return 0;
+
+err_clk:
+	clk_unprepare(tce.clk);
+err_slow:
+	clk_disable_unprepare(tce.slow_clk);
+
+	return ret;
+}
+
 static u64 tc_get_cycles(struct clocksource *cs)
 {
 	u32		lower, upper, tmp;
@@ -299,7 +460,7 @@ static int __init tcb_clksrc_init(struct device_node *node)
 	u32 channel;
 	int bits, irq, err, chan1 = -1;
 
-	if (tc.registered)
+	if (tc.registered && tce.registered)
 		return -ENODEV;
 
 	regmap = syscon_node_to_regmap(node->parent);
@@ -318,12 +479,20 @@ static int __init tcb_clksrc_init(struct device_node *node)
 	if (irq < 0)
 		return irq;
 
+	if (tc.registered)
+		return tc_clkevt_register(node, regmap, channel, irq, bits);
+
 	if (bits == 16) {
 		of_property_read_u32_index(node, "reg", 1, &chan1);
 		if (chan1 == -1) {
-			pr_err("%s: clocksource needs two channels\n",
-			       node->parent->full_name);
-			return -EINVAL;
+			if (tce.registered) {
+				pr_err("%s: clocksource needs two channels\n",
+				       node->parent->full_name);
+				return -EINVAL;
+			} else {
+				return tc_clkevt_register(node, regmap, channel,
+							  irq, bits);
+			}
 		}
 	}
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 48/58] clocksource/drivers: timer-atmel-tcbclksrc: add clockevent device on separate channel
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Add an other clockevent device that uses a separate TCB channel when
available.

Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/clocksource/timer-atmel-tcbclksrc.c | 177 +++++++++++++++++++++++++++-
 1 file changed, 173 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/timer-atmel-tcbclksrc.c b/drivers/clocksource/timer-atmel-tcbclksrc.c
index 462b04e9fed8..e117c11b4d1c 100644
--- a/drivers/clocksource/timer-atmel-tcbclksrc.c
+++ b/drivers/clocksource/timer-atmel-tcbclksrc.c
@@ -32,6 +32,167 @@ static struct atmel_tcb_clksrc {
 	},
 };
 
+static struct tc_clkevt_device {
+	char name[20];
+	struct clock_event_device clkevt;
+	struct regmap *regmap;
+	struct clk *slow_clk;
+	struct clk *clk;
+	int channel;
+	int irq;
+	bool registered;
+} tce = {
+	.clkevt	= {
+		.features		= CLOCK_EVT_FEAT_PERIODIC |
+					  CLOCK_EVT_FEAT_ONESHOT,
+		/*
+		 * Should be lower than at91rm9200's system timer
+		 * but higher than tc.clkevt.rating
+		 */
+		.rating			= 140,
+	},
+};
+
+static int tc_clkevt2_shutdown(struct clock_event_device *d)
+{
+	regmap_write(tce.regmap, ATMEL_TC_IDR(tce.channel), 0xff);
+	regmap_write(tce.regmap, ATMEL_TC_CCR(tce.channel),
+		     ATMEL_TC_CCR_CLKDIS);
+	if (!clockevent_state_detached(d))
+		clk_disable(tce.clk);
+
+	return 0;
+}
+
+/* For now, we always use the 32K clock ... this optimizes for NO_HZ,
+ * because using one of the divided clocks would usually mean the
+ * tick rate can never be less than several dozen Hz (vs 0.5 Hz).
+ *
+ * A divided clock could be good for high resolution timers, since
+ * 30.5 usec resolution can seem "low".
+ */
+static int tc_clkevt2_set_oneshot(struct clock_event_device *d)
+{
+	if (clockevent_state_oneshot(d) || clockevent_state_periodic(d))
+		tc_clkevt2_shutdown(d);
+
+	clk_enable(tce.clk);
+
+	/* slow clock, count up to RC, then irq and stop */
+	regmap_write(tce.regmap, ATMEL_TC_CMR(tce.channel),
+		     ATMEL_TC_CMR_TCLK(4) | ATMEL_TC_CMR_CPCSTOP |
+		     ATMEL_TC_CMR_WAVE | ATMEL_TC_CMR_WAVESEL_UPRC);
+	regmap_write(tce.regmap, ATMEL_TC_IER(tce.channel),
+		     ATMEL_TC_CPCS);
+
+	return 0;
+}
+
+static int tc_clkevt2_set_periodic(struct clock_event_device *d)
+{
+	if (clockevent_state_oneshot(d) || clockevent_state_periodic(d))
+		tc_clkevt2_shutdown(d);
+
+	/* By not making the gentime core emulate periodic mode on top
+	 * of oneshot, we get lower overhead and improved accuracy.
+	 */
+	clk_enable(tce.clk);
+
+	/* slow clock, count up to RC, then irq and restart */
+	regmap_write(tce.regmap, ATMEL_TC_CMR(tce.channel),
+		     ATMEL_TC_CMR_TCLK(4) | ATMEL_TC_CMR_WAVE |
+		     ATMEL_TC_CMR_WAVESEL_UPRC);
+	regmap_write(tce.regmap, ATMEL_TC_RC(tce.channel),
+		     (32768 + HZ / 2) / HZ);
+
+	/* Enable clock and interrupts on RC compare */
+	regmap_write(tce.regmap, ATMEL_TC_IER(tce.channel), ATMEL_TC_CPCS);
+	regmap_write(tce.regmap, ATMEL_TC_CCR(tce.channel),
+		     ATMEL_TC_CCR_CLKEN | ATMEL_TC_CCR_SWTRG);
+
+	return 0;
+}
+
+static int tc_clkevt2_next_event(unsigned long delta, struct clock_event_device *d)
+{
+	regmap_write(tce.regmap, ATMEL_TC_RC(tce.channel), delta);
+	regmap_write(tce.regmap, ATMEL_TC_CCR(tce.channel),
+		     ATMEL_TC_CCR_CLKEN | ATMEL_TC_CCR_SWTRG);
+
+	return 0;
+}
+
+static irqreturn_t tc_clkevt2_irq(int irq, void *handle)
+{
+	unsigned int sr;
+
+	regmap_read(tce.regmap, ATMEL_TC_SR(tce.channel), &sr);
+	if (sr & ATMEL_TC_CPCS) {
+		tce.clkevt.event_handler(&tce.clkevt);
+		return IRQ_HANDLED;
+	}
+
+	return IRQ_NONE;
+}
+
+static int __init tc_clkevt_register(struct device_node *node,
+				     struct regmap *regmap, int channel,
+				     int irq, int bits)
+{
+	int ret;
+
+	tce.regmap = regmap;
+	tce.channel = channel;
+	tce.irq = irq;
+
+	tce.slow_clk = of_clk_get_by_name(node->parent, "slow_clk");
+	if (IS_ERR(tce.slow_clk))
+		return PTR_ERR(tce.slow_clk);
+
+	ret = clk_prepare_enable(tce.slow_clk);
+	if (ret)
+		return ret;
+
+	tce.clk = tcb_clk_get(node, tce.channel);
+	if (IS_ERR(tce.clk)) {
+		ret = PTR_ERR(tce.clk);
+		goto err_slow;
+	}
+
+	snprintf(tce.name, sizeof(tce.name), "%s:%d",
+		 kbasename(node->parent->full_name), channel);
+	tce.clkevt.cpumask = cpumask_of(0);
+	tce.clkevt.name = tce.name;
+	tce.clkevt.set_next_event = tc_clkevt2_next_event,
+	tce.clkevt.set_state_shutdown = tc_clkevt2_shutdown,
+	tce.clkevt.set_state_periodic = tc_clkevt2_set_periodic,
+	tce.clkevt.set_state_oneshot = tc_clkevt2_set_oneshot,
+
+	/* try to enable clk to avoid future errors in mode change */
+	ret = clk_prepare_enable(tce.clk);
+	if (ret)
+		goto err_slow;
+	clk_disable(tce.clk);
+
+	clockevents_config_and_register(&tce.clkevt, 32768, 1, bits - 1);
+
+	ret = request_irq(tce.irq, tc_clkevt2_irq, IRQF_TIMER | IRQF_SHARED,
+			  tce.clkevt.name, &tce);
+	if (ret)
+		goto err_clk;
+
+	tce.registered = true;
+
+	return 0;
+
+err_clk:
+	clk_unprepare(tce.clk);
+err_slow:
+	clk_disable_unprepare(tce.slow_clk);
+
+	return ret;
+}
+
 static u64 tc_get_cycles(struct clocksource *cs)
 {
 	u32		lower, upper, tmp;
@@ -299,7 +460,7 @@ static int __init tcb_clksrc_init(struct device_node *node)
 	u32 channel;
 	int bits, irq, err, chan1 = -1;
 
-	if (tc.registered)
+	if (tc.registered && tce.registered)
 		return -ENODEV;
 
 	regmap = syscon_node_to_regmap(node->parent);
@@ -318,12 +479,20 @@ static int __init tcb_clksrc_init(struct device_node *node)
 	if (irq < 0)
 		return irq;
 
+	if (tc.registered)
+		return tc_clkevt_register(node, regmap, channel, irq, bits);
+
 	if (bits == 16) {
 		of_property_read_u32_index(node, "reg", 1, &chan1);
 		if (chan1 == -1) {
-			pr_err("%s: clocksource needs two channels\n",
-			       node->parent->full_name);
-			return -EINVAL;
+			if (tce.registered) {
+				pr_err("%s: clocksource needs two channels\n",
+				       node->parent->full_name);
+				return -EINVAL;
+			} else {
+				return tc_clkevt_register(node, regmap, channel,
+							  irq, bits);
+			}
 		}
 	}
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 49/58] clocksource/drivers: atmel-pit: allow unselecting ATMEL_PIT
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Daniel Lezcano, Thomas Gleixner

With the new TCB clocksource driver, atmel platforms are now able to boot
without the PIT driver. Allow unselecting it.

Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/clocksource/Kconfig | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index cbd710db3c09..2777c29191e3 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -408,7 +408,14 @@ config ARMV7M_SYSTICK
 
 config ATMEL_PIT
 	select CLKSRC_OF if OF
-	def_bool SOC_AT91SAM9 || SOC_SAMA5
+	bool "Atmel Periodic Interval Timer (PIT)"
+	depends on SOC_AT91SAM9 || SOC_SAMA5
+	default SOC_AT91SAM9 || SOC_SAMA5
+	help
+	  Select this to get a clocksource based on the Atmel Periodic Interval
+	  Timer. It has a relatively low resolution and the TC Block clocksource
+	  should be preferred.
+	  It also provides a clock event device.
 
 config ATMEL_ST
 	bool "Atmel ST timer support" if COMPILE_TEST
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 49/58] clocksource/drivers: atmel-pit: allow unselecting ATMEL_PIT
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

With the new TCB clocksource driver, atmel platforms are now able to boot
without the PIT driver. Allow unselecting it.

Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/clocksource/Kconfig | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index cbd710db3c09..2777c29191e3 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -408,7 +408,14 @@ config ARMV7M_SYSTICK
 
 config ATMEL_PIT
 	select CLKSRC_OF if OF
-	def_bool SOC_AT91SAM9 || SOC_SAMA5
+	bool "Atmel Periodic Interval Timer (PIT)"
+	depends on SOC_AT91SAM9 || SOC_SAMA5
+	default SOC_AT91SAM9 || SOC_SAMA5
+	help
+	  Select this to get a clocksource based on the Atmel Periodic Interval
+	  Timer. It has a relatively low resolution and the TC Block clocksource
+	  should be preferred.
+	  It also provides a clock event device.
 
 config ATMEL_ST
 	bool "Atmel ST timer support" if COMPILE_TEST
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 50/58] ARM: at91/defconfig: sama5: unselect ATMEL_PIT
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

The PIT is not required anymore to successfully boot and may actually harm
in case preempt-rt is used because the PIT interrupt is shared.
Disable it so the TCB clocksource is used.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/configs/sama5_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/sama5_defconfig b/arch/arm/configs/sama5_defconfig
index 777c9e986425..161d6221ce6e 100644
--- a/arch/arm/configs/sama5_defconfig
+++ b/arch/arm/configs/sama5_defconfig
@@ -197,6 +197,7 @@ CONFIG_RTC_DRV_AT91RM9200=y
 CONFIG_DMADEVICES=y
 CONFIG_AT_HDMAC=y
 CONFIG_AT_XDMAC=y
+# CONFIG_ATMEL_PIT is not set
 # CONFIG_IOMMU_SUPPORT is not set
 CONFIG_IIO=y
 CONFIG_AT91_ADC=y
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 50/58] ARM: at91/defconfig: sama5: unselect ATMEL_PIT
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

The PIT is not required anymore to successfully boot and may actually harm
in case preempt-rt is used because the PIT interrupt is shared.
Disable it so the TCB clocksource is used.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/configs/sama5_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/sama5_defconfig b/arch/arm/configs/sama5_defconfig
index 777c9e986425..161d6221ce6e 100644
--- a/arch/arm/configs/sama5_defconfig
+++ b/arch/arm/configs/sama5_defconfig
@@ -197,6 +197,7 @@ CONFIG_RTC_DRV_AT91RM9200=y
 CONFIG_DMADEVICES=y
 CONFIG_AT_HDMAC=y
 CONFIG_AT_XDMAC=y
+# CONFIG_ATMEL_PIT is not set
 # CONFIG_IOMMU_SUPPORT is not set
 CONFIG_IIO=y
 CONFIG_AT91_ADC=y
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 51/58] ARM: at91/defconfig: at91_dt unselect ATMEL_PIT
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

The PIT is not required anymore to successfully boot and may actually harm
in case preempt-rt is used because the PIT interrupt is shared.
Disable it so the TCB clocksource is used.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/configs/at91_dt_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/at91_dt_defconfig b/arch/arm/configs/at91_dt_defconfig
index e4b1be66b3f5..9d068f07b84b 100644
--- a/arch/arm/configs/at91_dt_defconfig
+++ b/arch/arm/configs/at91_dt_defconfig
@@ -182,6 +182,7 @@ CONFIG_RTC_DRV_AT91RM9200=y
 CONFIG_RTC_DRV_AT91SAM9=y
 CONFIG_DMADEVICES=y
 CONFIG_AT_HDMAC=y
+# CONFIG_ATMEL_PIT is not set
 # CONFIG_IOMMU_SUPPORT is not set
 CONFIG_IIO=y
 CONFIG_AT91_ADC=y
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 51/58] ARM: at91/defconfig: at91_dt unselect ATMEL_PIT
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

The PIT is not required anymore to successfully boot and may actually harm
in case preempt-rt is used because the PIT interrupt is shared.
Disable it so the TCB clocksource is used.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/configs/at91_dt_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/at91_dt_defconfig b/arch/arm/configs/at91_dt_defconfig
index e4b1be66b3f5..9d068f07b84b 100644
--- a/arch/arm/configs/at91_dt_defconfig
+++ b/arch/arm/configs/at91_dt_defconfig
@@ -182,6 +182,7 @@ CONFIG_RTC_DRV_AT91RM9200=y
 CONFIG_RTC_DRV_AT91SAM9=y
 CONFIG_DMADEVICES=y
 CONFIG_AT_HDMAC=y
+# CONFIG_ATMEL_PIT is not set
 # CONFIG_IOMMU_SUPPORT is not set
 CONFIG_IIO=y
 CONFIG_AT91_ADC=y
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 52/58] PWM: atmel-tcb: switch to new binding
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Thierry Reding, linux-pwm

The PWM is now a subnode of the used TCB. This is cleaner and it mainly
allows to stop wasting TCB channels when only 4 PWMs are used.

Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-pwm@vger.kernel.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/pwm/Kconfig         |   3 +-
 drivers/pwm/pwm-atmel-tcb.c | 221 ++++++++++++++++++++++++--------------------
 2 files changed, 122 insertions(+), 102 deletions(-)

diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index 313c10789ca2..d154f1fb610e 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -64,7 +64,8 @@ config PWM_ATMEL_HLCDC_PWM
 
 config PWM_ATMEL_TCB
 	tristate "Atmel TC Block PWM support"
-	depends on ATMEL_TCLIB && OF
+	depends on OF
+	select REGMAP_MMIO
 	help
 	  Generic PWM framework driver for Atmel Timer Counter Block.
 
diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c
index 75db585a2a94..9aa569835b97 100644
--- a/drivers/pwm/pwm-atmel-tcb.c
+++ b/drivers/pwm/pwm-atmel-tcb.c
@@ -16,19 +16,26 @@
 #include <linux/err.h>
 #include <linux/ioport.h>
 #include <linux/io.h>
+#include <linux/mfd/syscon.h>
 #include <linux/platform_device.h>
-#include <linux/atmel_tc.h>
 #include <linux/pwm.h>
 #include <linux/of_device.h>
+#include <linux/of_irq.h>
+#include <linux/regmap.h>
 #include <linux/slab.h>
+#include <soc/at91/atmel_tcb.h>
 
-#define NPWM	6
+#define NPWM	2
 
-#define ATMEL_TC_ACMR_MASK	(ATMEL_TC_ACPA | ATMEL_TC_ACPC |	\
-				 ATMEL_TC_AEEVT | ATMEL_TC_ASWTRG)
+#define ATMEL_TC_ACMR_MASK	(ATMEL_TC_CMR_ACPA_MSK | \
+				 ATMEL_TC_CMR_ACPC_MSK | \
+				 ATMEL_TC_CMR_AEEVT_MSK | \
+				 ATMEL_TC_CMR_ASWTRG_MSK)
 
-#define ATMEL_TC_BCMR_MASK	(ATMEL_TC_BCPB | ATMEL_TC_BCPC |	\
-				 ATMEL_TC_BEEVT | ATMEL_TC_BSWTRG)
+#define ATMEL_TC_BCMR_MASK	(ATMEL_TC_CMR_BCPB_MSK | \
+				 ATMEL_TC_CMR_BCPC_MSK | \
+				 ATMEL_TC_CMR_BEEVT_MSK | \
+				 ATMEL_TC_CMR_BSWTRG_MSK)
 
 struct atmel_tcb_pwm_device {
 	enum pwm_polarity polarity;	/* PWM polarity */
@@ -40,7 +47,11 @@ struct atmel_tcb_pwm_device {
 struct atmel_tcb_pwm_chip {
 	struct pwm_chip chip;
 	spinlock_t lock;
-	struct atmel_tc *tc;
+	u8 channel;
+	u8 width;
+	struct regmap *regmap;
+	struct clk *clk;
+	struct clk *slow_clk;
 	struct atmel_tcb_pwm_device *pwms[NPWM];
 };
 
@@ -65,10 +76,6 @@ static int atmel_tcb_pwm_request(struct pwm_chip *chip,
 {
 	struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip);
 	struct atmel_tcb_pwm_device *tcbpwm;
-	struct atmel_tc *tc = tcbpwmc->tc;
-	void __iomem *regs = tc->regs;
-	unsigned group = pwm->hwpwm / 2;
-	unsigned index = pwm->hwpwm % 2;
 	unsigned cmr;
 	int ret;
 
@@ -76,7 +83,7 @@ static int atmel_tcb_pwm_request(struct pwm_chip *chip,
 	if (!tcbpwm)
 		return -ENOMEM;
 
-	ret = clk_prepare_enable(tc->clk[group]);
+	ret = clk_prepare_enable(tcbpwmc->clk);
 	if (ret) {
 		devm_kfree(chip->dev, tcbpwm);
 		return ret;
@@ -89,28 +96,32 @@ static int atmel_tcb_pwm_request(struct pwm_chip *chip,
 	tcbpwm->div = 0;
 
 	spin_lock(&tcbpwmc->lock);
-	cmr = __raw_readl(regs + ATMEL_TC_REG(group, CMR));
+	regmap_read(tcbpwmc->regmap, ATMEL_TC_CMR(tcbpwmc->channel), &cmr);
 	/*
 	 * Get init config from Timer Counter registers if
 	 * Timer Counter is already configured as a PWM generator.
 	 */
-	if (cmr & ATMEL_TC_WAVE) {
-		if (index == 0)
-			tcbpwm->duty =
-				__raw_readl(regs + ATMEL_TC_REG(group, RA));
+	if (cmr & ATMEL_TC_CMR_WAVE) {
+		if (pwm->hwpwm == 0)
+			regmap_read(tcbpwmc->regmap,
+				    ATMEL_TC_RA(tcbpwmc->channel),
+				    &tcbpwm->duty);
 		else
-			tcbpwm->duty =
-				__raw_readl(regs + ATMEL_TC_REG(group, RB));
-
-		tcbpwm->div = cmr & ATMEL_TC_TCCLKS;
-		tcbpwm->period = __raw_readl(regs + ATMEL_TC_REG(group, RC));
-		cmr &= (ATMEL_TC_TCCLKS | ATMEL_TC_ACMR_MASK |
+			regmap_read(tcbpwmc->regmap,
+				    ATMEL_TC_RB(tcbpwmc->channel),
+				    &tcbpwm->duty);
+
+		tcbpwm->div = cmr & ATMEL_TC_CMR_TCLKS_MSK;
+		regmap_read(tcbpwmc->regmap, ATMEL_TC_RC(tcbpwmc->channel),
+			    &tcbpwm->period);
+		cmr &= (ATMEL_TC_CMR_TCLKS_MSK | ATMEL_TC_ACMR_MASK |
 			ATMEL_TC_BCMR_MASK);
 	} else
 		cmr = 0;
 
-	cmr |= ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO | ATMEL_TC_EEVT_XC0;
-	__raw_writel(cmr, regs + ATMEL_TC_REG(group, CMR));
+	cmr |= ATMEL_TC_CMR_WAVE | ATMEL_TC_CMR_WAVESEL_UPRC |
+	       ATMEL_TC_CMR_EEVT_XC(0);
+	regmap_write(tcbpwmc->regmap, ATMEL_TC_CMR(tcbpwmc->channel), cmr);
 	spin_unlock(&tcbpwmc->lock);
 
 	tcbpwmc->pwms[pwm->hwpwm] = tcbpwm;
@@ -122,9 +133,8 @@ static void atmel_tcb_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
 {
 	struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip);
 	struct atmel_tcb_pwm_device *tcbpwm = pwm_get_chip_data(pwm);
-	struct atmel_tc *tc = tcbpwmc->tc;
 
-	clk_disable_unprepare(tc->clk[pwm->hwpwm / 2]);
+	clk_disable_unprepare(tcbpwmc->clk);
 	tcbpwmc->pwms[pwm->hwpwm] = NULL;
 	devm_kfree(chip->dev, tcbpwm);
 }
@@ -133,10 +143,6 @@ static void atmel_tcb_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
 {
 	struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip);
 	struct atmel_tcb_pwm_device *tcbpwm = pwm_get_chip_data(pwm);
-	struct atmel_tc *tc = tcbpwmc->tc;
-	void __iomem *regs = tc->regs;
-	unsigned group = pwm->hwpwm / 2;
-	unsigned index = pwm->hwpwm % 2;
 	unsigned cmr;
 	enum pwm_polarity polarity = tcbpwm->polarity;
 
@@ -152,35 +158,35 @@ static void atmel_tcb_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
 		polarity = !polarity;
 
 	spin_lock(&tcbpwmc->lock);
-	cmr = __raw_readl(regs + ATMEL_TC_REG(group, CMR));
+	regmap_read(tcbpwmc->regmap, ATMEL_TC_CMR(tcbpwmc->channel), &cmr);
 
 	/* flush old setting and set the new one */
-	if (index == 0) {
+	if (pwm->hwpwm == 0) {
 		cmr &= ~ATMEL_TC_ACMR_MASK;
 		if (polarity == PWM_POLARITY_INVERSED)
-			cmr |= ATMEL_TC_ASWTRG_CLEAR;
+			cmr |= ATMEL_TC_CMR_ASWTRG(CLEAR);
 		else
-			cmr |= ATMEL_TC_ASWTRG_SET;
+			cmr |= ATMEL_TC_CMR_ASWTRG(SET);
 	} else {
 		cmr &= ~ATMEL_TC_BCMR_MASK;
 		if (polarity == PWM_POLARITY_INVERSED)
-			cmr |= ATMEL_TC_BSWTRG_CLEAR;
+			cmr |= ATMEL_TC_CMR_BSWTRG(CLEAR);
 		else
-			cmr |= ATMEL_TC_BSWTRG_SET;
+			cmr |= ATMEL_TC_CMR_BSWTRG(SET);
 	}
 
-	__raw_writel(cmr, regs + ATMEL_TC_REG(group, CMR));
+	regmap_write(tcbpwmc->regmap, ATMEL_TC_CMR(tcbpwmc->channel), cmr);
 
 	/*
 	 * Use software trigger to apply the new setting.
 	 * If both PWM devices in this group are disabled we stop the clock.
 	 */
-	if (!(cmr & (ATMEL_TC_ACPC | ATMEL_TC_BCPC)))
-		__raw_writel(ATMEL_TC_SWTRG | ATMEL_TC_CLKDIS,
-			     regs + ATMEL_TC_REG(group, CCR));
+	if (!(cmr & (ATMEL_TC_CMR_ACPC_MSK | ATMEL_TC_CMR_BCPC_MSK)))
+		regmap_write(tcbpwmc->regmap, ATMEL_TC_CCR(tcbpwmc->channel),
+			     ATMEL_TC_CCR_SWTRG | ATMEL_TC_CCR_CLKDIS);
 	else
-		__raw_writel(ATMEL_TC_SWTRG, regs +
-			     ATMEL_TC_REG(group, CCR));
+		regmap_write(tcbpwmc->regmap, ATMEL_TC_CCR(tcbpwmc->channel),
+			     ATMEL_TC_CCR_SWTRG);
 
 	spin_unlock(&tcbpwmc->lock);
 }
@@ -189,10 +195,6 @@ static int atmel_tcb_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 {
 	struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip);
 	struct atmel_tcb_pwm_device *tcbpwm = pwm_get_chip_data(pwm);
-	struct atmel_tc *tc = tcbpwmc->tc;
-	void __iomem *regs = tc->regs;
-	unsigned group = pwm->hwpwm / 2;
-	unsigned index = pwm->hwpwm % 2;
 	u32 cmr;
 	enum pwm_polarity polarity = tcbpwm->polarity;
 
@@ -208,25 +210,25 @@ static int atmel_tcb_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 		polarity = !polarity;
 
 	spin_lock(&tcbpwmc->lock);
-	cmr = __raw_readl(regs + ATMEL_TC_REG(group, CMR));
+	regmap_read(tcbpwmc->regmap, ATMEL_TC_CMR(tcbpwmc->channel), &cmr);
 
 	/* flush old setting and set the new one */
-	cmr &= ~ATMEL_TC_TCCLKS;
+	cmr &= ~ATMEL_TC_CMR_TCLKS_MSK;
 
-	if (index == 0) {
+	if (pwm->hwpwm == 0) {
 		cmr &= ~ATMEL_TC_ACMR_MASK;
 
 		/* Set CMR flags according to given polarity */
 		if (polarity == PWM_POLARITY_INVERSED)
-			cmr |= ATMEL_TC_ASWTRG_CLEAR;
+			cmr |= ATMEL_TC_CMR_ASWTRG(CLEAR);
 		else
-			cmr |= ATMEL_TC_ASWTRG_SET;
+			cmr |= ATMEL_TC_CMR_ASWTRG(SET);
 	} else {
 		cmr &= ~ATMEL_TC_BCMR_MASK;
 		if (polarity == PWM_POLARITY_INVERSED)
-			cmr |= ATMEL_TC_BSWTRG_CLEAR;
+			cmr |= ATMEL_TC_CMR_BSWTRG(CLEAR);
 		else
-			cmr |= ATMEL_TC_BSWTRG_SET;
+			cmr |= ATMEL_TC_CMR_BSWTRG(SET);
 	}
 
 	/*
@@ -236,33 +238,40 @@ static int atmel_tcb_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 	 * this config till next config call.
 	 */
 	if (tcbpwm->duty != tcbpwm->period && tcbpwm->duty > 0) {
-		if (index == 0) {
+		if (pwm->hwpwm == 0) {
 			if (polarity == PWM_POLARITY_INVERSED)
-				cmr |= ATMEL_TC_ACPA_SET | ATMEL_TC_ACPC_CLEAR;
+				cmr |= ATMEL_TC_CMR_ACPA(SET) |
+				       ATMEL_TC_CMR_ACPC(CLEAR);
 			else
-				cmr |= ATMEL_TC_ACPA_CLEAR | ATMEL_TC_ACPC_SET;
+				cmr |= ATMEL_TC_CMR_ACPA(CLEAR) |
+				       ATMEL_TC_CMR_ACPC(SET);
 		} else {
 			if (polarity == PWM_POLARITY_INVERSED)
-				cmr |= ATMEL_TC_BCPB_SET | ATMEL_TC_BCPC_CLEAR;
+				cmr |= ATMEL_TC_CMR_BCPB(SET) |
+				       ATMEL_TC_CMR_BCPC(CLEAR);
 			else
-				cmr |= ATMEL_TC_BCPB_CLEAR | ATMEL_TC_BCPC_SET;
+				cmr |= ATMEL_TC_CMR_BCPB(CLEAR) |
+				       ATMEL_TC_CMR_BCPC(SET);
 		}
 	}
 
-	cmr |= (tcbpwm->div & ATMEL_TC_TCCLKS);
+	cmr |= (tcbpwm->div & ATMEL_TC_CMR_TCLKS_MSK);
 
-	__raw_writel(cmr, regs + ATMEL_TC_REG(group, CMR));
+	regmap_write(tcbpwmc->regmap, ATMEL_TC_CMR(tcbpwmc->channel), cmr);
 
-	if (index == 0)
-		__raw_writel(tcbpwm->duty, regs + ATMEL_TC_REG(group, RA));
+	if (pwm->hwpwm == 0)
+		regmap_write(tcbpwmc->regmap, ATMEL_TC_RA(tcbpwmc->channel),
+			     tcbpwm->duty);
 	else
-		__raw_writel(tcbpwm->duty, regs + ATMEL_TC_REG(group, RB));
+		regmap_write(tcbpwmc->regmap, ATMEL_TC_RB(tcbpwmc->channel),
+			     tcbpwm->duty);
 
-	__raw_writel(tcbpwm->period, regs + ATMEL_TC_REG(group, RC));
+	regmap_write(tcbpwmc->regmap, ATMEL_TC_RC(tcbpwmc->channel),
+		     tcbpwm->period);
 
 	/* Use software trigger to apply the new setting */
-	__raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
-		     regs + ATMEL_TC_REG(group, CCR));
+	regmap_write(tcbpwmc->regmap, ATMEL_TC_CCR(tcbpwmc->channel),
+		     ATMEL_TC_CCR_SWTRG | ATMEL_TC_CCR_CLKEN);
 	spin_unlock(&tcbpwmc->lock);
 	return 0;
 }
@@ -272,15 +281,12 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 {
 	struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip);
 	struct atmel_tcb_pwm_device *tcbpwm = pwm_get_chip_data(pwm);
-	unsigned group = pwm->hwpwm / 2;
-	unsigned index = pwm->hwpwm % 2;
 	struct atmel_tcb_pwm_device *atcbpwm = NULL;
-	struct atmel_tc *tc = tcbpwmc->tc;
 	int i;
 	int slowclk = 0;
 	unsigned period;
 	unsigned duty;
-	unsigned rate = clk_get_rate(tc->clk[group]);
+	unsigned rate = clk_get_rate(tcbpwmc->clk);
 	unsigned long long min;
 	unsigned long long max;
 
@@ -294,7 +300,7 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 			continue;
 		}
 		min = div_u64((u64)NSEC_PER_SEC * atmel_tc_divisors[i], rate);
-		max = min << tc->tcb_config->counter_width;
+		max = min << tcbpwmc->width;
 		if (max >= period_ns)
 			break;
 	}
@@ -305,9 +311,9 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 	 */
 	if (i == 5) {
 		i = slowclk;
-		rate = clk_get_rate(tc->slow_clk);
+		rate = clk_get_rate(tcbpwmc->slow_clk);
 		min = div_u64(NSEC_PER_SEC, rate);
-		max = min << tc->tcb_config->counter_width;
+		max = min << tcbpwmc->width;
 
 		/* If period is too big return ERANGE error */
 		if (max < period_ns)
@@ -317,17 +323,13 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 	duty = div_u64(duty_ns, min);
 	period = div_u64(period_ns, min);
 
-	if (index == 0)
-		atcbpwm = tcbpwmc->pwms[pwm->hwpwm + 1];
+	if (pwm->hwpwm == 0)
+		atcbpwm = tcbpwmc->pwms[1];
 	else
-		atcbpwm = tcbpwmc->pwms[pwm->hwpwm - 1];
+		atcbpwm = tcbpwmc->pwms[0];
 
 	/*
-	 * PWM devices provided by TCB driver are grouped by 2:
-	 * - group 0: PWM 0 & 1
-	 * - group 1: PWM 2 & 3
-	 * - group 2: PWM 4 & 5
-	 *
+	 * PWM devices provided by the TCB driver are grouped by 2.
 	 * PWM devices in a given group must be configured with the
 	 * same period_ns.
 	 *
@@ -365,31 +367,41 @@ static const struct pwm_ops atmel_tcb_pwm_ops = {
 
 static int atmel_tcb_pwm_probe(struct platform_device *pdev)
 {
+	const struct of_device_id *match;
+	const struct atmel_tcb_info *tcb_info;
 	struct atmel_tcb_pwm_chip *tcbpwm;
 	struct device_node *np = pdev->dev.of_node;
-	struct atmel_tc *tc;
+	struct regmap *regmap;
+	struct clk *clk;
+	struct clk *slow_clk;
 	int err;
-	int tcblock;
+	int channel;
 
-	err = of_property_read_u32(np, "tc-block", &tcblock);
+	err = of_property_read_u32(np, "reg", &channel);
 	if (err < 0) {
 		dev_err(&pdev->dev,
-			"failed to get Timer Counter Block number from device tree (error: %d)\n",
+			"failed to get Timer Counter Block channel from device tree (error: %d)\n",
 			err);
 		return err;
 	}
 
-	tc = atmel_tc_alloc(tcblock);
-	if (tc == NULL) {
-		dev_err(&pdev->dev, "failed to allocate Timer Counter Block\n");
-		return -ENOMEM;
-	}
+	regmap = syscon_node_to_regmap(np->parent);
+	if (IS_ERR(regmap))
+		return PTR_ERR(regmap);
+
+	slow_clk = of_clk_get_by_name(np->parent, "slow_clk");
+	if (IS_ERR(slow_clk))
+		return PTR_ERR(slow_clk);
+
+	clk = tcb_clk_get(np, channel);
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
 
 	tcbpwm = devm_kzalloc(&pdev->dev, sizeof(*tcbpwm), GFP_KERNEL);
 	if (tcbpwm == NULL) {
 		err = -ENOMEM;
 		dev_err(&pdev->dev, "failed to allocate memory\n");
-		goto err_free_tc;
+		goto err_slow_clk;
 	}
 
 	tcbpwm->chip.dev = &pdev->dev;
@@ -398,11 +410,18 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev)
 	tcbpwm->chip.of_pwm_n_cells = 3;
 	tcbpwm->chip.base = -1;
 	tcbpwm->chip.npwm = NPWM;
-	tcbpwm->tc = tc;
+	tcbpwm->channel = channel;
+	tcbpwm->regmap = regmap;
+	tcbpwm->clk = clk;
+	tcbpwm->slow_clk = slow_clk;
 
-	err = clk_prepare_enable(tc->slow_clk);
+	match = of_match_node(atmel_tcb_dt_ids, np->parent);
+	tcb_info = match->data;
+	tcbpwm->width = tcb_info->bits;
+
+	err = clk_prepare_enable(slow_clk);
 	if (err)
-		goto err_free_tc;
+		goto err_slow_clk;
 
 	spin_lock_init(&tcbpwm->lock);
 
@@ -415,10 +434,10 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev)
 	return 0;
 
 err_disable_clk:
-	clk_disable_unprepare(tcbpwm->tc->slow_clk);
+	clk_disable_unprepare(tcbpwm->slow_clk);
 
-err_free_tc:
-	atmel_tc_free(tc);
+err_slow_clk:
+	clk_put(slow_clk);
 
 	return err;
 }
@@ -428,14 +447,14 @@ static int atmel_tcb_pwm_remove(struct platform_device *pdev)
 	struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev);
 	int err;
 
-	clk_disable_unprepare(tcbpwm->tc->slow_clk);
+	clk_disable_unprepare(tcbpwm->slow_clk);
+	clk_put(tcbpwm->slow_clk);
+	clk_put(tcbpwm->clk);
 
 	err = pwmchip_remove(&tcbpwm->chip);
 	if (err < 0)
 		return err;
 
-	atmel_tc_free(tcbpwm->tc);
-
 	return 0;
 }
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 52/58] PWM: atmel-tcb: switch to new binding
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

The PWM is now a subnode of the used TCB. This is cleaner and it mainly
allows to stop wasting TCB channels when only 4 PWMs are used.

Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-pwm at vger.kernel.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/pwm/Kconfig         |   3 +-
 drivers/pwm/pwm-atmel-tcb.c | 221 ++++++++++++++++++++++++--------------------
 2 files changed, 122 insertions(+), 102 deletions(-)

diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index 313c10789ca2..d154f1fb610e 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -64,7 +64,8 @@ config PWM_ATMEL_HLCDC_PWM
 
 config PWM_ATMEL_TCB
 	tristate "Atmel TC Block PWM support"
-	depends on ATMEL_TCLIB && OF
+	depends on OF
+	select REGMAP_MMIO
 	help
 	  Generic PWM framework driver for Atmel Timer Counter Block.
 
diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c
index 75db585a2a94..9aa569835b97 100644
--- a/drivers/pwm/pwm-atmel-tcb.c
+++ b/drivers/pwm/pwm-atmel-tcb.c
@@ -16,19 +16,26 @@
 #include <linux/err.h>
 #include <linux/ioport.h>
 #include <linux/io.h>
+#include <linux/mfd/syscon.h>
 #include <linux/platform_device.h>
-#include <linux/atmel_tc.h>
 #include <linux/pwm.h>
 #include <linux/of_device.h>
+#include <linux/of_irq.h>
+#include <linux/regmap.h>
 #include <linux/slab.h>
+#include <soc/at91/atmel_tcb.h>
 
-#define NPWM	6
+#define NPWM	2
 
-#define ATMEL_TC_ACMR_MASK	(ATMEL_TC_ACPA | ATMEL_TC_ACPC |	\
-				 ATMEL_TC_AEEVT | ATMEL_TC_ASWTRG)
+#define ATMEL_TC_ACMR_MASK	(ATMEL_TC_CMR_ACPA_MSK | \
+				 ATMEL_TC_CMR_ACPC_MSK | \
+				 ATMEL_TC_CMR_AEEVT_MSK | \
+				 ATMEL_TC_CMR_ASWTRG_MSK)
 
-#define ATMEL_TC_BCMR_MASK	(ATMEL_TC_BCPB | ATMEL_TC_BCPC |	\
-				 ATMEL_TC_BEEVT | ATMEL_TC_BSWTRG)
+#define ATMEL_TC_BCMR_MASK	(ATMEL_TC_CMR_BCPB_MSK | \
+				 ATMEL_TC_CMR_BCPC_MSK | \
+				 ATMEL_TC_CMR_BEEVT_MSK | \
+				 ATMEL_TC_CMR_BSWTRG_MSK)
 
 struct atmel_tcb_pwm_device {
 	enum pwm_polarity polarity;	/* PWM polarity */
@@ -40,7 +47,11 @@ struct atmel_tcb_pwm_device {
 struct atmel_tcb_pwm_chip {
 	struct pwm_chip chip;
 	spinlock_t lock;
-	struct atmel_tc *tc;
+	u8 channel;
+	u8 width;
+	struct regmap *regmap;
+	struct clk *clk;
+	struct clk *slow_clk;
 	struct atmel_tcb_pwm_device *pwms[NPWM];
 };
 
@@ -65,10 +76,6 @@ static int atmel_tcb_pwm_request(struct pwm_chip *chip,
 {
 	struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip);
 	struct atmel_tcb_pwm_device *tcbpwm;
-	struct atmel_tc *tc = tcbpwmc->tc;
-	void __iomem *regs = tc->regs;
-	unsigned group = pwm->hwpwm / 2;
-	unsigned index = pwm->hwpwm % 2;
 	unsigned cmr;
 	int ret;
 
@@ -76,7 +83,7 @@ static int atmel_tcb_pwm_request(struct pwm_chip *chip,
 	if (!tcbpwm)
 		return -ENOMEM;
 
-	ret = clk_prepare_enable(tc->clk[group]);
+	ret = clk_prepare_enable(tcbpwmc->clk);
 	if (ret) {
 		devm_kfree(chip->dev, tcbpwm);
 		return ret;
@@ -89,28 +96,32 @@ static int atmel_tcb_pwm_request(struct pwm_chip *chip,
 	tcbpwm->div = 0;
 
 	spin_lock(&tcbpwmc->lock);
-	cmr = __raw_readl(regs + ATMEL_TC_REG(group, CMR));
+	regmap_read(tcbpwmc->regmap, ATMEL_TC_CMR(tcbpwmc->channel), &cmr);
 	/*
 	 * Get init config from Timer Counter registers if
 	 * Timer Counter is already configured as a PWM generator.
 	 */
-	if (cmr & ATMEL_TC_WAVE) {
-		if (index == 0)
-			tcbpwm->duty =
-				__raw_readl(regs + ATMEL_TC_REG(group, RA));
+	if (cmr & ATMEL_TC_CMR_WAVE) {
+		if (pwm->hwpwm == 0)
+			regmap_read(tcbpwmc->regmap,
+				    ATMEL_TC_RA(tcbpwmc->channel),
+				    &tcbpwm->duty);
 		else
-			tcbpwm->duty =
-				__raw_readl(regs + ATMEL_TC_REG(group, RB));
-
-		tcbpwm->div = cmr & ATMEL_TC_TCCLKS;
-		tcbpwm->period = __raw_readl(regs + ATMEL_TC_REG(group, RC));
-		cmr &= (ATMEL_TC_TCCLKS | ATMEL_TC_ACMR_MASK |
+			regmap_read(tcbpwmc->regmap,
+				    ATMEL_TC_RB(tcbpwmc->channel),
+				    &tcbpwm->duty);
+
+		tcbpwm->div = cmr & ATMEL_TC_CMR_TCLKS_MSK;
+		regmap_read(tcbpwmc->regmap, ATMEL_TC_RC(tcbpwmc->channel),
+			    &tcbpwm->period);
+		cmr &= (ATMEL_TC_CMR_TCLKS_MSK | ATMEL_TC_ACMR_MASK |
 			ATMEL_TC_BCMR_MASK);
 	} else
 		cmr = 0;
 
-	cmr |= ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO | ATMEL_TC_EEVT_XC0;
-	__raw_writel(cmr, regs + ATMEL_TC_REG(group, CMR));
+	cmr |= ATMEL_TC_CMR_WAVE | ATMEL_TC_CMR_WAVESEL_UPRC |
+	       ATMEL_TC_CMR_EEVT_XC(0);
+	regmap_write(tcbpwmc->regmap, ATMEL_TC_CMR(tcbpwmc->channel), cmr);
 	spin_unlock(&tcbpwmc->lock);
 
 	tcbpwmc->pwms[pwm->hwpwm] = tcbpwm;
@@ -122,9 +133,8 @@ static void atmel_tcb_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
 {
 	struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip);
 	struct atmel_tcb_pwm_device *tcbpwm = pwm_get_chip_data(pwm);
-	struct atmel_tc *tc = tcbpwmc->tc;
 
-	clk_disable_unprepare(tc->clk[pwm->hwpwm / 2]);
+	clk_disable_unprepare(tcbpwmc->clk);
 	tcbpwmc->pwms[pwm->hwpwm] = NULL;
 	devm_kfree(chip->dev, tcbpwm);
 }
@@ -133,10 +143,6 @@ static void atmel_tcb_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
 {
 	struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip);
 	struct atmel_tcb_pwm_device *tcbpwm = pwm_get_chip_data(pwm);
-	struct atmel_tc *tc = tcbpwmc->tc;
-	void __iomem *regs = tc->regs;
-	unsigned group = pwm->hwpwm / 2;
-	unsigned index = pwm->hwpwm % 2;
 	unsigned cmr;
 	enum pwm_polarity polarity = tcbpwm->polarity;
 
@@ -152,35 +158,35 @@ static void atmel_tcb_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
 		polarity = !polarity;
 
 	spin_lock(&tcbpwmc->lock);
-	cmr = __raw_readl(regs + ATMEL_TC_REG(group, CMR));
+	regmap_read(tcbpwmc->regmap, ATMEL_TC_CMR(tcbpwmc->channel), &cmr);
 
 	/* flush old setting and set the new one */
-	if (index == 0) {
+	if (pwm->hwpwm == 0) {
 		cmr &= ~ATMEL_TC_ACMR_MASK;
 		if (polarity == PWM_POLARITY_INVERSED)
-			cmr |= ATMEL_TC_ASWTRG_CLEAR;
+			cmr |= ATMEL_TC_CMR_ASWTRG(CLEAR);
 		else
-			cmr |= ATMEL_TC_ASWTRG_SET;
+			cmr |= ATMEL_TC_CMR_ASWTRG(SET);
 	} else {
 		cmr &= ~ATMEL_TC_BCMR_MASK;
 		if (polarity == PWM_POLARITY_INVERSED)
-			cmr |= ATMEL_TC_BSWTRG_CLEAR;
+			cmr |= ATMEL_TC_CMR_BSWTRG(CLEAR);
 		else
-			cmr |= ATMEL_TC_BSWTRG_SET;
+			cmr |= ATMEL_TC_CMR_BSWTRG(SET);
 	}
 
-	__raw_writel(cmr, regs + ATMEL_TC_REG(group, CMR));
+	regmap_write(tcbpwmc->regmap, ATMEL_TC_CMR(tcbpwmc->channel), cmr);
 
 	/*
 	 * Use software trigger to apply the new setting.
 	 * If both PWM devices in this group are disabled we stop the clock.
 	 */
-	if (!(cmr & (ATMEL_TC_ACPC | ATMEL_TC_BCPC)))
-		__raw_writel(ATMEL_TC_SWTRG | ATMEL_TC_CLKDIS,
-			     regs + ATMEL_TC_REG(group, CCR));
+	if (!(cmr & (ATMEL_TC_CMR_ACPC_MSK | ATMEL_TC_CMR_BCPC_MSK)))
+		regmap_write(tcbpwmc->regmap, ATMEL_TC_CCR(tcbpwmc->channel),
+			     ATMEL_TC_CCR_SWTRG | ATMEL_TC_CCR_CLKDIS);
 	else
-		__raw_writel(ATMEL_TC_SWTRG, regs +
-			     ATMEL_TC_REG(group, CCR));
+		regmap_write(tcbpwmc->regmap, ATMEL_TC_CCR(tcbpwmc->channel),
+			     ATMEL_TC_CCR_SWTRG);
 
 	spin_unlock(&tcbpwmc->lock);
 }
@@ -189,10 +195,6 @@ static int atmel_tcb_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 {
 	struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip);
 	struct atmel_tcb_pwm_device *tcbpwm = pwm_get_chip_data(pwm);
-	struct atmel_tc *tc = tcbpwmc->tc;
-	void __iomem *regs = tc->regs;
-	unsigned group = pwm->hwpwm / 2;
-	unsigned index = pwm->hwpwm % 2;
 	u32 cmr;
 	enum pwm_polarity polarity = tcbpwm->polarity;
 
@@ -208,25 +210,25 @@ static int atmel_tcb_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 		polarity = !polarity;
 
 	spin_lock(&tcbpwmc->lock);
-	cmr = __raw_readl(regs + ATMEL_TC_REG(group, CMR));
+	regmap_read(tcbpwmc->regmap, ATMEL_TC_CMR(tcbpwmc->channel), &cmr);
 
 	/* flush old setting and set the new one */
-	cmr &= ~ATMEL_TC_TCCLKS;
+	cmr &= ~ATMEL_TC_CMR_TCLKS_MSK;
 
-	if (index == 0) {
+	if (pwm->hwpwm == 0) {
 		cmr &= ~ATMEL_TC_ACMR_MASK;
 
 		/* Set CMR flags according to given polarity */
 		if (polarity == PWM_POLARITY_INVERSED)
-			cmr |= ATMEL_TC_ASWTRG_CLEAR;
+			cmr |= ATMEL_TC_CMR_ASWTRG(CLEAR);
 		else
-			cmr |= ATMEL_TC_ASWTRG_SET;
+			cmr |= ATMEL_TC_CMR_ASWTRG(SET);
 	} else {
 		cmr &= ~ATMEL_TC_BCMR_MASK;
 		if (polarity == PWM_POLARITY_INVERSED)
-			cmr |= ATMEL_TC_BSWTRG_CLEAR;
+			cmr |= ATMEL_TC_CMR_BSWTRG(CLEAR);
 		else
-			cmr |= ATMEL_TC_BSWTRG_SET;
+			cmr |= ATMEL_TC_CMR_BSWTRG(SET);
 	}
 
 	/*
@@ -236,33 +238,40 @@ static int atmel_tcb_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 	 * this config till next config call.
 	 */
 	if (tcbpwm->duty != tcbpwm->period && tcbpwm->duty > 0) {
-		if (index == 0) {
+		if (pwm->hwpwm == 0) {
 			if (polarity == PWM_POLARITY_INVERSED)
-				cmr |= ATMEL_TC_ACPA_SET | ATMEL_TC_ACPC_CLEAR;
+				cmr |= ATMEL_TC_CMR_ACPA(SET) |
+				       ATMEL_TC_CMR_ACPC(CLEAR);
 			else
-				cmr |= ATMEL_TC_ACPA_CLEAR | ATMEL_TC_ACPC_SET;
+				cmr |= ATMEL_TC_CMR_ACPA(CLEAR) |
+				       ATMEL_TC_CMR_ACPC(SET);
 		} else {
 			if (polarity == PWM_POLARITY_INVERSED)
-				cmr |= ATMEL_TC_BCPB_SET | ATMEL_TC_BCPC_CLEAR;
+				cmr |= ATMEL_TC_CMR_BCPB(SET) |
+				       ATMEL_TC_CMR_BCPC(CLEAR);
 			else
-				cmr |= ATMEL_TC_BCPB_CLEAR | ATMEL_TC_BCPC_SET;
+				cmr |= ATMEL_TC_CMR_BCPB(CLEAR) |
+				       ATMEL_TC_CMR_BCPC(SET);
 		}
 	}
 
-	cmr |= (tcbpwm->div & ATMEL_TC_TCCLKS);
+	cmr |= (tcbpwm->div & ATMEL_TC_CMR_TCLKS_MSK);
 
-	__raw_writel(cmr, regs + ATMEL_TC_REG(group, CMR));
+	regmap_write(tcbpwmc->regmap, ATMEL_TC_CMR(tcbpwmc->channel), cmr);
 
-	if (index == 0)
-		__raw_writel(tcbpwm->duty, regs + ATMEL_TC_REG(group, RA));
+	if (pwm->hwpwm == 0)
+		regmap_write(tcbpwmc->regmap, ATMEL_TC_RA(tcbpwmc->channel),
+			     tcbpwm->duty);
 	else
-		__raw_writel(tcbpwm->duty, regs + ATMEL_TC_REG(group, RB));
+		regmap_write(tcbpwmc->regmap, ATMEL_TC_RB(tcbpwmc->channel),
+			     tcbpwm->duty);
 
-	__raw_writel(tcbpwm->period, regs + ATMEL_TC_REG(group, RC));
+	regmap_write(tcbpwmc->regmap, ATMEL_TC_RC(tcbpwmc->channel),
+		     tcbpwm->period);
 
 	/* Use software trigger to apply the new setting */
-	__raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
-		     regs + ATMEL_TC_REG(group, CCR));
+	regmap_write(tcbpwmc->regmap, ATMEL_TC_CCR(tcbpwmc->channel),
+		     ATMEL_TC_CCR_SWTRG | ATMEL_TC_CCR_CLKEN);
 	spin_unlock(&tcbpwmc->lock);
 	return 0;
 }
@@ -272,15 +281,12 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 {
 	struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip);
 	struct atmel_tcb_pwm_device *tcbpwm = pwm_get_chip_data(pwm);
-	unsigned group = pwm->hwpwm / 2;
-	unsigned index = pwm->hwpwm % 2;
 	struct atmel_tcb_pwm_device *atcbpwm = NULL;
-	struct atmel_tc *tc = tcbpwmc->tc;
 	int i;
 	int slowclk = 0;
 	unsigned period;
 	unsigned duty;
-	unsigned rate = clk_get_rate(tc->clk[group]);
+	unsigned rate = clk_get_rate(tcbpwmc->clk);
 	unsigned long long min;
 	unsigned long long max;
 
@@ -294,7 +300,7 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 			continue;
 		}
 		min = div_u64((u64)NSEC_PER_SEC * atmel_tc_divisors[i], rate);
-		max = min << tc->tcb_config->counter_width;
+		max = min << tcbpwmc->width;
 		if (max >= period_ns)
 			break;
 	}
@@ -305,9 +311,9 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 	 */
 	if (i == 5) {
 		i = slowclk;
-		rate = clk_get_rate(tc->slow_clk);
+		rate = clk_get_rate(tcbpwmc->slow_clk);
 		min = div_u64(NSEC_PER_SEC, rate);
-		max = min << tc->tcb_config->counter_width;
+		max = min << tcbpwmc->width;
 
 		/* If period is too big return ERANGE error */
 		if (max < period_ns)
@@ -317,17 +323,13 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 	duty = div_u64(duty_ns, min);
 	period = div_u64(period_ns, min);
 
-	if (index == 0)
-		atcbpwm = tcbpwmc->pwms[pwm->hwpwm + 1];
+	if (pwm->hwpwm == 0)
+		atcbpwm = tcbpwmc->pwms[1];
 	else
-		atcbpwm = tcbpwmc->pwms[pwm->hwpwm - 1];
+		atcbpwm = tcbpwmc->pwms[0];
 
 	/*
-	 * PWM devices provided by TCB driver are grouped by 2:
-	 * - group 0: PWM 0 & 1
-	 * - group 1: PWM 2 & 3
-	 * - group 2: PWM 4 & 5
-	 *
+	 * PWM devices provided by the TCB driver are grouped by 2.
 	 * PWM devices in a given group must be configured with the
 	 * same period_ns.
 	 *
@@ -365,31 +367,41 @@ static const struct pwm_ops atmel_tcb_pwm_ops = {
 
 static int atmel_tcb_pwm_probe(struct platform_device *pdev)
 {
+	const struct of_device_id *match;
+	const struct atmel_tcb_info *tcb_info;
 	struct atmel_tcb_pwm_chip *tcbpwm;
 	struct device_node *np = pdev->dev.of_node;
-	struct atmel_tc *tc;
+	struct regmap *regmap;
+	struct clk *clk;
+	struct clk *slow_clk;
 	int err;
-	int tcblock;
+	int channel;
 
-	err = of_property_read_u32(np, "tc-block", &tcblock);
+	err = of_property_read_u32(np, "reg", &channel);
 	if (err < 0) {
 		dev_err(&pdev->dev,
-			"failed to get Timer Counter Block number from device tree (error: %d)\n",
+			"failed to get Timer Counter Block channel from device tree (error: %d)\n",
 			err);
 		return err;
 	}
 
-	tc = atmel_tc_alloc(tcblock);
-	if (tc == NULL) {
-		dev_err(&pdev->dev, "failed to allocate Timer Counter Block\n");
-		return -ENOMEM;
-	}
+	regmap = syscon_node_to_regmap(np->parent);
+	if (IS_ERR(regmap))
+		return PTR_ERR(regmap);
+
+	slow_clk = of_clk_get_by_name(np->parent, "slow_clk");
+	if (IS_ERR(slow_clk))
+		return PTR_ERR(slow_clk);
+
+	clk = tcb_clk_get(np, channel);
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
 
 	tcbpwm = devm_kzalloc(&pdev->dev, sizeof(*tcbpwm), GFP_KERNEL);
 	if (tcbpwm == NULL) {
 		err = -ENOMEM;
 		dev_err(&pdev->dev, "failed to allocate memory\n");
-		goto err_free_tc;
+		goto err_slow_clk;
 	}
 
 	tcbpwm->chip.dev = &pdev->dev;
@@ -398,11 +410,18 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev)
 	tcbpwm->chip.of_pwm_n_cells = 3;
 	tcbpwm->chip.base = -1;
 	tcbpwm->chip.npwm = NPWM;
-	tcbpwm->tc = tc;
+	tcbpwm->channel = channel;
+	tcbpwm->regmap = regmap;
+	tcbpwm->clk = clk;
+	tcbpwm->slow_clk = slow_clk;
 
-	err = clk_prepare_enable(tc->slow_clk);
+	match = of_match_node(atmel_tcb_dt_ids, np->parent);
+	tcb_info = match->data;
+	tcbpwm->width = tcb_info->bits;
+
+	err = clk_prepare_enable(slow_clk);
 	if (err)
-		goto err_free_tc;
+		goto err_slow_clk;
 
 	spin_lock_init(&tcbpwm->lock);
 
@@ -415,10 +434,10 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev)
 	return 0;
 
 err_disable_clk:
-	clk_disable_unprepare(tcbpwm->tc->slow_clk);
+	clk_disable_unprepare(tcbpwm->slow_clk);
 
-err_free_tc:
-	atmel_tc_free(tc);
+err_slow_clk:
+	clk_put(slow_clk);
 
 	return err;
 }
@@ -428,14 +447,14 @@ static int atmel_tcb_pwm_remove(struct platform_device *pdev)
 	struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev);
 	int err;
 
-	clk_disable_unprepare(tcbpwm->tc->slow_clk);
+	clk_disable_unprepare(tcbpwm->slow_clk);
+	clk_put(tcbpwm->slow_clk);
+	clk_put(tcbpwm->clk);
 
 	err = pwmchip_remove(&tcbpwm->chip);
 	if (err < 0)
 		return err;
 
-	atmel_tc_free(tcbpwm->tc);
-
 	return 0;
 }
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 53/58] ARM: dts: at91: kizbox: switch to new pwm-atmel-tcb binding
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel,
	Alexandre Belloni, Antoine Aubert

Switch to the new pwm-atmel-tcb binding that avoid wasting TCB channels.

Cc: Antoine Aubert <a.aubert@overkiz.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-kizbox.dts | 42 +++++++++++++++++++++++++--------------
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/arch/arm/boot/dts/at91-kizbox.dts b/arch/arm/boot/dts/at91-kizbox.dts
index c6bf08f8201e..c831f605a974 100644
--- a/arch/arm/boot/dts/at91-kizbox.dts
+++ b/arch/arm/boot/dts/at91-kizbox.dts
@@ -43,6 +43,29 @@
 				};
 			};
 
+			tcb1: timer@fffdc000 {
+				tcb1_pwm0: pwm@0 {
+					compatible = "atmel,tcb-pwm";
+					#pwm-cells = <3>;
+					pinctrl-names = "default";
+					pinctrl-0 = <&pinctrl_tcb1_tioa0 &pinctrl_tcb1_tiob0>;
+				};
+
+				tcb1_pwm1: pwm@1 {
+					compatible = "atmel,tcb-pwm";
+					#pwm-cells = <3>;
+					pinctrl-names = "default";
+					pinctrl-0 = <&pinctrl_tcb1_tioa1>;
+				};
+
+				tcb1_pwm2: pwm@2 {
+					compatible = "atmel,tcb-pwm";
+					#pwm-cells = <3>;
+					pinctrl-names = "default";
+					pinctrl-0 = <&pinctrl_tcb1_tioa2>;
+				};
+			};
+
 			macb0: ethernet@fffc4000 {
 				phy-mode = "mii";
 				pinctrl-0 = <&pinctrl_macb_rmii
@@ -122,41 +145,30 @@
 
 		network_green {
 			label = "pwm:green:network";
-			pwms = <&tcb_pwm 2 10000000 PWM_POLARITY_INVERTED>;
+			pwms = <&tcb1_pwm1 0 10000000 PWM_POLARITY_INVERTED>;
 			max-brightness = <255>;
 			linux,default-trigger = "default-on";
 		};
 
 		network_red {
 			label = "pwm:red:network";
-			pwms = <&tcb_pwm 4 10000000 PWM_POLARITY_INVERTED>;
+			pwms = <&tcb1_pwm2 0 10000000 PWM_POLARITY_INVERTED>;
 			max-brightness = <255>;
 			linux,default-trigger = "default-on";
 		};
 
 		user_green {
 			label = "pwm:green:user";
-			pwms = <&tcb_pwm 0 10000000 PWM_POLARITY_INVERTED>;
+			pwms = <&tcb1_pwm0 0 10000000 PWM_POLARITY_INVERTED>;
 			max-brightness = <255>;
 			linux,default-trigger = "default-on";
 		};
 
 		user_red {
 			label = "pwm:red:user";
-			pwms = <&tcb_pwm 1 10000000 PWM_POLARITY_INVERTED>;
+			pwms = <&tcb1_pwm0 1 10000000 PWM_POLARITY_INVERTED>;
 			max-brightness = <255>;
 			linux,default-trigger = "default-on";
 		};
 	};
-
-	tcb_pwm: pwm {
-		compatible = "atmel,tcb-pwm";
-		#pwm-cells = <3>;
-		tc-block = <1>;
-		pinctrl-names = "default";
-		pinctrl-0 = <&pinctrl_tcb1_tioa0
-			     &pinctrl_tcb1_tioa1
-			     &pinctrl_tcb1_tioa2
-			     &pinctrl_tcb1_tiob0>;
-	};
 };
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 53/58] ARM: dts: at91: kizbox: switch to new pwm-atmel-tcb binding
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

Switch to the new pwm-atmel-tcb binding that avoid wasting TCB channels.

Cc: Antoine Aubert <a.aubert@overkiz.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/boot/dts/at91-kizbox.dts | 42 +++++++++++++++++++++++++--------------
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/arch/arm/boot/dts/at91-kizbox.dts b/arch/arm/boot/dts/at91-kizbox.dts
index c6bf08f8201e..c831f605a974 100644
--- a/arch/arm/boot/dts/at91-kizbox.dts
+++ b/arch/arm/boot/dts/at91-kizbox.dts
@@ -43,6 +43,29 @@
 				};
 			};
 
+			tcb1: timer at fffdc000 {
+				tcb1_pwm0: pwm at 0 {
+					compatible = "atmel,tcb-pwm";
+					#pwm-cells = <3>;
+					pinctrl-names = "default";
+					pinctrl-0 = <&pinctrl_tcb1_tioa0 &pinctrl_tcb1_tiob0>;
+				};
+
+				tcb1_pwm1: pwm at 1 {
+					compatible = "atmel,tcb-pwm";
+					#pwm-cells = <3>;
+					pinctrl-names = "default";
+					pinctrl-0 = <&pinctrl_tcb1_tioa1>;
+				};
+
+				tcb1_pwm2: pwm at 2 {
+					compatible = "atmel,tcb-pwm";
+					#pwm-cells = <3>;
+					pinctrl-names = "default";
+					pinctrl-0 = <&pinctrl_tcb1_tioa2>;
+				};
+			};
+
 			macb0: ethernet at fffc4000 {
 				phy-mode = "mii";
 				pinctrl-0 = <&pinctrl_macb_rmii
@@ -122,41 +145,30 @@
 
 		network_green {
 			label = "pwm:green:network";
-			pwms = <&tcb_pwm 2 10000000 PWM_POLARITY_INVERTED>;
+			pwms = <&tcb1_pwm1 0 10000000 PWM_POLARITY_INVERTED>;
 			max-brightness = <255>;
 			linux,default-trigger = "default-on";
 		};
 
 		network_red {
 			label = "pwm:red:network";
-			pwms = <&tcb_pwm 4 10000000 PWM_POLARITY_INVERTED>;
+			pwms = <&tcb1_pwm2 0 10000000 PWM_POLARITY_INVERTED>;
 			max-brightness = <255>;
 			linux,default-trigger = "default-on";
 		};
 
 		user_green {
 			label = "pwm:green:user";
-			pwms = <&tcb_pwm 0 10000000 PWM_POLARITY_INVERTED>;
+			pwms = <&tcb1_pwm0 0 10000000 PWM_POLARITY_INVERTED>;
 			max-brightness = <255>;
 			linux,default-trigger = "default-on";
 		};
 
 		user_red {
 			label = "pwm:red:user";
-			pwms = <&tcb_pwm 1 10000000 PWM_POLARITY_INVERTED>;
+			pwms = <&tcb1_pwm0 1 10000000 PWM_POLARITY_INVERTED>;
 			max-brightness = <255>;
 			linux,default-trigger = "default-on";
 		};
 	};
-
-	tcb_pwm: pwm {
-		compatible = "atmel,tcb-pwm";
-		#pwm-cells = <3>;
-		tc-block = <1>;
-		pinctrl-names = "default";
-		pinctrl-0 = <&pinctrl_tcb1_tioa0
-			     &pinctrl_tcb1_tioa1
-			     &pinctrl_tcb1_tioa2
-			     &pinctrl_tcb1_tiob0>;
-	};
 };
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 54/58] clocksource/drivers: remove tcb_clksrc
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

AVR32 is now the last user of tcb_clksrc. It was removed in 4.12, remove
the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/clocksource/Makefile     |   1 -
 drivers/clocksource/tcb_clksrc.c | 381 ---------------------------------------
 2 files changed, 382 deletions(-)
 delete mode 100644 drivers/clocksource/tcb_clksrc.c

diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 53a0b40e0db2..68efe1fdeab3 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -2,7 +2,6 @@ obj-$(CONFIG_CLKSRC_PROBE)	+= clksrc-probe.o
 obj-$(CONFIG_CLKEVT_PROBE)	+= clkevt-probe.o
 obj-$(CONFIG_ATMEL_PIT)		+= timer-atmel-pit.o
 obj-$(CONFIG_ATMEL_ST)		+= timer-atmel-st.o
-obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o
 obj-$(CONFIG_ATMEL_ARM_TCB_CLKSRC)	+= timer-atmel-tcbclksrc.o
 obj-$(CONFIG_X86_PM_TIMER)	+= acpi_pm.o
 obj-$(CONFIG_SCx200HR_TIMER)	+= scx200_hrt.o
diff --git a/drivers/clocksource/tcb_clksrc.c b/drivers/clocksource/tcb_clksrc.c
deleted file mode 100644
index d4ca9962a759..000000000000
--- a/drivers/clocksource/tcb_clksrc.c
+++ /dev/null
@@ -1,381 +0,0 @@
-#include <linux/init.h>
-#include <linux/clocksource.h>
-#include <linux/clockchips.h>
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-
-#include <linux/clk.h>
-#include <linux/err.h>
-#include <linux/ioport.h>
-#include <linux/io.h>
-#include <linux/platform_device.h>
-#include <linux/atmel_tc.h>
-
-
-/*
- * We're configured to use a specific TC block, one that's not hooked
- * up to external hardware, to provide a time solution:
- *
- *   - Two channels combine to create a free-running 32 bit counter
- *     with a base rate of 5+ MHz, packaged as a clocksource (with
- *     resolution better than 200 nsec).
- *   - Some chips support 32 bit counter. A single channel is used for
- *     this 32 bit free-running counter. the second channel is not used.
- *
- *   - The third channel may be used to provide a 16-bit clockevent
- *     source, used in either periodic or oneshot mode.  This runs
- *     at 32 KiHZ, and can handle delays of up to two seconds.
- *
- * A boot clocksource and clockevent source are also currently needed,
- * unless the relevant platforms (ARM/AT91, AVR32/AT32) are changed so
- * this code can be used when init_timers() is called, well before most
- * devices are set up.  (Some low end AT91 parts, which can run uClinux,
- * have only the timers in one TC block... they currently don't support
- * the tclib code, because of that initialization issue.)
- *
- * REVISIT behavior during system suspend states... we should disable
- * all clocks and save the power.  Easily done for clockevent devices,
- * but clocksources won't necessarily get the needed notifications.
- * For deeper system sleep states, this will be mandatory...
- */
-
-static void __iomem *tcaddr;
-
-static u64 tc_get_cycles(struct clocksource *cs)
-{
-	unsigned long	flags;
-	u32		lower, upper;
-
-	raw_local_irq_save(flags);
-	do {
-		upper = __raw_readl(tcaddr + ATMEL_TC_REG(1, CV));
-		lower = __raw_readl(tcaddr + ATMEL_TC_REG(0, CV));
-	} while (upper != __raw_readl(tcaddr + ATMEL_TC_REG(1, CV)));
-
-	raw_local_irq_restore(flags);
-	return (upper << 16) | lower;
-}
-
-static u64 tc_get_cycles32(struct clocksource *cs)
-{
-	return __raw_readl(tcaddr + ATMEL_TC_REG(0, CV));
-}
-
-static struct clocksource clksrc = {
-	.name           = "tcb_clksrc",
-	.rating         = 200,
-	.read           = tc_get_cycles,
-	.mask           = CLOCKSOURCE_MASK(32),
-	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
-};
-
-#ifdef CONFIG_GENERIC_CLOCKEVENTS
-
-struct tc_clkevt_device {
-	struct clock_event_device	clkevt;
-	struct clk			*clk;
-	void __iomem			*regs;
-};
-
-static struct tc_clkevt_device *to_tc_clkevt(struct clock_event_device *clkevt)
-{
-	return container_of(clkevt, struct tc_clkevt_device, clkevt);
-}
-
-/* For now, we always use the 32K clock ... this optimizes for NO_HZ,
- * because using one of the divided clocks would usually mean the
- * tick rate can never be less than several dozen Hz (vs 0.5 Hz).
- *
- * A divided clock could be good for high resolution timers, since
- * 30.5 usec resolution can seem "low".
- */
-static u32 timer_clock;
-
-static int tc_shutdown(struct clock_event_device *d)
-{
-	struct tc_clkevt_device *tcd = to_tc_clkevt(d);
-	void __iomem		*regs = tcd->regs;
-
-	__raw_writel(0xff, regs + ATMEL_TC_REG(2, IDR));
-	__raw_writel(ATMEL_TC_CLKDIS, regs + ATMEL_TC_REG(2, CCR));
-	if (!clockevent_state_detached(d))
-		clk_disable(tcd->clk);
-
-	return 0;
-}
-
-static int tc_set_oneshot(struct clock_event_device *d)
-{
-	struct tc_clkevt_device *tcd = to_tc_clkevt(d);
-	void __iomem		*regs = tcd->regs;
-
-	if (clockevent_state_oneshot(d) || clockevent_state_periodic(d))
-		tc_shutdown(d);
-
-	clk_enable(tcd->clk);
-
-	/* slow clock, count up to RC, then irq and stop */
-	__raw_writel(timer_clock | ATMEL_TC_CPCSTOP | ATMEL_TC_WAVE |
-		     ATMEL_TC_WAVESEL_UP_AUTO, regs + ATMEL_TC_REG(2, CMR));
-	__raw_writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER));
-
-	/* set_next_event() configures and starts the timer */
-	return 0;
-}
-
-static int tc_set_periodic(struct clock_event_device *d)
-{
-	struct tc_clkevt_device *tcd = to_tc_clkevt(d);
-	void __iomem		*regs = tcd->regs;
-
-	if (clockevent_state_oneshot(d) || clockevent_state_periodic(d))
-		tc_shutdown(d);
-
-	/* By not making the gentime core emulate periodic mode on top
-	 * of oneshot, we get lower overhead and improved accuracy.
-	 */
-	clk_enable(tcd->clk);
-
-	/* slow clock, count up to RC, then irq and restart */
-	__raw_writel(timer_clock | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO,
-		     regs + ATMEL_TC_REG(2, CMR));
-	__raw_writel((32768 + HZ / 2) / HZ, tcaddr + ATMEL_TC_REG(2, RC));
-
-	/* Enable clock and interrupts on RC compare */
-	__raw_writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER));
-
-	/* go go gadget! */
-	__raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG, regs +
-		     ATMEL_TC_REG(2, CCR));
-	return 0;
-}
-
-static int tc_next_event(unsigned long delta, struct clock_event_device *d)
-{
-	__raw_writel(delta, tcaddr + ATMEL_TC_REG(2, RC));
-
-	/* go go gadget! */
-	__raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
-			tcaddr + ATMEL_TC_REG(2, CCR));
-	return 0;
-}
-
-static struct tc_clkevt_device clkevt = {
-	.clkevt	= {
-		.name			= "tc_clkevt",
-		.features		= CLOCK_EVT_FEAT_PERIODIC |
-					  CLOCK_EVT_FEAT_ONESHOT,
-		/* Should be lower than at91rm9200's system timer */
-		.rating			= 125,
-		.set_next_event		= tc_next_event,
-		.set_state_shutdown	= tc_shutdown,
-		.set_state_periodic	= tc_set_periodic,
-		.set_state_oneshot	= tc_set_oneshot,
-	},
-};
-
-static irqreturn_t ch2_irq(int irq, void *handle)
-{
-	struct tc_clkevt_device	*dev = handle;
-	unsigned int		sr;
-
-	sr = __raw_readl(dev->regs + ATMEL_TC_REG(2, SR));
-	if (sr & ATMEL_TC_CPCS) {
-		dev->clkevt.event_handler(&dev->clkevt);
-		return IRQ_HANDLED;
-	}
-
-	return IRQ_NONE;
-}
-
-static int __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)
-{
-	int ret;
-	struct clk *t2_clk = tc->clk[2];
-	int irq = tc->irq[2];
-
-	ret = clk_prepare_enable(tc->slow_clk);
-	if (ret)
-		return ret;
-
-	/* try to enable t2 clk to avoid future errors in mode change */
-	ret = clk_prepare_enable(t2_clk);
-	if (ret) {
-		clk_disable_unprepare(tc->slow_clk);
-		return ret;
-	}
-
-	clk_disable(t2_clk);
-
-	clkevt.regs = tc->regs;
-	clkevt.clk = t2_clk;
-
-	timer_clock = clk32k_divisor_idx;
-
-	clkevt.clkevt.cpumask = cpumask_of(0);
-
-	ret = request_irq(irq, ch2_irq, IRQF_TIMER, "tc_clkevt", &clkevt);
-	if (ret) {
-		clk_unprepare(t2_clk);
-		clk_disable_unprepare(tc->slow_clk);
-		return ret;
-	}
-
-	clockevents_config_and_register(&clkevt.clkevt, 32768, 1, 0xffff);
-
-	return ret;
-}
-
-#else /* !CONFIG_GENERIC_CLOCKEVENTS */
-
-static int __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)
-{
-	/* NOTHING */
-	return 0;
-}
-
-#endif
-
-static void __init tcb_setup_dual_chan(struct atmel_tc *tc, int mck_divisor_idx)
-{
-	/* channel 0:  waveform mode, input mclk/8, clock TIOA0 on overflow */
-	__raw_writel(mck_divisor_idx			/* likely divide-by-8 */
-			| ATMEL_TC_WAVE
-			| ATMEL_TC_WAVESEL_UP		/* free-run */
-			| ATMEL_TC_ACPA_SET		/* TIOA0 rises at 0 */
-			| ATMEL_TC_ACPC_CLEAR,		/* (duty cycle 50%) */
-			tcaddr + ATMEL_TC_REG(0, CMR));
-	__raw_writel(0x0000, tcaddr + ATMEL_TC_REG(0, RA));
-	__raw_writel(0x8000, tcaddr + ATMEL_TC_REG(0, RC));
-	__raw_writel(0xff, tcaddr + ATMEL_TC_REG(0, IDR));	/* no irqs */
-	__raw_writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(0, CCR));
-
-	/* channel 1:  waveform mode, input TIOA0 */
-	__raw_writel(ATMEL_TC_XC1			/* input: TIOA0 */
-			| ATMEL_TC_WAVE
-			| ATMEL_TC_WAVESEL_UP,		/* free-run */
-			tcaddr + ATMEL_TC_REG(1, CMR));
-	__raw_writel(0xff, tcaddr + ATMEL_TC_REG(1, IDR));	/* no irqs */
-	__raw_writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(1, CCR));
-
-	/* chain channel 0 to channel 1*/
-	__raw_writel(ATMEL_TC_TC1XC1S_TIOA0, tcaddr + ATMEL_TC_BMR);
-	/* then reset all the timers */
-	__raw_writel(ATMEL_TC_SYNC, tcaddr + ATMEL_TC_BCR);
-}
-
-static void __init tcb_setup_single_chan(struct atmel_tc *tc, int mck_divisor_idx)
-{
-	/* channel 0:  waveform mode, input mclk/8 */
-	__raw_writel(mck_divisor_idx			/* likely divide-by-8 */
-			| ATMEL_TC_WAVE
-			| ATMEL_TC_WAVESEL_UP,		/* free-run */
-			tcaddr + ATMEL_TC_REG(0, CMR));
-	__raw_writel(0xff, tcaddr + ATMEL_TC_REG(0, IDR));	/* no irqs */
-	__raw_writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(0, CCR));
-
-	/* then reset all the timers */
-	__raw_writel(ATMEL_TC_SYNC, tcaddr + ATMEL_TC_BCR);
-}
-
-static int __init tcb_clksrc_init(void)
-{
-	static char bootinfo[] __initdata
-		= KERN_DEBUG "%s: tc%d at %d.%03d MHz\n";
-
-	struct platform_device *pdev;
-	struct atmel_tc *tc;
-	struct clk *t0_clk;
-	u32 rate, divided_rate = 0;
-	int best_divisor_idx = -1;
-	int clk32k_divisor_idx = -1;
-	int i;
-	int ret;
-
-	tc = atmel_tc_alloc(CONFIG_ATMEL_TCB_CLKSRC_BLOCK);
-	if (!tc) {
-		pr_debug("can't alloc TC for clocksource\n");
-		return -ENODEV;
-	}
-	tcaddr = tc->regs;
-	pdev = tc->pdev;
-
-	t0_clk = tc->clk[0];
-	ret = clk_prepare_enable(t0_clk);
-	if (ret) {
-		pr_debug("can't enable T0 clk\n");
-		goto err_free_tc;
-	}
-
-	/* How fast will we be counting?  Pick something over 5 MHz.  */
-	rate = (u32) clk_get_rate(t0_clk);
-	for (i = 0; i < 5; i++) {
-		unsigned divisor = atmel_tc_divisors[i];
-		unsigned tmp;
-
-		/* remember 32 KiHz clock for later */
-		if (!divisor) {
-			clk32k_divisor_idx = i;
-			continue;
-		}
-
-		tmp = rate / divisor;
-		pr_debug("TC: %u / %-3u [%d] --> %u\n", rate, divisor, i, tmp);
-		if (best_divisor_idx > 0) {
-			if (tmp < 5 * 1000 * 1000)
-				continue;
-		}
-		divided_rate = tmp;
-		best_divisor_idx = i;
-	}
-
-
-	printk(bootinfo, clksrc.name, CONFIG_ATMEL_TCB_CLKSRC_BLOCK,
-			divided_rate / 1000000,
-			((divided_rate + 500000) % 1000000) / 1000);
-
-	if (tc->tcb_config && tc->tcb_config->counter_width == 32) {
-		/* use apropriate function to read 32 bit counter */
-		clksrc.read = tc_get_cycles32;
-		/* setup ony channel 0 */
-		tcb_setup_single_chan(tc, best_divisor_idx);
-	} else {
-		/* tclib will give us three clocks no matter what the
-		 * underlying platform supports.
-		 */
-		ret = clk_prepare_enable(tc->clk[1]);
-		if (ret) {
-			pr_debug("can't enable T1 clk\n");
-			goto err_disable_t0;
-		}
-		/* setup both channel 0 & 1 */
-		tcb_setup_dual_chan(tc, best_divisor_idx);
-	}
-
-	/* and away we go! */
-	ret = clocksource_register_hz(&clksrc, divided_rate);
-	if (ret)
-		goto err_disable_t1;
-
-	/* channel 2:  periodic and oneshot timer support */
-	ret = setup_clkevents(tc, clk32k_divisor_idx);
-	if (ret)
-		goto err_unregister_clksrc;
-
-	return 0;
-
-err_unregister_clksrc:
-	clocksource_unregister(&clksrc);
-
-err_disable_t1:
-	if (!tc->tcb_config || tc->tcb_config->counter_width != 32)
-		clk_disable_unprepare(tc->clk[1]);
-
-err_disable_t0:
-	clk_disable_unprepare(t0_clk);
-
-err_free_tc:
-	atmel_tc_free(tc);
-	return ret;
-}
-arch_initcall(tcb_clksrc_init);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 54/58] clocksource/drivers: remove tcb_clksrc
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

AVR32 is now the last user of tcb_clksrc. It was removed in 4.12, remove
the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/clocksource/Makefile     |   1 -
 drivers/clocksource/tcb_clksrc.c | 381 ---------------------------------------
 2 files changed, 382 deletions(-)
 delete mode 100644 drivers/clocksource/tcb_clksrc.c

diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 53a0b40e0db2..68efe1fdeab3 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -2,7 +2,6 @@ obj-$(CONFIG_CLKSRC_PROBE)	+= clksrc-probe.o
 obj-$(CONFIG_CLKEVT_PROBE)	+= clkevt-probe.o
 obj-$(CONFIG_ATMEL_PIT)		+= timer-atmel-pit.o
 obj-$(CONFIG_ATMEL_ST)		+= timer-atmel-st.o
-obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o
 obj-$(CONFIG_ATMEL_ARM_TCB_CLKSRC)	+= timer-atmel-tcbclksrc.o
 obj-$(CONFIG_X86_PM_TIMER)	+= acpi_pm.o
 obj-$(CONFIG_SCx200HR_TIMER)	+= scx200_hrt.o
diff --git a/drivers/clocksource/tcb_clksrc.c b/drivers/clocksource/tcb_clksrc.c
deleted file mode 100644
index d4ca9962a759..000000000000
--- a/drivers/clocksource/tcb_clksrc.c
+++ /dev/null
@@ -1,381 +0,0 @@
-#include <linux/init.h>
-#include <linux/clocksource.h>
-#include <linux/clockchips.h>
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-
-#include <linux/clk.h>
-#include <linux/err.h>
-#include <linux/ioport.h>
-#include <linux/io.h>
-#include <linux/platform_device.h>
-#include <linux/atmel_tc.h>
-
-
-/*
- * We're configured to use a specific TC block, one that's not hooked
- * up to external hardware, to provide a time solution:
- *
- *   - Two channels combine to create a free-running 32 bit counter
- *     with a base rate of 5+ MHz, packaged as a clocksource (with
- *     resolution better than 200 nsec).
- *   - Some chips support 32 bit counter. A single channel is used for
- *     this 32 bit free-running counter. the second channel is not used.
- *
- *   - The third channel may be used to provide a 16-bit clockevent
- *     source, used in either periodic or oneshot mode.  This runs
- *     at 32 KiHZ, and can handle delays of up to two seconds.
- *
- * A boot clocksource and clockevent source are also currently needed,
- * unless the relevant platforms (ARM/AT91, AVR32/AT32) are changed so
- * this code can be used when init_timers() is called, well before most
- * devices are set up.  (Some low end AT91 parts, which can run uClinux,
- * have only the timers in one TC block... they currently don't support
- * the tclib code, because of that initialization issue.)
- *
- * REVISIT behavior during system suspend states... we should disable
- * all clocks and save the power.  Easily done for clockevent devices,
- * but clocksources won't necessarily get the needed notifications.
- * For deeper system sleep states, this will be mandatory...
- */
-
-static void __iomem *tcaddr;
-
-static u64 tc_get_cycles(struct clocksource *cs)
-{
-	unsigned long	flags;
-	u32		lower, upper;
-
-	raw_local_irq_save(flags);
-	do {
-		upper = __raw_readl(tcaddr + ATMEL_TC_REG(1, CV));
-		lower = __raw_readl(tcaddr + ATMEL_TC_REG(0, CV));
-	} while (upper != __raw_readl(tcaddr + ATMEL_TC_REG(1, CV)));
-
-	raw_local_irq_restore(flags);
-	return (upper << 16) | lower;
-}
-
-static u64 tc_get_cycles32(struct clocksource *cs)
-{
-	return __raw_readl(tcaddr + ATMEL_TC_REG(0, CV));
-}
-
-static struct clocksource clksrc = {
-	.name           = "tcb_clksrc",
-	.rating         = 200,
-	.read           = tc_get_cycles,
-	.mask           = CLOCKSOURCE_MASK(32),
-	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
-};
-
-#ifdef CONFIG_GENERIC_CLOCKEVENTS
-
-struct tc_clkevt_device {
-	struct clock_event_device	clkevt;
-	struct clk			*clk;
-	void __iomem			*regs;
-};
-
-static struct tc_clkevt_device *to_tc_clkevt(struct clock_event_device *clkevt)
-{
-	return container_of(clkevt, struct tc_clkevt_device, clkevt);
-}
-
-/* For now, we always use the 32K clock ... this optimizes for NO_HZ,
- * because using one of the divided clocks would usually mean the
- * tick rate can never be less than several dozen Hz (vs 0.5 Hz).
- *
- * A divided clock could be good for high resolution timers, since
- * 30.5 usec resolution can seem "low".
- */
-static u32 timer_clock;
-
-static int tc_shutdown(struct clock_event_device *d)
-{
-	struct tc_clkevt_device *tcd = to_tc_clkevt(d);
-	void __iomem		*regs = tcd->regs;
-
-	__raw_writel(0xff, regs + ATMEL_TC_REG(2, IDR));
-	__raw_writel(ATMEL_TC_CLKDIS, regs + ATMEL_TC_REG(2, CCR));
-	if (!clockevent_state_detached(d))
-		clk_disable(tcd->clk);
-
-	return 0;
-}
-
-static int tc_set_oneshot(struct clock_event_device *d)
-{
-	struct tc_clkevt_device *tcd = to_tc_clkevt(d);
-	void __iomem		*regs = tcd->regs;
-
-	if (clockevent_state_oneshot(d) || clockevent_state_periodic(d))
-		tc_shutdown(d);
-
-	clk_enable(tcd->clk);
-
-	/* slow clock, count up to RC, then irq and stop */
-	__raw_writel(timer_clock | ATMEL_TC_CPCSTOP | ATMEL_TC_WAVE |
-		     ATMEL_TC_WAVESEL_UP_AUTO, regs + ATMEL_TC_REG(2, CMR));
-	__raw_writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER));
-
-	/* set_next_event() configures and starts the timer */
-	return 0;
-}
-
-static int tc_set_periodic(struct clock_event_device *d)
-{
-	struct tc_clkevt_device *tcd = to_tc_clkevt(d);
-	void __iomem		*regs = tcd->regs;
-
-	if (clockevent_state_oneshot(d) || clockevent_state_periodic(d))
-		tc_shutdown(d);
-
-	/* By not making the gentime core emulate periodic mode on top
-	 * of oneshot, we get lower overhead and improved accuracy.
-	 */
-	clk_enable(tcd->clk);
-
-	/* slow clock, count up to RC, then irq and restart */
-	__raw_writel(timer_clock | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO,
-		     regs + ATMEL_TC_REG(2, CMR));
-	__raw_writel((32768 + HZ / 2) / HZ, tcaddr + ATMEL_TC_REG(2, RC));
-
-	/* Enable clock and interrupts on RC compare */
-	__raw_writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER));
-
-	/* go go gadget! */
-	__raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG, regs +
-		     ATMEL_TC_REG(2, CCR));
-	return 0;
-}
-
-static int tc_next_event(unsigned long delta, struct clock_event_device *d)
-{
-	__raw_writel(delta, tcaddr + ATMEL_TC_REG(2, RC));
-
-	/* go go gadget! */
-	__raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
-			tcaddr + ATMEL_TC_REG(2, CCR));
-	return 0;
-}
-
-static struct tc_clkevt_device clkevt = {
-	.clkevt	= {
-		.name			= "tc_clkevt",
-		.features		= CLOCK_EVT_FEAT_PERIODIC |
-					  CLOCK_EVT_FEAT_ONESHOT,
-		/* Should be lower than at91rm9200's system timer */
-		.rating			= 125,
-		.set_next_event		= tc_next_event,
-		.set_state_shutdown	= tc_shutdown,
-		.set_state_periodic	= tc_set_periodic,
-		.set_state_oneshot	= tc_set_oneshot,
-	},
-};
-
-static irqreturn_t ch2_irq(int irq, void *handle)
-{
-	struct tc_clkevt_device	*dev = handle;
-	unsigned int		sr;
-
-	sr = __raw_readl(dev->regs + ATMEL_TC_REG(2, SR));
-	if (sr & ATMEL_TC_CPCS) {
-		dev->clkevt.event_handler(&dev->clkevt);
-		return IRQ_HANDLED;
-	}
-
-	return IRQ_NONE;
-}
-
-static int __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)
-{
-	int ret;
-	struct clk *t2_clk = tc->clk[2];
-	int irq = tc->irq[2];
-
-	ret = clk_prepare_enable(tc->slow_clk);
-	if (ret)
-		return ret;
-
-	/* try to enable t2 clk to avoid future errors in mode change */
-	ret = clk_prepare_enable(t2_clk);
-	if (ret) {
-		clk_disable_unprepare(tc->slow_clk);
-		return ret;
-	}
-
-	clk_disable(t2_clk);
-
-	clkevt.regs = tc->regs;
-	clkevt.clk = t2_clk;
-
-	timer_clock = clk32k_divisor_idx;
-
-	clkevt.clkevt.cpumask = cpumask_of(0);
-
-	ret = request_irq(irq, ch2_irq, IRQF_TIMER, "tc_clkevt", &clkevt);
-	if (ret) {
-		clk_unprepare(t2_clk);
-		clk_disable_unprepare(tc->slow_clk);
-		return ret;
-	}
-
-	clockevents_config_and_register(&clkevt.clkevt, 32768, 1, 0xffff);
-
-	return ret;
-}
-
-#else /* !CONFIG_GENERIC_CLOCKEVENTS */
-
-static int __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)
-{
-	/* NOTHING */
-	return 0;
-}
-
-#endif
-
-static void __init tcb_setup_dual_chan(struct atmel_tc *tc, int mck_divisor_idx)
-{
-	/* channel 0:  waveform mode, input mclk/8, clock TIOA0 on overflow */
-	__raw_writel(mck_divisor_idx			/* likely divide-by-8 */
-			| ATMEL_TC_WAVE
-			| ATMEL_TC_WAVESEL_UP		/* free-run */
-			| ATMEL_TC_ACPA_SET		/* TIOA0 rises at 0 */
-			| ATMEL_TC_ACPC_CLEAR,		/* (duty cycle 50%) */
-			tcaddr + ATMEL_TC_REG(0, CMR));
-	__raw_writel(0x0000, tcaddr + ATMEL_TC_REG(0, RA));
-	__raw_writel(0x8000, tcaddr + ATMEL_TC_REG(0, RC));
-	__raw_writel(0xff, tcaddr + ATMEL_TC_REG(0, IDR));	/* no irqs */
-	__raw_writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(0, CCR));
-
-	/* channel 1:  waveform mode, input TIOA0 */
-	__raw_writel(ATMEL_TC_XC1			/* input: TIOA0 */
-			| ATMEL_TC_WAVE
-			| ATMEL_TC_WAVESEL_UP,		/* free-run */
-			tcaddr + ATMEL_TC_REG(1, CMR));
-	__raw_writel(0xff, tcaddr + ATMEL_TC_REG(1, IDR));	/* no irqs */
-	__raw_writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(1, CCR));
-
-	/* chain channel 0 to channel 1*/
-	__raw_writel(ATMEL_TC_TC1XC1S_TIOA0, tcaddr + ATMEL_TC_BMR);
-	/* then reset all the timers */
-	__raw_writel(ATMEL_TC_SYNC, tcaddr + ATMEL_TC_BCR);
-}
-
-static void __init tcb_setup_single_chan(struct atmel_tc *tc, int mck_divisor_idx)
-{
-	/* channel 0:  waveform mode, input mclk/8 */
-	__raw_writel(mck_divisor_idx			/* likely divide-by-8 */
-			| ATMEL_TC_WAVE
-			| ATMEL_TC_WAVESEL_UP,		/* free-run */
-			tcaddr + ATMEL_TC_REG(0, CMR));
-	__raw_writel(0xff, tcaddr + ATMEL_TC_REG(0, IDR));	/* no irqs */
-	__raw_writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(0, CCR));
-
-	/* then reset all the timers */
-	__raw_writel(ATMEL_TC_SYNC, tcaddr + ATMEL_TC_BCR);
-}
-
-static int __init tcb_clksrc_init(void)
-{
-	static char bootinfo[] __initdata
-		= KERN_DEBUG "%s: tc%d at %d.%03d MHz\n";
-
-	struct platform_device *pdev;
-	struct atmel_tc *tc;
-	struct clk *t0_clk;
-	u32 rate, divided_rate = 0;
-	int best_divisor_idx = -1;
-	int clk32k_divisor_idx = -1;
-	int i;
-	int ret;
-
-	tc = atmel_tc_alloc(CONFIG_ATMEL_TCB_CLKSRC_BLOCK);
-	if (!tc) {
-		pr_debug("can't alloc TC for clocksource\n");
-		return -ENODEV;
-	}
-	tcaddr = tc->regs;
-	pdev = tc->pdev;
-
-	t0_clk = tc->clk[0];
-	ret = clk_prepare_enable(t0_clk);
-	if (ret) {
-		pr_debug("can't enable T0 clk\n");
-		goto err_free_tc;
-	}
-
-	/* How fast will we be counting?  Pick something over 5 MHz.  */
-	rate = (u32) clk_get_rate(t0_clk);
-	for (i = 0; i < 5; i++) {
-		unsigned divisor = atmel_tc_divisors[i];
-		unsigned tmp;
-
-		/* remember 32 KiHz clock for later */
-		if (!divisor) {
-			clk32k_divisor_idx = i;
-			continue;
-		}
-
-		tmp = rate / divisor;
-		pr_debug("TC: %u / %-3u [%d] --> %u\n", rate, divisor, i, tmp);
-		if (best_divisor_idx > 0) {
-			if (tmp < 5 * 1000 * 1000)
-				continue;
-		}
-		divided_rate = tmp;
-		best_divisor_idx = i;
-	}
-
-
-	printk(bootinfo, clksrc.name, CONFIG_ATMEL_TCB_CLKSRC_BLOCK,
-			divided_rate / 1000000,
-			((divided_rate + 500000) % 1000000) / 1000);
-
-	if (tc->tcb_config && tc->tcb_config->counter_width == 32) {
-		/* use apropriate function to read 32 bit counter */
-		clksrc.read = tc_get_cycles32;
-		/* setup ony channel 0 */
-		tcb_setup_single_chan(tc, best_divisor_idx);
-	} else {
-		/* tclib will give us three clocks no matter what the
-		 * underlying platform supports.
-		 */
-		ret = clk_prepare_enable(tc->clk[1]);
-		if (ret) {
-			pr_debug("can't enable T1 clk\n");
-			goto err_disable_t0;
-		}
-		/* setup both channel 0 & 1 */
-		tcb_setup_dual_chan(tc, best_divisor_idx);
-	}
-
-	/* and away we go! */
-	ret = clocksource_register_hz(&clksrc, divided_rate);
-	if (ret)
-		goto err_disable_t1;
-
-	/* channel 2:  periodic and oneshot timer support */
-	ret = setup_clkevents(tc, clk32k_divisor_idx);
-	if (ret)
-		goto err_unregister_clksrc;
-
-	return 0;
-
-err_unregister_clksrc:
-	clocksource_unregister(&clksrc);
-
-err_disable_t1:
-	if (!tc->tcb_config || tc->tcb_config->counter_width != 32)
-		clk_disable_unprepare(tc->clk[1]);
-
-err_disable_t0:
-	clk_disable_unprepare(t0_clk);
-
-err_free_tc:
-	atmel_tc_free(tc);
-	return ret;
-}
-arch_initcall(tcb_clksrc_init);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 55/58] misc: remove atmel_tclib.c
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

The last user of atmel_tclib is gone, remove it too.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/misc/Kconfig       |  33 --------
 drivers/misc/Makefile      |   1 -
 drivers/misc/atmel_tclib.c | 198 ---------------------------------------------
 include/linux/atmel_tc.h   |   9 ---
 4 files changed, 241 deletions(-)
 delete mode 100644 drivers/misc/atmel_tclib.c

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 2cba76e6fa3c..5946ac3399ad 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -51,39 +51,6 @@ config AD525X_DPOT_SPI
 	  To compile this driver as a module, choose M here: the
 	  module will be called ad525x_dpot-spi.
 
-config ATMEL_TCLIB
-	bool "Atmel AT32/AT91 Timer/Counter Library"
-	depends on (AVR32 || ARCH_AT91)
-	help
-	  Select this if you want a library to allocate the Timer/Counter
-	  blocks found on many Atmel processors.  This facilitates using
-	  these blocks by different drivers despite processor differences.
-
-config ATMEL_TCB_CLKSRC
-	bool "TC Block Clocksource"
-	depends on ATMEL_TCLIB
-	default y
-	help
-	  Select this to get a high precision clocksource based on a
-	  TC block with a 5+ MHz base clock rate.  Two timer channels
-	  are combined to make a single 32-bit timer.
-
-	  When GENERIC_CLOCKEVENTS is defined, the third timer channel
-	  may be used as a clock event device supporting oneshot mode
-	  (delays of up to two seconds) based on the 32 KiHz clock.
-
-config ATMEL_TCB_CLKSRC_BLOCK
-	int
-	depends on ATMEL_TCB_CLKSRC
-	prompt "TC Block" if CPU_AT32AP700X
-	default 0
-	range 0 1
-	help
-	  Some chips provide more than one TC block, so you have the
-	  choice of which one to use for the clock framework.  The other
-	  TC can be used for other purposes, such as PWM generation and
-	  interval timing.
-
 config DUMMY_IRQ
 	tristate "Dummy IRQ handler"
 	default n
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 81ef3e67acc9..00adf5088699 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -8,7 +8,6 @@ obj-$(CONFIG_AD525X_DPOT_I2C)	+= ad525x_dpot-i2c.o
 obj-$(CONFIG_AD525X_DPOT_SPI)	+= ad525x_dpot-spi.o
 obj-$(CONFIG_INTEL_MID_PTI)	+= pti.o
 obj-$(CONFIG_ATMEL_SSC)		+= atmel-ssc.o
-obj-$(CONFIG_ATMEL_TCLIB)	+= atmel_tclib.o
 obj-$(CONFIG_DUMMY_IRQ)		+= dummy-irq.o
 obj-$(CONFIG_ICS932S401)	+= ics932s401.o
 obj-$(CONFIG_LKDTM)		+= lkdtm.o
diff --git a/drivers/misc/atmel_tclib.c b/drivers/misc/atmel_tclib.c
deleted file mode 100644
index ac24a4bd63f7..000000000000
--- a/drivers/misc/atmel_tclib.c
+++ /dev/null
@@ -1,198 +0,0 @@
-#include <linux/atmel_tc.h>
-#include <linux/clk.h>
-#include <linux/err.h>
-#include <linux/init.h>
-#include <linux/io.h>
-#include <linux/ioport.h>
-#include <linux/kernel.h>
-#include <linux/platform_device.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/export.h>
-#include <linux/of.h>
-
-/*
- * This is a thin library to solve the problem of how to portably allocate
- * one of the TC blocks.  For simplicity, it doesn't currently expect to
- * share individual timers between different drivers.
- */
-
-#if defined(CONFIG_AVR32)
-/* AVR32 has these divide PBB */
-const u8 atmel_tc_divisors[5] = { 0, 4, 8, 16, 32, };
-EXPORT_SYMBOL(atmel_tc_divisors);
-
-#elif defined(CONFIG_ARCH_AT91)
-/* AT91 has these divide MCK */
-const u8 atmel_tc_divisors[5] = { 2, 8, 32, 128, 0, };
-EXPORT_SYMBOL(atmel_tc_divisors);
-
-#endif
-
-static DEFINE_SPINLOCK(tc_list_lock);
-static LIST_HEAD(tc_list);
-
-/**
- * atmel_tc_alloc - allocate a specified TC block
- * @block: which block to allocate
- *
- * Caller allocates a block.  If it is available, a pointer to a
- * pre-initialized struct atmel_tc is returned. The caller can access
- * the registers directly through the "regs" field.
- */
-struct atmel_tc *atmel_tc_alloc(unsigned block)
-{
-	struct atmel_tc		*tc;
-	struct platform_device	*pdev = NULL;
-
-	spin_lock(&tc_list_lock);
-	list_for_each_entry(tc, &tc_list, node) {
-		if (tc->allocated)
-			continue;
-
-		if ((tc->pdev->dev.of_node && tc->id == block) ||
-		    (tc->pdev->id == block)) {
-			pdev = tc->pdev;
-			tc->allocated = true;
-			break;
-		}
-	}
-	spin_unlock(&tc_list_lock);
-
-	return pdev ? tc : NULL;
-}
-EXPORT_SYMBOL_GPL(atmel_tc_alloc);
-
-/**
- * atmel_tc_free - release a specified TC block
- * @tc: Timer/counter block that was returned by atmel_tc_alloc()
- *
- * This reverses the effect of atmel_tc_alloc(), invalidating the resource
- * returned by that routine and making the TC available to other drivers.
- */
-void atmel_tc_free(struct atmel_tc *tc)
-{
-	spin_lock(&tc_list_lock);
-	if (tc->allocated)
-		tc->allocated = false;
-	spin_unlock(&tc_list_lock);
-}
-EXPORT_SYMBOL_GPL(atmel_tc_free);
-
-#if defined(CONFIG_OF)
-static struct atmel_tcb_config tcb_rm9200_config = {
-	.counter_width = 16,
-};
-
-static struct atmel_tcb_config tcb_sam9x5_config = {
-	.counter_width = 32,
-};
-
-static const struct of_device_id atmel_tcb_dt_ids[] = {
-	{
-		.compatible = "atmel,at91rm9200-tcb",
-		.data = &tcb_rm9200_config,
-	}, {
-		.compatible = "atmel,at91sam9x5-tcb",
-		.data = &tcb_sam9x5_config,
-	}, {
-		/* sentinel */
-	}
-};
-
-MODULE_DEVICE_TABLE(of, atmel_tcb_dt_ids);
-#endif
-
-static int __init tc_probe(struct platform_device *pdev)
-{
-	struct atmel_tc *tc;
-	struct clk	*clk;
-	int		irq;
-	struct resource	*r;
-	unsigned int	i;
-
-	irq = platform_get_irq(pdev, 0);
-	if (irq < 0)
-		return -EINVAL;
-
-	tc = devm_kzalloc(&pdev->dev, sizeof(struct atmel_tc), GFP_KERNEL);
-	if (!tc)
-		return -ENOMEM;
-
-	tc->pdev = pdev;
-
-	clk = devm_clk_get(&pdev->dev, "t0_clk");
-	if (IS_ERR(clk))
-		return PTR_ERR(clk);
-
-	tc->slow_clk = devm_clk_get(&pdev->dev, "slow_clk");
-	if (IS_ERR(tc->slow_clk))
-		return PTR_ERR(tc->slow_clk);
-
-	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	tc->regs = devm_ioremap_resource(&pdev->dev, r);
-	if (IS_ERR(tc->regs))
-		return PTR_ERR(tc->regs);
-
-	/* Now take SoC information if available */
-	if (pdev->dev.of_node) {
-		const struct of_device_id *match;
-		match = of_match_node(atmel_tcb_dt_ids, pdev->dev.of_node);
-		if (match)
-			tc->tcb_config = match->data;
-
-		tc->id = of_alias_get_id(tc->pdev->dev.of_node, "tcb");
-	} else {
-		tc->id = pdev->id;
-	}
-
-	tc->clk[0] = clk;
-	tc->clk[1] = devm_clk_get(&pdev->dev, "t1_clk");
-	if (IS_ERR(tc->clk[1]))
-		tc->clk[1] = clk;
-	tc->clk[2] = devm_clk_get(&pdev->dev, "t2_clk");
-	if (IS_ERR(tc->clk[2]))
-		tc->clk[2] = clk;
-
-	tc->irq[0] = irq;
-	tc->irq[1] = platform_get_irq(pdev, 1);
-	if (tc->irq[1] < 0)
-		tc->irq[1] = irq;
-	tc->irq[2] = platform_get_irq(pdev, 2);
-	if (tc->irq[2] < 0)
-		tc->irq[2] = irq;
-
-	for (i = 0; i < 3; i++)
-		writel(ATMEL_TC_ALL_IRQ, tc->regs + ATMEL_TC_REG(i, IDR));
-
-	spin_lock(&tc_list_lock);
-	list_add_tail(&tc->node, &tc_list);
-	spin_unlock(&tc_list_lock);
-
-	platform_set_drvdata(pdev, tc);
-
-	return 0;
-}
-
-static void tc_shutdown(struct platform_device *pdev)
-{
-	int i;
-	struct atmel_tc *tc = platform_get_drvdata(pdev);
-
-	for (i = 0; i < 3; i++)
-		writel(ATMEL_TC_ALL_IRQ, tc->regs + ATMEL_TC_REG(i, IDR));
-}
-
-static struct platform_driver tc_driver = {
-	.driver = {
-		.name	= "atmel_tcb",
-		.of_match_table	= of_match_ptr(atmel_tcb_dt_ids),
-	},
-	.shutdown = tc_shutdown,
-};
-
-static int __init tc_init(void)
-{
-	return platform_driver_probe(&tc_driver, tc_probe);
-}
-arch_initcall(tc_init);
diff --git a/include/linux/atmel_tc.h b/include/linux/atmel_tc.h
index 468fdfa643f0..92f182345222 100644
--- a/include/linux/atmel_tc.h
+++ b/include/linux/atmel_tc.h
@@ -34,14 +34,6 @@
 struct clk;
 
 /**
- * struct atmel_tcb_config - SoC data for a Timer/Counter Block
- * @counter_width: size in bits of a timer counter register
- */
-struct atmel_tcb_config {
-	size_t	counter_width;
-};
-
-/**
  * struct atmel_tc - information about a Timer/Counter Block
  * @pdev: physical device
  * @regs: mapping through which the I/O registers can be accessed
@@ -64,7 +56,6 @@ struct atmel_tc {
 	struct platform_device	*pdev;
 	void __iomem		*regs;
 	int                     id;
-	const struct atmel_tcb_config *tcb_config;
 	int			irq[3];
 	struct clk		*clk[3];
 	struct clk		*slow_clk;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 55/58] misc: remove atmel_tclib.c
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

The last user of atmel_tclib is gone, remove it too.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/misc/Kconfig       |  33 --------
 drivers/misc/Makefile      |   1 -
 drivers/misc/atmel_tclib.c | 198 ---------------------------------------------
 include/linux/atmel_tc.h   |   9 ---
 4 files changed, 241 deletions(-)
 delete mode 100644 drivers/misc/atmel_tclib.c

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 2cba76e6fa3c..5946ac3399ad 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -51,39 +51,6 @@ config AD525X_DPOT_SPI
 	  To compile this driver as a module, choose M here: the
 	  module will be called ad525x_dpot-spi.
 
-config ATMEL_TCLIB
-	bool "Atmel AT32/AT91 Timer/Counter Library"
-	depends on (AVR32 || ARCH_AT91)
-	help
-	  Select this if you want a library to allocate the Timer/Counter
-	  blocks found on many Atmel processors.  This facilitates using
-	  these blocks by different drivers despite processor differences.
-
-config ATMEL_TCB_CLKSRC
-	bool "TC Block Clocksource"
-	depends on ATMEL_TCLIB
-	default y
-	help
-	  Select this to get a high precision clocksource based on a
-	  TC block with a 5+ MHz base clock rate.  Two timer channels
-	  are combined to make a single 32-bit timer.
-
-	  When GENERIC_CLOCKEVENTS is defined, the third timer channel
-	  may be used as a clock event device supporting oneshot mode
-	  (delays of up to two seconds) based on the 32 KiHz clock.
-
-config ATMEL_TCB_CLKSRC_BLOCK
-	int
-	depends on ATMEL_TCB_CLKSRC
-	prompt "TC Block" if CPU_AT32AP700X
-	default 0
-	range 0 1
-	help
-	  Some chips provide more than one TC block, so you have the
-	  choice of which one to use for the clock framework.  The other
-	  TC can be used for other purposes, such as PWM generation and
-	  interval timing.
-
 config DUMMY_IRQ
 	tristate "Dummy IRQ handler"
 	default n
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 81ef3e67acc9..00adf5088699 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -8,7 +8,6 @@ obj-$(CONFIG_AD525X_DPOT_I2C)	+= ad525x_dpot-i2c.o
 obj-$(CONFIG_AD525X_DPOT_SPI)	+= ad525x_dpot-spi.o
 obj-$(CONFIG_INTEL_MID_PTI)	+= pti.o
 obj-$(CONFIG_ATMEL_SSC)		+= atmel-ssc.o
-obj-$(CONFIG_ATMEL_TCLIB)	+= atmel_tclib.o
 obj-$(CONFIG_DUMMY_IRQ)		+= dummy-irq.o
 obj-$(CONFIG_ICS932S401)	+= ics932s401.o
 obj-$(CONFIG_LKDTM)		+= lkdtm.o
diff --git a/drivers/misc/atmel_tclib.c b/drivers/misc/atmel_tclib.c
deleted file mode 100644
index ac24a4bd63f7..000000000000
--- a/drivers/misc/atmel_tclib.c
+++ /dev/null
@@ -1,198 +0,0 @@
-#include <linux/atmel_tc.h>
-#include <linux/clk.h>
-#include <linux/err.h>
-#include <linux/init.h>
-#include <linux/io.h>
-#include <linux/ioport.h>
-#include <linux/kernel.h>
-#include <linux/platform_device.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/export.h>
-#include <linux/of.h>
-
-/*
- * This is a thin library to solve the problem of how to portably allocate
- * one of the TC blocks.  For simplicity, it doesn't currently expect to
- * share individual timers between different drivers.
- */
-
-#if defined(CONFIG_AVR32)
-/* AVR32 has these divide PBB */
-const u8 atmel_tc_divisors[5] = { 0, 4, 8, 16, 32, };
-EXPORT_SYMBOL(atmel_tc_divisors);
-
-#elif defined(CONFIG_ARCH_AT91)
-/* AT91 has these divide MCK */
-const u8 atmel_tc_divisors[5] = { 2, 8, 32, 128, 0, };
-EXPORT_SYMBOL(atmel_tc_divisors);
-
-#endif
-
-static DEFINE_SPINLOCK(tc_list_lock);
-static LIST_HEAD(tc_list);
-
-/**
- * atmel_tc_alloc - allocate a specified TC block
- * @block: which block to allocate
- *
- * Caller allocates a block.  If it is available, a pointer to a
- * pre-initialized struct atmel_tc is returned. The caller can access
- * the registers directly through the "regs" field.
- */
-struct atmel_tc *atmel_tc_alloc(unsigned block)
-{
-	struct atmel_tc		*tc;
-	struct platform_device	*pdev = NULL;
-
-	spin_lock(&tc_list_lock);
-	list_for_each_entry(tc, &tc_list, node) {
-		if (tc->allocated)
-			continue;
-
-		if ((tc->pdev->dev.of_node && tc->id == block) ||
-		    (tc->pdev->id == block)) {
-			pdev = tc->pdev;
-			tc->allocated = true;
-			break;
-		}
-	}
-	spin_unlock(&tc_list_lock);
-
-	return pdev ? tc : NULL;
-}
-EXPORT_SYMBOL_GPL(atmel_tc_alloc);
-
-/**
- * atmel_tc_free - release a specified TC block
- * @tc: Timer/counter block that was returned by atmel_tc_alloc()
- *
- * This reverses the effect of atmel_tc_alloc(), invalidating the resource
- * returned by that routine and making the TC available to other drivers.
- */
-void atmel_tc_free(struct atmel_tc *tc)
-{
-	spin_lock(&tc_list_lock);
-	if (tc->allocated)
-		tc->allocated = false;
-	spin_unlock(&tc_list_lock);
-}
-EXPORT_SYMBOL_GPL(atmel_tc_free);
-
-#if defined(CONFIG_OF)
-static struct atmel_tcb_config tcb_rm9200_config = {
-	.counter_width = 16,
-};
-
-static struct atmel_tcb_config tcb_sam9x5_config = {
-	.counter_width = 32,
-};
-
-static const struct of_device_id atmel_tcb_dt_ids[] = {
-	{
-		.compatible = "atmel,at91rm9200-tcb",
-		.data = &tcb_rm9200_config,
-	}, {
-		.compatible = "atmel,at91sam9x5-tcb",
-		.data = &tcb_sam9x5_config,
-	}, {
-		/* sentinel */
-	}
-};
-
-MODULE_DEVICE_TABLE(of, atmel_tcb_dt_ids);
-#endif
-
-static int __init tc_probe(struct platform_device *pdev)
-{
-	struct atmel_tc *tc;
-	struct clk	*clk;
-	int		irq;
-	struct resource	*r;
-	unsigned int	i;
-
-	irq = platform_get_irq(pdev, 0);
-	if (irq < 0)
-		return -EINVAL;
-
-	tc = devm_kzalloc(&pdev->dev, sizeof(struct atmel_tc), GFP_KERNEL);
-	if (!tc)
-		return -ENOMEM;
-
-	tc->pdev = pdev;
-
-	clk = devm_clk_get(&pdev->dev, "t0_clk");
-	if (IS_ERR(clk))
-		return PTR_ERR(clk);
-
-	tc->slow_clk = devm_clk_get(&pdev->dev, "slow_clk");
-	if (IS_ERR(tc->slow_clk))
-		return PTR_ERR(tc->slow_clk);
-
-	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	tc->regs = devm_ioremap_resource(&pdev->dev, r);
-	if (IS_ERR(tc->regs))
-		return PTR_ERR(tc->regs);
-
-	/* Now take SoC information if available */
-	if (pdev->dev.of_node) {
-		const struct of_device_id *match;
-		match = of_match_node(atmel_tcb_dt_ids, pdev->dev.of_node);
-		if (match)
-			tc->tcb_config = match->data;
-
-		tc->id = of_alias_get_id(tc->pdev->dev.of_node, "tcb");
-	} else {
-		tc->id = pdev->id;
-	}
-
-	tc->clk[0] = clk;
-	tc->clk[1] = devm_clk_get(&pdev->dev, "t1_clk");
-	if (IS_ERR(tc->clk[1]))
-		tc->clk[1] = clk;
-	tc->clk[2] = devm_clk_get(&pdev->dev, "t2_clk");
-	if (IS_ERR(tc->clk[2]))
-		tc->clk[2] = clk;
-
-	tc->irq[0] = irq;
-	tc->irq[1] = platform_get_irq(pdev, 1);
-	if (tc->irq[1] < 0)
-		tc->irq[1] = irq;
-	tc->irq[2] = platform_get_irq(pdev, 2);
-	if (tc->irq[2] < 0)
-		tc->irq[2] = irq;
-
-	for (i = 0; i < 3; i++)
-		writel(ATMEL_TC_ALL_IRQ, tc->regs + ATMEL_TC_REG(i, IDR));
-
-	spin_lock(&tc_list_lock);
-	list_add_tail(&tc->node, &tc_list);
-	spin_unlock(&tc_list_lock);
-
-	platform_set_drvdata(pdev, tc);
-
-	return 0;
-}
-
-static void tc_shutdown(struct platform_device *pdev)
-{
-	int i;
-	struct atmel_tc *tc = platform_get_drvdata(pdev);
-
-	for (i = 0; i < 3; i++)
-		writel(ATMEL_TC_ALL_IRQ, tc->regs + ATMEL_TC_REG(i, IDR));
-}
-
-static struct platform_driver tc_driver = {
-	.driver = {
-		.name	= "atmel_tcb",
-		.of_match_table	= of_match_ptr(atmel_tcb_dt_ids),
-	},
-	.shutdown = tc_shutdown,
-};
-
-static int __init tc_init(void)
-{
-	return platform_driver_probe(&tc_driver, tc_probe);
-}
-arch_initcall(tc_init);
diff --git a/include/linux/atmel_tc.h b/include/linux/atmel_tc.h
index 468fdfa643f0..92f182345222 100644
--- a/include/linux/atmel_tc.h
+++ b/include/linux/atmel_tc.h
@@ -34,14 +34,6 @@
 struct clk;
 
 /**
- * struct atmel_tcb_config - SoC data for a Timer/Counter Block
- * @counter_width: size in bits of a timer counter register
- */
-struct atmel_tcb_config {
-	size_t	counter_width;
-};
-
-/**
  * struct atmel_tc - information about a Timer/Counter Block
  * @pdev: physical device
  * @regs: mapping through which the I/O registers can be accessed
@@ -64,7 +56,6 @@ struct atmel_tc {
 	struct platform_device	*pdev;
 	void __iomem		*regs;
 	int                     id;
-	const struct atmel_tcb_config *tcb_config;
 	int			irq[3];
 	struct clk		*clk[3];
 	struct clk		*slow_clk;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 56/58] ARM: configs: at91: remove ATMEL_TCLIB
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

The atmel_tclib driver is now removed, remove its config symbol.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/configs/at91_dt_defconfig | 1 -
 arch/arm/configs/sama5_defconfig   | 1 -
 2 files changed, 2 deletions(-)

diff --git a/arch/arm/configs/at91_dt_defconfig b/arch/arm/configs/at91_dt_defconfig
index 9d068f07b84b..3ec7afe7a6c9 100644
--- a/arch/arm/configs/at91_dt_defconfig
+++ b/arch/arm/configs/at91_dt_defconfig
@@ -64,7 +64,6 @@ CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=4
 CONFIG_BLK_DEV_RAM_SIZE=8192
-CONFIG_ATMEL_TCLIB=y
 CONFIG_ATMEL_SSC=y
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
diff --git a/arch/arm/configs/sama5_defconfig b/arch/arm/configs/sama5_defconfig
index 161d6221ce6e..edda4b5cbcfd 100644
--- a/arch/arm/configs/sama5_defconfig
+++ b/arch/arm/configs/sama5_defconfig
@@ -74,7 +74,6 @@ CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=4
 CONFIG_BLK_DEV_RAM_SIZE=8192
-CONFIG_ATMEL_TCLIB=y
 CONFIG_ATMEL_SSC=y
 CONFIG_EEPROM_AT24=y
 CONFIG_SCSI=y
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 56/58] ARM: configs: at91: remove ATMEL_TCLIB
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

The atmel_tclib driver is now removed, remove its config symbol.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/configs/at91_dt_defconfig | 1 -
 arch/arm/configs/sama5_defconfig   | 1 -
 2 files changed, 2 deletions(-)

diff --git a/arch/arm/configs/at91_dt_defconfig b/arch/arm/configs/at91_dt_defconfig
index 9d068f07b84b..3ec7afe7a6c9 100644
--- a/arch/arm/configs/at91_dt_defconfig
+++ b/arch/arm/configs/at91_dt_defconfig
@@ -64,7 +64,6 @@ CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=4
 CONFIG_BLK_DEV_RAM_SIZE=8192
-CONFIG_ATMEL_TCLIB=y
 CONFIG_ATMEL_SSC=y
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
diff --git a/arch/arm/configs/sama5_defconfig b/arch/arm/configs/sama5_defconfig
index 161d6221ce6e..edda4b5cbcfd 100644
--- a/arch/arm/configs/sama5_defconfig
+++ b/arch/arm/configs/sama5_defconfig
@@ -74,7 +74,6 @@ CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=4
 CONFIG_BLK_DEV_RAM_SIZE=8192
-CONFIG_ATMEL_TCLIB=y
 CONFIG_ATMEL_SSC=y
 CONFIG_EEPROM_AT24=y
 CONFIG_SCSI=y
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 57/58] ARM: multi_v7_defconfig: Remove ATMEL_TCLIB Kconfig symbol
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

The atmel_tclib driver is now removed, remove it from the configs

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/configs/multi_v7_defconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index 2685e03600b1..1b4296474cab 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -215,7 +215,6 @@ CONFIG_BLK_DEV_RAM_SIZE=65536
 CONFIG_VIRTIO_BLK=y
 CONFIG_AD525X_DPOT=y
 CONFIG_AD525X_DPOT_I2C=y
-CONFIG_ATMEL_TCLIB=y
 CONFIG_ICS932S401=y
 CONFIG_ATMEL_SSC=m
 CONFIG_QCOM_COINCELL=m
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 57/58] ARM: multi_v7_defconfig: Remove ATMEL_TCLIB Kconfig symbol
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

The atmel_tclib driver is now removed, remove it from the configs

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/configs/multi_v7_defconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index 2685e03600b1..1b4296474cab 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -215,7 +215,6 @@ CONFIG_BLK_DEV_RAM_SIZE=65536
 CONFIG_VIRTIO_BLK=y
 CONFIG_AD525X_DPOT=y
 CONFIG_AD525X_DPOT_I2C=y
-CONFIG_ATMEL_TCLIB=y
 CONFIG_ICS932S401=y
 CONFIG_ATMEL_SSC=m
 CONFIG_QCOM_COINCELL=m
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 58/58] ARM: multi_v5_defconfig: Remove ATMEL_TCLIB Kconfig symbol
  2017-05-30 21:50 ` Alexandre Belloni
@ 2017-05-30 21:51   ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Alexandre Belloni

The atmel_tclib driver is now removed, remove it from the configs.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/configs/multi_v5_defconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm/configs/multi_v5_defconfig b/arch/arm/configs/multi_v5_defconfig
index 69a4bd13eea5..de835577bb3b 100644
--- a/arch/arm/configs/multi_v5_defconfig
+++ b/arch/arm/configs/multi_v5_defconfig
@@ -95,7 +95,6 @@ CONFIG_MTD_NAND_ATMEL=y
 CONFIG_MTD_NAND_ORION=y
 CONFIG_MTD_UBI=y
 CONFIG_BLK_DEV_LOOP=y
-CONFIG_ATMEL_TCLIB=y
 CONFIG_ATMEL_SSC=m
 CONFIG_EEPROM_AT24=y
 # CONFIG_SCSI_PROC_FS is not set
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* [PATCH 58/58] ARM: multi_v5_defconfig: Remove ATMEL_TCLIB Kconfig symbol
@ 2017-05-30 21:51   ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-30 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

The atmel_tclib driver is now removed, remove it from the configs.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 arch/arm/configs/multi_v5_defconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm/configs/multi_v5_defconfig b/arch/arm/configs/multi_v5_defconfig
index 69a4bd13eea5..de835577bb3b 100644
--- a/arch/arm/configs/multi_v5_defconfig
+++ b/arch/arm/configs/multi_v5_defconfig
@@ -95,7 +95,6 @@ CONFIG_MTD_NAND_ATMEL=y
 CONFIG_MTD_NAND_ORION=y
 CONFIG_MTD_UBI=y
 CONFIG_BLK_DEV_LOOP=y
-CONFIG_ATMEL_TCLIB=y
 CONFIG_ATMEL_SSC=m
 CONFIG_EEPROM_AT24=y
 # CONFIG_SCSI_PROC_FS is not set
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 189+ messages in thread

* Re: [PATCH 00/58] ARM: at91: rework Atmel TCB drivers
  2017-05-30 21:50 ` Alexandre Belloni
  (?)
@ 2017-05-31  6:34   ` Peter Rosin
  -1 siblings, 0 replies; 189+ messages in thread
From: Peter Rosin @ 2017-05-31  6:34 UTC (permalink / raw)
  To: Alexandre Belloni, Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Antoine Aubert,
	Daniel Lezcano, devicetree, Douglas Gilbert, Fabio Porcedda,
	Gregory CLEMENT, Gregory Hermant, Joachim Eastwood, linux-pwm,
	Marek Vasut, Martin Reimann, Raashid Muhammed, Rob Herring,
	Rodolfo Giometti, Sergio Tanzilli, Thierry Reding,
	Thomas Gleixner, Tim Schendekehl

On 2017-05-30 23:50, Alexandre Belloni wrote:
> Hi,
> 
> This series reworks the Atmel Timer counter Block drivers. Those blocks
> each have 3 counters with 2 channels each and can be used for
> multiple functions:
>  - timers
>  - PWMs
>  - Quadrature decoders
>  - Stepper motor counters

I'd like to test this, but I have a hard time doing that since all I got
was this cover letter and a single DT-only patch.

I understand that you were reluctant to spam too many people with
dozens of patches, but perhaps the series can be fetched from
somewhere?

Cheers,
peda

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 00/58] ARM: at91: rework Atmel TCB drivers
@ 2017-05-31  6:34   ` Peter Rosin
  0 siblings, 0 replies; 189+ messages in thread
From: Peter Rosin @ 2017-05-31  6:34 UTC (permalink / raw)
  To: Alexandre Belloni, Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel, Antoine Aubert,
	Daniel Lezcano, devicetree, Douglas Gilbert, Fabio Porcedda,
	Gregory CLEMENT, Gregory Hermant, Joachim Eastwood, linux-pwm,
	Marek Vasut, Martin Reimann, Raashid Muhammed, Rob Herring,
	Rodolfo Giometti, Sergio Tanzilli, Thierry Reding

On 2017-05-30 23:50, Alexandre Belloni wrote:
> Hi,
> 
> This series reworks the Atmel Timer counter Block drivers. Those blocks
> each have 3 counters with 2 channels each and can be used for
> multiple functions:
>  - timers
>  - PWMs
>  - Quadrature decoders
>  - Stepper motor counters

I'd like to test this, but I have a hard time doing that since all I got
was this cover letter and a single DT-only patch.

I understand that you were reluctant to spam too many people with
dozens of patches, but perhaps the series can be fetched from
somewhere?

Cheers,
peda

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 00/58] ARM: at91: rework Atmel TCB drivers
@ 2017-05-31  6:34   ` Peter Rosin
  0 siblings, 0 replies; 189+ messages in thread
From: Peter Rosin @ 2017-05-31  6:34 UTC (permalink / raw)
  To: linux-arm-kernel

On 2017-05-30 23:50, Alexandre Belloni wrote:
> Hi,
> 
> This series reworks the Atmel Timer counter Block drivers. Those blocks
> each have 3 counters with 2 channels each and can be used for
> multiple functions:
>  - timers
>  - PWMs
>  - Quadrature decoders
>  - Stepper motor counters

I'd like to test this, but I have a hard time doing that since all I got
was this cover letter and a single DT-only patch.

I understand that you were reluctant to spam too many people with
dozens of patches, but perhaps the series can be fetched from
somewhere?

Cheers,
peda

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 00/58] ARM: at91: rework Atmel TCB drivers
  2017-05-31  6:34   ` Peter Rosin
  (?)
@ 2017-05-31  7:21     ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-31  7:21 UTC (permalink / raw)
  To: Peter Rosin
  Cc: Nicolas Ferre, Boris Brezillon, linux-arm-kernel, linux-kernel,
	Antoine Aubert, Daniel Lezcano, devicetree, Douglas Gilbert,
	Fabio Porcedda, Gregory CLEMENT, Gregory Hermant,
	Joachim Eastwood, linux-pwm, Marek Vasut, Martin Reimann,
	Raashid Muhammed, Rob Herring, Rodolfo Giometti, Sergio Tanzilli,
	Thierry Reding, Thomas Gleixner, Tim Schendekehl

Hi,

On 31/05/2017 at 08:34:00 +0200, Peter Rosin wrote:
> On 2017-05-30 23:50, Alexandre Belloni wrote:
> > Hi,
> > 
> > This series reworks the Atmel Timer counter Block drivers. Those blocks
> > each have 3 counters with 2 channels each and can be used for
> > multiple functions:
> >  - timers
> >  - PWMs
> >  - Quadrature decoders
> >  - Stepper motor counters
> 
> I'd like to test this, but I have a hard time doing that since all I got
> was this cover letter and a single DT-only patch.
> 
> I understand that you were reluctant to spam too many people with
> dozens of patches, but perhaps the series can be fetched from
> somewhere?
> 

Sure, I've pushed the branch here:
https://github.com/alexandrebelloni/linux/tree/at91-tcb-v3

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 00/58] ARM: at91: rework Atmel TCB drivers
@ 2017-05-31  7:21     ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-31  7:21 UTC (permalink / raw)
  To: Peter Rosin
  Cc: Nicolas Ferre, Boris Brezillon, linux-arm-kernel, linux-kernel,
	Antoine Aubert, Daniel Lezcano, devicetree, Douglas Gilbert,
	Fabio Porcedda, Gregory CLEMENT, Gregory Hermant,
	Joachim Eastwood, linux-pwm, Marek Vasut, Martin Reimann,
	Raashid Muhammed, Rob Herring, Rodolfo Giometti, Sergio Tanzilli

Hi,

On 31/05/2017 at 08:34:00 +0200, Peter Rosin wrote:
> On 2017-05-30 23:50, Alexandre Belloni wrote:
> > Hi,
> > 
> > This series reworks the Atmel Timer counter Block drivers. Those blocks
> > each have 3 counters with 2 channels each and can be used for
> > multiple functions:
> >  - timers
> >  - PWMs
> >  - Quadrature decoders
> >  - Stepper motor counters
> 
> I'd like to test this, but I have a hard time doing that since all I got
> was this cover letter and a single DT-only patch.
> 
> I understand that you were reluctant to spam too many people with
> dozens of patches, but perhaps the series can be fetched from
> somewhere?
> 

Sure, I've pushed the branch here:
https://github.com/alexandrebelloni/linux/tree/at91-tcb-v3

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 00/58] ARM: at91: rework Atmel TCB drivers
@ 2017-05-31  7:21     ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-05-31  7:21 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On 31/05/2017 at 08:34:00 +0200, Peter Rosin wrote:
> On 2017-05-30 23:50, Alexandre Belloni wrote:
> > Hi,
> > 
> > This series reworks the Atmel Timer counter Block drivers. Those blocks
> > each have 3 counters with 2 channels each and can be used for
> > multiple functions:
> >  - timers
> >  - PWMs
> >  - Quadrature decoders
> >  - Stepper motor counters
> 
> I'd like to test this, but I have a hard time doing that since all I got
> was this cover letter and a single DT-only patch.
> 
> I understand that you were reluctant to spam too many people with
> dozens of patches, but perhaps the series can be fetched from
> somewhere?
> 

Sure, I've pushed the branch here:
https://github.com/alexandrebelloni/linux/tree/at91-tcb-v3

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 36/58] ARM: dts: at91: linea/tse850-3: use TCB0 as clocksource
  2017-05-30 21:51   ` Alexandre Belloni
@ 2017-06-01 18:52     ` Peter Rosin
  -1 siblings, 0 replies; 189+ messages in thread
From: Peter Rosin @ 2017-06-01 18:52 UTC (permalink / raw)
  To: Alexandre Belloni, Nicolas Ferre
  Cc: Boris Brezillon, linux-arm-kernel, linux-kernel

On 2017-05-30 23:51, Alexandre Belloni wrote:
> Use tcb0 as the clocksource like previously selected in sama5_defconfig.
> 
> Cc: Peter Rosin <peda@axentia.se>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

Tested-by: Peter Rosin <peda@axentia.se>

Cheers,
peda

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 36/58] ARM: dts: at91: linea/tse850-3: use TCB0 as clocksource
@ 2017-06-01 18:52     ` Peter Rosin
  0 siblings, 0 replies; 189+ messages in thread
From: Peter Rosin @ 2017-06-01 18:52 UTC (permalink / raw)
  To: linux-arm-kernel

On 2017-05-30 23:51, Alexandre Belloni wrote:
> Use tcb0 as the clocksource like previously selected in sama5_defconfig.
> 
> Cc: Peter Rosin <peda@axentia.se>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

Tested-by: Peter Rosin <peda@axentia.se>

Cheers,
peda

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 42/58] ARM: dts: at91: vinco: use TCB2 as clocksource
  2017-05-30 21:51   ` Alexandre Belloni
@ 2017-06-02 12:48     ` Gregory CLEMENT
  -1 siblings, 0 replies; 189+ messages in thread
From: Gregory CLEMENT @ 2017-06-02 12:48 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Nicolas Ferre, Boris Brezillon, linux-arm-kernel, linux-kernel

Hi Alexandre,
 
 On mar., mai 30 2017, Alexandre Belloni <alexandre.belloni@free-electrons.com> wrote:

> As TCB2 doesn't have any output pins, use it as a clocksource.
>

In case you have not already applied it:

Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>

Thanks,

Gregory


> Cc: Gregory CLEMENT <gregory.clement@free-electrons.com>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
>  arch/arm/boot/dts/at91-vinco.dts | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/arch/arm/boot/dts/at91-vinco.dts b/arch/arm/boot/dts/at91-vinco.dts
> index e0c0b2897a49..d495a5e2aeac 100644
> --- a/arch/arm/boot/dts/at91-vinco.dts
> +++ b/arch/arm/boot/dts/at91-vinco.dts
> @@ -151,6 +151,18 @@
>  				status = "okay";
>  			};
>  
> +			tcb2: timer@fc024000 {
> +				timer@0 {
> +					compatible = "atmel,tcb-timer";
> +					reg = <0>;
> +				};
> +
> +				timer@1 {
> +					compatible = "atmel,tcb-timer";
> +					reg = <1>;
> +				};
> +			};
> +
>  			macb1: ethernet@fc028000 {
>  				phy-mode = "rmii";
>  				status = "okay";
> -- 
> 2.11.0
>

-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 42/58] ARM: dts: at91: vinco: use TCB2 as clocksource
@ 2017-06-02 12:48     ` Gregory CLEMENT
  0 siblings, 0 replies; 189+ messages in thread
From: Gregory CLEMENT @ 2017-06-02 12:48 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Alexandre,
 
 On mar., mai 30 2017, Alexandre Belloni <alexandre.belloni@free-electrons.com> wrote:

> As TCB2 doesn't have any output pins, use it as a clocksource.
>

In case you have not already applied it:

Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>

Thanks,

Gregory


> Cc: Gregory CLEMENT <gregory.clement@free-electrons.com>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
>  arch/arm/boot/dts/at91-vinco.dts | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/arch/arm/boot/dts/at91-vinco.dts b/arch/arm/boot/dts/at91-vinco.dts
> index e0c0b2897a49..d495a5e2aeac 100644
> --- a/arch/arm/boot/dts/at91-vinco.dts
> +++ b/arch/arm/boot/dts/at91-vinco.dts
> @@ -151,6 +151,18 @@
>  				status = "okay";
>  			};
>  
> +			tcb2: timer at fc024000 {
> +				timer at 0 {
> +					compatible = "atmel,tcb-timer";
> +					reg = <0>;
> +				};
> +
> +				timer at 1 {
> +					compatible = "atmel,tcb-timer";
> +					reg = <1>;
> +				};
> +			};
> +
>  			macb1: ethernet at fc028000 {
>  				phy-mode = "rmii";
>  				status = "okay";
> -- 
> 2.11.0
>

-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-05-30 21:51   ` Alexandre Belloni
@ 2017-06-06 15:21     ` Daniel Lezcano
  -1 siblings, 0 replies; 189+ messages in thread
From: Daniel Lezcano @ 2017-06-06 15:21 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Nicolas Ferre, Boris Brezillon, linux-arm-kernel, linux-kernel,
	Thomas Gleixner

On Tue, May 30, 2017 at 11:51:27PM +0200, Alexandre Belloni wrote:
> Add a driver for the Atmel Timer Counter Blocks. This driver provides a
> clocksource and a clockevent device. The clockevent device is linked to the
> clocksource counter and so it will run at the same frequency.

Where is the clockevent in this driver?

It seems the cutting out of this driver is a bit fuzzy and hard to follow.

Please re-org the changes in a logical manner when resubmitting.

> This driver uses regmap and syscon to be able to probe early in the boot
> and avoid having to switch on the TCB clocksource later. Using regmap also
> means that unused TCB channels may be used by other drivers (PWM for
> example).

Can you give more details, I fail to understand how regmap and syscon help to
probe sooner than timer_init()?

> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
>  drivers/clocksource/Kconfig                 |  13 ++
>  drivers/clocksource/Makefile                |   3 +-
>  drivers/clocksource/timer-atmel-tcbclksrc.c | 252 ++++++++++++++++++++++++++++

As it is a clksrc + clkevt, please change the name to something more adequate:

eg. timer-tcb.c

>  3 files changed, 267 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/clocksource/timer-atmel-tcbclksrc.c
> 
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index 545d541ae20e..cbd710db3c09 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -418,6 +418,19 @@ config ATMEL_ST
>  	help
>  	  Support for the Atmel ST timer.
>  
> +config ATMEL_ARM_TCB_CLKSRC
> +	bool "TC Block Clocksource"
> +	select REGMAP_MMIO
> +	depends on GENERIC_CLOCKEVENTS
> +	depends on SOC_AT91RM9200 || SOC_AT91SAM9 || SOC_SAMA5 || COMPILE_TEST
> +	default SOC_AT91RM9200 || SOC_AT91SAM9 || SOC_SAMA5
> +	help
> +	  Select this to get a high precision clocksource based on a
> +	  TC block with a 5+ MHz base clock rate.
> +	  On platforms with 16-bit counters, two timer channels are combined
> +	  to make a single 32-bit timer.
> +	  It can also be used as a clock event device supporting oneshot mode.
> +
>  config CLKSRC_METAG_GENERIC
>  	def_bool y if METAG
>  	help
> diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> index 2b5b56a6f00f..53a0b40e0db2 100644
> --- a/drivers/clocksource/Makefile
> +++ b/drivers/clocksource/Makefile
> @@ -2,7 +2,8 @@ obj-$(CONFIG_CLKSRC_PROBE)	+= clksrc-probe.o
>  obj-$(CONFIG_CLKEVT_PROBE)	+= clkevt-probe.o
>  obj-$(CONFIG_ATMEL_PIT)		+= timer-atmel-pit.o
>  obj-$(CONFIG_ATMEL_ST)		+= timer-atmel-st.o
> -obj-$(CONFIG_ATMEL_TCB_CLKSRC)	+= tcb_clksrc.o
> +obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o
> +obj-$(CONFIG_ATMEL_ARM_TCB_CLKSRC)	+= timer-atmel-tcbclksrc.o
>  obj-$(CONFIG_X86_PM_TIMER)	+= acpi_pm.o
>  obj-$(CONFIG_SCx200HR_TIMER)	+= scx200_hrt.o
>  obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC)	+= cs5535-clockevt.o
> diff --git a/drivers/clocksource/timer-atmel-tcbclksrc.c b/drivers/clocksource/timer-atmel-tcbclksrc.c
> new file mode 100644
> index 000000000000..f18d177bfdea
> --- /dev/null
> +++ b/drivers/clocksource/timer-atmel-tcbclksrc.c
> @@ -0,0 +1,252 @@
> +#include <linux/clk.h>
> +#include <linux/clockchips.h>
> +#include <linux/clocksource.h>
> +#include <linux/interrupt.h>
> +#include <linux/kernel.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/of_irq.h>
> +#include <linux/regmap.h>
> +#include <linux/sched_clock.h>
> +#include <soc/at91/atmel_tcb.h>
> +
> +static struct atmel_tcb_clksrc {
> +	char name[20];

	^^^^^^^^^^^^^^
This field is pointless.

> +	struct clocksource clksrc;

Why is this field defined and passed around to functions which do not use it?

Please consider using clocksource_mmio_init() and remove this field.

> +	struct regmap *regmap;
> +	struct clk *clk[2];

Can you explain why we have two clocks here?

> +	int channels[2];

Instead of dealing with 2 channels and a costly bits shifting in the hot path,
why not use a single channel with a different wrap up? IOW mask is 16 or 32.

The resulting code will be simpler, nicer and perhaps more efficient if you
save the tc_get_cycles() loop?

> +	int bits;

	^^^^^^^^

This field is pointless.

> +	int irq;

irq belongs to clockevents changes.

> +	bool registered;

What is the purpose of this registered boolean?

> +} tc = {
> +	.clksrc = {
> +		.rating		= 200,
> +		.mask		= CLOCKSOURCE_MASK(32),
> +		.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
> +	},
> +};
> +
> +static u64 tc_get_cycles(struct clocksource *cs)
> +{
> +	u32		lower, upper, tmp;

Fix these trailing spaces/tab.

> +
> +	do {
> +		regmap_read(tc.regmap, ATMEL_TC_CV(1), &upper);
> +		regmap_read(tc.regmap, ATMEL_TC_CV(0), &lower);
> +		regmap_read(tc.regmap, ATMEL_TC_CV(1), &tmp);
> +	} while (upper != tmp);
> +
> +	return (upper << 16) | lower;
> +}
> +
> +static u64 tc_get_cycles32(struct clocksource *cs)
> +{
> +	u32 val;
> +
> +	regmap_read(tc.regmap, ATMEL_TC_CV(tc.channels[0]), &val);
> +
> +	return val;
> +}
> +
> +static u64 notrace tc_sched_clock_read(void)
> +{
> +	return tc_get_cycles(&tc.clksrc);
> +}
> +
> +static u64 notrace tc_sched_clock_read32(void)
> +{
> +	return tc_get_cycles32(&tc.clksrc);
> +}
> +
> +static void __init tcb_setup_dual_chan(struct atmel_tcb_clksrc *tc,
> +				       int mck_divisor_idx)
> +{
> +	/* first channel: waveform mode, input mclk/8, clock TIOA on overflow */
> +	regmap_write(tc->regmap, ATMEL_TC_CMR(tc->channels[0]),
> +		     mck_divisor_idx	/* likely divide-by-8 */
> +			| ATMEL_TC_CMR_WAVE
> +			| ATMEL_TC_CMR_WAVESEL_UP	/* free-run */
> +			| ATMEL_TC_CMR_ACPA(SET)	/* TIOA rises at 0 */
> +			| ATMEL_TC_CMR_ACPC(CLEAR));	/* (duty cycle 50%) */
> +	regmap_write(tc->regmap, ATMEL_TC_RA(tc->channels[0]), 0x0000);
> +	regmap_write(tc->regmap, ATMEL_TC_RC(tc->channels[0]), 0x8000);
> +	regmap_write(tc->regmap, ATMEL_TC_IDR(tc->channels[0]), 0xff);	/* no irqs */
> +	regmap_write(tc->regmap, ATMEL_TC_CCR(tc->channels[0]),
> +		     ATMEL_TC_CCR_CLKEN);
> +
> +	/* second channel: waveform mode, input TIOA */
> +	regmap_write(tc->regmap, ATMEL_TC_CMR(tc->channels[1]),
> +		     ATMEL_TC_CMR_XC(tc->channels[1])	/* input: TIOA */
> +		     | ATMEL_TC_CMR_WAVE
> +		     | ATMEL_TC_CMR_WAVESEL_UP);	/* free-run */
> +	regmap_write(tc->regmap, ATMEL_TC_IDR(tc->channels[1]), 0xff);	/* no irqs */
> +	regmap_write(tc->regmap, ATMEL_TC_CCR(tc->channels[1]),
> +		     ATMEL_TC_CCR_CLKEN);
> +
> +	/* chain both channel, we assume the previous channel */
> +	regmap_write(tc->regmap, ATMEL_TC_BMR,
> +		     ATMEL_TC_BMR_TCXC(1 + tc->channels[1], tc->channels[1]));
> +	/* then reset all the timers */
> +	regmap_write(tc->regmap, ATMEL_TC_BCR, ATMEL_TC_BCR_SYNC);
> +}
> +
> +static void __init tcb_setup_single_chan(struct atmel_tcb_clksrc *tc,
> +					 int mck_divisor_idx)
> +{
> +	/* channel 0:  waveform mode, input mclk/8 */
> +	regmap_write(tc->regmap, ATMEL_TC_CMR(tc->channels[0]),
> +		     mck_divisor_idx	/* likely divide-by-8 */
> +			| ATMEL_TC_CMR_WAVE
> +			| ATMEL_TC_CMR_WAVESEL_UP	/* free-run */
> +			);
> +	regmap_write(tc->regmap, ATMEL_TC_IDR(tc->channels[0]), 0xff);	/* no irqs */
> +	regmap_write(tc->regmap, ATMEL_TC_CCR(tc->channels[0]),
> +		     ATMEL_TC_CCR_CLKEN);
> +
> +	/* then reset all the timers */
> +	regmap_write(tc->regmap, ATMEL_TC_BCR, ATMEL_TC_BCR_SYNC);
> +}
> +
> +static int __init tcb_clksrc_register(struct device_node *node,
> +				      struct regmap *regmap, int channel,
> +				      int channel1, int irq, int bits)
> +{
> +	u32 rate, divided_rate = 0;
> +	int best_divisor_idx = -1;
> +	int i, err = -1;
> +	u64 (*tc_sched_clock)(void);
> +
> +	tc.regmap = regmap;
> +	tc.channels[0] = channel;
> +	tc.channels[1] = channel1;
> +	tc.irq = irq;
> +	tc.bits = bits;
> +
> +	tc.clk[0] = tcb_clk_get(node, tc.channels[0]);
> +	if (IS_ERR(tc.clk[0]))
> +		return PTR_ERR(tc.clk[0]);
> +	err = clk_prepare_enable(tc.clk[0]);
> +	if (err) {
> +		pr_debug("can't enable T0 clk\n");
> +		goto err_clk;
> +	}
> +
> +	/* How fast will we be counting?  Pick something over 5 MHz.  */
> +	rate = (u32)clk_get_rate(tc.clk[0]);
> +	for (i = 0; i < 5; i++) {
> +		unsigned int divisor = atmel_tc_divisors[i];
> +		unsigned int tmp;
> +
> +		if (!divisor)
> +			continue;
> +
> +		tmp = rate / divisor;
> +		pr_debug("TC: %u / %-3u [%d] --> %u\n", rate, divisor, i, tmp);
> +		if (best_divisor_idx > 0) {
> +			if (tmp < 5 * 1000 * 1000)
> +				continue;
> +		}
> +		divided_rate = tmp;
> +		best_divisor_idx = i;
> +	}
> +
> +	if (tc.bits == 32) {
> +		tc.clksrc.read = tc_get_cycles32;
> +		tcb_setup_single_chan(&tc, best_divisor_idx);
> +		tc_sched_clock = tc_sched_clock_read32;
> +		snprintf(tc.name, sizeof(tc.name), "%s:%d",
> +			 kbasename(node->parent->full_name), tc.channels[0]);
> +	} else {
> +		tc.clk[1] = tcb_clk_get(node, tc.channels[1]);
> +		if (IS_ERR(tc.clk[1]))
> +			goto err_disable_t0;
> +
> +		err = clk_prepare_enable(tc.clk[1]);
> +		if (err) {
> +			pr_debug("can't enable T1 clk\n");
> +			goto err_clk1;
> +		}
> +		tc.clksrc.read = tc_get_cycles,
> +		tcb_setup_dual_chan(&tc, best_divisor_idx);
> +		tc_sched_clock = tc_sched_clock_read;
> +		snprintf(tc.name, sizeof(tc.name), "%s:%d,%d",
> +			 kbasename(node->parent->full_name), tc.channels[0],
> +			 tc.channels[1]);
> +	}
> +
> +	pr_debug("%s at %d.%03d MHz\n", tc.name,
> +		 divided_rate / 1000000,
> +		 ((divided_rate + 500000) % 1000000) / 1000);
> +
> +	tc.clksrc.name = tc.name;
> +
> +	err = clocksource_register_hz(&tc.clksrc, divided_rate);
> +	if (err)
> +		goto err_disable_t1;
> +
> +	sched_clock_register(tc_sched_clock, 32, divided_rate);
> +
> +	tc.registered = true;
> +
> +	return 0;
> +
> +err_disable_t1:
> +	if (tc.bits == 16)
> +		clk_disable_unprepare(tc.clk[1]);
> +
> +err_clk1:
> +	if (tc.bits == 16)
> +		clk_put(tc.clk[1]);
> +
> +err_disable_t0:
> +	clk_disable_unprepare(tc.clk[0]);
> +
> +err_clk:
> +	clk_put(tc.clk[0]);
> +
> +	pr_err("%s: unable to register clocksource/clockevent\n",
> +	       tc.clksrc.name);
> +
> +	return err;
> +}
> +
> +static int __init tcb_clksrc_init(struct device_node *node)
> +{
> +	const struct of_device_id *match;
> +	const struct atmel_tcb_info *tcb_info;
> +	struct regmap *regmap;
> +	u32 channel;
> +	int bits, irq, err, chan1 = -1;
> +
> +	if (tc.registered)
> +		return -ENODEV;
> +
> +	regmap = syscon_node_to_regmap(node->parent);
> +	if (IS_ERR(regmap))
> +		return PTR_ERR(regmap);
> +
> +	match = of_match_node(atmel_tcb_dt_ids, node->parent);
> +	tcb_info = match->data;
> +	bits = tcb_info->bits;
> +
> +	err = of_property_read_u32_index(node, "reg", 0, &channel);
> +	if (err)
> +		return err;
> +
> +	irq = tcb_irq_get(node, channel);
> +	if (irq < 0)
> +		return irq;
> +
> +	if (bits == 16) {
> +		of_property_read_u32_index(node, "reg", 1, &chan1);
> +		if (chan1 == -1) {
> +			pr_err("%s: clocksource needs two channels\n",
> +			       node->parent->full_name);
> +			return -EINVAL;
> +		}
> +	}
> +
> +	return tcb_clksrc_register(node, regmap, channel, chan1, irq, bits);
> +}
> +CLOCKSOURCE_OF_DECLARE(atmel_tcb_clksrc, "atmel,tcb-timer",
> +		       tcb_clksrc_init);
> -- 
> 2.11.0
> 

-- 

 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-06 15:21     ` Daniel Lezcano
  0 siblings, 0 replies; 189+ messages in thread
From: Daniel Lezcano @ 2017-06-06 15:21 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, May 30, 2017 at 11:51:27PM +0200, Alexandre Belloni wrote:
> Add a driver for the Atmel Timer Counter Blocks. This driver provides a
> clocksource and a clockevent device. The clockevent device is linked to the
> clocksource counter and so it will run at the same frequency.

Where is the clockevent in this driver?

It seems the cutting out of this driver is a bit fuzzy and hard to follow.

Please re-org the changes in a logical manner when resubmitting.

> This driver uses regmap and syscon to be able to probe early in the boot
> and avoid having to switch on the TCB clocksource later. Using regmap also
> means that unused TCB channels may be used by other drivers (PWM for
> example).

Can you give more details, I fail to understand how regmap and syscon help to
probe sooner than timer_init()?

> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
>  drivers/clocksource/Kconfig                 |  13 ++
>  drivers/clocksource/Makefile                |   3 +-
>  drivers/clocksource/timer-atmel-tcbclksrc.c | 252 ++++++++++++++++++++++++++++

As it is a clksrc + clkevt, please change the name to something more adequate:

eg. timer-tcb.c

>  3 files changed, 267 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/clocksource/timer-atmel-tcbclksrc.c
> 
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index 545d541ae20e..cbd710db3c09 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -418,6 +418,19 @@ config ATMEL_ST
>  	help
>  	  Support for the Atmel ST timer.
>  
> +config ATMEL_ARM_TCB_CLKSRC
> +	bool "TC Block Clocksource"
> +	select REGMAP_MMIO
> +	depends on GENERIC_CLOCKEVENTS
> +	depends on SOC_AT91RM9200 || SOC_AT91SAM9 || SOC_SAMA5 || COMPILE_TEST
> +	default SOC_AT91RM9200 || SOC_AT91SAM9 || SOC_SAMA5
> +	help
> +	  Select this to get a high precision clocksource based on a
> +	  TC block with a 5+ MHz base clock rate.
> +	  On platforms with 16-bit counters, two timer channels are combined
> +	  to make a single 32-bit timer.
> +	  It can also be used as a clock event device supporting oneshot mode.
> +
>  config CLKSRC_METAG_GENERIC
>  	def_bool y if METAG
>  	help
> diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> index 2b5b56a6f00f..53a0b40e0db2 100644
> --- a/drivers/clocksource/Makefile
> +++ b/drivers/clocksource/Makefile
> @@ -2,7 +2,8 @@ obj-$(CONFIG_CLKSRC_PROBE)	+= clksrc-probe.o
>  obj-$(CONFIG_CLKEVT_PROBE)	+= clkevt-probe.o
>  obj-$(CONFIG_ATMEL_PIT)		+= timer-atmel-pit.o
>  obj-$(CONFIG_ATMEL_ST)		+= timer-atmel-st.o
> -obj-$(CONFIG_ATMEL_TCB_CLKSRC)	+= tcb_clksrc.o
> +obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o
> +obj-$(CONFIG_ATMEL_ARM_TCB_CLKSRC)	+= timer-atmel-tcbclksrc.o
>  obj-$(CONFIG_X86_PM_TIMER)	+= acpi_pm.o
>  obj-$(CONFIG_SCx200HR_TIMER)	+= scx200_hrt.o
>  obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC)	+= cs5535-clockevt.o
> diff --git a/drivers/clocksource/timer-atmel-tcbclksrc.c b/drivers/clocksource/timer-atmel-tcbclksrc.c
> new file mode 100644
> index 000000000000..f18d177bfdea
> --- /dev/null
> +++ b/drivers/clocksource/timer-atmel-tcbclksrc.c
> @@ -0,0 +1,252 @@
> +#include <linux/clk.h>
> +#include <linux/clockchips.h>
> +#include <linux/clocksource.h>
> +#include <linux/interrupt.h>
> +#include <linux/kernel.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/of_irq.h>
> +#include <linux/regmap.h>
> +#include <linux/sched_clock.h>
> +#include <soc/at91/atmel_tcb.h>
> +
> +static struct atmel_tcb_clksrc {
> +	char name[20];

	^^^^^^^^^^^^^^
This field is pointless.

> +	struct clocksource clksrc;

Why is this field defined and passed around to functions which do not use it?

Please consider using clocksource_mmio_init() and remove this field.

> +	struct regmap *regmap;
> +	struct clk *clk[2];

Can you explain why we have two clocks here?

> +	int channels[2];

Instead of dealing with 2 channels and a costly bits shifting in the hot path,
why not use a single channel with a different wrap up? IOW mask is 16 or 32.

The resulting code will be simpler, nicer and perhaps more efficient if you
save the tc_get_cycles() loop?

> +	int bits;

	^^^^^^^^

This field is pointless.

> +	int irq;

irq belongs to clockevents changes.

> +	bool registered;

What is the purpose of this registered boolean?

> +} tc = {
> +	.clksrc = {
> +		.rating		= 200,
> +		.mask		= CLOCKSOURCE_MASK(32),
> +		.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
> +	},
> +};
> +
> +static u64 tc_get_cycles(struct clocksource *cs)
> +{
> +	u32		lower, upper, tmp;

Fix these trailing spaces/tab.

> +
> +	do {
> +		regmap_read(tc.regmap, ATMEL_TC_CV(1), &upper);
> +		regmap_read(tc.regmap, ATMEL_TC_CV(0), &lower);
> +		regmap_read(tc.regmap, ATMEL_TC_CV(1), &tmp);
> +	} while (upper != tmp);
> +
> +	return (upper << 16) | lower;
> +}
> +
> +static u64 tc_get_cycles32(struct clocksource *cs)
> +{
> +	u32 val;
> +
> +	regmap_read(tc.regmap, ATMEL_TC_CV(tc.channels[0]), &val);
> +
> +	return val;
> +}
> +
> +static u64 notrace tc_sched_clock_read(void)
> +{
> +	return tc_get_cycles(&tc.clksrc);
> +}
> +
> +static u64 notrace tc_sched_clock_read32(void)
> +{
> +	return tc_get_cycles32(&tc.clksrc);
> +}
> +
> +static void __init tcb_setup_dual_chan(struct atmel_tcb_clksrc *tc,
> +				       int mck_divisor_idx)
> +{
> +	/* first channel: waveform mode, input mclk/8, clock TIOA on overflow */
> +	regmap_write(tc->regmap, ATMEL_TC_CMR(tc->channels[0]),
> +		     mck_divisor_idx	/* likely divide-by-8 */
> +			| ATMEL_TC_CMR_WAVE
> +			| ATMEL_TC_CMR_WAVESEL_UP	/* free-run */
> +			| ATMEL_TC_CMR_ACPA(SET)	/* TIOA rises at 0 */
> +			| ATMEL_TC_CMR_ACPC(CLEAR));	/* (duty cycle 50%) */
> +	regmap_write(tc->regmap, ATMEL_TC_RA(tc->channels[0]), 0x0000);
> +	regmap_write(tc->regmap, ATMEL_TC_RC(tc->channels[0]), 0x8000);
> +	regmap_write(tc->regmap, ATMEL_TC_IDR(tc->channels[0]), 0xff);	/* no irqs */
> +	regmap_write(tc->regmap, ATMEL_TC_CCR(tc->channels[0]),
> +		     ATMEL_TC_CCR_CLKEN);
> +
> +	/* second channel: waveform mode, input TIOA */
> +	regmap_write(tc->regmap, ATMEL_TC_CMR(tc->channels[1]),
> +		     ATMEL_TC_CMR_XC(tc->channels[1])	/* input: TIOA */
> +		     | ATMEL_TC_CMR_WAVE
> +		     | ATMEL_TC_CMR_WAVESEL_UP);	/* free-run */
> +	regmap_write(tc->regmap, ATMEL_TC_IDR(tc->channels[1]), 0xff);	/* no irqs */
> +	regmap_write(tc->regmap, ATMEL_TC_CCR(tc->channels[1]),
> +		     ATMEL_TC_CCR_CLKEN);
> +
> +	/* chain both channel, we assume the previous channel */
> +	regmap_write(tc->regmap, ATMEL_TC_BMR,
> +		     ATMEL_TC_BMR_TCXC(1 + tc->channels[1], tc->channels[1]));
> +	/* then reset all the timers */
> +	regmap_write(tc->regmap, ATMEL_TC_BCR, ATMEL_TC_BCR_SYNC);
> +}
> +
> +static void __init tcb_setup_single_chan(struct atmel_tcb_clksrc *tc,
> +					 int mck_divisor_idx)
> +{
> +	/* channel 0:  waveform mode, input mclk/8 */
> +	regmap_write(tc->regmap, ATMEL_TC_CMR(tc->channels[0]),
> +		     mck_divisor_idx	/* likely divide-by-8 */
> +			| ATMEL_TC_CMR_WAVE
> +			| ATMEL_TC_CMR_WAVESEL_UP	/* free-run */
> +			);
> +	regmap_write(tc->regmap, ATMEL_TC_IDR(tc->channels[0]), 0xff);	/* no irqs */
> +	regmap_write(tc->regmap, ATMEL_TC_CCR(tc->channels[0]),
> +		     ATMEL_TC_CCR_CLKEN);
> +
> +	/* then reset all the timers */
> +	regmap_write(tc->regmap, ATMEL_TC_BCR, ATMEL_TC_BCR_SYNC);
> +}
> +
> +static int __init tcb_clksrc_register(struct device_node *node,
> +				      struct regmap *regmap, int channel,
> +				      int channel1, int irq, int bits)
> +{
> +	u32 rate, divided_rate = 0;
> +	int best_divisor_idx = -1;
> +	int i, err = -1;
> +	u64 (*tc_sched_clock)(void);
> +
> +	tc.regmap = regmap;
> +	tc.channels[0] = channel;
> +	tc.channels[1] = channel1;
> +	tc.irq = irq;
> +	tc.bits = bits;
> +
> +	tc.clk[0] = tcb_clk_get(node, tc.channels[0]);
> +	if (IS_ERR(tc.clk[0]))
> +		return PTR_ERR(tc.clk[0]);
> +	err = clk_prepare_enable(tc.clk[0]);
> +	if (err) {
> +		pr_debug("can't enable T0 clk\n");
> +		goto err_clk;
> +	}
> +
> +	/* How fast will we be counting?  Pick something over 5 MHz.  */
> +	rate = (u32)clk_get_rate(tc.clk[0]);
> +	for (i = 0; i < 5; i++) {
> +		unsigned int divisor = atmel_tc_divisors[i];
> +		unsigned int tmp;
> +
> +		if (!divisor)
> +			continue;
> +
> +		tmp = rate / divisor;
> +		pr_debug("TC: %u / %-3u [%d] --> %u\n", rate, divisor, i, tmp);
> +		if (best_divisor_idx > 0) {
> +			if (tmp < 5 * 1000 * 1000)
> +				continue;
> +		}
> +		divided_rate = tmp;
> +		best_divisor_idx = i;
> +	}
> +
> +	if (tc.bits == 32) {
> +		tc.clksrc.read = tc_get_cycles32;
> +		tcb_setup_single_chan(&tc, best_divisor_idx);
> +		tc_sched_clock = tc_sched_clock_read32;
> +		snprintf(tc.name, sizeof(tc.name), "%s:%d",
> +			 kbasename(node->parent->full_name), tc.channels[0]);
> +	} else {
> +		tc.clk[1] = tcb_clk_get(node, tc.channels[1]);
> +		if (IS_ERR(tc.clk[1]))
> +			goto err_disable_t0;
> +
> +		err = clk_prepare_enable(tc.clk[1]);
> +		if (err) {
> +			pr_debug("can't enable T1 clk\n");
> +			goto err_clk1;
> +		}
> +		tc.clksrc.read = tc_get_cycles,
> +		tcb_setup_dual_chan(&tc, best_divisor_idx);
> +		tc_sched_clock = tc_sched_clock_read;
> +		snprintf(tc.name, sizeof(tc.name), "%s:%d,%d",
> +			 kbasename(node->parent->full_name), tc.channels[0],
> +			 tc.channels[1]);
> +	}
> +
> +	pr_debug("%s at %d.%03d MHz\n", tc.name,
> +		 divided_rate / 1000000,
> +		 ((divided_rate + 500000) % 1000000) / 1000);
> +
> +	tc.clksrc.name = tc.name;
> +
> +	err = clocksource_register_hz(&tc.clksrc, divided_rate);
> +	if (err)
> +		goto err_disable_t1;
> +
> +	sched_clock_register(tc_sched_clock, 32, divided_rate);
> +
> +	tc.registered = true;
> +
> +	return 0;
> +
> +err_disable_t1:
> +	if (tc.bits == 16)
> +		clk_disable_unprepare(tc.clk[1]);
> +
> +err_clk1:
> +	if (tc.bits == 16)
> +		clk_put(tc.clk[1]);
> +
> +err_disable_t0:
> +	clk_disable_unprepare(tc.clk[0]);
> +
> +err_clk:
> +	clk_put(tc.clk[0]);
> +
> +	pr_err("%s: unable to register clocksource/clockevent\n",
> +	       tc.clksrc.name);
> +
> +	return err;
> +}
> +
> +static int __init tcb_clksrc_init(struct device_node *node)
> +{
> +	const struct of_device_id *match;
> +	const struct atmel_tcb_info *tcb_info;
> +	struct regmap *regmap;
> +	u32 channel;
> +	int bits, irq, err, chan1 = -1;
> +
> +	if (tc.registered)
> +		return -ENODEV;
> +
> +	regmap = syscon_node_to_regmap(node->parent);
> +	if (IS_ERR(regmap))
> +		return PTR_ERR(regmap);
> +
> +	match = of_match_node(atmel_tcb_dt_ids, node->parent);
> +	tcb_info = match->data;
> +	bits = tcb_info->bits;
> +
> +	err = of_property_read_u32_index(node, "reg", 0, &channel);
> +	if (err)
> +		return err;
> +
> +	irq = tcb_irq_get(node, channel);
> +	if (irq < 0)
> +		return irq;
> +
> +	if (bits == 16) {
> +		of_property_read_u32_index(node, "reg", 1, &chan1);
> +		if (chan1 == -1) {
> +			pr_err("%s: clocksource needs two channels\n",
> +			       node->parent->full_name);
> +			return -EINVAL;
> +		}
> +	}
> +
> +	return tcb_clksrc_register(node, regmap, channel, chan1, irq, bits);
> +}
> +CLOCKSOURCE_OF_DECLARE(atmel_tcb_clksrc, "atmel,tcb-timer",
> +		       tcb_clksrc_init);
> -- 
> 2.11.0
> 

-- 

 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-06-06 15:21     ` Daniel Lezcano
@ 2017-06-06 18:05       ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-06-06 18:05 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Nicolas Ferre, Boris Brezillon, linux-arm-kernel, linux-kernel,
	Thomas Gleixner

On 06/06/2017 at 17:21:05 +0200, Daniel Lezcano wrote:
> On Tue, May 30, 2017 at 11:51:27PM +0200, Alexandre Belloni wrote:
> > Add a driver for the Atmel Timer Counter Blocks. This driver provides a
> > clocksource and a clockevent device. The clockevent device is linked to the
> > clocksource counter and so it will run at the same frequency.
> 
> Where is the clockevent in this driver?
> 

That's a leftover from v1, it seems I forgot to rework that commit
message.

> It seems the cutting out of this driver is a bit fuzzy and hard to follow.
> 
> Please re-org the changes in a logical manner when resubmitting.
> 

I can submit the whole driver as a single patch if that is easier for
you to review.

> > This driver uses regmap and syscon to be able to probe early in the boot
> > and avoid having to switch on the TCB clocksource later. Using regmap also
> > means that unused TCB channels may be used by other drivers (PWM for
> > example).
> 
> Can you give more details, I fail to understand how regmap and syscon help to
> probe sooner than timer_init()?
> 

Because before that, the tcb driver relied on atmel_tclib to share the
TCBs and it happened way too late, at arch_initcall() time.


> > Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> > ---
> >  drivers/clocksource/Kconfig                 |  13 ++
> >  drivers/clocksource/Makefile                |   3 +-
> >  drivers/clocksource/timer-atmel-tcbclksrc.c | 252 ++++++++++++++++++++++++++++
> 
> As it is a clksrc + clkevt, please change the name to something more adequate:
> 
> eg. timer-tcb.c
> 
> >  3 files changed, 267 insertions(+), 1 deletion(-)
> >  create mode 100644 drivers/clocksource/timer-atmel-tcbclksrc.c
> > 
> > diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> > index 545d541ae20e..cbd710db3c09 100644
> > --- a/drivers/clocksource/Kconfig
> > +++ b/drivers/clocksource/Kconfig
> > @@ -418,6 +418,19 @@ config ATMEL_ST
> >  	help
> >  	  Support for the Atmel ST timer.
> >  
> > +config ATMEL_ARM_TCB_CLKSRC
> > +	bool "TC Block Clocksource"
> > +	select REGMAP_MMIO
> > +	depends on GENERIC_CLOCKEVENTS
> > +	depends on SOC_AT91RM9200 || SOC_AT91SAM9 || SOC_SAMA5 || COMPILE_TEST
> > +	default SOC_AT91RM9200 || SOC_AT91SAM9 || SOC_SAMA5
> > +	help
> > +	  Select this to get a high precision clocksource based on a
> > +	  TC block with a 5+ MHz base clock rate.
> > +	  On platforms with 16-bit counters, two timer channels are combined
> > +	  to make a single 32-bit timer.
> > +	  It can also be used as a clock event device supporting oneshot mode.
> > +
> >  config CLKSRC_METAG_GENERIC
> >  	def_bool y if METAG
> >  	help
> > diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> > index 2b5b56a6f00f..53a0b40e0db2 100644
> > --- a/drivers/clocksource/Makefile
> > +++ b/drivers/clocksource/Makefile
> > @@ -2,7 +2,8 @@ obj-$(CONFIG_CLKSRC_PROBE)	+= clksrc-probe.o
> >  obj-$(CONFIG_CLKEVT_PROBE)	+= clkevt-probe.o
> >  obj-$(CONFIG_ATMEL_PIT)		+= timer-atmel-pit.o
> >  obj-$(CONFIG_ATMEL_ST)		+= timer-atmel-st.o
> > -obj-$(CONFIG_ATMEL_TCB_CLKSRC)	+= tcb_clksrc.o
> > +obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o
> > +obj-$(CONFIG_ATMEL_ARM_TCB_CLKSRC)	+= timer-atmel-tcbclksrc.o
> >  obj-$(CONFIG_X86_PM_TIMER)	+= acpi_pm.o
> >  obj-$(CONFIG_SCx200HR_TIMER)	+= scx200_hrt.o
> >  obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC)	+= cs5535-clockevt.o
> > diff --git a/drivers/clocksource/timer-atmel-tcbclksrc.c b/drivers/clocksource/timer-atmel-tcbclksrc.c
> > new file mode 100644
> > index 000000000000..f18d177bfdea
> > --- /dev/null
> > +++ b/drivers/clocksource/timer-atmel-tcbclksrc.c
> > @@ -0,0 +1,252 @@
> > +#include <linux/clk.h>
> > +#include <linux/clockchips.h>
> > +#include <linux/clocksource.h>
> > +#include <linux/interrupt.h>
> > +#include <linux/kernel.h>
> > +#include <linux/mfd/syscon.h>
> > +#include <linux/of_irq.h>
> > +#include <linux/regmap.h>
> > +#include <linux/sched_clock.h>
> > +#include <soc/at91/atmel_tcb.h>
> > +
> > +static struct atmel_tcb_clksrc {
> > +	char name[20];
> 
> 	^^^^^^^^^^^^^^
> This field is pointless.
> 

You mean you don't like how it is used? Or you don't think having the
timer full name is useful?

> > +	struct clocksource clksrc;
> 
> Why is this field defined and passed around to functions which do not use it?
> 
> Please consider using clocksource_mmio_init() and remove this field.
> 

Well, this doesn't work with a regmap so it doesn't fit.

> > +	struct regmap *regmap;
> > +	struct clk *clk[2];
> 
> Can you explain why we have two clocks here?
> 

Each channel have its clock, I can add a comment if you want.

> > +	int channels[2];
> 
> Instead of dealing with 2 channels and a costly bits shifting in the hot path,
> why not use a single channel with a different wrap up? IOW mask is 16 or 32.
> 
> The resulting code will be simpler, nicer and perhaps more efficient if you
> save the tc_get_cycles() loop?
> 

I think the rationale behind it is that 16 bits at 5MHz makes it
wrap every 13ms which is too fast to be useful.

> > +	int bits;
> 
> 	^^^^^^^^
> 
> This field is pointless.
> 
> > +	int irq;
> 
> irq belongs to clockevents changes.
> 
> > +	bool registered;
> 
> What is the purpose of this registered boolean?
> 

The main reason is that RobH doesn't want to have the use (clocksource
or clockevent) of the timer in the DT so when probing a timer, I need to
know whether I already have a clocksource to decide when it is time to
register a clockevent.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-06 18:05       ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-06-06 18:05 UTC (permalink / raw)
  To: linux-arm-kernel

On 06/06/2017 at 17:21:05 +0200, Daniel Lezcano wrote:
> On Tue, May 30, 2017 at 11:51:27PM +0200, Alexandre Belloni wrote:
> > Add a driver for the Atmel Timer Counter Blocks. This driver provides a
> > clocksource and a clockevent device. The clockevent device is linked to the
> > clocksource counter and so it will run at the same frequency.
> 
> Where is the clockevent in this driver?
> 

That's a leftover from v1, it seems I forgot to rework that commit
message.

> It seems the cutting out of this driver is a bit fuzzy and hard to follow.
> 
> Please re-org the changes in a logical manner when resubmitting.
> 

I can submit the whole driver as a single patch if that is easier for
you to review.

> > This driver uses regmap and syscon to be able to probe early in the boot
> > and avoid having to switch on the TCB clocksource later. Using regmap also
> > means that unused TCB channels may be used by other drivers (PWM for
> > example).
> 
> Can you give more details, I fail to understand how regmap and syscon help to
> probe sooner than timer_init()?
> 

Because before that, the tcb driver relied on atmel_tclib to share the
TCBs and it happened way too late, at arch_initcall() time.


> > Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> > ---
> >  drivers/clocksource/Kconfig                 |  13 ++
> >  drivers/clocksource/Makefile                |   3 +-
> >  drivers/clocksource/timer-atmel-tcbclksrc.c | 252 ++++++++++++++++++++++++++++
> 
> As it is a clksrc + clkevt, please change the name to something more adequate:
> 
> eg. timer-tcb.c
> 
> >  3 files changed, 267 insertions(+), 1 deletion(-)
> >  create mode 100644 drivers/clocksource/timer-atmel-tcbclksrc.c
> > 
> > diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> > index 545d541ae20e..cbd710db3c09 100644
> > --- a/drivers/clocksource/Kconfig
> > +++ b/drivers/clocksource/Kconfig
> > @@ -418,6 +418,19 @@ config ATMEL_ST
> >  	help
> >  	  Support for the Atmel ST timer.
> >  
> > +config ATMEL_ARM_TCB_CLKSRC
> > +	bool "TC Block Clocksource"
> > +	select REGMAP_MMIO
> > +	depends on GENERIC_CLOCKEVENTS
> > +	depends on SOC_AT91RM9200 || SOC_AT91SAM9 || SOC_SAMA5 || COMPILE_TEST
> > +	default SOC_AT91RM9200 || SOC_AT91SAM9 || SOC_SAMA5
> > +	help
> > +	  Select this to get a high precision clocksource based on a
> > +	  TC block with a 5+ MHz base clock rate.
> > +	  On platforms with 16-bit counters, two timer channels are combined
> > +	  to make a single 32-bit timer.
> > +	  It can also be used as a clock event device supporting oneshot mode.
> > +
> >  config CLKSRC_METAG_GENERIC
> >  	def_bool y if METAG
> >  	help
> > diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> > index 2b5b56a6f00f..53a0b40e0db2 100644
> > --- a/drivers/clocksource/Makefile
> > +++ b/drivers/clocksource/Makefile
> > @@ -2,7 +2,8 @@ obj-$(CONFIG_CLKSRC_PROBE)	+= clksrc-probe.o
> >  obj-$(CONFIG_CLKEVT_PROBE)	+= clkevt-probe.o
> >  obj-$(CONFIG_ATMEL_PIT)		+= timer-atmel-pit.o
> >  obj-$(CONFIG_ATMEL_ST)		+= timer-atmel-st.o
> > -obj-$(CONFIG_ATMEL_TCB_CLKSRC)	+= tcb_clksrc.o
> > +obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o
> > +obj-$(CONFIG_ATMEL_ARM_TCB_CLKSRC)	+= timer-atmel-tcbclksrc.o
> >  obj-$(CONFIG_X86_PM_TIMER)	+= acpi_pm.o
> >  obj-$(CONFIG_SCx200HR_TIMER)	+= scx200_hrt.o
> >  obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC)	+= cs5535-clockevt.o
> > diff --git a/drivers/clocksource/timer-atmel-tcbclksrc.c b/drivers/clocksource/timer-atmel-tcbclksrc.c
> > new file mode 100644
> > index 000000000000..f18d177bfdea
> > --- /dev/null
> > +++ b/drivers/clocksource/timer-atmel-tcbclksrc.c
> > @@ -0,0 +1,252 @@
> > +#include <linux/clk.h>
> > +#include <linux/clockchips.h>
> > +#include <linux/clocksource.h>
> > +#include <linux/interrupt.h>
> > +#include <linux/kernel.h>
> > +#include <linux/mfd/syscon.h>
> > +#include <linux/of_irq.h>
> > +#include <linux/regmap.h>
> > +#include <linux/sched_clock.h>
> > +#include <soc/at91/atmel_tcb.h>
> > +
> > +static struct atmel_tcb_clksrc {
> > +	char name[20];
> 
> 	^^^^^^^^^^^^^^
> This field is pointless.
> 

You mean you don't like how it is used? Or you don't think having the
timer full name is useful?

> > +	struct clocksource clksrc;
> 
> Why is this field defined and passed around to functions which do not use it?
> 
> Please consider using clocksource_mmio_init() and remove this field.
> 

Well, this doesn't work with a regmap so it doesn't fit.

> > +	struct regmap *regmap;
> > +	struct clk *clk[2];
> 
> Can you explain why we have two clocks here?
> 

Each channel have its clock, I can add a comment if you want.

> > +	int channels[2];
> 
> Instead of dealing with 2 channels and a costly bits shifting in the hot path,
> why not use a single channel with a different wrap up? IOW mask is 16 or 32.
> 
> The resulting code will be simpler, nicer and perhaps more efficient if you
> save the tc_get_cycles() loop?
> 

I think the rationale behind it is that 16 bits at 5MHz makes it
wrap every 13ms which is too fast to be useful.

> > +	int bits;
> 
> 	^^^^^^^^
> 
> This field is pointless.
> 
> > +	int irq;
> 
> irq belongs to clockevents changes.
> 
> > +	bool registered;
> 
> What is the purpose of this registered boolean?
> 

The main reason is that RobH doesn't want to have the use (clocksource
or clockevent) of the timer in the DT so when probing a timer, I need to
know whether I already have a clocksource to decide when it is time to
register a clockevent.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-06-06 18:05       ` Alexandre Belloni
@ 2017-06-07 14:17         ` Daniel Lezcano
  -1 siblings, 0 replies; 189+ messages in thread
From: Daniel Lezcano @ 2017-06-07 14:17 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Nicolas Ferre, Boris Brezillon, linux-arm-kernel, linux-kernel,
	Thomas Gleixner

On Tue, Jun 06, 2017 at 08:05:59PM +0200, Alexandre Belloni wrote:
> On 06/06/2017 at 17:21:05 +0200, Daniel Lezcano wrote:
> > On Tue, May 30, 2017 at 11:51:27PM +0200, Alexandre Belloni wrote:
> > > Add a driver for the Atmel Timer Counter Blocks. This driver provides a
> > > clocksource and a clockevent device. The clockevent device is linked to the
> > > clocksource counter and so it will run at the same frequency.
> > 
> > Where is the clockevent in this driver?
> > 
> 
> That's a leftover from v1, it seems I forgot to rework that commit
> message.
> 
> > It seems the cutting out of this driver is a bit fuzzy and hard to follow.
> > 
> > Please re-org the changes in a logical manner when resubmitting.
> > 
> 
> I can submit the whole driver as a single patch if that is easier for
> you to review.

As you wish. A single driver or a split into consistent parts.

> > > This driver uses regmap and syscon to be able to probe early in the boot
> > > and avoid having to switch on the TCB clocksource later. Using regmap also
> > > means that unused TCB channels may be used by other drivers (PWM for
> > > example).
> > 
> > Can you give more details, I fail to understand how regmap and syscon help to
> > probe sooner than timer_init()?
> 
> 
> Because before that, the tcb driver relied on atmel_tclib to share the
> TCBs and it happened way too late, at arch_initcall() time.

So is it still necesary to use regmap? I would like to take the opportunity to
move the init routine to the common init routine if possible:

	https://patchwork.kernel.org/patch/9768845/

> > > Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> > > Cc: Thomas Gleixner <tglx@linutronix.de>
> > > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> > > ---
> > >  drivers/clocksource/Kconfig                 |  13 ++
> > >  drivers/clocksource/Makefile                |   3 +-
> > >  drivers/clocksource/timer-atmel-tcbclksrc.c | 252 ++++++++++++++++++++++++++++
> > 
> > As it is a clksrc + clkevt, please change the name to something more adequate:
> > 
> > eg. timer-tcb.c
> > 
> > >  3 files changed, 267 insertions(+), 1 deletion(-)
> > >  create mode 100644 drivers/clocksource/timer-atmel-tcbclksrc.c
> > > 
> > > diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> > > index 545d541ae20e..cbd710db3c09 100644
> > > --- a/drivers/clocksource/Kconfig
> > > +++ b/drivers/clocksource/Kconfig
> > > @@ -418,6 +418,19 @@ config ATMEL_ST
> > >  	help
> > >  	  Support for the Atmel ST timer.
> > >  
> > > +config ATMEL_ARM_TCB_CLKSRC
> > > +	bool "TC Block Clocksource"
> > > +	select REGMAP_MMIO
> > > +	depends on GENERIC_CLOCKEVENTS
> > > +	depends on SOC_AT91RM9200 || SOC_AT91SAM9 || SOC_SAMA5 || COMPILE_TEST
> > > +	default SOC_AT91RM9200 || SOC_AT91SAM9 || SOC_SAMA5
> > > +	help
> > > +	  Select this to get a high precision clocksource based on a
> > > +	  TC block with a 5+ MHz base clock rate.
> > > +	  On platforms with 16-bit counters, two timer channels are combined
> > > +	  to make a single 32-bit timer.
> > > +	  It can also be used as a clock event device supporting oneshot mode.
> > > +
> > >  config CLKSRC_METAG_GENERIC
> > >  	def_bool y if METAG
> > >  	help
> > > diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> > > index 2b5b56a6f00f..53a0b40e0db2 100644
> > > --- a/drivers/clocksource/Makefile
> > > +++ b/drivers/clocksource/Makefile
> > > @@ -2,7 +2,8 @@ obj-$(CONFIG_CLKSRC_PROBE)	+= clksrc-probe.o
> > >  obj-$(CONFIG_CLKEVT_PROBE)	+= clkevt-probe.o
> > >  obj-$(CONFIG_ATMEL_PIT)		+= timer-atmel-pit.o
> > >  obj-$(CONFIG_ATMEL_ST)		+= timer-atmel-st.o
> > > -obj-$(CONFIG_ATMEL_TCB_CLKSRC)	+= tcb_clksrc.o
> > > +obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o
> > > +obj-$(CONFIG_ATMEL_ARM_TCB_CLKSRC)	+= timer-atmel-tcbclksrc.o
> > >  obj-$(CONFIG_X86_PM_TIMER)	+= acpi_pm.o
> > >  obj-$(CONFIG_SCx200HR_TIMER)	+= scx200_hrt.o
> > >  obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC)	+= cs5535-clockevt.o
> > > diff --git a/drivers/clocksource/timer-atmel-tcbclksrc.c b/drivers/clocksource/timer-atmel-tcbclksrc.c
> > > new file mode 100644
> > > index 000000000000..f18d177bfdea
> > > --- /dev/null
> > > +++ b/drivers/clocksource/timer-atmel-tcbclksrc.c
> > > @@ -0,0 +1,252 @@
> > > +#include <linux/clk.h>
> > > +#include <linux/clockchips.h>
> > > +#include <linux/clocksource.h>
> > > +#include <linux/interrupt.h>
> > > +#include <linux/kernel.h>
> > > +#include <linux/mfd/syscon.h>
> > > +#include <linux/of_irq.h>
> > > +#include <linux/regmap.h>
> > > +#include <linux/sched_clock.h>
> > > +#include <soc/at91/atmel_tcb.h>
> > > +
> > > +static struct atmel_tcb_clksrc {
> > > +	char name[20];
> > 
> > 	^^^^^^^^^^^^^^
> > This field is pointless.
> > 
> 
> You mean you don't like how it is used? Or you don't think having the
> timer full name is useful?

The field is not needed, the only place where it is used is where we affect it.
 
> > > +	struct clocksource clksrc;
> > 
> > Why is this field defined and passed around to functions which do not use it?
> > 
> > Please consider using clocksource_mmio_init() and remove this field.
> > 
> 
> Well, this doesn't work with a regmap so it doesn't fit.
>
> > > +	struct regmap *regmap;
> > > +	struct clk *clk[2];
> > 
> > Can you explain why we have two clocks here?
> > 
> 
> Each channel have its clock, I can add a comment if you want.

I don't understand. Why do we have two clocks?

One channel is driven by one clock and the second one takes the overflow signal
from the first one, so no second clock is involved there, no?

> > > +	int channels[2];
> > 
> > Instead of dealing with 2 channels and a costly bits shifting in the hot path,
> > why not use a single channel with a different wrap up? IOW mask is 16 or 32.
> > 
> > The resulting code will be simpler, nicer and perhaps more efficient if you
> > save the tc_get_cycles() loop?
> > 
> 
> I think the rationale behind it is that 16 bits at 5MHz makes it
> wrap every 13ms which is too fast to be useful.

Ok, I see.

> > > +	int bits;
> > 
> > 	^^^^^^^^
> > 
> > This field is pointless.
> > 
> > > +	int irq;
> > 
> > irq belongs to clockevents changes.
> > 
> > > +	bool registered;
> > 
> > What is the purpose of this registered boolean?
> > 
> 
> The main reason is that RobH doesn't want to have the use (clocksource
> or clockevent) of the timer in the DT so when probing a timer, I need to
> know whether I already have a clocksource to decide when it is time to
> register a clockevent.

Yes, we had this discussion some weeks ago.

This registered hack forces the DT to define first the clocksource, then the
clockevent.

So, I suggest you fold the timer definition into a single one like the other
drivers.


-- 

 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-07 14:17         ` Daniel Lezcano
  0 siblings, 0 replies; 189+ messages in thread
From: Daniel Lezcano @ 2017-06-07 14:17 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jun 06, 2017 at 08:05:59PM +0200, Alexandre Belloni wrote:
> On 06/06/2017 at 17:21:05 +0200, Daniel Lezcano wrote:
> > On Tue, May 30, 2017 at 11:51:27PM +0200, Alexandre Belloni wrote:
> > > Add a driver for the Atmel Timer Counter Blocks. This driver provides a
> > > clocksource and a clockevent device. The clockevent device is linked to the
> > > clocksource counter and so it will run at the same frequency.
> > 
> > Where is the clockevent in this driver?
> > 
> 
> That's a leftover from v1, it seems I forgot to rework that commit
> message.
> 
> > It seems the cutting out of this driver is a bit fuzzy and hard to follow.
> > 
> > Please re-org the changes in a logical manner when resubmitting.
> > 
> 
> I can submit the whole driver as a single patch if that is easier for
> you to review.

As you wish. A single driver or a split into consistent parts.

> > > This driver uses regmap and syscon to be able to probe early in the boot
> > > and avoid having to switch on the TCB clocksource later. Using regmap also
> > > means that unused TCB channels may be used by other drivers (PWM for
> > > example).
> > 
> > Can you give more details, I fail to understand how regmap and syscon help to
> > probe sooner than timer_init()?
> 
> 
> Because before that, the tcb driver relied on atmel_tclib to share the
> TCBs and it happened way too late, at arch_initcall() time.

So is it still necesary to use regmap? I would like to take the opportunity to
move the init routine to the common init routine if possible:

	https://patchwork.kernel.org/patch/9768845/

> > > Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> > > Cc: Thomas Gleixner <tglx@linutronix.de>
> > > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> > > ---
> > >  drivers/clocksource/Kconfig                 |  13 ++
> > >  drivers/clocksource/Makefile                |   3 +-
> > >  drivers/clocksource/timer-atmel-tcbclksrc.c | 252 ++++++++++++++++++++++++++++
> > 
> > As it is a clksrc + clkevt, please change the name to something more adequate:
> > 
> > eg. timer-tcb.c
> > 
> > >  3 files changed, 267 insertions(+), 1 deletion(-)
> > >  create mode 100644 drivers/clocksource/timer-atmel-tcbclksrc.c
> > > 
> > > diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> > > index 545d541ae20e..cbd710db3c09 100644
> > > --- a/drivers/clocksource/Kconfig
> > > +++ b/drivers/clocksource/Kconfig
> > > @@ -418,6 +418,19 @@ config ATMEL_ST
> > >  	help
> > >  	  Support for the Atmel ST timer.
> > >  
> > > +config ATMEL_ARM_TCB_CLKSRC
> > > +	bool "TC Block Clocksource"
> > > +	select REGMAP_MMIO
> > > +	depends on GENERIC_CLOCKEVENTS
> > > +	depends on SOC_AT91RM9200 || SOC_AT91SAM9 || SOC_SAMA5 || COMPILE_TEST
> > > +	default SOC_AT91RM9200 || SOC_AT91SAM9 || SOC_SAMA5
> > > +	help
> > > +	  Select this to get a high precision clocksource based on a
> > > +	  TC block with a 5+ MHz base clock rate.
> > > +	  On platforms with 16-bit counters, two timer channels are combined
> > > +	  to make a single 32-bit timer.
> > > +	  It can also be used as a clock event device supporting oneshot mode.
> > > +
> > >  config CLKSRC_METAG_GENERIC
> > >  	def_bool y if METAG
> > >  	help
> > > diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> > > index 2b5b56a6f00f..53a0b40e0db2 100644
> > > --- a/drivers/clocksource/Makefile
> > > +++ b/drivers/clocksource/Makefile
> > > @@ -2,7 +2,8 @@ obj-$(CONFIG_CLKSRC_PROBE)	+= clksrc-probe.o
> > >  obj-$(CONFIG_CLKEVT_PROBE)	+= clkevt-probe.o
> > >  obj-$(CONFIG_ATMEL_PIT)		+= timer-atmel-pit.o
> > >  obj-$(CONFIG_ATMEL_ST)		+= timer-atmel-st.o
> > > -obj-$(CONFIG_ATMEL_TCB_CLKSRC)	+= tcb_clksrc.o
> > > +obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o
> > > +obj-$(CONFIG_ATMEL_ARM_TCB_CLKSRC)	+= timer-atmel-tcbclksrc.o
> > >  obj-$(CONFIG_X86_PM_TIMER)	+= acpi_pm.o
> > >  obj-$(CONFIG_SCx200HR_TIMER)	+= scx200_hrt.o
> > >  obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC)	+= cs5535-clockevt.o
> > > diff --git a/drivers/clocksource/timer-atmel-tcbclksrc.c b/drivers/clocksource/timer-atmel-tcbclksrc.c
> > > new file mode 100644
> > > index 000000000000..f18d177bfdea
> > > --- /dev/null
> > > +++ b/drivers/clocksource/timer-atmel-tcbclksrc.c
> > > @@ -0,0 +1,252 @@
> > > +#include <linux/clk.h>
> > > +#include <linux/clockchips.h>
> > > +#include <linux/clocksource.h>
> > > +#include <linux/interrupt.h>
> > > +#include <linux/kernel.h>
> > > +#include <linux/mfd/syscon.h>
> > > +#include <linux/of_irq.h>
> > > +#include <linux/regmap.h>
> > > +#include <linux/sched_clock.h>
> > > +#include <soc/at91/atmel_tcb.h>
> > > +
> > > +static struct atmel_tcb_clksrc {
> > > +	char name[20];
> > 
> > 	^^^^^^^^^^^^^^
> > This field is pointless.
> > 
> 
> You mean you don't like how it is used? Or you don't think having the
> timer full name is useful?

The field is not needed, the only place where it is used is where we affect it.
 
> > > +	struct clocksource clksrc;
> > 
> > Why is this field defined and passed around to functions which do not use it?
> > 
> > Please consider using clocksource_mmio_init() and remove this field.
> > 
> 
> Well, this doesn't work with a regmap so it doesn't fit.
>
> > > +	struct regmap *regmap;
> > > +	struct clk *clk[2];
> > 
> > Can you explain why we have two clocks here?
> > 
> 
> Each channel have its clock, I can add a comment if you want.

I don't understand. Why do we have two clocks?

One channel is driven by one clock and the second one takes the overflow signal
from the first one, so no second clock is involved there, no?

> > > +	int channels[2];
> > 
> > Instead of dealing with 2 channels and a costly bits shifting in the hot path,
> > why not use a single channel with a different wrap up? IOW mask is 16 or 32.
> > 
> > The resulting code will be simpler, nicer and perhaps more efficient if you
> > save the tc_get_cycles() loop?
> > 
> 
> I think the rationale behind it is that 16 bits at 5MHz makes it
> wrap every 13ms which is too fast to be useful.

Ok, I see.

> > > +	int bits;
> > 
> > 	^^^^^^^^
> > 
> > This field is pointless.
> > 
> > > +	int irq;
> > 
> > irq belongs to clockevents changes.
> > 
> > > +	bool registered;
> > 
> > What is the purpose of this registered boolean?
> > 
> 
> The main reason is that RobH doesn't want to have the use (clocksource
> or clockevent) of the timer in the DT so when probing a timer, I need to
> know whether I already have a clocksource to decide when it is time to
> register a clockevent.

Yes, we had this discussion some weeks ago.

This registered hack forces the DT to define first the clocksource, then the
clockevent.

So, I suggest you fold the timer definition into a single one like the other
drivers.


-- 

 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-06-07 14:17         ` Daniel Lezcano
@ 2017-06-07 15:09           ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-06-07 15:09 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Nicolas Ferre, Boris Brezillon, linux-arm-kernel, linux-kernel,
	Thomas Gleixner

On 07/06/2017 at 16:17:35 +0200, Daniel Lezcano wrote:
> > > > This driver uses regmap and syscon to be able to probe early in the boot
> > > > and avoid having to switch on the TCB clocksource later. Using regmap also
> > > > means that unused TCB channels may be used by other drivers (PWM for
> > > > example).
> > > 
> > > Can you give more details, I fail to understand how regmap and syscon help to
> > > probe sooner than timer_init()?
> > 
> > 
> > Because before that, the tcb driver relied on atmel_tclib to share the
> > TCBs and it happened way too late, at arch_initcall() time.
> 
> So is it still necesary to use regmap? I would like to take the opportunity to
> move the init routine to the common init routine if possible:
> 
> 	https://patchwork.kernel.org/patch/9768845/
> 

It is still necessary because we want to be able to share the timer
between multiple drivers. For example, you can have the clocksource on
channel 0, clockevent on channel 1 and a pwm on channel 2

> > > Can you explain why we have two clocks here?
> > > 
> > 
> > Each channel have its clock, I can add a comment if you want.
> 
> I don't understand. Why do we have two clocks?
> 
> One channel is driven by one clock and the second one takes the overflow signal
> from the first one, so no second clock is involved there, no?
> 

Those are the peripheral clocks, they are not used by the counters but
used to be able to read/write the registers.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-07 15:09           ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-06-07 15:09 UTC (permalink / raw)
  To: linux-arm-kernel

On 07/06/2017 at 16:17:35 +0200, Daniel Lezcano wrote:
> > > > This driver uses regmap and syscon to be able to probe early in the boot
> > > > and avoid having to switch on the TCB clocksource later. Using regmap also
> > > > means that unused TCB channels may be used by other drivers (PWM for
> > > > example).
> > > 
> > > Can you give more details, I fail to understand how regmap and syscon help to
> > > probe sooner than timer_init()?
> > 
> > 
> > Because before that, the tcb driver relied on atmel_tclib to share the
> > TCBs and it happened way too late, at arch_initcall() time.
> 
> So is it still necesary to use regmap? I would like to take the opportunity to
> move the init routine to the common init routine if possible:
> 
> 	https://patchwork.kernel.org/patch/9768845/
> 

It is still necessary because we want to be able to share the timer
between multiple drivers. For example, you can have the clocksource on
channel 0, clockevent on channel 1 and a pwm on channel 2

> > > Can you explain why we have two clocks here?
> > > 
> > 
> > Each channel have its clock, I can add a comment if you want.
> 
> I don't understand. Why do we have two clocks?
> 
> One channel is driven by one clock and the second one takes the overflow signal
> from the first one, so no second clock is involved there, no?
> 

Those are the peripheral clocks, they are not used by the counters but
used to be able to read/write the registers.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-06-07 14:17         ` Daniel Lezcano
@ 2017-06-07 15:27           ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-06-07 15:27 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Nicolas Ferre, Boris Brezillon, linux-arm-kernel, linux-kernel,
	Thomas Gleixner

On 07/06/2017 at 16:17:35 +0200, Daniel Lezcano wrote:
> > You mean you don't like how it is used? Or you don't think having the
> > timer full name is useful?
> 
> The field is not needed, the only place where it is used is where we affect it.
>  

It is used in tcb_clksrc_register:

tc.clksrc.name = tc.name;

> > The main reason is that RobH doesn't want to have the use (clocksource
> > or clockevent) of the timer in the DT so when probing a timer, I need to
> > know whether I already have a clocksource to decide when it is time to
> > register a clockevent.
> 
> Yes, we had this discussion some weeks ago.
> 
> This registered hack forces the DT to define first the clocksource, then the
> clockevent.
> 
> So, I suggest you fold the timer definition into a single one like the other
> drivers.

I was going to agree but this is not flexible enough because the
quadrature decoder always uses the first two channels. So on some
products, we may have:
 - TCB0:
   o channels 0,1: qdec
   o channel 2: clocksource

 - TCB1:
   o channels 0,1: qdec
   o channel 2: clockevent

This avoids wasting TCB channels.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-07 15:27           ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-06-07 15:27 UTC (permalink / raw)
  To: linux-arm-kernel

On 07/06/2017 at 16:17:35 +0200, Daniel Lezcano wrote:
> > You mean you don't like how it is used? Or you don't think having the
> > timer full name is useful?
> 
> The field is not needed, the only place where it is used is where we affect it.
>  

It is used in tcb_clksrc_register:

tc.clksrc.name = tc.name;

> > The main reason is that RobH doesn't want to have the use (clocksource
> > or clockevent) of the timer in the DT so when probing a timer, I need to
> > know whether I already have a clocksource to decide when it is time to
> > register a clockevent.
> 
> Yes, we had this discussion some weeks ago.
> 
> This registered hack forces the DT to define first the clocksource, then the
> clockevent.
> 
> So, I suggest you fold the timer definition into a single one like the other
> drivers.

I was going to agree but this is not flexible enough because the
quadrature decoder always uses the first two channels. So on some
products, we may have:
 - TCB0:
   o channels 0,1: qdec
   o channel 2: clocksource

 - TCB1:
   o channels 0,1: qdec
   o channel 2: clockevent

This avoids wasting TCB channels.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-06-07 15:27           ` Alexandre Belloni
@ 2017-06-07 21:08             ` Daniel Lezcano
  -1 siblings, 0 replies; 189+ messages in thread
From: Daniel Lezcano @ 2017-06-07 21:08 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Nicolas Ferre, Boris Brezillon, linux-arm-kernel, linux-kernel,
	Thomas Gleixner

On Wed, Jun 07, 2017 at 05:27:50PM +0200, Alexandre Belloni wrote:
> On 07/06/2017 at 16:17:35 +0200, Daniel Lezcano wrote:
> > > You mean you don't like how it is used? Or you don't think having the
> > > timer full name is useful?
> > 
> > The field is not needed, the only place where it is used is where we affect it.
> >  
> 
> It is used in tcb_clksrc_register:
> 
> tc.clksrc.name = tc.name;

Yes, but tc.name is only in the scope of the function, so there is no need to
include this field in the structure, just a working buffer in the function is
enough.
 
> > > The main reason is that RobH doesn't want to have the use (clocksource
> > > or clockevent) of the timer in the DT so when probing a timer, I need to
> > > know whether I already have a clocksource to decide when it is time to
> > > register a clockevent.
> > 
> > Yes, we had this discussion some weeks ago.
> > 
> > This registered hack forces the DT to define first the clocksource, then the
> > clockevent.
> > 
> > So, I suggest you fold the timer definition into a single one like the other
> > drivers.
> 
> I was going to agree but this is not flexible enough because the
> quadrature decoder always uses the first two channels. So on some
> products, we may have:
>  - TCB0:
>    o channels 0,1: qdec
>    o channel 2: clocksource
> 
>  - TCB1:
>    o channels 0,1: qdec
>    o channel 2: clockevent
> 
> This avoids wasting TCB channels.

Ok. In this case you can check if the interrupt is specified for the node, if
yes, then it is a clockevent.

-- 

 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-07 21:08             ` Daniel Lezcano
  0 siblings, 0 replies; 189+ messages in thread
From: Daniel Lezcano @ 2017-06-07 21:08 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jun 07, 2017 at 05:27:50PM +0200, Alexandre Belloni wrote:
> On 07/06/2017 at 16:17:35 +0200, Daniel Lezcano wrote:
> > > You mean you don't like how it is used? Or you don't think having the
> > > timer full name is useful?
> > 
> > The field is not needed, the only place where it is used is where we affect it.
> >  
> 
> It is used in tcb_clksrc_register:
> 
> tc.clksrc.name = tc.name;

Yes, but tc.name is only in the scope of the function, so there is no need to
include this field in the structure, just a working buffer in the function is
enough.
 
> > > The main reason is that RobH doesn't want to have the use (clocksource
> > > or clockevent) of the timer in the DT so when probing a timer, I need to
> > > know whether I already have a clocksource to decide when it is time to
> > > register a clockevent.
> > 
> > Yes, we had this discussion some weeks ago.
> > 
> > This registered hack forces the DT to define first the clocksource, then the
> > clockevent.
> > 
> > So, I suggest you fold the timer definition into a single one like the other
> > drivers.
> 
> I was going to agree but this is not flexible enough because the
> quadrature decoder always uses the first two channels. So on some
> products, we may have:
>  - TCB0:
>    o channels 0,1: qdec
>    o channel 2: clocksource
> 
>  - TCB1:
>    o channels 0,1: qdec
>    o channel 2: clockevent
> 
> This avoids wasting TCB channels.

Ok. In this case you can check if the interrupt is specified for the node, if
yes, then it is a clockevent.

-- 

 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 01/58] ARM: at91: Document new TCB bindings
@ 2017-06-07 21:17     ` Rob Herring
  0 siblings, 0 replies; 189+ messages in thread
From: Rob Herring @ 2017-06-07 21:17 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Nicolas Ferre, Boris Brezillon, linux-arm-kernel, linux-kernel,
	Daniel Lezcano, Thierry Reding, linux-pwm, devicetree

On Tue, May 30, 2017 at 11:50:42PM +0200, Alexandre Belloni wrote:
> The current binding for the TCB is not flexible enough for some use cases
> and prevents proper utilization of all the channels.
> 
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: linux-pwm@vger.kernel.org
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
>  .../devicetree/bindings/arm/atmel-at91.txt         | 32 ------------
>  .../devicetree/bindings/mfd/atmel-tcb.txt          | 58 ++++++++++++++++++++++
>  .../devicetree/bindings/pwm/atmel-tcb-pwm.txt      | 12 +++--
>  3 files changed, 65 insertions(+), 37 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/mfd/atmel-tcb.txt

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 01/58] ARM: at91: Document new TCB bindings
@ 2017-06-07 21:17     ` Rob Herring
  0 siblings, 0 replies; 189+ messages in thread
From: Rob Herring @ 2017-06-07 21:17 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Nicolas Ferre, Boris Brezillon,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Daniel Lezcano,
	Thierry Reding, linux-pwm-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA

On Tue, May 30, 2017 at 11:50:42PM +0200, Alexandre Belloni wrote:
> The current binding for the TCB is not flexible enough for some use cases
> and prevents proper utilization of all the channels.
> 
> Cc: Daniel Lezcano <daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> Cc: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Cc: linux-pwm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Signed-off-by: Alexandre Belloni <alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> ---
>  .../devicetree/bindings/arm/atmel-at91.txt         | 32 ------------
>  .../devicetree/bindings/mfd/atmel-tcb.txt          | 58 ++++++++++++++++++++++
>  .../devicetree/bindings/pwm/atmel-tcb-pwm.txt      | 12 +++--
>  3 files changed, 65 insertions(+), 37 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/mfd/atmel-tcb.txt

Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 01/58] ARM: at91: Document new TCB bindings
@ 2017-06-07 21:17     ` Rob Herring
  0 siblings, 0 replies; 189+ messages in thread
From: Rob Herring @ 2017-06-07 21:17 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, May 30, 2017 at 11:50:42PM +0200, Alexandre Belloni wrote:
> The current binding for the TCB is not flexible enough for some use cases
> and prevents proper utilization of all the channels.
> 
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: linux-pwm at vger.kernel.org
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: devicetree at vger.kernel.org
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
>  .../devicetree/bindings/arm/atmel-at91.txt         | 32 ------------
>  .../devicetree/bindings/mfd/atmel-tcb.txt          | 58 ++++++++++++++++++++++
>  .../devicetree/bindings/pwm/atmel-tcb-pwm.txt      | 12 +++--
>  3 files changed, 65 insertions(+), 37 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/mfd/atmel-tcb.txt

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-06-07 15:09           ` Alexandre Belloni
@ 2017-06-07 21:38             ` Daniel Lezcano
  -1 siblings, 0 replies; 189+ messages in thread
From: Daniel Lezcano @ 2017-06-07 21:38 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Nicolas Ferre, Boris Brezillon, linux-arm-kernel, linux-kernel,
	Thomas Gleixner

On Wed, Jun 07, 2017 at 05:09:08PM +0200, Alexandre Belloni wrote:
> On 07/06/2017 at 16:17:35 +0200, Daniel Lezcano wrote:
> > > > > This driver uses regmap and syscon to be able to probe early in the boot
> > > > > and avoid having to switch on the TCB clocksource later. Using regmap also
> > > > > means that unused TCB channels may be used by other drivers (PWM for
> > > > > example).
> > > > 
> > > > Can you give more details, I fail to understand how regmap and syscon help to
> > > > probe sooner than timer_init()?
> > > 
> > > 
> > > Because before that, the tcb driver relied on atmel_tclib to share the
> > > TCBs and it happened way too late, at arch_initcall() time.
> > 
> > So is it still necesary to use regmap? I would like to take the opportunity to
> > move the init routine to the common init routine if possible:
> > 
> > 	https://patchwork.kernel.org/patch/9768845/
> > 
> 
> It is still necessary because we want to be able to share the timer
> between multiple drivers. For example, you can have the clocksource on
> channel 0, clockevent on channel 1 and a pwm on channel 2

The hardware timer can be shared, the channels used in different subsystem.

Each channel are used exclusively.

What is the benefit of regmap? It has a cost, and takes a lock at each read.

For instance:

+static u64 tc_get_cycles(struct clocksource *cs)
+{
+	u32		lower, upper, tmp;
+
+	do {
+		regmap_read(tc.regmap, ATMEL_TC_CV(1), &upper);
+		regmap_read(tc.regmap, ATMEL_TC_CV(0), &lower);
+		regmap_read(tc.regmap, ATMEL_TC_CV(1), &tmp);
+	} while (upper != tmp);
+
+	return (upper << 16) | lower;
+}

Is:

+static u64 tc_get_cycles(struct clocksource *cs)
+{
+	u32		lower, upper, tmp;
+
+	do {
+		regmap_read(tc.regmap, ATMEL_TC_CV(1), &upper);
			lock();
			lot-of-things();
			unlock();
+		regmap_read(tc.regmap, ATMEL_TC_CV(0), &lower);
			lock();
			lot-of-things();
			unlock();
+		regmap_read(tc.regmap, ATMEL_TC_CV(1), &tmp);
			lock();
			lot-of-things();
			unlock();
+	} while (upper != tmp);
+
+	return (upper << 16) | lower;
+}

I suggest to look what is in 'lot-of-things()' and especially what is doing
regcache_read().

May be you can reconsider the regmap? This driver is the only one use the
regmap AFAICT and I don't think it is adequate.

> > > > Can you explain why we have two clocks here?
> > > > 
> > > 
> > > Each channel have its clock, I can add a comment if you want.
> > 
> > I don't understand. Why do we have two clocks?
> > 
> > One channel is driven by one clock and the second one takes the overflow signal
> > from the first one, so no second clock is involved there, no?
> > 
> 
> Those are the peripheral clocks, they are not used by the counters but
> used to be able to read/write the registers.

Mmh, strange. Why is the clk[0]'s rate used in this case?

-- 

 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-07 21:38             ` Daniel Lezcano
  0 siblings, 0 replies; 189+ messages in thread
From: Daniel Lezcano @ 2017-06-07 21:38 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jun 07, 2017 at 05:09:08PM +0200, Alexandre Belloni wrote:
> On 07/06/2017 at 16:17:35 +0200, Daniel Lezcano wrote:
> > > > > This driver uses regmap and syscon to be able to probe early in the boot
> > > > > and avoid having to switch on the TCB clocksource later. Using regmap also
> > > > > means that unused TCB channels may be used by other drivers (PWM for
> > > > > example).
> > > > 
> > > > Can you give more details, I fail to understand how regmap and syscon help to
> > > > probe sooner than timer_init()?
> > > 
> > > 
> > > Because before that, the tcb driver relied on atmel_tclib to share the
> > > TCBs and it happened way too late, at arch_initcall() time.
> > 
> > So is it still necesary to use regmap? I would like to take the opportunity to
> > move the init routine to the common init routine if possible:
> > 
> > 	https://patchwork.kernel.org/patch/9768845/
> > 
> 
> It is still necessary because we want to be able to share the timer
> between multiple drivers. For example, you can have the clocksource on
> channel 0, clockevent on channel 1 and a pwm on channel 2

The hardware timer can be shared, the channels used in different subsystem.

Each channel are used exclusively.

What is the benefit of regmap? It has a cost, and takes a lock at each read.

For instance:

+static u64 tc_get_cycles(struct clocksource *cs)
+{
+	u32		lower, upper, tmp;
+
+	do {
+		regmap_read(tc.regmap, ATMEL_TC_CV(1), &upper);
+		regmap_read(tc.regmap, ATMEL_TC_CV(0), &lower);
+		regmap_read(tc.regmap, ATMEL_TC_CV(1), &tmp);
+	} while (upper != tmp);
+
+	return (upper << 16) | lower;
+}

Is:

+static u64 tc_get_cycles(struct clocksource *cs)
+{
+	u32		lower, upper, tmp;
+
+	do {
+		regmap_read(tc.regmap, ATMEL_TC_CV(1), &upper);
			lock();
			lot-of-things();
			unlock();
+		regmap_read(tc.regmap, ATMEL_TC_CV(0), &lower);
			lock();
			lot-of-things();
			unlock();
+		regmap_read(tc.regmap, ATMEL_TC_CV(1), &tmp);
			lock();
			lot-of-things();
			unlock();
+	} while (upper != tmp);
+
+	return (upper << 16) | lower;
+}

I suggest to look what is in 'lot-of-things()' and especially what is doing
regcache_read().

May be you can reconsider the regmap? This driver is the only one use the
regmap AFAICT and I don't think it is adequate.

> > > > Can you explain why we have two clocks here?
> > > > 
> > > 
> > > Each channel have its clock, I can add a comment if you want.
> > 
> > I don't understand. Why do we have two clocks?
> > 
> > One channel is driven by one clock and the second one takes the overflow signal
> > from the first one, so no second clock is involved there, no?
> > 
> 
> Those are the peripheral clocks, they are not used by the counters but
> used to be able to read/write the registers.

Mmh, strange. Why is the clk[0]'s rate used in this case?

-- 

 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-06-07 21:38             ` Daniel Lezcano
@ 2017-06-07 23:11               ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-06-07 23:11 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Nicolas Ferre, Boris Brezillon, linux-arm-kernel, linux-kernel,
	Thomas Gleixner

On 07/06/2017 at 23:38:10 +0200, Daniel Lezcano wrote:
> On Wed, Jun 07, 2017 at 05:09:08PM +0200, Alexandre Belloni wrote:
> I suggest to look what is in 'lot-of-things()' and especially what is doing
> regcache_read().
> 

I know it does a lot...

> May be you can reconsider the regmap? This driver is the only one use the
> regmap AFAICT and I don't think it is adequate.
> 

That is not true, I also converted the PWM driver and both a capture and
qdec drivers are coming.



> > > > > Can you explain why we have two clocks here?
> > > > > 
> > > > 
> > > > Each channel have its clock, I can add a comment if you want.
> > > 
> > > I don't understand. Why do we have two clocks?
> > > 
> > > One channel is driven by one clock and the second one takes the overflow signal
> > > from the first one, so no second clock is involved there, no?
> > > 
> > 
> > Those are the peripheral clocks, they are not used by the counters but
> > used to be able to read/write the registers.
> 
> Mmh, strange. Why is the clk[0]'s rate used in this case?
> 

That's abusing the fact that is has the same rate as the clock feeding
the counter.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-07 23:11               ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-06-07 23:11 UTC (permalink / raw)
  To: linux-arm-kernel

On 07/06/2017 at 23:38:10 +0200, Daniel Lezcano wrote:
> On Wed, Jun 07, 2017 at 05:09:08PM +0200, Alexandre Belloni wrote:
> I suggest to look what is in 'lot-of-things()' and especially what is doing
> regcache_read().
> 

I know it does a lot...

> May be you can reconsider the regmap? This driver is the only one use the
> regmap AFAICT and I don't think it is adequate.
> 

That is not true, I also converted the PWM driver and both a capture and
qdec drivers are coming.



> > > > > Can you explain why we have two clocks here?
> > > > > 
> > > > 
> > > > Each channel have its clock, I can add a comment if you want.
> > > 
> > > I don't understand. Why do we have two clocks?
> > > 
> > > One channel is driven by one clock and the second one takes the overflow signal
> > > from the first one, so no second clock is involved there, no?
> > > 
> > 
> > Those are the peripheral clocks, they are not used by the counters but
> > used to be able to read/write the registers.
> 
> Mmh, strange. Why is the clk[0]'s rate used in this case?
> 

That's abusing the fact that is has the same rate as the clock feeding
the counter.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-06-07 21:08             ` Daniel Lezcano
@ 2017-06-07 23:17               ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-06-07 23:17 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Nicolas Ferre, Boris Brezillon, linux-arm-kernel, linux-kernel,
	Thomas Gleixner

On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:
> > I was going to agree but this is not flexible enough because the
> > quadrature decoder always uses the first two channels. So on some
> > products, we may have:
> >  - TCB0:
> >    o channels 0,1: qdec
> >    o channel 2: clocksource
> > 
> >  - TCB1:
> >    o channels 0,1: qdec
> >    o channel 2: clockevent
> > 
> > This avoids wasting TCB channels.
> 
> Ok. In this case you can check if the interrupt is specified for the node, if
> yes, then it is a clockevent.
> 

But currently it is always specified in the SoC's dtsi. I don't find
that too practical to push that to the board's dts. Also, lying by
omission (the IRQ is always wired) in the DT is not different from
having a property selecting which timer is the clocksource and which is
the clockevent.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-07 23:17               ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-06-07 23:17 UTC (permalink / raw)
  To: linux-arm-kernel

On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:
> > I was going to agree but this is not flexible enough because the
> > quadrature decoder always uses the first two channels. So on some
> > products, we may have:
> >  - TCB0:
> >    o channels 0,1: qdec
> >    o channel 2: clocksource
> > 
> >  - TCB1:
> >    o channels 0,1: qdec
> >    o channel 2: clockevent
> > 
> > This avoids wasting TCB channels.
> 
> Ok. In this case you can check if the interrupt is specified for the node, if
> yes, then it is a clockevent.
> 

But currently it is always specified in the SoC's dtsi. I don't find
that too practical to push that to the board's dts. Also, lying by
omission (the IRQ is always wired) in the DT is not different from
having a property selecting which timer is the clocksource and which is
the clockevent.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-08  5:42                 ` Boris Brezillon
  0 siblings, 0 replies; 189+ messages in thread
From: Boris Brezillon @ 2017-06-08  5:42 UTC (permalink / raw)
  To: Alexandre Belloni, Rob Herring
  Cc: Daniel Lezcano, Nicolas Ferre, linux-arm-kernel, linux-kernel,
	Thomas Gleixner, devicetree

Le Thu, 8 Jun 2017 01:17:15 +0200,
Alexandre Belloni <alexandre.belloni@free-electrons.com> a écrit :

> On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:
> > > I was going to agree but this is not flexible enough because the
> > > quadrature decoder always uses the first two channels. So on some
> > > products, we may have:
> > >  - TCB0:
> > >    o channels 0,1: qdec
> > >    o channel 2: clocksource
> > > 
> > >  - TCB1:
> > >    o channels 0,1: qdec
> > >    o channel 2: clockevent
> > > 
> > > This avoids wasting TCB channels.  
> > 
> > Ok. In this case you can check if the interrupt is specified for the node, if
> > yes, then it is a clockevent.
> >   
> 
> But currently it is always specified in the SoC's dtsi. I don't find
> that too practical to push that to the board's dts. Also, lying by
> omission (the IRQ is always wired) in the DT is not different from
> having a property selecting which timer is the clocksource and which is
> the clockevent.
> 

I agree with Alexandre here. Really, there's not much we can do to
detect which timer should be used as a clockevent and which one should
be used as a clocksource except explicitly specifying it in the DT.
Having an interrupt defined in one case (clockevent) and undefined in
the other case (clocksource), is just as hack-ish as the detection logic
Alexandre developed to avoid explicitly specifying the function
assigned to a specific timer.

Can we please find a solution that makes everyone happy (DT,
clocksoure/clockevent and at91 maintainers)?

How about adding a linux,timer-function property to specify which
function this timer is providing?

Something like that for example:

	tcb0: timer@fff7c000 {
		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
		#address-cells = <1>;
		#size-cells = <0>;
		reg = <0xfff7c000 0x100>;
		interrupts = <18 4>;
		clocks = <&tcb0_clk>, <&clk32k>;
		clock-names = "t0_clk", "slow_clk";

		timer@0 {
			compatible = "atmel,tcb-timer";
			reg = <0>, <1>;
			linux,timer-function = "clocksource";
		};

		timer@2 {
			compatible = "atmel,tcb-timer";
			reg = <2>;
			linux,timer-function = "clockevent";
		};
	};

Alternatively, we could have a property or a node in chosen describing which
timer should be used:

	chosen {
		clockevent {
			timer = <&timer2>;
		};

		clocksource {
			timer = <&timer0>;
		};

		/*
		 * or
		 *
		 * clockevent = <&timer2>;
		 * clocksource = <&timer0>;
		 *
		 * but I think the clocksource/clockevent node approach
		 * is more future proof in case we need to add extra
		 * information like the expected resolution/precision or
		 * anything that could be tweakable.
		 */
	};

	tcb0: timer@fff7c000 {
		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
		#address-cells = <1>;
		#size-cells = <0>;
		reg = <0xfff7c000 0x100>;
		interrupts = <18 4>;
		clocks = <&tcb0_clk>, <&clk32k>;
		clock-names = "t0_clk", "slow_clk";

		timer0: timer@0 {
			compatible = "atmel,tcb-timer";
			reg = <0>, <1>;
		};

		timer2: timer@2 {
			compatible = "atmel,tcb-timer";
			reg = <2>;
		};
	};

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-08  5:42                 ` Boris Brezillon
  0 siblings, 0 replies; 189+ messages in thread
From: Boris Brezillon @ 2017-06-08  5:42 UTC (permalink / raw)
  To: Alexandre Belloni, Rob Herring
  Cc: Daniel Lezcano, Nicolas Ferre,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Thomas Gleixner,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Le Thu, 8 Jun 2017 01:17:15 +0200,
Alexandre Belloni <alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> a écrit :

> On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:
> > > I was going to agree but this is not flexible enough because the
> > > quadrature decoder always uses the first two channels. So on some
> > > products, we may have:
> > >  - TCB0:
> > >    o channels 0,1: qdec
> > >    o channel 2: clocksource
> > > 
> > >  - TCB1:
> > >    o channels 0,1: qdec
> > >    o channel 2: clockevent
> > > 
> > > This avoids wasting TCB channels.  
> > 
> > Ok. In this case you can check if the interrupt is specified for the node, if
> > yes, then it is a clockevent.
> >   
> 
> But currently it is always specified in the SoC's dtsi. I don't find
> that too practical to push that to the board's dts. Also, lying by
> omission (the IRQ is always wired) in the DT is not different from
> having a property selecting which timer is the clocksource and which is
> the clockevent.
> 

I agree with Alexandre here. Really, there's not much we can do to
detect which timer should be used as a clockevent and which one should
be used as a clocksource except explicitly specifying it in the DT.
Having an interrupt defined in one case (clockevent) and undefined in
the other case (clocksource), is just as hack-ish as the detection logic
Alexandre developed to avoid explicitly specifying the function
assigned to a specific timer.

Can we please find a solution that makes everyone happy (DT,
clocksoure/clockevent and at91 maintainers)?

How about adding a linux,timer-function property to specify which
function this timer is providing?

Something like that for example:

	tcb0: timer@fff7c000 {
		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
		#address-cells = <1>;
		#size-cells = <0>;
		reg = <0xfff7c000 0x100>;
		interrupts = <18 4>;
		clocks = <&tcb0_clk>, <&clk32k>;
		clock-names = "t0_clk", "slow_clk";

		timer@0 {
			compatible = "atmel,tcb-timer";
			reg = <0>, <1>;
			linux,timer-function = "clocksource";
		};

		timer@2 {
			compatible = "atmel,tcb-timer";
			reg = <2>;
			linux,timer-function = "clockevent";
		};
	};

Alternatively, we could have a property or a node in chosen describing which
timer should be used:

	chosen {
		clockevent {
			timer = <&timer2>;
		};

		clocksource {
			timer = <&timer0>;
		};

		/*
		 * or
		 *
		 * clockevent = <&timer2>;
		 * clocksource = <&timer0>;
		 *
		 * but I think the clocksource/clockevent node approach
		 * is more future proof in case we need to add extra
		 * information like the expected resolution/precision or
		 * anything that could be tweakable.
		 */
	};

	tcb0: timer@fff7c000 {
		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
		#address-cells = <1>;
		#size-cells = <0>;
		reg = <0xfff7c000 0x100>;
		interrupts = <18 4>;
		clocks = <&tcb0_clk>, <&clk32k>;
		clock-names = "t0_clk", "slow_clk";

		timer0: timer@0 {
			compatible = "atmel,tcb-timer";
			reg = <0>, <1>;
		};

		timer2: timer@2 {
			compatible = "atmel,tcb-timer";
			reg = <2>;
		};
	};
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-08  5:42                 ` Boris Brezillon
  0 siblings, 0 replies; 189+ messages in thread
From: Boris Brezillon @ 2017-06-08  5:42 UTC (permalink / raw)
  To: linux-arm-kernel

Le Thu, 8 Jun 2017 01:17:15 +0200,
Alexandre Belloni <alexandre.belloni@free-electrons.com> a ?crit :

> On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:
> > > I was going to agree but this is not flexible enough because the
> > > quadrature decoder always uses the first two channels. So on some
> > > products, we may have:
> > >  - TCB0:
> > >    o channels 0,1: qdec
> > >    o channel 2: clocksource
> > > 
> > >  - TCB1:
> > >    o channels 0,1: qdec
> > >    o channel 2: clockevent
> > > 
> > > This avoids wasting TCB channels.  
> > 
> > Ok. In this case you can check if the interrupt is specified for the node, if
> > yes, then it is a clockevent.
> >   
> 
> But currently it is always specified in the SoC's dtsi. I don't find
> that too practical to push that to the board's dts. Also, lying by
> omission (the IRQ is always wired) in the DT is not different from
> having a property selecting which timer is the clocksource and which is
> the clockevent.
> 

I agree with Alexandre here. Really, there's not much we can do to
detect which timer should be used as a clockevent and which one should
be used as a clocksource except explicitly specifying it in the DT.
Having an interrupt defined in one case (clockevent) and undefined in
the other case (clocksource), is just as hack-ish as the detection logic
Alexandre developed to avoid explicitly specifying the function
assigned to a specific timer.

Can we please find a solution that makes everyone happy (DT,
clocksoure/clockevent and at91 maintainers)?

How about adding a linux,timer-function property to specify which
function this timer is providing?

Something like that for example:

	tcb0: timer at fff7c000 {
		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
		#address-cells = <1>;
		#size-cells = <0>;
		reg = <0xfff7c000 0x100>;
		interrupts = <18 4>;
		clocks = <&tcb0_clk>, <&clk32k>;
		clock-names = "t0_clk", "slow_clk";

		timer at 0 {
			compatible = "atmel,tcb-timer";
			reg = <0>, <1>;
			linux,timer-function = "clocksource";
		};

		timer at 2 {
			compatible = "atmel,tcb-timer";
			reg = <2>;
			linux,timer-function = "clockevent";
		};
	};

Alternatively, we could have a property or a node in chosen describing which
timer should be used:

	chosen {
		clockevent {
			timer = <&timer2>;
		};

		clocksource {
			timer = <&timer0>;
		};

		/*
		 * or
		 *
		 * clockevent = <&timer2>;
		 * clocksource = <&timer0>;
		 *
		 * but I think the clocksource/clockevent node approach
		 * is more future proof in case we need to add extra
		 * information like the expected resolution/precision or
		 * anything that could be tweakable.
		 */
	};

	tcb0: timer at fff7c000 {
		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
		#address-cells = <1>;
		#size-cells = <0>;
		reg = <0xfff7c000 0x100>;
		interrupts = <18 4>;
		clocks = <&tcb0_clk>, <&clk32k>;
		clock-names = "t0_clk", "slow_clk";

		timer0: timer at 0 {
			compatible = "atmel,tcb-timer";
			reg = <0>, <1>;
		};

		timer2: timer at 2 {
			compatible = "atmel,tcb-timer";
			reg = <2>;
		};
	};

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-06-07 21:08             ` Daniel Lezcano
@ 2017-06-08  6:21               ` Boris Brezillon
  -1 siblings, 0 replies; 189+ messages in thread
From: Boris Brezillon @ 2017-06-08  6:21 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Alexandre Belloni, Nicolas Ferre, linux-arm-kernel, linux-kernel,
	Thomas Gleixner

Le Wed, 7 Jun 2017 23:08:48 +0200,
Daniel Lezcano <daniel.lezcano@linaro.org> a écrit :

> On Wed, Jun 07, 2017 at 05:27:50PM +0200, Alexandre Belloni wrote:
> > On 07/06/2017 at 16:17:35 +0200, Daniel Lezcano wrote:  
> > > > You mean you don't like how it is used? Or you don't think having the
> > > > timer full name is useful?  
> > > 
> > > The field is not needed, the only place where it is used is where we affect it.
> > >    
> > 
> > It is used in tcb_clksrc_register:
> > 
> > tc.clksrc.name = tc.name;  
> 
> Yes, but tc.name is only in the scope of the function, so there is no need to
> include this field in the structure, just a working buffer in the function is
> enough.

Hm, do you mean allocating the buffer dynamically and leaking the
resource (not a real leak here, since we're talking about something
that cannot be unregistered) or defining a 'static char name[]' variable
in the function and passing this pointer to clksrc.name? Note
that putting the name var on the stack won't work, because the core
does not seem to duplicate the name, and uses clksrc->name after
tcb_clksrc_register() has returned.

Anyway, I'm not sure dynamically generating the name is really
needed because we only accept a single tcb-clocksource device. We can
just set tc.clksrc.name to "atmel-tcb-clocksource" and we should be
good.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-08  6:21               ` Boris Brezillon
  0 siblings, 0 replies; 189+ messages in thread
From: Boris Brezillon @ 2017-06-08  6:21 UTC (permalink / raw)
  To: linux-arm-kernel

Le Wed, 7 Jun 2017 23:08:48 +0200,
Daniel Lezcano <daniel.lezcano@linaro.org> a ?crit :

> On Wed, Jun 07, 2017 at 05:27:50PM +0200, Alexandre Belloni wrote:
> > On 07/06/2017 at 16:17:35 +0200, Daniel Lezcano wrote:  
> > > > You mean you don't like how it is used? Or you don't think having the
> > > > timer full name is useful?  
> > > 
> > > The field is not needed, the only place where it is used is where we affect it.
> > >    
> > 
> > It is used in tcb_clksrc_register:
> > 
> > tc.clksrc.name = tc.name;  
> 
> Yes, but tc.name is only in the scope of the function, so there is no need to
> include this field in the structure, just a working buffer in the function is
> enough.

Hm, do you mean allocating the buffer dynamically and leaking the
resource (not a real leak here, since we're talking about something
that cannot be unregistered) or defining a 'static char name[]' variable
in the function and passing this pointer to clksrc.name? Note
that putting the name var on the stack won't work, because the core
does not seem to duplicate the name, and uses clksrc->name after
tcb_clksrc_register() has returned.

Anyway, I'm not sure dynamically generating the name is really
needed because we only accept a single tcb-clocksource device. We can
just set tc.clksrc.name to "atmel-tcb-clocksource" and we should be
good.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-06-07 21:38             ` Daniel Lezcano
@ 2017-06-08  6:52               ` Boris Brezillon
  -1 siblings, 0 replies; 189+ messages in thread
From: Boris Brezillon @ 2017-06-08  6:52 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Alexandre Belloni, Nicolas Ferre, linux-arm-kernel, linux-kernel,
	Thomas Gleixner

Le Wed, 7 Jun 2017 23:38:10 +0200,
Daniel Lezcano <daniel.lezcano@linaro.org> a écrit :

> On Wed, Jun 07, 2017 at 05:09:08PM +0200, Alexandre Belloni wrote:
> > On 07/06/2017 at 16:17:35 +0200, Daniel Lezcano wrote:  
> > > > > > This driver uses regmap and syscon to be able to probe early in the boot
> > > > > > and avoid having to switch on the TCB clocksource later. Using regmap also
> > > > > > means that unused TCB channels may be used by other drivers (PWM for
> > > > > > example).  
> > > > > 
> > > > > Can you give more details, I fail to understand how regmap and syscon help to
> > > > > probe sooner than timer_init()?  
> > > > 
> > > > 
> > > > Because before that, the tcb driver relied on atmel_tclib to share the
> > > > TCBs and it happened way too late, at arch_initcall() time.  
> > > 
> > > So is it still necesary to use regmap? I would like to take the opportunity to
> > > move the init routine to the common init routine if possible:
> > > 
> > > 	https://patchwork.kernel.org/patch/9768845/
> > >   
> > 
> > It is still necessary because we want to be able to share the timer
> > between multiple drivers. For example, you can have the clocksource on
> > channel 0, clockevent on channel 1 and a pwm on channel 2  
> 
> The hardware timer can be shared, the channels used in different subsystem.
> 
> Each channel are used exclusively.

Yes, that's correct, but some registers are shared, and we need locking
to control accesses to these registers. There's one register in
particular that has to be protected against concurrent accesses:
TC_BMR. But this register is only written at init time, not in the hot
path.

> 
> What is the benefit of regmap? It has a cost, and takes a lock at each read.
> 
> For instance:
> 
> +static u64 tc_get_cycles(struct clocksource *cs)
> +{
> +	u32		lower, upper, tmp;
> +
> +	do {
> +		regmap_read(tc.regmap, ATMEL_TC_CV(1), &upper);
> +		regmap_read(tc.regmap, ATMEL_TC_CV(0), &lower);
> +		regmap_read(tc.regmap, ATMEL_TC_CV(1), &tmp);
> +	} while (upper != tmp);
> +
> +	return (upper << 16) | lower;
> +}
> 
> Is:
> 
> +static u64 tc_get_cycles(struct clocksource *cs)
> +{
> +	u32		lower, upper, tmp;
> +
> +	do {
> +		regmap_read(tc.regmap, ATMEL_TC_CV(1), &upper);
> 			lock();
> 			lot-of-things();
> 			unlock();
> +		regmap_read(tc.regmap, ATMEL_TC_CV(0), &lower);
> 			lock();
> 			lot-of-things();
> 			unlock();
> +		regmap_read(tc.regmap, ATMEL_TC_CV(1), &tmp);
> 			lock();
> 			lot-of-things();
> 			unlock();
> +	} while (upper != tmp);
> +
> +	return (upper << 16) | lower;
> +}
> 
> I suggest to look what is in 'lot-of-things()' and especially what is doing
> regcache_read().
> 
> May be you can reconsider the regmap? This driver is the only one use the
> regmap AFAICT and I don't think it is adequate.

Alexandre, maybe we could of_ioremap() the TCB region in this driver
and use regular readl to read TC_CV regs: those are attached to a
specific channel, so we shouldn't have concurrency issues here.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-08  6:52               ` Boris Brezillon
  0 siblings, 0 replies; 189+ messages in thread
From: Boris Brezillon @ 2017-06-08  6:52 UTC (permalink / raw)
  To: linux-arm-kernel

Le Wed, 7 Jun 2017 23:38:10 +0200,
Daniel Lezcano <daniel.lezcano@linaro.org> a ?crit :

> On Wed, Jun 07, 2017 at 05:09:08PM +0200, Alexandre Belloni wrote:
> > On 07/06/2017 at 16:17:35 +0200, Daniel Lezcano wrote:  
> > > > > > This driver uses regmap and syscon to be able to probe early in the boot
> > > > > > and avoid having to switch on the TCB clocksource later. Using regmap also
> > > > > > means that unused TCB channels may be used by other drivers (PWM for
> > > > > > example).  
> > > > > 
> > > > > Can you give more details, I fail to understand how regmap and syscon help to
> > > > > probe sooner than timer_init()?  
> > > > 
> > > > 
> > > > Because before that, the tcb driver relied on atmel_tclib to share the
> > > > TCBs and it happened way too late, at arch_initcall() time.  
> > > 
> > > So is it still necesary to use regmap? I would like to take the opportunity to
> > > move the init routine to the common init routine if possible:
> > > 
> > > 	https://patchwork.kernel.org/patch/9768845/
> > >   
> > 
> > It is still necessary because we want to be able to share the timer
> > between multiple drivers. For example, you can have the clocksource on
> > channel 0, clockevent on channel 1 and a pwm on channel 2  
> 
> The hardware timer can be shared, the channels used in different subsystem.
> 
> Each channel are used exclusively.

Yes, that's correct, but some registers are shared, and we need locking
to control accesses to these registers. There's one register in
particular that has to be protected against concurrent accesses:
TC_BMR. But this register is only written at init time, not in the hot
path.

> 
> What is the benefit of regmap? It has a cost, and takes a lock at each read.
> 
> For instance:
> 
> +static u64 tc_get_cycles(struct clocksource *cs)
> +{
> +	u32		lower, upper, tmp;
> +
> +	do {
> +		regmap_read(tc.regmap, ATMEL_TC_CV(1), &upper);
> +		regmap_read(tc.regmap, ATMEL_TC_CV(0), &lower);
> +		regmap_read(tc.regmap, ATMEL_TC_CV(1), &tmp);
> +	} while (upper != tmp);
> +
> +	return (upper << 16) | lower;
> +}
> 
> Is:
> 
> +static u64 tc_get_cycles(struct clocksource *cs)
> +{
> +	u32		lower, upper, tmp;
> +
> +	do {
> +		regmap_read(tc.regmap, ATMEL_TC_CV(1), &upper);
> 			lock();
> 			lot-of-things();
> 			unlock();
> +		regmap_read(tc.regmap, ATMEL_TC_CV(0), &lower);
> 			lock();
> 			lot-of-things();
> 			unlock();
> +		regmap_read(tc.regmap, ATMEL_TC_CV(1), &tmp);
> 			lock();
> 			lot-of-things();
> 			unlock();
> +	} while (upper != tmp);
> +
> +	return (upper << 16) | lower;
> +}
> 
> I suggest to look what is in 'lot-of-things()' and especially what is doing
> regcache_read().
> 
> May be you can reconsider the regmap? This driver is the only one use the
> regmap AFAICT and I don't think it is adequate.

Alexandre, maybe we could of_ioremap() the TCB region in this driver
and use regular readl to read TC_CV regs: those are attached to a
specific channel, so we shouldn't have concurrency issues here.

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-06-08  5:42                 ` Boris Brezillon
@ 2017-06-08  7:44                   ` Daniel Lezcano
  -1 siblings, 0 replies; 189+ messages in thread
From: Daniel Lezcano @ 2017-06-08  7:44 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Alexandre Belloni, Rob Herring, Nicolas Ferre, linux-arm-kernel,
	linux-kernel, Thomas Gleixner, devicetree


+Mark Rutland, +Rob Herring


Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html

That will tell you the story.

On Thu, Jun 08, 2017 at 07:42:36AM +0200, Boris Brezillon wrote:
> Le Thu, 8 Jun 2017 01:17:15 +0200,
> Alexandre Belloni <alexandre.belloni@free-electrons.com> a écrit :
> 
> > On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:
> > > > I was going to agree but this is not flexible enough because the
> > > > quadrature decoder always uses the first two channels. So on some
> > > > products, we may have:
> > > >  - TCB0:
> > > >    o channels 0,1: qdec
> > > >    o channel 2: clocksource
> > > > 
> > > >  - TCB1:
> > > >    o channels 0,1: qdec
> > > >    o channel 2: clockevent
> > > > 
> > > > This avoids wasting TCB channels.  
> > > 
> > > Ok. In this case you can check if the interrupt is specified for the node, if
> > > yes, then it is a clockevent.
> > >   
> > 
> > But currently it is always specified in the SoC's dtsi. I don't find
> > that too practical to push that to the board's dts. Also, lying by
> > omission (the IRQ is always wired) in the DT is not different from
> > having a property selecting which timer is the clocksource and which is
> > the clockevent.
> > 
> 
> I agree with Alexandre here. Really, there's not much we can do to
> detect which timer should be used as a clockevent and which one should
> be used as a clocksource except explicitly specifying it in the DT.
> Having an interrupt defined in one case (clockevent) and undefined in
> the other case (clocksource), is just as hack-ish as the detection logic
> Alexandre developed to avoid explicitly specifying the function
> assigned to a specific timer.
> 
> Can we please find a solution that makes everyone happy (DT,
> clocksoure/clockevent and at91 maintainers)?
> 
> How about adding a linux,timer-function property to specify which
> function this timer is providing?
> 
> Something like that for example:
> 
> 	tcb0: timer@fff7c000 {
> 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> 		#address-cells = <1>;
> 		#size-cells = <0>;
> 		reg = <0xfff7c000 0x100>;
> 		interrupts = <18 4>;
> 		clocks = <&tcb0_clk>, <&clk32k>;
> 		clock-names = "t0_clk", "slow_clk";
> 
> 		timer@0 {
> 			compatible = "atmel,tcb-timer";
> 			reg = <0>, <1>;
> 			linux,timer-function = "clocksource";
> 		};
> 
> 		timer@2 {
> 			compatible = "atmel,tcb-timer";
> 			reg = <2>;
> 			linux,timer-function = "clockevent";
> 		};
> 	};
> 
> Alternatively, we could have a property or a node in chosen describing which
> timer should be used:
> 
> 	chosen {
> 		clockevent {
> 			timer = <&timer2>;
> 		};
> 
> 		clocksource {
> 			timer = <&timer0>;
> 		};
> 
> 		/*
> 		 * or
> 		 *
> 		 * clockevent = <&timer2>;
> 		 * clocksource = <&timer0>;
> 		 *
> 		 * but I think the clocksource/clockevent node approach
> 		 * is more future proof in case we need to add extra
> 		 * information like the expected resolution/precision or
> 		 * anything that could be tweakable.
> 		 */
> 	};
> 
> 	tcb0: timer@fff7c000 {
> 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> 		#address-cells = <1>;
> 		#size-cells = <0>;
> 		reg = <0xfff7c000 0x100>;
> 		interrupts = <18 4>;
> 		clocks = <&tcb0_clk>, <&clk32k>;
> 		clock-names = "t0_clk", "slow_clk";
> 
> 		timer0: timer@0 {
> 			compatible = "atmel,tcb-timer";
> 			reg = <0>, <1>;
> 		};
> 
> 		timer2: timer@2 {
> 			compatible = "atmel,tcb-timer";
> 			reg = <2>;
> 		};
> 	};

-- 

 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-08  7:44                   ` Daniel Lezcano
  0 siblings, 0 replies; 189+ messages in thread
From: Daniel Lezcano @ 2017-06-08  7:44 UTC (permalink / raw)
  To: linux-arm-kernel


+Mark Rutland, +Rob Herring


Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html

That will tell you the story.

On Thu, Jun 08, 2017 at 07:42:36AM +0200, Boris Brezillon wrote:
> Le Thu, 8 Jun 2017 01:17:15 +0200,
> Alexandre Belloni <alexandre.belloni@free-electrons.com> a ?crit :
> 
> > On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:
> > > > I was going to agree but this is not flexible enough because the
> > > > quadrature decoder always uses the first two channels. So on some
> > > > products, we may have:
> > > >  - TCB0:
> > > >    o channels 0,1: qdec
> > > >    o channel 2: clocksource
> > > > 
> > > >  - TCB1:
> > > >    o channels 0,1: qdec
> > > >    o channel 2: clockevent
> > > > 
> > > > This avoids wasting TCB channels.  
> > > 
> > > Ok. In this case you can check if the interrupt is specified for the node, if
> > > yes, then it is a clockevent.
> > >   
> > 
> > But currently it is always specified in the SoC's dtsi. I don't find
> > that too practical to push that to the board's dts. Also, lying by
> > omission (the IRQ is always wired) in the DT is not different from
> > having a property selecting which timer is the clocksource and which is
> > the clockevent.
> > 
> 
> I agree with Alexandre here. Really, there's not much we can do to
> detect which timer should be used as a clockevent and which one should
> be used as a clocksource except explicitly specifying it in the DT.
> Having an interrupt defined in one case (clockevent) and undefined in
> the other case (clocksource), is just as hack-ish as the detection logic
> Alexandre developed to avoid explicitly specifying the function
> assigned to a specific timer.
> 
> Can we please find a solution that makes everyone happy (DT,
> clocksoure/clockevent and at91 maintainers)?
> 
> How about adding a linux,timer-function property to specify which
> function this timer is providing?
> 
> Something like that for example:
> 
> 	tcb0: timer at fff7c000 {
> 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> 		#address-cells = <1>;
> 		#size-cells = <0>;
> 		reg = <0xfff7c000 0x100>;
> 		interrupts = <18 4>;
> 		clocks = <&tcb0_clk>, <&clk32k>;
> 		clock-names = "t0_clk", "slow_clk";
> 
> 		timer at 0 {
> 			compatible = "atmel,tcb-timer";
> 			reg = <0>, <1>;
> 			linux,timer-function = "clocksource";
> 		};
> 
> 		timer at 2 {
> 			compatible = "atmel,tcb-timer";
> 			reg = <2>;
> 			linux,timer-function = "clockevent";
> 		};
> 	};
> 
> Alternatively, we could have a property or a node in chosen describing which
> timer should be used:
> 
> 	chosen {
> 		clockevent {
> 			timer = <&timer2>;
> 		};
> 
> 		clocksource {
> 			timer = <&timer0>;
> 		};
> 
> 		/*
> 		 * or
> 		 *
> 		 * clockevent = <&timer2>;
> 		 * clocksource = <&timer0>;
> 		 *
> 		 * but I think the clocksource/clockevent node approach
> 		 * is more future proof in case we need to add extra
> 		 * information like the expected resolution/precision or
> 		 * anything that could be tweakable.
> 		 */
> 	};
> 
> 	tcb0: timer at fff7c000 {
> 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> 		#address-cells = <1>;
> 		#size-cells = <0>;
> 		reg = <0xfff7c000 0x100>;
> 		interrupts = <18 4>;
> 		clocks = <&tcb0_clk>, <&clk32k>;
> 		clock-names = "t0_clk", "slow_clk";
> 
> 		timer0: timer at 0 {
> 			compatible = "atmel,tcb-timer";
> 			reg = <0>, <1>;
> 		};
> 
> 		timer2: timer at 2 {
> 			compatible = "atmel,tcb-timer";
> 			reg = <2>;
> 		};
> 	};

-- 

 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-06-08  7:44                   ` Daniel Lezcano
  (?)
@ 2017-06-08  7:59                     ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-06-08  7:59 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Boris Brezillon, Rob Herring, Nicolas Ferre, linux-arm-kernel,
	linux-kernel, Thomas Gleixner, devicetree

On 08/06/2017 at 09:44:46 +0200, Daniel Lezcano wrote:
> 
> +Mark Rutland, +Rob Herring
> 
> 
> Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
> 
> That will tell you the story.
> 

Ok, so is the solution putting the driver back in mach-at91 were we can
do whatever we want like mach-omap2 is doing?

> On Thu, Jun 08, 2017 at 07:42:36AM +0200, Boris Brezillon wrote:
> > Le Thu, 8 Jun 2017 01:17:15 +0200,
> > Alexandre Belloni <alexandre.belloni@free-electrons.com> a écrit :
> > 
> > > On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:
> > > > > I was going to agree but this is not flexible enough because the
> > > > > quadrature decoder always uses the first two channels. So on some
> > > > > products, we may have:
> > > > >  - TCB0:
> > > > >    o channels 0,1: qdec
> > > > >    o channel 2: clocksource
> > > > > 
> > > > >  - TCB1:
> > > > >    o channels 0,1: qdec
> > > > >    o channel 2: clockevent
> > > > > 
> > > > > This avoids wasting TCB channels.  
> > > > 
> > > > Ok. In this case you can check if the interrupt is specified for the node, if
> > > > yes, then it is a clockevent.
> > > >   
> > > 
> > > But currently it is always specified in the SoC's dtsi. I don't find
> > > that too practical to push that to the board's dts. Also, lying by
> > > omission (the IRQ is always wired) in the DT is not different from
> > > having a property selecting which timer is the clocksource and which is
> > > the clockevent.
> > > 
> > 
> > I agree with Alexandre here. Really, there's not much we can do to
> > detect which timer should be used as a clockevent and which one should
> > be used as a clocksource except explicitly specifying it in the DT.
> > Having an interrupt defined in one case (clockevent) and undefined in
> > the other case (clocksource), is just as hack-ish as the detection logic
> > Alexandre developed to avoid explicitly specifying the function
> > assigned to a specific timer.
> > 
> > Can we please find a solution that makes everyone happy (DT,
> > clocksoure/clockevent and at91 maintainers)?
> > 
> > How about adding a linux,timer-function property to specify which
> > function this timer is providing?
> > 
> > Something like that for example:
> > 
> > 	tcb0: timer@fff7c000 {
> > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > 		#address-cells = <1>;
> > 		#size-cells = <0>;
> > 		reg = <0xfff7c000 0x100>;
> > 		interrupts = <18 4>;
> > 		clocks = <&tcb0_clk>, <&clk32k>;
> > 		clock-names = "t0_clk", "slow_clk";
> > 
> > 		timer@0 {
> > 			compatible = "atmel,tcb-timer";
> > 			reg = <0>, <1>;
> > 			linux,timer-function = "clocksource";
> > 		};
> > 
> > 		timer@2 {
> > 			compatible = "atmel,tcb-timer";
> > 			reg = <2>;
> > 			linux,timer-function = "clockevent";
> > 		};
> > 	};
> > 
> > Alternatively, we could have a property or a node in chosen describing which
> > timer should be used:
> > 
> > 	chosen {
> > 		clockevent {
> > 			timer = <&timer2>;
> > 		};
> > 
> > 		clocksource {
> > 			timer = <&timer0>;
> > 		};
> > 
> > 		/*
> > 		 * or
> > 		 *
> > 		 * clockevent = <&timer2>;
> > 		 * clocksource = <&timer0>;
> > 		 *
> > 		 * but I think the clocksource/clockevent node approach
> > 		 * is more future proof in case we need to add extra
> > 		 * information like the expected resolution/precision or
> > 		 * anything that could be tweakable.
> > 		 */
> > 	};
> > 
> > 	tcb0: timer@fff7c000 {
> > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > 		#address-cells = <1>;
> > 		#size-cells = <0>;
> > 		reg = <0xfff7c000 0x100>;
> > 		interrupts = <18 4>;
> > 		clocks = <&tcb0_clk>, <&clk32k>;
> > 		clock-names = "t0_clk", "slow_clk";
> > 
> > 		timer0: timer@0 {
> > 			compatible = "atmel,tcb-timer";
> > 			reg = <0>, <1>;
> > 		};
> > 
> > 		timer2: timer@2 {
> > 			compatible = "atmel,tcb-timer";
> > 			reg = <2>;
> > 		};
> > 	};
> 
> -- 
> 
>  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
> 
> Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
> <http://twitter.com/#!/linaroorg> Twitter |
> <http://www.linaro.org/linaro-blog/> Blog

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-08  7:59                     ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-06-08  7:59 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Boris Brezillon, Rob Herring, Nicolas Ferre,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Thomas Gleixner,
	devicetree-u79uwXL29TY76Z2rM5mHXA

On 08/06/2017 at 09:44:46 +0200, Daniel Lezcano wrote:
> 
> +Mark Rutland, +Rob Herring
> 
> 
> Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
> 
> That will tell you the story.
> 

Ok, so is the solution putting the driver back in mach-at91 were we can
do whatever we want like mach-omap2 is doing?

> On Thu, Jun 08, 2017 at 07:42:36AM +0200, Boris Brezillon wrote:
> > Le Thu, 8 Jun 2017 01:17:15 +0200,
> > Alexandre Belloni <alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> a écrit :
> > 
> > > On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:
> > > > > I was going to agree but this is not flexible enough because the
> > > > > quadrature decoder always uses the first two channels. So on some
> > > > > products, we may have:
> > > > >  - TCB0:
> > > > >    o channels 0,1: qdec
> > > > >    o channel 2: clocksource
> > > > > 
> > > > >  - TCB1:
> > > > >    o channels 0,1: qdec
> > > > >    o channel 2: clockevent
> > > > > 
> > > > > This avoids wasting TCB channels.  
> > > > 
> > > > Ok. In this case you can check if the interrupt is specified for the node, if
> > > > yes, then it is a clockevent.
> > > >   
> > > 
> > > But currently it is always specified in the SoC's dtsi. I don't find
> > > that too practical to push that to the board's dts. Also, lying by
> > > omission (the IRQ is always wired) in the DT is not different from
> > > having a property selecting which timer is the clocksource and which is
> > > the clockevent.
> > > 
> > 
> > I agree with Alexandre here. Really, there's not much we can do to
> > detect which timer should be used as a clockevent and which one should
> > be used as a clocksource except explicitly specifying it in the DT.
> > Having an interrupt defined in one case (clockevent) and undefined in
> > the other case (clocksource), is just as hack-ish as the detection logic
> > Alexandre developed to avoid explicitly specifying the function
> > assigned to a specific timer.
> > 
> > Can we please find a solution that makes everyone happy (DT,
> > clocksoure/clockevent and at91 maintainers)?
> > 
> > How about adding a linux,timer-function property to specify which
> > function this timer is providing?
> > 
> > Something like that for example:
> > 
> > 	tcb0: timer@fff7c000 {
> > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > 		#address-cells = <1>;
> > 		#size-cells = <0>;
> > 		reg = <0xfff7c000 0x100>;
> > 		interrupts = <18 4>;
> > 		clocks = <&tcb0_clk>, <&clk32k>;
> > 		clock-names = "t0_clk", "slow_clk";
> > 
> > 		timer@0 {
> > 			compatible = "atmel,tcb-timer";
> > 			reg = <0>, <1>;
> > 			linux,timer-function = "clocksource";
> > 		};
> > 
> > 		timer@2 {
> > 			compatible = "atmel,tcb-timer";
> > 			reg = <2>;
> > 			linux,timer-function = "clockevent";
> > 		};
> > 	};
> > 
> > Alternatively, we could have a property or a node in chosen describing which
> > timer should be used:
> > 
> > 	chosen {
> > 		clockevent {
> > 			timer = <&timer2>;
> > 		};
> > 
> > 		clocksource {
> > 			timer = <&timer0>;
> > 		};
> > 
> > 		/*
> > 		 * or
> > 		 *
> > 		 * clockevent = <&timer2>;
> > 		 * clocksource = <&timer0>;
> > 		 *
> > 		 * but I think the clocksource/clockevent node approach
> > 		 * is more future proof in case we need to add extra
> > 		 * information like the expected resolution/precision or
> > 		 * anything that could be tweakable.
> > 		 */
> > 	};
> > 
> > 	tcb0: timer@fff7c000 {
> > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > 		#address-cells = <1>;
> > 		#size-cells = <0>;
> > 		reg = <0xfff7c000 0x100>;
> > 		interrupts = <18 4>;
> > 		clocks = <&tcb0_clk>, <&clk32k>;
> > 		clock-names = "t0_clk", "slow_clk";
> > 
> > 		timer0: timer@0 {
> > 			compatible = "atmel,tcb-timer";
> > 			reg = <0>, <1>;
> > 		};
> > 
> > 		timer2: timer@2 {
> > 			compatible = "atmel,tcb-timer";
> > 			reg = <2>;
> > 		};
> > 	};
> 
> -- 
> 
>  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
> 
> Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
> <http://twitter.com/#!/linaroorg> Twitter |
> <http://www.linaro.org/linaro-blog/> Blog

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-08  7:59                     ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-06-08  7:59 UTC (permalink / raw)
  To: linux-arm-kernel

On 08/06/2017 at 09:44:46 +0200, Daniel Lezcano wrote:
> 
> +Mark Rutland, +Rob Herring
> 
> 
> Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
> 
> That will tell you the story.
> 

Ok, so is the solution putting the driver back in mach-at91 were we can
do whatever we want like mach-omap2 is doing?

> On Thu, Jun 08, 2017 at 07:42:36AM +0200, Boris Brezillon wrote:
> > Le Thu, 8 Jun 2017 01:17:15 +0200,
> > Alexandre Belloni <alexandre.belloni@free-electrons.com> a ?crit :
> > 
> > > On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:
> > > > > I was going to agree but this is not flexible enough because the
> > > > > quadrature decoder always uses the first two channels. So on some
> > > > > products, we may have:
> > > > >  - TCB0:
> > > > >    o channels 0,1: qdec
> > > > >    o channel 2: clocksource
> > > > > 
> > > > >  - TCB1:
> > > > >    o channels 0,1: qdec
> > > > >    o channel 2: clockevent
> > > > > 
> > > > > This avoids wasting TCB channels.  
> > > > 
> > > > Ok. In this case you can check if the interrupt is specified for the node, if
> > > > yes, then it is a clockevent.
> > > >   
> > > 
> > > But currently it is always specified in the SoC's dtsi. I don't find
> > > that too practical to push that to the board's dts. Also, lying by
> > > omission (the IRQ is always wired) in the DT is not different from
> > > having a property selecting which timer is the clocksource and which is
> > > the clockevent.
> > > 
> > 
> > I agree with Alexandre here. Really, there's not much we can do to
> > detect which timer should be used as a clockevent and which one should
> > be used as a clocksource except explicitly specifying it in the DT.
> > Having an interrupt defined in one case (clockevent) and undefined in
> > the other case (clocksource), is just as hack-ish as the detection logic
> > Alexandre developed to avoid explicitly specifying the function
> > assigned to a specific timer.
> > 
> > Can we please find a solution that makes everyone happy (DT,
> > clocksoure/clockevent and at91 maintainers)?
> > 
> > How about adding a linux,timer-function property to specify which
> > function this timer is providing?
> > 
> > Something like that for example:
> > 
> > 	tcb0: timer at fff7c000 {
> > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > 		#address-cells = <1>;
> > 		#size-cells = <0>;
> > 		reg = <0xfff7c000 0x100>;
> > 		interrupts = <18 4>;
> > 		clocks = <&tcb0_clk>, <&clk32k>;
> > 		clock-names = "t0_clk", "slow_clk";
> > 
> > 		timer at 0 {
> > 			compatible = "atmel,tcb-timer";
> > 			reg = <0>, <1>;
> > 			linux,timer-function = "clocksource";
> > 		};
> > 
> > 		timer at 2 {
> > 			compatible = "atmel,tcb-timer";
> > 			reg = <2>;
> > 			linux,timer-function = "clockevent";
> > 		};
> > 	};
> > 
> > Alternatively, we could have a property or a node in chosen describing which
> > timer should be used:
> > 
> > 	chosen {
> > 		clockevent {
> > 			timer = <&timer2>;
> > 		};
> > 
> > 		clocksource {
> > 			timer = <&timer0>;
> > 		};
> > 
> > 		/*
> > 		 * or
> > 		 *
> > 		 * clockevent = <&timer2>;
> > 		 * clocksource = <&timer0>;
> > 		 *
> > 		 * but I think the clocksource/clockevent node approach
> > 		 * is more future proof in case we need to add extra
> > 		 * information like the expected resolution/precision or
> > 		 * anything that could be tweakable.
> > 		 */
> > 	};
> > 
> > 	tcb0: timer at fff7c000 {
> > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > 		#address-cells = <1>;
> > 		#size-cells = <0>;
> > 		reg = <0xfff7c000 0x100>;
> > 		interrupts = <18 4>;
> > 		clocks = <&tcb0_clk>, <&clk32k>;
> > 		clock-names = "t0_clk", "slow_clk";
> > 
> > 		timer0: timer at 0 {
> > 			compatible = "atmel,tcb-timer";
> > 			reg = <0>, <1>;
> > 		};
> > 
> > 		timer2: timer at 2 {
> > 			compatible = "atmel,tcb-timer";
> > 			reg = <2>;
> > 		};
> > 	};
> 
> -- 
> 
>  <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs
> 
> Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
> <http://twitter.com/#!/linaroorg> Twitter |
> <http://www.linaro.org/linaro-blog/> Blog

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-06-08  7:44                   ` Daniel Lezcano
@ 2017-06-08  8:13                     ` Boris Brezillon
  -1 siblings, 0 replies; 189+ messages in thread
From: Boris Brezillon @ 2017-06-08  8:13 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Alexandre Belloni, Rob Herring, Nicolas Ferre, linux-arm-kernel,
	linux-kernel, Thomas Gleixner, devicetree, Mark Rutland

On Thu, 8 Jun 2017 09:44:46 +0200
Daniel Lezcano <daniel.lezcano@linaro.org> wrote:

> +Mark Rutland, +Rob Herring

Mark doesn't seem to be CCed.

> 
> 
> Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
> 
> That will tell you the story.

Then we're in a deadlock situation here. I'm tired of hearing this kind
of argument "DT is only supposed to describe HW, not configuration, bla
bla". The truth is, we already have plenty of bindings that do not
strictly describe HW.

A simple example: ECC configuration on NAND devices. This is clearly a
configuration thing, the NAND controller is usually able to support
several kind of strength+ECC-block-size config, but we are able to
overload this with the nand-ecc-xxx properties. Another example, still
MTD related: MTD partitions, this is purely a software configuration,
still we allow users to pass this information in the DT. You want
another one? What about the linux,code and linux,input-type properties
described here [1]?

So please, let's not use these "this is not decribing HW" or "this is
linux specific" arguments every time someone tries to encode something
that can be considered a configuration detail.

Let's be pragmatic. How you want to use your timer counter blocks (I'm
talking about atmel TCBs) is clearly board specific. Whether you want
to use the PIT for your clocksource or use one or 2 channels of a TCB
at a specific resolution is again board specific. We need a solution to
assign timer channels to a linux function, and I'm not convinced
passing this information through the command line makes much more sense
than specifying it in the DT (and it's definitely less intuitive, since
you have to reference something defined in the DT from the cmdline).

Now, in his review, Mark says:

"
To me it sounds like what we need is Linux infrastructure that allows
one to register a device as having both clockevent/clocksource
functionality.

That way, we can choose to do something sane at boot time, and if the
user really wants specific devices used in specific ways, they can
request that.
"

Does that mean that, after adding this "HW timer" infrastructure, we
would have a standard way to assign a function to a specific timer
block from the DT? How is this different from what I suggest below
(note the linux, prefix on my linux,timer-function property, which
clearly shows that this is Linux specific)?

> 
> On Thu, Jun 08, 2017 at 07:42:36AM +0200, Boris Brezillon wrote:
> > Le Thu, 8 Jun 2017 01:17:15 +0200,
> > Alexandre Belloni <alexandre.belloni@free-electrons.com> a écrit :
> >   
> > > On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:  
> > > > > I was going to agree but this is not flexible enough because the
> > > > > quadrature decoder always uses the first two channels. So on some
> > > > > products, we may have:
> > > > >  - TCB0:
> > > > >    o channels 0,1: qdec
> > > > >    o channel 2: clocksource
> > > > > 
> > > > >  - TCB1:
> > > > >    o channels 0,1: qdec
> > > > >    o channel 2: clockevent
> > > > > 
> > > > > This avoids wasting TCB channels.    
> > > > 
> > > > Ok. In this case you can check if the interrupt is specified for the node, if
> > > > yes, then it is a clockevent.
> > > >     
> > > 
> > > But currently it is always specified in the SoC's dtsi. I don't find
> > > that too practical to push that to the board's dts. Also, lying by
> > > omission (the IRQ is always wired) in the DT is not different from
> > > having a property selecting which timer is the clocksource and which is
> > > the clockevent.
> > >   
> > 
> > I agree with Alexandre here. Really, there's not much we can do to
> > detect which timer should be used as a clockevent and which one should
> > be used as a clocksource except explicitly specifying it in the DT.
> > Having an interrupt defined in one case (clockevent) and undefined in
> > the other case (clocksource), is just as hack-ish as the detection logic
> > Alexandre developed to avoid explicitly specifying the function
> > assigned to a specific timer.
> > 
> > Can we please find a solution that makes everyone happy (DT,
> > clocksoure/clockevent and at91 maintainers)?
> > 
> > How about adding a linux,timer-function property to specify which
> > function this timer is providing?
> > 
> > Something like that for example:
> > 
> > 	tcb0: timer@fff7c000 {
> > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > 		#address-cells = <1>;
> > 		#size-cells = <0>;
> > 		reg = <0xfff7c000 0x100>;
> > 		interrupts = <18 4>;
> > 		clocks = <&tcb0_clk>, <&clk32k>;
> > 		clock-names = "t0_clk", "slow_clk";
> > 
> > 		timer@0 {
> > 			compatible = "atmel,tcb-timer";
> > 			reg = <0>, <1>;
> > 			linux,timer-function = "clocksource";
> > 		};
> > 
> > 		timer@2 {
> > 			compatible = "atmel,tcb-timer";
> > 			reg = <2>;
> > 			linux,timer-function = "clockevent";
> > 		};
> > 	};
> > 
> > Alternatively, we could have a property or a node in chosen describing which
> > timer should be used:
> > 
> > 	chosen {
> > 		clockevent {
> > 			timer = <&timer2>;
> > 		};
> > 
> > 		clocksource {
> > 			timer = <&timer0>;
> > 		};
> > 
> > 		/*
> > 		 * or
> > 		 *
> > 		 * clockevent = <&timer2>;
> > 		 * clocksource = <&timer0>;
> > 		 *
> > 		 * but I think the clocksource/clockevent node approach
> > 		 * is more future proof in case we need to add extra
> > 		 * information like the expected resolution/precision or
> > 		 * anything that could be tweakable.
> > 		 */
> > 	};
> > 
> > 	tcb0: timer@fff7c000 {
> > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > 		#address-cells = <1>;
> > 		#size-cells = <0>;
> > 		reg = <0xfff7c000 0x100>;
> > 		interrupts = <18 4>;
> > 		clocks = <&tcb0_clk>, <&clk32k>;
> > 		clock-names = "t0_clk", "slow_clk";
> > 
> > 		timer0: timer@0 {
> > 			compatible = "atmel,tcb-timer";
> > 			reg = <0>, <1>;
> > 		};
> > 
> > 		timer2: timer@2 {
> > 			compatible = "atmel,tcb-timer";
> > 			reg = <2>;
> > 		};
> > 	};  
> 

[1]http://elixir.free-electrons.com/linux/latest/source/Documentation/devicetree/bindings/input/gpio-keys.txt

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-08  8:13                     ` Boris Brezillon
  0 siblings, 0 replies; 189+ messages in thread
From: Boris Brezillon @ 2017-06-08  8:13 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 8 Jun 2017 09:44:46 +0200
Daniel Lezcano <daniel.lezcano@linaro.org> wrote:

> +Mark Rutland, +Rob Herring

Mark doesn't seem to be CCed.

> 
> 
> Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
> 
> That will tell you the story.

Then we're in a deadlock situation here. I'm tired of hearing this kind
of argument "DT is only supposed to describe HW, not configuration, bla
bla". The truth is, we already have plenty of bindings that do not
strictly describe HW.

A simple example: ECC configuration on NAND devices. This is clearly a
configuration thing, the NAND controller is usually able to support
several kind of strength+ECC-block-size config, but we are able to
overload this with the nand-ecc-xxx properties. Another example, still
MTD related: MTD partitions, this is purely a software configuration,
still we allow users to pass this information in the DT. You want
another one? What about the linux,code and linux,input-type properties
described here [1]?

So please, let's not use these "this is not decribing HW" or "this is
linux specific" arguments every time someone tries to encode something
that can be considered a configuration detail.

Let's be pragmatic. How you want to use your timer counter blocks (I'm
talking about atmel TCBs) is clearly board specific. Whether you want
to use the PIT for your clocksource or use one or 2 channels of a TCB
at a specific resolution is again board specific. We need a solution to
assign timer channels to a linux function, and I'm not convinced
passing this information through the command line makes much more sense
than specifying it in the DT (and it's definitely less intuitive, since
you have to reference something defined in the DT from the cmdline).

Now, in his review, Mark says:

"
To me it sounds like what we need is Linux infrastructure that allows
one to register a device as having both clockevent/clocksource
functionality.

That way, we can choose to do something sane at boot time, and if the
user really wants specific devices used in specific ways, they can
request that.
"

Does that mean that, after adding this "HW timer" infrastructure, we
would have a standard way to assign a function to a specific timer
block from the DT? How is this different from what I suggest below
(note the linux, prefix on my linux,timer-function property, which
clearly shows that this is Linux specific)?

> 
> On Thu, Jun 08, 2017 at 07:42:36AM +0200, Boris Brezillon wrote:
> > Le Thu, 8 Jun 2017 01:17:15 +0200,
> > Alexandre Belloni <alexandre.belloni@free-electrons.com> a ?crit :
> >   
> > > On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:  
> > > > > I was going to agree but this is not flexible enough because the
> > > > > quadrature decoder always uses the first two channels. So on some
> > > > > products, we may have:
> > > > >  - TCB0:
> > > > >    o channels 0,1: qdec
> > > > >    o channel 2: clocksource
> > > > > 
> > > > >  - TCB1:
> > > > >    o channels 0,1: qdec
> > > > >    o channel 2: clockevent
> > > > > 
> > > > > This avoids wasting TCB channels.    
> > > > 
> > > > Ok. In this case you can check if the interrupt is specified for the node, if
> > > > yes, then it is a clockevent.
> > > >     
> > > 
> > > But currently it is always specified in the SoC's dtsi. I don't find
> > > that too practical to push that to the board's dts. Also, lying by
> > > omission (the IRQ is always wired) in the DT is not different from
> > > having a property selecting which timer is the clocksource and which is
> > > the clockevent.
> > >   
> > 
> > I agree with Alexandre here. Really, there's not much we can do to
> > detect which timer should be used as a clockevent and which one should
> > be used as a clocksource except explicitly specifying it in the DT.
> > Having an interrupt defined in one case (clockevent) and undefined in
> > the other case (clocksource), is just as hack-ish as the detection logic
> > Alexandre developed to avoid explicitly specifying the function
> > assigned to a specific timer.
> > 
> > Can we please find a solution that makes everyone happy (DT,
> > clocksoure/clockevent and at91 maintainers)?
> > 
> > How about adding a linux,timer-function property to specify which
> > function this timer is providing?
> > 
> > Something like that for example:
> > 
> > 	tcb0: timer at fff7c000 {
> > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > 		#address-cells = <1>;
> > 		#size-cells = <0>;
> > 		reg = <0xfff7c000 0x100>;
> > 		interrupts = <18 4>;
> > 		clocks = <&tcb0_clk>, <&clk32k>;
> > 		clock-names = "t0_clk", "slow_clk";
> > 
> > 		timer at 0 {
> > 			compatible = "atmel,tcb-timer";
> > 			reg = <0>, <1>;
> > 			linux,timer-function = "clocksource";
> > 		};
> > 
> > 		timer at 2 {
> > 			compatible = "atmel,tcb-timer";
> > 			reg = <2>;
> > 			linux,timer-function = "clockevent";
> > 		};
> > 	};
> > 
> > Alternatively, we could have a property or a node in chosen describing which
> > timer should be used:
> > 
> > 	chosen {
> > 		clockevent {
> > 			timer = <&timer2>;
> > 		};
> > 
> > 		clocksource {
> > 			timer = <&timer0>;
> > 		};
> > 
> > 		/*
> > 		 * or
> > 		 *
> > 		 * clockevent = <&timer2>;
> > 		 * clocksource = <&timer0>;
> > 		 *
> > 		 * but I think the clocksource/clockevent node approach
> > 		 * is more future proof in case we need to add extra
> > 		 * information like the expected resolution/precision or
> > 		 * anything that could be tweakable.
> > 		 */
> > 	};
> > 
> > 	tcb0: timer at fff7c000 {
> > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > 		#address-cells = <1>;
> > 		#size-cells = <0>;
> > 		reg = <0xfff7c000 0x100>;
> > 		interrupts = <18 4>;
> > 		clocks = <&tcb0_clk>, <&clk32k>;
> > 		clock-names = "t0_clk", "slow_clk";
> > 
> > 		timer0: timer at 0 {
> > 			compatible = "atmel,tcb-timer";
> > 			reg = <0>, <1>;
> > 		};
> > 
> > 		timer2: timer at 2 {
> > 			compatible = "atmel,tcb-timer";
> > 			reg = <2>;
> > 		};
> > 	};  
> 

[1]http://elixir.free-electrons.com/linux/latest/source/Documentation/devicetree/bindings/input/gpio-keys.txt

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-06-08  7:59                     ` Alexandre Belloni
@ 2017-06-08  8:24                       ` Daniel Lezcano
  -1 siblings, 0 replies; 189+ messages in thread
From: Daniel Lezcano @ 2017-06-08  8:24 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Boris Brezillon, Rob Herring, Nicolas Ferre, linux-arm-kernel,
	linux-kernel, Thomas Gleixner, devicetree

On Thu, Jun 08, 2017 at 09:59:01AM +0200, Alexandre Belloni wrote:
> On 08/06/2017 at 09:44:46 +0200, Daniel Lezcano wrote:
> > 
> > +Mark Rutland, +Rob Herring
> > 
> > 
> > Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
> > 
> > That will tell you the story.
> > 
> 
> Ok, so is the solution putting the driver back in mach-at91 were we can
> do whatever we want like mach-omap2 is doing?

No. And putting a driver in mach-<whatever> does not give the permission to do
whatever you want. I won't tell you how OSS works, but moving code around or
using another tree to circumvent a code review is just the best way to upset
maintainers in general and hurt your karma.

That said, I think you misunderstood my comment (or I was not clear). In the
discussion given in the link above, I am in favor, somehow, to distinguish
clockevent and clocksource to solve exactly what you are facing.

Rob Herring told me it could be acceptable to have a property to tell if it is
a clockevent or a clocksource.

Mark Rutland disagreed on this.

I was alone in the discussion, no consensus have been found.

Now, you have a particular use case and I would like to resurrect the
discussion in order to find a solution which can apply to all DT drivers.

> > On Thu, Jun 08, 2017 at 07:42:36AM +0200, Boris Brezillon wrote:
> > > Le Thu, 8 Jun 2017 01:17:15 +0200,
> > > Alexandre Belloni <alexandre.belloni@free-electrons.com> a écrit :
> > > 
> > > > On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:
> > > > > > I was going to agree but this is not flexible enough because the
> > > > > > quadrature decoder always uses the first two channels. So on some
> > > > > > products, we may have:
> > > > > >  - TCB0:
> > > > > >    o channels 0,1: qdec
> > > > > >    o channel 2: clocksource
> > > > > > 
> > > > > >  - TCB1:
> > > > > >    o channels 0,1: qdec
> > > > > >    o channel 2: clockevent
> > > > > > 
> > > > > > This avoids wasting TCB channels.  
> > > > > 
> > > > > Ok. In this case you can check if the interrupt is specified for the node, if
> > > > > yes, then it is a clockevent.
> > > > >   
> > > > 
> > > > But currently it is always specified in the SoC's dtsi. I don't find
> > > > that too practical to push that to the board's dts. Also, lying by
> > > > omission (the IRQ is always wired) in the DT is not different from
> > > > having a property selecting which timer is the clocksource and which is
> > > > the clockevent.
> > > > 
> > > 
> > > I agree with Alexandre here. Really, there's not much we can do to
> > > detect which timer should be used as a clockevent and which one should
> > > be used as a clocksource except explicitly specifying it in the DT.
> > > Having an interrupt defined in one case (clockevent) and undefined in
> > > the other case (clocksource), is just as hack-ish as the detection logic
> > > Alexandre developed to avoid explicitly specifying the function
> > > assigned to a specific timer.
> > > 
> > > Can we please find a solution that makes everyone happy (DT,
> > > clocksoure/clockevent and at91 maintainers)?
> > > 
> > > How about adding a linux,timer-function property to specify which
> > > function this timer is providing?
> > > 
> > > Something like that for example:
> > > 
> > > 	tcb0: timer@fff7c000 {
> > > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > > 		#address-cells = <1>;
> > > 		#size-cells = <0>;
> > > 		reg = <0xfff7c000 0x100>;
> > > 		interrupts = <18 4>;
> > > 		clocks = <&tcb0_clk>, <&clk32k>;
> > > 		clock-names = "t0_clk", "slow_clk";
> > > 
> > > 		timer@0 {
> > > 			compatible = "atmel,tcb-timer";
> > > 			reg = <0>, <1>;
> > > 			linux,timer-function = "clocksource";
> > > 		};
> > > 
> > > 		timer@2 {
> > > 			compatible = "atmel,tcb-timer";
> > > 			reg = <2>;
> > > 			linux,timer-function = "clockevent";
> > > 		};
> > > 	};
> > > 
> > > Alternatively, we could have a property or a node in chosen describing which
> > > timer should be used:
> > > 
> > > 	chosen {
> > > 		clockevent {
> > > 			timer = <&timer2>;
> > > 		};
> > > 
> > > 		clocksource {
> > > 			timer = <&timer0>;
> > > 		};
> > > 
> > > 		/*
> > > 		 * or
> > > 		 *
> > > 		 * clockevent = <&timer2>;
> > > 		 * clocksource = <&timer0>;
> > > 		 *
> > > 		 * but I think the clocksource/clockevent node approach
> > > 		 * is more future proof in case we need to add extra
> > > 		 * information like the expected resolution/precision or
> > > 		 * anything that could be tweakable.
> > > 		 */
> > > 	};
> > > 
> > > 	tcb0: timer@fff7c000 {
> > > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > > 		#address-cells = <1>;
> > > 		#size-cells = <0>;
> > > 		reg = <0xfff7c000 0x100>;
> > > 		interrupts = <18 4>;
> > > 		clocks = <&tcb0_clk>, <&clk32k>;
> > > 		clock-names = "t0_clk", "slow_clk";
> > > 
> > > 		timer0: timer@0 {
> > > 			compatible = "atmel,tcb-timer";
> > > 			reg = <0>, <1>;
> > > 		};
> > > 
> > > 		timer2: timer@2 {
> > > 			compatible = "atmel,tcb-timer";
> > > 			reg = <2>;
> > > 		};
> > > 	};
> > 
> > -- 
> > 
> >  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
> > 
> > Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
> > <http://twitter.com/#!/linaroorg> Twitter |
> > <http://www.linaro.org/linaro-blog/> Blog
> 
> -- 
> Alexandre Belloni, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com

-- 

 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-08  8:24                       ` Daniel Lezcano
  0 siblings, 0 replies; 189+ messages in thread
From: Daniel Lezcano @ 2017-06-08  8:24 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jun 08, 2017 at 09:59:01AM +0200, Alexandre Belloni wrote:
> On 08/06/2017 at 09:44:46 +0200, Daniel Lezcano wrote:
> > 
> > +Mark Rutland, +Rob Herring
> > 
> > 
> > Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
> > 
> > That will tell you the story.
> > 
> 
> Ok, so is the solution putting the driver back in mach-at91 were we can
> do whatever we want like mach-omap2 is doing?

No. And putting a driver in mach-<whatever> does not give the permission to do
whatever you want. I won't tell you how OSS works, but moving code around or
using another tree to circumvent a code review is just the best way to upset
maintainers in general and hurt your karma.

That said, I think you misunderstood my comment (or I was not clear). In the
discussion given in the link above, I am in favor, somehow, to distinguish
clockevent and clocksource to solve exactly what you are facing.

Rob Herring told me it could be acceptable to have a property to tell if it is
a clockevent or a clocksource.

Mark Rutland disagreed on this.

I was alone in the discussion, no consensus have been found.

Now, you have a particular use case and I would like to resurrect the
discussion in order to find a solution which can apply to all DT drivers.

> > On Thu, Jun 08, 2017 at 07:42:36AM +0200, Boris Brezillon wrote:
> > > Le Thu, 8 Jun 2017 01:17:15 +0200,
> > > Alexandre Belloni <alexandre.belloni@free-electrons.com> a ?crit :
> > > 
> > > > On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:
> > > > > > I was going to agree but this is not flexible enough because the
> > > > > > quadrature decoder always uses the first two channels. So on some
> > > > > > products, we may have:
> > > > > >  - TCB0:
> > > > > >    o channels 0,1: qdec
> > > > > >    o channel 2: clocksource
> > > > > > 
> > > > > >  - TCB1:
> > > > > >    o channels 0,1: qdec
> > > > > >    o channel 2: clockevent
> > > > > > 
> > > > > > This avoids wasting TCB channels.  
> > > > > 
> > > > > Ok. In this case you can check if the interrupt is specified for the node, if
> > > > > yes, then it is a clockevent.
> > > > >   
> > > > 
> > > > But currently it is always specified in the SoC's dtsi. I don't find
> > > > that too practical to push that to the board's dts. Also, lying by
> > > > omission (the IRQ is always wired) in the DT is not different from
> > > > having a property selecting which timer is the clocksource and which is
> > > > the clockevent.
> > > > 
> > > 
> > > I agree with Alexandre here. Really, there's not much we can do to
> > > detect which timer should be used as a clockevent and which one should
> > > be used as a clocksource except explicitly specifying it in the DT.
> > > Having an interrupt defined in one case (clockevent) and undefined in
> > > the other case (clocksource), is just as hack-ish as the detection logic
> > > Alexandre developed to avoid explicitly specifying the function
> > > assigned to a specific timer.
> > > 
> > > Can we please find a solution that makes everyone happy (DT,
> > > clocksoure/clockevent and at91 maintainers)?
> > > 
> > > How about adding a linux,timer-function property to specify which
> > > function this timer is providing?
> > > 
> > > Something like that for example:
> > > 
> > > 	tcb0: timer at fff7c000 {
> > > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > > 		#address-cells = <1>;
> > > 		#size-cells = <0>;
> > > 		reg = <0xfff7c000 0x100>;
> > > 		interrupts = <18 4>;
> > > 		clocks = <&tcb0_clk>, <&clk32k>;
> > > 		clock-names = "t0_clk", "slow_clk";
> > > 
> > > 		timer at 0 {
> > > 			compatible = "atmel,tcb-timer";
> > > 			reg = <0>, <1>;
> > > 			linux,timer-function = "clocksource";
> > > 		};
> > > 
> > > 		timer at 2 {
> > > 			compatible = "atmel,tcb-timer";
> > > 			reg = <2>;
> > > 			linux,timer-function = "clockevent";
> > > 		};
> > > 	};
> > > 
> > > Alternatively, we could have a property or a node in chosen describing which
> > > timer should be used:
> > > 
> > > 	chosen {
> > > 		clockevent {
> > > 			timer = <&timer2>;
> > > 		};
> > > 
> > > 		clocksource {
> > > 			timer = <&timer0>;
> > > 		};
> > > 
> > > 		/*
> > > 		 * or
> > > 		 *
> > > 		 * clockevent = <&timer2>;
> > > 		 * clocksource = <&timer0>;
> > > 		 *
> > > 		 * but I think the clocksource/clockevent node approach
> > > 		 * is more future proof in case we need to add extra
> > > 		 * information like the expected resolution/precision or
> > > 		 * anything that could be tweakable.
> > > 		 */
> > > 	};
> > > 
> > > 	tcb0: timer at fff7c000 {
> > > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > > 		#address-cells = <1>;
> > > 		#size-cells = <0>;
> > > 		reg = <0xfff7c000 0x100>;
> > > 		interrupts = <18 4>;
> > > 		clocks = <&tcb0_clk>, <&clk32k>;
> > > 		clock-names = "t0_clk", "slow_clk";
> > > 
> > > 		timer0: timer at 0 {
> > > 			compatible = "atmel,tcb-timer";
> > > 			reg = <0>, <1>;
> > > 		};
> > > 
> > > 		timer2: timer at 2 {
> > > 			compatible = "atmel,tcb-timer";
> > > 			reg = <2>;
> > > 		};
> > > 	};
> > 
> > -- 
> > 
> >  <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs
> > 
> > Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
> > <http://twitter.com/#!/linaroorg> Twitter |
> > <http://www.linaro.org/linaro-blog/> Blog
> 
> -- 
> Alexandre Belloni, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com

-- 

 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-06-08  8:24                       ` Daniel Lezcano
  (?)
@ 2017-06-08  8:33                         ` Boris Brezillon
  -1 siblings, 0 replies; 189+ messages in thread
From: Boris Brezillon @ 2017-06-08  8:33 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Alexandre Belloni, Rob Herring, Nicolas Ferre, linux-arm-kernel,
	linux-kernel, Thomas Gleixner, devicetree, Mark Rutland

On Thu, 8 Jun 2017 10:24:17 +0200
Daniel Lezcano <daniel.lezcano@linaro.org> wrote:

> On Thu, Jun 08, 2017 at 09:59:01AM +0200, Alexandre Belloni wrote:
> > On 08/06/2017 at 09:44:46 +0200, Daniel Lezcano wrote:  
> > > 
> > > +Mark Rutland, +Rob Herring
> > > 
> > > 
> > > Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
> > > 
> > > That will tell you the story.
> > >   
> > 
> > Ok, so is the solution putting the driver back in mach-at91 were we can
> > do whatever we want like mach-omap2 is doing?  
> 
> No. And putting a driver in mach-<whatever> does not give the permission to do
> whatever you want. I won't tell you how OSS works, but moving code around or
> using another tree to circumvent a code review is just the best way to upset
> maintainers in general and hurt your karma.
> 
> That said, I think you misunderstood my comment (or I was not clear). In the
> discussion given in the link above, I am in favor, somehow, to distinguish
> clockevent and clocksource to solve exactly what you are facing.
> 
> Rob Herring told me it could be acceptable to have a property to tell if it is
> a clockevent or a clocksource.
> 
> Mark Rutland disagreed on this.
> 
> I was alone in the discussion, no consensus have been found.

Indeed, I misunderstood your point.

> 
> Now, you have a particular use case and I would like to resurrect the
> discussion in order to find a solution which can apply to all DT drivers.

Ok, glad to see we're on the same page.

Mark, can we re-open the discussion?

Thanks,

Boris

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-08  8:33                         ` Boris Brezillon
  0 siblings, 0 replies; 189+ messages in thread
From: Boris Brezillon @ 2017-06-08  8:33 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Alexandre Belloni, Rob Herring, Nicolas Ferre,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Thomas Gleixner,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Mark Rutland

On Thu, 8 Jun 2017 10:24:17 +0200
Daniel Lezcano <daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:

> On Thu, Jun 08, 2017 at 09:59:01AM +0200, Alexandre Belloni wrote:
> > On 08/06/2017 at 09:44:46 +0200, Daniel Lezcano wrote:  
> > > 
> > > +Mark Rutland, +Rob Herring
> > > 
> > > 
> > > Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
> > > 
> > > That will tell you the story.
> > >   
> > 
> > Ok, so is the solution putting the driver back in mach-at91 were we can
> > do whatever we want like mach-omap2 is doing?  
> 
> No. And putting a driver in mach-<whatever> does not give the permission to do
> whatever you want. I won't tell you how OSS works, but moving code around or
> using another tree to circumvent a code review is just the best way to upset
> maintainers in general and hurt your karma.
> 
> That said, I think you misunderstood my comment (or I was not clear). In the
> discussion given in the link above, I am in favor, somehow, to distinguish
> clockevent and clocksource to solve exactly what you are facing.
> 
> Rob Herring told me it could be acceptable to have a property to tell if it is
> a clockevent or a clocksource.
> 
> Mark Rutland disagreed on this.
> 
> I was alone in the discussion, no consensus have been found.

Indeed, I misunderstood your point.

> 
> Now, you have a particular use case and I would like to resurrect the
> discussion in order to find a solution which can apply to all DT drivers.

Ok, glad to see we're on the same page.

Mark, can we re-open the discussion?

Thanks,

Boris
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-08  8:33                         ` Boris Brezillon
  0 siblings, 0 replies; 189+ messages in thread
From: Boris Brezillon @ 2017-06-08  8:33 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 8 Jun 2017 10:24:17 +0200
Daniel Lezcano <daniel.lezcano@linaro.org> wrote:

> On Thu, Jun 08, 2017 at 09:59:01AM +0200, Alexandre Belloni wrote:
> > On 08/06/2017 at 09:44:46 +0200, Daniel Lezcano wrote:  
> > > 
> > > +Mark Rutland, +Rob Herring
> > > 
> > > 
> > > Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
> > > 
> > > That will tell you the story.
> > >   
> > 
> > Ok, so is the solution putting the driver back in mach-at91 were we can
> > do whatever we want like mach-omap2 is doing?  
> 
> No. And putting a driver in mach-<whatever> does not give the permission to do
> whatever you want. I won't tell you how OSS works, but moving code around or
> using another tree to circumvent a code review is just the best way to upset
> maintainers in general and hurt your karma.
> 
> That said, I think you misunderstood my comment (or I was not clear). In the
> discussion given in the link above, I am in favor, somehow, to distinguish
> clockevent and clocksource to solve exactly what you are facing.
> 
> Rob Herring told me it could be acceptable to have a property to tell if it is
> a clockevent or a clocksource.
> 
> Mark Rutland disagreed on this.
> 
> I was alone in the discussion, no consensus have been found.

Indeed, I misunderstood your point.

> 
> Now, you have a particular use case and I would like to resurrect the
> discussion in order to find a solution which can apply to all DT drivers.

Ok, glad to see we're on the same page.

Mark, can we re-open the discussion?

Thanks,

Boris

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-06-08  8:13                     ` Boris Brezillon
  (?)
@ 2017-06-08  8:40                       ` Daniel Lezcano
  -1 siblings, 0 replies; 189+ messages in thread
From: Daniel Lezcano @ 2017-06-08  8:40 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Alexandre Belloni, Rob Herring, Nicolas Ferre, linux-arm-kernel,
	linux-kernel, Thomas Gleixner, devicetree, Mark Rutland

On Thu, Jun 08, 2017 at 10:13:34AM +0200, Boris Brezillon wrote:
> On Thu, 8 Jun 2017 09:44:46 +0200
> Daniel Lezcano <daniel.lezcano@linaro.org> wrote:
> 
> > +Mark Rutland, +Rob Herring
> 
> Mark doesn't seem to be CCed.

Ah, yes. Thanks for fixing this.

> > 
> > 
> > Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
> > 
> > That will tell you the story.
> 
> Then we're in a deadlock situation here. I'm tired of hearing this kind
> of argument "DT is only supposed to describe HW, not configuration, bla
> bla". The truth is, we already have plenty of bindings that do not
> strictly describe HW.
> 
> A simple example: ECC configuration on NAND devices. This is clearly a
> configuration thing, the NAND controller is usually able to support
> several kind of strength+ECC-block-size config, but we are able to
> overload this with the nand-ecc-xxx properties. Another example, still
> MTD related: MTD partitions, this is purely a software configuration,
> still we allow users to pass this information in the DT. You want
> another one? What about the linux,code and linux,input-type properties
> described here [1]?
> 
> So please, let's not use these "this is not decribing HW" or "this is
> linux specific" arguments every time someone tries to encode something
> that can be considered a configuration detail.
> 
> Let's be pragmatic. How you want to use your timer counter blocks (I'm
> talking about atmel TCBs) is clearly board specific. Whether you want
> to use the PIT for your clocksource or use one or 2 channels of a TCB
> at a specific resolution is again board specific. We need a solution to
> assign timer channels to a linux function, and I'm not convinced
> passing this information through the command line makes much more sense
> than specifying it in the DT (and it's definitely less intuitive, since
> you have to reference something defined in the DT from the cmdline).
> 
> Now, in his review, Mark says:
> 
> "
> To me it sounds like what we need is Linux infrastructure that allows
> one to register a device as having both clockevent/clocksource
> functionality.
> 
> That way, we can choose to do something sane at boot time, and if the
> user really wants specific devices used in specific ways, they can
> request that.
> "
> 
> Does that mean that, after adding this "HW timer" infrastructure, we
> would have a standard way to assign a function to a specific timer
> block from the DT? How is this different from what I suggest below
> (note the linux, prefix on my linux,timer-function property, which
> clearly shows that this is Linux specific)?

I like the 'chosen' approach with the nodes you are proposing below. Thanks for
the constructive suggestion. The binding description matches perfectly what we
are trying to achieve.

Rob? what do you think?

> > On Thu, Jun 08, 2017 at 07:42:36AM +0200, Boris Brezillon wrote:
> > > Le Thu, 8 Jun 2017 01:17:15 +0200,
> > > Alexandre Belloni <alexandre.belloni@free-electrons.com> a écrit :
> > >   
> > > > On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:  
> > > > > > I was going to agree but this is not flexible enough because the
> > > > > > quadrature decoder always uses the first two channels. So on some
> > > > > > products, we may have:
> > > > > >  - TCB0:
> > > > > >    o channels 0,1: qdec
> > > > > >    o channel 2: clocksource
> > > > > > 
> > > > > >  - TCB1:
> > > > > >    o channels 0,1: qdec
> > > > > >    o channel 2: clockevent
> > > > > > 
> > > > > > This avoids wasting TCB channels.    
> > > > > 
> > > > > Ok. In this case you can check if the interrupt is specified for the node, if
> > > > > yes, then it is a clockevent.
> > > > >     
> > > > 
> > > > But currently it is always specified in the SoC's dtsi. I don't find
> > > > that too practical to push that to the board's dts. Also, lying by
> > > > omission (the IRQ is always wired) in the DT is not different from
> > > > having a property selecting which timer is the clocksource and which is
> > > > the clockevent.
> > > >   
> > > 
> > > I agree with Alexandre here. Really, there's not much we can do to
> > > detect which timer should be used as a clockevent and which one should
> > > be used as a clocksource except explicitly specifying it in the DT.
> > > Having an interrupt defined in one case (clockevent) and undefined in
> > > the other case (clocksource), is just as hack-ish as the detection logic
> > > Alexandre developed to avoid explicitly specifying the function
> > > assigned to a specific timer.
> > > 
> > > Can we please find a solution that makes everyone happy (DT,
> > > clocksoure/clockevent and at91 maintainers)?
> > > 
> > > How about adding a linux,timer-function property to specify which
> > > function this timer is providing?
> > > 
> > > Something like that for example:
> > > 
> > > 	tcb0: timer@fff7c000 {
> > > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > > 		#address-cells = <1>;
> > > 		#size-cells = <0>;
> > > 		reg = <0xfff7c000 0x100>;
> > > 		interrupts = <18 4>;
> > > 		clocks = <&tcb0_clk>, <&clk32k>;
> > > 		clock-names = "t0_clk", "slow_clk";
> > > 
> > > 		timer@0 {
> > > 			compatible = "atmel,tcb-timer";
> > > 			reg = <0>, <1>;
> > > 			linux,timer-function = "clocksource";
> > > 		};
> > > 
> > > 		timer@2 {
> > > 			compatible = "atmel,tcb-timer";
> > > 			reg = <2>;
> > > 			linux,timer-function = "clockevent";
> > > 		};
> > > 	};
> > > 
> > > Alternatively, we could have a property or a node in chosen describing which
> > > timer should be used:
> > > 
> > > 	chosen {
> > > 		clockevent {
> > > 			timer = <&timer2>;
> > > 		};
> > > 
> > > 		clocksource {
> > > 			timer = <&timer0>;
> > > 		};
> > > 
> > > 		/*
> > > 		 * or
> > > 		 *
> > > 		 * clockevent = <&timer2>;
> > > 		 * clocksource = <&timer0>;
> > > 		 *
> > > 		 * but I think the clocksource/clockevent node approach
> > > 		 * is more future proof in case we need to add extra
> > > 		 * information like the expected resolution/precision or
> > > 		 * anything that could be tweakable.
> > > 		 */
> > > 	};
> > > 
> > > 	tcb0: timer@fff7c000 {
> > > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > > 		#address-cells = <1>;
> > > 		#size-cells = <0>;
> > > 		reg = <0xfff7c000 0x100>;
> > > 		interrupts = <18 4>;
> > > 		clocks = <&tcb0_clk>, <&clk32k>;
> > > 		clock-names = "t0_clk", "slow_clk";
> > > 
> > > 		timer0: timer@0 {
> > > 			compatible = "atmel,tcb-timer";
> > > 			reg = <0>, <1>;
> > > 		};
> > > 
> > > 		timer2: timer@2 {
> > > 			compatible = "atmel,tcb-timer";
> > > 			reg = <2>;
> > > 		};
> > > 	};  
> > 
> 
> [1]http://elixir.free-electrons.com/linux/latest/source/Documentation/devicetree/bindings/input/gpio-keys.txt

-- 

 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-08  8:40                       ` Daniel Lezcano
  0 siblings, 0 replies; 189+ messages in thread
From: Daniel Lezcano @ 2017-06-08  8:40 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Alexandre Belloni, Rob Herring, Nicolas Ferre,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Thomas Gleixner,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Mark Rutland

On Thu, Jun 08, 2017 at 10:13:34AM +0200, Boris Brezillon wrote:
> On Thu, 8 Jun 2017 09:44:46 +0200
> Daniel Lezcano <daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:
> 
> > +Mark Rutland, +Rob Herring
> 
> Mark doesn't seem to be CCed.

Ah, yes. Thanks for fixing this.

> > 
> > 
> > Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
> > 
> > That will tell you the story.
> 
> Then we're in a deadlock situation here. I'm tired of hearing this kind
> of argument "DT is only supposed to describe HW, not configuration, bla
> bla". The truth is, we already have plenty of bindings that do not
> strictly describe HW.
> 
> A simple example: ECC configuration on NAND devices. This is clearly a
> configuration thing, the NAND controller is usually able to support
> several kind of strength+ECC-block-size config, but we are able to
> overload this with the nand-ecc-xxx properties. Another example, still
> MTD related: MTD partitions, this is purely a software configuration,
> still we allow users to pass this information in the DT. You want
> another one? What about the linux,code and linux,input-type properties
> described here [1]?
> 
> So please, let's not use these "this is not decribing HW" or "this is
> linux specific" arguments every time someone tries to encode something
> that can be considered a configuration detail.
> 
> Let's be pragmatic. How you want to use your timer counter blocks (I'm
> talking about atmel TCBs) is clearly board specific. Whether you want
> to use the PIT for your clocksource or use one or 2 channels of a TCB
> at a specific resolution is again board specific. We need a solution to
> assign timer channels to a linux function, and I'm not convinced
> passing this information through the command line makes much more sense
> than specifying it in the DT (and it's definitely less intuitive, since
> you have to reference something defined in the DT from the cmdline).
> 
> Now, in his review, Mark says:
> 
> "
> To me it sounds like what we need is Linux infrastructure that allows
> one to register a device as having both clockevent/clocksource
> functionality.
> 
> That way, we can choose to do something sane at boot time, and if the
> user really wants specific devices used in specific ways, they can
> request that.
> "
> 
> Does that mean that, after adding this "HW timer" infrastructure, we
> would have a standard way to assign a function to a specific timer
> block from the DT? How is this different from what I suggest below
> (note the linux, prefix on my linux,timer-function property, which
> clearly shows that this is Linux specific)?

I like the 'chosen' approach with the nodes you are proposing below. Thanks for
the constructive suggestion. The binding description matches perfectly what we
are trying to achieve.

Rob? what do you think?

> > On Thu, Jun 08, 2017 at 07:42:36AM +0200, Boris Brezillon wrote:
> > > Le Thu, 8 Jun 2017 01:17:15 +0200,
> > > Alexandre Belloni <alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> a écrit :
> > >   
> > > > On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:  
> > > > > > I was going to agree but this is not flexible enough because the
> > > > > > quadrature decoder always uses the first two channels. So on some
> > > > > > products, we may have:
> > > > > >  - TCB0:
> > > > > >    o channels 0,1: qdec
> > > > > >    o channel 2: clocksource
> > > > > > 
> > > > > >  - TCB1:
> > > > > >    o channels 0,1: qdec
> > > > > >    o channel 2: clockevent
> > > > > > 
> > > > > > This avoids wasting TCB channels.    
> > > > > 
> > > > > Ok. In this case you can check if the interrupt is specified for the node, if
> > > > > yes, then it is a clockevent.
> > > > >     
> > > > 
> > > > But currently it is always specified in the SoC's dtsi. I don't find
> > > > that too practical to push that to the board's dts. Also, lying by
> > > > omission (the IRQ is always wired) in the DT is not different from
> > > > having a property selecting which timer is the clocksource and which is
> > > > the clockevent.
> > > >   
> > > 
> > > I agree with Alexandre here. Really, there's not much we can do to
> > > detect which timer should be used as a clockevent and which one should
> > > be used as a clocksource except explicitly specifying it in the DT.
> > > Having an interrupt defined in one case (clockevent) and undefined in
> > > the other case (clocksource), is just as hack-ish as the detection logic
> > > Alexandre developed to avoid explicitly specifying the function
> > > assigned to a specific timer.
> > > 
> > > Can we please find a solution that makes everyone happy (DT,
> > > clocksoure/clockevent and at91 maintainers)?
> > > 
> > > How about adding a linux,timer-function property to specify which
> > > function this timer is providing?
> > > 
> > > Something like that for example:
> > > 
> > > 	tcb0: timer@fff7c000 {
> > > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > > 		#address-cells = <1>;
> > > 		#size-cells = <0>;
> > > 		reg = <0xfff7c000 0x100>;
> > > 		interrupts = <18 4>;
> > > 		clocks = <&tcb0_clk>, <&clk32k>;
> > > 		clock-names = "t0_clk", "slow_clk";
> > > 
> > > 		timer@0 {
> > > 			compatible = "atmel,tcb-timer";
> > > 			reg = <0>, <1>;
> > > 			linux,timer-function = "clocksource";
> > > 		};
> > > 
> > > 		timer@2 {
> > > 			compatible = "atmel,tcb-timer";
> > > 			reg = <2>;
> > > 			linux,timer-function = "clockevent";
> > > 		};
> > > 	};
> > > 
> > > Alternatively, we could have a property or a node in chosen describing which
> > > timer should be used:
> > > 
> > > 	chosen {
> > > 		clockevent {
> > > 			timer = <&timer2>;
> > > 		};
> > > 
> > > 		clocksource {
> > > 			timer = <&timer0>;
> > > 		};
> > > 
> > > 		/*
> > > 		 * or
> > > 		 *
> > > 		 * clockevent = <&timer2>;
> > > 		 * clocksource = <&timer0>;
> > > 		 *
> > > 		 * but I think the clocksource/clockevent node approach
> > > 		 * is more future proof in case we need to add extra
> > > 		 * information like the expected resolution/precision or
> > > 		 * anything that could be tweakable.
> > > 		 */
> > > 	};
> > > 
> > > 	tcb0: timer@fff7c000 {
> > > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > > 		#address-cells = <1>;
> > > 		#size-cells = <0>;
> > > 		reg = <0xfff7c000 0x100>;
> > > 		interrupts = <18 4>;
> > > 		clocks = <&tcb0_clk>, <&clk32k>;
> > > 		clock-names = "t0_clk", "slow_clk";
> > > 
> > > 		timer0: timer@0 {
> > > 			compatible = "atmel,tcb-timer";
> > > 			reg = <0>, <1>;
> > > 		};
> > > 
> > > 		timer2: timer@2 {
> > > 			compatible = "atmel,tcb-timer";
> > > 			reg = <2>;
> > > 		};
> > > 	};  
> > 
> 
> [1]http://elixir.free-electrons.com/linux/latest/source/Documentation/devicetree/bindings/input/gpio-keys.txt

-- 

 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-08  8:40                       ` Daniel Lezcano
  0 siblings, 0 replies; 189+ messages in thread
From: Daniel Lezcano @ 2017-06-08  8:40 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jun 08, 2017 at 10:13:34AM +0200, Boris Brezillon wrote:
> On Thu, 8 Jun 2017 09:44:46 +0200
> Daniel Lezcano <daniel.lezcano@linaro.org> wrote:
> 
> > +Mark Rutland, +Rob Herring
> 
> Mark doesn't seem to be CCed.

Ah, yes. Thanks for fixing this.

> > 
> > 
> > Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
> > 
> > That will tell you the story.
> 
> Then we're in a deadlock situation here. I'm tired of hearing this kind
> of argument "DT is only supposed to describe HW, not configuration, bla
> bla". The truth is, we already have plenty of bindings that do not
> strictly describe HW.
> 
> A simple example: ECC configuration on NAND devices. This is clearly a
> configuration thing, the NAND controller is usually able to support
> several kind of strength+ECC-block-size config, but we are able to
> overload this with the nand-ecc-xxx properties. Another example, still
> MTD related: MTD partitions, this is purely a software configuration,
> still we allow users to pass this information in the DT. You want
> another one? What about the linux,code and linux,input-type properties
> described here [1]?
> 
> So please, let's not use these "this is not decribing HW" or "this is
> linux specific" arguments every time someone tries to encode something
> that can be considered a configuration detail.
> 
> Let's be pragmatic. How you want to use your timer counter blocks (I'm
> talking about atmel TCBs) is clearly board specific. Whether you want
> to use the PIT for your clocksource or use one or 2 channels of a TCB
> at a specific resolution is again board specific. We need a solution to
> assign timer channels to a linux function, and I'm not convinced
> passing this information through the command line makes much more sense
> than specifying it in the DT (and it's definitely less intuitive, since
> you have to reference something defined in the DT from the cmdline).
> 
> Now, in his review, Mark says:
> 
> "
> To me it sounds like what we need is Linux infrastructure that allows
> one to register a device as having both clockevent/clocksource
> functionality.
> 
> That way, we can choose to do something sane at boot time, and if the
> user really wants specific devices used in specific ways, they can
> request that.
> "
> 
> Does that mean that, after adding this "HW timer" infrastructure, we
> would have a standard way to assign a function to a specific timer
> block from the DT? How is this different from what I suggest below
> (note the linux, prefix on my linux,timer-function property, which
> clearly shows that this is Linux specific)?

I like the 'chosen' approach with the nodes you are proposing below. Thanks for
the constructive suggestion. The binding description matches perfectly what we
are trying to achieve.

Rob? what do you think?

> > On Thu, Jun 08, 2017 at 07:42:36AM +0200, Boris Brezillon wrote:
> > > Le Thu, 8 Jun 2017 01:17:15 +0200,
> > > Alexandre Belloni <alexandre.belloni@free-electrons.com> a ?crit :
> > >   
> > > > On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:  
> > > > > > I was going to agree but this is not flexible enough because the
> > > > > > quadrature decoder always uses the first two channels. So on some
> > > > > > products, we may have:
> > > > > >  - TCB0:
> > > > > >    o channels 0,1: qdec
> > > > > >    o channel 2: clocksource
> > > > > > 
> > > > > >  - TCB1:
> > > > > >    o channels 0,1: qdec
> > > > > >    o channel 2: clockevent
> > > > > > 
> > > > > > This avoids wasting TCB channels.    
> > > > > 
> > > > > Ok. In this case you can check if the interrupt is specified for the node, if
> > > > > yes, then it is a clockevent.
> > > > >     
> > > > 
> > > > But currently it is always specified in the SoC's dtsi. I don't find
> > > > that too practical to push that to the board's dts. Also, lying by
> > > > omission (the IRQ is always wired) in the DT is not different from
> > > > having a property selecting which timer is the clocksource and which is
> > > > the clockevent.
> > > >   
> > > 
> > > I agree with Alexandre here. Really, there's not much we can do to
> > > detect which timer should be used as a clockevent and which one should
> > > be used as a clocksource except explicitly specifying it in the DT.
> > > Having an interrupt defined in one case (clockevent) and undefined in
> > > the other case (clocksource), is just as hack-ish as the detection logic
> > > Alexandre developed to avoid explicitly specifying the function
> > > assigned to a specific timer.
> > > 
> > > Can we please find a solution that makes everyone happy (DT,
> > > clocksoure/clockevent and at91 maintainers)?
> > > 
> > > How about adding a linux,timer-function property to specify which
> > > function this timer is providing?
> > > 
> > > Something like that for example:
> > > 
> > > 	tcb0: timer at fff7c000 {
> > > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > > 		#address-cells = <1>;
> > > 		#size-cells = <0>;
> > > 		reg = <0xfff7c000 0x100>;
> > > 		interrupts = <18 4>;
> > > 		clocks = <&tcb0_clk>, <&clk32k>;
> > > 		clock-names = "t0_clk", "slow_clk";
> > > 
> > > 		timer at 0 {
> > > 			compatible = "atmel,tcb-timer";
> > > 			reg = <0>, <1>;
> > > 			linux,timer-function = "clocksource";
> > > 		};
> > > 
> > > 		timer at 2 {
> > > 			compatible = "atmel,tcb-timer";
> > > 			reg = <2>;
> > > 			linux,timer-function = "clockevent";
> > > 		};
> > > 	};
> > > 
> > > Alternatively, we could have a property or a node in chosen describing which
> > > timer should be used:
> > > 
> > > 	chosen {
> > > 		clockevent {
> > > 			timer = <&timer2>;
> > > 		};
> > > 
> > > 		clocksource {
> > > 			timer = <&timer0>;
> > > 		};
> > > 
> > > 		/*
> > > 		 * or
> > > 		 *
> > > 		 * clockevent = <&timer2>;
> > > 		 * clocksource = <&timer0>;
> > > 		 *
> > > 		 * but I think the clocksource/clockevent node approach
> > > 		 * is more future proof in case we need to add extra
> > > 		 * information like the expected resolution/precision or
> > > 		 * anything that could be tweakable.
> > > 		 */
> > > 	};
> > > 
> > > 	tcb0: timer at fff7c000 {
> > > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > > 		#address-cells = <1>;
> > > 		#size-cells = <0>;
> > > 		reg = <0xfff7c000 0x100>;
> > > 		interrupts = <18 4>;
> > > 		clocks = <&tcb0_clk>, <&clk32k>;
> > > 		clock-names = "t0_clk", "slow_clk";
> > > 
> > > 		timer0: timer at 0 {
> > > 			compatible = "atmel,tcb-timer";
> > > 			reg = <0>, <1>;
> > > 		};
> > > 
> > > 		timer2: timer at 2 {
> > > 			compatible = "atmel,tcb-timer";
> > > 			reg = <2>;
> > > 		};
> > > 	};  
> > 
> 
> [1]http://elixir.free-electrons.com/linux/latest/source/Documentation/devicetree/bindings/input/gpio-keys.txt

-- 

 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-06-08  8:24                       ` Daniel Lezcano
@ 2017-06-08  8:42                         ` Alexandre Belloni
  -1 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-06-08  8:42 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Boris Brezillon, Rob Herring, Nicolas Ferre, linux-arm-kernel,
	linux-kernel, Thomas Gleixner, devicetree

On 08/06/2017 at 10:24:17 +0200, Daniel Lezcano wrote:
> On Thu, Jun 08, 2017 at 09:59:01AM +0200, Alexandre Belloni wrote:
> > On 08/06/2017 at 09:44:46 +0200, Daniel Lezcano wrote:
> > > 
> > > +Mark Rutland, +Rob Herring
> > > 
> > > 
> > > Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
> > > 
> > > That will tell you the story.
> > > 
> > 
> > Ok, so is the solution putting the driver back in mach-at91 were we can
> > do whatever we want like mach-omap2 is doing?
> 
> No. And putting a driver in mach-<whatever> does not give the permission to do
> whatever you want. I won't tell you how OSS works, but moving code around or
> using another tree to circumvent a code review is just the best way to upset
> maintainers in general and hurt your karma.
> 

I know that but some SoCs will not be able to even boot until we have a
solution. And it has been one year since we raised the issue without any
solution coming from the DT maintainers.


> That said, I think you misunderstood my comment (or I was not clear). In the
> discussion given in the link above, I am in favor, somehow, to distinguish
> clockevent and clocksource to solve exactly what you are facing.
> 
> Rob Herring told me it could be acceptable to have a property to tell if it is
> a clockevent or a clocksource.
> 

Ok, then let's do it!


> Mark Rutland disagreed on this.
> 
> I was alone in the discussion, no consensus have been found.
> 
> Now, you have a particular use case and I would like to resurrect the
> discussion in order to find a solution which can apply to all DT drivers.
> 

Again, it has been one year and it seems nobody actually cares. There is
a whole family of SoCs that can't boot because of that. Should I resort
to the evil vendor tree argument again?




> > > On Thu, Jun 08, 2017 at 07:42:36AM +0200, Boris Brezillon wrote:
> > > > Le Thu, 8 Jun 2017 01:17:15 +0200,
> > > > Alexandre Belloni <alexandre.belloni@free-electrons.com> a écrit :
> > > > 
> > > > > On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:
> > > > > > > I was going to agree but this is not flexible enough because the
> > > > > > > quadrature decoder always uses the first two channels. So on some
> > > > > > > products, we may have:
> > > > > > >  - TCB0:
> > > > > > >    o channels 0,1: qdec
> > > > > > >    o channel 2: clocksource
> > > > > > > 
> > > > > > >  - TCB1:
> > > > > > >    o channels 0,1: qdec
> > > > > > >    o channel 2: clockevent
> > > > > > > 
> > > > > > > This avoids wasting TCB channels.  
> > > > > > 
> > > > > > Ok. In this case you can check if the interrupt is specified for the node, if
> > > > > > yes, then it is a clockevent.
> > > > > >   
> > > > > 
> > > > > But currently it is always specified in the SoC's dtsi. I don't find
> > > > > that too practical to push that to the board's dts. Also, lying by
> > > > > omission (the IRQ is always wired) in the DT is not different from
> > > > > having a property selecting which timer is the clocksource and which is
> > > > > the clockevent.
> > > > > 
> > > > 
> > > > I agree with Alexandre here. Really, there's not much we can do to
> > > > detect which timer should be used as a clockevent and which one should
> > > > be used as a clocksource except explicitly specifying it in the DT.
> > > > Having an interrupt defined in one case (clockevent) and undefined in
> > > > the other case (clocksource), is just as hack-ish as the detection logic
> > > > Alexandre developed to avoid explicitly specifying the function
> > > > assigned to a specific timer.
> > > > 
> > > > Can we please find a solution that makes everyone happy (DT,
> > > > clocksoure/clockevent and at91 maintainers)?
> > > > 
> > > > How about adding a linux,timer-function property to specify which
> > > > function this timer is providing?
> > > > 
> > > > Something like that for example:
> > > > 
> > > > 	tcb0: timer@fff7c000 {
> > > > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > > > 		#address-cells = <1>;
> > > > 		#size-cells = <0>;
> > > > 		reg = <0xfff7c000 0x100>;
> > > > 		interrupts = <18 4>;
> > > > 		clocks = <&tcb0_clk>, <&clk32k>;
> > > > 		clock-names = "t0_clk", "slow_clk";
> > > > 
> > > > 		timer@0 {
> > > > 			compatible = "atmel,tcb-timer";
> > > > 			reg = <0>, <1>;
> > > > 			linux,timer-function = "clocksource";
> > > > 		};
> > > > 
> > > > 		timer@2 {
> > > > 			compatible = "atmel,tcb-timer";
> > > > 			reg = <2>;
> > > > 			linux,timer-function = "clockevent";
> > > > 		};
> > > > 	};
> > > > 
> > > > Alternatively, we could have a property or a node in chosen describing which
> > > > timer should be used:
> > > > 
> > > > 	chosen {
> > > > 		clockevent {
> > > > 			timer = <&timer2>;
> > > > 		};
> > > > 
> > > > 		clocksource {
> > > > 			timer = <&timer0>;
> > > > 		};
> > > > 
> > > > 		/*
> > > > 		 * or
> > > > 		 *
> > > > 		 * clockevent = <&timer2>;
> > > > 		 * clocksource = <&timer0>;
> > > > 		 *
> > > > 		 * but I think the clocksource/clockevent node approach
> > > > 		 * is more future proof in case we need to add extra
> > > > 		 * information like the expected resolution/precision or
> > > > 		 * anything that could be tweakable.
> > > > 		 */
> > > > 	};
> > > > 
> > > > 	tcb0: timer@fff7c000 {
> > > > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > > > 		#address-cells = <1>;
> > > > 		#size-cells = <0>;
> > > > 		reg = <0xfff7c000 0x100>;
> > > > 		interrupts = <18 4>;
> > > > 		clocks = <&tcb0_clk>, <&clk32k>;
> > > > 		clock-names = "t0_clk", "slow_clk";
> > > > 
> > > > 		timer0: timer@0 {
> > > > 			compatible = "atmel,tcb-timer";
> > > > 			reg = <0>, <1>;
> > > > 		};
> > > > 
> > > > 		timer2: timer@2 {
> > > > 			compatible = "atmel,tcb-timer";
> > > > 			reg = <2>;
> > > > 		};
> > > > 	};
> > > 
> > > -- 
> > > 
> > >  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
> > > 
> > > Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
> > > <http://twitter.com/#!/linaroorg> Twitter |
> > > <http://www.linaro.org/linaro-blog/> Blog
> > 
> > -- 
> > Alexandre Belloni, Free Electrons
> > Embedded Linux and Kernel engineering
> > http://free-electrons.com
> 
> -- 
> 
>  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
> 
> Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
> <http://twitter.com/#!/linaroorg> Twitter |
> <http://www.linaro.org/linaro-blog/> Blog

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-08  8:42                         ` Alexandre Belloni
  0 siblings, 0 replies; 189+ messages in thread
From: Alexandre Belloni @ 2017-06-08  8:42 UTC (permalink / raw)
  To: linux-arm-kernel

On 08/06/2017 at 10:24:17 +0200, Daniel Lezcano wrote:
> On Thu, Jun 08, 2017 at 09:59:01AM +0200, Alexandre Belloni wrote:
> > On 08/06/2017 at 09:44:46 +0200, Daniel Lezcano wrote:
> > > 
> > > +Mark Rutland, +Rob Herring
> > > 
> > > 
> > > Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
> > > 
> > > That will tell you the story.
> > > 
> > 
> > Ok, so is the solution putting the driver back in mach-at91 were we can
> > do whatever we want like mach-omap2 is doing?
> 
> No. And putting a driver in mach-<whatever> does not give the permission to do
> whatever you want. I won't tell you how OSS works, but moving code around or
> using another tree to circumvent a code review is just the best way to upset
> maintainers in general and hurt your karma.
> 

I know that but some SoCs will not be able to even boot until we have a
solution. And it has been one year since we raised the issue without any
solution coming from the DT maintainers.


> That said, I think you misunderstood my comment (or I was not clear). In the
> discussion given in the link above, I am in favor, somehow, to distinguish
> clockevent and clocksource to solve exactly what you are facing.
> 
> Rob Herring told me it could be acceptable to have a property to tell if it is
> a clockevent or a clocksource.
> 

Ok, then let's do it!


> Mark Rutland disagreed on this.
> 
> I was alone in the discussion, no consensus have been found.
> 
> Now, you have a particular use case and I would like to resurrect the
> discussion in order to find a solution which can apply to all DT drivers.
> 

Again, it has been one year and it seems nobody actually cares. There is
a whole family of SoCs that can't boot because of that. Should I resort
to the evil vendor tree argument again?




> > > On Thu, Jun 08, 2017 at 07:42:36AM +0200, Boris Brezillon wrote:
> > > > Le Thu, 8 Jun 2017 01:17:15 +0200,
> > > > Alexandre Belloni <alexandre.belloni@free-electrons.com> a ?crit :
> > > > 
> > > > > On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:
> > > > > > > I was going to agree but this is not flexible enough because the
> > > > > > > quadrature decoder always uses the first two channels. So on some
> > > > > > > products, we may have:
> > > > > > >  - TCB0:
> > > > > > >    o channels 0,1: qdec
> > > > > > >    o channel 2: clocksource
> > > > > > > 
> > > > > > >  - TCB1:
> > > > > > >    o channels 0,1: qdec
> > > > > > >    o channel 2: clockevent
> > > > > > > 
> > > > > > > This avoids wasting TCB channels.  
> > > > > > 
> > > > > > Ok. In this case you can check if the interrupt is specified for the node, if
> > > > > > yes, then it is a clockevent.
> > > > > >   
> > > > > 
> > > > > But currently it is always specified in the SoC's dtsi. I don't find
> > > > > that too practical to push that to the board's dts. Also, lying by
> > > > > omission (the IRQ is always wired) in the DT is not different from
> > > > > having a property selecting which timer is the clocksource and which is
> > > > > the clockevent.
> > > > > 
> > > > 
> > > > I agree with Alexandre here. Really, there's not much we can do to
> > > > detect which timer should be used as a clockevent and which one should
> > > > be used as a clocksource except explicitly specifying it in the DT.
> > > > Having an interrupt defined in one case (clockevent) and undefined in
> > > > the other case (clocksource), is just as hack-ish as the detection logic
> > > > Alexandre developed to avoid explicitly specifying the function
> > > > assigned to a specific timer.
> > > > 
> > > > Can we please find a solution that makes everyone happy (DT,
> > > > clocksoure/clockevent and at91 maintainers)?
> > > > 
> > > > How about adding a linux,timer-function property to specify which
> > > > function this timer is providing?
> > > > 
> > > > Something like that for example:
> > > > 
> > > > 	tcb0: timer at fff7c000 {
> > > > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > > > 		#address-cells = <1>;
> > > > 		#size-cells = <0>;
> > > > 		reg = <0xfff7c000 0x100>;
> > > > 		interrupts = <18 4>;
> > > > 		clocks = <&tcb0_clk>, <&clk32k>;
> > > > 		clock-names = "t0_clk", "slow_clk";
> > > > 
> > > > 		timer at 0 {
> > > > 			compatible = "atmel,tcb-timer";
> > > > 			reg = <0>, <1>;
> > > > 			linux,timer-function = "clocksource";
> > > > 		};
> > > > 
> > > > 		timer at 2 {
> > > > 			compatible = "atmel,tcb-timer";
> > > > 			reg = <2>;
> > > > 			linux,timer-function = "clockevent";
> > > > 		};
> > > > 	};
> > > > 
> > > > Alternatively, we could have a property or a node in chosen describing which
> > > > timer should be used:
> > > > 
> > > > 	chosen {
> > > > 		clockevent {
> > > > 			timer = <&timer2>;
> > > > 		};
> > > > 
> > > > 		clocksource {
> > > > 			timer = <&timer0>;
> > > > 		};
> > > > 
> > > > 		/*
> > > > 		 * or
> > > > 		 *
> > > > 		 * clockevent = <&timer2>;
> > > > 		 * clocksource = <&timer0>;
> > > > 		 *
> > > > 		 * but I think the clocksource/clockevent node approach
> > > > 		 * is more future proof in case we need to add extra
> > > > 		 * information like the expected resolution/precision or
> > > > 		 * anything that could be tweakable.
> > > > 		 */
> > > > 	};
> > > > 
> > > > 	tcb0: timer at fff7c000 {
> > > > 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
> > > > 		#address-cells = <1>;
> > > > 		#size-cells = <0>;
> > > > 		reg = <0xfff7c000 0x100>;
> > > > 		interrupts = <18 4>;
> > > > 		clocks = <&tcb0_clk>, <&clk32k>;
> > > > 		clock-names = "t0_clk", "slow_clk";
> > > > 
> > > > 		timer0: timer at 0 {
> > > > 			compatible = "atmel,tcb-timer";
> > > > 			reg = <0>, <1>;
> > > > 		};
> > > > 
> > > > 		timer2: timer at 2 {
> > > > 			compatible = "atmel,tcb-timer";
> > > > 			reg = <2>;
> > > > 		};
> > > > 	};
> > > 
> > > -- 
> > > 
> > >  <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs
> > > 
> > > Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
> > > <http://twitter.com/#!/linaroorg> Twitter |
> > > <http://www.linaro.org/linaro-blog/> Blog
> > 
> > -- 
> > Alexandre Belloni, Free Electrons
> > Embedded Linux and Kernel engineering
> > http://free-electrons.com
> 
> -- 
> 
>  <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs
> 
> Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
> <http://twitter.com/#!/linaroorg> Twitter |
> <http://www.linaro.org/linaro-blog/> Blog

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-06-08  8:40                       ` Daniel Lezcano
  (?)
@ 2017-06-08  8:57                         ` Boris Brezillon
  -1 siblings, 0 replies; 189+ messages in thread
From: Boris Brezillon @ 2017-06-08  8:57 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Alexandre Belloni, Rob Herring, Nicolas Ferre, linux-arm-kernel,
	linux-kernel, Thomas Gleixner, devicetree, Mark Rutland

On Thu, 8 Jun 2017 10:40:26 +0200
Daniel Lezcano <daniel.lezcano@linaro.org> wrote:

> > > 
> > > Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
> > > 
> > > That will tell you the story.  
> > 
> > Then we're in a deadlock situation here. I'm tired of hearing this kind
> > of argument "DT is only supposed to describe HW, not configuration, bla
> > bla". The truth is, we already have plenty of bindings that do not
> > strictly describe HW.
> > 
> > A simple example: ECC configuration on NAND devices. This is clearly a
> > configuration thing, the NAND controller is usually able to support
> > several kind of strength+ECC-block-size config, but we are able to
> > overload this with the nand-ecc-xxx properties. Another example, still
> > MTD related: MTD partitions, this is purely a software configuration,
> > still we allow users to pass this information in the DT. You want
> > another one? What about the linux,code and linux,input-type properties
> > described here [1]?
> > 
> > So please, let's not use these "this is not decribing HW" or "this is
> > linux specific" arguments every time someone tries to encode something
> > that can be considered a configuration detail.
> > 
> > Let's be pragmatic. How you want to use your timer counter blocks (I'm
> > talking about atmel TCBs) is clearly board specific. Whether you want
> > to use the PIT for your clocksource or use one or 2 channels of a TCB
> > at a specific resolution is again board specific. We need a solution to
> > assign timer channels to a linux function, and I'm not convinced
> > passing this information through the command line makes much more sense
> > than specifying it in the DT (and it's definitely less intuitive, since
> > you have to reference something defined in the DT from the cmdline).
> > 
> > Now, in his review, Mark says:
> > 
> > "
> > To me it sounds like what we need is Linux infrastructure that allows
> > one to register a device as having both clockevent/clocksource
> > functionality.
> > 
> > That way, we can choose to do something sane at boot time, and if the
> > user really wants specific devices used in specific ways, they can
> > request that.
> > "
> > 
> > Does that mean that, after adding this "HW timer" infrastructure, we
> > would have a standard way to assign a function to a specific timer
> > block from the DT? How is this different from what I suggest below
> > (note the linux, prefix on my linux,timer-function property, which
> > clearly shows that this is Linux specific)?  
> 
> I like the 'chosen' approach with the nodes you are proposing below. Thanks for
> the constructive suggestion. The binding description matches perfectly what we
> are trying to achieve.

Actually, this is Alexandre who initially suggested the chosen
approach (I thought it was important to mention that ;-)).

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-08  8:57                         ` Boris Brezillon
  0 siblings, 0 replies; 189+ messages in thread
From: Boris Brezillon @ 2017-06-08  8:57 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Alexandre Belloni, Rob Herring, Nicolas Ferre,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Thomas Gleixner,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Mark Rutland

On Thu, 8 Jun 2017 10:40:26 +0200
Daniel Lezcano <daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:

> > > 
> > > Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
> > > 
> > > That will tell you the story.  
> > 
> > Then we're in a deadlock situation here. I'm tired of hearing this kind
> > of argument "DT is only supposed to describe HW, not configuration, bla
> > bla". The truth is, we already have plenty of bindings that do not
> > strictly describe HW.
> > 
> > A simple example: ECC configuration on NAND devices. This is clearly a
> > configuration thing, the NAND controller is usually able to support
> > several kind of strength+ECC-block-size config, but we are able to
> > overload this with the nand-ecc-xxx properties. Another example, still
> > MTD related: MTD partitions, this is purely a software configuration,
> > still we allow users to pass this information in the DT. You want
> > another one? What about the linux,code and linux,input-type properties
> > described here [1]?
> > 
> > So please, let's not use these "this is not decribing HW" or "this is
> > linux specific" arguments every time someone tries to encode something
> > that can be considered a configuration detail.
> > 
> > Let's be pragmatic. How you want to use your timer counter blocks (I'm
> > talking about atmel TCBs) is clearly board specific. Whether you want
> > to use the PIT for your clocksource or use one or 2 channels of a TCB
> > at a specific resolution is again board specific. We need a solution to
> > assign timer channels to a linux function, and I'm not convinced
> > passing this information through the command line makes much more sense
> > than specifying it in the DT (and it's definitely less intuitive, since
> > you have to reference something defined in the DT from the cmdline).
> > 
> > Now, in his review, Mark says:
> > 
> > "
> > To me it sounds like what we need is Linux infrastructure that allows
> > one to register a device as having both clockevent/clocksource
> > functionality.
> > 
> > That way, we can choose to do something sane at boot time, and if the
> > user really wants specific devices used in specific ways, they can
> > request that.
> > "
> > 
> > Does that mean that, after adding this "HW timer" infrastructure, we
> > would have a standard way to assign a function to a specific timer
> > block from the DT? How is this different from what I suggest below
> > (note the linux, prefix on my linux,timer-function property, which
> > clearly shows that this is Linux specific)?  
> 
> I like the 'chosen' approach with the nodes you are proposing below. Thanks for
> the constructive suggestion. The binding description matches perfectly what we
> are trying to achieve.

Actually, this is Alexandre who initially suggested the chosen
approach (I thought it was important to mention that ;-)).
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-08  8:57                         ` Boris Brezillon
  0 siblings, 0 replies; 189+ messages in thread
From: Boris Brezillon @ 2017-06-08  8:57 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 8 Jun 2017 10:40:26 +0200
Daniel Lezcano <daniel.lezcano@linaro.org> wrote:

> > > 
> > > Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
> > > 
> > > That will tell you the story.  
> > 
> > Then we're in a deadlock situation here. I'm tired of hearing this kind
> > of argument "DT is only supposed to describe HW, not configuration, bla
> > bla". The truth is, we already have plenty of bindings that do not
> > strictly describe HW.
> > 
> > A simple example: ECC configuration on NAND devices. This is clearly a
> > configuration thing, the NAND controller is usually able to support
> > several kind of strength+ECC-block-size config, but we are able to
> > overload this with the nand-ecc-xxx properties. Another example, still
> > MTD related: MTD partitions, this is purely a software configuration,
> > still we allow users to pass this information in the DT. You want
> > another one? What about the linux,code and linux,input-type properties
> > described here [1]?
> > 
> > So please, let's not use these "this is not decribing HW" or "this is
> > linux specific" arguments every time someone tries to encode something
> > that can be considered a configuration detail.
> > 
> > Let's be pragmatic. How you want to use your timer counter blocks (I'm
> > talking about atmel TCBs) is clearly board specific. Whether you want
> > to use the PIT for your clocksource or use one or 2 channels of a TCB
> > at a specific resolution is again board specific. We need a solution to
> > assign timer channels to a linux function, and I'm not convinced
> > passing this information through the command line makes much more sense
> > than specifying it in the DT (and it's definitely less intuitive, since
> > you have to reference something defined in the DT from the cmdline).
> > 
> > Now, in his review, Mark says:
> > 
> > "
> > To me it sounds like what we need is Linux infrastructure that allows
> > one to register a device as having both clockevent/clocksource
> > functionality.
> > 
> > That way, we can choose to do something sane at boot time, and if the
> > user really wants specific devices used in specific ways, they can
> > request that.
> > "
> > 
> > Does that mean that, after adding this "HW timer" infrastructure, we
> > would have a standard way to assign a function to a specific timer
> > block from the DT? How is this different from what I suggest below
> > (note the linux, prefix on my linux,timer-function property, which
> > clearly shows that this is Linux specific)?  
> 
> I like the 'chosen' approach with the nodes you are proposing below. Thanks for
> the constructive suggestion. The binding description matches perfectly what we
> are trying to achieve.

Actually, this is Alexandre who initially suggested the chosen
approach (I thought it was important to mention that ;-)).

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
  2017-06-08  8:40                       ` Daniel Lezcano
  (?)
@ 2017-06-12 12:54                         ` Nicolas Ferre
  -1 siblings, 0 replies; 189+ messages in thread
From: Nicolas Ferre @ 2017-06-12 12:54 UTC (permalink / raw)
  To: Daniel Lezcano, Rob Herring, devicetree
  Cc: Boris Brezillon, Alexandre Belloni, linux-arm-kernel,
	linux-kernel, Thomas Gleixner, Mark Rutland

Le 08/06/2017 à 10:40, Daniel Lezcano a écrit :
> On Thu, Jun 08, 2017 at 10:13:34AM +0200, Boris Brezillon wrote:
>> On Thu, 8 Jun 2017 09:44:46 +0200
>> Daniel Lezcano <daniel.lezcano@linaro.org> wrote:
>>
>>> +Mark Rutland, +Rob Herring
>>
>> Mark doesn't seem to be CCed.
> 
> Ah, yes. Thanks for fixing this.
> 
>>>
>>>
>>> Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
>>>
>>> That will tell you the story.
>>
>> Then we're in a deadlock situation here. I'm tired of hearing this kind
>> of argument "DT is only supposed to describe HW, not configuration, bla
>> bla". The truth is, we already have plenty of bindings that do not
>> strictly describe HW.
>>
>> A simple example: ECC configuration on NAND devices. This is clearly a
>> configuration thing, the NAND controller is usually able to support
>> several kind of strength+ECC-block-size config, but we are able to
>> overload this with the nand-ecc-xxx properties. Another example, still
>> MTD related: MTD partitions, this is purely a software configuration,
>> still we allow users to pass this information in the DT. You want
>> another one? What about the linux,code and linux,input-type properties
>> described here [1]?
>>
>> So please, let's not use these "this is not decribing HW" or "this is
>> linux specific" arguments every time someone tries to encode something
>> that can be considered a configuration detail.
>>
>> Let's be pragmatic. How you want to use your timer counter blocks (I'm
>> talking about atmel TCBs) is clearly board specific. Whether you want
>> to use the PIT for your clocksource or use one or 2 channels of a TCB
>> at a specific resolution is again board specific. We need a solution to
>> assign timer channels to a linux function, and I'm not convinced
>> passing this information through the command line makes much more sense
>> than specifying it in the DT (and it's definitely less intuitive, since
>> you have to reference something defined in the DT from the cmdline).
>>
>> Now, in his review, Mark says:
>>
>> "
>> To me it sounds like what we need is Linux infrastructure that allows
>> one to register a device as having both clockevent/clocksource
>> functionality.
>>
>> That way, we can choose to do something sane at boot time, and if the
>> user really wants specific devices used in specific ways, they can
>> request that.
>> "
>>
>> Does that mean that, after adding this "HW timer" infrastructure, we
>> would have a standard way to assign a function to a specific timer
>> block from the DT? How is this different from what I suggest below
>> (note the linux, prefix on my linux,timer-function property, which
>> clearly shows that this is Linux specific)?
> 
> I like the 'chosen' approach with the nodes you are proposing below. Thanks for
> the constructive suggestion. The binding description matches perfectly what we
> are trying to achieve.
> 
> Rob? what do you think?

I'm following this work from a distance but as we've just celebrated the
1st anniversary for this patch series (11 June 2016), I propose that we
now make up our mind quickly. Everybody seem to be on the same page and
willing to make this rework move forward.

In Microchip/Atmel we would like to actually use this TCB rework both
internally and in our mainline work to avoid having to rely on our own
out-of-tree implementation.

The newly-added samv7 cortex-M can't boot without this series and a use
of our current cortex-A SoCs with TrustZone in Secure World (SWd) is not
possible with current mainline code only. On these two examples, the
current timer on which we rely, the PIT, is not present.

So you probably understand that more than one year without real progress
begins to be a little bit frustrating for the AT91 users...

Regards,


>>> On Thu, Jun 08, 2017 at 07:42:36AM +0200, Boris Brezillon wrote:
>>>> Le Thu, 8 Jun 2017 01:17:15 +0200,
>>>> Alexandre Belloni <alexandre.belloni@free-electrons.com> a écrit :
>>>>   
>>>>> On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:  
>>>>>>> I was going to agree but this is not flexible enough because the
>>>>>>> quadrature decoder always uses the first two channels. So on some
>>>>>>> products, we may have:
>>>>>>>  - TCB0:
>>>>>>>    o channels 0,1: qdec
>>>>>>>    o channel 2: clocksource
>>>>>>>
>>>>>>>  - TCB1:
>>>>>>>    o channels 0,1: qdec
>>>>>>>    o channel 2: clockevent
>>>>>>>
>>>>>>> This avoids wasting TCB channels.    
>>>>>>
>>>>>> Ok. In this case you can check if the interrupt is specified for the node, if
>>>>>> yes, then it is a clockevent.
>>>>>>     
>>>>>
>>>>> But currently it is always specified in the SoC's dtsi. I don't find
>>>>> that too practical to push that to the board's dts. Also, lying by
>>>>> omission (the IRQ is always wired) in the DT is not different from
>>>>> having a property selecting which timer is the clocksource and which is
>>>>> the clockevent.
>>>>>   
>>>>
>>>> I agree with Alexandre here. Really, there's not much we can do to
>>>> detect which timer should be used as a clockevent and which one should
>>>> be used as a clocksource except explicitly specifying it in the DT.
>>>> Having an interrupt defined in one case (clockevent) and undefined in
>>>> the other case (clocksource), is just as hack-ish as the detection logic
>>>> Alexandre developed to avoid explicitly specifying the function
>>>> assigned to a specific timer.
>>>>
>>>> Can we please find a solution that makes everyone happy (DT,
>>>> clocksoure/clockevent and at91 maintainers)?
>>>>
>>>> How about adding a linux,timer-function property to specify which
>>>> function this timer is providing?
>>>>
>>>> Something like that for example:
>>>>
>>>> 	tcb0: timer@fff7c000 {
>>>> 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
>>>> 		#address-cells = <1>;
>>>> 		#size-cells = <0>;
>>>> 		reg = <0xfff7c000 0x100>;
>>>> 		interrupts = <18 4>;
>>>> 		clocks = <&tcb0_clk>, <&clk32k>;
>>>> 		clock-names = "t0_clk", "slow_clk";
>>>>
>>>> 		timer@0 {
>>>> 			compatible = "atmel,tcb-timer";
>>>> 			reg = <0>, <1>;
>>>> 			linux,timer-function = "clocksource";
>>>> 		};
>>>>
>>>> 		timer@2 {
>>>> 			compatible = "atmel,tcb-timer";
>>>> 			reg = <2>;
>>>> 			linux,timer-function = "clockevent";
>>>> 		};
>>>> 	};
>>>>
>>>> Alternatively, we could have a property or a node in chosen describing which
>>>> timer should be used:
>>>>
>>>> 	chosen {
>>>> 		clockevent {
>>>> 			timer = <&timer2>;
>>>> 		};
>>>>
>>>> 		clocksource {
>>>> 			timer = <&timer0>;
>>>> 		};
>>>>
>>>> 		/*
>>>> 		 * or
>>>> 		 *
>>>> 		 * clockevent = <&timer2>;
>>>> 		 * clocksource = <&timer0>;
>>>> 		 *
>>>> 		 * but I think the clocksource/clockevent node approach
>>>> 		 * is more future proof in case we need to add extra
>>>> 		 * information like the expected resolution/precision or
>>>> 		 * anything that could be tweakable.
>>>> 		 */
>>>> 	};
>>>>
>>>> 	tcb0: timer@fff7c000 {
>>>> 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
>>>> 		#address-cells = <1>;
>>>> 		#size-cells = <0>;
>>>> 		reg = <0xfff7c000 0x100>;
>>>> 		interrupts = <18 4>;
>>>> 		clocks = <&tcb0_clk>, <&clk32k>;
>>>> 		clock-names = "t0_clk", "slow_clk";
>>>>
>>>> 		timer0: timer@0 {
>>>> 			compatible = "atmel,tcb-timer";
>>>> 			reg = <0>, <1>;
>>>> 		};
>>>>
>>>> 		timer2: timer@2 {
>>>> 			compatible = "atmel,tcb-timer";
>>>> 			reg = <2>;
>>>> 		};
>>>> 	};  
>>>
>>
>> [1]http://elixir.free-electrons.com/linux/latest/source/Documentation/devicetree/bindings/input/gpio-keys.txt
> 


-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-12 12:54                         ` Nicolas Ferre
  0 siblings, 0 replies; 189+ messages in thread
From: Nicolas Ferre @ 2017-06-12 12:54 UTC (permalink / raw)
  To: Daniel Lezcano, Rob Herring, devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: Boris Brezillon, Alexandre Belloni,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Thomas Gleixner,
	Mark Rutland

Le 08/06/2017 à 10:40, Daniel Lezcano a écrit :
> On Thu, Jun 08, 2017 at 10:13:34AM +0200, Boris Brezillon wrote:
>> On Thu, 8 Jun 2017 09:44:46 +0200
>> Daniel Lezcano <daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:
>>
>>> +Mark Rutland, +Rob Herring
>>
>> Mark doesn't seem to be CCed.
> 
> Ah, yes. Thanks for fixing this.
> 
>>>
>>>
>>> Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
>>>
>>> That will tell you the story.
>>
>> Then we're in a deadlock situation here. I'm tired of hearing this kind
>> of argument "DT is only supposed to describe HW, not configuration, bla
>> bla". The truth is, we already have plenty of bindings that do not
>> strictly describe HW.
>>
>> A simple example: ECC configuration on NAND devices. This is clearly a
>> configuration thing, the NAND controller is usually able to support
>> several kind of strength+ECC-block-size config, but we are able to
>> overload this with the nand-ecc-xxx properties. Another example, still
>> MTD related: MTD partitions, this is purely a software configuration,
>> still we allow users to pass this information in the DT. You want
>> another one? What about the linux,code and linux,input-type properties
>> described here [1]?
>>
>> So please, let's not use these "this is not decribing HW" or "this is
>> linux specific" arguments every time someone tries to encode something
>> that can be considered a configuration detail.
>>
>> Let's be pragmatic. How you want to use your timer counter blocks (I'm
>> talking about atmel TCBs) is clearly board specific. Whether you want
>> to use the PIT for your clocksource or use one or 2 channels of a TCB
>> at a specific resolution is again board specific. We need a solution to
>> assign timer channels to a linux function, and I'm not convinced
>> passing this information through the command line makes much more sense
>> than specifying it in the DT (and it's definitely less intuitive, since
>> you have to reference something defined in the DT from the cmdline).
>>
>> Now, in his review, Mark says:
>>
>> "
>> To me it sounds like what we need is Linux infrastructure that allows
>> one to register a device as having both clockevent/clocksource
>> functionality.
>>
>> That way, we can choose to do something sane at boot time, and if the
>> user really wants specific devices used in specific ways, they can
>> request that.
>> "
>>
>> Does that mean that, after adding this "HW timer" infrastructure, we
>> would have a standard way to assign a function to a specific timer
>> block from the DT? How is this different from what I suggest below
>> (note the linux, prefix on my linux,timer-function property, which
>> clearly shows that this is Linux specific)?
> 
> I like the 'chosen' approach with the nodes you are proposing below. Thanks for
> the constructive suggestion. The binding description matches perfectly what we
> are trying to achieve.
> 
> Rob? what do you think?

I'm following this work from a distance but as we've just celebrated the
1st anniversary for this patch series (11 June 2016), I propose that we
now make up our mind quickly. Everybody seem to be on the same page and
willing to make this rework move forward.

In Microchip/Atmel we would like to actually use this TCB rework both
internally and in our mainline work to avoid having to rely on our own
out-of-tree implementation.

The newly-added samv7 cortex-M can't boot without this series and a use
of our current cortex-A SoCs with TrustZone in Secure World (SWd) is not
possible with current mainline code only. On these two examples, the
current timer on which we rely, the PIT, is not present.

So you probably understand that more than one year without real progress
begins to be a little bit frustrating for the AT91 users...

Regards,


>>> On Thu, Jun 08, 2017 at 07:42:36AM +0200, Boris Brezillon wrote:
>>>> Le Thu, 8 Jun 2017 01:17:15 +0200,
>>>> Alexandre Belloni <alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> a écrit :
>>>>   
>>>>> On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:  
>>>>>>> I was going to agree but this is not flexible enough because the
>>>>>>> quadrature decoder always uses the first two channels. So on some
>>>>>>> products, we may have:
>>>>>>>  - TCB0:
>>>>>>>    o channels 0,1: qdec
>>>>>>>    o channel 2: clocksource
>>>>>>>
>>>>>>>  - TCB1:
>>>>>>>    o channels 0,1: qdec
>>>>>>>    o channel 2: clockevent
>>>>>>>
>>>>>>> This avoids wasting TCB channels.    
>>>>>>
>>>>>> Ok. In this case you can check if the interrupt is specified for the node, if
>>>>>> yes, then it is a clockevent.
>>>>>>     
>>>>>
>>>>> But currently it is always specified in the SoC's dtsi. I don't find
>>>>> that too practical to push that to the board's dts. Also, lying by
>>>>> omission (the IRQ is always wired) in the DT is not different from
>>>>> having a property selecting which timer is the clocksource and which is
>>>>> the clockevent.
>>>>>   
>>>>
>>>> I agree with Alexandre here. Really, there's not much we can do to
>>>> detect which timer should be used as a clockevent and which one should
>>>> be used as a clocksource except explicitly specifying it in the DT.
>>>> Having an interrupt defined in one case (clockevent) and undefined in
>>>> the other case (clocksource), is just as hack-ish as the detection logic
>>>> Alexandre developed to avoid explicitly specifying the function
>>>> assigned to a specific timer.
>>>>
>>>> Can we please find a solution that makes everyone happy (DT,
>>>> clocksoure/clockevent and at91 maintainers)?
>>>>
>>>> How about adding a linux,timer-function property to specify which
>>>> function this timer is providing?
>>>>
>>>> Something like that for example:
>>>>
>>>> 	tcb0: timer@fff7c000 {
>>>> 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
>>>> 		#address-cells = <1>;
>>>> 		#size-cells = <0>;
>>>> 		reg = <0xfff7c000 0x100>;
>>>> 		interrupts = <18 4>;
>>>> 		clocks = <&tcb0_clk>, <&clk32k>;
>>>> 		clock-names = "t0_clk", "slow_clk";
>>>>
>>>> 		timer@0 {
>>>> 			compatible = "atmel,tcb-timer";
>>>> 			reg = <0>, <1>;
>>>> 			linux,timer-function = "clocksource";
>>>> 		};
>>>>
>>>> 		timer@2 {
>>>> 			compatible = "atmel,tcb-timer";
>>>> 			reg = <2>;
>>>> 			linux,timer-function = "clockevent";
>>>> 		};
>>>> 	};
>>>>
>>>> Alternatively, we could have a property or a node in chosen describing which
>>>> timer should be used:
>>>>
>>>> 	chosen {
>>>> 		clockevent {
>>>> 			timer = <&timer2>;
>>>> 		};
>>>>
>>>> 		clocksource {
>>>> 			timer = <&timer0>;
>>>> 		};
>>>>
>>>> 		/*
>>>> 		 * or
>>>> 		 *
>>>> 		 * clockevent = <&timer2>;
>>>> 		 * clocksource = <&timer0>;
>>>> 		 *
>>>> 		 * but I think the clocksource/clockevent node approach
>>>> 		 * is more future proof in case we need to add extra
>>>> 		 * information like the expected resolution/precision or
>>>> 		 * anything that could be tweakable.
>>>> 		 */
>>>> 	};
>>>>
>>>> 	tcb0: timer@fff7c000 {
>>>> 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
>>>> 		#address-cells = <1>;
>>>> 		#size-cells = <0>;
>>>> 		reg = <0xfff7c000 0x100>;
>>>> 		interrupts = <18 4>;
>>>> 		clocks = <&tcb0_clk>, <&clk32k>;
>>>> 		clock-names = "t0_clk", "slow_clk";
>>>>
>>>> 		timer0: timer@0 {
>>>> 			compatible = "atmel,tcb-timer";
>>>> 			reg = <0>, <1>;
>>>> 		};
>>>>
>>>> 		timer2: timer@2 {
>>>> 			compatible = "atmel,tcb-timer";
>>>> 			reg = <2>;
>>>> 		};
>>>> 	};  
>>>
>>
>> [1]http://elixir.free-electrons.com/linux/latest/source/Documentation/devicetree/bindings/input/gpio-keys.txt
> 


-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-12 12:54                         ` Nicolas Ferre
  0 siblings, 0 replies; 189+ messages in thread
From: Nicolas Ferre @ 2017-06-12 12:54 UTC (permalink / raw)
  To: linux-arm-kernel

Le 08/06/2017 ? 10:40, Daniel Lezcano a ?crit :
> On Thu, Jun 08, 2017 at 10:13:34AM +0200, Boris Brezillon wrote:
>> On Thu, 8 Jun 2017 09:44:46 +0200
>> Daniel Lezcano <daniel.lezcano@linaro.org> wrote:
>>
>>> +Mark Rutland, +Rob Herring
>>
>> Mark doesn't seem to be CCed.
> 
> Ah, yes. Thanks for fixing this.
> 
>>>
>>>
>>> Alexandre, Boris, have a look at https://www.spinics.net/lists/arm-kernel/msg572652.html
>>>
>>> That will tell you the story.
>>
>> Then we're in a deadlock situation here. I'm tired of hearing this kind
>> of argument "DT is only supposed to describe HW, not configuration, bla
>> bla". The truth is, we already have plenty of bindings that do not
>> strictly describe HW.
>>
>> A simple example: ECC configuration on NAND devices. This is clearly a
>> configuration thing, the NAND controller is usually able to support
>> several kind of strength+ECC-block-size config, but we are able to
>> overload this with the nand-ecc-xxx properties. Another example, still
>> MTD related: MTD partitions, this is purely a software configuration,
>> still we allow users to pass this information in the DT. You want
>> another one? What about the linux,code and linux,input-type properties
>> described here [1]?
>>
>> So please, let's not use these "this is not decribing HW" or "this is
>> linux specific" arguments every time someone tries to encode something
>> that can be considered a configuration detail.
>>
>> Let's be pragmatic. How you want to use your timer counter blocks (I'm
>> talking about atmel TCBs) is clearly board specific. Whether you want
>> to use the PIT for your clocksource or use one or 2 channels of a TCB
>> at a specific resolution is again board specific. We need a solution to
>> assign timer channels to a linux function, and I'm not convinced
>> passing this information through the command line makes much more sense
>> than specifying it in the DT (and it's definitely less intuitive, since
>> you have to reference something defined in the DT from the cmdline).
>>
>> Now, in his review, Mark says:
>>
>> "
>> To me it sounds like what we need is Linux infrastructure that allows
>> one to register a device as having both clockevent/clocksource
>> functionality.
>>
>> That way, we can choose to do something sane at boot time, and if the
>> user really wants specific devices used in specific ways, they can
>> request that.
>> "
>>
>> Does that mean that, after adding this "HW timer" infrastructure, we
>> would have a standard way to assign a function to a specific timer
>> block from the DT? How is this different from what I suggest below
>> (note the linux, prefix on my linux,timer-function property, which
>> clearly shows that this is Linux specific)?
> 
> I like the 'chosen' approach with the nodes you are proposing below. Thanks for
> the constructive suggestion. The binding description matches perfectly what we
> are trying to achieve.
> 
> Rob? what do you think?

I'm following this work from a distance but as we've just celebrated the
1st anniversary for this patch series (11 June 2016), I propose that we
now make up our mind quickly. Everybody seem to be on the same page and
willing to make this rework move forward.

In Microchip/Atmel we would like to actually use this TCB rework both
internally and in our mainline work to avoid having to rely on our own
out-of-tree implementation.

The newly-added samv7 cortex-M can't boot without this series and a use
of our current cortex-A SoCs with TrustZone in Secure World (SWd) is not
possible with current mainline code only. On these two examples, the
current timer on which we rely, the PIT, is not present.

So you probably understand that more than one year without real progress
begins to be a little bit frustrating for the AT91 users...

Regards,


>>> On Thu, Jun 08, 2017 at 07:42:36AM +0200, Boris Brezillon wrote:
>>>> Le Thu, 8 Jun 2017 01:17:15 +0200,
>>>> Alexandre Belloni <alexandre.belloni@free-electrons.com> a ?crit :
>>>>   
>>>>> On 07/06/2017 at 23:08:48 +0200, Daniel Lezcano wrote:  
>>>>>>> I was going to agree but this is not flexible enough because the
>>>>>>> quadrature decoder always uses the first two channels. So on some
>>>>>>> products, we may have:
>>>>>>>  - TCB0:
>>>>>>>    o channels 0,1: qdec
>>>>>>>    o channel 2: clocksource
>>>>>>>
>>>>>>>  - TCB1:
>>>>>>>    o channels 0,1: qdec
>>>>>>>    o channel 2: clockevent
>>>>>>>
>>>>>>> This avoids wasting TCB channels.    
>>>>>>
>>>>>> Ok. In this case you can check if the interrupt is specified for the node, if
>>>>>> yes, then it is a clockevent.
>>>>>>     
>>>>>
>>>>> But currently it is always specified in the SoC's dtsi. I don't find
>>>>> that too practical to push that to the board's dts. Also, lying by
>>>>> omission (the IRQ is always wired) in the DT is not different from
>>>>> having a property selecting which timer is the clocksource and which is
>>>>> the clockevent.
>>>>>   
>>>>
>>>> I agree with Alexandre here. Really, there's not much we can do to
>>>> detect which timer should be used as a clockevent and which one should
>>>> be used as a clocksource except explicitly specifying it in the DT.
>>>> Having an interrupt defined in one case (clockevent) and undefined in
>>>> the other case (clocksource), is just as hack-ish as the detection logic
>>>> Alexandre developed to avoid explicitly specifying the function
>>>> assigned to a specific timer.
>>>>
>>>> Can we please find a solution that makes everyone happy (DT,
>>>> clocksoure/clockevent and at91 maintainers)?
>>>>
>>>> How about adding a linux,timer-function property to specify which
>>>> function this timer is providing?
>>>>
>>>> Something like that for example:
>>>>
>>>> 	tcb0: timer at fff7c000 {
>>>> 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
>>>> 		#address-cells = <1>;
>>>> 		#size-cells = <0>;
>>>> 		reg = <0xfff7c000 0x100>;
>>>> 		interrupts = <18 4>;
>>>> 		clocks = <&tcb0_clk>, <&clk32k>;
>>>> 		clock-names = "t0_clk", "slow_clk";
>>>>
>>>> 		timer at 0 {
>>>> 			compatible = "atmel,tcb-timer";
>>>> 			reg = <0>, <1>;
>>>> 			linux,timer-function = "clocksource";
>>>> 		};
>>>>
>>>> 		timer at 2 {
>>>> 			compatible = "atmel,tcb-timer";
>>>> 			reg = <2>;
>>>> 			linux,timer-function = "clockevent";
>>>> 		};
>>>> 	};
>>>>
>>>> Alternatively, we could have a property or a node in chosen describing which
>>>> timer should be used:
>>>>
>>>> 	chosen {
>>>> 		clockevent {
>>>> 			timer = <&timer2>;
>>>> 		};
>>>>
>>>> 		clocksource {
>>>> 			timer = <&timer0>;
>>>> 		};
>>>>
>>>> 		/*
>>>> 		 * or
>>>> 		 *
>>>> 		 * clockevent = <&timer2>;
>>>> 		 * clocksource = <&timer0>;
>>>> 		 *
>>>> 		 * but I think the clocksource/clockevent node approach
>>>> 		 * is more future proof in case we need to add extra
>>>> 		 * information like the expected resolution/precision or
>>>> 		 * anything that could be tweakable.
>>>> 		 */
>>>> 	};
>>>>
>>>> 	tcb0: timer at fff7c000 {
>>>> 		compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
>>>> 		#address-cells = <1>;
>>>> 		#size-cells = <0>;
>>>> 		reg = <0xfff7c000 0x100>;
>>>> 		interrupts = <18 4>;
>>>> 		clocks = <&tcb0_clk>, <&clk32k>;
>>>> 		clock-names = "t0_clk", "slow_clk";
>>>>
>>>> 		timer0: timer at 0 {
>>>> 			compatible = "atmel,tcb-timer";
>>>> 			reg = <0>, <1>;
>>>> 		};
>>>>
>>>> 		timer2: timer at 2 {
>>>> 			compatible = "atmel,tcb-timer";
>>>> 			reg = <2>;
>>>> 		};
>>>> 	};  
>>>
>>
>> [1]http://elixir.free-electrons.com/linux/latest/source/Documentation/devicetree/bindings/input/gpio-keys.txt
> 


-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-12 13:25                           ` Daniel Lezcano
  0 siblings, 0 replies; 189+ messages in thread
From: Daniel Lezcano @ 2017-06-12 13:25 UTC (permalink / raw)
  To: Nicolas Ferre, Rob Herring, devicetree
  Cc: Boris Brezillon, Alexandre Belloni, linux-arm-kernel,
	linux-kernel, Thomas Gleixner, Mark Rutland

On 12/06/2017 14:54, Nicolas Ferre wrote:

[ ... ]

>> I like the 'chosen' approach with the nodes you are proposing below. Thanks for
>> the constructive suggestion. The binding description matches perfectly what we
>> are trying to achieve.
>>
>> Rob? what do you think?
> 
> I'm following this work from a distance but as we've just celebrated the
> 1st anniversary for this patch series (11 June 2016), I propose that we
> now make up our mind quickly. Everybody seem to be on the same page and
> willing to make this rework move forward.
> 
> In Microchip/Atmel we would like to actually use this TCB rework both
> internally and in our mainline work to avoid having to rely on our own
> out-of-tree implementation.
> 
> The newly-added samv7 cortex-M can't boot without this series and a use
> of our current cortex-A SoCs with TrustZone in Secure World (SWd) is not
> possible with current mainline code only. On these two examples, the
> current timer on which we rely, the PIT, is not present.
> 
> So you probably understand that more than one year without real progress
> begins to be a little bit frustrating for the AT91 users...

Nicolas,

who are you exactly blaming?

Are you surprised a 58 patches series, with a gazillion of Cc'ed people
posted awhile ago, is ignored?




-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-12 13:25                           ` Daniel Lezcano
  0 siblings, 0 replies; 189+ messages in thread
From: Daniel Lezcano @ 2017-06-12 13:25 UTC (permalink / raw)
  To: Nicolas Ferre, Rob Herring, devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: Boris Brezillon, Alexandre Belloni,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Thomas Gleixner,
	Mark Rutland

On 12/06/2017 14:54, Nicolas Ferre wrote:

[ ... ]

>> I like the 'chosen' approach with the nodes you are proposing below. Thanks for
>> the constructive suggestion. The binding description matches perfectly what we
>> are trying to achieve.
>>
>> Rob? what do you think?
> 
> I'm following this work from a distance but as we've just celebrated the
> 1st anniversary for this patch series (11 June 2016), I propose that we
> now make up our mind quickly. Everybody seem to be on the same page and
> willing to make this rework move forward.
> 
> In Microchip/Atmel we would like to actually use this TCB rework both
> internally and in our mainline work to avoid having to rely on our own
> out-of-tree implementation.
> 
> The newly-added samv7 cortex-M can't boot without this series and a use
> of our current cortex-A SoCs with TrustZone in Secure World (SWd) is not
> possible with current mainline code only. On these two examples, the
> current timer on which we rely, the PIT, is not present.
> 
> So you probably understand that more than one year without real progress
> begins to be a little bit frustrating for the AT91 users...

Nicolas,

who are you exactly blaming?

Are you surprised a 58 patches series, with a gazillion of Cc'ed people
posted awhile ago, is ignored?




-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-12 13:25                           ` Daniel Lezcano
  0 siblings, 0 replies; 189+ messages in thread
From: Daniel Lezcano @ 2017-06-12 13:25 UTC (permalink / raw)
  To: linux-arm-kernel

On 12/06/2017 14:54, Nicolas Ferre wrote:

[ ... ]

>> I like the 'chosen' approach with the nodes you are proposing below. Thanks for
>> the constructive suggestion. The binding description matches perfectly what we
>> are trying to achieve.
>>
>> Rob? what do you think?
> 
> I'm following this work from a distance but as we've just celebrated the
> 1st anniversary for this patch series (11 June 2016), I propose that we
> now make up our mind quickly. Everybody seem to be on the same page and
> willing to make this rework move forward.
> 
> In Microchip/Atmel we would like to actually use this TCB rework both
> internally and in our mainline work to avoid having to rely on our own
> out-of-tree implementation.
> 
> The newly-added samv7 cortex-M can't boot without this series and a use
> of our current cortex-A SoCs with TrustZone in Secure World (SWd) is not
> possible with current mainline code only. On these two examples, the
> current timer on which we rely, the PIT, is not present.
> 
> So you probably understand that more than one year without real progress
> begins to be a little bit frustrating for the AT91 users...

Nicolas,

who are you exactly blaming?

Are you surprised a 58 patches series, with a gazillion of Cc'ed people
posted awhile ago, is ignored?




-- 
 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-12 15:26                             ` Nicolas Ferre
  0 siblings, 0 replies; 189+ messages in thread
From: Nicolas Ferre @ 2017-06-12 15:26 UTC (permalink / raw)
  To: Daniel Lezcano, Rob Herring, devicetree
  Cc: Boris Brezillon, Alexandre Belloni, linux-arm-kernel,
	linux-kernel, Thomas Gleixner, Mark Rutland

Le 12/06/2017 à 15:25, Daniel Lezcano a écrit :
> On 12/06/2017 14:54, Nicolas Ferre wrote:
> 
> [ ... ]
> 
>>> I like the 'chosen' approach with the nodes you are proposing below. Thanks for
>>> the constructive suggestion. The binding description matches perfectly what we
>>> are trying to achieve.
>>>
>>> Rob? what do you think?
>>
>> I'm following this work from a distance but as we've just celebrated the
>> 1st anniversary for this patch series (11 June 2016), I propose that we
>> now make up our mind quickly. Everybody seem to be on the same page and
>> willing to make this rework move forward.
>>
>> In Microchip/Atmel we would like to actually use this TCB rework both
>> internally and in our mainline work to avoid having to rely on our own
>> out-of-tree implementation.
>>
>> The newly-added samv7 cortex-M can't boot without this series and a use
>> of our current cortex-A SoCs with TrustZone in Secure World (SWd) is not
>> possible with current mainline code only. On these two examples, the
>> current timer on which we rely, the PIT, is not present.
>>
>> So you probably understand that more than one year without real progress
>> begins to be a little bit frustrating for the AT91 users...
> 
> Nicolas,
> 
> who are you exactly blaming?
> 
> Are you surprised a 58 patches series, with a gazillion of Cc'ed people
> posted awhile ago, is ignored?

Daniel,

Well, I'm talking about the only patch about DT bindings here, not the
other (large number) of soc/board dts changes.
Note that Alexandre tried to extract this discussion from the other
patches without coming to a conclusion either ("[PATCH v3] ARM: at91:
Document new TCB bindings", for instance).

I had the feeling that this email thread was about to be fading out on a
DT binding discussion, as it had done a couple of times during the last
months... Both you and me produced "ping" messages to make this
discussion progress with no real success so far... This is why I was a
little worried.

Regards,
-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-12 15:26                             ` Nicolas Ferre
  0 siblings, 0 replies; 189+ messages in thread
From: Nicolas Ferre @ 2017-06-12 15:26 UTC (permalink / raw)
  To: Daniel Lezcano, Rob Herring, devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: Boris Brezillon, Alexandre Belloni,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Thomas Gleixner,
	Mark Rutland

Le 12/06/2017 à 15:25, Daniel Lezcano a écrit :
> On 12/06/2017 14:54, Nicolas Ferre wrote:
> 
> [ ... ]
> 
>>> I like the 'chosen' approach with the nodes you are proposing below. Thanks for
>>> the constructive suggestion. The binding description matches perfectly what we
>>> are trying to achieve.
>>>
>>> Rob? what do you think?
>>
>> I'm following this work from a distance but as we've just celebrated the
>> 1st anniversary for this patch series (11 June 2016), I propose that we
>> now make up our mind quickly. Everybody seem to be on the same page and
>> willing to make this rework move forward.
>>
>> In Microchip/Atmel we would like to actually use this TCB rework both
>> internally and in our mainline work to avoid having to rely on our own
>> out-of-tree implementation.
>>
>> The newly-added samv7 cortex-M can't boot without this series and a use
>> of our current cortex-A SoCs with TrustZone in Secure World (SWd) is not
>> possible with current mainline code only. On these two examples, the
>> current timer on which we rely, the PIT, is not present.
>>
>> So you probably understand that more than one year without real progress
>> begins to be a little bit frustrating for the AT91 users...
> 
> Nicolas,
> 
> who are you exactly blaming?
> 
> Are you surprised a 58 patches series, with a gazillion of Cc'ed people
> posted awhile ago, is ignored?

Daniel,

Well, I'm talking about the only patch about DT bindings here, not the
other (large number) of soc/board dts changes.
Note that Alexandre tried to extract this discussion from the other
patches without coming to a conclusion either ("[PATCH v3] ARM: at91:
Document new TCB bindings", for instance).

I had the feeling that this email thread was about to be fading out on a
DT binding discussion, as it had done a couple of times during the last
months... Both you and me produced "ping" messages to make this
discussion progress with no real success so far... This is why I was a
little worried.

Regards,
-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks
@ 2017-06-12 15:26                             ` Nicolas Ferre
  0 siblings, 0 replies; 189+ messages in thread
From: Nicolas Ferre @ 2017-06-12 15:26 UTC (permalink / raw)
  To: linux-arm-kernel

Le 12/06/2017 ? 15:25, Daniel Lezcano a ?crit :
> On 12/06/2017 14:54, Nicolas Ferre wrote:
> 
> [ ... ]
> 
>>> I like the 'chosen' approach with the nodes you are proposing below. Thanks for
>>> the constructive suggestion. The binding description matches perfectly what we
>>> are trying to achieve.
>>>
>>> Rob? what do you think?
>>
>> I'm following this work from a distance but as we've just celebrated the
>> 1st anniversary for this patch series (11 June 2016), I propose that we
>> now make up our mind quickly. Everybody seem to be on the same page and
>> willing to make this rework move forward.
>>
>> In Microchip/Atmel we would like to actually use this TCB rework both
>> internally and in our mainline work to avoid having to rely on our own
>> out-of-tree implementation.
>>
>> The newly-added samv7 cortex-M can't boot without this series and a use
>> of our current cortex-A SoCs with TrustZone in Secure World (SWd) is not
>> possible with current mainline code only. On these two examples, the
>> current timer on which we rely, the PIT, is not present.
>>
>> So you probably understand that more than one year without real progress
>> begins to be a little bit frustrating for the AT91 users...
> 
> Nicolas,
> 
> who are you exactly blaming?
> 
> Are you surprised a 58 patches series, with a gazillion of Cc'ed people
> posted awhile ago, is ignored?

Daniel,

Well, I'm talking about the only patch about DT bindings here, not the
other (large number) of soc/board dts changes.
Note that Alexandre tried to extract this discussion from the other
patches without coming to a conclusion either ("[PATCH v3] ARM: at91:
Document new TCB bindings", for instance).

I had the feeling that this email thread was about to be fading out on a
DT binding discussion, as it had done a couple of times during the last
months... Both you and me produced "ping" messages to make this
discussion progress with no real success so far... This is why I was a
little worried.

Regards,
-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 00/58] ARM: at91: rework Atmel TCB drivers
  2017-05-30 21:50 ` Alexandre Belloni
  (?)
@ 2017-07-06  6:40   ` Thierry Reding
  -1 siblings, 0 replies; 189+ messages in thread
From: Thierry Reding @ 2017-07-06  6:40 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Nicolas Ferre, Boris Brezillon, linux-arm-kernel, linux-kernel,
	Antoine Aubert, Daniel Lezcano, devicetree, Douglas Gilbert,
	Fabio Porcedda, Gregory CLEMENT, Gregory Hermant,
	Joachim Eastwood, linux-pwm, Marek Vasut, Martin Reimann,
	Peter Rosin, Raashid Muhammed, Rob Herring, Rodolfo Giometti,
	Sergio Tanzilli, Thomas Gleixner, Tim Schendekehl

[-- Attachment #1: Type: text/plain, Size: 1372 bytes --]

On Tue, May 30, 2017 at 11:50:41PM +0200, Alexandre Belloni wrote:
> Hi,
> 
> This series reworks the Atmel Timer counter Block drivers. Those blocks
> each have 3 counters with 2 channels each and can be used for
> multiple functions:
>  - timers
>  - PWMs
>  - Quadrature decoders
>  - Stepper motor counters
> 
> Up until now, each TCB was fully used by each driver, possibly wasting
> counters/channels.
> 
> There is a second issue motivating that rework. Until now, the PIT is
> still used to boot then later in the boot sequence, the clocksource is
> switched to the TCB. This ends up not working well with preempt-rt
> because on some SoCs, the PIT interrupt is shared with the DBGU uart.
> When using preempt-rt the interrupt flags for the PIT and the DBGU end
> up being incompatible.
> 
> The rework breaks the DT ABI. Backward compatibility can be kept by
> keeping tcb_clksrc and atmel_tclib but as AVR32 is now gone from the
> kernel, I don't think it makes much sense to keep them.
> 
> Also, there is no other choice than breaking the mainly unused
> pwm-atmel-tcb binding. Only the kizbox is actually using it.
> 
> I think the bindings are now ok and I hope we can take the DT changes
> for 4.13.

Has anyone volunteered to pick this up? What are the dependencies here
and how did you plan to get this merged?

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* Re: [PATCH 00/58] ARM: at91: rework Atmel TCB drivers
@ 2017-07-06  6:40   ` Thierry Reding
  0 siblings, 0 replies; 189+ messages in thread
From: Thierry Reding @ 2017-07-06  6:40 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Nicolas Ferre, Boris Brezillon, linux-arm-kernel, linux-kernel,
	Antoine Aubert, Daniel Lezcano, devicetree, Douglas Gilbert,
	Fabio Porcedda, Gregory CLEMENT, Gregory Hermant,
	Joachim Eastwood, linux-pwm, Marek Vasut, Martin Reimann,
	Peter Rosin, Raashid Muhammed, Rob Herring, Rodolfo Giometti, Se

[-- Attachment #1: Type: text/plain, Size: 1372 bytes --]

On Tue, May 30, 2017 at 11:50:41PM +0200, Alexandre Belloni wrote:
> Hi,
> 
> This series reworks the Atmel Timer counter Block drivers. Those blocks
> each have 3 counters with 2 channels each and can be used for
> multiple functions:
>  - timers
>  - PWMs
>  - Quadrature decoders
>  - Stepper motor counters
> 
> Up until now, each TCB was fully used by each driver, possibly wasting
> counters/channels.
> 
> There is a second issue motivating that rework. Until now, the PIT is
> still used to boot then later in the boot sequence, the clocksource is
> switched to the TCB. This ends up not working well with preempt-rt
> because on some SoCs, the PIT interrupt is shared with the DBGU uart.
> When using preempt-rt the interrupt flags for the PIT and the DBGU end
> up being incompatible.
> 
> The rework breaks the DT ABI. Backward compatibility can be kept by
> keeping tcb_clksrc and atmel_tclib but as AVR32 is now gone from the
> kernel, I don't think it makes much sense to keep them.
> 
> Also, there is no other choice than breaking the mainly unused
> pwm-atmel-tcb binding. Only the kizbox is actually using it.
> 
> I think the bindings are now ok and I hope we can take the DT changes
> for 4.13.

Has anyone volunteered to pick this up? What are the dependencies here
and how did you plan to get this merged?

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 189+ messages in thread

* [PATCH 00/58] ARM: at91: rework Atmel TCB drivers
@ 2017-07-06  6:40   ` Thierry Reding
  0 siblings, 0 replies; 189+ messages in thread
From: Thierry Reding @ 2017-07-06  6:40 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, May 30, 2017 at 11:50:41PM +0200, Alexandre Belloni wrote:
> Hi,
> 
> This series reworks the Atmel Timer counter Block drivers. Those blocks
> each have 3 counters with 2 channels each and can be used for
> multiple functions:
>  - timers
>  - PWMs
>  - Quadrature decoders
>  - Stepper motor counters
> 
> Up until now, each TCB was fully used by each driver, possibly wasting
> counters/channels.
> 
> There is a second issue motivating that rework. Until now, the PIT is
> still used to boot then later in the boot sequence, the clocksource is
> switched to the TCB. This ends up not working well with preempt-rt
> because on some SoCs, the PIT interrupt is shared with the DBGU uart.
> When using preempt-rt the interrupt flags for the PIT and the DBGU end
> up being incompatible.
> 
> The rework breaks the DT ABI. Backward compatibility can be kept by
> keeping tcb_clksrc and atmel_tclib but as AVR32 is now gone from the
> kernel, I don't think it makes much sense to keep them.
> 
> Also, there is no other choice than breaking the mainly unused
> pwm-atmel-tcb binding. Only the kizbox is actually using it.
> 
> I think the bindings are now ok and I hope we can take the DT changes
> for 4.13.

Has anyone volunteered to pick this up? What are the dependencies here
and how did you plan to get this merged?

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170706/813edc1e/attachment.sig>

^ permalink raw reply	[flat|nested] 189+ messages in thread

end of thread, other threads:[~2017-07-06  6:41 UTC | newest]

Thread overview: 189+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-30 21:50 [PATCH 00/58] ARM: at91: rework Atmel TCB drivers Alexandre Belloni
2017-05-30 21:50 ` Alexandre Belloni
2017-05-30 21:50 ` Alexandre Belloni
2017-05-30 21:50 ` [PATCH 01/58] ARM: at91: Document new TCB bindings Alexandre Belloni
2017-05-30 21:50   ` Alexandre Belloni
2017-06-07 21:17   ` Rob Herring
2017-06-07 21:17     ` Rob Herring
2017-06-07 21:17     ` Rob Herring
2017-05-30 21:50 ` [PATCH 02/58] ARM: dts: at91: at91rm9200: TC blocks are also simple-mfd and syscon devices Alexandre Belloni
2017-05-30 21:50   ` Alexandre Belloni
2017-05-30 21:50 ` [PATCH 03/58] ARM: dts: at91: at91rm9200ek: use TCB0 as clocksource Alexandre Belloni
2017-05-30 21:50   ` Alexandre Belloni
2017-05-30 21:50 ` [PATCH 04/58] ARM: dts: at91: mpa1600: " Alexandre Belloni
2017-05-30 21:50   ` Alexandre Belloni
2017-05-30 21:50 ` [PATCH 05/58] ARM: dts: at91: at91sam9260: TC blocks are also simple-mfd and syscon devices Alexandre Belloni
2017-05-30 21:50   ` Alexandre Belloni
2017-05-30 21:50 ` [PATCH 06/58] ARM: dts: at91: at91sam9260ek: use TCB0 as clocksource Alexandre Belloni
2017-05-30 21:50   ` Alexandre Belloni
2017-05-30 21:50 ` [PATCH 07/58] ARM: dts: at91: sam9_l9260: " Alexandre Belloni
2017-05-30 21:50   ` Alexandre Belloni
2017-05-30 21:50 ` [PATCH 08/58] ARM: dts: at91: ethernut5: " Alexandre Belloni
2017-05-30 21:50   ` Alexandre Belloni
2017-05-30 21:50 ` [PATCH 09/58] ARM: dts: at91: foxg20: " Alexandre Belloni
2017-05-30 21:50   ` Alexandre Belloni
2017-05-30 21:50 ` [PATCH 10/58] ARM: dts: at91: animeo_ip: " Alexandre Belloni
2017-05-30 21:50   ` Alexandre Belloni
2017-05-30 21:50 ` [PATCH 11/58] ARM: dts: at91: kizbox: " Alexandre Belloni
2017-05-30 21:50   ` Alexandre Belloni
2017-05-30 21:50 ` [PATCH 12/58] ARM: dts: at91: at91sam9g20ek: " Alexandre Belloni
2017-05-30 21:50   ` Alexandre Belloni
2017-05-30 21:50 ` [PATCH 13/58] ARM: dts: at91: ge863-pro3: " Alexandre Belloni
2017-05-30 21:50   ` Alexandre Belloni
2017-05-30 21:50 ` [PATCH 14/58] ARM: dts: at91: at91sam9261: TC blocks are also simple-mfd and syscon devices Alexandre Belloni
2017-05-30 21:50   ` Alexandre Belloni
2017-05-30 21:50 ` [PATCH 15/58] ARM: dts: at91: at91sam9261ek: use TCB0 as clocksource Alexandre Belloni
2017-05-30 21:50   ` Alexandre Belloni
2017-05-30 21:50 ` [PATCH 16/58] ARM: dts: at91: at91sam9263: TC blocks are also simple-mfd and syscon devices Alexandre Belloni
2017-05-30 21:50   ` Alexandre Belloni
2017-05-30 21:50 ` [PATCH 17/58] ARM: dts: at91: at91sam9263ek: use TCB0 as clocksource Alexandre Belloni
2017-05-30 21:50   ` Alexandre Belloni
2017-05-30 21:50 ` [PATCH 18/58] ARM: dts: at91: calao: " Alexandre Belloni
2017-05-30 21:50   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 19/58] ARM: dts: at91: at91sam9g45: TC blocks are also simple-mfd and syscon devices Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 20/58] ARM: dts: at91: at91sam9m10g45ek: use TCB0 as clocksource Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 21/58] ARM: dts: at91: pm9g45: " Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 22/58] ARM: dts: at91: at91sam9rl: TC blocks are also simple-mfd and syscon devices Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 23/58] ARM: dts: at91: at91sam9rlek: use TCB0 as clocksource Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 24/58] ARM: dts: at91: at91sam9n12: TC blocks are also simple-mfd and syscon devices Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 25/58] ARM: dts: at91: at91sam9n12ek: use TCB0 as clocksource Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 26/58] ARM: dts: at91: at91sam9x5: TC blocks are also simple-mfd and syscon devices Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 27/58] ARM: dts: at91: at91sam9x5cm: use TCB0 as clocksource Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 28/58] ARM: dts: at91: acme/g25: " Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 29/58] ARM: dts: at91: cosino: " Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 30/58] ARM: dts: at91: kizboxmini: " Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 31/58] ARM: dts: at91: sama5d3: TC blocks are also simple-mfd and syscon devices Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 32/58] ARM: dts: at91: sama5d3xek: use TCB0 as clocksource Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 33/58] ARM: dts: at91: sama5d3 Xplained: " Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 34/58] ARM: dts: at91: kizbox2: " Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 35/58] ARM: dts: at91: sama5d3xek_cmp: " Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 36/58] ARM: dts: at91: linea/tse850-3: " Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-06-01 18:52   ` Peter Rosin
2017-06-01 18:52     ` Peter Rosin
2017-05-30 21:51 ` [PATCH 37/58] ARM: dts: at91: sama5d4: TC blocks are also simple-mfd and syscon devices Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 38/58] ARM: dts: at91: sama5d4: Add TCB2 Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 39/58] ARM: dts: at91: sama5d4ek: use TCB2 as clocksource Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 40/58] ARM: dts: at91: sama5d4 Xplained: " Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 41/58] ARM: dts: at91: ma5d4: " Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 42/58] ARM: dts: at91: vinco: " Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-06-02 12:48   ` Gregory CLEMENT
2017-06-02 12:48     ` Gregory CLEMENT
2017-05-30 21:51 ` [PATCH 43/58] ARM: dts: at91: sama5d2: TC blocks are also simple-mfd and syscon devices Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 44/58] ARM: dts: at91: sama5d2 Xplained: use TCB0 as clocksource Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 45/58] ARM: at91: add TCB registers definitions Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 46/58] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-06-06 15:21   ` Daniel Lezcano
2017-06-06 15:21     ` Daniel Lezcano
2017-06-06 18:05     ` Alexandre Belloni
2017-06-06 18:05       ` Alexandre Belloni
2017-06-07 14:17       ` Daniel Lezcano
2017-06-07 14:17         ` Daniel Lezcano
2017-06-07 15:09         ` Alexandre Belloni
2017-06-07 15:09           ` Alexandre Belloni
2017-06-07 21:38           ` Daniel Lezcano
2017-06-07 21:38             ` Daniel Lezcano
2017-06-07 23:11             ` Alexandre Belloni
2017-06-07 23:11               ` Alexandre Belloni
2017-06-08  6:52             ` Boris Brezillon
2017-06-08  6:52               ` Boris Brezillon
2017-06-07 15:27         ` Alexandre Belloni
2017-06-07 15:27           ` Alexandre Belloni
2017-06-07 21:08           ` Daniel Lezcano
2017-06-07 21:08             ` Daniel Lezcano
2017-06-07 23:17             ` Alexandre Belloni
2017-06-07 23:17               ` Alexandre Belloni
2017-06-08  5:42               ` Boris Brezillon
2017-06-08  5:42                 ` Boris Brezillon
2017-06-08  5:42                 ` Boris Brezillon
2017-06-08  7:44                 ` Daniel Lezcano
2017-06-08  7:44                   ` Daniel Lezcano
2017-06-08  7:59                   ` Alexandre Belloni
2017-06-08  7:59                     ` Alexandre Belloni
2017-06-08  7:59                     ` Alexandre Belloni
2017-06-08  8:24                     ` Daniel Lezcano
2017-06-08  8:24                       ` Daniel Lezcano
2017-06-08  8:33                       ` Boris Brezillon
2017-06-08  8:33                         ` Boris Brezillon
2017-06-08  8:33                         ` Boris Brezillon
2017-06-08  8:42                       ` Alexandre Belloni
2017-06-08  8:42                         ` Alexandre Belloni
2017-06-08  8:13                   ` Boris Brezillon
2017-06-08  8:13                     ` Boris Brezillon
2017-06-08  8:40                     ` Daniel Lezcano
2017-06-08  8:40                       ` Daniel Lezcano
2017-06-08  8:40                       ` Daniel Lezcano
2017-06-08  8:57                       ` Boris Brezillon
2017-06-08  8:57                         ` Boris Brezillon
2017-06-08  8:57                         ` Boris Brezillon
2017-06-12 12:54                       ` Nicolas Ferre
2017-06-12 12:54                         ` Nicolas Ferre
2017-06-12 12:54                         ` Nicolas Ferre
2017-06-12 13:25                         ` Daniel Lezcano
2017-06-12 13:25                           ` Daniel Lezcano
2017-06-12 13:25                           ` Daniel Lezcano
2017-06-12 15:26                           ` Nicolas Ferre
2017-06-12 15:26                             ` Nicolas Ferre
2017-06-12 15:26                             ` Nicolas Ferre
2017-06-08  6:21             ` Boris Brezillon
2017-06-08  6:21               ` Boris Brezillon
2017-05-30 21:51 ` [PATCH 47/58] clocksource/drivers: timer-atmel-tcbclksrc: add clockevent device Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 48/58] clocksource/drivers: timer-atmel-tcbclksrc: add clockevent device on separate channel Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 49/58] clocksource/drivers: atmel-pit: allow unselecting ATMEL_PIT Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 50/58] ARM: at91/defconfig: sama5: unselect ATMEL_PIT Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 51/58] ARM: at91/defconfig: at91_dt " Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 52/58] PWM: atmel-tcb: switch to new binding Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 53/58] ARM: dts: at91: kizbox: switch to new pwm-atmel-tcb binding Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 54/58] clocksource/drivers: remove tcb_clksrc Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 55/58] misc: remove atmel_tclib.c Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 56/58] ARM: configs: at91: remove ATMEL_TCLIB Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 57/58] ARM: multi_v7_defconfig: Remove ATMEL_TCLIB Kconfig symbol Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-30 21:51 ` [PATCH 58/58] ARM: multi_v5_defconfig: " Alexandre Belloni
2017-05-30 21:51   ` Alexandre Belloni
2017-05-31  6:34 ` [PATCH 00/58] ARM: at91: rework Atmel TCB drivers Peter Rosin
2017-05-31  6:34   ` Peter Rosin
2017-05-31  6:34   ` Peter Rosin
2017-05-31  7:21   ` Alexandre Belloni
2017-05-31  7:21     ` Alexandre Belloni
2017-05-31  7:21     ` Alexandre Belloni
2017-07-06  6:40 ` Thierry Reding
2017-07-06  6:40   ` Thierry Reding
2017-07-06  6:40   ` Thierry Reding

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.