Skip to contentSkip to conversation

Introducing Exynos ChipId driver

PATCH In review [email protected] 6 participants 31 messages May 10, 2014 – Jun 17, 2014

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

v3 cover Introducing Exynos ChipId driver

From: Pankaj Dubey <[email protected]>

This patch series attempts to get rid of soc_is_exynosXXXX macros and eventually with the help of this series we can probably get rid of CONFIG_SOC_EXYNOSXXXX in near future.
Each Exynos SoC has ChipID block which can give information about SoC's product Id and revision number. Currently we have single DT binding information for this as "samsung,exynos4210-chipid". But Exynos4 and Exynos5 SoC series have one small difference in chip Id, with resepect to product id bit-masks. So it means we should have separate compatible string for these different series of SoCs. So I have added second compatible string for handling this difference.
This patch series is based on Kukjin Kim's for-next (3.14_rc1 tag) and prepared on top of following patch series and it's dependent patch series.

[1]: Map SYSRAM through generic SRAM bindings by Sachin Kamat.

	http://www.spinics.net/lists/arm-kernel/msg327677.html
[2]: Exynos PMU cleanup and refactoring.
	https://lkml.org/lkml/2014/4/30/44
[3]: Introduce drivers/soc and add QCOM GSBI driver.
	https://lkml.org/lkml/2014/4/24/520

Revision 2 and it's discussion can be found here
- https://lkml.org/lkml/2014/5/6/100

Changes since v2:
- Reorganized patches as suggested by Tomasz Figa.
- Addressed review comments of Tomasz Figa in i2c-s3c2410.c file.

Changes since v1:
- Added patch to move i2c interrupt re-configuration code from exynos.c to i2c driver, as suggested by Arnd.
- After above patch only user of SYS_I2C_CFG register is pm.c so moving save/restore of this register also into i2c driver.
- Spiltted up exynos4 and exynos5 machine descriptors to get rid from soc_is_exynos4/exynos5 kind of macros, as suggested by Arnd.
- Changed location of chipid driver to "drivers/soc".
- Added drivers/base/soc.c provided infrastructure to make SoC specific information avaible to user space via sysfs entry, as suggested by Arnd.

Pankaj Dubey (6):
i2c: s3c2410: Handle i2c sys_cfg register in i2c driver
ARM: EXYNOS: Remove i2c sys configuration related code
ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c
ARM: EXYNOS: Remove unused header inclusion from hotplug.c
soc: samsung: exynos-chipid: Add Exynos Chipid driver support
ARM: EXYNOS: Refactoring to remove soc_is_exynos macros from exynos

 .../bindings/arm/samsung/exynos-chipid.txt         |   21 +++
 .../devicetree/bindings/arm/samsung/sysreg.txt     |    1 +
 arch/arm/Kconfig                                   |    1 +
 arch/arm/boot/dts/exynos4.dtsi                     |    2 +-
 arch/arm/boot/dts/exynos5.dtsi                     |    7 +-
 arch/arm/boot/dts/exynos5250.dtsi                  |    4 +
 arch/arm/boot/dts/exynos5420.dtsi                  |    4 +
 arch/arm/mach-exynos/exynos.c                      |  119 ++++----------
 arch/arm/mach-exynos/hotplug.c                     |    2 -
 arch/arm/mach-exynos/include/mach/map.h            |    3 -
 arch/arm/mach-exynos/platsmp.c                     |   11 +-
 arch/arm/mach-exynos/pm.c                          |   36 ++---
 arch/arm/mach-exynos/regs-sys.h                    |   22 ---
 arch/arm/plat-samsung/include/plat/cpu.h           |   60 -------
 drivers/clk/samsung/clk-exynos4.c                  |    2 +-
 drivers/cpufreq/exynos-cpufreq.c                   |    9 +-
 drivers/cpufreq/exynos-cpufreq.h                   |    1 -
 drivers/cpufreq/exynos4x12-cpufreq.c               |    5 +-
 drivers/i2c/busses/i2c-s3c2410.c                   |   32 ++++
 drivers/soc/Kconfig                                |    1 +
 drivers/soc/Makefile                               |    1 +
 drivers/soc/samsung/Kconfig                        |   10 ++
 drivers/soc/samsung/Makefile                       |    1 +
 drivers/soc/samsung/exynos-chipid.c                |  166 ++++++++++++++++++++
 include/linux/exynos-soc.h                         |   46 ++++++
 25 files changed, 357 insertions(+), 210 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt
 delete mode 100644 arch/arm/mach-exynos/regs-sys.h
 create mode 100644 drivers/soc/samsung/Kconfig
 create mode 100644 drivers/soc/samsung/Makefile
 create mode 100644 drivers/soc/samsung/exynos-chipid.c
 create mode 100644 include/linux/exynos-soc.h
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v3 1/6 i2c: s3c2410: Handle i2c sys_cfg register in i2c driver

From: Pankaj Dubey <[email protected]>

Let's handle i2c interrupt re-configuration in i2c driver. This will help us in removing some soc specific checks from machine files. Since only Exynos5250, and Exynos5420 need to do this, added syscon based phandle to i2c device nodes of respective SoC DT files. Also handle saving and restoring of SYS_I2C_CFG register during suspend and resume of i2c driver. This will help in removing soc specific check from mach-exynos/pm.c.

---
 .../devicetree/bindings/arm/samsung/sysreg.txt     |    1 +
 arch/arm/boot/dts/exynos5.dtsi                     |    5 +++
 arch/arm/boot/dts/exynos5250.dtsi                  |    4 +++
 arch/arm/boot/dts/exynos5420.dtsi                  |    4 +++
 drivers/i2c/busses/i2c-s3c2410.c                   |   32 ++++++++++++++++++++
 5 files changed, 46 insertions(+)
Documentation/devicetree/bindings/arm/samsung/sysreg.txt +1 -0
index 0ab3251..fd71581 100644
@@ -3,6 +3,7 @@ SAMSUNG S5P/Exynos SoC series System Registers (SYSREG)
 Properties:
  - compatible : should contain "samsung,<chip name>-sysreg", "syscon";
    For Exynos4 SoC series it should be "samsung,exynos4-sysreg", "syscon";
+   For Exynos5 SoC series it should be "samsung,exynos5-sysreg", "syscon";
  - reg : offset and length of the register set.
 
 Example:
arch/arm/boot/dts/exynos5.dtsi +5 -0
index 79d0608..3027e37 100644
@@ -99,4 +99,9 @@
 		#size-cells = <0>;
 		status = "disabled";
 	};
+
+	sys_reg: syscon@10050000 {
+		compatible = "samsung,exynos5-sysreg", "syscon";
+		reg = <0x10050000 0x400>;
+	};
 };
arch/arm/boot/dts/exynos5250.dtsi +4 -0
index 8d724d5..46f0233 100644
@@ -285,6 +285,7 @@
 		clock-names = "i2c";
 		pinctrl-names = "default";
 		pinctrl-0 = <&i2c0_bus>;
+		samsung,syscon-phandle = <&sys_reg>;
 		status = "disabled";
 	};
 
@@ -298,6 +299,7 @@
 		clock-names = "i2c";
 		pinctrl-names = "default";
 		pinctrl-0 = <&i2c1_bus>;
+		samsung,syscon-phandle = <&sys_reg>;
 		status = "disabled";
 	};
 
@@ -311,6 +313,7 @@
 		clock-names = "i2c";
 		pinctrl-names = "default";
 		pinctrl-0 = <&i2c2_bus>;
+		samsung,syscon-phandle = <&sys_reg>;
 		status = "disabled";
 	};
 
@@ -324,6 +327,7 @@
 		clock-names = "i2c";
 		pinctrl-names = "default";
 		pinctrl-0 = <&i2c3_bus>;
+		samsung,syscon-phandle = <&sys_reg>;
 		status = "disabled";
 	};
 
arch/arm/boot/dts/exynos5420.dtsi +4 -0
index ff496ad..762128c 100644
@@ -517,6 +517,7 @@
 		clock-names = "i2c";
 		pinctrl-names = "default";
 		pinctrl-0 = <&i2c0_bus>;
+		samsung,syscon-phandle = <&sys_reg>;
 		status = "disabled";
 	};
 
@@ -530,6 +531,7 @@
 		clock-names = "i2c";
 		pinctrl-names = "default";
 		pinctrl-0 = <&i2c1_bus>;
+		samsung,syscon-phandle = <&sys_reg>;
 		status = "disabled";
 	};
 
@@ -543,6 +545,7 @@
 		clock-names = "i2c";
 		pinctrl-names = "default";
 		pinctrl-0 = <&i2c2_bus>;
+		samsung,syscon-phandle = <&sys_reg>;
 		status = "disabled";
 	};
 
@@ -556,6 +559,7 @@
 		clock-names = "i2c";
 		pinctrl-names = "default";
 		pinctrl-0 = <&i2c3_bus>;
+		samsung,syscon-phandle = <&sys_reg>;
 		status = "disabled";
 	};
 
drivers/i2c/busses/i2c-s3c2410.c +32 -0
index ae44910..e707062 100644
@@ -39,6 +39,8 @@
 #include <linux/of.h>
 #include <linux/of_gpio.h>
 #include <linux/pinctrl/consumer.h>
+#include <linux/mfd/syscon.h>
+#include <linux/regmap.h>
 
 #include <asm/irq.h>
 
@@ -91,6 +93,9 @@
 /* Max time to wait for bus to become idle after a xfer (in us) */
 #define S3C2410_IDLE_TIMEOUT	5000
 
+/* Exynos5 Sysreg offset */
+#define EXYNOS5_SYS_I2C_CFG	0x0234
+
 /* i2c controller state */
 enum s3c24xx_i2c_state {
 	STATE_IDLE,
@@ -127,6 +132,8 @@ struct s3c24xx_i2c {
 #if defined(CONFIG_ARM_S3C24XX_CPUFREQ)
 	struct notifier_block	freq_transition;
 #endif
+	struct regmap		*sysreg;
+	unsigned int		sys_i2s_cfg;
 };
 
 static struct platform_device_id s3c24xx_driver_ids[] = {
@@ -1075,6 +1082,8 @@ static void
 s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c)
 {
 	struct s3c2410_platform_i2c *pdata = i2c->pdata;
+	u32 val = 0;
+	int id;
 
 	if (!np)
 		return;
@@ -1084,6 +1093,23 @@ s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c)
 	of_property_read_u32(np, "samsung,i2c-slave-addr", &pdata->slave_addr);
 	of_property_read_u32(np, "samsung,i2c-max-bus-freq",
 				(u32 *)&pdata->frequency);
+	/*
+	 * Exynos5's legacy i2c controller and new high speed i2c
+	 * controller have muxed interrupt sources. By default the
+	 * interrupts for 4-channel HS-I2C controller are enabled.
+	 * If node for first four channels of legacy i2c controller
+	 * are available then re-configure the interrupts via the
+	 * system register.
+	 */
+	id = of_alias_get_id(np, "i2c");
+	i2c->sysreg = syscon_regmap_lookup_by_phandle(np,
+			"samsung,syscon-phandle");
+	if (IS_ERR(i2c->sysreg)) {
+		/* As this is not compulsory do not return error */
+		pr_info("i2c-%d skipping re-configuration of interrutps\n", id);
+		return;
+	}
+	regmap_update_bits(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, BIT(id), val);
 }
 #else
 static void
@@ -1268,6 +1294,9 @@ static int s3c24xx_i2c_suspend_noirq(struct device *dev)
 
 	i2c->suspended = 1;
 
+	if (!IS_ERR(i2c->sysreg))
+		regmap_read(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, &i2c->sys_i2s_cfg);
+
 	return 0;
 }
 
@@ -1276,6 +1305,9 @@ static int s3c24xx_i2c_resume(struct device *dev)
 	struct platform_device *pdev = to_platform_device(dev);
 	struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
 
+	if (!IS_ERR(i2c->sysreg))
+		regmap_write(i2c->sysreg, i2c->sys_i2s_cfg, EXYNOS5_SYS_I2C_CFG);
+
 	i2c->suspended = 0;
 	clk_prepare_enable(i2c->clk);
 	s3c24xx_i2c_init(i2c);
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH v3 2/6 ARM: EXYNOS: Remove i2c sys configuration related code

In reply to [email protected]

From: Pankaj Dubey <[email protected]>

Since all these code has been moved into i2c driver, now we can safely remove them from machine files.

---
 arch/arm/mach-exynos/exynos.c           |   38 +------------------------------
 arch/arm/mach-exynos/include/mach/map.h |    3 ---
 arch/arm/mach-exynos/pm.c               |   10 --------
 arch/arm/mach-exynos/regs-sys.h         |   22 ------------------
 4 files changed, 1 insertion(+), 72 deletions(-)
 delete mode 100644 arch/arm/mach-exynos/regs-sys.h
arch/arm/mach-exynos/exynos.c +1 -37
index 59eb1f1..09063ee 100644
@@ -29,11 +29,11 @@
 #include <asm/memory.h>
 
 #include <plat/cpu.h>
+#include <mach/map.h>
 
 #include "common.h"
 #include "mfc.h"
 #include "regs-pmu.h"
-#include "regs-sys.h"
 
 #define L2_AUX_VAL 0x7C470001
 #define L2_AUX_MASK 0xC200ffff
@@ -42,11 +42,6 @@ static struct regmap *exynos_pmu_regmap;
 
 static struct map_desc exynos4_iodesc[] __initdata = {
 	{
-		.virtual	= (unsigned long)S3C_VA_SYS,
-		.pfn		= __phys_to_pfn(EXYNOS4_PA_SYSCON),
-		.length		= SZ_64K,
-		.type		= MT_DEVICE,
-	}, {
 		.virtual	= (unsigned long)S3C_VA_TIMER,
 		.pfn		= __phys_to_pfn(EXYNOS4_PA_TIMER),
 		.length		= SZ_16K,
@@ -116,11 +111,6 @@ static struct map_desc exynos4_iodesc[] __initdata = {
 
 static struct map_desc exynos5_iodesc[] __initdata = {
 	{
-		.virtual	= (unsigned long)S3C_VA_SYS,
-		.pfn		= __phys_to_pfn(EXYNOS5_PA_SYSCON),
-		.length		= SZ_64K,
-		.type		= MT_DEVICE,
-	}, {
 		.virtual	= (unsigned long)S3C_VA_TIMER,
 		.pfn		= __phys_to_pfn(EXYNOS5_PA_TIMER),
 		.length		= SZ_16K,
@@ -293,32 +283,6 @@ void __init exynos_map_pmu(void)
 
 static void __init exynos_dt_machine_init(void)
 {
-	struct device_node *i2c_np;
-	const char *i2c_compat = "samsung,s3c2440-i2c";
-	unsigned int tmp;
-	int id;
-
-	/*
-	 * Exynos5's legacy i2c controller and new high speed i2c
-	 * controller have muxed interrupt sources. By default the
-	 * interrupts for 4-channel HS-I2C controller are enabled.
-	 * If node for first four channels of legacy i2c controller
-	 * are available then re-configure the interrupts via the
-	 * system register.
-	 */
-	if (soc_is_exynos5()) {
-		for_each_compatible_node(i2c_np, NULL, i2c_compat) {
-			if (of_device_is_available(i2c_np)) {
-				id = of_alias_get_id(i2c_np, "i2c");
-				if (id < 4) {
-					tmp = readl(EXYNOS5_SYS_I2C_CFG);
-					writel(tmp & ~(0x1 << id),
-							EXYNOS5_SYS_I2C_CFG);
-				}
-			}
-		}
-	}
-
 	exynos_map_pmu();
 
 	if (!soc_is_exynos5440())
arch/arm/mach-exynos/include/mach/map.h +0 -3
index 34eee6e..bd4a320 100644
@@ -25,9 +25,6 @@
 
 #define EXYNOS_PA_CHIPID		0x10000000
 
-#define EXYNOS4_PA_SYSCON		0x10010000
-#define EXYNOS5_PA_SYSCON		0x10050100
-
 #define EXYNOS4_PA_CMU			0x10030000
 #define EXYNOS5_PA_CMU			0x10010000
 
arch/arm/mach-exynos/pm.c +0 -10
index a7a1b7f..59e5604 100644
@@ -37,7 +37,6 @@
 
 #include "common.h"
 #include "regs-pmu.h"
-#include "regs-sys.h"
 #include "exynos-pmu.h"
 
 static struct regmap *pmu_regmap;
@@ -52,10 +51,6 @@ struct exynos_wkup_irq {
 	u32 mask;
 };
 
-static struct sleep_save exynos5_sys_save[] = {
-	SAVE_ITEM(EXYNOS5_SYS_I2C_CFG),
-};
-
 static struct sleep_save exynos_core_save[] = {
 	/* SROM side */
 	SAVE_ITEM(S5P_SROM_BW),
@@ -211,7 +206,6 @@ static void exynos_pm_prepare(void)
 	s3c_pm_do_save(exynos_core_save, ARRAY_SIZE(exynos_core_save));
 
 	if (soc_is_exynos5250()) {
-		s3c_pm_do_save(exynos5_sys_save, ARRAY_SIZE(exynos5_sys_save));
 		/* Disable USE_RETENTION of JPEG_MEM_OPTION */
 		regmap_read(pmu_regmap, EXYNOS5_JPEG_MEM_OPTION, &tmp);
 		tmp &= ~EXYNOS5_OPTION_USE_RETENTION;
@@ -296,10 +290,6 @@ static void exynos_pm_resume(void)
 	regmap_write(pmu_regmap, S5P_PAD_RET_EBIA_OPTION, (1 << 28));
 	regmap_write(pmu_regmap, S5P_PAD_RET_EBIB_OPTION, (1 << 28));
 
-	if (soc_is_exynos5250())
-		s3c_pm_do_restore(exynos5_sys_save,
-			ARRAY_SIZE(exynos5_sys_save));
-
 	s3c_pm_do_restore_core(exynos_core_save, ARRAY_SIZE(exynos_core_save));
 
 	if (!soc_is_exynos5250())
arch/arm/mach-exynos/regs-sys.h deleted +0 -22
deleted file mode 100644
index 84332b0..0000000
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *             http://www.samsung.com
- *
- * EXYNOS - system register definition
- *
- * 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 __ASM_ARCH_REGS_SYS_H
-#define __ASM_ARCH_REGS_SYS_H __FILE__
-
-#include <mach/map.h>
-
-#define S5P_SYSREG(x)                          (S3C_VA_SYS + (x))
-
-/* For EXYNOS5 */
-#define EXYNOS5_SYS_I2C_CFG                    S5P_SYSREG(0x0234)
-
-#endif /* __ASM_ARCH_REGS_SYS_H */
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH v3 3/6 ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c

In reply to [email protected]

From: Pankaj Dubey <[email protected]>

This patch removes usage of soc_is_exynos4/5 from exynos.c. For this we need to separate machine descriptors for exynos4 and exynos5. While doing this patch does some consolidation also.

CC Russell King <[email protected]>
CC Thomas Abraham <[email protected]>
---
 arch/arm/mach-exynos/exynos.c            |   52 +++++++++++++++++++-----------
 arch/arm/plat-samsung/include/plat/cpu.h |    3 --
 2 files changed, 33 insertions(+), 22 deletions(-)
arch/arm/mach-exynos/exynos.c +33 -19
index 09063ee..9902e52 100644
@@ -202,20 +202,6 @@ static const struct of_device_id exynos_dt_pmu_match[] = {
 	{},
 };
 
-/*
- * exynos_map_io
- *
- * register the standard cpu IO areas
- */
-static void __init exynos_map_io(void)
-{
-	if (soc_is_exynos4())
-		iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc));
-
-	if (soc_is_exynos5())
-		iotable_init(exynos5_iodesc, ARRAY_SIZE(exynos5_iodesc));
-}
-
 static void __init exynos_init_io(void)
 {
 	debug_ll_io_init();
@@ -224,8 +210,18 @@ static void __init exynos_init_io(void)
 
 	/* detect cpu id and rev. */
 	s5p_init_cpu(S5P_VA_CHIPID);
+}
+
+static void __init exynos5_init_io(void)
+{
+	exynos_init_io();
+	iotable_init(exynos5_iodesc, ARRAY_SIZE(exynos5_iodesc));
+}
 
-	exynos_map_io();
+static void __init exynos4_init_io(void)
+{
+	exynos_init_io();
+	iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc));
 }
 
 struct bus_type exynos_subsys = {
@@ -293,11 +289,15 @@ static void __init exynos_dt_machine_init(void)
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 }
 
-static char const *exynos_dt_compat[] __initconst = {
+static char const *exynos4_dt_compat[] __initconst = {
 	"samsung,exynos4",
 	"samsung,exynos4210",
 	"samsung,exynos4212",
 	"samsung,exynos4412",
+	NULL
+};
+
+static char const *exynos5_dt_compat[] __initconst = {
 	"samsung,exynos5",
 	"samsung,exynos5250",
 	"samsung,exynos5420",
@@ -321,15 +321,29 @@ static void __init exynos_reserve(void)
 #endif
 }
 
-DT_MACHINE_START(EXYNOS_DT, "SAMSUNG EXYNOS (Flattened Device Tree)")
+DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS (Flattened Device Tree)")
+	/* Maintainer: Thomas Abraham <[email protected]> */
+	/* Maintainer: Kukjin Kim <[email protected]> */
+	.smp		= smp_ops(exynos_smp_ops),
+	.map_io		= exynos5_init_io,
+	.init_early	= exynos_firmware_init,
+	.init_machine	= exynos_dt_machine_init,
+	.init_late	= exynos_init_late,
+	.dt_compat	= exynos5_dt_compat,
+	.restart	= exynos_restart,
+	.reserve	= exynos_reserve,
+MACHINE_END
+
+
+DT_MACHINE_START(EXYNOS4_DT, "SAMSUNG EXYNOS (Flattened Device Tree)")
 	/* Maintainer: Thomas Abraham <[email protected]> */
 	/* Maintainer: Kukjin Kim <[email protected]> */
 	.smp		= smp_ops(exynos_smp_ops),
-	.map_io		= exynos_init_io,
+	.map_io		= exynos4_init_io,
 	.init_early	= exynos_firmware_init,
 	.init_machine	= exynos_dt_machine_init,
 	.init_late	= exynos_init_late,
-	.dt_compat	= exynos_dt_compat,
+	.dt_compat	= exynos4_dt_compat,
 	.restart	= exynos_restart,
 	.reserve	= exynos_reserve,
 MACHINE_END
arch/arm/plat-samsung/include/plat/cpu.h +0 -3
index 5992b8d..18a9a00 100644
@@ -166,9 +166,6 @@ IS_SAMSUNG_CPU(exynos5440, EXYNOS5440_SOC_ID, EXYNOS5_SOC_MASK)
 # define soc_is_exynos5440()	0
 #endif
 
-#define soc_is_exynos4() (soc_is_exynos4210() || soc_is_exynos4212() || \
-			  soc_is_exynos4412())
-#define soc_is_exynos5() (soc_is_exynos5250() || soc_is_exynos5420())
 
 #define IODESC_ENT(x) { (unsigned long)S3C24XX_VA_##x, __phys_to_pfn(S3C24XX_PA_##x), S3C24XX_SZ_##x, MT_DEVICE }
 
Signature · 1 line
1.7.10.4
#4 lore raw

Re: [PATCH v3 3/6] ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c

Quoted 77 lines · On Sat, May 10, 2014 at 12:18 AM, <[email protected]> wrote:

From: Pankaj Dubey <[email protected]>

This patch removes usage of soc_is_exynos4/5 from exynos.c. For this we need to separate machine descriptors for exynos4 and exynos5. While doing this patch does some consolidation also.

CC Russell King <[email protected]>
CC Thomas Abraham <[email protected]>
---
 arch/arm/mach-exynos/exynos.c            |   52 +++++++++++++++++++-----------
 arch/arm/plat-samsung/include/plat/cpu.h |    3 --
 2 files changed, 33 insertions(+), 22 deletions(-)
arch/arm/mach-exynos/exynos.c +16 -16
index 09063ee..9902e52 100644
@@ -202,20 +202,6 @@ static const struct of_device_id exynos_dt_pmu_match[] = {
        {},
 };
 
-/*
- * exynos_map_io
- *
- * register the standard cpu IO areas
- */
-static void __init exynos_map_io(void)
-{
-       if (soc_is_exynos4())
-               iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc));
-
-       if (soc_is_exynos5())
-               iotable_init(exynos5_iodesc, ARRAY_SIZE(exynos5_iodesc));
-}
-
 static void __init exynos_init_io(void)
 {
        debug_ll_io_init();
@@ -224,8 +210,18 @@ static void __init exynos_init_io(void)
 
        /* detect cpu id and rev. */
        s5p_init_cpu(S5P_VA_CHIPID);
+}
+
+static void __init exynos5_init_io(void)
+{
+       exynos_init_io();
+       iotable_init(exynos5_iodesc, ARRAY_SIZE(exynos5_iodesc));
+}
 
-       exynos_map_io();
+static void __init exynos4_init_io(void)
+{
+       exynos_init_io();
+       iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc));
 }
 
 struct bus_type exynos_subsys = {
@@ -293,11 +289,15 @@ static void __init exynos_dt_machine_init(void)
        of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 }
 
