Skip to contentSkip to conversation

Prerequisite patches to support device tree on Samsung's Exynos4 platform

PATCH In review Thomas Abraham 2 participants 8 messages Mar 28, 2011 – Mar 29, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover Prerequisite patches to support device tree on Samsung's Exynos4 platform

This patchset is a prerequisite for device tree patches on Exynos4. It includes the following changes.

1. Adds clkdev support for Exynos4
2. Removes redundant console registration for Exynos4 and clkdev.
3. Modifies samsung serial driver to keep a copy of platform data and use it.

Changes since V1:

1. Fixed incorrect devname for clocks.
2. Moved CLKDEV_LOOKUP to arch/arm/Kconfig

Thomas Abraham (5):
serial: samsung: Fix unintended usage of uart port 0 as console
serial: s5pv210: Remove redundant console_initcall
ARM: SAMSUNG: Add clkdev support
ARM: SAMSUNG: Add clkdev support for exynos4
serial: samsung: Keep a copy a pdev->dev.platform_data and use it

 arch/arm/Kconfig                            |    1 +
 arch/arm/mach-exynos4/clock.c               |   57 +++++++++++++++++++++++++++
 arch/arm/mach-exynos4/include/mach/clkdev.h |    7 +++
 arch/arm/mach-exynos4/time.c                |    2 +
 arch/arm/plat-samsung/clock.c               |   18 ++++++++
 arch/arm/plat-samsung/include/plat/clock.h  |    5 ++
 arch/arm/plat-samsung/pwm-clock.c           |   10 +++++
 drivers/tty/serial/s5pv210.c                |   19 +++++----
 drivers/tty/serial/samsung.c                |   35 +++++++++++-----
 drivers/tty/serial/samsung.h                |    3 +
 10 files changed, 137 insertions(+), 20 deletions(-)
 create mode 100644 arch/arm/mach-exynos4/include/mach/clkdev.h
#1 lore raw

PATCH v2 1/5 serial: samsung: Fix unintended usage of uart port 0 as console

In s3c24xx_serial_console_setup function, if the uart port that is being setup as a console has not been initialized, an error can be returned instead of using uart port 0 as the default console port. The uart port that was intended to be used as a console could be initialized at a later point during boot and then registered as a console. This will avoid using uart port 0 as a unintended console port.

---
 drivers/tty/serial/samsung.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/tty/serial/samsung.c +2 -4
index 2335eda..1586440 100644
@@ -1417,10 +1417,8 @@ s3c24xx_serial_console_setup(struct console *co, char *options)
 
 	/* is the port configured? */
 
-	if (port->mapbase == 0x0) {
-		co->index = 0;
-		port = &s3c24xx_serial_ports[co->index].port;
-	}
+	if (port->mapbase == 0x0)
+		return -ENODEV;
 
 	cons_uart = port;
 
Signature · 1 line
1.6.6.rc2
#2 lore raw

PATCH v2 2/5 serial: s5pv210: Remove redundant console_initcall

In reply to Thomas Abraham

Uart port is registered as a console during the driver's probe. So explict registration of console with console_initcall is removed.

---
 drivers/tty/serial/s5pv210.c |    7 -------
 drivers/tty/serial/samsung.c |    3 ++-
 2 files changed, 2 insertions(+), 8 deletions(-)
drivers/tty/serial/s5pv210.c +0 -7
index 6ebccd7..cdee626 100644
@@ -136,13 +136,6 @@ static struct platform_driver s5p_serial_driver = {
 	},
 };
 
-static int __init s5pv210_serial_console_init(void)
-{
-	return s3c24xx_serial_initconsole(&s5p_serial_driver, s5p_uart_inf);
-}
-
-console_initcall(s5pv210_serial_console_init);
-
 static int __init s5p_serial_init(void)
 {
 	return s3c24xx_serial_init(&s5p_serial_driver, *s5p_uart_inf);
drivers/tty/serial/samsung.c +2 -1
index 1586440..9d9d97c 100644
@@ -1450,7 +1450,8 @@ static struct console s3c24xx_serial_console = {
 	.flags		= CON_PRINTBUFFER,
 	.index		= -1,
 	.write		= s3c24xx_serial_console_write,
-	.setup		= s3c24xx_serial_console_setup
+	.setup		= s3c24xx_serial_console_setup,
+	.data		= &s3c24xx_uart_drv,
 };
 
 int s3c24xx_serial_initconsole(struct platform_driver *drv,
Signature · 1 line
1.6.6.rc2
#3 lore raw

PATCH v2 3/5 ARM: SAMSUNG: Add clkdev support

In reply to Thomas Abraham

Add infrastructure for clkdev support on samsung platforms.

---
 arch/arm/plat-samsung/clock.c              |   18 ++++++++++++++++++
 arch/arm/plat-samsung/include/plat/clock.h |    5 +++++
 2 files changed, 23 insertions(+), 0 deletions(-)
arch/arm/plat-samsung/clock.c +18 -0
index 7728928..177580e 100644
@@ -71,6 +71,12 @@ static int clk_null_enable(struct clk *clk, int enable)
 	return 0;
 }
 
+/*
+ * When all Samsung platforms use clkdev, pdev->id based clock lookup
+ * code can be removed.
+ */
+#ifndef CONFIG_CLKDEV_LOOKUP
+
 static int dev_is_s3c_uart(struct device *dev)
 {
 	struct platform_device **pdev = s3c24xx_uart_devs;
@@ -139,6 +145,8 @@ void clk_put(struct clk *clk)
 	module_put(clk->owner);
 }
 
+#endif /* CONFIG_CLKDEV_LOOKUP */
+
 int clk_enable(struct clk *clk)
 {
 	if (IS_ERR(clk) || clk == NULL)
@@ -241,8 +249,10 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
 	return ret;
 }
 
+#ifndef CONFIG_CLKDEV_LOOKUP
 EXPORT_SYMBOL(clk_get);
 EXPORT_SYMBOL(clk_put);
+#endif
 EXPORT_SYMBOL(clk_enable);
 EXPORT_SYMBOL(clk_disable);
 EXPORT_SYMBOL(clk_get_rate);
@@ -346,6 +356,7 @@ int s3c24xx_register_clock(struct clk *clk)
 	if (clk->enable == NULL)
 		clk->enable = clk_null_enable;
 
+#ifndef CONFIG_CLKDEV_LOOKUP
 	/* add to the list of available clocks */
 
 	/* Quick check to see if this clock has already been registered. */
@@ -354,6 +365,13 @@ int s3c24xx_register_clock(struct clk *clk)
 	spin_lock(&clocks_lock);
 	list_add(&clk->list, &clocks);
 	spin_unlock(&clocks_lock);
+#else
+	/* fill up the clk_lookup structure and register it*/
+	clk->lookup.dev_id = clk->devname;
+	clk->lookup.con_id = clk->name;
+	clk->lookup.clk = clk;
+	clkdev_add(&clk->lookup);
+#endif
 
 	return 0;
 }
