Skip to contentSkip to conversation

ARM: samsung-time: Prepare for multiplatform support

PATCH Superseded Tomasz Figa 6 participants 29 messages Apr 4, 2013 – Apr 11, 2013

Subsystems (7)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover ARM: samsung-time: Prepare for multiplatform support

This series is an attempt to make the samsung-time clocksource driver ready for multiplatform kernels. It moves the driver to drivers/clocksource, cleans it up from uses of static platform-specific definitions, simplifies timer interrupt handling and adds Device Tree support.

Only samsung-time driver is reworked to use the master driver at this time, since the PWM driver can be already considered broken at the moment and needs separate series of several patches to fix and clean it up, which I am already working on.

Tested on Universal C210 board with Device Tree. Not tested without Device Tree, since it has been already broken before this series. Compile tested for other related SoCs.

Changes since v3:
(http://thread.gmane.org/gmane.linux.kernel.samsung-soc/16664/)
- Changed the design to use common (master) driver for operations that can be done from both clocksource and PWM drivers (as suggested by Arnd Bergmann) - needed to properly synchronize access to PWM registers
- Moved handling of PWM prescaler and divider to master driver

Changes since v2:
(http://thread.gmane.org/gmane.linux.kernel.samsung-soc/16158)
- Addressed comments from Rob Herring and Mark Rutland
- Removed unused register definitions
- Replaced samsung,source-timer and samsung,event-timer properties with samsung,pwm-outputs property that defines which PWM channels are reserved for PWM outputs on particular platform
- Split non-DT and DT initialization into two functions
- Fixed a copy paste error

Changes since v1:
(http://thread.gmane.org/gmane.linux.kernel.samsung-soc/16005)
- Addressed comments from Mark Rutland
- Documented struct samsung_timer_variant
- Dropped inactive mail addresses from CC

Tomasz Figa (14):
ARM: SAMSUNG: Move samsung-time to drivers/clocksource
clocksource: samsung-time: Drop useless defines from public header
clocksource: samsung-time: Use local register definitions
mfd: Add Samsung PWM/timer master driver
ARM: SAMSUNG: Unify base address definitions of timer block
ARM: SAMSUNG: Add new PWM platform device
ARM: SAMSUNG: Set PWM platform data
clocksource: samsung-time: Use Samsung PWM/timer master driver
clocksource: samsung-time: Use variant data to get SoC-specific bits
clocksource: samsung-time: Use master driver to configure dividers
clocksource: samsung-time: Use clk_prepare_enable
clocksource: samsung-time: Use master driver to control PWM channels
clocksource: samsung-time: Move IRQ mask/ack handling to the driver
ARM: SAMSUNG: Remove unused PWM timer IRQ chip code

 .../devicetree/bindings/pwm/pwm-samsung.txt        |  37 ++
 arch/arm/Kconfig                                   |   1 -
 arch/arm/mach-exynos/common.c                      |  10 +
 arch/arm/mach-exynos/include/mach/irqs.h           |   3 +-
 arch/arm/mach-exynos/include/mach/map.h            |   1 +
 arch/arm/mach-s3c24xx/common.c                     |  10 +
 arch/arm/mach-s3c24xx/include/mach/irqs.h          |   6 +
 arch/arm/mach-s3c24xx/include/mach/map.h           |   2 +
 arch/arm/mach-s3c64xx/common.c                     |  14 +-
 arch/arm/mach-s3c64xx/include/mach/irqs.h          |   8 -
 arch/arm/mach-s3c64xx/include/mach/map.h           |   1 +
 arch/arm/mach-s5p64x0/common.c                     |  10 +
 arch/arm/mach-s5p64x0/include/mach/irqs.h          |   2 -
 arch/arm/mach-s5p64x0/include/mach/map.h           |   1 +
 arch/arm/mach-s5pc100/common.c                     |  10 +
 arch/arm/mach-s5pc100/include/mach/irqs.h          |   2 -
 arch/arm/mach-s5pc100/include/mach/map.h           |   1 +
 arch/arm/mach-s5pv210/common.c                     |  10 +
 arch/arm/mach-s5pv210/include/mach/irqs.h          |   2 -
 arch/arm/mach-s5pv210/include/mach/map.h           |   1 +
 arch/arm/plat-samsung/Kconfig                      |  14 -
 arch/arm/plat-samsung/Makefile                     |   2 -
 arch/arm/plat-samsung/devs.c                       |  33 +-
 arch/arm/plat-samsung/include/plat/devs.h          |   1 +
 arch/arm/plat-samsung/include/plat/irq-vic-timer.h |  13 -
 arch/arm/plat-samsung/include/plat/irqs.h          |   9 -
 arch/arm/plat-samsung/include/plat/samsung-time.h  |  38 +-
 arch/arm/plat-samsung/irq-vic-timer.c              |  98 -----
 arch/arm/plat-samsung/s5p-irq.c                    |   3 -
 arch/arm/plat-samsung/samsung-time.c               | 394 ------------------
 drivers/clocksource/Kconfig                        |   8 +
 drivers/clocksource/Makefile                       |   1 +
 drivers/clocksource/samsung-time.c                 | 298 ++++++++++++++
 drivers/mfd/Kconfig                                |   3 +
 drivers/mfd/Makefile                               |   1 +
 drivers/mfd/samsung-pwm.c                          | 439 +++++++++++++++++++++
 drivers/pwm/Kconfig                                |   1 +
 include/linux/mfd/samsung-pwm.h                    |  49 +++
 include/linux/platform_data/samsung-pwm.h          |  29 ++
 39 files changed, 983 insertions(+), 583 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pwm/pwm-samsung.txt
 delete mode 100644 arch/arm/plat-samsung/include/plat/irq-vic-timer.h
 delete mode 100644 arch/arm/plat-samsung/irq-vic-timer.c
 delete mode 100644 arch/arm/plat-samsung/samsung-time.c
 create mode 100644 drivers/clocksource/samsung-time.c
 create mode 100644 drivers/mfd/samsung-pwm.c
 create mode 100644 include/linux/mfd/samsung-pwm.h
 create mode 100644 include/linux/platform_data/samsung-pwm.h
Signature · 1 line
1.8.1.5
#1 lore raw

PATCH v4 1/14 ARM: SAMSUNG: Move samsung-time to drivers/clocksource

This patch moves the Samsung PWM-based high resolution timer support code from arch/arm/plat-samsung to drivers/clocksource.

This is a prerequisite for further work on making the driver more multiplatform and Device Tree friendly.

---
 arch/arm/plat-samsung/Kconfig        |   8 -
 arch/arm/plat-samsung/Makefile       |   1 -
 arch/arm/plat-samsung/samsung-time.c | 394 -----------------------------------
 drivers/clocksource/Kconfig          |   7 +
 drivers/clocksource/Makefile         |   1 +
 drivers/clocksource/samsung-time.c   | 394 +++++++++++++++++++++++++++++++++++
 6 files changed, 402 insertions(+), 403 deletions(-)
 delete mode 100644 arch/arm/plat-samsung/samsung-time.c
 create mode 100644 drivers/clocksource/samsung-time.c
arch/arm/plat-samsung/Kconfig +0 -8
index 54d1861..6f632ba 100644
@@ -60,14 +60,6 @@ config S3C_LOWLEVEL_UART_PORT
 	  this configuration should be between zero and two. The port
 	  must have been initialised by the boot-loader before use.
 
-# timer options
-
-config SAMSUNG_HRT
-	bool
-	select SAMSUNG_DEV_PWM
-	help
-	  Use the High Resolution timer support
-
 # clock options
 
 config SAMSUNG_CLOCK
arch/arm/plat-samsung/Makefile +0 -1
index a23c460..87494e1 100644
@@ -12,7 +12,6 @@ obj-				:=
 # Objects we always build independent of SoC choice
 
 obj-y				+= init.o cpu.o
-obj-$(CONFIG_SAMSUNG_HRT) 	+= samsung-time.o
 
 obj-$(CONFIG_SAMSUNG_CLOCK)	+= clock.o
 obj-$(CONFIG_SAMSUNG_CLOCK)	+= pwm-clock.o
arch/arm/plat-samsung/samsung-time.c deleted +0 -394

394 lines not on this page · raw message

drivers/clocksource/Kconfig +7 -0
index e8c4532..dd20f6a 100644
@@ -25,6 +25,13 @@ config DW_APB_TIMER_OF
 config ARMADA_370_XP_TIMER
 	bool
 
+config SAMSUNG_HRT
+	bool
+	depends on PLAT_SAMSUNG
+	select SAMSUNG_DEV_PWM
+	help
+	  Use the high resolution timer support on Samsung platforms.
+
 config SUNXI_TIMER
 	bool
 
drivers/clocksource/Makefile +1 -0
index 1c1b15d..0d68580 100644
@@ -16,6 +16,7 @@ obj-$(CONFIG_CLKSRC_NOMADIK_MTU)	+= nomadik-mtu.o
 obj-$(CONFIG_CLKSRC_DBX500_PRCMU)	+= clksrc-dbx500-prcmu.o
 obj-$(CONFIG_ARMADA_370_XP_TIMER)	+= time-armada-370-xp.o
 obj-$(CONFIG_ARCH_BCM2835)	+= bcm2835_timer.o
+obj-$(CONFIG_SAMSUNG_HRT) 	+= samsung-time.o
 obj-$(CONFIG_SUNXI_TIMER)	+= sunxi_timer.o
 obj-$(CONFIG_ARCH_TEGRA)	+= tegra20_timer.o
 obj-$(CONFIG_VT8500_TIMER)	+= vt8500_timer.o
drivers/clocksource/samsung-time.c new file +394 -0

394 lines not on this page · raw message

Signature · 1 line
1.8.1.5
#2 lore raw

PATCH v4 2/14 clocksource: samsung-time: Drop useless defines from public header

In reply to Tomasz Figa

This patch cleans up public header from useless definitions.

---
 arch/arm/plat-samsung/include/plat/samsung-time.h |  6 ------
 drivers/clocksource/samsung-time.c                | 10 +++++-----
 2 files changed, 5 insertions(+), 11 deletions(-)
arch/arm/plat-samsung/include/plat/samsung-time.h +0 -6
index 4cc99bb..5d098ef 100644
@@ -27,9 +27,6 @@ struct samsung_timer_source {
 	unsigned int source_id;
 };
 
-/* Be able to sleep for atleast 4 seconds (usually more) */
-#define SAMSUNG_TIMER_MIN_RANGE	4
-
 #if defined(CONFIG_ARCH_S3C24XX) || defined(CONFIG_ARCH_S5PC100)
 #define TCNT_MAX		0xffff
 #define TSCALER_DIV		25
@@ -42,9 +39,6 @@ struct samsung_timer_source {
 #define TSIZE			32
 #endif
 
-#define NON_PERIODIC		0
-#define PERIODIC		1
-
 extern void __init samsung_set_timer_source(enum samsung_timer_mode event,
 					enum samsung_timer_mode source);
 
drivers/clocksource/samsung-time.c +5 -5
index f899cbc..d4d7e3e 100644
@@ -182,7 +182,7 @@ static int samsung_set_next_event(unsigned long cycles,
 				struct clock_event_device *evt)
 {
 	samsung_time_setup(timer_source.event_id, cycles);
-	samsung_time_start(timer_source.event_id, NON_PERIODIC);
+	samsung_time_start(timer_source.event_id, false);
 
 	return 0;
 }
@@ -195,7 +195,7 @@ static void samsung_set_mode(enum clock_event_mode mode,
 	switch (mode) {
 	case CLOCK_EVT_MODE_PERIODIC:
 		samsung_time_setup(timer_source.event_id, clock_count_per_tick);
-		samsung_time_start(timer_source.event_id, PERIODIC);
+		samsung_time_start(timer_source.event_id, true);
 		break;
 
 	case CLOCK_EVT_MODE_ONESHOT:
@@ -215,11 +215,11 @@ static void samsung_timer_resume(void)
 {
 	/* event timer restart */
 	samsung_time_setup(timer_source.event_id, clock_count_per_tick);
-	samsung_time_start(timer_source.event_id, PERIODIC);
+	samsung_time_start(timer_source.event_id, true);
 
 	/* source timer restart */
 	samsung_time_setup(timer_source.source_id, TCNT_MAX);
-	samsung_time_start(timer_source.source_id, PERIODIC);
+	samsung_time_start(timer_source.source_id, true);
 }
 
 void __init samsung_set_timer_source(enum samsung_timer_mode event,
@@ -335,7 +335,7 @@ static void __init samsung_clocksource_init(void)
 	clock_rate = clk_get_rate(tin_source);
 
 	samsung_time_setup(timer_source.source_id, TCNT_MAX);
-	samsung_time_start(timer_source.source_id, PERIODIC);
+	samsung_time_start(timer_source.source_id, true);
 
 	setup_sched_clock(samsung_read_sched_clock, TSIZE, clock_rate);
 
Signature · 1 line
1.8.1.5
#3 lore raw

PATCH v4 3/14 clocksource: samsung-time: Use local register definitions

In reply to Tomasz Figa

This patch copies PWM timer register definitions to samsung-time.c. The original header in plat is being kept for now, since it is also used by other code that also needs to be reworked to be multiplatform-friendly.

---
 drivers/clocksource/samsung-time.c | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)
drivers/clocksource/samsung-time.c +35 -1
index d4d7e3e..bccc291 100644
@@ -24,9 +24,43 @@
 
 #include <mach/map.h>
 #include <plat/devs.h>
-#include <plat/regs-timer.h>
 #include <plat/samsung-time.h>
 
+#define S3C_TIMERREG(x) (S3C_VA_TIMER + (x))
+#define S3C_TIMERREG2(tmr,reg) S3C_TIMERREG((reg)+0x0c+((tmr)*0x0c))
+
+#define S3C2410_TCON	      S3C_TIMERREG(0x08)
+#define S3C64XX_TINT_CSTAT    S3C_TIMERREG(0x44)
+
+/* for each timer, we have an count buffer, an compare buffer and
+ * an observation buffer
+*/
+
+/* WARNING - timer 4 has no buffer reg, and it's observation is at +4 */
+
+#define S3C2410_TCNTB(tmr)    S3C_TIMERREG2(tmr, 0x00)
+#define S3C2410_TCMPB(tmr)    S3C_TIMERREG2(tmr, 0x04)
+
+#define S3C2410_TCON_T4RELOAD	  (1<<22)
+#define S3C2410_TCON_T4MANUALUPD  (1<<21)
+#define S3C2410_TCON_T4START	  (1<<20)
+
+#define S3C2410_TCON_T3RELOAD	  (1<<19)
+#define S3C2410_TCON_T3MANUALUPD  (1<<17)
+#define S3C2410_TCON_T3START	  (1<<16)
+
+#define S3C2410_TCON_T2RELOAD	  (1<<15)
+#define S3C2410_TCON_T2MANUALUPD  (1<<13)
+#define S3C2410_TCON_T2START	  (1<<12)
+
+#define S3C2410_TCON_T1RELOAD	  (1<<11)
+#define S3C2410_TCON_T1MANUALUPD  (1<<9)
+#define S3C2410_TCON_T1START	  (1<<8)
+
+#define S3C2410_TCON_T0RELOAD	  (1<<3)
+#define S3C2410_TCON_T0MANUALUPD  (1<<1)
+#define S3C2410_TCON_T0START	  (1<<0)
+
 static struct clk *tin_event;
 static struct clk *tin_source;
 static struct clk *tdiv_event;
Signature · 1 line
1.8.1.5
#4 lore raw

PATCH v4 4/14 mfd: Add Samsung PWM/timer master driver

In reply to Tomasz Figa

This patch adds master driver for PWM/timer block available on many Samsung SoCs providing clocksource and PWM output capabilities.

---
 .../devicetree/bindings/pwm/pwm-samsung.txt        |  37 ++
 drivers/clocksource/Kconfig                        |   1 +
 drivers/mfd/Kconfig                                |   3 +
 drivers/mfd/Makefile                               |   1 +
 drivers/mfd/samsung-pwm.c                          | 439 +++++++++++++++++++++
 drivers/pwm/Kconfig                                |   1 +
 include/linux/mfd/samsung-pwm.h                    |  49 +++
 include/linux/platform_data/samsung-pwm.h          |  28 ++
 8 files changed, 559 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pwm/pwm-samsung.txt
 create mode 100644 drivers/mfd/samsung-pwm.c
 create mode 100644 include/linux/mfd/samsung-pwm.h
 create mode 100644 include/linux/platform_data/samsung-pwm.h
Documentation/devicetree/bindings/pwm/pwm-samsung.txt new file +37 -0
new file mode 100644
index 0000000..8ed4c11
@@ -0,0 +1,37 @@
+* Samsung PWM timers
+
+Samsung SoCs contain PWM timer blocks which can be used for system clock source
+and clock event timers, as well as to drive SoC outputs with PWM signal. Each
+PWM timer block provides 5 PWM channels (not all of them can drive physical
+outputs - see SoC and board manual).
+
+Be aware that this driver supports clock event only on CPU 0. It can
+provide SMP support together with ARM dummy_timer, but only in periodic tick
+mode.
+
+Required properties:
+- compatible : should be one of following:
+    samsung,s3c2410-pwm - for 16-bit timers present on S3C24xx SoCs
+    samsung,s3c6400-pwm - for 32-bit timers present on S3C64xx SoCs
+    samsung,s5p6440-pwm - for 32-bit timers present on S5P64x0 SoCs
+    samsung,s5pc100-pwm - for 32-bit timers present on S5PC100, S5PV210,
+			  Exynos4210, Exynos4x12 and Exynos5250 SoCs
+- reg: base address and size of register area
+- interrupts: list of timer interrupts (one interrupt per timer, starting at
+  timer 0)
+- #pwm-cells: number of cells used for PWM specifier - must be 2
+
+Optional properties:
+- samsung,pwm-outputs: list of PWM channels used as PWM outputs on particular
+    platform - an array of up to 5 elements being indices of PWM channels
+    (from 0 to 4), the order does not matter.
+
+Example:
+	pwm at 7f006000 {
+		compatible = "samsung,s3c6400-pwm";
+		reg = <0x7f006000 0x1000>;
+		interrupt-parent = <&vic0>;
+		interrupts = <23>, <24>, <25>, <27>, <28>;
+		samsung,pwm-outputs = <0>, <1>;
+		#pwm-cells = <2>;
+	}
drivers/clocksource/Kconfig +1 -0
index dd20f6a..a69a5b7 100644
@@ -29,6 +29,7 @@ config SAMSUNG_HRT
 	bool
 	depends on PLAT_SAMSUNG
 	select SAMSUNG_DEV_PWM
+	select MFD_SAMSUNG_PWM
 	help
 	  Use the high resolution timer support on Samsung platforms.
 
drivers/mfd/Kconfig +3 -0
index 3ab3a11..c25425c 100644
@@ -1015,6 +1015,9 @@ config MFD_PM8XXX_IRQ
 	  This is required to use certain other PM 8xxx features, such as GPIO
 	  and MPP.
 
+config MFD_SAMSUNG_PWM
+	bool
+
 config TPS65911_COMPARATOR
 	tristate
 
drivers/mfd/Makefile +1 -0
index b90409c..513d9c9 100644
@@ -145,6 +145,7 @@ obj-$(CONFIG_MFD_RC5T583)	+= rc5t583.o rc5t583-irq.o
 obj-$(CONFIG_MFD_SEC_CORE)	+= sec-core.o sec-irq.o
 obj-$(CONFIG_MFD_SYSCON)	+= syscon.o
 obj-$(CONFIG_MFD_LM3533)	+= lm3533-core.o lm3533-ctrlbank.o
+obj-$(CONFIG_MFD_SAMSUNG_PWM)	+= samsung-pwm.o
 obj-$(CONFIG_VEXPRESS_CONFIG)	+= vexpress-config.o vexpress-sysreg.o
 obj-$(CONFIG_MFD_RETU)		+= retu-mfd.o
 obj-$(CONFIG_MFD_AS3711)	+= as3711.o
drivers/mfd/samsung-pwm.c new file +439 -0

439 lines not on this page · raw message

drivers/pwm/Kconfig +1 -0
index 0e0bfa0..c80070b 100644
@@ -118,6 +118,7 @@ config PWM_PXA
 config PWM_SAMSUNG
 	tristate "Samsung PWM support"
 	depends on PLAT_SAMSUNG
+	select MFD_SAMSUNG_PWM
 	help
 	  Generic PWM framework driver for Samsung.
 
include/linux/mfd/samsung-pwm.h new file +49 -0

49 lines not on this page · raw message

include/linux/platform_data/samsung-pwm.h new file +28 -0
new file mode 100644
index 0000000..8c48dbb
@@ -0,0 +1,28 @@
+/*
+ * Samsung PWM/timers driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ *
+ * Author: Tomasz Figa <[email protected]>
+ *
+ * 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.
+ */
+
+#ifndef PLATFORM_DATA_SAMSUNG_PWM_H_
+#define PLATFORM_DATA_SAMSUNG_PWM_H_
+
+struct platform_device;
+
+struct samsung_pwm_variant {
+	u8 bits;
+	u8 div_base;
+	u8 tclk_mask;
+	u8 output_mask;
+	bool has_tint_cstat;
+};
+
+extern int samsung_pwm_register(struct platform_device *pdev);
+
+#endif
Signature · 1 line
1.8.1.5
#5 lore raw

PATCH v4 4/14 mfd: Add Samsung PWM/timer master driver

Hi Tomasz,

Quoted 5 lines · Tomasz Figa

This patch adds master driver for PWM/timer block available on many Samsung SoCs providing clocksource and PWM output capabilities.

Quoted 14 lines
---
 .../devicetree/bindings/pwm/pwm-samsung.txt        |  37 ++
 drivers/clocksource/Kconfig                        |   1 +
 drivers/mfd/Kconfig                                |   3 +
 drivers/mfd/Makefile                               |   1 +
 drivers/mfd/samsung-pwm.c                          | 439 +++++++++++++++++++++
 drivers/pwm/Kconfig                                |   1 +
 include/linux/mfd/samsung-pwm.h                    |  49 +++
 include/linux/platform_data/samsung-pwm.h          |  28 ++
 8 files changed, 559 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pwm/pwm-samsung.txt
 create mode 100644 drivers/mfd/samsung-pwm.c
 create mode 100644 include/linux/mfd/samsung-pwm.h
 create mode 100644 include/linux/platform_data/samsung-pwm.h

Why is that an MFD driver, and why aren't you using the PWM APIs for it ? Also, you probably want to look at using the regmap APIs for your IO.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#6 lore raw

PATCH v4 4/14 mfd: Add Samsung PWM/timer master driver

Hi Samuel,

Quoted 25 lines · On Friday 05 of April 2013 18:39:58 Samuel Ortiz wrote:

Hi Tomasz,

Quoted 7 lines · Tomasz Figa

This patch adds master driver for PWM/timer block available on many Samsung SoCs providing clocksource and PWM output capabilities.

---

Quoted 14 lines
 .../devicetree/bindings/pwm/pwm-samsung.txt        |  37 ++
 drivers/clocksource/Kconfig                        |   1 +
 drivers/mfd/Kconfig                                |   3 +
 drivers/mfd/Makefile                               |   1 +
 drivers/mfd/samsung-pwm.c                          | 439
 +++++++++++++++++++++ drivers/pwm/Kconfig                               
 |   1 +
 include/linux/mfd/samsung-pwm.h                    |  49 +++
 include/linux/platform_data/samsung-pwm.h          |  28 ++
 8 files changed, 559 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pwm/pwm-samsung.txt
 create mode 100644 drivers/mfd/samsung-pwm.c
 create mode 100644 include/linux/mfd/samsung-pwm.h
 create mode 100644 include/linux/platform_data/samsung-pwm.h
Quoted 2 lines

Why is that an MFD driver, and why aren't you using the PWM APIs for it ? Also, you probably want to look at using the regmap APIs for your IO.

The case of Samsung PWM timers is rather complicated. It is a hardware block that can be used at the same time to generate PWM signal and as a system clocksource.

There was a discussion on how to solve the problem of sharing the hardware:
http://thread.gmane.org/gmane.linux.kernel.samsung-soc/16480/focus=16500
(see the linked post and replies to it).

Best regards,

Signature · 3 lines
Tomasz Figa
Samsung Poland R&D Center
SW Solution Development, Kernel and System Framework
#7 lore raw

PATCH v4 4/14 mfd: Add Samsung PWM/timer master driver

Quoted 10 lines · Tomasz Figa
Quoted 8 lines · On Friday 05 of April 2013 18:39:58 Samuel Ortiz wrote:

Hi Tomasz,

Quoted 2 lines · Tomasz Figa

This patch adds master driver for PWM/timer block available on many Samsung SoCs providing clocksource and PWM output capabilities.

Why is that an MFD driver, and why aren't you using the PWM APIs for it ? Also, you probably want to look at using the regmap APIs for your IO.

Quoted 8 lines

The case of Samsung PWM timers is rather complicated. It is a hardware block that can be used at the same time to generate PWM signal and as a system clocksource.

There was a discussion on how to solve the problem of sharing the hardware:
http://thread.gmane.org/gmane.linux.kernel.samsung-soc/16480/focus=16500
(see the linked post and replies to it).

I don't think anyone ever suggested using a private API though. I think it's ok if the driver lives in drivers/mfd when it doesn't fit anywhere else easily, but you should really register it to the pwm subsystem to expose that functionality, not export functions that can be used by a pwm shim driver, which even seems to be missing from the series.

Arnd

#8 lore raw

PATCH v4 4/14 mfd: Add Samsung PWM/timer master driver

Quoted 16 lines · On Friday 05 of April 2013 19:05:24 Arnd Bergmann wrote:
Quoted 15 lines · Tomasz Figa
Quoted 9 lines · On Friday 05 of April 2013 18:39:58 Samuel Ortiz wrote:

Hi Tomasz,

Quoted 2 lines · Tomasz Figa

This patch adds master driver for PWM/timer block available on many Samsung SoCs providing clocksource and PWM output capabilities.

Why is that an MFD driver, and why aren't you using the PWM APIs for it ?
Also, you probably want to look at using the regmap APIs for your IO.

The case of Samsung PWM timers is rather complicated. It is a hardware block that can be used at the same time to generate PWM signal and as a system clocksource.

Quoted 6 lines
Quoted 4 lines

There was a discussion on how to solve the problem of sharing the hardware:
http://thread.gmane.org/gmane.linux.kernel.samsung-soc/16480/focus=16500
(see the linked post and replies to it).

I don't think anyone ever suggested using a private API though.

I must have gotten the last paragraph of
http://article.gmane.org/gmane.linux.kernel.samsung-soc/16638
wrong then. For me it seemed like the timer driver would expose a private API to the PWM driver.

Quoted 5 lines

I think
it's ok if the driver lives in drivers/mfd when it doesn't fit anywhere else easily, but you should really register it to the pwm subsystem to expose that functionality, not export functions that can be used by a pwm shim driver, which even seems to be missing from the series.

Anyway, using PWM API in a clocksource driver that needs to be running very early (before any initcalls get called) seems a bit weird for me, especially when PWM API doesn't provide such fine grained control over PWM timers that is required in the clocksource drivers.

Best regards,

Signature · 3 lines
Tomasz Figa
Samsung Poland R&D Center
SW Solution Development, Kernel and System Framework
#9 lore raw

PATCH v4 4/14 mfd: Add Samsung PWM/timer master driver

Quoted 6 lines · Tomasz Figa
Quoted 1 line

I don't think anyone ever suggested using a private API though.

I must have gotten the last paragraph of
http://article.gmane.org/gmane.linux.kernel.samsung-soc/16638
wrong then. For me it seemed like the timer driver would expose a private API to the PWM driver.

Yes, sorry I wasn't clear enough. I meant a register-level interface exposed from the base driver, not a high-level interface like you did.

Quoted 10 lines
Quoted 5 lines

I think
it's ok if the driver lives in drivers/mfd when it doesn't fit anywhere else easily, but you should really register it to the pwm subsystem to expose that functionality, not export functions that can be used by a pwm shim driver, which even seems to be missing from the series.

Anyway, using PWM API in a clocksource driver that needs to be running very early (before any initcalls get called) seems a bit weird for me, especially when PWM API doesn't provide such fine grained control over PWM timers that is required in the clocksource drivers.

Exactly, that's why you should have a regular PWM driver that gets loaded at a convenient time and just uses an interface exported by the base driver to access the common registers.

Arnd

#10 lore raw

PATCH v4 4/14 mfd: Add Samsung PWM/timer master driver

Quoted 11 lines · On Friday 05 of April 2013 21:54:21 Arnd Bergmann wrote:
Quoted 6 lines · Tomasz Figa
Quoted 1 line

I don't think anyone ever suggested using a private API though.

I must have gotten the last paragraph of
http://article.gmane.org/gmane.linux.kernel.samsung-soc/16638
wrong then. For me it seemed like the timer driver would expose a private API to the PWM driver.

Yes, sorry I wasn't clear enough. I meant a register-level interface exposed from the base driver, not a high-level interface like you did.

I'm not sure what you mean by a register-level interface. Something like samsung_pwm_update_reg(reg, mask, val), which modifies bitfields according to the mask and value with appropriate synchronization? If yes, this solves only the problem of access to shared registers.

The other problems that remain:

- negotiation of PWM channels to use for clock source and clock events, because each board can use different channels for PWM outputs,

- code duplication caused by both of the drivers doing mostly the same things and or having to parse the same data from device tree,

- both non-DT and DT platforms must be supported,

- how to keep the ability to load PWM driver as a module (or not load it at all when PWM is not used on particular board), while retaining everything that is needed for the clocksource driver in kernel,

- some platforms can't use PWM timers as system clocksources, while on others this is the only timekeeping hardware available.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

I think
it's ok if the driver lives in drivers/mfd when it doesn't fit anywhere
else easily, but you should really register it to the pwm subsystem to
expose that functionality, not export functions that can be used by a pwm shim driver, which even seems to be missing from the series.

Quoted 8 lines
Quoted 4 lines

Anyway, using PWM API in a clocksource driver that needs to be running very early (before any initcalls get called) seems a bit weird for me, especially when PWM API doesn't provide such fine grained control over PWM timers that is required in the clocksource drivers.

Exactly, that's why you should have a regular PWM driver that gets loaded at a convenient time and just uses an interface exported by the base driver to access the common registers.

Well, this is basically what my patches do, except that the PWM driver isn't reworked to use the base driver yet.

The private API exported to the samsung-time and pwm-samsung drivers isn't maybe the most fortunate one, but it clearly has the advantage of solving all the problems I mentioned before.

Same goes for calling this an MFD driver. It doesn't even use the MFD core, but there seems to be no better place to put it. Maybe drivers/platform/arm would be better, if it existed, just as currently available drivers/platform/x86?

Best regards,
Tomasz

#11 lore raw

PATCH v4 4/14 mfd: Add Samsung PWM/timer master driver

Quoted 26 lines · On Saturday 06 of April 2013 00:24:18 Tomasz Figa wrote:
Quoted 11 lines · On Friday 05 of April 2013 21:54:21 Arnd Bergmann wrote:
Quoted 6 lines · Tomasz Figa
Quoted 1 line

I don't think anyone ever suggested using a private API though.

I must have gotten the last paragraph of
http://article.gmane.org/gmane.linux.kernel.samsung-soc/16638
wrong then. For me it seemed like the timer driver would expose a private API to the PWM driver.

Yes, sorry I wasn't clear enough. I meant a register-level interface exposed from the base driver, not a high-level interface like you did.

I'm not sure what you mean by a register-level interface. Something like samsung_pwm_update_reg(reg, mask, val), which modifies bitfields according to the mask and value with appropriate synchronization? If yes, this solves only the problem of access to shared registers.

The other problems that remain:

- negotiation of PWM channels to use for clock source and clock events, because each board can use different channels for PWM outputs,

- code duplication caused by both of the drivers doing mostly the same things and or having to parse the same data from device tree,

Quoted 9 lines

- both non-DT and DT platforms must be supported,

- how to keep the ability to load PWM driver as a module (or not load it at all when PWM is not used on particular board), while retaining everything that is needed for the clocksource driver in kernel,

- some platforms can't use PWM timers as system clocksources, while on others this is the only timekeeping hardware available.

Hmm. Does anybody have an idea of a better way of implementing this PWM timer support, which solves the above problems?

This series is a dependency for moving Universal C210 board to DT-based description and it's already almost out of time to get this included for 3.10...

Best regards,
Tomasz

Quoted 35 lines
Quoted 17 lines
Quoted 10 lines
Quoted 9 lines

I think
it's ok if the driver lives in drivers/mfd when it doesn't fit anywhere
else easily, but you should really register it to the pwm subsystem
to
expose that functionality, not export functions that can be used by
a pwm shim driver, which even seems to be missing from the series.

Quoted 6 lines

Anyway, using PWM API in a clocksource driver that needs to be running
very early (before any initcalls get called) seems a bit weird for me, especially when PWM API doesn't provide such fine grained control
over PWM timers that is required in the clocksource drivers.

Quoted 3 lines

Exactly, that's why you should have a regular PWM driver that gets loaded at a convenient time and just uses an interface exported by the base driver to access the common registers.

Well, this is basically what my patches do, except that the PWM driver isn't reworked to use the base driver yet.

The private API exported to the samsung-time and pwm-samsung drivers isn't maybe the most fortunate one, but it clearly has the advantage of solving all the problems I mentioned before.

Same goes for calling this an MFD driver. It doesn't even use the MFD core, but there seems to be no better place to put it. Maybe drivers/platform/arm would be better, if it existed, just as currently available drivers/platform/x86?

Best regards,
Tomasz

#12 lore raw

PATCH v4 4/14 mfd: Add Samsung PWM/timer master driver

Quoted 27 lines · Tomasz Figa
Quoted 16 lines · On Saturday 06 of April 2013 00:24:18 Tomasz Figa wrote:
Quoted 1 line · On Friday 05 of April 2013 21:54:21 Arnd Bergmann wrote:

On Friday 05 April 2013, Tomasz Figa wrote:

I'm not sure what you mean by a register-level interface. Something like samsung_pwm_update_reg(reg, mask, val), which modifies bitfields according to the mask and value with appropriate synchronization? If yes, this solves only the problem of access to shared registers.

The other problems that remain:

- negotiation of PWM channels to use for clock source and clock events, because each board can use different channels for PWM outputs,

- code duplication caused by both of the drivers doing mostly the same things and or having to parse the same data from device tree,

Quoted 9 lines

- both non-DT and DT platforms must be supported,

- how to keep the ability to load PWM driver as a module (or not load it at all when PWM is not used on particular board), while retaining everything that is needed for the clocksource driver in kernel,

- some platforms can't use PWM timers as system clocksources, while on others this is the only timekeeping hardware available.

Quoted 7 lines

Hmm. Does anybody have an idea of a better way of implementing this PWM timer support, which solves the above problems?

This series is a dependency for moving Universal C210 board to DT-based description and it's already almost out of time to get this included for 3.10...

Sorry for not replying earlier. My idea for the register level interface was to create a platform_device for each PWM, e.g. using the mfd_cell infrastructure. You can then pass a "struct regmap" as the platform data for each child of the timer node, and all the DT handling code can stay in the parent driver.

Arnd

#13 lore raw

PATCH v4 4/14 mfd: Add Samsung PWM/timer master driver

Quoted 5 lines · Arnd Bergmann

Sorry for not replying earlier. My idea for the register level interface was to create a platform_device for each PWM, e.g. using the mfd_cell infrastructure. You can then pass a "struct regmap" as the platform data for each child of the timer node, and all the DT handling code can stay in the parent driver.

Dunno if it helps or not but there's also dev_get_regmap() if you're
passing the struct device around or can fish one out of thhe parent.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130411/f538ba40/attachment.sig>

#14 lore raw

PATCH v4 4/14 mfd: Add Samsung PWM/timer master driver

In reply to Arnd Bergmann
Quoted 36 lines · On Thursday 11 of April 2013 00:35:47 Arnd Bergmann wrote:
Quoted 26 lines · Tomasz Figa
Quoted 25 lines · On Saturday 06 of April 2013 00:24:18 Tomasz Figa wrote:
Quoted 1 line · On Friday 05 of April 2013 21:54:21 Arnd Bergmann wrote:

On Friday 05 April 2013, Tomasz Figa wrote:

I'm not sure what you mean by a register-level interface. Something like samsung_pwm_update_reg(reg, mask, val), which modifies bitfields according to the mask and value with appropriate synchronization? If yes, this solves only the problem of access to shared registers.

The other problems that remain:

- negotiation of PWM channels to use for clock source and clock events,

because each board can use different channels for PWM outputs,

- code duplication caused by both of the drivers doing mostly the same

things and or having to parse the same data from device tree,

- both non-DT and DT platforms must be supported,

- how to keep the ability to load PWM driver as a module (or not load it at all when PWM is not used on particular board), while retaining everything that is needed for the clocksource driver in kernel,

- some platforms can't use PWM timers as system clocksources, while on

Quoted 8 lines
Quoted 1 line

others this is the only timekeeping hardware available.

Hmm. Does anybody have an idea of a better way of implementing this PWM timer support, which solves the above problems?

This series is a dependency for moving Universal C210 board to DT-based description and it's already almost out of time to get this included for 3.10...

Quoted 5 lines

Sorry for not replying earlier. My idea for the register level interface was to create a platform_device for each PWM, e.g. using the mfd_cell infrastructure. You can then pass a "struct regmap" as the platform data for each child of the timer node, and all the DT handling code can stay in the parent driver.

Hmm. As I said, I'm completely fine with using a regmap for sharing registers between subdrivers. However the clocksource can not be registered as an MFD cell, because it's needed very early.

I can imagine a solution alternative to my original one, where the MFD cells would be registered from the clocksource driver. This would mean that platforms that don't need (and can't use) the PWM clocksource would have to enable the driver anyway.

Another thing is that I don't see a need to create one cell per PWM channel. The PWM core is designed in a way that supports multiple channels per PWM controller and so is the generic PWM DT specifier (<&controller channel period flags>), so I'd rather see a single cell for all PWM channels.

So, to summarize this alternative concept:
- two drivers:
1) clocksource driver - registering clocksource and PWM MFD cell
2) PWM driver - handling the PWM MFD cell
- both drivers would share registers using a regmap with custom lock/unlock callbacks (using spin_lock_irqsave/spin_unlock_irqrestore, because the clocksource needs to access PWM registers in IRQ context)
- the clocksource/master driver would have a samsung_time_init function which would set up the driver early and initialize the clocksource
- a platform driver would be registered by the clocksource/master driver which would register the PWM MFD cell in its probe
- MFD cell platform data would contain struct regmap * and variant data (parsed from DT or received from platform code - as in my original version)

This should indeed work, assuming that I find a solution to make clocksource_of_init not initialize the PWM clocksource (from PWM DT node) on platforms that can't use it.

Best regards,

Signature · 3 lines
Tomasz Figa
Samsung Poland R&D Center
SW Solution Development, Kernel and System Framework
#15 lore raw

PATCH v4 4/14 mfd: Add Samsung PWM/timer master driver

Quoted 12 lines · Tomasz Figa
Quoted 10 lines · On Thursday 11 of April 2013 00:35:47 Arnd Bergmann wrote:
Quoted 3 lines · Tomasz Figa
Quoted 2 lines · On Saturday 06 of April 2013 00:24:18 Tomasz Figa wrote:
Quoted 1 line · On Friday 05 of April 2013 21:54:21 Arnd Bergmann wrote:

On Friday 05 April 2013, Tomasz Figa wrote:

Sorry for not replying earlier. My idea for the register level interface was to create a platform_device for each PWM, e.g. using the mfd_cell infrastructure. You can then pass a "struct regmap" as the platform data for each child of the timer node, and all the DT handling code can stay in the parent driver.

Quoted 8 lines

Hmm. As I said, I'm completely fine with using a regmap for sharing registers between subdrivers. However the clocksource can not be registered as an MFD cell, because it's needed very early.

I can imagine a solution alternative to my original one, where the MFD cells would be registered from the clocksource driver. This would mean that platforms that don't need (and can't use) the PWM clocksource would have to enable the driver anyway.

Sounds ok to me. The main part I want to avoid is having two separate device nodes in the DT for one physical device, but there are multiple ways to get there.

Quoted 4 lines

Another thing is that I don't see a need to create one cell per PWM channel. The PWM core is designed in a way that supports multiple channels per PWM controller and so is the generic PWM DT specifier (<&controller channel period flags>), so I'd rather see a single cell for all PWM channels.

Sure, no problem with that.

Quoted 4 lines

So, to summarize this alternative concept:
- two drivers:
1) clocksource driver - registering clocksource and PWM MFD cell
2) PWM driver - handling the PWM MFD cell