-static char const *exynos_dt_compat[] __initconst = {
+static char const *exynos4_dt_compat[] __initconst = {
        "samsung,exynos4",
        "samsung,exynos4210",
        "samsung,exynos4212",
        "samsung,exynos4412",
+       NULL
+};
+
+static char const *exynos5_dt_compat[] __initconst = {
        "samsung,exynos5",
        "samsung,exynos5250",
        "samsung,exynos5420",

arch/arm/mach-exynos/exynos.c static void __init exynos_reserve(void) · line 324

Quoted 5 lines
arch/arm/mach-exynos/exynos.c +1 -1
@@ -321,15 +321,29 @@ static void __init exynos_reserve(void)
 #endif
 }
 
-DT_MACHINE_START(EXYNOS_DT, "SAMSUNG EXYNOS (Flattened Device Tree)")
+DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS (Flattened Device Tree)")

SAMSUNG EXYNOS5

Quoted 4 lines
arch/arm/mach-exynos/exynos.c +4 -0
+       /* Maintainer: Thomas Abraham <[email protected]> */
+       /* Maintainer: Kukjin Kim <[email protected]> */
+       .smp            = smp_ops(exynos_smp_ops),
+       .map_io         = exynos5_init_io,

arch/arm/mach-exynos/exynos.c static void __init exynos_reserve(void) · line 338

Quoted 10 lines
arch/arm/mach-exynos/exynos.c +10 -0
+       .init_early     = exynos_firmware_init,
+       .init_machine   = exynos_dt_machine_init,
+       .init_late      = exynos_init_late,
+       .dt_compat      = exynos5_dt_compat,
+       .restart        = exynos_restart,
+       .reserve        = exynos_reserve,
+MACHINE_END
+
+
+DT_MACHINE_START(EXYNOS4_DT, "SAMSUNG EXYNOS (Flattened Device Tree)")

SAMSUNG EXYNOS4

... so you can tell the difference if you for some reason probed with the wrong one.

Also, you should order these with 4 before 5.

-Olof

#5 lore raw

Re: [PATCH v3 3/6] ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c

Quoted 101 lines · Olof Johansson
Quoted 77 lines · On Sat, May 10, 2014 at 12:18 AM, <[email protected]> wrote:

From: Pankaj Dubey <[email protected]>

This patch removes usage of soc_is_exynos4/5 from exynos.c. For this we need to separate machine descriptors for exynos4 and exynos5. While doing this patch does some consolidation also.

CC Russell King <[email protected]>
CC Thomas Abraham <[email protected]>
---
  arch/arm/mach-exynos/exynos.c            |   52 +++++++++++++++++++-----------
  arch/arm/plat-samsung/include/plat/cpu.h |    3 --
  2 files changed, 33 insertions(+), 22 deletions(-)
arch/arm/mach-exynos/exynos.c +16 -16
index 09063ee..9902e52 100644
@@ -202,20 +202,6 @@ static const struct of_device_id exynos_dt_pmu_match[] = {
         {},
  };
 
-/*
- * exynos_map_io
- *
- * register the standard cpu IO areas
- */
-static void __init exynos_map_io(void)
-{
-       if (soc_is_exynos4())
-               iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc));
-
-       if (soc_is_exynos5())
-               iotable_init(exynos5_iodesc, ARRAY_SIZE(exynos5_iodesc));
-}
-
  static void __init exynos_init_io(void)
  {
         debug_ll_io_init();
@@ -224,8 +210,18 @@ static void __init exynos_init_io(void)
 
         /* detect cpu id and rev. */
         s5p_init_cpu(S5P_VA_CHIPID);
+}
+
+static void __init exynos5_init_io(void)
+{
+       exynos_init_io();
+       iotable_init(exynos5_iodesc, ARRAY_SIZE(exynos5_iodesc));
+}
 
-       exynos_map_io();
+static void __init exynos4_init_io(void)
+{
+       exynos_init_io();
+       iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc));
  }
 
  struct bus_type exynos_subsys = {
@@ -293,11 +289,15 @@ static void __init exynos_dt_machine_init(void)
         of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  }
 
-static char const *exynos_dt_compat[] __initconst = {
+static char const *exynos4_dt_compat[] __initconst = {
         "samsung,exynos4",
         "samsung,exynos4210",
         "samsung,exynos4212",
         "samsung,exynos4412",
+       NULL
+};
+
+static char const *exynos5_dt_compat[] __initconst = {
         "samsung,exynos5",
         "samsung,exynos5250",
         "samsung,exynos5420",

arch/arm/mach-exynos/exynos.c static void __init exynos_reserve(void) · line 324

Quoted 5 lines
arch/arm/mach-exynos/exynos.c +1 -1
@@ -321,15 +321,29 @@ static void __init exynos_reserve(void)
  #endif
  }
 
-DT_MACHINE_START(EXYNOS_DT, "SAMSUNG EXYNOS (Flattened Device Tree)")
+DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS (Flattened Device Tree)")

SAMSUNG EXYNOS5

Quoted 4 lines
arch/arm/mach-exynos/exynos.c +4 -0
+       /* Maintainer: Thomas Abraham <[email protected]> */
+       /* Maintainer: Kukjin Kim <[email protected]> */
+       .smp            = smp_ops(exynos_smp_ops),
+       .map_io         = exynos5_init_io,

arch/arm/mach-exynos/exynos.c static void __init exynos_reserve(void) · line 338

Quoted 10 lines
arch/arm/mach-exynos/exynos.c +10 -0
+       .init_early     = exynos_firmware_init,
+       .init_machine   = exynos_dt_machine_init,
+       .init_late      = exynos_init_late,
+       .dt_compat      = exynos5_dt_compat,
+       .restart        = exynos_restart,
+       .reserve        = exynos_reserve,
+MACHINE_END
+
+
+DT_MACHINE_START(EXYNOS4_DT, "SAMSUNG EXYNOS (Flattened Device Tree)")

SAMSUNG EXYNOS4

Quoted 5 lines

... so you can tell the difference if you for some reason probed with the wrong one.

Also, you should order these with 4 before 5.

Thanks for review. I will take care of this in next revision.

Quoted 2 lines

-Olof

Signature · 2 lines
Best Regards,
Pankaj Dubey
#6 lore raw

PATCH v3 4/6 ARM: EXYNOS: Remove unused header inclusion from hotplug.c

In reply to [email protected]

From: Pankaj Dubey <[email protected]>

This patch removed "plat/cpu.h" inclusion from hotplug.c as it is not required.

---
 arch/arm/mach-exynos/hotplug.c |    2 --
 1 file changed, 2 deletions(-)
arch/arm/mach-exynos/hotplug.c +0 -2
index 0243ef3..5e19601 100644
@@ -19,8 +19,6 @@
 #include <asm/cp15.h>
 #include <asm/smp_plat.h>
 
-#include <plat/cpu.h>
-
 #include "common.h"
 #include "regs-pmu.h"
 
Signature · 1 line
1.7.10.4
#7 lore raw

PATCH v3 5/6 soc: samsung: exynos-chipid: Add Exynos Chipid driver support

In reply to [email protected]

From: Pankaj Dubey <[email protected]>

Exynos SoCs have Chipid, for identification of product IDs and SoC revistions. Till now we are using static macros such as soc_is_exynosNNNN and #ifdefs for run time identification of SoCs and their revisions. This is leading to add new Kconfig, soc_is_exynosNNNN definitions each time new SoC support is getting added. So this driver intends to provide initialization code all these functionalites and thus helping in removing macros.

---
 drivers/soc/Kconfig                 |    1 +
 drivers/soc/Makefile                |    1 +
 drivers/soc/samsung/Kconfig         |   10 +++
 drivers/soc/samsung/Makefile        |    1 +
 drivers/soc/samsung/exynos-chipid.c |  166 +++++++++++++++++++++++++++++++++++
 include/linux/exynos-soc.h          |   46 ++++++++++
 6 files changed, 225 insertions(+)
 create mode 100644 drivers/soc/samsung/Kconfig
 create mode 100644 drivers/soc/samsung/Makefile
 create mode 100644 drivers/soc/samsung/exynos-chipid.c
 create mode 100644 include/linux/exynos-soc.h
drivers/soc/Kconfig +1 -0
index 07a11be..86e52b1 100644
@@ -1,5 +1,6 @@
 menu "SOC specific Drivers"
 
 source "drivers/soc/qcom/Kconfig"
+source "drivers/soc/samsung/Kconfig"
 
 endmenu
drivers/soc/Makefile +1 -0
index 0f7c447..ee890aa 100644
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_ARCH_QCOM)		+= qcom/
+obj-$(CONFIG_ARCH_EXYNOS)	+= samsung/
drivers/soc/samsung/Kconfig new file +10 -0
new file mode 100644
index 0000000..dacc95d
@@ -0,0 +1,10 @@
+
+# SAMSUNG Soc drivers
+#
+config EXYNOS_CHIPID
+	tristate "Support Exynos CHIPID"
+	default y
+	select SOC_BUS
+	depends on ARCH_EXYNOS || ARM64
+	help
+	  If you say Y here you get support for the Exynos CHIP id.
drivers/soc/samsung/Makefile new file +1 -0
new file mode 100644
index 0000000..855ca05
@@ -0,0 +1 @@
+obj-$(CONFIG_EXYNOS_CHIPID)	+= exynos-chipid.o
drivers/soc/samsung/exynos-chipid.c new file +166 -0

166 lines not on this page · raw message

include/linux/exynos-soc.h new file +46 -0

46 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#8 lore raw

PATCH v3 6/6 ARM: EXYNOS: Refactoring to remove soc_is_exynos macros from exynos

In reply to [email protected]

From: Pankaj Dubey <[email protected]>

This patch enables chipid driver for ARCH_EXYNOS and refactors machine code as well as exynos cpufreq driver code for using chipid driver for identification of SoC ID and SoC rev.

This patch also updates DT binding information in exynos4 and exynos5 dtsi file. As to differentiate product id bit-mask we need separate compatible string for exynos4 and exynos5. Hoping this will be helpful in future as bit-mask and bit-shift bit may differ. Added binding information as well.

---
 .../bindings/arm/samsung/exynos-chipid.txt         |   21 ++++++++
 arch/arm/Kconfig                                   |    1 +
 arch/arm/boot/dts/exynos4.dtsi                     |    2 +-
 arch/arm/boot/dts/exynos5.dtsi                     |    2 +-
 arch/arm/mach-exynos/exynos.c                      |   47 ++++------------
 arch/arm/mach-exynos/platsmp.c                     |   11 ++--
 arch/arm/mach-exynos/pm.c                          |   26 ++++-----
 arch/arm/plat-samsung/include/plat/cpu.h           |   57 --------------------
 drivers/clk/samsung/clk-exynos4.c                  |    2 +-
 drivers/cpufreq/exynos-cpufreq.c                   |    9 ++--
 drivers/cpufreq/exynos-cpufreq.h                   |    1 -
 drivers/cpufreq/exynos4x12-cpufreq.c               |    5 +-
 12 files changed, 61 insertions(+), 123 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt
Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt new file +21 -0
new file mode 100644
index 0000000..a496459
@@ -0,0 +1,21 @@
+SAMSUNG Exynos4/Exynos5 SoCs Chipid driver.
+
+Required properties:
+- compatible : Should at least contain "samsung,exynos4210-chipid". More
+	specific compatible string specify which SoC version (exynos4 or
+	exynos5) are paired with.
+  Details:
+  samsung,exynos4-chipid: Exynos4 SoCs has Chip ID block that can provide
+	product id, revision number and package information.
+	It has different product-id bit-mask than Exynos5 series SoC.
+  samsung,exynos5-chipid: Exynos5 SoCs has Chip ID block that can provide
+	product id, revision number and package information.
+	It has different product-id bit-mask then Exynos4 series SoC.
+
+- reg: offset and length of the register set
+
+Example:
+	chipid@10000000 {
+		compatible = "samsung,exynos4210-chipid", "samsung,exynos4-chipid";
+		reg = <0x10000000 0x100>;
+	};
arch/arm/Kconfig +1 -0
index a4eac2f..06f14a4 100644
@@ -856,6 +856,7 @@ config ARCH_EXYNOS
 	select SRAM
 	select USE_OF
 	select MFD_SYSCON
+	select EXYNOS_CHIPID
 	help
 	  Support for SAMSUNG's EXYNOS SoCs (EXYNOS4/5)
 
arch/arm/boot/dts/exynos4.dtsi +1 -1
index 2f8bcd0..d4c0657 100644
@@ -46,7 +46,7 @@
 	};
 
 	chipid@10000000 {
-		compatible = "samsung,exynos4210-chipid";
+		compatible = "samsung,exynos4210-chipid", "samsung,exynos4-chipid";
 		reg = <0x10000000 0x100>;
 	};
 
arch/arm/boot/dts/exynos5.dtsi +1 -1
index 3027e37..1d0b569 100644
@@ -19,7 +19,7 @@
 	interrupt-parent = <&gic>;
 
 	chipid@10000000 {
-		compatible = "samsung,exynos4210-chipid";
+		compatible = "samsung,exynos4210-chipid", "samsung,exynos5-chipid";
 		reg = <0x10000000 0x100>;
 	};
 
arch/arm/mach-exynos/exynos.c +9 -38

90 lines not on this page · raw message

arch/arm/mach-exynos/platsmp.c +7 -4
index d0482c2..9d6ec84 100644
@@ -20,13 +20,13 @@
 #include <linux/smp.h>
 #include <linux/io.h>
 #include <linux/of_address.h>
+#include <linux/exynos-soc.h>
 
 #include <asm/cacheflush.h>
 #include <asm/smp_plat.h>
 #include <asm/smp_scu.h>
 #include <asm/firmware.h>
 
-#include <plat/cpu.h>
 #include <mach/map.h>
 
 #include "common.h"
@@ -59,7 +59,8 @@ static void __init exynos_smp_prepare_sram(void)
 
 static inline void __iomem *cpu_boot_reg_base(void)
 {
-	if (soc_is_exynos4210() && samsung_rev() == EXYNOS4210_REV_1_1)
+	if (is_soc_id_compatible(EXYNOS4210) &&
+			is_soc_rev_compatible(EXYNOS4210_REV_1_1))
 		return pmu_base + S5P_INFORM5;
 
 	return sram_base_addr;
@@ -72,9 +73,10 @@ static inline void __iomem *cpu_boot_reg(int cpu)
 	boot_reg = cpu_boot_reg_base();
 	if (!boot_reg)
 		return ERR_PTR(-ENODEV);
-	if (soc_is_exynos4412())
+
+	if (is_soc_id_compatible(EXYNOS4412))
 		boot_reg += 4*cpu;
-	else if (soc_is_exynos5420())
+	else if (is_soc_id_compatible(EXYNOS5420))
 		boot_reg += 4;
 	return boot_reg;
 }
@@ -264,6 +266,7 @@ static void __init exynos_smp_init_cpus(void)
 static void __init exynos_smp_prepare_cpus(unsigned int max_cpus)
 {
 	int i;
+	early_exynos_chipid_init();
 
 	pmu_base = pmu_base_addr();
 
arch/arm/mach-exynos/pm.c +13 -13
index 59e5604..5cb5449 100644
@@ -22,13 +22,13 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/regmap.h>
+#include <linux/exynos-soc.h>
 
 #include <asm/cacheflush.h>
 #include <asm/hardware/cache-l2x0.h>
 #include <asm/smp_scu.h>
 #include <asm/suspend.h>
 
-#include <plat/cpu.h>
 #include <plat/pm-common.h>
 #include <plat/pll.h>
 #include <plat/regs-srom.h>
@@ -82,7 +82,7 @@ static int exynos_irq_set_wake(struct irq_data *data, unsigned int state)
 {
 	const struct exynos_wkup_irq *wkup_irq;
 
-	if (soc_is_exynos5250())
+	if (is_soc_id_compatible(EXYNOS5250))
 		wkup_irq = exynos5250_wkup_irq;
 	else
 		wkup_irq = exynos4_wkup_irq;
@@ -101,11 +101,11 @@ static int exynos_irq_set_wake(struct irq_data *data, unsigned int state)
 	return -ENOENT;
 }
 
-#define EXYNOS_BOOT_VECTOR_ADDR	(samsung_rev() == EXYNOS4210_REV_1_1 ? \
-			S5P_INFORM7 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \
+#define EXYNOS_BOOT_VECTOR_ADDR	(is_soc_rev_compatible(EXYNOS4210_REV_1_1) ? \
+			S5P_INFORM7 : (is_soc_rev_compatible(EXYNOS4210_REV_1_0) ? \
 			0x24 : S5P_INFORM0))