arch/arm/plat-samsung/include/plat/clock.h +5 -0
index 9a82b88..5ef5ec1 100644
@@ -10,6 +10,7 @@
 */
 
 #include <linux/spinlock.h>
+#include <linux/clkdev.h>
 
 struct clk;
 
@@ -40,6 +41,7 @@ struct clk {
 	struct module        *owner;
 	struct clk           *parent;
 	const char           *name;
+	const char		*devname;
 	int		      id;
 	int		      usage;
 	unsigned long         rate;
@@ -47,6 +49,9 @@ struct clk {
 
 	struct clk_ops		*ops;
 	int		    (*enable)(struct clk *, int enable);
+#ifdef CONFIG_CLKDEV_LOOKUP
+	struct clk_lookup	lookup;
+#endif
 #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
 	struct dentry		*dent;	/* For visible tree hierarchy */
 #endif
Signature · 1 line
1.6.6.rc2
#4 lore raw

PATCH v2 4/5 ARM: SAMSUNG: Add clkdev support for exynos4

In reply to Thomas Abraham

Add clkdev support for Samsung's Exynos4 platforms.

---
 arch/arm/Kconfig                            |    1 +
 arch/arm/mach-exynos4/clock.c               |   57 +++++++++++++++++++++++++++
 arch/arm/mach-exynos4/include/mach/clkdev.h |    7 +++
 arch/arm/mach-exynos4/time.c                |    2 +
 arch/arm/plat-samsung/pwm-clock.c           |   10 +++++
 5 files changed, 77 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-exynos4/include/mach/clkdev.h
arch/arm/Kconfig +1 -0
index 93d595a..66f50f8 100644
@@ -779,6 +779,7 @@ config ARCH_EXYNOS4
 	select ARCH_SPARSEMEM_ENABLE
 	select GENERIC_GPIO
 	select HAVE_CLK
+	select CLKDEV_LOOKUP
 	select ARCH_HAS_CPUFREQ
 	select GENERIC_CLOCKEVENTS
 	select HAVE_S3C_RTC if RTC_CLASS
arch/arm/mach-exynos4/clock.c +57 -0

381 lines not on this page · raw message

arch/arm/mach-exynos4/include/mach/clkdev.h new file +7 -0
new file mode 100644
index 0000000..1247f5e
@@ -0,0 +1,7 @@
+#ifndef __MACH_EXYNOS4_CLKDEV_H__
+#define __MACH_EXYNOS4_CLKDEV_H__
+
+#define __clk_get(clk) ({ 1; })
+#define __clk_put(clk) do { } while (0)
+
+#endif
arch/arm/mach-exynos4/time.c +2 -0
index 86b9fa0..cb63f97 100644
@@ -262,6 +262,7 @@ static void __init exynos4_timer_resources(void)
 	clk_enable(timerclk);
 
 	tmpdev.id = 2;
+	tmpdev.dev.init_name = "s3c24xx-pwm.2";
 	tin2 = clk_get(&tmpdev.dev, "pwm-tin");
 	if (IS_ERR(tin2))
 		panic("failed to get pwm-tin2 clock for system timer");
@@ -272,6 +273,7 @@ static void __init exynos4_timer_resources(void)
 	clk_enable(tin2);
 
 	tmpdev.id = 4;
+	tmpdev.dev.init_name = "s3c24xx-pwm.4";
 	tin4 = clk_get(&tmpdev.dev, "pwm-tin");
 	if (IS_ERR(tin4))
 		panic("failed to get pwm-tin4 clock for system timer");
arch/arm/plat-samsung/pwm-clock.c +10 -0
index 46c9381..f1bba88 100644
@@ -268,6 +268,7 @@ static struct pwm_tdiv_clk clk_timer_tdiv[] = {
 	[0]	= {
 		.clk	= {
 			.name	= "pwm-tdiv",
+			.devname	= "s3c24xx-pwm.0",
 			.ops	= &clk_tdiv_ops,
 			.parent	= &clk_timer_scaler[0],
 		},
@@ -275,6 +276,7 @@ static struct pwm_tdiv_clk clk_timer_tdiv[] = {
 	[1]	= {
 		.clk	= {
 			.name	= "pwm-tdiv",
+			.devname	= "s3c24xx-pwm.1",
 			.ops	= &clk_tdiv_ops,
 			.parent	= &clk_timer_scaler[0],
 		}
@@ -282,6 +284,7 @@ static struct pwm_tdiv_clk clk_timer_tdiv[] = {
 	[2]	= {
 		.clk	= {
 			.name	= "pwm-tdiv",
+			.devname	= "s3c24xx-pwm.2",
 			.ops	= &clk_tdiv_ops,
 			.parent	= &clk_timer_scaler[1],
 		},
@@ -289,6 +292,7 @@ static struct pwm_tdiv_clk clk_timer_tdiv[] = {
 	[3]	= {
 		.clk	= {
 			.name	= "pwm-tdiv",
+			.devname	= "s3c24xx-pwm.3",
 			.ops	= &clk_tdiv_ops,
 			.parent	= &clk_timer_scaler[1],
 		},
@@ -296,6 +300,7 @@ static struct pwm_tdiv_clk clk_timer_tdiv[] = {
 	[4]	= {
 		.clk	= {
 			.name	= "pwm-tdiv",
+			.devname	= "s3c24xx-pwm.4",
 			.ops	= &clk_tdiv_ops,
 			.parent	= &clk_timer_scaler[1],
 		},
@@ -361,26 +366,31 @@ static struct clk_ops clk_tin_ops = {
 static struct clk clk_tin[] = {
 	[0]	= {
 		.name	= "pwm-tin",
+		.devname	= "s3c24xx-pwm.0",
 		.id	= 0,
 		.ops	= &clk_tin_ops,
 	},
 	[1]	= {
 		.name	= "pwm-tin",
+		.devname	= "s3c24xx-pwm.1",
 		.id	= 1,
 		.ops	= &clk_tin_ops,
 	},
 	[2]	= {
 		.name	= "pwm-tin",
+		.devname	= "s3c24xx-pwm.2",
 		.id	= 2,
 		.ops	= &clk_tin_ops,
 	},
 	[3]	= {
 		.name	= "pwm-tin",
+		.devname	= "s3c24xx-pwm.3",
 		.id	= 3,
 		.ops	= &clk_tin_ops,
 	},
 	[4]	= {
 		.name	= "pwm-tin",
+		.devname	= "s3c24xx-pwm.4",
 		.id	= 4,
 		.ops	= &clk_tin_ops,
 	},
Signature · 1 line
1.6.6.rc2
#5 lore raw

Re: [PATCH 4/5] ARM: SAMSUNG: Add clkdev support for exynos4

Hi,

Quoted 60 lines · Thomas Abraham

Add clkdev support for Samsung's Exynos4 platforms.

---
 arch/arm/Kconfig                            |    1 + arch/arm/mach-exynos4/clock.c               |   57 +++++++++++++++++++++++++++ arch/arm/mach-exynos4/include/mach/clkdev.h |    7 +++ arch/arm/mach-exynos4/time.c                |    2 + arch/arm/plat-samsung/pwm-clock.c           |   10 +++++

 5 files changed, 77 insertions(+), 0 deletions(-)

 create mode 100644 arch/arm/mach-exynos4/include/mach/clkdev.h

arch/arm/Kconfig +0 -0
index 93d595a..66f50f8 100644
@@ -779,6 +779,7 @@ config ARCH_EXYNOS4

       select ARCH_SPARSEMEM_ENABLE
       select GENERIC_GPIO
       select HAVE_CLK
+       select CLKDEV_LOOKUP
       select ARCH_HAS_CPUFREQ
       select GENERIC_CLOCKEVENTS
       select HAVE_S3C_RTC if RTC_CLASS

arch/arm/mach-exynos4/clock.c +5 -0
index 871f9d5..8e4dbf6 100644
@@ -404,41 +404,49 @@ static struct clk init_clocks_off[] = {
                .ctrlbit        = (1<<24),
        }, {
                .name           = "csis",
+               .devname        = "s5p-mipi-csis.0",
                .id             = 0,
                .enable         = exynos4_clk_ip_cam_ctrl,
                .ctrlbit        = (1 << 4),
        }, {
                .name           = "csis",
+               .devname        = "s5p-mipi-csis.1",
                .id             = 1,
                .enable         = exynos4_clk_ip_cam_ctrl,
                .ctrlbit        = (1 << 5),
        }, {
                .name           = "fimc",
+               .devname        = "exynos4-fimc.0",
                .id             = 0,
                .enable         = exynos4_clk_ip_cam_ctrl,
                .ctrlbit        = (1 << 0),
        }, {
                .name           = "fimc",
+               .devname        = "exynos4-fimc.1",
                .id             = 1,
                .enable         = exynos4_clk_ip_cam_ctrl,
                .ctrlbit        = (1 << 1),
        }, {
                .name           = "fimc",
+               .devname        = "exynos4-fimc.2",
                .id             = 2,
                .enable         = exynos4_clk_ip_cam_ctrl,

arch/arm/mach-exynos4/clock.c static struct clk init_clocks_off[] = { · line 443

Quoted 10 lines
arch/arm/mach-exynos4/clock.c +2 -0
                .ctrlbit        = (1 << 2),
        }, {
                .name           = "fimc",
+               .devname        = "exynos4-fimc.3",
                .id             = 3,
                .enable         = exynos4_clk_ip_cam_ctrl,
                .ctrlbit        = (1 << 3),
        }, {
                .name           = "fimd",
+               .devname        = "s5pv310-fb.0",

actually it doesn't yet determine which name is used at framebuffer, fimd or lcd.

Quoted 32 lines
arch/arm/mach-exynos4/clock.c +4 -0
                .id             = 0,
                .enable         = exynos4_clk_ip_lcd0_ctrl,
                .ctrlbit        = (1 << 0),
        }, {
                .name           = "fimd",
+               .devname        = "s5pv310-fb.1",
                .id             = 1,
                .enable         = exynos4_clk_ip_lcd1_ctrl,
                .ctrlbit        = (1 << 0),
@@ -450,30 +458,35 @@ static struct clk init_clocks_off[] = {
                .ctrlbit        = (1 << 3),
        }, {
                .name           = "hsmmc",
+               .devname        = "s3c-sdhci.0",
                .id             = 0,
                .parent         = &clk_aclk_133.clk,
                .enable         = exynos4_clk_ip_fsys_ctrl,
                .ctrlbit        = (1 << 5),
        }, {
                .name           = "hsmmc",
+               .devname        = "s3c-sdhci.1",
                .id             = 1,
                .parent         = &clk_aclk_133.clk,
                .enable         = exynos4_clk_ip_fsys_ctrl,
                .ctrlbit        = (1 << 6),
        }, {
                .name           = "hsmmc",
+               .devname        = "s3c-sdhci.2",
                .id             = 2,
                .parent         = &clk_aclk_133.clk,
                .enable         = exynos4_clk_ip_fsys_ctrl,
                .ctrlbit        = (1 << 7),

arch/arm/mach-exynos4/clock.c static struct clk init_clocks_off[] = { · line 489

Quoted 10 lines
arch/arm/mach-exynos4/clock.c +2 -0
        }, {
                .name           = "hsmmc",
+               .devname        = "s3c-sdhci.3",
                .id             = 3,
                .parent         = &clk_aclk_133.clk,
                .enable         = exynos4_clk_ip_fsys_ctrl,
                .ctrlbit        = (1 << 8),
        }, {
                .name           = "hsmmc",
+               .devname        = "s3c-sdhci.4",

exynos4 has different host controller at channel 4. designeware dw_mmc. so please check it.

Quoted 30 lines
arch/arm/mach-exynos4/clock.c +4 -0
                .id             = 4,
                .parent         = &clk_aclk_133.clk,
                .enable         = exynos4_clk_ip_fsys_ctrl,
@@ -486,11 +499,13 @@ static struct clk init_clocks_off[] = {
                .ctrlbit        = (1 << 10),
        }, {
                .name           = "pdma",
+               .devname        = "s3c-pl330.0",
                .id             = 0,
                .enable         = exynos4_clk_ip_fsys_ctrl,
                .ctrlbit        = (1 << 0),
        }, {
                .name           = "pdma",
+               .devname        = "s3c-pl330.1",
                .id             = 1,
                .enable         = exynos4_clk_ip_fsys_ctrl,
                .ctrlbit        = (1 << 1),
@@ -527,31 +542,37 @@ static struct clk init_clocks_off[] = {
                .ctrlbit        = (1 << 13),
        }, {
                .name           = "spi",
+               .devname        = "s3c64xx-spi.0",
                .id             = 0,
                .enable         = exynos4_clk_ip_peril_ctrl,
                .ctrlbit        = (1 << 16),
        }, {
                .name           = "spi",
+               .devname        = "s3c64xx-spi.1",
                .id             = 1,
                .enable         = exynos4_clk_ip_peril_ctrl,

arch/arm/mach-exynos4/clock.c static struct clk init_clocks_off[] = { · line 563

Quoted 10 lines
arch/arm/mach-exynos4/clock.c +2 -0
                .ctrlbit        = (1 << 17),
        }, {
                .name           = "spi",
+               .devname        = "s3c64xx-spi.2",
                .id             = 2,
                .enable         = exynos4_clk_ip_peril_ctrl,
                .ctrlbit        = (1 << 18),
        }, {
                .name           = "iis",
+               .devname        = "samsung-i2s.0",

does it still use the 'iis'?

Quoted 304 lines
arch/arm/mach-exynos4/clock.c +38 -0
                .id             = 0,
                .enable         = exynos4_clk_ip_peril_ctrl,
                .ctrlbit        = (1 << 19),
        }, {
                .name           = "iis",
+               .devname        = "samsung-i2s.1",
                .id             = 1,
                .enable         = exynos4_clk_ip_peril_ctrl,
                .ctrlbit        = (1 << 20),
        }, {
                .name           = "iis",
+               .devname        = "samsung-i2s.2",
                .id             = 2,
                .enable         = exynos4_clk_ip_peril_ctrl,
                .ctrlbit        = (1 << 21),
@@ -567,48 +588,56 @@ static struct clk init_clocks_off[] = {
                .ctrlbit        = (1 << 0),
        }, {
                .name           = "i2c",
+               .devname        = "s3c-i2c.0",
                .id             = 0,
                .parent         = &clk_aclk_100.clk,
                .enable         = exynos4_clk_ip_peril_ctrl,
                .ctrlbit        = (1 << 6),
        }, {
                .name           = "i2c",
+               .devname        = "s3c-i2c.1",
                .id             = 1,
                .parent         = &clk_aclk_100.clk,
                .enable         = exynos4_clk_ip_peril_ctrl,
                .ctrlbit        = (1 << 7),
        }, {
                .name           = "i2c",
+               .devname        = "s3c-i2c.2",
                .id             = 2,
                .parent         = &clk_aclk_100.clk,
                .enable         = exynos4_clk_ip_peril_ctrl,
                .ctrlbit        = (1 << 8),
        }, {
                .name           = "i2c",
+               .devname        = "s3c-i2c.3",
                .id             = 3,
                .parent         = &clk_aclk_100.clk,
                .enable         = exynos4_clk_ip_peril_ctrl,
                .ctrlbit        = (1 << 9),
        }, {
                .name           = "i2c",
+               .devname        = "s3c-i2c.4",
                .id             = 4,
                .parent         = &clk_aclk_100.clk,
                .enable         = exynos4_clk_ip_peril_ctrl,
                .ctrlbit        = (1 << 10),
        }, {
                .name           = "i2c",
+               .devname        = "s3c-i2c.5",
                .id             = 5,
                .parent         = &clk_aclk_100.clk,
                .enable         = exynos4_clk_ip_peril_ctrl,
                .ctrlbit        = (1 << 11),
        }, {
                .name           = "i2c",
+               .devname        = "s3c-i2c.6",
                .id             = 6,
                .parent         = &clk_aclk_100.clk,
                .enable         = exynos4_clk_ip_peril_ctrl,
                .ctrlbit        = (1 << 12),
        }, {
                .name           = "i2c",
+               .devname        = "s3c-i2c.7",
                .id             = 7,
                .parent         = &clk_aclk_100.clk,
                .enable         = exynos4_clk_ip_peril_ctrl,
@@ -689,31 +718,37 @@ static struct clk init_clocks_off[] = {
  static struct clk init_clocks[] = {
        {
                .name           = "uart",
+               .devname        = "s5pv210-uart.0",
                .id             = 0,
                .enable         = exynos4_clk_ip_peril_ctrl,
                .ctrlbit        = (1 << 0),
        }, {
                .name           = "uart",
+               .devname        = "s5pv210-uart.1",
                .id             = 1,
                .enable         = exynos4_clk_ip_peril_ctrl,
                .ctrlbit        = (1 << 1),
        }, {
                .name           = "uart",
+               .devname        = "s5pv210-uart.2",
                .id             = 2,
                .enable         = exynos4_clk_ip_peril_ctrl,
                .ctrlbit        = (1 << 2),
        }, {
                .name           = "uart",
+               .devname        = "s5pv210-uart.3",
                .id             = 3,
                .enable         = exynos4_clk_ip_peril_ctrl,
                .ctrlbit        = (1 << 3),
        }, {
                .name           = "uart",
+               .devname        = "s5pv210-uart.4",
                .id             = 4,
                .enable         = exynos4_clk_ip_peril_ctrl,
                .ctrlbit        = (1 << 4),
        }, {
                .name           = "uart",
+               .devname        = "s5pv210-uart.5",
                .id             = 5,
                .enable         = exynos4_clk_ip_peril_ctrl,
                .ctrlbit        = (1 << 5),
@@ -839,6 +874,7 @@ static struct clksrc_clk clksrcs[] = {
        {
                .clk    = {
                        .name           = "uclk1",
+                       .devname        = "s5pv210-uart.0",
                        .id             = 0,
                        .enable         = exynos4_clksrc_mask_peril0_ctrl,
                        .ctrlbit        = (1 << 0),
@@ -849,6 +885,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "uclk1",
+                       .devname        = "s5pv210-uart.1",
                        .id             = 1,
                        .enable         = exynos4_clksrc_mask_peril0_ctrl,
                        .ctrlbit        = (1 << 4),
@@ -859,6 +896,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "uclk1",
+                       .devname        = "s5pv210-uart.2",
                        .id             = 2,
                        .enable         = exynos4_clksrc_mask_peril0_ctrl,
                        .ctrlbit        = (1 << 8),
@@ -869,6 +907,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "uclk1",
+                       .devname        = "s5pv210-uart.3",
                        .id             = 3,
                        .enable         = exynos4_clksrc_mask_peril0_ctrl,
                        .ctrlbit        = (1 << 12),
@@ -889,6 +928,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "sclk_csis",
+                       .devname        = "s5p-mipi-csis.0",
                        .id             = 0,
                        .enable         = exynos4_clksrc_mask_cam_ctrl,
                        .ctrlbit        = (1 << 24),
@@ -899,6 +939,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "sclk_csis",
+                       .devname        = "s5p-mipi-csis.1",
                        .id             = 1,
                        .enable         = exynos4_clksrc_mask_cam_ctrl,
                        .ctrlbit        = (1 << 28),
@@ -909,6 +950,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "sclk_cam",
+                       .devname        = "exynos4-fimc.0",
                        .id             = 0,
                        .enable         = exynos4_clksrc_mask_cam_ctrl,
                        .ctrlbit        = (1 << 16),
@@ -919,6 +961,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "sclk_cam",
+                       .devname        = "exynos4-fimc.1",
                        .id             = 1,
                        .enable         = exynos4_clksrc_mask_cam_ctrl,
                        .ctrlbit        = (1 << 20),
@@ -929,6 +972,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "sclk_fimc",
+                       .devname        = "exynos4-fimc.0",
                        .id             = 0,
                        .enable         = exynos4_clksrc_mask_cam_ctrl,
                        .ctrlbit        = (1 << 0),
@@ -939,6 +983,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "sclk_fimc",
+                       .devname        = "exynos4-fimc.1",
                        .id             = 1,
                        .enable         = exynos4_clksrc_mask_cam_ctrl,
                        .ctrlbit        = (1 << 4),
@@ -949,6 +994,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "sclk_fimc",
+                       .devname        = "exynos4-fimc.2",
                        .id             = 2,
                        .enable         = exynos4_clksrc_mask_cam_ctrl,
                        .ctrlbit        = (1 << 8),
@@ -959,6 +1005,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "sclk_fimc",
+                       .devname        = "exynos4-fimc.3",
                        .id             = 3,
                        .enable         = exynos4_clksrc_mask_cam_ctrl,
                        .ctrlbit        = (1 << 12),
@@ -969,6 +1016,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "sclk_fimd",
+                       .devname        = "s5pv310-fb.0",
                        .id             = 0,
                        .enable         = exynos4_clksrc_mask_lcd0_ctrl,
                        .ctrlbit        = (1 << 0),
@@ -979,6 +1027,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "sclk_fimd",
+                       .devname        = "s5pv310-fb.1",
                        .id             = 1,
                        .enable         = exynos4_clksrc_mask_lcd1_ctrl,
                        .ctrlbit        = (1 << 0),
@@ -999,6 +1048,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "sclk_spi",
+                       .devname        = "s3c64xx-spi.0",
                        .id             = 0,
                        .enable         = exynos4_clksrc_mask_peril1_ctrl,
                        .ctrlbit        = (1 << 16),
@@ -1009,6 +1059,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "sclk_spi",
+                       .devname        = "s3c64xx-spi.1",
                        .id             = 1,
                        .enable         = exynos4_clksrc_mask_peril1_ctrl,
                        .ctrlbit        = (1 << 20),
@@ -1019,6 +1070,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "sclk_spi",
+                       .devname        = "s3c64xx-spi.2",
                        .id             = 2,
                        .enable         = exynos4_clksrc_mask_peril1_ctrl,
                        .ctrlbit        = (1 << 24),
@@ -1037,6 +1089,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "sclk_mmc",
+                       .devname        = "s3c-sdhci.0",
                        .id             = 0,
                        .parent         = &clk_dout_mmc0.clk,
                        .enable         = exynos4_clksrc_mask_fsys_ctrl,
@@ -1046,6 +1099,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "sclk_mmc",
+                       .devname        = "s3c-sdhci.1",
                        .id             = 1,
                        .parent         = &clk_dout_mmc1.clk,
                        .enable         = exynos4_clksrc_mask_fsys_ctrl,
@@ -1055,6 +1109,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "sclk_mmc",
+                       .devname        = "s3c-sdhci.2",
                        .id             = 2,
                        .parent         = &clk_dout_mmc2.clk,
                        .enable         = exynos4_clksrc_mask_fsys_ctrl,
@@ -1064,6 +1119,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "sclk_mmc",
+                       .devname        = "s3c-sdhci.3",
                        .id             = 3,
                        .parent         = &clk_dout_mmc3.clk,
                        .enable         = exynos4_clksrc_mask_fsys_ctrl,
@@ -1073,6 +1129,7 @@ static struct clksrc_clk clksrcs[] = {
        }, {
                .clk            = {
                        .name           = "sclk_mmc",
+                       .devname        = "s3c-sdhci.4",
                        .id             = 4,
                        .parent         = &clk_dout_mmc4.clk,
                        .enable         = exynos4_clksrc_mask_fsys_ctrl,
arch/arm/mach-exynos4/include/mach/clkdev.h new file +7 -0
new file mode 100644
index 0000000..1247f5e
@@ -0,0 +1,7 @@
+#ifndef __MACH_EXYNOS4_CLKDEV_H__
+#define __MACH_EXYNOS4_CLKDEV_H__
+
+#define __clk_get(clk) ({ 1; })
+#define __clk_put(clk) do { } while (0)
+
+#endif
arch/arm/mach-exynos4/time.c +0 -0
index 86b9fa0..cb63f97 100644

arch/arm/mach-exynos4/time.c static void __init exynos4_timer_resources(void) · line 265

Quoted 4 lines
arch/arm/mach-exynos4/time.c +1 -0
@@ -262,6 +262,7 @@ static void __init exynos4_timer_resources(void)
        clk_enable(timerclk);
 
        tmpdev.id = 2;
+       tmpdev.dev.init_name = "s3c24xx-pwm.2";

what's this? why does it need at here?

Thank you,
Kyungmin Park

Quoted 95 lines
arch/arm/mach-exynos4/time.c +1 -0
        tin2 = clk_get(&tmpdev.dev, "pwm-tin");
        if (IS_ERR(tin2))
                panic("failed to get pwm-tin2 clock for system timer");
@@ -272,6 +273,7 @@ static void __init exynos4_timer_resources(void)
        clk_enable(tin2);
 
        tmpdev.id = 4;
+       tmpdev.dev.init_name = "s3c24xx-pwm.4";
        tin4 = clk_get(&tmpdev.dev, "pwm-tin");
        if (IS_ERR(tin4))
                panic("failed to get pwm-tin4 clock for system timer");
arch/arm/plat-samsung/pwm-clock.c +10 -1
index 46c9381..f1bba88 100644
@@ -268,6 +268,7 @@ static struct pwm_tdiv_clk clk_timer_tdiv[] = {
        [0]     = {
                .clk    = {
                        .name   = "pwm-tdiv",
+                       .devname        = "s3c24xx-pwm.0",
                        .ops    = &clk_tdiv_ops,
                        .parent = &clk_timer_scaler[0],
                },
@@ -275,6 +276,7 @@ static struct pwm_tdiv_clk clk_timer_tdiv[] = {
        [1]     = {
                .clk    = {
                        .name   = "pwm-tdiv",
+                       .devname        = "s3c24xx-pwm.1",
                        .ops    = &clk_tdiv_ops,
                        .parent = &clk_timer_scaler[0],
                }
@@ -282,6 +284,7 @@ static struct pwm_tdiv_clk clk_timer_tdiv[] = {
        [2]     = {
                .clk    = {
                        .name   = "pwm-tdiv",
+                       .devname        = "s3c24xx-pwm.2",
                        .ops    = &clk_tdiv_ops,
                        .parent = &clk_timer_scaler[1],
                },
@@ -289,6 +292,7 @@ static struct pwm_tdiv_clk clk_timer_tdiv[] = {
        [3]     = {
                .clk    = {
                        .name   = "pwm-tdiv",
+                       .devname        = "s3c24xx-pwm.3",
                        .ops    = &clk_tdiv_ops,
                        .parent = &clk_timer_scaler[1],
                },
@@ -296,6 +300,7 @@ static struct pwm_tdiv_clk clk_timer_tdiv[] = {
        [4]     = {
                .clk    = {
                        .name   = "pwm-tdiv",
+                       .devname        = "s3c24xx-pwm.4",
                        .ops    = &clk_tdiv_ops,
                        .parent = &clk_timer_scaler[1],
                },
@@ -361,26 +366,31 @@ static struct clk_ops clk_tin_ops = {
  static struct clk clk_tin[] = {
        [0]     = {
                .name   = "pwm-tin",
+               .devname        = "s3c24xx-pwm.0",
                .id     = 0,
                .ops    = &clk_tin_ops,
        },
        [1]     = {
                .name   = "pwm-tin",
+               .devname        = "s3c24xx-pwm.1",
                .id     = 1,
                .ops    = &clk_tin_ops,
        },
        [2]     = {
                .name   = "pwm-tin",
+               .devname        = "s3c24xx-pwm.2",
                .id     = 2,
                .ops    = &clk_tin_ops,
        },
        [3]     = {
                .name   = "pwm-tin",
+               .devname        = "s3c24xx-pwm.3",
                .id     = 3,
                .ops    = &clk_tin_ops,
        },
        [4]     = {
                .name   = "pwm-tin",
+               .devname        = "s3c24xx-pwm.4",
                .id     = 4,
                .ops    = &clk_tin_ops,
        },
--

1.6.6.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

#6 lore raw

Re: [PATCH 4/5] ARM: SAMSUNG: Add clkdev support for exynos4

Hi Mr. Kyungmin Park,

Quoted 40 lines · Kyungmin Park

Hi,

Quoted 37 lines · Thomas Abraham

Add clkdev support for Samsung's Exynos4 platforms.

---
 arch/arm/Kconfig                            |    1 +
 arch/arm/mach-exynos4/clock.c               |   57 +++++++++++++++++++++++++++
 arch/arm/mach-exynos4/include/mach/clkdev.h |    7 +++
 arch/arm/mach-exynos4/time.c                |    2 +
 arch/arm/plat-samsung/pwm-clock.c           |   10 +++++
 5 files changed, 77 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-exynos4/include/mach/clkdev.h
arch/arm/Kconfig +1 -0
index 93d595a..66f50f8 100644
@@ -779,6 +779,7 @@ config ARCH_EXYNOS4
       select ARCH_SPARSEMEM_ENABLE
       select GENERIC_GPIO
       select HAVE_CLK
+       select CLKDEV_LOOKUP
       select ARCH_HAS_CPUFREQ
       select GENERIC_CLOCKEVENTS
       select HAVE_S3C_RTC if RTC_CLASS
arch/arm/mach-exynos4/clock.c +1 -0
index 871f9d5..8e4dbf6 100644
@@ -404,41 +404,49 @@ static struct clk init_clocks_off[] = {
               .ctrlbit        = (1<<24),
       }, {
               .name           = "csis",
+               .devname        = "s5p-mipi-csis.0",
               .id             = 0,
               .enable         = exynos4_clk_ip_cam_ctrl,
               .ctrlbit        = (1 << 4),

[...]

Quoted 10 lines

arch/arm/mach-exynos4/clock.c static struct clk init_clocks_off[] = { · line 443

Quoted 9 lines

}, {
.name = "fimc",

arch/arm/mach-exynos4/clock.c +2 -0
+               .devname        = "exynos4-fimc.3",
               .id             = 3,
               .enable         = exynos4_clk_ip_cam_ctrl,
               .ctrlbit        = (1 << 3),
       }, {
               .name           = "fimd",
+               .devname        = "s5pv310-fb.0",
Quoted 2 lines

actually it doesn't yet determine which name is used at framebuffer, fimd or lcd.

The fb driver (drivers/video/s3c-fb.c) is using 'lcd' as the name of the clock. So the name of the clock above 'fimd' will have to be changed to 'lcd'. If a patch for that change is not already submitted, I will submit a separate patch for that.

Quoted 5 lines
Quoted 5 lines
               .id             = 0,
               .enable         = exynos4_clk_ip_lcd0_ctrl,
               .ctrlbit        = (1 << 0),
       }, {

[...]

Quoted 4 lines
Quoted 2 lines

.name = "hsmmc",
+ .devname = "s3c-sdhci.4",

exynos4 has different host controller at channel 4. designeware dw_mmc. so please check it.

Thanks for pointing this out. The clock name will change for this (need to still find a name). Since, this will be the only instance of clock (.id = -1), the devname can be avoided. In the next revision of this patch, I will remove the devname addition for this clock.

Quoted 12 lines
Quoted 12 lines
               .id             = 4,
               .parent         = &clk_aclk_133.clk,
               .enable         = exynos4_clk_ip_fsys_ctrl,
arch/arm/mach-exynos4/clock.c +1 -0
@@ -486,11 +499,13 @@ static struct clk init_clocks_off[] = {
               .ctrlbit        = (1 << 10),
       }, {
               .name           = "pdma",
+               .devname        = "s3c-pl330.0",
               .id             = 0,
               .enable         = exynos4_clk_ip_fsys_ctrl,
               .ctrlbit        = (1 << 0),

[...]

Quoted 4 lines
Quoted 3 lines

}, {
.name = "iis",
+ .devname = "samsung-i2s.0",

does it still use the 'iis'?

The i2c driver uses the clock name as iis. So no change here.

Quoted 5 lines
Quoted 5 lines
               .id             = 0,
               .enable         = exynos4_clk_ip_peril_ctrl,
               .ctrlbit        = (1 << 19),

}, {
.name = "iis",

[...]

Quoted 20 lines
Quoted 20 lines
arch/arm/mach-exynos4/include/mach/clkdev.h new file +7 -0
new file mode 100644
index 0000000..1247f5e
@@ -0,0 +1,7 @@
+#ifndef __MACH_EXYNOS4_CLKDEV_H__
+#define __MACH_EXYNOS4_CLKDEV_H__
+
+#define __clk_get(clk) ({ 1; })
+#define __clk_put(clk) do { } while (0)
+
+#endif
arch/arm/mach-exynos4/time.c +0 -0
index 86b9fa0..cb63f97 100644
@@ -262,6 +262,7 @@ static void __init exynos4_timer_resources(void)
       clk_enable(timerclk);
 
Quoted 4 lines

arch/arm/mach-exynos4/time.c static void __init exynos4_timer_resources(void) · line 265

Quoted 2 lines
arch/arm/mach-exynos4/time.c +1 -0
       tmpdev.id = 2;
+       tmpdev.dev.init_name = "s3c24xx-pwm.2";

what's this? why does it need at here?

platform_device instances are not registered for PWM timer's that are used to generate the clock ticks. A un-registered version of platform_device (tmpdev above) is used to lookup the clocks in this case. Since this platform_device is unregistered and clk_get (when using clkdev lookup) requires a devname, a temporary device name can be assigned to the platform_device (refer to dev_name function in include/linux/device.h file).

Thanks for your comments.

Regards,
Thomas.

#7 lore raw

PATCH v2 5/5 serial: samsung: Keep a copy a pdev->dev.platform_data and use it

In reply to Thomas Abraham

The driver depends on pdev->dev.platform_data to retrive information about the platform data even after the initialization. To add device tree support, this has to be changed in way that the platform data is avialable from driver's private data. This patch adds support for keeping a copy of the plaform data in s3c24xx_uart_info and using it when needed after the initialization.

---
 drivers/tty/serial/s5pv210.c |   12 ++++++++++--
 drivers/tty/serial/samsung.c |   26 ++++++++++++++++++++------
 drivers/tty/serial/samsung.h |    3 +++
 3 files changed, 33 insertions(+), 8 deletions(-)
drivers/tty/serial/s5pv210.c +10 -2
index cdee626..5010c8e 100644
@@ -28,9 +28,13 @@
 static int s5pv210_serial_setsource(struct uart_port *port,
 					struct s3c24xx_uart_clksrc *clk)
 {
-	struct s3c2410_uartcfg *cfg = port->dev->platform_data;
+	struct s3c24xx_uart_port *ourport;
+	struct s3c2410_uartcfg *cfg;
 	unsigned long ucon = rd_regl(port, S3C2410_UCON);
 
+	ourport = container_of(port, struct s3c24xx_uart_port, port);
+	cfg = &ourport->info->cfg;
+
 	if ((cfg->clocks_size) == 1)
 		return 0;
 
@@ -51,9 +55,13 @@ static int s5pv210_serial_setsource(struct uart_port *port,
 static int s5pv210_serial_getsource(struct uart_port *port,
 					struct s3c24xx_uart_clksrc *clk)
 {
-	struct s3c2410_uartcfg *cfg = port->dev->platform_data;
+	struct s3c24xx_uart_port *ourport;
+	struct s3c2410_uartcfg *cfg;
 	u32 ucon = rd_regl(port, S3C2410_UCON);
 
+	ourport = container_of(port, struct s3c24xx_uart_port, port);
+	cfg = &ourport->info->cfg;
+
 	clk->divisor = 1;
 
 	if ((cfg->clocks_size) == 1)
drivers/tty/serial/samsung.c +20 -6
index 9d9d97c..aee4ec9 100644
@@ -43,6 +43,7 @@
 #include <linux/delay.h>
 #include <linux/clk.h>
 #include <linux/cpufreq.h>
+#include <linux/slab.h>
 
 #include <asm/irq.h>
 
@@ -170,10 +171,13 @@ static inline struct s3c24xx_uart_info *s3c24xx_port_to_info(struct uart_port *p
 
 static inline struct s3c2410_uartcfg *s3c24xx_port_to_cfg(struct uart_port *port)
 {
+	struct s3c24xx_uart_port *ourport;
+
 	if (port->dev == NULL)
 		return NULL;
 
-	return (struct s3c2410_uartcfg *)port->dev->platform_data;
+	ourport = container_of(port, struct s3c24xx_uart_port, port);
+	return &ourport->info->cfg;
 }
 
 static int s3c24xx_serial_rx_fifocnt(struct s3c24xx_uart_port *ourport,
@@ -1054,7 +1058,7 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
 				    struct platform_device *platdev)
 {
 	struct uart_port *port = &ourport->port;
-	struct s3c2410_uartcfg *cfg;
+	struct s3c2410_uartcfg *cfg = platdev->dev.platform_data;
 	struct resource *res;
 	int ret;
 
@@ -1063,7 +1067,9 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
 	if (platdev == NULL)
 		return -ENODEV;
 
-	cfg = s3c24xx_dev_to_cfg(&platdev->dev);
+	/* setup info for port */
+	port->dev	= &platdev->dev;
+	ourport->info	= info;
 
 	if (port->mapbase != 0)
 		return 0;
@@ -1074,9 +1080,17 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
 		return -ERANGE;
 	}
 
-	/* setup info for port */
-	port->dev	= &platdev->dev;
-	ourport->info	= info;
+	memcpy((void *)&info->cfg, cfg, sizeof(struct s3c2410_uartcfg));
+
+	info->cfg.clocks = kzalloc(sizeof(struct s3c24xx_uart_clksrc) *
+				info->cfg.clocks_size, GFP_KERNEL);
+	if (!info->cfg.clocks)
+		return -ENOMEM;
+
+	memcpy(info->cfg.clocks, cfg->clocks, sizeof(struct s3c24xx_uart_clksrc)
+		* ourport->info->cfg.clocks_size);
+
+	cfg = &ourport->info->cfg;
 
 	/* copy the info in from provided structure */
 	ourport->port.fifosize = info->fifosize;
drivers/tty/serial/samsung.h +3 -0
index 0ac06a0..48a24d1 100644
@@ -25,6 +25,9 @@ struct s3c24xx_uart_info {
 
 	unsigned int		has_divslot:1;
 
+	/* Copy of platform data */
+	struct s3c2410_uartcfg	cfg;
+
 	/* clock source control */
 
 	int (*get_clksrc)(struct uart_port *, struct s3c24xx_uart_clksrc *clk);
Signature · 1 line
1.6.6.rc2