Ok. Don't be too tied to the MFD concept though if it causes problems. In many cases calling platform_device_register_resndata or similar is actually easier than MFD, especially if you only want a single child device. Either way is fine though.

Quoted 3 lines

- both drivers would share registers using a regmap with custom lock/unlock callbacks (using spin_lock_irqsave/spin_unlock_irqrestore, because the clocksource needs to access PWM registers in IRQ context)

Ok.

Quoted 2 lines

- the clocksource/master driver would have a samsung_time_init function which would set up the driver early and initialize the clocksource

Right. If you want to use the clocksource_of_init() infratstructure for this (which is probably a good idea), please base your series on top of the clksrc/cleanup branch in arm-soc.

Quoted 2 lines

- a platform driver would be registered by the clocksource/master driver which would register the PWM MFD cell in its probe.

This seems unnecessary, if the only purpose of the platform driver is to export the MFD cell. In that case, I would actually suggest a simpler model where the PWM driver registers the main platform driver directly and calls a function exported by the clocksource driver to get the regmap structure and anything else it may need (possibly initializing the driver in the case where it is not used as the clocksource but only provides the registers for PWM).

Quoted 2 lines

- MFD cell platform data would contain struct regmap * and variant data (parsed from DT or received from platform code - as in my original version)

Yes, either the MFD cell, or the exported symbol, whichever ends up easier.