-#define EXYNOS_BOOT_VECTOR_FLAG	(samsung_rev() == EXYNOS4210_REV_1_1 ? \
-			S5P_INFORM6 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \
+#define EXYNOS_BOOT_VECTOR_FLAG	(is_soc_rev_compatible(EXYNOS4210_REV_1_1) ? \
+			S5P_INFORM6 : (is_soc_rev_compatible(EXYNOS4210_REV_1_0) ? \
 			0x20 : S5P_INFORM1))
 
 #define S5P_CHECK_AFTR  0xFCBA0D10
@@ -119,7 +119,7 @@ static void exynos_set_wakeupmask(long mask)
 
 static void exynos_cpu_set_boot_vector(long flags)
 {
-	if (samsung_rev() == EXYNOS4210_REV_1_0) {
+	if (is_soc_rev_compatible(EXYNOS4210_REV_1_0)) {
 		__raw_writel(virt_to_phys(exynos_cpu_resume),
 				S5P_VA_SYSRAM + EXYNOS_BOOT_VECTOR_ADDR);
 		__raw_writel(flags, S5P_VA_SYSRAM + EXYNOS_BOOT_VECTOR_FLAG);
@@ -183,7 +183,7 @@ static int exynos_cpu_suspend(unsigned long arg)
 	outer_flush_all();
 #endif
 
-	if (soc_is_exynos5250())
+	if (is_soc_id_compatible(EXYNOS5250))
 		flush_cache_all();
 
 	/* issue the standby signal into the pm unit. */
@@ -205,7 +205,7 @@ static void exynos_pm_prepare(void)
 
 	s3c_pm_do_save(exynos_core_save, ARRAY_SIZE(exynos_core_save));
 
-	if (soc_is_exynos5250()) {
+	if (is_soc_id_compatible(EXYNOS5250)) {
 		/* Disable USE_RETENTION of JPEG_MEM_OPTION */
 		regmap_read(pmu_regmap, EXYNOS5_JPEG_MEM_OPTION, &tmp);
 		tmp &= ~EXYNOS5_OPTION_USE_RETENTION;
@@ -243,7 +243,7 @@ static int exynos_pm_suspend(void)
 	tmp = (S5P_USE_STANDBY_WFI0 | S5P_USE_STANDBY_WFE0);
 	regmap_write(pmu_regmap, S5P_CENTRAL_SEQ_OPTION, tmp);
 
-	if (!soc_is_exynos5250())
+	if (!is_soc_id_compatible(EXYNOS5250))
 		exynos_cpu_save_register();
 
 	return 0;
@@ -277,7 +277,7 @@ static void exynos_pm_resume(void)
 	if (exynos_pm_central_resume())
 		goto early_wakeup;
 
-	if (!soc_is_exynos5250())
+	if (!is_soc_id_compatible(EXYNOS5250))
 		exynos_cpu_restore_register();
 
 	/* For release retention */
@@ -292,7 +292,7 @@ static void exynos_pm_resume(void)
 
 	s3c_pm_do_restore_core(exynos_core_save, ARRAY_SIZE(exynos_core_save));
 
-	if (!soc_is_exynos5250())
+	if (!is_soc_id_compatible(EXYNOS5250))
 		scu_enable(S5P_VA_SCU);
 
 early_wakeup:
@@ -385,7 +385,7 @@ static int exynos_cpu_pm_notifier(struct notifier_block *self,
 
 	case CPU_PM_EXIT:
 		if (cpu == 0) {
-			if (!soc_is_exynos5250())
+			if (!is_soc_id_compatible(EXYNOS5250))
 				scu_enable(S5P_VA_SCU);
 			exynos_cpu_restore_register();
 			exynos_pm_central_resume();
arch/arm/plat-samsung/include/plat/cpu.h +0 -57

75 lines not on this page · raw message

drivers/clk/samsung/clk-exynos4.c +1 -1
index b4f9672..7b0ea1f 100644
@@ -1030,7 +1030,7 @@ static unsigned long exynos4_get_xom(void)
 	void __iomem *chipid_base;
 	struct device_node *np;
 
-	np = of_find_compatible_node(NULL, NULL, "samsung,exynos4210-chipid");
+	np = of_find_compatible_node(NULL, NULL, "samsung,exynos4-chipid");
 	if (np) {
 		chipid_base = of_iomap(np, 0);
 
drivers/cpufreq/exynos-cpufreq.c +4 -5
index f99cfe2..5fe84a1 100644
@@ -17,8 +17,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/cpufreq.h>
 #include <linux/platform_device.h>
-
-#include <plat/cpu.h>
+#include <linux/exynos-soc.h>
 
 #include "exynos-cpufreq.h"
 
@@ -163,11 +162,11 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
 	if (!exynos_info)
 		return -ENOMEM;
 
-	if (soc_is_exynos4210())
+	if (is_soc_id_compatible(EXYNOS4210))
 		ret = exynos4210_cpufreq_init(exynos_info);
-	else if (soc_is_exynos4212() || soc_is_exynos4412())
+	else if (is_soc_id_compatible(EXYNOS4212) || is_soc_id_compatible(EXYNOS4412))
 		ret = exynos4x12_cpufreq_init(exynos_info);
-	else if (soc_is_exynos5250())
+	else if (is_soc_id_compatible(EXYNOS5250))
 		ret = exynos5250_cpufreq_init(exynos_info);
 	else
 		return 0;
drivers/cpufreq/exynos-cpufreq.h +0 -1
index 3ddade8..4201b6d 100644
@@ -68,7 +68,6 @@ static inline int exynos5250_cpufreq_init(struct exynos_dvfs_info *info)
 }
 #endif
 
-#include <plat/cpu.h>
 #include <mach/map.h>
 
 #define EXYNOS4_CLKSRC_CPU			(S5P_VA_CMU + 0x14200)
drivers/cpufreq/exynos4x12-cpufreq.c +3 -2
index 466c76a..958d86f 100644
@@ -16,6 +16,7 @@
 #include <linux/io.h>
 #include <linux/slab.h>
 #include <linux/cpufreq.h>
+#include <linux/exynos-soc.h>
 
 #include "exynos-cpufreq.h"
 
@@ -115,7 +116,7 @@ static void exynos4x12_set_clkdiv(unsigned int div_index)
 	tmp = apll_freq_4x12[div_index].clk_div_cpu1;
 
 	__raw_writel(tmp, EXYNOS4_CLKDIV_CPU1);
-	if (soc_is_exynos4212())
+	if (is_soc_id_compatible(EXYNOS4212))
 		stat_cpu1 = 0x11;
 	else
 		stat_cpu1 = 0x111;
@@ -184,7 +185,7 @@ int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info)
 	if (IS_ERR(mout_apll))
 		goto err_mout_apll;
 
-	if (soc_is_exynos4212())
+	if (is_soc_id_compatible(EXYNOS4212))
 		apll_freq_4x12 = apll_freq_4212;
 	else
 		apll_freq_4x12 = apll_freq_4412;
Signature · 1 line
1.7.10.4
#9 lore raw

Re: [PATCH v3 6/6] ARM: EXYNOS: Refactoring to remove soc_is_exynos macros from exynos

Quoted 46 lines · On Sat, May 10, 2014 at 12:18 AM, <[email protected]> wrote:

From: Pankaj Dubey <[email protected]>

This patch enables chipid driver for ARCH_EXYNOS and refactors machine code as well as exynos cpufreq driver code for using chipid driver for identification of SoC ID and SoC rev.

This patch also updates DT binding information in exynos4 and exynos5 dtsi file. As to differentiate product id bit-mask we need separate compatible string for exynos4 and exynos5. Hoping this will be helpful in future as bit-mask and bit-shift bit may differ. Added binding information as well.

---
 .../bindings/arm/samsung/exynos-chipid.txt         |   21 ++++++++
 arch/arm/Kconfig                                   |    1 +
 arch/arm/boot/dts/exynos4.dtsi                     |    2 +-
 arch/arm/boot/dts/exynos5.dtsi                     |    2 +-
 arch/arm/mach-exynos/exynos.c                      |   47 ++++------------
 arch/arm/mach-exynos/platsmp.c                     |   11 ++--
 arch/arm/mach-exynos/pm.c                          |   26 ++++-----
 arch/arm/plat-samsung/include/plat/cpu.h           |   57 --------------------
 drivers/clk/samsung/clk-exynos4.c                  |    2 +-
 drivers/cpufreq/exynos-cpufreq.c                   |    9 ++--
 drivers/cpufreq/exynos-cpufreq.h                   |    1 -
 drivers/cpufreq/exynos4x12-cpufreq.c               |    5 +-
 12 files changed, 61 insertions(+), 123 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt
Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt new file +11 -0
new file mode 100644
index 0000000..a496459
@@ -0,0 +1,21 @@
+SAMSUNG Exynos4/Exynos5 SoCs Chipid driver.
+
+Required properties:
+- compatible : Should at least contain "samsung,exynos4210-chipid". More
+       specific compatible string specify which SoC version (exynos4 or
+       exynos5) are paired with.
+  Details:
+  samsung,exynos4-chipid: Exynos4 SoCs has Chip ID block that can provide
+       product id, revision number and package information.
+       It has different product-id bit-mask than Exynos5 series SoC.
+  samsung,exynos5-chipid: Exynos5 SoCs has Chip ID block that can provide

Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt line 21

Quoted 10 lines
Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt new file +10 -0
+       product id, revision number and package information.
+       It has different product-id bit-mask then Exynos4 series SoC.
+
+- reg: offset and length of the register set
+
+Example:
+       chipid at 10000000 {
+               compatible = "samsung,exynos4210-chipid", "samsung,exynos4-chipid";
+               reg = <0x10000000 0x100>;
+       };

This needs to go with the patch adding the driver.

Quoted 17 lines
arch/arm/Kconfig +1 -0
index a4eac2f..06f14a4 100644
@@ -856,6 +856,7 @@ config ARCH_EXYNOS
        select SRAM
        select USE_OF
        select MFD_SYSCON
+       select EXYNOS_CHIPID
        help
          Support for SAMSUNG's EXYNOS SoCs (EXYNOS4/5)
 
arch/arm/boot/dts/exynos4.dtsi +0 -0
index 2f8bcd0..d4c0657 100644

arch/arm/boot/dts/exynos4.dtsi line 49

Quoted 5 lines
arch/arm/boot/dts/exynos4.dtsi +1 -1
@@ -46,7 +46,7 @@
        };
 
        chipid at 10000000 {
-               compatible = "samsung,exynos4210-chipid";
+               compatible = "samsung,exynos4210-chipid", "samsung,exynos4-chipid";

Only 4210-chipid. We normally don't use generic names on any drivers (we might on system level, but not on drivers).

arch/arm/boot/dts/exynos5.dtsi line 22

Quoted 13 lines
arch/arm/boot/dts/exynos4.dtsi +0 -0
                reg = <0x10000000 0x100>;
        };
 
arch/arm/boot/dts/exynos5.dtsi +1 -1
index 3027e37..1d0b569 100644
@@ -19,7 +19,7 @@
        interrupt-parent = <&gic>;
 
        chipid at 10000000 {
-               compatible = "samsung,exynos4210-chipid";
+               compatible = "samsung,exynos4210-chipid", "samsung,exynos5-chipid";

Same here. Each SoC should probably have:

samsung,exynos<soc>-chipid, samsung,exynos4210-chipid

At least if you think there will ever be a difference in how the driver has to work when interacting with this IP block compared to 4210.

Quoted 132 lines
arch/arm/boot/dts/exynos5.dtsi +0 -0
                reg = <0x10000000 0x100>;
        };
 
arch/arm/mach-exynos/exynos.c +9 -38
index 9902e52..26f5e8c 100644
@@ -21,6 +21,7 @@
 #include <linux/pm_domain.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
+#include <linux/exynos-soc.h>
 
 #include <asm/cacheflush.h>
 #include <asm/hardware/cache-l2x0.h>
@@ -28,7 +29,6 @@
 #include <asm/mach/map.h>
 #include <asm/memory.h>
 
-#include <plat/cpu.h>
 #include <mach/map.h>
 
 #include "common.h"
@@ -171,29 +171,6 @@ static void __init exynos_init_late(void)
        exynos_pm_init();
 }
 
-static int __init exynos_fdt_map_chipid(unsigned long node, const char *uname,
-                                       int depth, void *data)
-{
-       struct map_desc iodesc;
-       __be32 *reg;
-       unsigned long len;
-
-       if (!of_flat_dt_is_compatible(node, "samsung,exynos4210-chipid") &&
-               !of_flat_dt_is_compatible(node, "samsung,exynos5440-clock"))
-               return 0;
-
-       reg = of_get_flat_dt_prop(node, "reg", &len);
-       if (reg == NULL || len != (sizeof(unsigned long) * 2))
-               return 0;
-
-       iodesc.pfn = __phys_to_pfn(be32_to_cpu(reg[0]));
-       iodesc.length = be32_to_cpu(reg[1]) - 1;
-       iodesc.virtual = (unsigned long)S5P_VA_CHIPID;
-       iodesc.type = MT_DEVICE;
-       iotable_init(&iodesc, 1);
-       return 1;
-}
-
 static const struct of_device_id exynos_dt_pmu_match[] = {
        { .compatible = "samsung,exynos4210-pmu" },
        { .compatible = "samsung,exynos4212-pmu" },
@@ -202,25 +179,15 @@ static const struct of_device_id exynos_dt_pmu_match[] = {
        {},
 };
 
-static void __init exynos_init_io(void)
-{
-       debug_ll_io_init();
-
-       of_scan_flat_dt(exynos_fdt_map_chipid, NULL);
-
-       /* detect cpu id and rev. */
-       s5p_init_cpu(S5P_VA_CHIPID);
-}
-
 static void __init exynos5_init_io(void)
 {
-       exynos_init_io();
+       debug_ll_io_init();
        iotable_init(exynos5_iodesc, ARRAY_SIZE(exynos5_iodesc));
 }
 
 static void __init exynos4_init_io(void)
 {
-       exynos_init_io();
+       debug_ll_io_init();
        iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc));
 }
 
@@ -279,14 +246,18 @@ void __init exynos_map_pmu(void)
 
 static void __init exynos_dt_machine_init(void)
 {
+       struct device *parent;
+
        exynos_map_pmu();
 
-       if (!soc_is_exynos5440())
+       parent = exynos_soc_device_init();
+
+       if (is_soc_id_compatible(EXYNOS5440))
                platform_device_register(&exynos_cpuidle);
 
        platform_device_register_simple("exynos-cpufreq", -1, NULL, 0);
 
-       of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
+       of_platform_populate(NULL, of_default_bus_match_table, NULL, parent);
 }
 
 static char const *exynos4_dt_compat[] __initconst = {
arch/arm/mach-exynos/platsmp.c +3 -2
index d0482c2..9d6ec84 100644
@@ -20,13 +20,13 @@
 #include <linux/smp.h>
 #include <linux/io.h>
 #include <linux/of_address.h>
+#include <linux/exynos-soc.h>
 
 #include <asm/cacheflush.h>
 #include <asm/smp_plat.h>
 #include <asm/smp_scu.h>
 #include <asm/firmware.h>
 
-#include <plat/cpu.h>
 #include <mach/map.h>
 
 #include "common.h"
@@ -59,7 +59,8 @@ static void __init exynos_smp_prepare_sram(void)
 
 static inline void __iomem *cpu_boot_reg_base(void)
 {
-       if (soc_is_exynos4210() && samsung_rev() == EXYNOS4210_REV_1_1)
+       if (is_soc_id_compatible(EXYNOS4210) &&
+                       is_soc_rev_compatible(EXYNOS4210_REV_1_1))
                return pmu_base + S5P_INFORM5;
 
        return sram_base_addr;

arch/arm/mach-exynos/platsmp.c static inline void __iomem *cpu_boot_reg(int cpu) · line 80

Quoted 10 lines
arch/arm/mach-exynos/platsmp.c +3 -2
@@ -72,9 +73,10 @@ static inline void __iomem *cpu_boot_reg(int cpu)
        boot_reg = cpu_boot_reg_base();
        if (!boot_reg)
                return ERR_PTR(-ENODEV);
-       if (soc_is_exynos4412())
+
+       if (is_soc_id_compatible(EXYNOS4412))
                boot_reg += 4*cpu;
-       else if (soc_is_exynos5420())
+       else if (is_soc_id_compatible(EXYNOS5420))
                boot_reg += 4;

This won't work much longer. You'll need to add another check for any other SoC that has another register layout. This is probably one of these cases where it makes more sense to describe the register offset/layout in the DT.

Quoted 82 lines
arch/arm/mach-exynos/platsmp.c +1 -0
        return boot_reg;
 }
@@ -264,6 +266,7 @@ static void __init exynos_smp_init_cpus(void)
 static void __init exynos_smp_prepare_cpus(unsigned int max_cpus)
 {
        int i;
+       early_exynos_chipid_init();
 
        pmu_base = pmu_base_addr();
 
arch/arm/mach-exynos/pm.c +9 -9
index 59e5604..5cb5449 100644
@@ -22,13 +22,13 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/regmap.h>
+#include <linux/exynos-soc.h>
 
 #include <asm/cacheflush.h>
 #include <asm/hardware/cache-l2x0.h>
 #include <asm/smp_scu.h>
 #include <asm/suspend.h>
 
-#include <plat/cpu.h>
 #include <plat/pm-common.h>
 #include <plat/pll.h>
 #include <plat/regs-srom.h>
@@ -82,7 +82,7 @@ static int exynos_irq_set_wake(struct irq_data *data, unsigned int state)
 {
        const struct exynos_wkup_irq *wkup_irq;
 
-       if (soc_is_exynos5250())
+       if (is_soc_id_compatible(EXYNOS5250))
                wkup_irq = exynos5250_wkup_irq;
        else
                wkup_irq = exynos4_wkup_irq;
@@ -101,11 +101,11 @@ static int exynos_irq_set_wake(struct irq_data *data, unsigned int state)
        return -ENOENT;
 }
 
-#define EXYNOS_BOOT_VECTOR_ADDR        (samsung_rev() == EXYNOS4210_REV_1_1 ? \
-                       S5P_INFORM7 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \
+#define EXYNOS_BOOT_VECTOR_ADDR        (is_soc_rev_compatible(EXYNOS4210_REV_1_1) ? \
+                       S5P_INFORM7 : (is_soc_rev_compatible(EXYNOS4210_REV_1_0) ? \
                        0x24 : S5P_INFORM0))
-#define EXYNOS_BOOT_VECTOR_FLAG        (samsung_rev() == EXYNOS4210_REV_1_1 ? \
-                       S5P_INFORM6 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \
+#define EXYNOS_BOOT_VECTOR_FLAG        (is_soc_rev_compatible(EXYNOS4210_REV_1_1) ? \
+                       S5P_INFORM6 : (is_soc_rev_compatible(EXYNOS4210_REV_1_0) ? \
                        0x20 : S5P_INFORM1))
 
 #define S5P_CHECK_AFTR  0xFCBA0D10
@@ -119,7 +119,7 @@ static void exynos_set_wakeupmask(long mask)
 
 static void exynos_cpu_set_boot_vector(long flags)
 {
-       if (samsung_rev() == EXYNOS4210_REV_1_0) {
+       if (is_soc_rev_compatible(EXYNOS4210_REV_1_0)) {
                __raw_writel(virt_to_phys(exynos_cpu_resume),
                                S5P_VA_SYSRAM + EXYNOS_BOOT_VECTOR_ADDR);
                __raw_writel(flags, S5P_VA_SYSRAM + EXYNOS_BOOT_VECTOR_FLAG);
@@ -183,7 +183,7 @@ static int exynos_cpu_suspend(unsigned long arg)
        outer_flush_all();
 #endif
 
-       if (soc_is_exynos5250())
+       if (is_soc_id_compatible(EXYNOS5250))
                flush_cache_all();
 
        /* issue the standby signal into the pm unit. */
@@ -205,7 +205,7 @@ static void exynos_pm_prepare(void)
 
        s3c_pm_do_save(exynos_core_save, ARRAY_SIZE(exynos_core_save));
 
-       if (soc_is_exynos5250()) {
+       if (is_soc_id_compatible(EXYNOS5250)) {
                /* Disable USE_RETENTION of JPEG_MEM_OPTION */
                regmap_read(pmu_regmap, EXYNOS5_JPEG_MEM_OPTION, &tmp);
                tmp &= ~EXYNOS5_OPTION_USE_RETENTION;

arch/arm/mach-exynos/pm.c static int exynos_pm_suspend(void) · line 247

Quoted 6 lines
arch/arm/mach-exynos/pm.c +1 -1
@@ -243,7 +243,7 @@ static int exynos_pm_suspend(void)
        tmp = (S5P_USE_STANDBY_WFI0 | S5P_USE_STANDBY_WFE0);
        regmap_write(pmu_regmap, S5P_CENTRAL_SEQ_OPTION, tmp);
 
-       if (!soc_is_exynos5250())
+       if (!is_soc_id_compatible(EXYNOS5250))
                exynos_cpu_save_register();

These kind of constructs don't work well, you will have to address them too. I know there'll be need for code here for 5420/5422 already, for example.

drivers/clk/samsung/clk-exynos4.c static unsigned long exynos4_get_xom(void) · line 1033

Quoted 10 lines
drivers/clk/samsung/clk-exynos4.c +1 -1
index b4f9672..7b0ea1f 100644
@@ -1030,7 +1030,7 @@ static unsigned long exynos4_get_xom(void)
        void __iomem *chipid_base;
        struct device_node *np;
 
-       np = of_find_compatible_node(NULL, NULL, "samsung,exynos4210-chipid");
+       np = of_find_compatible_node(NULL, NULL, "samsung,exynos4-chipid");

This should likely still say 4210.

Quoted 20 lines
drivers/clk/samsung/clk-exynos4.c +0 -0
        if (np) {
                chipid_base = of_iomap(np, 0);
 
drivers/cpufreq/exynos-cpufreq.c +1 -2
index f99cfe2..5fe84a1 100644
@@ -17,8 +17,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/cpufreq.h>
 #include <linux/platform_device.h>
-
-#include <plat/cpu.h>
+#include <linux/exynos-soc.h>
 
 #include "exynos-cpufreq.h"
 
@@ -163,11 +162,11 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
        if (!exynos_info)
                return -ENOMEM;

drivers/cpufreq/exynos-cpufreq.c static int exynos_cpufreq_probe(struct platform_device *pdev) · line 170

Quoted 10 lines
drivers/cpufreq/exynos-cpufreq.c +3 -3
 
-       if (soc_is_exynos4210())
+       if (is_soc_id_compatible(EXYNOS4210))
                ret = exynos4210_cpufreq_init(exynos_info);
-       else if (soc_is_exynos4212() || soc_is_exynos4412())
+       else if (is_soc_id_compatible(EXYNOS4212) || is_soc_id_compatible(EXYNOS4412))
                ret = exynos4x12_cpufreq_init(exynos_info);
-       else if (soc_is_exynos5250())
+       else if (is_soc_id_compatible(EXYNOS5250))
                ret = exynos5250_cpufreq_init(exynos_info);

Many drivers tend to use of_machine_is_compatible here. I wonder if that'll solve most of your problems in a more generic way. Any machine based on an SoC should have the SoC somewhere in the compatible array for the board anyway.

Actually, I think using that approach in most of your patch set will remove the need for the chipid driver alltogether, and just using machine compatibles instead.

-Olof

#10 lore raw

Re: [PATCH v3 6/6] ARM: EXYNOS: Refactoring to remove soc_is_exynos macros from exynos

Quoted 50 lines · Olof Johansson
Quoted 49 lines · On Sat, May 10, 2014 at 12:18 AM, <[email protected]> wrote:

From: Pankaj Dubey <[email protected]>

This patch enables chipid driver for ARCH_EXYNOS and refactors machine code as well as exynos cpufreq driver code for using chipid driver for identification of SoC ID and SoC rev.

This patch also updates DT binding information in exynos4 and exynos5 dtsi file. As to differentiate product id bit-mask we need separate compatible string for exynos4 and exynos5. Hoping this will be helpful in future as bit-mask and bit-shift bit may differ. Added binding information as well.

---
  .../bindings/arm/samsung/exynos-chipid.txt         |   21 ++++++++
  arch/arm/Kconfig                                   |    1 +
  arch/arm/boot/dts/exynos4.dtsi                     |    2 +-
  arch/arm/boot/dts/exynos5.dtsi                     |    2 +-
  arch/arm/mach-exynos/exynos.c                      |   47 ++++------------
  arch/arm/mach-exynos/platsmp.c                     |   11 ++--
  arch/arm/mach-exynos/pm.c                          |   26 ++++-----
  arch/arm/plat-samsung/include/plat/cpu.h           |   57 --------------------
  drivers/clk/samsung/clk-exynos4.c                  |    2 +-
  drivers/cpufreq/exynos-cpufreq.c                   |    9 ++--
  drivers/cpufreq/exynos-cpufreq.h                   |    1 -
  drivers/cpufreq/exynos4x12-cpufreq.c               |    5 +-
  12 files changed, 61 insertions(+), 123 deletions(-)

create mode 100644 Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt

Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt new file +14 -0
new file mode 100644
index 0000000..a496459
@@ -0,0 +1,21 @@
+SAMSUNG Exynos4/Exynos5 SoCs Chipid driver.
+
+Required properties:
+- compatible : Should at least contain "samsung,exynos4210-chipid". More
+       specific compatible string specify which SoC version (exynos4 or
+       exynos5) are paired with.
+  Details:
+  samsung,exynos4-chipid: Exynos4 SoCs has Chip ID block that can provide
+       product id, revision number and package information.
+       It has different product-id bit-mask than Exynos5 series SoC.
+  samsung,exynos5-chipid: Exynos5 SoCs has Chip ID block that can provide
+       product id, revision number and package information.
+       It has different product-id bit-mask then Exynos4 series SoC.
+
Quoted 8 lines

Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt line 21

Quoted 7 lines
Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt new file +7 -0
+- reg: offset and length of the register set
+
+Example:
+       chipid@10000000 {
+               compatible = "samsung,exynos4210-chipid", "samsung,exynos4-chipid";
+               reg = <0x10000000 0x100>;
+       };

This needs to go with the patch adding the driver.

OK, will make this along with driver.

Quoted 280 lines
Quoted 18 lines
arch/arm/Kconfig +1 -0
index a4eac2f..06f14a4 100644
@@ -856,6 +856,7 @@ config ARCH_EXYNOS
         select SRAM
         select USE_OF
         select MFD_SYSCON
+       select EXYNOS_CHIPID
         help
           Support for SAMSUNG's EXYNOS SoCs (EXYNOS4/5)
 
arch/arm/boot/dts/exynos4.dtsi +0 -0
index 2f8bcd0..d4c0657 100644

arch/arm/boot/dts/exynos4.dtsi line 49

Quoted 5 lines
arch/arm/boot/dts/exynos4.dtsi +1 -1
@@ -46,7 +46,7 @@
         };
 
         chipid@10000000 {
-               compatible = "samsung,exynos4210-chipid";
+               compatible = "samsung,exynos4210-chipid", "samsung,exynos4-chipid";

Only 4210-chipid. We normally don't use generic names on any drivers (we might on system level, but not on drivers).

arch/arm/boot/dts/exynos5.dtsi line 22

Quoted 13 lines
arch/arm/boot/dts/exynos4.dtsi +0 -0
                 reg = <0x10000000 0x100>;
         };
 
arch/arm/boot/dts/exynos5.dtsi +1 -1
index 3027e37..1d0b569 100644
@@ -19,7 +19,7 @@
         interrupt-parent = <&gic>;
 
         chipid@10000000 {
-               compatible = "samsung,exynos4210-chipid";
+               compatible = "samsung,exynos4210-chipid", "samsung,exynos5-chipid";

Same here. Each SoC should probably have:

samsung,exynos<soc>-chipid, samsung,exynos4210-chipid

At least if you think there will ever be a difference in how the driver has to work when interacting with this IP block compared to 4210.

Quoted 132 lines
arch/arm/boot/dts/exynos5.dtsi +0 -0
                 reg = <0x10000000 0x100>;
         };
 
arch/arm/mach-exynos/exynos.c +9 -38
index 9902e52..26f5e8c 100644
@@ -21,6 +21,7 @@
  #include <linux/pm_domain.h>
  #include <linux/mfd/syscon.h>
  #include <linux/regmap.h>
+#include <linux/exynos-soc.h>
 
  #include <asm/cacheflush.h>
  #include <asm/hardware/cache-l2x0.h>
@@ -28,7 +29,6 @@
  #include <asm/mach/map.h>
  #include <asm/memory.h>
 
-#include <plat/cpu.h>
  #include <mach/map.h>
 
  #include "common.h"
@@ -171,29 +171,6 @@ static void __init exynos_init_late(void)
         exynos_pm_init();
  }
 
-static int __init exynos_fdt_map_chipid(unsigned long node, const char *uname,
-                                       int depth, void *data)
-{
-       struct map_desc iodesc;
-       __be32 *reg;
-       unsigned long len;
-
-       if (!of_flat_dt_is_compatible(node, "samsung,exynos4210-chipid") &&
-               !of_flat_dt_is_compatible(node, "samsung,exynos5440-clock"))
-               return 0;
-
-       reg = of_get_flat_dt_prop(node, "reg", &len);
-       if (reg == NULL || len != (sizeof(unsigned long) * 2))
-               return 0;
-
-       iodesc.pfn = __phys_to_pfn(be32_to_cpu(reg[0]));
-       iodesc.length = be32_to_cpu(reg[1]) - 1;
-       iodesc.virtual = (unsigned long)S5P_VA_CHIPID;
-       iodesc.type = MT_DEVICE;
-       iotable_init(&iodesc, 1);
-       return 1;
-}
-
  static const struct of_device_id exynos_dt_pmu_match[] = {
         { .compatible = "samsung,exynos4210-pmu" },
         { .compatible = "samsung,exynos4212-pmu" },
@@ -202,25 +179,15 @@ static const struct of_device_id exynos_dt_pmu_match[] = {
         {},
  };
 
-static void __init exynos_init_io(void)
-{
-       debug_ll_io_init();
-
-       of_scan_flat_dt(exynos_fdt_map_chipid, NULL);
-
-       /* detect cpu id and rev. */
-       s5p_init_cpu(S5P_VA_CHIPID);
-}
-
  static void __init exynos5_init_io(void)
  {
-       exynos_init_io();
+       debug_ll_io_init();
         iotable_init(exynos5_iodesc, ARRAY_SIZE(exynos5_iodesc));
  }
 
  static void __init exynos4_init_io(void)
  {
-       exynos_init_io();
+       debug_ll_io_init();
         iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc));
  }
 
@@ -279,14 +246,18 @@ void __init exynos_map_pmu(void)
 
  static void __init exynos_dt_machine_init(void)
  {
+       struct device *parent;
+
         exynos_map_pmu();
 
-       if (!soc_is_exynos5440())
+       parent = exynos_soc_device_init();
+
+       if (is_soc_id_compatible(EXYNOS5440))
                 platform_device_register(&exynos_cpuidle);
 
         platform_device_register_simple("exynos-cpufreq", -1, NULL, 0);
 
-       of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
+       of_platform_populate(NULL, of_default_bus_match_table, NULL, parent);
  }
 
  static char const *exynos4_dt_compat[] __initconst = {
arch/arm/mach-exynos/platsmp.c +3 -2
index d0482c2..9d6ec84 100644
@@ -20,13 +20,13 @@
  #include <linux/smp.h>
  #include <linux/io.h>
  #include <linux/of_address.h>
+#include <linux/exynos-soc.h>
 
  #include <asm/cacheflush.h>
  #include <asm/smp_plat.h>
  #include <asm/smp_scu.h>
  #include <asm/firmware.h>
 
-#include <plat/cpu.h>
  #include <mach/map.h>
 
  #include "common.h"
@@ -59,7 +59,8 @@ static void __init exynos_smp_prepare_sram(void)
 
  static inline void __iomem *cpu_boot_reg_base(void)
  {
-       if (soc_is_exynos4210() && samsung_rev() == EXYNOS4210_REV_1_1)
+       if (is_soc_id_compatible(EXYNOS4210) &&
+                       is_soc_rev_compatible(EXYNOS4210_REV_1_1))
                 return pmu_base + S5P_INFORM5;
 
         return sram_base_addr;

arch/arm/mach-exynos/platsmp.c static inline void __iomem *cpu_boot_reg(int cpu) · line 80

Quoted 10 lines
arch/arm/mach-exynos/platsmp.c +3 -2
@@ -72,9 +73,10 @@ static inline void __iomem *cpu_boot_reg(int cpu)
         boot_reg = cpu_boot_reg_base();
         if (!boot_reg)
                 return ERR_PTR(-ENODEV);
-       if (soc_is_exynos4412())
+
+       if (is_soc_id_compatible(EXYNOS4412))
                 boot_reg += 4*cpu;
-       else if (soc_is_exynos5420())
+       else if (is_soc_id_compatible(EXYNOS5420))
                 boot_reg += 4;

This won't work much longer. You'll need to add another check for any other SoC that has another register layout. This is probably one of these cases where it makes more sense to describe the register offset/layout in the DT.

Quoted 85 lines
arch/arm/mach-exynos/platsmp.c +1 -0
         return boot_reg;
  }
@@ -264,6 +266,7 @@ static void __init exynos_smp_init_cpus(void)
  static void __init exynos_smp_prepare_cpus(unsigned int max_cpus)
  {
         int i;
+       early_exynos_chipid_init();
 
         pmu_base = pmu_base_addr();
 
arch/arm/mach-exynos/pm.c +9 -9
index 59e5604..5cb5449 100644
@@ -22,13 +22,13 @@
  #include <linux/err.h>
  #include <linux/clk.h>
  #include <linux/regmap.h>
+#include <linux/exynos-soc.h>
 
  #include <asm/cacheflush.h>
  #include <asm/hardware/cache-l2x0.h>
  #include <asm/smp_scu.h>
  #include <asm/suspend.h>
 
-#include <plat/cpu.h>
  #include <plat/pm-common.h>
  #include <plat/pll.h>
  #include <plat/regs-srom.h>
@@ -82,7 +82,7 @@ static int exynos_irq_set_wake(struct irq_data *data, unsigned int state)
  {
         const struct exynos_wkup_irq *wkup_irq;
 
-       if (soc_is_exynos5250())
+       if (is_soc_id_compatible(EXYNOS5250))
                 wkup_irq = exynos5250_wkup_irq;
         else
                 wkup_irq = exynos4_wkup_irq;
@@ -101,11 +101,11 @@ static int exynos_irq_set_wake(struct irq_data *data, unsigned int state)
         return -ENOENT;
  }
 
-#define EXYNOS_BOOT_VECTOR_ADDR        (samsung_rev() == EXYNOS4210_REV_1_1 ? \
-                       S5P_INFORM7 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \
+#define EXYNOS_BOOT_VECTOR_ADDR        (is_soc_rev_compatible(EXYNOS4210_REV_1_1) ? \
+                       S5P_INFORM7 : (is_soc_rev_compatible(EXYNOS4210_REV_1_0) ? \
                         0x24 : S5P_INFORM0))
-#define EXYNOS_BOOT_VECTOR_FLAG        (samsung_rev() == EXYNOS4210_REV_1_1 ? \
-                       S5P_INFORM6 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \
+#define EXYNOS_BOOT_VECTOR_FLAG        (is_soc_rev_compatible(EXYNOS4210_REV_1_1) ? \
+                       S5P_INFORM6 : (is_soc_rev_compatible(EXYNOS4210_REV_1_0) ? \
                         0x20 : S5P_INFORM1))
 
  #define S5P_CHECK_AFTR  0xFCBA0D10
@@ -119,7 +119,7 @@ static void exynos_set_wakeupmask(long mask)
 
  static void exynos_cpu_set_boot_vector(long flags)
  {
-       if (samsung_rev() == EXYNOS4210_REV_1_0) {
+       if (is_soc_rev_compatible(EXYNOS4210_REV_1_0)) {
                 __raw_writel(virt_to_phys(exynos_cpu_resume),
                                 S5P_VA_SYSRAM + EXYNOS_BOOT_VECTOR_ADDR);
                 __raw_writel(flags, S5P_VA_SYSRAM + EXYNOS_BOOT_VECTOR_FLAG);
@@ -183,7 +183,7 @@ static int exynos_cpu_suspend(unsigned long arg)
         outer_flush_all();
  #endif
 
-       if (soc_is_exynos5250())
+       if (is_soc_id_compatible(EXYNOS5250))
                 flush_cache_all();
 
         /* issue the standby signal into the pm unit. */
@@ -205,7 +205,7 @@ static void exynos_pm_prepare(void)
 
         s3c_pm_do_save(exynos_core_save, ARRAY_SIZE(exynos_core_save));
 
-       if (soc_is_exynos5250()) {
+       if (is_soc_id_compatible(EXYNOS5250)) {
                 /* Disable USE_RETENTION of JPEG_MEM_OPTION */
                 regmap_read(pmu_regmap, EXYNOS5_JPEG_MEM_OPTION, &tmp);
                 tmp &= ~EXYNOS5_OPTION_USE_RETENTION;
@@ -243,7 +243,7 @@ static int exynos_pm_suspend(void)
         tmp = (S5P_USE_STANDBY_WFI0 | S5P_USE_STANDBY_WFE0);
         regmap_write(pmu_regmap, S5P_CENTRAL_SEQ_OPTION, tmp);
 
Quoted 6 lines

arch/arm/mach-exynos/pm.c static int exynos_pm_suspend(void) · line 247

Quoted 3 lines
arch/arm/mach-exynos/pm.c +1 -1
-       if (!soc_is_exynos5250())
+       if (!is_soc_id_compatible(EXYNOS5250))
                 exynos_cpu_save_register();

These kind of constructs don't work well, you will have to address them too. I know there'll be need for code here for 5420/5422 already, for example.

Well in "pm.c" we are doing many SoC specific stuffs. So until all these are not being handled in generic way, I could not see we can get rid of such if/else. If we do not use "is_soc_id_compatible" then it might be old "soc_is_exynosXYZ" or as you said it might be "is_soc_compatible" any case we would end up doing if/else.

Only advantage in choosing chipid driver APIs or "is_soc_compatible" API I can see that it will allow us to get rid of #ifdef based macros soc_is_exynosxyz, which requires Kconfig changes also. Otherwise every time new SoC comes (e.g Exynos5260, and Exynos5410) we will see more and more such additions.

In my attempt to remove such usage from mach-exynos, I have done for two files (exynos.c and pmu.c) in different patch sets, and hope in near future we should be able to get rid of such things from left over files such as platsmp.c and pm.c.

Quoted 9 lines
Quoted 9 lines
drivers/clk/samsung/clk-exynos4.c +0 -0
index b4f9672..7b0ea1f 100644
@@ -1030,7 +1030,7 @@ static unsigned long exynos4_get_xom(void)
         void __iomem *chipid_base;
         struct device_node *np;
 
Quoted 3 lines

drivers/clk/samsung/clk-exynos4.c static unsigned long exynos4_get_xom(void) · line 1033

Quoted 2 lines
drivers/clk/samsung/clk-exynos4.c +1 -1
-       np = of_find_compatible_node(NULL, NULL, "samsung,exynos4210-chipid");
+       np = of_find_compatible_node(NULL, NULL, "samsung,exynos4-chipid");

This should likely still say 4210.

OK.

Quoted 43 lines
Quoted 21 lines
drivers/clk/samsung/clk-exynos4.c +0 -0
         if (np) {
                 chipid_base = of_iomap(np, 0);
 
drivers/cpufreq/exynos-cpufreq.c +1 -2
index f99cfe2..5fe84a1 100644
@@ -17,8 +17,7 @@
  #include <linux/regulator/consumer.h>
  #include <linux/cpufreq.h>
  #include <linux/platform_device.h>
-
-#include <plat/cpu.h>
+#include <linux/exynos-soc.h>
 
  #include "exynos-cpufreq.h"
 
@@ -163,11 +162,11 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
         if (!exynos_info)
                 return -ENOMEM;

drivers/cpufreq/exynos-cpufreq.c static int exynos_cpufreq_probe(struct platform_device *pdev) · line 170

Quoted 10 lines
drivers/cpufreq/exynos-cpufreq.c +3 -3
 
-       if (soc_is_exynos4210())
+       if (is_soc_id_compatible(EXYNOS4210))
                 ret = exynos4210_cpufreq_init(exynos_info);
-       else if (soc_is_exynos4212() || soc_is_exynos4412())
+       else if (is_soc_id_compatible(EXYNOS4212) || is_soc_id_compatible(EXYNOS4412))
                 ret = exynos4x12_cpufreq_init(exynos_info);
-       else if (soc_is_exynos5250())
+       else if (is_soc_id_compatible(EXYNOS5250))
                 ret = exynos5250_cpufreq_init(exynos_info);

Many drivers tend to use of_machine_is_compatible here. I wonder if that'll solve most of your problems in a more generic way. Any machine based on an SoC should have the SoC somewhere in the compatible array for the board anyway.

Actually, I think using that approach in most of your patch set will remove the need for the chipid driver alltogether, and just using machine compatibles instead.

-Olof

Signature · 2 lines
Best Regards,
Pankaj Dubey
#11 lore raw

v3 cover Introducing Exynos ChipId driver

In reply to [email protected]

This patch series attempts to get rid of soc_is_exynosXXXX macros and eventually with the help of this series we can probably get rid of CONFIG_SOC_EXYNOSXXXX in near future.
Each Exynos SoC has ChipID block which can give information about SoC's product Id and revision number. Currently we have single DT binding information for this as "samsung,exynos4210-chipid". But Exynos4 and Exynos5 SoC series have one small difference in chip Id, with resepect to product id bit-masks. So it means we should have separate compatible string for these different series of SoCs. So I have added second compatible string for handling this difference.
This patch series is based on Kukjin Kim's for-next (3.14_rc1 tag) and prepared on top of following patch series and it's dependent patch series.

[1]: Map SYSRAM through generic SRAM bindings by Sachin Kamat.

	http://www.spinics.net/lists/arm-kernel/msg327677.html
[2]: Exynos PMU cleanup and refactoring.
	https://lkml.org/lkml/2014/4/30/44
[3]: Introduce drivers/soc and add QCOM GSBI driver.
	https://lkml.org/lkml/2014/4/24/520

Revision 2 and it's discussion can be found here
- https://lkml.org/lkml/2014/5/6/100

Changes since v2:
- Reorganized patches as suggested by Tomasz Figa.
- Addressed review comments of Tomasz Figa in i2c-s3c2410.c file.

Changes since v1:
- Added patch to move i2c interrupt re-configuration code from exynos.c to i2c driver, as suggested by Arnd.
- After above patch only user of SYS_I2C_CFG register is pm.c so moving save/restore of this register also into i2c driver.
- Spiltted up exynos4 and exynos5 machine descriptors to get rid from soc_is_exynos4/exynos5 kind of macros, as suggested by Arnd.
- Changed location of chipid driver to "drivers/soc".
- Added drivers/base/soc.c provided infrastructure to make SoC specific information avaible to user space via sysfs entry, as suggested by Arnd.

Pankaj Dubey (6):
i2c: s3c2410: Handle i2c sys_cfg register in i2c driver
ARM: EXYNOS: Remove i2c sys configuration related code
ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c
ARM: EXYNOS: Remove unused header inclusion from hotplug.c
soc: samsung: exynos-chipid: Add Exynos Chipid driver support
ARM: EXYNOS: Refactoring to remove soc_is_exynos macros from exynos

 .../bindings/arm/samsung/exynos-chipid.txt         |   21 +++
 .../devicetree/bindings/arm/samsung/sysreg.txt     |    1 +
 arch/arm/Kconfig                                   |    1 +
 arch/arm/boot/dts/exynos4.dtsi                     |    2 +-
 arch/arm/boot/dts/exynos5.dtsi                     |    7 +-
 arch/arm/boot/dts/exynos5250.dtsi                  |    4 +
 arch/arm/boot/dts/exynos5420.dtsi                  |    4 +
 arch/arm/mach-exynos/exynos.c                      |  119 ++++----------
 arch/arm/mach-exynos/hotplug.c                     |    2 -
 arch/arm/mach-exynos/include/mach/map.h            |    3 -
 arch/arm/mach-exynos/platsmp.c                     |   11 +-
 arch/arm/mach-exynos/pm.c                          |   36 ++---
 arch/arm/mach-exynos/regs-sys.h                    |   22 ---
 arch/arm/plat-samsung/include/plat/cpu.h           |   60 -------
 drivers/clk/samsung/clk-exynos4.c                  |    2 +-
 drivers/cpufreq/exynos-cpufreq.c                   |    9 +-
 drivers/cpufreq/exynos-cpufreq.h                   |    1 -
 drivers/cpufreq/exynos4x12-cpufreq.c               |    5 +-
 drivers/i2c/busses/i2c-s3c2410.c                   |   32 ++++
 drivers/soc/Kconfig                                |    1 +
 drivers/soc/Makefile                               |    1 +
 drivers/soc/samsung/Kconfig                        |   10 ++
 drivers/soc/samsung/Makefile                       |    1 +
 drivers/soc/samsung/exynos-chipid.c                |  166 ++++++++++++++++++++
 include/linux/exynos-soc.h                         |   46 ++++++
 25 files changed, 357 insertions(+), 210 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt
 delete mode 100644 arch/arm/mach-exynos/regs-sys.h
 create mode 100644 drivers/soc/samsung/Kconfig
 create mode 100644 drivers/soc/samsung/Makefile
 create mode 100644 drivers/soc/samsung/exynos-chipid.c
 create mode 100644 include/linux/exynos-soc.h
Signature · 1 line
1.7.10.4
#12 lore raw

PATCH v3 1/6 i2c: s3c2410: Handle i2c sys_cfg register in i2c driver

Let's handle i2c interrupt re-configuration in i2c driver. This will help us in removing some soc specific checks from machine files. Since only Exynos5250, and Exynos5420 need to do this, added syscon based phandle to i2c device nodes of respective SoC DT files. Also handle saving and restoring of SYS_I2C_CFG register during suspend and resume of i2c driver. This will help in removing soc specific check from mach-exynos/pm.c.

---
 .../devicetree/bindings/arm/samsung/sysreg.txt     |    1 +
 arch/arm/boot/dts/exynos5.dtsi                     |    5 +++
 arch/arm/boot/dts/exynos5250.dtsi                  |    4 +++
 arch/arm/boot/dts/exynos5420.dtsi                  |    4 +++
 drivers/i2c/busses/i2c-s3c2410.c                   |   32 ++++++++++++++++++++
 5 files changed, 46 insertions(+)
Documentation/devicetree/bindings/arm/samsung/sysreg.txt +1 -0
index 0ab3251..fd71581 100644
@@ -3,6 +3,7 @@ SAMSUNG S5P/Exynos SoC series System Registers (SYSREG)
 Properties:
  - compatible : should contain "samsung,<chip name>-sysreg", "syscon";
    For Exynos4 SoC series it should be "samsung,exynos4-sysreg", "syscon";
+   For Exynos5 SoC series it should be "samsung,exynos5-sysreg", "syscon";
  - reg : offset and length of the register set.
 
 Example:
arch/arm/boot/dts/exynos5.dtsi +5 -0
index 79d0608..3027e37 100644
@@ -99,4 +99,9 @@
 		#size-cells = <0>;
 		status = "disabled";
 	};
+
+	sys_reg: syscon@10050000 {
+		compatible = "samsung,exynos5-sysreg", "syscon";
+		reg = <0x10050000 0x400>;
+	};
 };
arch/arm/boot/dts/exynos5250.dtsi +4 -0
index 8d724d5..46f0233 100644
@@ -285,6 +285,7 @@
 		clock-names = "i2c";
 		pinctrl-names = "default";
 		pinctrl-0 = <&i2c0_bus>;
+		samsung,syscon-phandle = <&sys_reg>;
 		status = "disabled";
 	};
 
@@ -298,6 +299,7 @@
 		clock-names = "i2c";
 		pinctrl-names = "default";
 		pinctrl-0 = <&i2c1_bus>;
+		samsung,syscon-phandle = <&sys_reg>;
 		status = "disabled";
 	};
 
@@ -311,6 +313,7 @@
 		clock-names = "i2c";
 		pinctrl-names = "default";
 		pinctrl-0 = <&i2c2_bus>;
+		samsung,syscon-phandle = <&sys_reg>;
 		status = "disabled";
 	};
 
@@ -324,6 +327,7 @@
 		clock-names = "i2c";
 		pinctrl-names = "default";
 		pinctrl-0 = <&i2c3_bus>;
+		samsung,syscon-phandle = <&sys_reg>;
 		status = "disabled";
 	};
 
arch/arm/boot/dts/exynos5420.dtsi +4 -0
index ff496ad..762128c 100644
@@ -517,6 +517,7 @@
 		clock-names = "i2c";
 		pinctrl-names = "default";
 		pinctrl-0 = <&i2c0_bus>;
+		samsung,syscon-phandle = <&sys_reg>;
 		status = "disabled";
 	};
 
@@ -530,6 +531,7 @@
 		clock-names = "i2c";
 		pinctrl-names = "default";
 		pinctrl-0 = <&i2c1_bus>;
+		samsung,syscon-phandle = <&sys_reg>;
 		status = "disabled";
 	};
 
@@ -543,6 +545,7 @@
 		clock-names = "i2c";
 		pinctrl-names = "default";
 		pinctrl-0 = <&i2c2_bus>;
+		samsung,syscon-phandle = <&sys_reg>;
 		status = "disabled";
 	};
 
@@ -556,6 +559,7 @@
 		clock-names = "i2c";
 		pinctrl-names = "default";
 		pinctrl-0 = <&i2c3_bus>;
+		samsung,syscon-phandle = <&sys_reg>;
 		status = "disabled";
 	};
 
drivers/i2c/busses/i2c-s3c2410.c +32 -0
index ae44910..e707062 100644
@@ -39,6 +39,8 @@
 #include <linux/of.h>
 #include <linux/of_gpio.h>
 #include <linux/pinctrl/consumer.h>
+#include <linux/mfd/syscon.h>
+#include <linux/regmap.h>
 
 #include <asm/irq.h>
 
@@ -91,6 +93,9 @@
 /* Max time to wait for bus to become idle after a xfer (in us) */
 #define S3C2410_IDLE_TIMEOUT	5000
 
+/* Exynos5 Sysreg offset */
+#define EXYNOS5_SYS_I2C_CFG	0x0234
+
 /* i2c controller state */
 enum s3c24xx_i2c_state {
 	STATE_IDLE,
@@ -127,6 +132,8 @@ struct s3c24xx_i2c {
 #if defined(CONFIG_ARM_S3C24XX_CPUFREQ)
 	struct notifier_block	freq_transition;
 #endif
+	struct regmap		*sysreg;
+	unsigned int		sys_i2s_cfg;
 };
 
 static struct platform_device_id s3c24xx_driver_ids[] = {
@@ -1075,6 +1082,8 @@ static void
 s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c)
 {
 	struct s3c2410_platform_i2c *pdata = i2c->pdata;
+	u32 val = 0;
+	int id;
 
 	if (!np)
 		return;
@@ -1084,6 +1093,23 @@ s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c)
 	of_property_read_u32(np, "samsung,i2c-slave-addr", &pdata->slave_addr);
 	of_property_read_u32(np, "samsung,i2c-max-bus-freq",
 				(u32 *)&pdata->frequency);
+	/*
+	 * Exynos5's legacy i2c controller and new high speed i2c
+	 * controller have muxed interrupt sources. By default the
+	 * interrupts for 4-channel HS-I2C controller are enabled.
+	 * If node for first four channels of legacy i2c controller
+	 * are available then re-configure the interrupts via the
+	 * system register.
+	 */
+	id = of_alias_get_id(np, "i2c");
+	i2c->sysreg = syscon_regmap_lookup_by_phandle(np,
+			"samsung,syscon-phandle");
+	if (IS_ERR(i2c->sysreg)) {
+		/* As this is not compulsory do not return error */
+		pr_info("i2c-%d skipping re-configuration of interrutps\n", id);
+		return;
+	}
+	regmap_update_bits(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, BIT(id), val);
 }
 #else
 static void
@@ -1268,6 +1294,9 @@ static int s3c24xx_i2c_suspend_noirq(struct device *dev)
 
 	i2c->suspended = 1;
 
+	if (!IS_ERR(i2c->sysreg))
+		regmap_read(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, &i2c->sys_i2s_cfg);
+
 	return 0;
 }
 
@@ -1276,6 +1305,9 @@ static int s3c24xx_i2c_resume(struct device *dev)
 	struct platform_device *pdev = to_platform_device(dev);
 	struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
 
+	if (!IS_ERR(i2c->sysreg))
+		regmap_write(i2c->sysreg, i2c->sys_i2s_cfg, EXYNOS5_SYS_I2C_CFG);
+
 	i2c->suspended = 0;
 	clk_prepare_enable(i2c->clk);
 	s3c24xx_i2c_init(i2c);
Signature · 1 line
1.7.10.4
#13 lore raw

Re: [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver

Quoted 8 lines · Pankaj Dubey

Let's handle i2c interrupt re-configuration in i2c driver. This will help us in removing some soc specific checks from machine files. Since only Exynos5250, and Exynos5420 need to do this, added syscon based phandle to i2c device nodes of respective SoC DT files. Also handle saving and restoring of SYS_I2C_CFG register during suspend and resume of i2c driver. This will help in removing soc specific check from mach-exynos/pm.c.

Quoted 8 lines
CC Rob Herring <[email protected]>
CC Randy Dunlap <[email protected]>
CC Wolfram Sang <[email protected]>
CC Russell King <[email protected]>
CC devicetree at vger.kernel.org
CC linux-doc at vger.kernel.org
CC linux-i2c at vger.kernel.org

Shall this go via i2c-tree? Looks to me like it should go with the rest of the series? Patch is mostly okay (only reviewed the code, not the bindings), one nit:

drivers/i2c/busses/i2c-s3c2410.c s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) · line 1112

Quoted 1 line
drivers/i2c/busses/i2c-s3c2410.c +1 -0
+	regmap_update_bits(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, BIT(id), val);

Hardcode the '0' and drop using 'val'?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140602/40aacffb/attachment.sig>

#14 lore raw

Re: [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver

In reply to Pankaj Dubey

Hi Pankaj,

Quoted 16 lines · Pankaj Dubey

Let's handle i2c interrupt re-configuration in i2c driver. This will help us in removing some soc specific checks from machine files. Since only Exynos5250, and Exynos5420 need to do this, added syscon based phandle to i2c device nodes of respective SoC DT files. Also handle saving and restoring of SYS_I2C_CFG register during suspend and resume of i2c driver. This will help in removing soc specific check from mach-exynos/pm.c.

CC Rob Herring <[email protected]>
CC Randy Dunlap <[email protected]>
CC Wolfram Sang <[email protected]>
CC Russell King <[email protected]>
CC devicetree at vger.kernel.org
CC linux-doc at vger.kernel.org
CC linux-i2c at vger.kernel.org
Quoted 5 lines
---
 .../devicetree/bindings/arm/samsung/sysreg.txt     |    1 +
 arch/arm/boot/dts/exynos5.dtsi                     |    5 +++
 arch/arm/boot/dts/exynos5250.dtsi                  |    4 +++
 arch/arm/boot/dts/exynos5420.dtsi                  |    4 +++

What about Exynos5410 and Exynos5800?

Quoted 2 lines
 drivers/i2c/busses/i2c-s3c2410.c                   |   32 ++++++++++++++++++++
 5 files changed, 46 insertions(+)

[snip]

Quoted 24 lines
drivers/i2c/busses/i2c-s3c2410.c +5 -0
index ae44910..e707062 100644
@@ -39,6 +39,8 @@
 #include <linux/of.h>
 #include <linux/of_gpio.h>
 #include <linux/pinctrl/consumer.h>
+#include <linux/mfd/syscon.h>
+#include <linux/regmap.h>
 
 #include <asm/irq.h>
 
@@ -91,6 +93,9 @@
 /* Max time to wait for bus to become idle after a xfer (in us) */
 #define S3C2410_IDLE_TIMEOUT	5000
 
+/* Exynos5 Sysreg offset */
+#define EXYNOS5_SYS_I2C_CFG	0x0234
+
 /* i2c controller state */
 enum s3c24xx_i2c_state {
 	STATE_IDLE,

drivers/i2c/busses/i2c-s3c2410.c struct s3c24xx_i2c { · line 136

Quoted 5 lines
drivers/i2c/busses/i2c-s3c2410.c +2 -0
@@ -127,6 +132,8 @@ struct s3c24xx_i2c {
 #if defined(CONFIG_ARM_S3C24XX_CPUFREQ)
 	struct notifier_block	freq_transition;
 #endif
+	struct regmap		*sysreg;
+	unsigned int		sys_i2s_cfg;

typo: s/i2s/i2c/

Quoted 13 lines
drivers/i2c/busses/i2c-s3c2410.c +2 -0
 };
 
 static struct platform_device_id s3c24xx_driver_ids[] = {
@@ -1075,6 +1082,8 @@ static void
 s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c)
 {
 	struct s3c2410_platform_i2c *pdata = i2c->pdata;
+	u32 val = 0;
+	int id;
 
 	if (!np)
 		return;

drivers/i2c/busses/i2c-s3c2410.c s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) · line 1098

Quoted 6 lines
drivers/i2c/busses/i2c-s3c2410.c +3 -0
@@ -1084,6 +1093,23 @@ s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c)
 	of_property_read_u32(np, "samsung,i2c-slave-addr", &pdata->slave_addr);
 	of_property_read_u32(np, "samsung,i2c-max-bus-freq",
 				(u32 *)&pdata->frequency);
+	/*
+	 * Exynos5's legacy i2c controller and new high speed i2c
+	 * controller have muxed interrupt sources. By default the

What do you mean by "by default"? Is it a setting from the bootloader or reset value?

Probably to ensure that the mux is set correctly, same thing should be also added to hsi2c driver.

Quoted 4 lines
drivers/i2c/busses/i2c-s3c2410.c +4 -0
+	 * interrupts for 4-channel HS-I2C controller are enabled.
+	 * If node for first four channels of legacy i2c controller
+	 * are available then re-configure the interrupts via the
+	 * system register.

drivers/i2c/busses/i2c-s3c2410.c s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) · line 1112

Quoted 10 lines
drivers/i2c/busses/i2c-s3c2410.c +10 -0
+	 */
+	id = of_alias_get_id(np, "i2c");
+	i2c->sysreg = syscon_regmap_lookup_by_phandle(np,
+			"samsung,syscon-phandle");
+	if (IS_ERR(i2c->sysreg)) {
+		/* As this is not compulsory do not return error */
+		pr_info("i2c-%d skipping re-configuration of interrutps\n", id);
+		return;
+	}
+	regmap_update_bits(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, BIT(id), val);

As Wolfram pointed, val can be replaced with immediate 0 here.

Quoted 14 lines
drivers/i2c/busses/i2c-s3c2410.c +3 -0
 }
 #else
 static void
@@ -1268,6 +1294,9 @@ static int s3c24xx_i2c_suspend_noirq(struct device *dev)
 
 	i2c->suspended = 1;
 
+	if (!IS_ERR(i2c->sysreg))
+		regmap_read(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, &i2c->sys_i2s_cfg);
+
 	return 0;
 }
 

drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_resume(struct device *dev) · line 1309

Quoted 5 lines
drivers/i2c/busses/i2c-s3c2410.c +2 -0
@@ -1276,6 +1305,9 @@ static int s3c24xx_i2c_resume(struct device *dev)
 	struct platform_device *pdev = to_platform_device(dev);
 	struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
 
+	if (!IS_ERR(i2c->sysreg))
+		regmap_write(i2c->sysreg, i2c->sys_i2s_cfg, EXYNOS5_SYS_I2C_CFG);

According to include/linux/regmap.h:

int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);