Quoted 3 lines

This should indeed work, assuming that I find a solution to make clocksource_of_init not initialize the PWM clocksource (from PWM DT node) on platforms that can't use it.

Right. If anything else comes up, I'd suggest we discuss it on IRC (#armlinux on irc.freenode.net) tomorrow for faster round-trip, or I can call you on the phone if you like. I'm available all day tomorrow, just send me your (landline) phone number by private email.

Arnd.

#16 lore raw

PATCH v4 5/14 ARM: SAMSUNG: Unify base address definitions of timer block

In reply to Tomasz Figa

This patch makes all defintions of timer block base address use the same prefix to allow using the common name to define platform device resource.

---
 arch/arm/mach-exynos/include/mach/map.h  | 1 +
 arch/arm/mach-s3c24xx/include/mach/map.h | 2 ++
 arch/arm/mach-s3c64xx/include/mach/map.h | 1 +
 arch/arm/mach-s5p64x0/include/mach/map.h | 1 +
 arch/arm/mach-s5pc100/include/mach/map.h | 1 +
 arch/arm/mach-s5pv210/include/mach/map.h | 1 +
 6 files changed, 7 insertions(+)
arch/arm/mach-exynos/include/mach/map.h +1 -0
index 99e0a79..7167aba 100644
@@ -272,6 +272,7 @@
 #define SAMSUNG_PA_ADC			EXYNOS4_PA_ADC
 #define SAMSUNG_PA_ADC1			EXYNOS4_PA_ADC1
 #define SAMSUNG_PA_KEYPAD		EXYNOS4_PA_KEYPAD
+#define SAMSUNG_PA_TIMER		EXYNOS4_PA_TIMER
 
 /* Compatibility UART */
 
arch/arm/mach-s3c24xx/include/mach/map.h +2 -0
index 8ba381f..444793f 100644
@@ -167,4 +167,6 @@
 #define S3C_PA_SPI0		S3C2443_PA_SPI0
 #define S3C_PA_SPI1		S3C2443_PA_SPI1
 
+#define SAMSUNG_PA_TIMER	S3C2410_PA_TIMER
+
 #endif /* __ASM_ARCH_MAP_H */
arch/arm/mach-s3c64xx/include/mach/map.h +1 -0
index 8e2097b..f55ccb1 100644
@@ -121,5 +121,6 @@
 #define SAMSUNG_PA_ADC		S3C64XX_PA_ADC
 #define SAMSUNG_PA_CFCON	S3C64XX_PA_CFCON
 #define SAMSUNG_PA_KEYPAD	S3C64XX_PA_KEYPAD
+#define SAMSUNG_PA_TIMER	S3C64XX_PA_TIMER
 
 #endif /* __ASM_ARCH_6400_MAP_H */
arch/arm/mach-s5p64x0/include/mach/map.h +1 -0
index 0c0175d..50a6e96 100644
@@ -76,6 +76,7 @@
 #define S5P_PA_TIMER		S5P64X0_PA_TIMER
 
 #define SAMSUNG_PA_ADC		S5P64X0_PA_ADC
+#define SAMSUNG_PA_TIMER	S5P64X0_PA_TIMER
 
 /* UART */
 
arch/arm/mach-s5pc100/include/mach/map.h +1 -0
index 54bc4f8..2550b61 100644
@@ -116,6 +116,7 @@
 #define SAMSUNG_PA_ADC			S5PC100_PA_TSADC
 #define SAMSUNG_PA_CFCON		S5PC100_PA_CFCON
 #define SAMSUNG_PA_KEYPAD		S5PC100_PA_KEYPAD
+#define SAMSUNG_PA_TIMER		S5PC100_PA_TIMER
 
 #define S5PC100_VA_OTHERS		(S3C_VA_SYS + 0x10000)
 
arch/arm/mach-s5pv210/include/mach/map.h +1 -0
index b7c8a19..763929a 100644
@@ -139,6 +139,7 @@
 #define SAMSUNG_PA_ADC			S5PV210_PA_ADC
 #define SAMSUNG_PA_CFCON		S5PV210_PA_CFCON
 #define SAMSUNG_PA_KEYPAD		S5PV210_PA_KEYPAD
+#define SAMSUNG_PA_TIMER		S5PV210_PA_TIMER
 
 /* UART */
 
Signature · 1 line
1.8.1.5
#17 lore raw

PATCH v4 6/14 ARM: SAMSUNG: Add new PWM platform device

In reply to Tomasz Figa

This patch adds new samsung_device_pwm platform device that represents the whole PWM/timer block and includes memory and IRQ resources.

---
 arch/arm/plat-samsung/devs.c              | 16 ++++++++++++++++
 arch/arm/plat-samsung/include/plat/devs.h |  1 +
 2 files changed, 17 insertions(+)
arch/arm/plat-samsung/devs.c +16 -0
index e1124d9..bfae4dd 100644
@@ -1168,6 +1168,22 @@ struct platform_device s3c_device_timer[] = {
 };
 #endif /* CONFIG_SAMSUNG_DEV_PWM */
 
+static struct resource samsung_pwm_resource[] = {
+	DEFINE_RES_IRQ(IRQ_TIMER0),
+	DEFINE_RES_IRQ(IRQ_TIMER1),
+	DEFINE_RES_IRQ(IRQ_TIMER2),
+	DEFINE_RES_IRQ(IRQ_TIMER3),
+	DEFINE_RES_IRQ(IRQ_TIMER4),
+	DEFINE_RES_MEM(SAMSUNG_PA_TIMER, SZ_4K),
+};
+
+struct platform_device samsung_device_pwm = {
+	.name		= "samsung-pwm",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(samsung_pwm_resource),
+	.resource	= samsung_pwm_resource,
+};
+
 /* RTC */
 
 #ifdef CONFIG_PLAT_S3C24XX