So in your code reg is swapped with val.

Best regards,
Tomasz

#15 lore raw

RE: [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver

Hi Tomasz,

Quoted 26 lines

Hi Pankaj,

Quoted 16 lines · Pankaj Dubey

Let's handle i2c interrupt re-configuration in i2c driver. This will help us in removing some soc specific checks from machine files. Since only Exynos5250, and Exynos5420 need to do this, added syscon based phandle to i2c device nodes of respective SoC DT files. Also handle saving and restoring of SYS_I2C_CFG register during suspend and resume of i2c driver. This will help in removing soc specific check from mach-exynos/pm.c.

Quoted 5 lines
---
 .../devicetree/bindings/arm/samsung/sysreg.txt     |    1 +
 arch/arm/boot/dts/exynos5.dtsi                     |    5 +++
 arch/arm/boot/dts/exynos5250.dtsi                  |    4 +++
 arch/arm/boot/dts/exynos5420.dtsi                  |    4 +++
Quoted 1 line

What about Exynos5410 and Exynos5800?

OK, I will check user manuals of these two SoCs and if required will update.

Quoted 25 lines
Quoted 2 lines
 drivers/i2c/busses/i2c-s3c2410.c                   |   32

++++++++++++++++++++

Quoted 1 line
 5 files changed, 46 insertions(+)

[snip]

Quoted 18 lines
drivers/i2c/busses/i2c-s3c2410.c +2 -0
index ae44910..e707062 100644
@@ -39,6 +39,8 @@
 #include <linux/of.h>
 #include <linux/of_gpio.h>
 #include <linux/pinctrl/consumer.h>
+#include <linux/mfd/syscon.h>
+#include <linux/regmap.h>
 
 #include <asm/irq.h>
 
@@ -91,6 +93,9 @@
 /* Max time to wait for bus to become idle after a xfer (in us) */
 #define S3C2410_IDLE_TIMEOUT	5000
 
Quoted 14 lines

drivers/i2c/busses/i2c-s3c2410.c struct s3c24xx_i2c { #if · line 136

Quoted 12 lines
drivers/i2c/busses/i2c-s3c2410.c +5 -0
+/* Exynos5 Sysreg offset */
+#define EXYNOS5_SYS_I2C_CFG	0x0234
+
 /* i2c controller state */
 enum s3c24xx_i2c_state {
 	STATE_IDLE,
@@ -127,6 +132,8 @@ struct s3c24xx_i2c {  #if
 defined(CONFIG_ARM_S3C24XX_CPUFREQ)
 	struct notifier_block	freq_transition;
 #endif
+	struct regmap		*sysreg;
+	unsigned int		sys_i2s_cfg;

typo: s/i2s/i2c/

Oops, sorry I will correct this.

Quoted 10 lines
Quoted 10 lines
drivers/i2c/busses/i2c-s3c2410.c +1 -0
 };
 
 static struct platform_device_id s3c24xx_driver_ids[] = { @@ -1075,6
+1082,8 @@ static void  s3c24xx_i2c_parse_dt(struct device_node *np,

struct s3c24xx_i2c *i2c) {

drivers/i2c/busses/i2c-s3c2410.c +2 -0
 	struct s3c2410_platform_i2c *pdata = i2c->pdata;
+	u32 val = 0;
+	int id;
Quoted 3 lines

drivers/i2c/busses/i2c-s3c2410.c s3c24xx_i2c_parse_dt(struct device_node *np,

Quoted 3 lines
drivers/i2c/busses/i2c-s3c2410.c +0 -0
 	if (!np)
 		return;
@@ -1084,6 +1093,23 @@ s3c24xx_i2c_parse_dt(struct device_node *np,

struct

Quoted 2 lines

s3c24xx_i2c *i2c)

Quoted 1 line
drivers/i2c/busses/i2c-s3c2410.c +0 -0
 	of_property_read_u32(np, "samsung,i2c-slave-addr",

&pdata->slave_addr);

Quoted 7 lines

drivers/i2c/busses/i2c-s3c2410.c s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) · line 1098

Quoted 5 lines
drivers/i2c/busses/i2c-s3c2410.c +3 -0
 	of_property_read_u32(np, "samsung,i2c-max-bus-freq",
 				(u32 *)&pdata->frequency);
+	/*
+	 * Exynos5's legacy i2c controller and new high speed i2c
+	 * controller have muxed interrupt sources. By default the

What do you mean by "by default"? Is it a setting from the bootloader or

reset value?

Quoted 1 line

It's a reset value.

Quoted 1 line

Probably to ensure that the mux is set correctly, same thing should be

also added to

Quoted 13 lines

hsi2c driver.

drivers/i2c/busses/i2c-s3c2410.c s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c)

Quoted 11 lines
drivers/i2c/busses/i2c-s3c2410.c +11 -0
+	 * interrupts for 4-channel HS-I2C controller are enabled.
+	 * If node for first four channels of legacy i2c controller
+	 * are available then re-configure the interrupts via the
+	 * system register.
+	 */
+	id = of_alias_get_id(np, "i2c");
+	i2c->sysreg = syscon_regmap_lookup_by_phandle(np,
+			"samsung,syscon-phandle");
+	if (IS_ERR(i2c->sysreg)) {
+		/* As this is not compulsory do not return error */
+		pr_info("i2c-%d skipping re-configuration of interrutps\n",

id);

Quoted 5 lines

drivers/i2c/busses/i2c-s3c2410.c s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) · line 1112

Quoted 3 lines
drivers/i2c/busses/i2c-s3c2410.c +3 -0
+		return;
+	}
+	regmap_update_bits(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, BIT(id), val);

As Wolfram pointed, val can be replaced with immediate 0 here.

OK, I will take care as per suggestion.

Quoted 24 lines
Quoted 17 lines
drivers/i2c/busses/i2c-s3c2410.c +3 -0
 }
 #else
 static void
@@ -1268,6 +1294,9 @@ static int s3c24xx_i2c_suspend_noirq(struct
 device *dev)
 
 	i2c->suspended = 1;
 
+	if (!IS_ERR(i2c->sysreg))
+		regmap_read(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, &i2c-
 sys_i2s_cfg);
+
 	return 0;

}

drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_resume(struct device *dev) · line 1309

Quoted 5 lines
drivers/i2c/busses/i2c-s3c2410.c +2 -0
@@ -1276,6 +1305,9 @@ static int s3c24xx_i2c_resume(struct device *dev)
 	struct platform_device *pdev = to_platform_device(dev);
 	struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
 
+	if (!IS_ERR(i2c->sysreg))
+		regmap_write(i2c->sysreg, i2c->sys_i2s_cfg,

EXYNOS5_SYS_I2C_CFG);

Quoted 5 lines

According to include/linux/regmap.h:

int regmap_write(struct regmap *map, unsigned int reg, unsigned int val);

So in your code reg is swapped with val.

Yes. I will correct this.

Quoted 3 lines

Best regards,
Tomasz

#16 lore raw

PATCH v3 2/6 ARM: EXYNOS: Remove i2c sys configuration related code

In reply to Pankaj Dubey

Since all these code has been moved into i2c driver, now we can safely remove them from machine files.

---
 arch/arm/mach-exynos/exynos.c           |   38 +------------------------------
 arch/arm/mach-exynos/include/mach/map.h |    3 ---
 arch/arm/mach-exynos/pm.c               |   10 --------
 arch/arm/mach-exynos/regs-sys.h         |   22 ------------------
 4 files changed, 1 insertion(+), 72 deletions(-)
 delete mode 100644 arch/arm/mach-exynos/regs-sys.h
arch/arm/mach-exynos/exynos.c +1 -37
index 59eb1f1..09063ee 100644
@@ -29,11 +29,11 @@
 #include <asm/memory.h>
 
 #include <plat/cpu.h>
+#include <mach/map.h>
 
 #include "common.h"
 #include "mfc.h"
 #include "regs-pmu.h"
-#include "regs-sys.h"
 
 #define L2_AUX_VAL 0x7C470001
 #define L2_AUX_MASK 0xC200ffff
@@ -42,11 +42,6 @@ static struct regmap *exynos_pmu_regmap;
 
 static struct map_desc exynos4_iodesc[] __initdata = {
 	{
-		.virtual	= (unsigned long)S3C_VA_SYS,
-		.pfn		= __phys_to_pfn(EXYNOS4_PA_SYSCON),
-		.length		= SZ_64K,
-		.type		= MT_DEVICE,
-	}, {
 		.virtual	= (unsigned long)S3C_VA_TIMER,
 		.pfn		= __phys_to_pfn(EXYNOS4_PA_TIMER),
 		.length		= SZ_16K,
@@ -116,11 +111,6 @@ static struct map_desc exynos4_iodesc[] __initdata = {
 
 static struct map_desc exynos5_iodesc[] __initdata = {
 	{
-		.virtual	= (unsigned long)S3C_VA_SYS,
-		.pfn		= __phys_to_pfn(EXYNOS5_PA_SYSCON),
-		.length		= SZ_64K,
-		.type		= MT_DEVICE,
-	}, {
 		.virtual	= (unsigned long)S3C_VA_TIMER,
 		.pfn		= __phys_to_pfn(EXYNOS5_PA_TIMER),
 		.length		= SZ_16K,
@@ -293,32 +283,6 @@ void __init exynos_map_pmu(void)
 
 static void __init exynos_dt_machine_init(void)
 {
-	struct device_node *i2c_np;
-	const char *i2c_compat = "samsung,s3c2440-i2c";
-	unsigned int tmp;
-	int id;
-
-	/*
-	 * Exynos5's legacy i2c controller and new high speed i2c
-	 * controller have muxed interrupt sources. By default the
-	 * interrupts for 4-channel HS-I2C controller are enabled.
-	 * If node for first four channels of legacy i2c controller
-	 * are available then re-configure the interrupts via the
-	 * system register.
-	 */
-	if (soc_is_exynos5()) {
-		for_each_compatible_node(i2c_np, NULL, i2c_compat) {
-			if (of_device_is_available(i2c_np)) {
-				id = of_alias_get_id(i2c_np, "i2c");
-				if (id < 4) {
-					tmp = readl(EXYNOS5_SYS_I2C_CFG);
-					writel(tmp & ~(0x1 << id),
-							EXYNOS5_SYS_I2C_CFG);
-				}
-			}
-		}
-	}
-
 	exynos_map_pmu();
 
 	if (!soc_is_exynos5440())
arch/arm/mach-exynos/include/mach/map.h +0 -3
index 34eee6e..bd4a320 100644
@@ -25,9 +25,6 @@
 
 #define EXYNOS_PA_CHIPID		0x10000000
 
-#define EXYNOS4_PA_SYSCON		0x10010000
-#define EXYNOS5_PA_SYSCON		0x10050100
-
 #define EXYNOS4_PA_CMU			0x10030000
 #define EXYNOS5_PA_CMU			0x10010000
 
arch/arm/mach-exynos/pm.c +0 -10
index a7a1b7f..59e5604 100644
@@ -37,7 +37,6 @@
 
 #include "common.h"
 #include "regs-pmu.h"
-#include "regs-sys.h"
 #include "exynos-pmu.h"
 
 static struct regmap *pmu_regmap;
@@ -52,10 +51,6 @@ struct exynos_wkup_irq {
 	u32 mask;
 };
 
-static struct sleep_save exynos5_sys_save[] = {
-	SAVE_ITEM(EXYNOS5_SYS_I2C_CFG),
-};
-
 static struct sleep_save exynos_core_save[] = {
 	/* SROM side */
 	SAVE_ITEM(S5P_SROM_BW),
@@ -211,7 +206,6 @@ static void exynos_pm_prepare(void)
 	s3c_pm_do_save(exynos_core_save, ARRAY_SIZE(exynos_core_save));
 
 	if (soc_is_exynos5250()) {
-		s3c_pm_do_save(exynos5_sys_save, ARRAY_SIZE(exynos5_sys_save));
 		/* Disable USE_RETENTION of JPEG_MEM_OPTION */
 		regmap_read(pmu_regmap, EXYNOS5_JPEG_MEM_OPTION, &tmp);
 		tmp &= ~EXYNOS5_OPTION_USE_RETENTION;
@@ -296,10 +290,6 @@ static void exynos_pm_resume(void)
 	regmap_write(pmu_regmap, S5P_PAD_RET_EBIA_OPTION, (1 << 28));
 	regmap_write(pmu_regmap, S5P_PAD_RET_EBIB_OPTION, (1 << 28));
 
-	if (soc_is_exynos5250())
-		s3c_pm_do_restore(exynos5_sys_save,
-			ARRAY_SIZE(exynos5_sys_save));
-
 	s3c_pm_do_restore_core(exynos_core_save, ARRAY_SIZE(exynos_core_save));
 
 	if (!soc_is_exynos5250())
arch/arm/mach-exynos/regs-sys.h deleted +0 -22
deleted file mode 100644
index 84332b0..0000000
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *             http://www.samsung.com
- *
- * EXYNOS - system register definition
- *
- * 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 __ASM_ARCH_REGS_SYS_H
-#define __ASM_ARCH_REGS_SYS_H __FILE__
-
-#include <mach/map.h>
-
-#define S5P_SYSREG(x)                          (S3C_VA_SYS + (x))
-
-/* For EXYNOS5 */
-#define EXYNOS5_SYS_I2C_CFG                    S5P_SYSREG(0x0234)
-
-#endif /* __ASM_ARCH_REGS_SYS_H */
Signature · 1 line
1.7.10.4
Reviewed-by on v3 2/6
#17 lore raw

Re: [PATCH v3 2/6] ARM: EXYNOS: Remove i2c sys configuration related code

Hi Pankaj,

Quoted 31 lines · Pankaj Dubey

Since all these code has been moved into i2c driver, now we can safely remove them from machine files.

---
 arch/arm/mach-exynos/exynos.c           |   38 +------------------------------
 arch/arm/mach-exynos/include/mach/map.h |    3 ---
 arch/arm/mach-exynos/pm.c               |   10 --------
 arch/arm/mach-exynos/regs-sys.h         |   22 ------------------
 4 files changed, 1 insertion(+), 72 deletions(-)
 delete mode 100644 arch/arm/mach-exynos/regs-sys.h
arch/arm/mach-exynos/exynos.c +1 -1
index 59eb1f1..09063ee 100644
@@ -29,11 +29,11 @@
 #include <asm/memory.h>
 
 #include <plat/cpu.h>
+#include <mach/map.h>
 
 #include "common.h"
 #include "mfc.h"
 #include "regs-pmu.h"
-#include "regs-sys.h"
 
 #define L2_AUX_VAL 0x7C470001
 #define L2_AUX_MASK 0xC200ffff

arch/arm/mach-exynos/exynos.c static struct regmap *exynos_pmu_regmap; · line 48

Quoted 7 lines
arch/arm/mach-exynos/exynos.c +0 -4
@@ -42,11 +42,6 @@ static struct regmap *exynos_pmu_regmap;
 
 static struct map_desc exynos4_iodesc[] __initdata = {
 	{
-		.virtual	= (unsigned long)S3C_VA_SYS,
-		.pfn		= __phys_to_pfn(EXYNOS4_PA_SYSCON),
-		.length		= SZ_64K,
-		.type		= MT_DEVICE,

Rest of this patch doesn't touch anything related to Exynos4, but I boot-tested removing this on Exynos4412-based Trats2 board and it works, so

Best regards,
Tomasz

#18 lore raw

PATCH v3 3/6 ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c

In reply to Pankaj Dubey

This patch removes usage of soc_is_exynos4/5 from exynos.c. For this we need to separate machine descriptors for exynos4 and exynos5. While doing this patch does some consolidation also.

CC Russell King <[email protected]>
CC Thomas Abraham <[email protected]>
---
 arch/arm/mach-exynos/exynos.c            |   52 +++++++++++++++++++-----------
 arch/arm/plat-samsung/include/plat/cpu.h |    3 --
 2 files changed, 33 insertions(+), 22 deletions(-)
arch/arm/mach-exynos/exynos.c +33 -19
index 09063ee..9902e52 100644
@@ -202,20 +202,6 @@ static const struct of_device_id exynos_dt_pmu_match[] = {
 	{},
 };
 
-/*
- * exynos_map_io
- *
- * register the standard cpu IO areas
- */
-static void __init exynos_map_io(void)
-{
-	if (soc_is_exynos4())
-		iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc));
-
-	if (soc_is_exynos5())
-		iotable_init(exynos5_iodesc, ARRAY_SIZE(exynos5_iodesc));
-}
-
 static void __init exynos_init_io(void)
 {
 	debug_ll_io_init();
@@ -224,8 +210,18 @@ static void __init exynos_init_io(void)
 
 	/* detect cpu id and rev. */
 	s5p_init_cpu(S5P_VA_CHIPID);
+}
+
+static void __init exynos5_init_io(void)
+{
+	exynos_init_io();
+	iotable_init(exynos5_iodesc, ARRAY_SIZE(exynos5_iodesc));
+}
 
-	exynos_map_io();
+static void __init exynos4_init_io(void)
+{
+	exynos_init_io();
+	iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc));
 }
 
 struct bus_type exynos_subsys = {
@@ -293,11 +289,15 @@ static void __init exynos_dt_machine_init(void)
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 }
 
-static char const *exynos_dt_compat[] __initconst = {
+static char const *exynos4_dt_compat[] __initconst = {
 	"samsung,exynos4",
 	"samsung,exynos4210",
 	"samsung,exynos4212",
 	"samsung,exynos4412",
+	NULL
+};
+
+static char const *exynos5_dt_compat[] __initconst = {
 	"samsung,exynos5",
 	"samsung,exynos5250",
 	"samsung,exynos5420",
@@ -321,15 +321,29 @@ static void __init exynos_reserve(void)
 #endif
 }
 
-DT_MACHINE_START(EXYNOS_DT, "SAMSUNG EXYNOS (Flattened Device Tree)")
+DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS (Flattened Device Tree)")
+	/* Maintainer: Thomas Abraham <[email protected]> */
+	/* Maintainer: Kukjin Kim <[email protected]> */
+	.smp		= smp_ops(exynos_smp_ops),
+	.map_io		= exynos5_init_io,
+	.init_early	= exynos_firmware_init,
+	.init_machine	= exynos_dt_machine_init,
+	.init_late	= exynos_init_late,
+	.dt_compat	= exynos5_dt_compat,
+	.restart	= exynos_restart,
+	.reserve	= exynos_reserve,
+MACHINE_END
+
+
+DT_MACHINE_START(EXYNOS4_DT, "SAMSUNG EXYNOS (Flattened Device Tree)")
 	/* Maintainer: Thomas Abraham <[email protected]> */
 	/* Maintainer: Kukjin Kim <[email protected]> */
 	.smp		= smp_ops(exynos_smp_ops),
-	.map_io		= exynos_init_io,
+	.map_io		= exynos4_init_io,
 	.init_early	= exynos_firmware_init,
 	.init_machine	= exynos_dt_machine_init,
 	.init_late	= exynos_init_late,
-	.dt_compat	= exynos_dt_compat,
+	.dt_compat	= exynos4_dt_compat,
 	.restart	= exynos_restart,
 	.reserve	= exynos_reserve,
 MACHINE_END
arch/arm/plat-samsung/include/plat/cpu.h +0 -3
index 5992b8d..18a9a00 100644
@@ -166,9 +166,6 @@ IS_SAMSUNG_CPU(exynos5440, EXYNOS5440_SOC_ID, EXYNOS5_SOC_MASK)
 # define soc_is_exynos5440()	0
 #endif
 
-#define soc_is_exynos4() (soc_is_exynos4210() || soc_is_exynos4212() || \
-			  soc_is_exynos4412())
-#define soc_is_exynos5() (soc_is_exynos5250() || soc_is_exynos5420())
 
 #define IODESC_ENT(x) { (unsigned long)S3C24XX_VA_##x, __phys_to_pfn(S3C24XX_PA_##x), S3C24XX_SZ_##x, MT_DEVICE }
 
Signature · 1 line
1.7.10.4
#19 lore raw

Re: [PATCH v3 3/6] ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c

Quoted 4 lines · Pankaj Dubey

This patch removes usage of soc_is_exynos4/5 from exynos.c. For this we need to separate machine descriptors for exynos4 and exynos5. While doing this patch does some consolidation also.

Quoted 8 lines
CC Russell King <[email protected]>
CC Thomas Abraham <[email protected]>
---
 arch/arm/mach-exynos/exynos.c            |   52 +++++++++++++++++++-----------
 arch/arm/plat-samsung/include/plat/cpu.h |    3 --
 2 files changed, 33 insertions(+), 22 deletions(-)

I don't think this is needed. All those static mappings should just go away, which will also eliminate the need to have separate machine descriptor or soc_is_exynos{4,5}() macros.

Best regards,
Tomasz

#20 lore raw

Re: [PATCH v3 3/6] ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c

Quoted 14 lines · On Tuesday 10 June 2014 15:55:09 Tomasz Figa wrote:
Quoted 4 lines · Pankaj Dubey

This patch removes usage of soc_is_exynos4/5 from exynos.c. For this we need to separate machine descriptors for exynos4 and exynos5. While doing this patch does some consolidation also.

Quoted 8 lines
CC Russell King <[email protected]>
CC Thomas Abraham <[email protected]>
---
 arch/arm/mach-exynos/exynos.c            |   52 +++++++++++++++++++-----------
 arch/arm/plat-samsung/include/plat/cpu.h |    3 --
 2 files changed, 33 insertions(+), 22 deletions(-)
Quoted 3 lines

I don't think this is needed. All those static mappings should just go away, which will also eliminate the need to have separate machine descriptor or soc_is_exynos{4,5}() macros.

I think I suggested doing this patch as an intermediate step to get rid of the macros first, so we don't get any new users. I agree that we should also remove the static mappings eventually, and once we do that, the machine descriptors can be unified again.

I have not checked which of the map_desc entries are currently used at all, or what it would take to remove them.

Arnd

#21 lore raw

PATCH v3 4/6 ARM: EXYNOS: Remove unused header inclusion from hotplug.c

In reply to Pankaj Dubey

This patch removed "plat/cpu.h" inclusion from hotplug.c as it is not required.

---
 arch/arm/mach-exynos/hotplug.c |    2 --
 1 file changed, 2 deletions(-)
arch/arm/mach-exynos/hotplug.c +0 -2
index 0243ef3..5e19601 100644
@@ -19,8 +19,6 @@
 #include <asm/cp15.h>
 #include <asm/smp_plat.h>
 
-#include <plat/cpu.h>
-
 #include "common.h"
 #include "regs-pmu.h"
 
Signature · 1 line
1.7.10.4
#22 lore raw

Re: [PATCH v3 4/6] ARM: EXYNOS: Remove unused header inclusion from hotplug.c

Hi Pankaj,

Quoted 14 lines · Pankaj Dubey

This patch removed "plat/cpu.h" inclusion from hotplug.c as it is not required.

---
 arch/arm/mach-exynos/hotplug.c |    2 --
 1 file changed, 2 deletions(-)
arch/arm/mach-exynos/hotplug.c +0 -0
index 0243ef3..5e19601 100644

arch/arm/mach-exynos/hotplug.c line 24

Quoted 8 lines
arch/arm/mach-exynos/hotplug.c +0 -2
@@ -19,8 +19,6 @@
 #include <asm/cp15.h>
 #include <asm/smp_plat.h>
 
-#include <plat/cpu.h>
-
 #include "common.h"
 #include "regs-pmu.h"
 

I don't see this header being included in current linux-next.

Best regards,
Tomasz

#23 lore raw

RE: [PATCH v3 4/6] ARM: EXYNOS: Remove unused header inclusion from hotplug.c

Hi Tomasz,

Quoted 21 lines

-----Original Message-----

Hi Pankaj,

Quoted 16 lines · Pankaj Dubey

This patch removed "plat/cpu.h" inclusion from hotplug.c as it is not required.

---
 arch/arm/mach-exynos/hotplug.c |    2 --
 1 file changed, 2 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-exynos/hotplug.c index 0243ef3..5e19601 100644

arch/arm/mach-exynos/hotplug.c +0 -0
@@ -19,8 +19,6 @@
 #include <asm/cp15.h>
 #include <asm/smp_plat.h>
 
Quoted 9 lines

arch/arm/mach-exynos/hotplug.c line 24

Quoted 6 lines
arch/arm/mach-exynos/hotplug.c +0 -2
-#include <plat/cpu.h>
-
 #include "common.h"
 #include "regs-pmu.h"
 

I don't see this header being included in current linux-next.

OK, if it's already taken care, I will drop this change in next version.

Quoted 2 lines

Best regards,
Tomasz

Thanks,
Pankaj Dubey

#24 lore raw

PATCH v3 5/6 soc: samsung: exynos-chipid: Add Exynos Chipid driver support

In reply to Pankaj Dubey

Exynos SoCs have Chipid, for identification of product IDs and SoC revistions. Till now we are using static macros such as soc_is_exynosNNNN and #ifdefs for run time identification of SoCs and their revisions. This is leading to add new Kconfig, soc_is_exynosNNNN definitions each time new SoC support is getting added. So this driver intends to provide initialization code all these functionalites and thus helping in removing macros.

---
 drivers/soc/Kconfig                 |    1 +
 drivers/soc/Makefile                |    1 +
 drivers/soc/samsung/Kconfig         |   10 +++
 drivers/soc/samsung/Makefile        |    1 +
 drivers/soc/samsung/exynos-chipid.c |  166 +++++++++++++++++++++++++++++++++++
 include/linux/exynos-soc.h          |   46 ++++++++++
 6 files changed, 225 insertions(+)
 create mode 100644 drivers/soc/samsung/Kconfig
 create mode 100644 drivers/soc/samsung/Makefile
 create mode 100644 drivers/soc/samsung/exynos-chipid.c
 create mode 100644 include/linux/exynos-soc.h
drivers/soc/Kconfig +1 -0
index 07a11be..86e52b1 100644
@@ -1,5 +1,6 @@
 menu "SOC specific Drivers"
 
 source "drivers/soc/qcom/Kconfig"
+source "drivers/soc/samsung/Kconfig"
 
 endmenu
drivers/soc/Makefile +1 -0
index 0f7c447..ee890aa 100644
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_ARCH_QCOM)		+= qcom/
+obj-$(CONFIG_ARCH_EXYNOS)	+= samsung/
drivers/soc/samsung/Kconfig new file +10 -0
new file mode 100644
index 0000000..dacc95d
@@ -0,0 +1,10 @@
+
+# SAMSUNG Soc drivers
+#
+config EXYNOS_CHIPID
+	tristate "Support Exynos CHIPID"
+	default y
+	select SOC_BUS
+	depends on ARCH_EXYNOS || ARM64
+	help
+	  If you say Y here you get support for the Exynos CHIP id.
drivers/soc/samsung/Makefile new file +1 -0
new file mode 100644
index 0000000..855ca05
@@ -0,0 +1 @@
+obj-$(CONFIG_EXYNOS_CHIPID)	+= exynos-chipid.o
drivers/soc/samsung/exynos-chipid.c new file +166 -0

166 lines not on this page · raw message

include/linux/exynos-soc.h new file +46 -0

46 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#25 lore raw

Re: [PATCH v3 5/6] soc: samsung: exynos-chipid: Add Exynos Chipid driver support

Hi Pankaj,

Quoted 38 lines · Pankaj Dubey

Exynos SoCs have Chipid, for identification of product IDs and SoC revistions. Till now we are using static macros such as soc_is_exynosNNNN and #ifdefs for run time identification of SoCs and their revisions. This is leading to add new Kconfig, soc_is_exynosNNNN definitions each time new SoC support is getting added. So this driver intends to provide initialization code all these functionalites and thus helping in removing macros.

---
 drivers/soc/Kconfig                 |    1 +
 drivers/soc/Makefile                |    1 +
 drivers/soc/samsung/Kconfig         |   10 +++
 drivers/soc/samsung/Makefile        |    1 +
 drivers/soc/samsung/exynos-chipid.c |  166 +++++++++++++++++++++++++++++++++++
 include/linux/exynos-soc.h          |   46 ++++++++++
 6 files changed, 225 insertions(+)
 create mode 100644 drivers/soc/samsung/Kconfig
 create mode 100644 drivers/soc/samsung/Makefile
 create mode 100644 drivers/soc/samsung/exynos-chipid.c
 create mode 100644 include/linux/exynos-soc.h
drivers/soc/Kconfig +1 -0
index 07a11be..86e52b1 100644
@@ -1,5 +1,6 @@
 menu "SOC specific Drivers"
 
 source "drivers/soc/qcom/Kconfig"
+source "drivers/soc/samsung/Kconfig"
 
 endmenu
drivers/soc/Makefile +0 -0
index 0f7c447..ee890aa 100644

drivers/soc/Makefile line 6

Quoted 4 lines
drivers/soc/Makefile +1 -0
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_ARCH_QCOM)		+= qcom/
+obj-$(CONFIG_ARCH_EXYNOS)	+= samsung/

EXYNOS or samsung/?

Also this is just a single file, is it necessary to create a directory for it?

Quoted 6 lines
drivers/soc/samsung/Kconfig new file +0 -0
new file mode 100644
index 0000000..dacc95d

drivers/soc/samsung/Kconfig line 10

Quoted 10 lines
drivers/soc/samsung/Kconfig new file +10 -0
@@ -0,0 +1,10 @@
+
+# SAMSUNG Soc drivers
+#
+config EXYNOS_CHIPID
+	tristate "Support Exynos CHIPID"
+	default y
+	select SOC_BUS
+	depends on ARCH_EXYNOS || ARM64
+	help
+	  If you say Y here you get support for the Exynos CHIP id.

Do we need to have this user-selectable? Couldn't we just have it selected by ARCH_EXYNOS and its 64-bit counterpart? AFAIK per-family Kconfig symbols are already present (see ARCH_VEXPRESS and ARCH_XGENE in arch/arm64/Kconfig), so it is not a problem.

Quoted 23 lines
drivers/soc/samsung/Makefile new file +1 -0
new file mode 100644
index 0000000..855ca05
@@ -0,0 +1 @@
+obj-$(CONFIG_EXYNOS_CHIPID)	+= exynos-chipid.o
drivers/soc/samsung/exynos-chipid.c new file +10 -0
new file mode 100644
index 0000000..b5bccd9
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *	      http://www.samsung.com/
+ *
+ * EXYNOS - CHIP ID support
+ * Author: Pankaj Dubey <[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.

drivers/soc/samsung/exynos-chipid.c line 20

Quoted 10 lines
drivers/soc/samsung/exynos-chipid.c new file +10 -0
+ */
+
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/slab.h>
+#include <linux/sys_soc.h>
+#include <linux/of_address.h>
+#include <linux/exynos-soc.h>
+
+#define EXYNOS4_SOC_MASK	0xFFFE0

Even though I can see the mask defined in current code to the value above, the documentation states that the whole bit field [31:12] is used for product ID, so it should be safe to use the same mask as for Exynos5.

drivers/soc/samsung/exynos-chipid.c line 26

Quoted 6 lines
drivers/soc/samsung/exynos-chipid.c new file +6 -0
+#define EXYNOS5_SOC_MASK	0xFFFFF
+
+#define PROD_ID_SHIFT	(12)
+
+static void __iomem	*exynos_chipid_base;
+unsigned int exynos_soc_id = EXYNOS_SOC_UNKNOWN;

static?

drivers/soc/samsung/exynos-chipid.c line 27

Quoted 1 line
drivers/soc/samsung/exynos-chipid.c new file +1 -0
+enum exynos_soc_revision exynos_revision;

static?

Quoted 14 lines
drivers/soc/samsung/exynos-chipid.c new file +14 -0
+
+struct exynos_chipid_data {
+	unsigned int product_id_mask;
+	unsigned int product_id_shift;
+};
+
+static struct exynos_chipid_data exynos4_chipid_data = {
+	.product_id_mask	= EXYNOS4_SOC_MASK,
+	.product_id_shift	= PROD_ID_SHIFT,
+};
+
+static struct exynos_chipid_data exynos5_chipid_data = {
+	.product_id_mask	= EXYNOS5_SOC_MASK,
+	.product_id_shift	= PROD_ID_SHIFT,

drivers/soc/samsung/exynos-chipid.c line 51

Quoted 10 lines
drivers/soc/samsung/exynos-chipid.c new file +10 -0
+};
+
+static struct of_device_id of_exynos_chipid_ids[] = {
+	{
+		.compatible	= "samsung,exynos4-chipid",
+		.data		= (void *)&exynos4_chipid_data,
+	},
+	{
+		.compatible	= "samsung,exynos5-chipid",
+		.data		= (void *)&exynos5_chipid_data,

We already have "samsung,exynos4210-chipid" compatible string defined and used in existing device tree sources (and deployed DTBs).

drivers/soc/samsung/exynos-chipid.c line 64

Quoted 13 lines
drivers/soc/samsung/exynos-chipid.c new file +13 -0
+	},
+	{},
+};
+
+bool is_soc_id_compatible(enum exynos_soc_id soc_id)
+{
+	return soc_id == exynos_soc_id;
+}
+
+bool is_soc_rev_compatible(enum exynos_soc_revision soc_rev)
+{
+	return soc_rev == exynos_revision;
+}

I don't think we need this API. (See below.)

Quoted 92 lines
drivers/soc/samsung/exynos-chipid.c new file +92 -0
+
+static const char *exynos_soc_id_to_name(enum exynos_soc_id id)
+{
+	const char *soc_name;
+	switch (id) {
+	case EXYNOS4210:
+		soc_name = "EXYNOS4210";
+		break;
+	case EXYNOS4212:
+		soc_name = "EXYNOS4212";
+		break;
+	case EXYNOS4412:
+		soc_name = "EXYNOS4412";
+		break;
+	case EXYNOS5250:
+		soc_name = "EXYNOS5250";
+		break;
+	case EXYNOS5420:
+		soc_name = "EXYNOS5420";
+		break;
+	case EXYNOS5440:
+		soc_name = "EXYNOS5440";
+		break;
+	default:
+		soc_name = "";
+	}
+	return soc_name;
+}
+
+struct device * __init exynos_soc_device_init(void)
+{
+	struct soc_device_attribute *soc_dev_attr;
+	struct soc_device *exynos_soc_dev;
+	struct device_node *root;
+	int ret;
+
+	if (!exynos_chipid_base)
+		early_exynos_chipid_init();
+
+	soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
+	if (!soc_dev_attr)
+		return NULL;
+
+	soc_dev_attr->family = "Samsung Exynos";
+
+	root = of_find_node_by_path("/");
+	ret = of_property_read_string(root, "model", &soc_dev_attr->machine);
+	of_node_put(root);
+	if (ret)
+		goto free_soc;
+
+	soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d", exynos_revision);
+	if (!soc_dev_attr->revision)
+		goto free_soc;
+
+	soc_dev_attr->soc_id = exynos_soc_id_to_name(exynos_soc_id);
+
+	exynos_soc_dev = soc_device_register(soc_dev_attr);
+	if (IS_ERR(exynos_soc_dev))
+		goto free_rev;
+
+	return soc_device_to_device(exynos_soc_dev);
+
+free_rev:
+	kfree(soc_dev_attr->revision);
+free_soc:
+	kfree(soc_dev_attr);
+	return NULL;
+}
+
+/**
+ * early_exynos_chipid_init - Early chipid initialization
+ */
+void __init early_exynos_chipid_init(void)
+{
+	struct device_node *np = NULL;
+	const struct of_device_id *match;
+	struct exynos_chipid_data *chipid_data;
+	int pro_id;
+
+	if (!exynos_chipid_base) {
+		np = of_find_matching_node_and_match(NULL,
+				of_exynos_chipid_ids, &match);
+		if (!np)
+			panic("%s, failed to find chipid node\n", __func__);
+
+		chipid_data = (struct exynos_chipid_data *) match->data;
+		exynos_chipid_base = of_iomap(np, 0);
+
+		if (!exynos_chipid_base)
+			panic("%s: failed to map registers\n", __func__);
+

drivers/soc/samsung/exynos-chipid.c line 166

Quoted 10 lines
drivers/soc/samsung/exynos-chipid.c new file +10 -0
+		pro_id  = __raw_readl(exynos_chipid_base);
+		exynos_soc_id = (pro_id >> chipid_data->product_id_shift)
+			& chipid_data->product_id_mask;
+		exynos_revision = pro_id & 0xFF;
+		pr_info("Exynos: CPU[%s] CPU_REV[0x%x] Detected\n",
+				exynos_soc_id_to_name(exynos_soc_id),
+				exynos_revision);
+	}
+
+}

Basically this API is not much better than soc_is_exynos*(). The goal is to get rid of per-SoC checks, not provide another API to do this.

In general, a SoC driver may be useful, though. So my proposal is to strip the whole questionable API from this driver, make it a platform driver and let it simply register the SoC device.

Quoted 15 lines
include/linux/exynos-soc.h new file +9 -0
new file mode 100644
index 0000000..ebd4366
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *		http://www.samsung.com
+ *
+ * Header for EXYNOS SoC Chipid support
+ *
+ * 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.

include/linux/exynos-soc.h line 19

Quoted 10 lines
include/linux/exynos-soc.h new file +10 -0
+ */
+
+#ifndef __EXYNOS_SOC_H
+#define __EXYNOS_SOC_H
+
+/* enum holding product id of Exynos SoC
+ * Any new Exynos SoC product id should be added here
+ */
+enum exynos_soc_id {
+	EXYNOS4210 = 0xE4210,

This is not the correct ID of Exynos4210. The correct one is 0x43210.

include/linux/exynos-soc.h line 20

Quoted 1 line
include/linux/exynos-soc.h new file +1 -0
+	EXYNOS4212 = 0xE4212,

Should be 0x43220.

Quoted 5 lines
include/linux/exynos-soc.h new file +5 -0
+	EXYNOS4412 = 0xE4412,
+	EXYNOS5250 = 0x43520,
+	EXYNOS5420 = 0xE5420,
+	EXYNOS5440 = 0xE5440,
+	EXYNOS_SOC_UNKNOWN = -1,

include/linux/exynos-soc.h line 35

Quoted 10 lines
include/linux/exynos-soc.h new file +10 -0
+};
+
+/* enum holding revision id of Exynos SoC
+ * Any new Exynos SoC revision id should be added here
+ */
+enum exynos_soc_revision {
+	EXYNOS4210_REV_0	= 0x0,
+	EXYNOS4210_REV_1_0	= 0x10,
+	EXYNOS4210_REV_1_1	= 0x11,
+};

AFAIK, considering my comments above, both SoC and revision IDs can be defined as macros inside the .c file.

Best regards,
Tomasz

#26 lore raw

PATCH v3 6/6 ARM: EXYNOS: Refactoring to remove soc_is_exynos macros from exynos

In reply to Pankaj Dubey

This patch enables chipid driver for ARCH_EXYNOS and refactors machine code as well as exynos cpufreq driver code for using chipid driver for identification of SoC ID and SoC rev.

This patch also updates DT binding information in exynos4 and exynos5 dtsi file. As to differentiate product id bit-mask we need separate compatible string for exynos4 and exynos5. Hoping this will be helpful in future as bit-mask and bit-shift bit may differ. Added binding information as well.

---
 .../bindings/arm/samsung/exynos-chipid.txt         |   21 ++++++++
 arch/arm/Kconfig                                   |    1 +
 arch/arm/boot/dts/exynos4.dtsi                     |    2 +-
 arch/arm/boot/dts/exynos5.dtsi                     |    2 +-
 arch/arm/mach-exynos/exynos.c                      |   47 ++++------------
 arch/arm/mach-exynos/platsmp.c                     |   11 ++--
 arch/arm/mach-exynos/pm.c                          |   26 ++++-----
 arch/arm/plat-samsung/include/plat/cpu.h           |   57 --------------------
 drivers/clk/samsung/clk-exynos4.c                  |    2 +-
 drivers/cpufreq/exynos-cpufreq.c                   |    9 ++--
 drivers/cpufreq/exynos-cpufreq.h                   |    1 -
 drivers/cpufreq/exynos4x12-cpufreq.c               |    5 +-
 12 files changed, 61 insertions(+), 123 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt
Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt new file +21 -0
new file mode 100644
index 0000000..a496459
@@ -0,0 +1,21 @@
+SAMSUNG Exynos4/Exynos5 SoCs Chipid driver.
+
+Required properties:
+- compatible : Should at least contain "samsung,exynos4210-chipid". More
+	specific compatible string specify which SoC version (exynos4 or
+	exynos5) are paired with.
+  Details:
+  samsung,exynos4-chipid: Exynos4 SoCs has Chip ID block that can provide
+	product id, revision number and package information.
+	It has different product-id bit-mask than Exynos5 series SoC.
+  samsung,exynos5-chipid: Exynos5 SoCs has Chip ID block that can provide
+	product id, revision number and package information.
+	It has different product-id bit-mask then Exynos4 series SoC.
+
+- reg: offset and length of the register set
+
+Example:
+	chipid@10000000 {
+		compatible = "samsung,exynos4210-chipid", "samsung,exynos4-chipid";
+		reg = <0x10000000 0x100>;
+	};
arch/arm/Kconfig +1 -0
index a4eac2f..06f14a4 100644
@@ -856,6 +856,7 @@ config ARCH_EXYNOS
 	select SRAM
 	select USE_OF
 	select MFD_SYSCON
+	select EXYNOS_CHIPID
 	help
 	  Support for SAMSUNG's EXYNOS SoCs (EXYNOS4/5)
 
arch/arm/boot/dts/exynos4.dtsi +1 -1
index 2f8bcd0..d4c0657 100644
@@ -46,7 +46,7 @@
 	};
 
 	chipid@10000000 {
-		compatible = "samsung,exynos4210-chipid";
+		compatible = "samsung,exynos4210-chipid", "samsung,exynos4-chipid";
 		reg = <0x10000000 0x100>;
 	};
 
arch/arm/boot/dts/exynos5.dtsi +1 -1
index 3027e37..1d0b569 100644
@@ -19,7 +19,7 @@
 	interrupt-parent = <&gic>;
 
 	chipid@10000000 {
-		compatible = "samsung,exynos4210-chipid";
+		compatible = "samsung,exynos4210-chipid", "samsung,exynos5-chipid";
 		reg = <0x10000000 0x100>;
 	};
 
arch/arm/mach-exynos/exynos.c +9 -38

90 lines not on this page · raw message

arch/arm/mach-exynos/platsmp.c +7 -4
index d0482c2..9d6ec84 100644
@@ -20,13 +20,13 @@
 #include <linux/smp.h>
 #include <linux/io.h>
 #include <linux/of_address.h>
+#include <linux/exynos-soc.h>
 
 #include <asm/cacheflush.h>
 #include <asm/smp_plat.h>
 #include <asm/smp_scu.h>
 #include <asm/firmware.h>
 
-#include <plat/cpu.h>
 #include <mach/map.h>
 
 #include "common.h"
@@ -59,7 +59,8 @@ static void __init exynos_smp_prepare_sram(void)
 
 static inline void __iomem *cpu_boot_reg_base(void)
 {
-	if (soc_is_exynos4210() && samsung_rev() == EXYNOS4210_REV_1_1)
+	if (is_soc_id_compatible(EXYNOS4210) &&
+			is_soc_rev_compatible(EXYNOS4210_REV_1_1))
 		return pmu_base + S5P_INFORM5;
 
 	return sram_base_addr;
@@ -72,9 +73,10 @@ static inline void __iomem *cpu_boot_reg(int cpu)
 	boot_reg = cpu_boot_reg_base();
 	if (!boot_reg)
 		return ERR_PTR(-ENODEV);
-	if (soc_is_exynos4412())
+
+	if (is_soc_id_compatible(EXYNOS4412))
 		boot_reg += 4*cpu;
-	else if (soc_is_exynos5420())
+	else if (is_soc_id_compatible(EXYNOS5420))
 		boot_reg += 4;
 	return boot_reg;
 }
@@ -264,6 +266,7 @@ static void __init exynos_smp_init_cpus(void)
 static void __init exynos_smp_prepare_cpus(unsigned int max_cpus)
 {
 	int i;
+	early_exynos_chipid_init();
 
 	pmu_base = pmu_base_addr();
 
arch/arm/mach-exynos/pm.c +13 -13
index 59e5604..5cb5449 100644
@@ -22,13 +22,13 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/regmap.h>
+#include <linux/exynos-soc.h>
 
 #include <asm/cacheflush.h>
 #include <asm/hardware/cache-l2x0.h>
 #include <asm/smp_scu.h>
 #include <asm/suspend.h>
 
-#include <plat/cpu.h>
 #include <plat/pm-common.h>
 #include <plat/pll.h>
 #include <plat/regs-srom.h>
@@ -82,7 +82,7 @@ static int exynos_irq_set_wake(struct irq_data *data, unsigned int state)
 {
 	const struct exynos_wkup_irq *wkup_irq;
 
-	if (soc_is_exynos5250())
+	if (is_soc_id_compatible(EXYNOS5250))
 		wkup_irq = exynos5250_wkup_irq;
 	else
 		wkup_irq = exynos4_wkup_irq;
@@ -101,11 +101,11 @@ static int exynos_irq_set_wake(struct irq_data *data, unsigned int state)
 	return -ENOENT;
 }
 
-#define EXYNOS_BOOT_VECTOR_ADDR	(samsung_rev() == EXYNOS4210_REV_1_1 ? \
-			S5P_INFORM7 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \
+#define EXYNOS_BOOT_VECTOR_ADDR	(is_soc_rev_compatible(EXYNOS4210_REV_1_1) ? \
+			S5P_INFORM7 : (is_soc_rev_compatible(EXYNOS4210_REV_1_0) ? \
 			0x24 : S5P_INFORM0))
-#define EXYNOS_BOOT_VECTOR_FLAG	(samsung_rev() == EXYNOS4210_REV_1_1 ? \
-			S5P_INFORM6 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \
+#define EXYNOS_BOOT_VECTOR_FLAG	(is_soc_rev_compatible(EXYNOS4210_REV_1_1) ? \
+			S5P_INFORM6 : (is_soc_rev_compatible(EXYNOS4210_REV_1_0) ? \
 			0x20 : S5P_INFORM1))
 
 #define S5P_CHECK_AFTR  0xFCBA0D10
@@ -119,7 +119,7 @@ static void exynos_set_wakeupmask(long mask)
 
 static void exynos_cpu_set_boot_vector(long flags)
 {
-	if (samsung_rev() == EXYNOS4210_REV_1_0) {
+	if (is_soc_rev_compatible(EXYNOS4210_REV_1_0)) {
 		__raw_writel(virt_to_phys(exynos_cpu_resume),
 				S5P_VA_SYSRAM + EXYNOS_BOOT_VECTOR_ADDR);
 		__raw_writel(flags, S5P_VA_SYSRAM + EXYNOS_BOOT_VECTOR_FLAG);
@@ -183,7 +183,7 @@ static int exynos_cpu_suspend(unsigned long arg)
 	outer_flush_all();
 #endif
 
-	if (soc_is_exynos5250())
+	if (is_soc_id_compatible(EXYNOS5250))
 		flush_cache_all();
 
 	/* issue the standby signal into the pm unit. */
@@ -205,7 +205,7 @@ static void exynos_pm_prepare(void)
 
 	s3c_pm_do_save(exynos_core_save, ARRAY_SIZE(exynos_core_save));
 
-	if (soc_is_exynos5250()) {
+	if (is_soc_id_compatible(EXYNOS5250)) {
 		/* Disable USE_RETENTION of JPEG_MEM_OPTION */
 		regmap_read(pmu_regmap, EXYNOS5_JPEG_MEM_OPTION, &tmp);
 		tmp &= ~EXYNOS5_OPTION_USE_RETENTION;
@@ -243,7 +243,7 @@ static int exynos_pm_suspend(void)
 	tmp = (S5P_USE_STANDBY_WFI0 | S5P_USE_STANDBY_WFE0);
 	regmap_write(pmu_regmap, S5P_CENTRAL_SEQ_OPTION, tmp);
 
-	if (!soc_is_exynos5250())
+	if (!is_soc_id_compatible(EXYNOS5250))
 		exynos_cpu_save_register();
 
 	return 0;
@@ -277,7 +277,7 @@ static void exynos_pm_resume(void)
 	if (exynos_pm_central_resume())
 		goto early_wakeup;
 
-	if (!soc_is_exynos5250())
+	if (!is_soc_id_compatible(EXYNOS5250))
 		exynos_cpu_restore_register();
 
 	/* For release retention */
@@ -292,7 +292,7 @@ static void exynos_pm_resume(void)
 
 	s3c_pm_do_restore_core(exynos_core_save, ARRAY_SIZE(exynos_core_save));
 
-	if (!soc_is_exynos5250())
+	if (!is_soc_id_compatible(EXYNOS5250))
 		scu_enable(S5P_VA_SCU);
 
 early_wakeup:
@@ -385,7 +385,7 @@ static int exynos_cpu_pm_notifier(struct notifier_block *self,
 
 	case CPU_PM_EXIT:
 		if (cpu == 0) {
-			if (!soc_is_exynos5250())
+			if (!is_soc_id_compatible(EXYNOS5250))
 				scu_enable(S5P_VA_SCU);
 			exynos_cpu_restore_register();
 			exynos_pm_central_resume();
arch/arm/plat-samsung/include/plat/cpu.h +0 -57

75 lines not on this page · raw message

drivers/clk/samsung/clk-exynos4.c +1 -1
index b4f9672..7b0ea1f 100644
@@ -1030,7 +1030,7 @@ static unsigned long exynos4_get_xom(void)
 	void __iomem *chipid_base;
 	struct device_node *np;
 
-	np = of_find_compatible_node(NULL, NULL, "samsung,exynos4210-chipid");
+	np = of_find_compatible_node(NULL, NULL, "samsung,exynos4-chipid");
 	if (np) {
 		chipid_base = of_iomap(np, 0);
 
drivers/cpufreq/exynos-cpufreq.c +4 -5
index f99cfe2..5fe84a1 100644
@@ -17,8 +17,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/cpufreq.h>
 #include <linux/platform_device.h>
-
-#include <plat/cpu.h>
+#include <linux/exynos-soc.h>
 
 #include "exynos-cpufreq.h"
 
@@ -163,11 +162,11 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)
 	if (!exynos_info)
 		return -ENOMEM;
 
-	if (soc_is_exynos4210())
+	if (is_soc_id_compatible(EXYNOS4210))
 		ret = exynos4210_cpufreq_init(exynos_info);
-	else if (soc_is_exynos4212() || soc_is_exynos4412())
+	else if (is_soc_id_compatible(EXYNOS4212) || is_soc_id_compatible(EXYNOS4412))
 		ret = exynos4x12_cpufreq_init(exynos_info);
-	else if (soc_is_exynos5250())
+	else if (is_soc_id_compatible(EXYNOS5250))
 		ret = exynos5250_cpufreq_init(exynos_info);
 	else
 		return 0;
drivers/cpufreq/exynos-cpufreq.h +0 -1
index 3ddade8..4201b6d 100644
@@ -68,7 +68,6 @@ static inline int exynos5250_cpufreq_init(struct exynos_dvfs_info *info)
 }
 #endif
 
-#include <plat/cpu.h>
 #include <mach/map.h>
 
 #define EXYNOS4_CLKSRC_CPU			(S5P_VA_CMU + 0x14200)
drivers/cpufreq/exynos4x12-cpufreq.c +3 -2
index 466c76a..958d86f 100644
@@ -16,6 +16,7 @@
 #include <linux/io.h>
 #include <linux/slab.h>
 #include <linux/cpufreq.h>
+#include <linux/exynos-soc.h>
 
 #include "exynos-cpufreq.h"
 
@@ -115,7 +116,7 @@ static void exynos4x12_set_clkdiv(unsigned int div_index)
 	tmp = apll_freq_4x12[div_index].clk_div_cpu1;
 
 	__raw_writel(tmp, EXYNOS4_CLKDIV_CPU1);
-	if (soc_is_exynos4212())
+	if (is_soc_id_compatible(EXYNOS4212))
 		stat_cpu1 = 0x11;
 	else
 		stat_cpu1 = 0x111;
@@ -184,7 +185,7 @@ int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info)
 	if (IS_ERR(mout_apll))
 		goto err_mout_apll;
 
-	if (soc_is_exynos4212())
+	if (is_soc_id_compatible(EXYNOS4212))
 		apll_freq_4x12 = apll_freq_4212;
 	else
 		apll_freq_4x12 = apll_freq_4412;
Signature · 1 line
1.7.10.4
#27 lore raw

Re: [PATCH v3 6/6] ARM: EXYNOS: Refactoring to remove soc_is_exynos macros from exynos

Hi Pankaj,

Quoted 9 lines · Pankaj Dubey

This patch enables chipid driver for ARCH_EXYNOS and refactors machine code as well as exynos cpufreq driver code for using chipid driver for identification of SoC ID and SoC rev.

This patch also updates DT binding information in exynos4 and exynos5 dtsi file. As to differentiate product id bit-mask we need separate compatible string for exynos4 and exynos5. Hoping this will be helpful in future as bit-mask and bit-shift bit may differ. Added binding information as well.

[snip]

Quoted 20 lines
arch/arm/mach-exynos/platsmp.c +1 -1
index d0482c2..9d6ec84 100644
@@ -20,13 +20,13 @@
 #include <linux/smp.h>
 #include <linux/io.h>
 #include <linux/of_address.h>
+#include <linux/exynos-soc.h>
 
 #include <asm/cacheflush.h>
 #include <asm/smp_plat.h>
 #include <asm/smp_scu.h>
 #include <asm/firmware.h>
 
-#include <plat/cpu.h>
 #include <mach/map.h>
 
 #include "common.h"

arch/arm/mach-exynos/platsmp.c static void __init exynos_smp_prepare_sram(void) · line 63

Quoted 6 lines
arch/arm/mach-exynos/platsmp.c +2 -1
@@ -59,7 +59,8 @@ static void __init exynos_smp_prepare_sram(void)
 
 static inline void __iomem *cpu_boot_reg_base(void)
 {
-	if (soc_is_exynos4210() && samsung_rev() == EXYNOS4210_REV_1_1)
+	if (is_soc_id_compatible(EXYNOS4210) &&
+			is_soc_rev_compatible(EXYNOS4210_REV_1_1))

Well, how is this any better than what is already there? When adding a new SoC, you will likely have to add another series of "||"s or "&&"s with specific SoC IDs, when using this kind of API. This is not the point.

For now, all those things can be replaced simply with of_machine_is_compatible() (except checks for samsung_rev()), but in the end they need to be properly abstracted. The goal is to be able to add support for new SoC, which requires identical steps to perform certain things as already supported SoCs, without explicitly stating this in driver code.

E.g. Exynos5250 is already supported, while Exynos5251 shows up. Let's say it has exactly the same secondary CPU boot-up method as Exynos5250, but to enter suspend mode, the same steps as on Exynos5260 have to be performed. With any kind of per-SoC check API, you will have to add soc_is_exynos5251() or is_soc_id_compatible(EXYNOS5251) in CPU bring-up code and low-level suspend code, even though all the functional code is already there.

Best regards,
Tomasz

#28 lore raw
In reply to [email protected]

Hi,

Quoted 18 lines · On Sat, May 10, 2014 at 12:18 AM, <[email protected]> wrote:

From: Pankaj Dubey <[email protected]>

This patch series attempts to get rid of soc_is_exynosXXXX macros and eventually with the help of this series we can probably get rid of CONFIG_SOC_EXYNOSXXXX in near future.
Each Exynos SoC has ChipID block which can give information about SoC's product Id and revision number. Currently we have single DT binding information for this as "samsung,exynos4210-chipid". But Exynos4 and Exynos5 SoC series have one small difference in chip Id, with resepect to product id bit-masks. So it means we should have separate compatible string for these different series of SoCs. So I have added second compatible string for handling this difference.
This patch series is based on Kukjin Kim's for-next (3.14_rc1 tag) and prepared on top of following patch series and it's dependent patch series.

[1]: Map SYSRAM through generic SRAM bindings by Sachin Kamat.

Quoted 8 lines
        http://www.spinics.net/lists/arm-kernel/msg327677.html
[2]: Exynos PMU cleanup and refactoring.
        https://lkml.org/lkml/2014/4/30/44
[3]: Introduce drivers/soc and add QCOM GSBI driver.
        https://lkml.org/lkml/2014/4/24/520

Revision 2 and it's discussion can be found here
- https://lkml.org/lkml/2014/5/6/100

As I just realized when I commented on the last patch in the patchset (the cpufreq section): I think you can, and should, use of_machine_is_compatible() for most of these cases, instead of using a new API through a chipid driver. Since all boards based on an SoC should have that in the string of compatibles, it's a shared and easy way to handle this without adding custom drivers per manufacturer.

There will possibly be some cases where it doesn't fit well, but for nearly all cases it should be sufficient.

(The patchset contains some other good cleanups, of course you should keep those).

-Olof

#29 lore raw
Quoted 27 lines · Olof Johansson

Hi,

Quoted 24 lines · On Sat, May 10, 2014 at 12:18 AM, <[email protected]> wrote:

From: Pankaj Dubey <[email protected]>

This patch series attempts to get rid of soc_is_exynosXXXX macros and eventually with the help of this series we can probably get rid of CONFIG_SOC_EXYNOSXXXX in near future.
Each Exynos SoC has ChipID block which can give information about SoC's product Id and revision number. Currently we have single DT binding information for this as "samsung,exynos4210-chipid". But Exynos4 and Exynos5 SoC series have one small difference in chip Id, with resepect to product id bit-masks. So it means we should have separate compatible string for these different series of SoCs. So I have added second compatible string for handling this difference.
This patch series is based on Kukjin Kim's for-next (3.14_rc1 tag) and prepared on top of following patch series and it's dependent patch series.

[1]: Map SYSRAM through generic SRAM bindings by Sachin Kamat.

         http://www.spinics.net/lists/arm-kernel/msg327677.html
[2]: Exynos PMU cleanup and refactoring.
         https://lkml.org/lkml/2014/4/30/44
[3]: Introduce drivers/soc and add QCOM GSBI driver.
         https://lkml.org/lkml/2014/4/24/520
Quoted 8 lines
Quoted 2 lines

Revision 2 and it's discussion can be found here
- https://lkml.org/lkml/2014/5/6/100

As I just realized when I commented on the last patch in the patchset (the cpufreq section): I think you can, and should, use of_machine_is_compatible() for most of these cases, instead of using a new API through a chipid driver. Since all boards based on an SoC should have that in the string of compatibles, it's a shared and easy way to handle this without adding custom drivers per manufacturer.

I am sorry, I could not see your comments in my last patch-set.

Anyway, thanks for review. During first version of this patch, I had discussion with Arnd [1], and it looks like he do not like idea of using "of_machine_is_compatible".

[1]: https://lkml.org/lkml/2014/5/5/126
and
https://lkml.org/lkml/2014/5/5/335

So my proposal was till we get generic solution for all files under mach-exynos let's use chip-id driver provided APIs.

Also chip-id driver is not only for providing this API but also to provide SoC specific information as a sysfs entry to userspace. So even though we do not want to use chipid driver API's for identifying SoCs we can keep this driver.

So let us discuss again and decide which will be best way (at the same time less overhead) solution for removing usage of soc_is_exynosXYZ and related CONFIG macros from exynos.

@Arnd and Tomasz, I would appreciate if you spent some time to review this series as I have addressed many of your review comments.

Quoted 5 lines

There will possibly be some cases where it doesn't fit well, but for nearly all cases it should be sufficient.

(The patchset contains some other good cleanups, of course you should keep those).

Thanks and sure, I would like those should get merged.

Quoted 3 lines

-Olof

Signature · 2 lines
Best Regards,
Pankaj Dubey
#30 lore raw

Hi,

Quoted 42 lines · Pankaj Dubey
Quoted 32 lines · Olof Johansson

Hi,

Quoted 19 lines · On Sat, May 10, 2014 at 12:18 AM, <[email protected]> wrote:

From: Pankaj Dubey <[email protected]>

This patch series attempts to get rid of soc_is_exynosXXXX macros and eventually with the help of this series we can probably get rid of CONFIG_SOC_EXYNOSXXXX in near future.
Each Exynos SoC has ChipID block which can give information about SoC's product Id and revision number. Currently we have single DT binding information for this as "samsung,exynos4210-chipid". But Exynos4 and Exynos5 SoC series have one small difference in chip Id, with resepect to product id bit-masks. So it means we should have separate compatible string for these different series of SoCs. So I have added second compatible string for handling this difference.
This patch series is based on Kukjin Kim's for-next (3.14_rc1 tag) and prepared on top of following patch series and it's dependent patch series.

[1]: Map SYSRAM through generic SRAM bindings by Sachin Kamat.

Quoted 8 lines
         http://www.spinics.net/lists/arm-kernel/msg327677.html
[2]: Exynos PMU cleanup and refactoring.
         https://lkml.org/lkml/2014/4/30/44
[3]: Introduce drivers/soc and add QCOM GSBI driver.
         https://lkml.org/lkml/2014/4/24/520

Revision 2 and it's discussion can be found here
- https://lkml.org/lkml/2014/5/6/100

Quoted 6 lines

As I just realized when I commented on the last patch in the patchset (the cpufreq section): I think you can, and should, use of_machine_is_compatible() for most of these cases, instead of using a new API through a chipid driver. Since all boards based on an SoC should have that in the string of compatibles, it's a shared and easy way to handle this without adding custom drivers per manufacturer.

I am sorry, I could not see your comments in my last patch-set.

Quoted 7 lines

Anyway, thanks for review. During first version of this patch, I had discussion with Arnd [1], and it looks like he do not like idea of using "of_machine_is_compatible".

[1]: https://lkml.org/lkml/2014/5/5/126
and
https://lkml.org/lkml/2014/5/5/335

Ok, I've commented on that thread now.

Quoted 2 lines

So my proposal was till we get generic solution for all files under mach-exynos let's use chip-id driver provided APIs.

of_machine_is_compatible() is a quite sensible existing generic interface to do this. We don't need to add a driver for it.

Quoted 4 lines

Also chip-id driver is not only for providing this API but also to provide SoC specific information as a sysfs entry to userspace. So even though we do not want to use chipid driver API's for identifying SoCs we can keep this driver.

For this you might want a chipid driver, yes. I'm mostly objecting to the addition of the new is_soc_.*() API, not the introduction of the driver for that purpose.

Quoted 7 lines

So let us discuss again and decide which will be best way (at the same time less overhead) solution for removing usage of soc_is_exynosXYZ and related CONFIG macros from exynos.

@Arnd and Tomasz, I would appreciate if you spent some time to review this series as I have addressed many of your review comments.

-Olof