arch/arm/plat-samsung/include/plat/devs.h +1 -0
index 87d501f..0dc4ac4 100644
@@ -134,6 +134,7 @@ extern struct platform_device exynos4_device_spdif;
 
 extern struct platform_device samsung_asoc_idma;
 extern struct platform_device samsung_device_keypad;
+extern struct platform_device samsung_device_pwm;
 
 /* s3c2440 specific devices */
 
Signature · 1 line
1.8.1.5
#18 lore raw

PATCH v4 7/14 ARM: SAMSUNG: Set PWM platform data

In reply to Tomasz Figa

This patch adds PWM platform data needed for legacy (non-DT) platforms to handle SoC-specific bits of the PWM/timer block.

---
 arch/arm/mach-exynos/common.c  | 10 ++++++++++
 arch/arm/mach-s3c24xx/common.c | 10 ++++++++++
 arch/arm/mach-s3c64xx/common.c | 10 ++++++++++
 arch/arm/mach-s5p64x0/common.c | 10 ++++++++++
 arch/arm/mach-s5pc100/common.c | 10 ++++++++++
 arch/arm/mach-s5pv210/common.c | 10 ++++++++++
 6 files changed, 60 insertions(+)
arch/arm/mach-exynos/common.c +10 -0
index 9cd857e..2b1ef98 100644
@@ -16,6 +16,7 @@
 #include <linux/io.h>
 #include <linux/device.h>
 #include <linux/gpio.h>
+#include <linux/platform_data/samsung-pwm.h>
 #include <linux/sched.h>
 #include <linux/serial_core.h>
 #include <linux/of.h>
@@ -378,6 +379,13 @@ void __init exynos_init_io(struct map_desc *mach_desc, int size)
 	s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids));
 }
 
+static struct samsung_pwm_variant exynos4_pwm_variant = {
+	.bits		= 32,
+	.div_base	= 0,
+	.has_tint_cstat	= true,
+	.tclk_mask	= (1 << 5),
+};
+
 static void __init exynos4_map_io(void)
 {
 	iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc));
@@ -419,6 +427,8 @@ static void __init exynos4_map_io(void)
 	s5p_hdmi_setname("exynos4-hdmi");
 
 	s3c64xx_spi_setname("exynos4210-spi");
+
+	samsung_device_pwm.dev.platform_data = &exynos4_pwm_variant;
 }
 
 static void __init exynos5_map_io(void)
arch/arm/mach-s3c24xx/common.c +10 -0
index d97533d..c09c6ba 100644
@@ -27,6 +27,7 @@
 #include <linux/interrupt.h>
 #include <linux/ioport.h>
 #include <linux/serial_core.h>
+#include <linux/platform_data/samsung-pwm.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
 #include <linux/io.h>
@@ -216,6 +217,13 @@ static void s3c24xx_default_idle(void)
 		     S3C2410_CLKCON);
 }
 
+static struct samsung_pwm_variant s3c24xx_pwm_variant = {
+	.bits		= 16,
+	.div_base	= 1,
+	.has_tint_cstat	= false,
+	.tclk_mask	= (1 << 4),
+};
+
 void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)
 {
 	arm_pm_idle = s3c24xx_default_idle;
@@ -232,6 +240,8 @@ void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)
 	s3c24xx_init_cpu();
 
 	s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids));
+
+	samsung_device_pwm.dev.platform_data = &s3c24xx_pwm_variant;
 }
 
 /* Serial port registrations */
arch/arm/mach-s3c64xx/common.c +10 -0
index 0b9c0ba..526b45e 100644
@@ -26,6 +26,7 @@
 #include <linux/irq.h>
 #include <linux/gpio.h>
 #include <linux/irqchip/arm-vic.h>
+#include <linux/platform_data/samsung-pwm.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -148,6 +149,13 @@ static struct device s3c64xx_dev = {
 	.bus	= &s3c64xx_subsys,
 };
 
+static struct samsung_pwm_variant s3c64xx_pwm_variant = {
+	.bits		= 32,
+	.div_base	= 0,
+	.has_tint_cstat	= true,
+	.tclk_mask	= (1 << 7) | (1 << 6) | (1 << 5),
+};
+
 /* read cpu identification code */
 
 void __init s3c64xx_init_io(struct map_desc *mach_desc, int size)
@@ -160,6 +168,8 @@ void __init s3c64xx_init_io(struct map_desc *mach_desc, int size)
 	s3c64xx_init_cpu();
 
 	s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids));
+
+	samsung_device_pwm.dev.platform_data = &s3c64xx_pwm_variant;
 }
 
 static __init int s3c64xx_dev_init(void)
arch/arm/mach-s5p64x0/common.c +10 -0
index 8ae5800..5cd3048 100644
@@ -19,6 +19,7 @@
 #include <linux/io.h>
 #include <linux/device.h>
 #include <linux/serial_core.h>
+#include <linux/platform_data/samsung-pwm.h>
 #include <linux/platform_device.h>
 #include <linux/sched.h>
 #include <linux/dma-mapping.h>
@@ -156,6 +157,13 @@ static void s5p64x0_idle(void)
 	cpu_do_idle();
 }
 
+static struct samsung_pwm_variant s5p64x0_pwm_variant = {
+	.bits		= 32,
+	.div_base	= 0,
+	.has_tint_cstat	= true,
+	.tclk_mask	= 0,
+};
+
 /*
  * s5p64x0_map_io
  *
@@ -173,6 +181,8 @@ void __init s5p64x0_init_io(struct map_desc *mach_desc, int size)
 	s5p_init_cpu(S5P64X0_SYS_ID);
 
 	s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids));
+
+	samsung_device_pwm.dev.platform_data = &s5p64x0_pwm_variant;
 }
 
 void __init s5p6440_map_io(void)
arch/arm/mach-s5pc100/common.c +10 -0
index cc6e561..d21938e 100644
@@ -22,6 +22,7 @@
 #include <linux/io.h>
 #include <linux/device.h>
 #include <linux/serial_core.h>
+#include <linux/platform_data/samsung-pwm.h>
 #include <linux/platform_device.h>
 #include <linux/sched.h>
 
@@ -131,6 +132,13 @@ static struct map_desc s5pc100_iodesc[] __initdata = {
 	}
 };
 
+static struct samsung_pwm_variant s5pc100_pwm_variant = {
+	.bits		= 32,
+	.div_base	= 0,
+	.has_tint_cstat	= true,
+	.tclk_mask	= (1 << 5),
+};
+
 /*
  * s5pc100_map_io
  *
@@ -148,6 +156,8 @@ void __init s5pc100_init_io(struct map_desc *mach_desc, int size)
 	s5p_init_cpu(S5P_VA_CHIPID);
 
 	s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids));
+
+	samsung_device_pwm.dev.platform_data = &s5pc100_pwm_variant;
 }
 
 void __init s5pc100_map_io(void)
arch/arm/mach-s5pv210/common.c +10 -0
index 9dfe93e..a3fc208 100644
@@ -19,6 +19,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/device.h>
+#include <linux/platform_data/samsung-pwm.h>
 #include <linux/platform_device.h>
 #include <linux/sched.h>
 #include <linux/dma-mapping.h>
@@ -148,6 +149,13 @@ void s5pv210_restart(char mode, const char *cmd)
 	__raw_writel(0x1, S5P_SWRESET);
 }
 
+static struct samsung_pwm_variant s5pv210_pwm_variant = {
+	.bits		= 32,
+	.div_base	= 0,
+	.has_tint_cstat	= true,
+	.tclk_mask	= (1 << 5),
+};
+
 /*
  * s5pv210_map_io
  *
@@ -165,6 +173,8 @@ void __init s5pv210_init_io(struct map_desc *mach_desc, int size)
 	s5p_init_cpu(S5P_VA_CHIPID);
 
 	s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids));
+
+	samsung_device_pwm.dev.platform_data = &s5pv210_pwm_variant;
 }
 
 void __init s5pv210_map_io(void)
Signature · 1 line
1.8.1.5
#19 lore raw

PATCH v4 8/14 clocksource: samsung-time: Use Samsung PWM/timer master driver

In reply to Tomasz Figa

This patch modifies the samsung-time clocksource driver to use the interface provided by Samsung PWM/timer master driver to get platform data.

---
 arch/arm/plat-samsung/devs.c                      |  7 ++++
 arch/arm/plat-samsung/include/plat/samsung-time.h | 17 +++++++--
 drivers/clocksource/samsung-time.c                | 44 ++++++++++++++---------
 include/linux/platform_data/samsung-pwm.h         |  1 +
 4 files changed, 51 insertions(+), 18 deletions(-)
arch/arm/plat-samsung/devs.c +7 -0
index bfae4dd..747763d 100644
@@ -57,6 +57,7 @@
 #include <plat/keypad.h>
 #include <linux/platform_data/mmc-s3cmci.h>
 #include <linux/platform_data/mtd-nand-s3c2410.h>
+#include <plat/samsung-time.h>
 #include <plat/sdhci.h>
 #include <linux/platform_data/touchscreen-s3c2410.h>
 #include <linux/platform_data/usb-s3c2410_udc.h>
@@ -1184,6 +1185,12 @@ struct platform_device samsung_device_pwm = {
 	.resource	= samsung_pwm_resource,
 };
 
+void samsung_timer_init(void)
+{
+	samsung_pwm_register(&samsung_device_pwm);
+	samsung_time_init();
+}
+
 /* RTC */
 
 #ifdef CONFIG_PLAT_S3C24XX
arch/arm/plat-samsung/include/plat/samsung-time.h +15 -2
index 5d098ef..c0f35cc 100644
@@ -13,6 +13,10 @@
 #ifndef __ASM_PLAT_SAMSUNG_TIME_H
 #define __ASM_PLAT_SAMSUNG_TIME_H __FILE__
 
+#include <linux/platform_data/samsung-pwm.h>
+
+#include <plat/devs.h>
+
 /* SAMSUNG HR-Timer Clock mode */
 enum samsung_timer_mode {
 	SAMSUNG_PWM0,
@@ -39,8 +43,17 @@ struct samsung_timer_source {
 #define TSIZE			32
 #endif
 
-extern void __init samsung_set_timer_source(enum samsung_timer_mode event,
-					enum samsung_timer_mode source);
+static inline void samsung_set_timer_source(enum samsung_timer_mode event,
+					enum samsung_timer_mode source)
+{
+	struct samsung_pwm_variant *variant;
+
+	variant = samsung_device_pwm.dev.platform_data;
+	BUG_ON(!variant);
+
+	variant->output_mask = (1 << 5) - 1;
+	variant->output_mask &= ~((1 << event) | (1 << source));
+}
 
 extern void __init samsung_timer_init(void);
 
drivers/clocksource/samsung-time.c +28 -16

84 lines not on this page · raw message

include/linux/platform_data/samsung-pwm.h +1 -0
index 8c48dbb..ca6c488 100644
@@ -24,5 +24,6 @@ struct samsung_pwm_variant {
 };
 
 extern int samsung_pwm_register(struct platform_device *pdev);
+extern void samsung_time_init(void);
 
 #endif
Signature · 1 line
1.8.1.5
#20 lore raw

PATCH v4 9/14 clocksource: samsung-time: Use variant data to get SoC-specific bits

In reply to Tomasz Figa

This patch modifies the driver to calculate SoC-specific parameters from variant data received from PWM/timer master driver.

---
 arch/arm/plat-samsung/include/plat/samsung-time.h | 17 --------
 drivers/clocksource/samsung-time.c                | 51 ++++++++++++++++++-----
 2 files changed, 41 insertions(+), 27 deletions(-)
arch/arm/plat-samsung/include/plat/samsung-time.h +0 -17
index c0f35cc..785c6b7 100644
@@ -26,23 +26,6 @@ enum samsung_timer_mode {
 	SAMSUNG_PWM4,
 };
 
-struct samsung_timer_source {
-	unsigned int event_id;
-	unsigned int source_id;
-};
-
-#if defined(CONFIG_ARCH_S3C24XX) || defined(CONFIG_ARCH_S5PC100)
-#define TCNT_MAX		0xffff
-#define TSCALER_DIV		25
-#define TDIV			50
-#define TSIZE			16
-#else
-#define TCNT_MAX		0xffffffff
-#define TSCALER_DIV		2
-#define TDIV			2
-#define TSIZE			32
-#endif
-
 static inline void samsung_set_timer_source(enum samsung_timer_mode event,
 					enum samsung_timer_mode source)
 {
drivers/clocksource/samsung-time.c +41 -10

103 lines not on this page · raw message

Signature · 1 line
1.8.1.5
#21 lore raw

PATCH v4 10/14 clocksource: samsung-time: Use master driver to configure dividers

In reply to Tomasz Figa

This patch modifies the driver to use functions provided by master driver to configure PWM frequency dividers.

---
 drivers/clocksource/samsung-time.c | 61 +++++---------------------------------
 1 file changed, 8 insertions(+), 53 deletions(-)
drivers/clocksource/samsung-time.c +8 -53
index 4fa6f6f..e617d37 100644
@@ -19,7 +19,6 @@
 
 #include <asm/sched_clock.h>
 
-#include <plat/devs.h>
 #define S3C_TIMERREG(x) (pwm->base + (x))
 #define S3C_TIMERREG2(tmr,reg) S3C_TIMERREG((reg)+0x0c+((tmr)*0x0c))
 
@@ -72,10 +71,6 @@ struct samsung_timer_source {
 };
 
 static struct samsung_pwm *pwm;
-static struct clk *tin_event;
-static struct clk *tin_source;
-static struct clk *tdiv_event;
-static struct clk *tdiv_source;
 static struct clk *timerclk;
 static struct samsung_timer_source timer_source;
 static unsigned long clock_count_per_tick;
@@ -267,9 +262,6 @@ static void samsung_timer_resume(void)
 	samsung_time_start(timer_source.source_id, true);
 }
 
-	s3c_device_timer[event].dev.bus = &platform_bus_type;
-	s3c_device_timer[source].dev.bus = &platform_bus_type;
-
 static struct clock_event_device time_event_device = {
 	.name		= "samsung_event_timer",
 	.features	= CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
@@ -299,18 +291,14 @@ static void __init samsung_clockevent_init(void)
 	unsigned long pclk;
 	unsigned long clock_rate;
 	unsigned int irq_number;
-	struct clk *tscaler;
 
 	pclk = clk_get_rate(timerclk);
 
-	tscaler = clk_get_parent(tdiv_event);
-
-	clk_set_rate(tscaler, pclk / timer_source.tscaler_div);
-	clk_set_rate(tdiv_event,
-			pclk / (timer_source.tscaler_div * timer_source.tdiv));
-	clk_set_parent(tin_event, tdiv_event);
+	samsung_pwm_set_prescale(pwm, timer_source.event_id,
+						timer_source.tscaler_div);
+	samsung_pwm_set_divisor(pwm, timer_source.event_id, timer_source.tdiv);
 
-	clock_rate = clk_get_rate(tin_event);
+	clock_rate = pclk / (timer_source.tscaler_div * timer_source.tdiv);
 	clock_count_per_tick = clock_rate / HZ;
 
 	time_event_device.cpumask = cpumask_of(0);
@@ -370,11 +358,11 @@ static void __init samsung_clocksource_init(void)
 
 	pclk = clk_get_rate(timerclk);
 
-	clk_set_rate(tdiv_source,
-			pclk / (timer_source.tscaler_div * timer_source.tdiv));
-	clk_set_parent(tin_source, tdiv_source);
+	samsung_pwm_set_prescale(pwm, timer_source.source_id,
+						timer_source.tscaler_div);
+	samsung_pwm_set_divisor(pwm, timer_source.source_id, timer_source.tdiv);
 
-	clock_rate = clk_get_rate(tin_source);
+	clock_rate = pclk / (timer_source.tscaler_div * timer_source.tdiv);
 
 	samsung_time_setup(timer_source.source_id, timer_source.tcnt_max);
 	samsung_time_start(timer_source.source_id, true);
@@ -391,43 +379,10 @@ static void __init samsung_clocksource_init(void)
 
 static void __init samsung_timer_resources(void)
 {
-
-	unsigned long event_id = timer_source.event_id;
-	unsigned long source_id = timer_source.source_id;
-	char devname[15];
-
 	timerclk = clk_get(NULL, "timers");
 	if (IS_ERR(timerclk))
 		panic("failed to get timers clock for timer");
 
-	clk_enable(timerclk);
-
-	sprintf(devname, "s3c24xx-pwm.%lu", event_id);
-	s3c_device_timer[event_id].id = event_id;
-	s3c_device_timer[event_id].dev.init_name = devname;
-
-	tin_event = clk_get(&s3c_device_timer[event_id].dev, "pwm-tin");
-	if (IS_ERR(tin_event))
-		panic("failed to get pwm-tin clock for event timer");
-
-	tdiv_event = clk_get(&s3c_device_timer[event_id].dev, "pwm-tdiv");
-	if (IS_ERR(tdiv_event))
-		panic("failed to get pwm-tdiv clock for event timer");
-
-	clk_enable(tin_event);
-
-	sprintf(devname, "s3c24xx-pwm.%lu", source_id);
-	s3c_device_timer[source_id].id = source_id;
-	s3c_device_timer[source_id].dev.init_name = devname;
-
-	tin_source = clk_get(&s3c_device_timer[source_id].dev, "pwm-tin");
-	if (IS_ERR(tin_source))
-		panic("failed to get pwm-tin clock for source timer");
-
-	tdiv_source = clk_get(&s3c_device_timer[source_id].dev, "pwm-tdiv");
-	if (IS_ERR(tdiv_source))
-		panic("failed to get pwm-tdiv clock for source timer");
-
 	clk_enable(tin_source);
 
 	timer_source.tcnt_max = (1UL << pwm->variant.bits) - 1;
Signature · 1 line
1.8.1.5
#22 lore raw

PATCH v4 11/14 clocksource: samsung-time: Use clk_prepare_enable

In reply to Tomasz Figa

This patch modifies the driver to use clk_prepare_enable instead of clk_enable, as required to be compliant with Common Clock Framework.

---
 drivers/clocksource/samsung-time.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/samsung-time.c +1 -1
index e617d37..7674882 100644
@@ -383,7 +383,7 @@ static void __init samsung_timer_resources(void)
 	if (IS_ERR(timerclk))
 		panic("failed to get timers clock for timer");
 
-	clk_enable(tin_source);
+	clk_prepare_enable(timerclk);
 
 	timer_source.tcnt_max = (1UL << pwm->variant.bits) - 1;
 	if (pwm->variant.bits == 16) {
Signature · 1 line
1.8.1.5
#23 lore raw

PATCH v4 12/14 clocksource: samsung-time: Use master driver to control PWM channels

In reply to Tomasz Figa

This patch modifies the driver to use functions provided by the master driver to control status of PWM channels instead of modifying shared registers directly.

---
 drivers/clocksource/samsung-time.c | 168 ++++---------------------------------
 1 file changed, 15 insertions(+), 153 deletions(-)
drivers/clocksource/samsung-time.c +15 -153
index 7674882..9425955 100644
@@ -76,153 +76,11 @@ static struct samsung_timer_source timer_source;
 static unsigned long clock_count_per_tick;
 static void samsung_timer_resume(void);
 
-static void samsung_time_stop(enum samsung_timer_mode mode)
-{
-	unsigned long tcon;
-
-	tcon = __raw_readl(S3C2410_TCON);
-
-	switch (mode) {
-	case SAMSUNG_PWM0:
-		tcon &= ~S3C2410_TCON_T0START;
-		break;
-
-	case SAMSUNG_PWM1:
-		tcon &= ~S3C2410_TCON_T1START;
-		break;
-
-	case SAMSUNG_PWM2:
-		tcon &= ~S3C2410_TCON_T2START;
-		break;
-
-	case SAMSUNG_PWM3:
-		tcon &= ~S3C2410_TCON_T3START;
-		break;
-
-	case SAMSUNG_PWM4:
-		tcon &= ~S3C2410_TCON_T4START;
-		break;
-
-	default:
-		printk(KERN_ERR "Invalid Timer %d\n", mode);
-		break;
-	}
-	__raw_writel(tcon, S3C2410_TCON);
-}
-
-static void samsung_time_setup(enum samsung_timer_mode mode, unsigned long tcnt)
-{
-	unsigned long tcon;
-
-	tcon = __raw_readl(S3C2410_TCON);
-
-	tcnt--;
-
-	switch (mode) {
-	case SAMSUNG_PWM0:
-		tcon &= ~(0x0f << 0);
-		tcon |= S3C2410_TCON_T0MANUALUPD;
-		break;
-
-	case SAMSUNG_PWM1:
-		tcon &= ~(0x0f << 8);
-		tcon |= S3C2410_TCON_T1MANUALUPD;
-		break;
-
-	case SAMSUNG_PWM2:
-		tcon &= ~(0x0f << 12);
-		tcon |= S3C2410_TCON_T2MANUALUPD;
-		break;
-
-	case SAMSUNG_PWM3:
-		tcon &= ~(0x0f << 16);
-		tcon |= S3C2410_TCON_T3MANUALUPD;
-		break;
-
-	case SAMSUNG_PWM4:
-		tcon &= ~(0x07 << 20);
-		tcon |= S3C2410_TCON_T4MANUALUPD;
-		break;
-
-	default:
-		printk(KERN_ERR "Invalid Timer %d\n", mode);
-		break;
-	}
-
-	__raw_writel(tcnt, S3C2410_TCNTB(mode));
-	__raw_writel(tcnt, S3C2410_TCMPB(mode));
-	__raw_writel(tcon, S3C2410_TCON);
-}
-
-static void samsung_time_start(enum samsung_timer_mode mode, bool periodic)
-{
-	unsigned long tcon;
-
-	tcon  = __raw_readl(S3C2410_TCON);
-
-	switch (mode) {
-	case SAMSUNG_PWM0:
-		tcon |= S3C2410_TCON_T0START;
-		tcon &= ~S3C2410_TCON_T0MANUALUPD;
-
-		if (periodic)
-			tcon |= S3C2410_TCON_T0RELOAD;
-		else
-			tcon &= ~S3C2410_TCON_T0RELOAD;
-		break;
-
-	case SAMSUNG_PWM1:
-		tcon |= S3C2410_TCON_T1START;
-		tcon &= ~S3C2410_TCON_T1MANUALUPD;
-
-		if (periodic)
-			tcon |= S3C2410_TCON_T1RELOAD;
-		else
-			tcon &= ~S3C2410_TCON_T1RELOAD;
-		break;
-
-	case SAMSUNG_PWM2:
-		tcon |= S3C2410_TCON_T2START;
-		tcon &= ~S3C2410_TCON_T2MANUALUPD;
-
-		if (periodic)
-			tcon |= S3C2410_TCON_T2RELOAD;
-		else
-			tcon &= ~S3C2410_TCON_T2RELOAD;
-		break;
-
-	case SAMSUNG_PWM3:
-		tcon |= S3C2410_TCON_T3START;
-		tcon &= ~S3C2410_TCON_T3MANUALUPD;
-
-		if (periodic)
-			tcon |= S3C2410_TCON_T3RELOAD;
-		else
-			tcon &= ~S3C2410_TCON_T3RELOAD;
-		break;
-
-	case SAMSUNG_PWM4:
-		tcon |= S3C2410_TCON_T4START;
-		tcon &= ~S3C2410_TCON_T4MANUALUPD;
-
-		if (periodic)
-			tcon |= S3C2410_TCON_T4RELOAD;
-		else
-			tcon &= ~S3C2410_TCON_T4RELOAD;
-		break;
-
-	default:
-		printk(KERN_ERR "Invalid Timer %d\n", mode);
-		break;
-	}
-	__raw_writel(tcon, S3C2410_TCON);
-}
-
 static int samsung_set_next_event(unsigned long cycles,
 				struct clock_event_device *evt)
 {
-	samsung_time_setup(timer_source.event_id, cycles);
-	samsung_time_start(timer_source.event_id, false);
+	samsung_pwm_setup(pwm, timer_source.event_id, cycles - 1, cycles - 1);
+	samsung_pwm_start(pwm, timer_source.event_id, false);
 
 	return 0;
 }
@@ -230,12 +88,13 @@ static int samsung_set_next_event(unsigned long cycles,
 static void samsung_set_mode(enum clock_event_mode mode,
 				struct clock_event_device *evt)
 {
-	samsung_time_stop(timer_source.event_id);
+	samsung_pwm_stop(pwm, timer_source.event_id);
 
 	switch (mode) {
 	case CLOCK_EVT_MODE_PERIODIC:
-		samsung_time_setup(timer_source.event_id, clock_count_per_tick);
-		samsung_time_start(timer_source.event_id, true);
+		samsung_pwm_setup(pwm, timer_source.event_id,
+			clock_count_per_tick - 1, clock_count_per_tick - 1);
+		samsung_pwm_start(pwm, timer_source.event_id, true);
 		break;
 
 	case CLOCK_EVT_MODE_ONESHOT:
@@ -254,12 +113,14 @@ static void samsung_set_mode(enum clock_event_mode mode,
 static void samsung_timer_resume(void)
 {
 	/* event timer restart */
-	samsung_time_setup(timer_source.event_id, clock_count_per_tick);
-	samsung_time_start(timer_source.event_id, true);
+	samsung_pwm_setup(pwm, timer_source.event_id,
+			clock_count_per_tick - 1, clock_count_per_tick - 1);
+	samsung_pwm_start(pwm, timer_source.event_id, true);
 
 	/* source timer restart */
-	samsung_time_setup(timer_source.source_id, timer_source.tcnt_max);
-	samsung_time_start(timer_source.source_id, true);
+	samsung_pwm_setup(pwm, timer_source.source_id,
+				timer_source.tcnt_max, timer_source.tcnt_max);
+	samsung_pwm_start(pwm, timer_source.source_id, true);
 }
 
 static struct clock_event_device time_event_device = {
@@ -364,8 +225,9 @@ static void __init samsung_clocksource_init(void)
 
 	clock_rate = pclk / (timer_source.tscaler_div * timer_source.tdiv);
 
-	samsung_time_setup(timer_source.source_id, timer_source.tcnt_max);
-	samsung_time_start(timer_source.source_id, true);
+	samsung_pwm_setup(pwm, timer_source.source_id,
+				timer_source.tcnt_max, timer_source.tcnt_max);
+	samsung_pwm_start(pwm, timer_source.source_id, true);
 
 	setup_sched_clock(samsung_read_sched_clock,
 						pwm->variant.bits, clock_rate);
Signature · 1 line
1.8.1.5
#24 lore raw

PATCH v4 13/14 clocksource: samsung-time: Move IRQ mask/ack handling to the driver

In reply to Tomasz Figa

Since the clocksource driver is the only user of PWM timer interrupts, there is no need to create an IRQ chip for handling them.

This patch the way of PWM timer interrupt handling to use real VIC/GIC interrupt signals and handle PWM mask/ack register internally in samsung-time driver.

---
 arch/arm/mach-exynos/include/mach/irqs.h  |  3 +--
 arch/arm/mach-s3c24xx/include/mach/irqs.h |  6 ++++++
 arch/arm/mach-s3c64xx/common.c            |  3 ---
 arch/arm/mach-s3c64xx/include/mach/irqs.h |  8 --------
 arch/arm/mach-s5p64x0/include/mach/irqs.h |  2 --
 arch/arm/mach-s5pc100/include/mach/irqs.h |  2 --
 arch/arm/mach-s5pv210/include/mach/irqs.h |  2 --
 arch/arm/plat-samsung/devs.c              | 20 ++++++++++----------
 arch/arm/plat-samsung/include/plat/irqs.h |  9 ---------
 arch/arm/plat-samsung/s5p-irq.c           |  2 --
 drivers/clocksource/samsung-time.c        | 10 ++++++++++
 11 files changed, 27 insertions(+), 40 deletions(-)
arch/arm/mach-exynos/include/mach/irqs.h +1 -2
index 35fe6d5..6fbe229 100644
@@ -464,10 +464,9 @@
 #define S5P_EINT_BASE2			(S5P_EINT_BASE1 + 16)
 #define S5P_GPIOINT_BASE		(S5P_EINT_BASE1 + 32)
 #define IRQ_GPIO_END			(S5P_GPIOINT_BASE + S5P_GPIOINT_COUNT)
-#define IRQ_TIMER_BASE			(IRQ_GPIO_END + 64)
 
 /* Set the default NR_IRQS */
 
-#define NR_IRQS				(IRQ_TIMER_BASE + IRQ_TIMER_COUNT)
+#define NR_IRQS				(IRQ_GPIO_END + 64)
 
 #endif /* __ASM_ARCH_IRQS_H */
arch/arm/mach-s3c24xx/include/mach/irqs.h +6 -0
index 43cada8..1ecbadb 100644
@@ -207,6 +207,12 @@
 #define IRQ_LCD_VSYNC		IRQ_S3C2443_LCD3
 #define IRQ_LCD_SYSTEM		IRQ_S3C2443_LCD2
 
+#define IRQ_TIMER0_VIC		IRQ_TIMER0
+#define IRQ_TIMER1_VIC		IRQ_TIMER1
+#define IRQ_TIMER2_VIC		IRQ_TIMER2
+#define IRQ_TIMER3_VIC		IRQ_TIMER3
+#define IRQ_TIMER4_VIC		IRQ_TIMER4
+
 #ifdef CONFIG_CPU_S3C2440
 #define IRQ_S3C244X_AC97 IRQ_S3C2440_AC97
 #else
arch/arm/mach-s3c64xx/common.c +0 -3
index 526b45e..5dca83a 100644
@@ -198,9 +198,6 @@ void __init s3c64xx_init_irq(u32 vic0_valid, u32 vic1_valid)
 	/* initialise the pair of VICs */
 	vic_init(VA_VIC0, IRQ_VIC0_BASE, vic0_valid, IRQ_VIC0_RESUME);
 	vic_init(VA_VIC1, IRQ_VIC1_BASE, vic1_valid, IRQ_VIC1_RESUME);
-
-	/* add the timer sub-irqs */
-	s3c_init_vic_timer_irq(5, IRQ_TIMER0);
 }
 
 #define eint_offset(irq)	((irq) - IRQ_EINT(0))
arch/arm/mach-s3c64xx/include/mach/irqs.h +0 -8
index 96d60e0..67bbd1d 100644
@@ -107,14 +107,6 @@
 #define IRQ_TC			IRQ_PENDN
 #define IRQ_ADC			S3C64XX_IRQ_VIC1(31)
 
-#define S3C64XX_TIMER_IRQ(x)	S3C_IRQ(64 + (x))
-
-#define IRQ_TIMER0		S3C64XX_TIMER_IRQ(0)
-#define IRQ_TIMER1		S3C64XX_TIMER_IRQ(1)
-#define IRQ_TIMER2		S3C64XX_TIMER_IRQ(2)
-#define IRQ_TIMER3		S3C64XX_TIMER_IRQ(3)
-#define IRQ_TIMER4		S3C64XX_TIMER_IRQ(4)
-
 /* compatibility for device defines */
 
 #define IRQ_IIC1		IRQ_S3C6410_IIC1
arch/arm/mach-s5p64x0/include/mach/irqs.h +0 -2
index 5b845e8..53982db 100644
@@ -141,8 +141,6 @@
 
 #define IRQ_EINT_GROUP(grp, x)	(IRQ_EINT_GROUP##grp##_BASE + (x))
 
-#define IRQ_TIMER_BASE		(11)
-
 /* Set the default NR_IRQS */
 
 #define NR_IRQS			(IRQ_EINT_GROUP8_BASE + IRQ_EINT_GROUP8_NR + 1)
arch/arm/mach-s5pc100/include/mach/irqs.h +0 -2
index 2870f12..d2eb475 100644
@@ -97,8 +97,6 @@
 #define IRQ_SDMFIQ		S5P_IRQ_VIC2(31)
 #define IRQ_VIC_END		S5P_IRQ_VIC2(31)
 
-#define IRQ_TIMER_BASE		(11)
-
 #define S5P_EINT_BASE1		(S5P_IRQ_VIC0(0))
 #define S5P_EINT_BASE2		(IRQ_VIC_END + 1)
 
arch/arm/mach-s5pv210/include/mach/irqs.h +0 -2
index e777e01..5e0de3a 100644
@@ -118,8 +118,6 @@
 #define IRQ_MDNIE3		S5P_IRQ_VIC3(8)
 #define IRQ_VIC_END		S5P_IRQ_VIC3(31)
 
-#define IRQ_TIMER_BASE		(11)
-
 #define S5P_EINT_BASE1		(S5P_IRQ_VIC0(0))
 #define S5P_EINT_BASE2		(IRQ_VIC_END + 1)
 
arch/arm/plat-samsung/devs.c +10 -10
index 747763d..cdeaf26 100644
@@ -1161,20 +1161,20 @@ arch_initcall(s5p_pmu_init);
  */
 
 struct platform_device s3c_device_timer[] = {
-	[0] = { DEFINE_S3C_TIMER(0, IRQ_TIMER0) },
-	[1] = { DEFINE_S3C_TIMER(1, IRQ_TIMER1) },
-	[2] = { DEFINE_S3C_TIMER(2, IRQ_TIMER2) },
-	[3] = { DEFINE_S3C_TIMER(3, IRQ_TIMER3) },
-	[4] = { DEFINE_S3C_TIMER(4, IRQ_TIMER4) },
+	[0] = { DEFINE_S3C_TIMER(0, IRQ_TIMER0_VIC) },
+	[1] = { DEFINE_S3C_TIMER(1, IRQ_TIMER1_VIC) },
+	[2] = { DEFINE_S3C_TIMER(2, IRQ_TIMER2_VIC) },
+	[3] = { DEFINE_S3C_TIMER(3, IRQ_TIMER3_VIC) },
+	[4] = { DEFINE_S3C_TIMER(4, IRQ_TIMER4_VIC) },
 };
 #endif /* CONFIG_SAMSUNG_DEV_PWM */
 
 static struct resource samsung_pwm_resource[] = {
-	DEFINE_RES_IRQ(IRQ_TIMER0),
-	DEFINE_RES_IRQ(IRQ_TIMER1),
-	DEFINE_RES_IRQ(IRQ_TIMER2),
-	DEFINE_RES_IRQ(IRQ_TIMER3),
-	DEFINE_RES_IRQ(IRQ_TIMER4),
+	DEFINE_RES_IRQ(IRQ_TIMER0_VIC),
+	DEFINE_RES_IRQ(IRQ_TIMER1_VIC),
+	DEFINE_RES_IRQ(IRQ_TIMER2_VIC),
+	DEFINE_RES_IRQ(IRQ_TIMER3_VIC),
+	DEFINE_RES_IRQ(IRQ_TIMER4_VIC),
 	DEFINE_RES_MEM(SAMSUNG_PA_TIMER, SZ_4K),
 };
 
arch/arm/plat-samsung/include/plat/irqs.h +0 -9
index df46b77..039001c 100644
@@ -44,15 +44,6 @@
 #define S5P_IRQ_VIC2(x)		(S5P_VIC2_BASE + (x))
 #define S5P_IRQ_VIC3(x)		(S5P_VIC3_BASE + (x))
 
-#define S5P_TIMER_IRQ(x)	(IRQ_TIMER_BASE + (x))
-
-#define IRQ_TIMER0		S5P_TIMER_IRQ(0)
-#define IRQ_TIMER1		S5P_TIMER_IRQ(1)
-#define IRQ_TIMER2		S5P_TIMER_IRQ(2)
-#define IRQ_TIMER3		S5P_TIMER_IRQ(3)
-#define IRQ_TIMER4		S5P_TIMER_IRQ(4)
-#define IRQ_TIMER_COUNT		(5)
-
 #define IRQ_EINT(x)		((x) < 16 ? ((x) + S5P_EINT_BASE1) \
 					: ((x) - 16 + S5P_EINT_BASE2))
 
arch/arm/plat-samsung/s5p-irq.c +0 -2
index 103e371..ce8564d 100644
@@ -29,6 +29,4 @@ void __init s5p_init_irq(u32 *vic, u32 num_vic)
 	for (irq = 0; irq < num_vic; irq++)
 		vic_init(VA_VIC(irq), VIC_BASE(irq), vic[irq], 0);
 #endif
-
-	s3c_init_vic_timer_irq(5, IRQ_TIMER0);
 }
drivers/clocksource/samsung-time.c +10 -0
index 9425955..d9a3d60 100644
@@ -135,6 +135,11 @@ static irqreturn_t samsung_clock_event_isr(int irq, void *dev_id)
 {
 	struct clock_event_device *evt = dev_id;
 
+	if (pwm->variant.has_tint_cstat) {
+		u32 mask = (1 << timer_source.event_id);
+		writel(mask | (mask << 5), S3C64XX_TINT_CSTAT);
+	}
+
 	evt->event_handler(evt);
 
 	return IRQ_HANDLED;
@@ -168,6 +173,11 @@ static void __init samsung_clockevent_init(void)
 
 	irq_number = pwm->irq[timer_source.event_id];
 	setup_irq(irq_number, &samsung_clock_event_irq);
+
+	if (pwm->variant.has_tint_cstat) {
+		u32 mask = (1 << timer_source.event_id);
+		writel(mask | (mask << 5), S3C64XX_TINT_CSTAT);
+	}
 }
 
 static void __iomem *samsung_timer_reg(void)
Signature · 1 line
1.8.1.5
#25 lore raw

PATCH v4 14/14 ARM: SAMSUNG: Remove unused PWM timer IRQ chip code

In reply to Tomasz Figa

As the need for an IRQ chip handling PWM timer interrupt chaining is gone now, this patch removes all the code made unnecessary.

---
 arch/arm/Kconfig                                   |  1 -
 arch/arm/mach-s3c64xx/common.c                     |  1 -
 arch/arm/plat-samsung/Kconfig                      |  6 --
 arch/arm/plat-samsung/Makefile                     |  1 -
 arch/arm/plat-samsung/include/plat/irq-vic-timer.h | 13 ---
 arch/arm/plat-samsung/irq-vic-timer.c              | 98 ----------------------
 arch/arm/plat-samsung/s5p-irq.c                    |  1 -
 7 files changed, 121 deletions(-)
 delete mode 100644 arch/arm/plat-samsung/include/plat/irq-vic-timer.h
 delete mode 100644 arch/arm/plat-samsung/irq-vic-timer.c
arch/arm/Kconfig +0 -1
index dd68dec..ed584d4 100644
@@ -806,7 +806,6 @@ config ARCH_S3C64XX
 	select S3C_GPIO_TRACK
 	select SAMSUNG_CLKSRC
 	select SAMSUNG_GPIOLIB_4BIT
-	select SAMSUNG_IRQ_VIC_TIMER
 	select USB_ARCH_HAS_OHCI
 	help
 	  Samsung S3C64XX series based systems
arch/arm/mach-s3c64xx/common.c +0 -1
index 5dca83a..e2134b0 100644
@@ -42,7 +42,6 @@
 #include <plat/pm.h>
 #include <plat/gpio-cfg.h>
 #include <plat/irq-uart.h>
-#include <plat/irq-vic-timer.h>
 #include <plat/regs-irqtype.h>
 #include <plat/regs-serial.h>
 #include <plat/watchdog-reset.h>
arch/arm/plat-samsung/Kconfig +0 -6
index 6f632ba..9951879 100644
@@ -27,7 +27,6 @@ config PLAT_S5P
 	select S5P_GPIO_DRVSTR
 	select SAMSUNG_CLKSRC if !COMMON_CLK
 	select SAMSUNG_GPIOLIB_4BIT
-	select SAMSUNG_IRQ_VIC_TIMER
 	help
 	  Base platform code for Samsung's S5P series SoC.
 
@@ -79,11 +78,6 @@ config S5P_CLOCK
 
 # options for IRQ support
 
-config SAMSUNG_IRQ_VIC_TIMER
-       bool
-       help
-         Internal configuration to build the VIC timer interrupt code.
-
 config S5P_IRQ
 	def_bool (ARCH_S5P64X0 || ARCH_S5PC100 || ARCH_S5PV210 || ARCH_EXYNOS)
 	help
arch/arm/plat-samsung/Makefile +0 -1
index 87494e1..ae2a0fd 100644
@@ -19,7 +19,6 @@ obj-$(CONFIG_SAMSUNG_CLOCK)	+= pwm-clock.o
 obj-$(CONFIG_SAMSUNG_CLKSRC)	+= clock-clksrc.o
 obj-$(CONFIG_S5P_CLOCK)		+= s5p-clock.o
 
-obj-$(CONFIG_SAMSUNG_IRQ_VIC_TIMER) += irq-vic-timer.o
 obj-$(CONFIG_S5P_IRQ)		+= s5p-irq.o
 obj-$(CONFIG_S5P_EXT_INT)	+= s5p-irq-eint.o
 obj-$(CONFIG_S5P_GPIO_INT)	+= s5p-irq-gpioint.o
arch/arm/plat-samsung/include/plat/irq-vic-timer.h deleted +0 -13
deleted file mode 100644
index 5b9c42f..0000000
@@ -1,13 +0,0 @@
-/* arch/arm/plat-samsung/include/plat/irq-vic-timer.h
- *
- * Copyright (c) 2010 Simtec Electronics
- *	Ben Dooks <[email protected]>
- *
- * Header file for Samsung SoC IRQ VIC timer
- *
- * 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.
-*/
-
-extern void s3c_init_vic_timer_irq(unsigned int num, unsigned int timer_irq);
arch/arm/plat-samsung/irq-vic-timer.c deleted +0 -98

98 lines not on this page · raw message

arch/arm/plat-samsung/s5p-irq.c +0 -1
index ce8564d..b1e2a82 100644
@@ -18,7 +18,6 @@
 #include <mach/map.h>
 #include <plat/regs-timer.h>
 #include <plat/cpu.h>
-#include <plat/irq-vic-timer.h>
 
 void __init s5p_init_irq(u32 *vic, u32 num_vic)
 {
Signature · 1 line
1.8.1.5
#26 lore raw

v4 cover ARM: samsung-time: Prepare for multiplatform support

In reply to Tomasz Figa

Am Donnerstag, 4. April 2013, 18:36:57 schrieb Tomasz Figa:

Quoted 5 lines

This series is an attempt to make the samsung-time clocksource driver ready for multiplatform kernels. It moves the driver to drivers/clocksource, cleans it up from uses of static platform-specific definitions, simplifies timer interrupt handling and adds Device Tree support.

Quoted 8 lines

Only samsung-time driver is reworked to use the master driver at this time, since the PWM driver can be already considered broken at the moment and needs separate series of several patches to fix and clean it up, which I am already working on.

Tested on Universal C210 board with Device Tree. Not tested without Device Tree, since it has been already broken before this series. Compile tested for other related SoCs.

Looks nice.

On a non-DT S3C2416 board:

And just so I don't search myself silly, am I right in thinking that the driver does not use the generic clocksource registration yet and dt machines must still use samsung_timer_init at this point?

Heiko

#27 lore raw

v4 cover ARM: samsung-time: Prepare for multiplatform support

Hi Heiko,

Quoted 13 lines · On Friday 05 of April 2013 01:15:02 Heiko St?bner wrote:

Am Donnerstag, 4. April 2013, 18:36:57 schrieb Tomasz Figa:

Quoted 12 lines

This series is an attempt to make the samsung-time clocksource driver ready
for multiplatform kernels. It moves the driver to drivers/clocksource, cleans it up from uses of static platform-specific definitions, simplifies timer interrupt handling and adds Device Tree support.

Only samsung-time driver is reworked to use the master driver at this time,
since the PWM driver can be already considered broken at the moment and needs separate series of several patches to fix and clean it up, which I am already working on.

Quoted 8 lines
Quoted 3 lines

Tested on Universal C210 board with Device Tree. Not tested without Device Tree, since it has been already broken before this series. Compile tested for other related SoCs.

Looks nice.

On a non-DT S3C2416 board:

Thanks for testing.

Quoted 3 lines

And just so I don't search myself silly, am I right in thinking that the driver does not use the generic clocksource registration yet and dt machines must still use samsung_timer_init at this point?

Yes. Because of the build failures it caused recently I have decided not to use it yet. It can be added with a small patch later, though.

Best regards,

Signature · 3 lines
Tomasz Figa
Samsung Poland R&D Center
SW Solution Development, Kernel and System Framework
#28 lore raw

v4 cover ARM: samsung-time: Prepare for multiplatform support

In reply to Tomasz Figa
Quoted 39 lines · On Thursday 04 of April 2013 18:36:57 Tomasz Figa wrote:

This series is an attempt to make the samsung-time clocksource driver ready for multiplatform kernels. It moves the driver to drivers/clocksource, cleans it up from uses of static platform-specific definitions, simplifies timer interrupt handling and adds Device Tree support.

Only samsung-time driver is reworked to use the master driver at this time, since the PWM driver can be already considered broken at the moment and needs separate series of several patches to fix and clean it up, which I am already working on.

Tested on Universal C210 board with Device Tree. Not tested without Device Tree, since it has been already broken before this series. Compile tested for other related SoCs.

Changes since v3:
(http://thread.gmane.org/gmane.linux.kernel.samsung-soc/16664/)
- Changed the design to use common (master) driver for operations that can be done from both clocksource and PWM drivers (as suggested by Arnd Bergmann) - needed to properly synchronize access to PWM
registers - Moved handling of PWM prescaler and divider to master driver

Changes since v2:
(http://thread.gmane.org/gmane.linux.kernel.samsung-soc/16158)
- Addressed comments from Rob Herring and Mark Rutland
- Removed unused register definitions
- Replaced samsung,source-timer and samsung,event-timer properties with samsung,pwm-outputs property that defines which PWM channels are reserved for PWM outputs on particular platform
- Split non-DT and DT initialization into two functions
- Fixed a copy paste error

Changes since v1:
(http://thread.gmane.org/gmane.linux.kernel.samsung-soc/16005)
- Addressed comments from Mark Rutland
- Documented struct samsung_timer_variant
- Dropped inactive mail addresses from CC

Quoted 15 lines

Tomasz Figa (14):
ARM: SAMSUNG: Move samsung-time to drivers/clocksource
clocksource: samsung-time: Drop useless defines from public header
clocksource: samsung-time: Use local register definitions
mfd: Add Samsung PWM/timer master driver
ARM: SAMSUNG: Unify base address definitions of timer block
ARM: SAMSUNG: Add new PWM platform device
ARM: SAMSUNG: Set PWM platform data
clocksource: samsung-time: Use Samsung PWM/timer master driver
clocksource: samsung-time: Use variant data to get SoC-specific bits
clocksource: samsung-time: Use master driver to configure dividers
clocksource: samsung-time: Use clk_prepare_enable
clocksource: samsung-time: Use master driver to control PWM channels
clocksource: samsung-time: Move IRQ mask/ack handling to the driver
ARM: SAMSUNG: Remove unused PWM timer IRQ chip code

On FriendlyARM's Tiny6410 board (Mini6410-compatible), both with (using my patches adding S3C64xx Device Tree and pinctrl support) and without Device Tree:

Best regards,
Tomasz