linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/6] Introducing Exynos ChipId driver
@ 2014-05-10  7:18 y
  2014-05-10  7:18 ` [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver y
                   ` (7 more replies)
  0 siblings, 8 replies; 31+ messages in thread
From: y @ 2014-05-10  7:18 UTC (permalink / raw)
  To: linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, t.figa, arnd, Pankaj Dubey

From: Pankaj Dubey <pankaj.dubey@samsung.com>

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

-- 
1.7.10.4


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

* [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver
  2014-05-10  7:18 [PATCH v3 0/6] Introducing Exynos ChipId driver y
@ 2014-05-10  7:18 ` y
  2014-05-10  7:18 ` [PATCH v3 2/6] ARM: EXYNOS: Remove i2c sys configuration related code y
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 31+ messages in thread
From: y @ 2014-05-10  7:18 UTC (permalink / raw)
  To: linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, t.figa, arnd, Pankaj Dubey, Rob Herring, Randy Dunlap,
	Wolfram Sang, Russell King, devicetree, linux-doc, linux-i2c

From: Pankaj Dubey <pankaj.dubey@samsung.com>

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 <robh+dt@kernel.org>
CC: Randy Dunlap <rdunlap@infradead.org>
CC: Wolfram Sang <wsa@the-dreams.de>
CC: Russell King <linux@arm.linux.org.uk>
CC: devicetree@vger.kernel.org
CC: linux-doc@vger.kernel.org
CC: linux-i2c@vger.kernel.org
Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
---
 .../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(+)

diff --git a/Documentation/devicetree/bindings/arm/samsung/sysreg.txt b/Documentation/devicetree/bindings/arm/samsung/sysreg.txt
index 0ab3251..fd71581 100644
--- a/Documentation/devicetree/bindings/arm/samsung/sysreg.txt
+++ b/Documentation/devicetree/bindings/arm/samsung/sysreg.txt
@@ -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:
diff --git a/arch/arm/boot/dts/exynos5.dtsi b/arch/arm/boot/dts/exynos5.dtsi
index 79d0608..3027e37 100644
--- a/arch/arm/boot/dts/exynos5.dtsi
+++ b/arch/arm/boot/dts/exynos5.dtsi
@@ -99,4 +99,9 @@
 		#size-cells = <0>;
 		status = "disabled";
 	};
+
+	sys_reg: syscon@10050000 {
+		compatible = "samsung,exynos5-sysreg", "syscon";
+		reg = <0x10050000 0x400>;
+	};
 };
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index 8d724d5..46f0233 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -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";
 	};
 
diff --git a/arch/arm/boot/dts/exynos5420.dtsi b/arch/arm/boot/dts/exynos5420.dtsi
index ff496ad..762128c 100644
--- a/arch/arm/boot/dts/exynos5420.dtsi
+++ b/arch/arm/boot/dts/exynos5420.dtsi
@@ -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";
 	};
 
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index ae44910..e707062 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -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);
-- 
1.7.10.4


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

* [PATCH v3 2/6] ARM: EXYNOS: Remove i2c sys configuration related code
  2014-05-10  7:18 [PATCH v3 0/6] Introducing Exynos ChipId driver y
  2014-05-10  7:18 ` [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver y
@ 2014-05-10  7:18 ` y
  2014-05-10  7:18 ` [PATCH v3 3/6] ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c y
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 31+ messages in thread
From: y @ 2014-05-10  7:18 UTC (permalink / raw)
  To: linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, t.figa, arnd, Pankaj Dubey, Russell King

From: Pankaj Dubey <pankaj.dubey@samsung.com>

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

CC: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
---
 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

diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c
index 59eb1f1..09063ee 100644
--- a/arch/arm/mach-exynos/exynos.c
+++ b/arch/arm/mach-exynos/exynos.c
@@ -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())
diff --git a/arch/arm/mach-exynos/include/mach/map.h b/arch/arm/mach-exynos/include/mach/map.h
index 34eee6e..bd4a320 100644
--- a/arch/arm/mach-exynos/include/mach/map.h
+++ b/arch/arm/mach-exynos/include/mach/map.h
@@ -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
 
diff --git a/arch/arm/mach-exynos/pm.c b/arch/arm/mach-exynos/pm.c
index a7a1b7f..59e5604 100644
--- a/arch/arm/mach-exynos/pm.c
+++ b/arch/arm/mach-exynos/pm.c
@@ -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())
diff --git a/arch/arm/mach-exynos/regs-sys.h b/arch/arm/mach-exynos/regs-sys.h
deleted file mode 100644
index 84332b0..0000000
--- a/arch/arm/mach-exynos/regs-sys.h
+++ /dev/null
@@ -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 */
-- 
1.7.10.4


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

* [PATCH v3 3/6] ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c
  2014-05-10  7:18 [PATCH v3 0/6] Introducing Exynos ChipId driver y
  2014-05-10  7:18 ` [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver y
  2014-05-10  7:18 ` [PATCH v3 2/6] ARM: EXYNOS: Remove i2c sys configuration related code y
@ 2014-05-10  7:18 ` y
  2014-05-11  6:52   ` Olof Johansson
  2014-05-10  7:18 ` [PATCH v3 4/6] ARM: EXYNOS: Remove unused header inclusion from hotplug.c y
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 31+ messages in thread
From: y @ 2014-05-10  7:18 UTC (permalink / raw)
  To: linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, t.figa, arnd, Pankaj Dubey, Russell King, Thomas Abraham

From: Pankaj Dubey <pankaj.dubey@samsung.com>

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 <linux@arm.linux.org.uk>
CC: Thomas Abraham <thomas.abraham@linaro.org>
Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
---
 arch/arm/mach-exynos/exynos.c            |   52 +++++++++++++++++++-----------
 arch/arm/plat-samsung/include/plat/cpu.h |    3 --
 2 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c
index 09063ee..9902e52 100644
--- a/arch/arm/mach-exynos/exynos.c
+++ b/arch/arm/mach-exynos/exynos.c
@@ -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 <thomas.abraham@linaro.org> */
+	/* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
+	.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 <thomas.abraham@linaro.org> */
 	/* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
 	.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
diff --git a/arch/arm/plat-samsung/include/plat/cpu.h b/arch/arm/plat-samsung/include/plat/cpu.h
index 5992b8d..18a9a00 100644
--- a/arch/arm/plat-samsung/include/plat/cpu.h
+++ b/arch/arm/plat-samsung/include/plat/cpu.h
@@ -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 }
 
-- 
1.7.10.4


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

* [PATCH v3 4/6] ARM:  EXYNOS: Remove unused header inclusion from hotplug.c
  2014-05-10  7:18 [PATCH v3 0/6] Introducing Exynos ChipId driver y
                   ` (2 preceding siblings ...)
  2014-05-10  7:18 ` [PATCH v3 3/6] ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c y
@ 2014-05-10  7:18 ` y
  2014-05-10  7:18 ` [PATCH v3 5/6] soc: samsung: exynos-chipid: Add Exynos Chipid driver support y
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 31+ messages in thread
From: y @ 2014-05-10  7:18 UTC (permalink / raw)
  To: linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, t.figa, arnd, Pankaj Dubey

From: Pankaj Dubey <pankaj.dubey@samsung.com>

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

Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
---
 arch/arm/mach-exynos/hotplug.c |    2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/arm/mach-exynos/hotplug.c b/arch/arm/mach-exynos/hotplug.c
index 0243ef3..5e19601 100644
--- a/arch/arm/mach-exynos/hotplug.c
+++ b/arch/arm/mach-exynos/hotplug.c
@@ -19,8 +19,6 @@
 #include <asm/cp15.h>
 #include <asm/smp_plat.h>
 
-#include <plat/cpu.h>
-
 #include "common.h"
 #include "regs-pmu.h"
 
-- 
1.7.10.4


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

* [PATCH v3 5/6] soc: samsung: exynos-chipid: Add Exynos Chipid driver support
  2014-05-10  7:18 [PATCH v3 0/6] Introducing Exynos ChipId driver y
                   ` (3 preceding siblings ...)
  2014-05-10  7:18 ` [PATCH v3 4/6] ARM: EXYNOS: Remove unused header inclusion from hotplug.c y
@ 2014-05-10  7:18 ` y
  2014-05-10  7:18 ` [PATCH v3 6/6] ARM: EXYNOS: Refactoring to remove soc_is_exynos macros from exynos y
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 31+ messages in thread
From: y @ 2014-05-10  7:18 UTC (permalink / raw)
  To: linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, t.figa, arnd, Pankaj Dubey

From: Pankaj Dubey <pankaj.dubey@samsung.com>

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.

Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
---
 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

diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
index 07a11be..86e52b1 100644
--- a/drivers/soc/Kconfig
+++ b/drivers/soc/Kconfig
@@ -1,5 +1,6 @@
 menu "SOC specific Drivers"
 
 source "drivers/soc/qcom/Kconfig"
+source "drivers/soc/samsung/Kconfig"
 
 endmenu
diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
index 0f7c447..ee890aa 100644
--- a/drivers/soc/Makefile
+++ b/drivers/soc/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_ARCH_QCOM)		+= qcom/
+obj-$(CONFIG_ARCH_EXYNOS)	+= samsung/
diff --git a/drivers/soc/samsung/Kconfig b/drivers/soc/samsung/Kconfig
new file mode 100644
index 0000000..dacc95d
--- /dev/null
+++ b/drivers/soc/samsung/Kconfig
@@ -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.
diff --git a/drivers/soc/samsung/Makefile b/drivers/soc/samsung/Makefile
new file mode 100644
index 0000000..855ca05
--- /dev/null
+++ b/drivers/soc/samsung/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_EXYNOS_CHIPID)	+= exynos-chipid.o
diff --git a/drivers/soc/samsung/exynos-chipid.c b/drivers/soc/samsung/exynos-chipid.c
new file mode 100644
index 0000000..b5bccd9
--- /dev/null
+++ b/drivers/soc/samsung/exynos-chipid.c
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *	      http://www.samsung.com/
+ *
+ * EXYNOS - CHIP ID support
+ * Author: Pankaj Dubey <pankaj.dubey@samsung.com>
+ *
+ * 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/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
+#define EXYNOS5_SOC_MASK	0xFFFFF
+
+#define PROD_ID_SHIFT	(12)
+
+static void __iomem	*exynos_chipid_base;
+unsigned int exynos_soc_id = EXYNOS_SOC_UNKNOWN;
+enum exynos_soc_revision exynos_revision;
+
+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,
+};
+
+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,
+	},
+	{},
+};
+
+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;
+}
+
+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__);
+
+		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);
+	}
+
+}
diff --git a/include/linux/exynos-soc.h b/include/linux/exynos-soc.h
new file mode 100644
index 0000000..ebd4366
--- /dev/null
+++ b/include/linux/exynos-soc.h
@@ -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.
+ */
+
+#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,
+	EXYNOS4212 = 0xE4212,
+	EXYNOS4412 = 0xE4412,
+	EXYNOS5250 = 0x43520,
+	EXYNOS5420 = 0xE5420,
+	EXYNOS5440 = 0xE5440,
+	EXYNOS_SOC_UNKNOWN = -1,
+};
+
+/* 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,
+};
+
+/* Since we need chipid to be initialized as early as possible
+ * during secondary core bootup adding early initialization function
+ * Note: This should be called only after device tree gets unflatten
+ */
+extern void early_exynos_chipid_init(void);
+extern struct device *exynos_soc_device_init(void);
+extern bool is_soc_id_compatible(enum exynos_soc_id soc_id);
+extern bool is_soc_rev_compatible(enum exynos_soc_revision soc_rev);
+
+#endif /* __EXYNOS_SOC_H */
-- 
1.7.10.4


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

* [PATCH v3 6/6] ARM: EXYNOS: Refactoring to remove soc_is_exynos macros from exynos
  2014-05-10  7:18 [PATCH v3 0/6] Introducing Exynos ChipId driver y
                   ` (4 preceding siblings ...)
  2014-05-10  7:18 ` [PATCH v3 5/6] soc: samsung: exynos-chipid: Add Exynos Chipid driver support y
@ 2014-05-10  7:18 ` y
  2014-05-11  7:10   ` Olof Johansson
  2014-05-10  7:20 ` [PATCH v3 0/6] Introducing Exynos ChipId driver Pankaj Dubey
  2014-05-11  7:12 ` [PATCH v3 0/6] Introducing Exynos ChipId driver Olof Johansson
  7 siblings, 1 reply; 31+ messages in thread
From: y @ 2014-05-10  7:18 UTC (permalink / raw)
  To: linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, t.figa, arnd, Pankaj Dubey

From: Pankaj Dubey <pankaj.dubey@samsung.com>

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.

Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
---
 .../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

diff --git a/Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt b/Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt
new file mode 100644
index 0000000..a496459
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt
@@ -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>;
+	};
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a4eac2f..06f14a4 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -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)
 
diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index 2f8bcd0..d4c0657 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -46,7 +46,7 @@
 	};
 
 	chipid@10000000 {
-		compatible = "samsung,exynos4210-chipid";
+		compatible = "samsung,exynos4210-chipid", "samsung,exynos4-chipid";
 		reg = <0x10000000 0x100>;
 	};
 
diff --git a/arch/arm/boot/dts/exynos5.dtsi b/arch/arm/boot/dts/exynos5.dtsi
index 3027e37..1d0b569 100644
--- a/arch/arm/boot/dts/exynos5.dtsi
+++ b/arch/arm/boot/dts/exynos5.dtsi
@@ -19,7 +19,7 @@
 	interrupt-parent = <&gic>;
 
 	chipid@10000000 {
-		compatible = "samsung,exynos4210-chipid";
+		compatible = "samsung,exynos4210-chipid", "samsung,exynos5-chipid";
 		reg = <0x10000000 0x100>;
 	};
 
diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c
index 9902e52..26f5e8c 100644
--- a/arch/arm/mach-exynos/exynos.c
+++ b/arch/arm/mach-exynos/exynos.c
@@ -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 = {
diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c
index d0482c2..9d6ec84 100644
--- a/arch/arm/mach-exynos/platsmp.c
+++ b/arch/arm/mach-exynos/platsmp.c
@@ -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();
 
diff --git a/arch/arm/mach-exynos/pm.c b/arch/arm/mach-exynos/pm.c
index 59e5604..5cb5449 100644
--- a/arch/arm/mach-exynos/pm.c
+++ b/arch/arm/mach-exynos/pm.c
@@ -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();
diff --git a/arch/arm/plat-samsung/include/plat/cpu.h b/arch/arm/plat-samsung/include/plat/cpu.h
index 18a9a00..135471d 100644
--- a/arch/arm/plat-samsung/include/plat/cpu.h
+++ b/arch/arm/plat-samsung/include/plat/cpu.h
@@ -43,16 +43,6 @@ extern unsigned long samsung_cpu_id;
 #define S5PV210_CPU_ID		0x43110000
 #define S5PV210_CPU_MASK	0xFFFFF000
 
-#define EXYNOS4210_CPU_ID	0x43210000
-#define EXYNOS4212_CPU_ID	0x43220000
-#define EXYNOS4412_CPU_ID	0xE4412200
-#define EXYNOS4_CPU_MASK	0xFFFE0000
-
-#define EXYNOS5250_SOC_ID	0x43520000
-#define EXYNOS5420_SOC_ID	0xE5420000
-#define EXYNOS5440_SOC_ID	0xE5440000
-#define EXYNOS5_SOC_MASK	0xFFFFF000
-
 #define IS_SAMSUNG_CPU(name, id, mask)		\
 static inline int is_samsung_##name(void)	\
 {						\
@@ -68,12 +58,6 @@ IS_SAMSUNG_CPU(s5p6440, S5P6440_CPU_ID, S5P64XX_CPU_MASK)
 IS_SAMSUNG_CPU(s5p6450, S5P6450_CPU_ID, S5P64XX_CPU_MASK)
 IS_SAMSUNG_CPU(s5pc100, S5PC100_CPU_ID, S5PC100_CPU_MASK)
 IS_SAMSUNG_CPU(s5pv210, S5PV210_CPU_ID, S5PV210_CPU_MASK)
-IS_SAMSUNG_CPU(exynos4210, EXYNOS4210_CPU_ID, EXYNOS4_CPU_MASK)
-IS_SAMSUNG_CPU(exynos4212, EXYNOS4212_CPU_ID, EXYNOS4_CPU_MASK)
-IS_SAMSUNG_CPU(exynos4412, EXYNOS4412_CPU_ID, EXYNOS4_CPU_MASK)
-IS_SAMSUNG_CPU(exynos5250, EXYNOS5250_SOC_ID, EXYNOS5_SOC_MASK)
-IS_SAMSUNG_CPU(exynos5420, EXYNOS5420_SOC_ID, EXYNOS5_SOC_MASK)
-IS_SAMSUNG_CPU(exynos5440, EXYNOS5440_SOC_ID, EXYNOS5_SOC_MASK)
 
 #if defined(CONFIG_CPU_S3C2410) || defined(CONFIG_CPU_S3C2412) || \
     defined(CONFIG_CPU_S3C2416) || defined(CONFIG_CPU_S3C2440) || \
@@ -126,47 +110,6 @@ IS_SAMSUNG_CPU(exynos5440, EXYNOS5440_SOC_ID, EXYNOS5_SOC_MASK)
 # define soc_is_s5pv210()	0
 #endif
 
-#if defined(CONFIG_CPU_EXYNOS4210)
-# define soc_is_exynos4210()	is_samsung_exynos4210()
-#else
-# define soc_is_exynos4210()	0
-#endif
-
-#if defined(CONFIG_SOC_EXYNOS4212)
-# define soc_is_exynos4212()	is_samsung_exynos4212()
-#else
-# define soc_is_exynos4212()	0
-#endif
-
-#if defined(CONFIG_SOC_EXYNOS4412)
-# define soc_is_exynos4412()	is_samsung_exynos4412()
-#else
-# define soc_is_exynos4412()	0
-#endif
-
-#define EXYNOS4210_REV_0	(0x0)
-#define EXYNOS4210_REV_1_0	(0x10)
-#define EXYNOS4210_REV_1_1	(0x11)
-
-#if defined(CONFIG_SOC_EXYNOS5250)
-# define soc_is_exynos5250()	is_samsung_exynos5250()
-#else
-# define soc_is_exynos5250()	0
-#endif
-
-#if defined(CONFIG_SOC_EXYNOS5420)
-# define soc_is_exynos5420()	is_samsung_exynos5420()
-#else
-# define soc_is_exynos5420()	0
-#endif
-
-#if defined(CONFIG_SOC_EXYNOS5440)
-# define soc_is_exynos5440()	is_samsung_exynos5440()
-#else
-# define soc_is_exynos5440()	0
-#endif
-
-
 #define IODESC_ENT(x) { (unsigned long)S3C24XX_VA_##x, __phys_to_pfn(S3C24XX_PA_##x), S3C24XX_SZ_##x, MT_DEVICE }
 
 #ifndef KHZ
diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c
index b4f9672..7b0ea1f 100644
--- a/drivers/clk/samsung/clk-exynos4.c
+++ b/drivers/clk/samsung/clk-exynos4.c
@@ -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);
 
diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index f99cfe2..5fe84a1 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -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;
diff --git a/drivers/cpufreq/exynos-cpufreq.h b/drivers/cpufreq/exynos-cpufreq.h
index 3ddade8..4201b6d 100644
--- a/drivers/cpufreq/exynos-cpufreq.h
+++ b/drivers/cpufreq/exynos-cpufreq.h
@@ -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)
diff --git a/drivers/cpufreq/exynos4x12-cpufreq.c b/drivers/cpufreq/exynos4x12-cpufreq.c
index 466c76a..958d86f 100644
--- a/drivers/cpufreq/exynos4x12-cpufreq.c
+++ b/drivers/cpufreq/exynos4x12-cpufreq.c
@@ -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;
-- 
1.7.10.4


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

* [PATCH v3 0/6] Introducing Exynos ChipId driver
  2014-05-10  7:18 [PATCH v3 0/6] Introducing Exynos ChipId driver y
                   ` (5 preceding siblings ...)
  2014-05-10  7:18 ` [PATCH v3 6/6] ARM: EXYNOS: Refactoring to remove soc_is_exynos macros from exynos y
@ 2014-05-10  7:20 ` Pankaj Dubey
  2014-05-10  7:20   ` [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver Pankaj Dubey
                     ` (5 more replies)
  2014-05-11  7:12 ` [PATCH v3 0/6] Introducing Exynos ChipId driver Olof Johansson
  7 siblings, 6 replies; 31+ messages in thread
From: Pankaj Dubey @ 2014-05-10  7:20 UTC (permalink / raw)
  To: linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, t.figa, arnd, Pankaj Dubey

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

-- 
1.7.10.4


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

* [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver
  2014-05-10  7:20 ` [PATCH v3 0/6] Introducing Exynos ChipId driver Pankaj Dubey
@ 2014-05-10  7:20   ` Pankaj Dubey
  2014-06-02 17:14     ` Wolfram Sang
  2014-06-10 13:35     ` Tomasz Figa
  2014-05-10  7:20   ` [PATCH v3 2/6] ARM: EXYNOS: Remove i2c sys configuration related code Pankaj Dubey
                     ` (4 subsequent siblings)
  5 siblings, 2 replies; 31+ messages in thread
From: Pankaj Dubey @ 2014-05-10  7:20 UTC (permalink / raw)
  To: linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, t.figa, arnd, Pankaj Dubey, Rob Herring, Randy Dunlap,
	Wolfram Sang, Russell King, devicetree, linux-doc, linux-i2c

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 <robh+dt@kernel.org>
CC: Randy Dunlap <rdunlap@infradead.org>
CC: Wolfram Sang <wsa@the-dreams.de>
CC: Russell King <linux@arm.linux.org.uk>
CC: devicetree@vger.kernel.org
CC: linux-doc@vger.kernel.org
CC: linux-i2c@vger.kernel.org
Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
---
 .../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(+)

diff --git a/Documentation/devicetree/bindings/arm/samsung/sysreg.txt b/Documentation/devicetree/bindings/arm/samsung/sysreg.txt
index 0ab3251..fd71581 100644
--- a/Documentation/devicetree/bindings/arm/samsung/sysreg.txt
+++ b/Documentation/devicetree/bindings/arm/samsung/sysreg.txt
@@ -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:
diff --git a/arch/arm/boot/dts/exynos5.dtsi b/arch/arm/boot/dts/exynos5.dtsi
index 79d0608..3027e37 100644
--- a/arch/arm/boot/dts/exynos5.dtsi
+++ b/arch/arm/boot/dts/exynos5.dtsi
@@ -99,4 +99,9 @@
 		#size-cells = <0>;
 		status = "disabled";
 	};
+
+	sys_reg: syscon@10050000 {
+		compatible = "samsung,exynos5-sysreg", "syscon";
+		reg = <0x10050000 0x400>;
+	};
 };
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index 8d724d5..46f0233 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -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";
 	};
 
diff --git a/arch/arm/boot/dts/exynos5420.dtsi b/arch/arm/boot/dts/exynos5420.dtsi
index ff496ad..762128c 100644
--- a/arch/arm/boot/dts/exynos5420.dtsi
+++ b/arch/arm/boot/dts/exynos5420.dtsi
@@ -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";
 	};
 
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index ae44910..e707062 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -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);
-- 
1.7.10.4


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

* [PATCH v3 2/6] ARM: EXYNOS: Remove i2c sys configuration related code
  2014-05-10  7:20 ` [PATCH v3 0/6] Introducing Exynos ChipId driver Pankaj Dubey
  2014-05-10  7:20   ` [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver Pankaj Dubey
@ 2014-05-10  7:20   ` Pankaj Dubey
  2014-06-10 13:52     ` Tomasz Figa
  2014-05-10  7:20   ` [PATCH v3 3/6] ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c Pankaj Dubey
                     ` (3 subsequent siblings)
  5 siblings, 1 reply; 31+ messages in thread
From: Pankaj Dubey @ 2014-05-10  7:20 UTC (permalink / raw)
  To: linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, t.figa, arnd, Pankaj Dubey, Russell King

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

CC: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
---
 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

diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c
index 59eb1f1..09063ee 100644
--- a/arch/arm/mach-exynos/exynos.c
+++ b/arch/arm/mach-exynos/exynos.c
@@ -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())
diff --git a/arch/arm/mach-exynos/include/mach/map.h b/arch/arm/mach-exynos/include/mach/map.h
index 34eee6e..bd4a320 100644
--- a/arch/arm/mach-exynos/include/mach/map.h
+++ b/arch/arm/mach-exynos/include/mach/map.h
@@ -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
 
diff --git a/arch/arm/mach-exynos/pm.c b/arch/arm/mach-exynos/pm.c
index a7a1b7f..59e5604 100644
--- a/arch/arm/mach-exynos/pm.c
+++ b/arch/arm/mach-exynos/pm.c
@@ -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())
diff --git a/arch/arm/mach-exynos/regs-sys.h b/arch/arm/mach-exynos/regs-sys.h
deleted file mode 100644
index 84332b0..0000000
--- a/arch/arm/mach-exynos/regs-sys.h
+++ /dev/null
@@ -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 */
-- 
1.7.10.4


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

* [PATCH v3 3/6] ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c
  2014-05-10  7:20 ` [PATCH v3 0/6] Introducing Exynos ChipId driver Pankaj Dubey
  2014-05-10  7:20   ` [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver Pankaj Dubey
  2014-05-10  7:20   ` [PATCH v3 2/6] ARM: EXYNOS: Remove i2c sys configuration related code Pankaj Dubey
@ 2014-05-10  7:20   ` Pankaj Dubey
  2014-06-10 13:55     ` Tomasz Figa
  2014-05-10  7:20   ` [PATCH v3 4/6] ARM: EXYNOS: Remove unused header inclusion from hotplug.c Pankaj Dubey
                     ` (2 subsequent siblings)
  5 siblings, 1 reply; 31+ messages in thread
From: Pankaj Dubey @ 2014-05-10  7:20 UTC (permalink / raw)
  To: linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, t.figa, arnd, Pankaj Dubey, Russell King, Thomas Abraham

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 <linux@arm.linux.org.uk>
CC: Thomas Abraham <thomas.abraham@linaro.org>
Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
---
 arch/arm/mach-exynos/exynos.c            |   52 +++++++++++++++++++-----------
 arch/arm/plat-samsung/include/plat/cpu.h |    3 --
 2 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c
index 09063ee..9902e52 100644
--- a/arch/arm/mach-exynos/exynos.c
+++ b/arch/arm/mach-exynos/exynos.c
@@ -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 <thomas.abraham@linaro.org> */
+	/* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
+	.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 <thomas.abraham@linaro.org> */
 	/* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
 	.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
diff --git a/arch/arm/plat-samsung/include/plat/cpu.h b/arch/arm/plat-samsung/include/plat/cpu.h
index 5992b8d..18a9a00 100644
--- a/arch/arm/plat-samsung/include/plat/cpu.h
+++ b/arch/arm/plat-samsung/include/plat/cpu.h
@@ -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 }
 
-- 
1.7.10.4


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

* [PATCH v3 4/6] ARM:  EXYNOS: Remove unused header inclusion from hotplug.c
  2014-05-10  7:20 ` [PATCH v3 0/6] Introducing Exynos ChipId driver Pankaj Dubey
                     ` (2 preceding siblings ...)
  2014-05-10  7:20   ` [PATCH v3 3/6] ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c Pankaj Dubey
@ 2014-05-10  7:20   ` Pankaj Dubey
  2014-06-10 13:56     ` Tomasz Figa
  2014-05-10  7:20   ` [PATCH v3 5/6] soc: samsung: exynos-chipid: Add Exynos Chipid driver support Pankaj Dubey
  2014-05-10  7:20   ` [PATCH v3 6/6] ARM: EXYNOS: Refactoring to remove soc_is_exynos macros from exynos Pankaj Dubey
  5 siblings, 1 reply; 31+ messages in thread
From: Pankaj Dubey @ 2014-05-10  7:20 UTC (permalink / raw)
  To: linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, t.figa, arnd, Pankaj Dubey

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

Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
---
 arch/arm/mach-exynos/hotplug.c |    2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/arm/mach-exynos/hotplug.c b/arch/arm/mach-exynos/hotplug.c
index 0243ef3..5e19601 100644
--- a/arch/arm/mach-exynos/hotplug.c
+++ b/arch/arm/mach-exynos/hotplug.c
@@ -19,8 +19,6 @@
 #include <asm/cp15.h>
 #include <asm/smp_plat.h>
 
-#include <plat/cpu.h>
-
 #include "common.h"
 #include "regs-pmu.h"
 
-- 
1.7.10.4


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

* [PATCH v3 5/6] soc: samsung: exynos-chipid: Add Exynos Chipid driver support
  2014-05-10  7:20 ` [PATCH v3 0/6] Introducing Exynos ChipId driver Pankaj Dubey
                     ` (3 preceding siblings ...)
  2014-05-10  7:20   ` [PATCH v3 4/6] ARM: EXYNOS: Remove unused header inclusion from hotplug.c Pankaj Dubey
@ 2014-05-10  7:20   ` Pankaj Dubey
  2014-06-10 14:36     ` Tomasz Figa
  2014-05-10  7:20   ` [PATCH v3 6/6] ARM: EXYNOS: Refactoring to remove soc_is_exynos macros from exynos Pankaj Dubey
  5 siblings, 1 reply; 31+ messages in thread
From: Pankaj Dubey @ 2014-05-10  7:20 UTC (permalink / raw)
  To: linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, t.figa, arnd, 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.

Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
---
 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

diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
index 07a11be..86e52b1 100644
--- a/drivers/soc/Kconfig
+++ b/drivers/soc/Kconfig
@@ -1,5 +1,6 @@
 menu "SOC specific Drivers"
 
 source "drivers/soc/qcom/Kconfig"
+source "drivers/soc/samsung/Kconfig"
 
 endmenu
diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
index 0f7c447..ee890aa 100644
--- a/drivers/soc/Makefile
+++ b/drivers/soc/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_ARCH_QCOM)		+= qcom/
+obj-$(CONFIG_ARCH_EXYNOS)	+= samsung/
diff --git a/drivers/soc/samsung/Kconfig b/drivers/soc/samsung/Kconfig
new file mode 100644
index 0000000..dacc95d
--- /dev/null
+++ b/drivers/soc/samsung/Kconfig
@@ -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.
diff --git a/drivers/soc/samsung/Makefile b/drivers/soc/samsung/Makefile
new file mode 100644
index 0000000..855ca05
--- /dev/null
+++ b/drivers/soc/samsung/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_EXYNOS_CHIPID)	+= exynos-chipid.o
diff --git a/drivers/soc/samsung/exynos-chipid.c b/drivers/soc/samsung/exynos-chipid.c
new file mode 100644
index 0000000..b5bccd9
--- /dev/null
+++ b/drivers/soc/samsung/exynos-chipid.c
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *	      http://www.samsung.com/
+ *
+ * EXYNOS - CHIP ID support
+ * Author: Pankaj Dubey <pankaj.dubey@samsung.com>
+ *
+ * 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/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
+#define EXYNOS5_SOC_MASK	0xFFFFF
+
+#define PROD_ID_SHIFT	(12)
+
+static void __iomem	*exynos_chipid_base;
+unsigned int exynos_soc_id = EXYNOS_SOC_UNKNOWN;
+enum exynos_soc_revision exynos_revision;
+
+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,
+};
+
+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,
+	},
+	{},
+};
+
+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;
+}
+
+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__);
+
+		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);
+	}
+
+}
diff --git a/include/linux/exynos-soc.h b/include/linux/exynos-soc.h
new file mode 100644
index 0000000..ebd4366
--- /dev/null
+++ b/include/linux/exynos-soc.h
@@ -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.
+ */
+
+#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,
+	EXYNOS4212 = 0xE4212,
+	EXYNOS4412 = 0xE4412,
+	EXYNOS5250 = 0x43520,
+	EXYNOS5420 = 0xE5420,
+	EXYNOS5440 = 0xE5440,
+	EXYNOS_SOC_UNKNOWN = -1,
+};
+
+/* 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,
+};
+
+/* Since we need chipid to be initialized as early as possible
+ * during secondary core bootup adding early initialization function
+ * Note: This should be called only after device tree gets unflatten
+ */
+extern void early_exynos_chipid_init(void);
+extern struct device *exynos_soc_device_init(void);
+extern bool is_soc_id_compatible(enum exynos_soc_id soc_id);
+extern bool is_soc_rev_compatible(enum exynos_soc_revision soc_rev);
+
+#endif /* __EXYNOS_SOC_H */
-- 
1.7.10.4


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

* [PATCH v3 6/6] ARM: EXYNOS: Refactoring to remove soc_is_exynos macros from exynos
  2014-05-10  7:20 ` [PATCH v3 0/6] Introducing Exynos ChipId driver Pankaj Dubey
                     ` (4 preceding siblings ...)
  2014-05-10  7:20   ` [PATCH v3 5/6] soc: samsung: exynos-chipid: Add Exynos Chipid driver support Pankaj Dubey
@ 2014-05-10  7:20   ` Pankaj Dubey
  2014-06-10 14:46     ` Tomasz Figa
  5 siblings, 1 reply; 31+ messages in thread
From: Pankaj Dubey @ 2014-05-10  7:20 UTC (permalink / raw)
  To: linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, t.figa, arnd, 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.

Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
---
 .../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

diff --git a/Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt b/Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt
new file mode 100644
index 0000000..a496459
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt
@@ -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>;
+	};
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a4eac2f..06f14a4 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -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)
 
diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index 2f8bcd0..d4c0657 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -46,7 +46,7 @@
 	};
 
 	chipid@10000000 {
-		compatible = "samsung,exynos4210-chipid";
+		compatible = "samsung,exynos4210-chipid", "samsung,exynos4-chipid";
 		reg = <0x10000000 0x100>;
 	};
 
diff --git a/arch/arm/boot/dts/exynos5.dtsi b/arch/arm/boot/dts/exynos5.dtsi
index 3027e37..1d0b569 100644
--- a/arch/arm/boot/dts/exynos5.dtsi
+++ b/arch/arm/boot/dts/exynos5.dtsi
@@ -19,7 +19,7 @@
 	interrupt-parent = <&gic>;
 
 	chipid@10000000 {
-		compatible = "samsung,exynos4210-chipid";
+		compatible = "samsung,exynos4210-chipid", "samsung,exynos5-chipid";
 		reg = <0x10000000 0x100>;
 	};
 
diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c
index 9902e52..26f5e8c 100644
--- a/arch/arm/mach-exynos/exynos.c
+++ b/arch/arm/mach-exynos/exynos.c
@@ -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 = {
diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c
index d0482c2..9d6ec84 100644
--- a/arch/arm/mach-exynos/platsmp.c
+++ b/arch/arm/mach-exynos/platsmp.c
@@ -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();
 
diff --git a/arch/arm/mach-exynos/pm.c b/arch/arm/mach-exynos/pm.c
index 59e5604..5cb5449 100644
--- a/arch/arm/mach-exynos/pm.c
+++ b/arch/arm/mach-exynos/pm.c
@@ -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();
diff --git a/arch/arm/plat-samsung/include/plat/cpu.h b/arch/arm/plat-samsung/include/plat/cpu.h
index 18a9a00..135471d 100644
--- a/arch/arm/plat-samsung/include/plat/cpu.h
+++ b/arch/arm/plat-samsung/include/plat/cpu.h
@@ -43,16 +43,6 @@ extern unsigned long samsung_cpu_id;
 #define S5PV210_CPU_ID		0x43110000
 #define S5PV210_CPU_MASK	0xFFFFF000
 
-#define EXYNOS4210_CPU_ID	0x43210000
-#define EXYNOS4212_CPU_ID	0x43220000
-#define EXYNOS4412_CPU_ID	0xE4412200
-#define EXYNOS4_CPU_MASK	0xFFFE0000
-
-#define EXYNOS5250_SOC_ID	0x43520000
-#define EXYNOS5420_SOC_ID	0xE5420000
-#define EXYNOS5440_SOC_ID	0xE5440000
-#define EXYNOS5_SOC_MASK	0xFFFFF000
-
 #define IS_SAMSUNG_CPU(name, id, mask)		\
 static inline int is_samsung_##name(void)	\
 {						\
@@ -68,12 +58,6 @@ IS_SAMSUNG_CPU(s5p6440, S5P6440_CPU_ID, S5P64XX_CPU_MASK)
 IS_SAMSUNG_CPU(s5p6450, S5P6450_CPU_ID, S5P64XX_CPU_MASK)
 IS_SAMSUNG_CPU(s5pc100, S5PC100_CPU_ID, S5PC100_CPU_MASK)
 IS_SAMSUNG_CPU(s5pv210, S5PV210_CPU_ID, S5PV210_CPU_MASK)
-IS_SAMSUNG_CPU(exynos4210, EXYNOS4210_CPU_ID, EXYNOS4_CPU_MASK)
-IS_SAMSUNG_CPU(exynos4212, EXYNOS4212_CPU_ID, EXYNOS4_CPU_MASK)
-IS_SAMSUNG_CPU(exynos4412, EXYNOS4412_CPU_ID, EXYNOS4_CPU_MASK)
-IS_SAMSUNG_CPU(exynos5250, EXYNOS5250_SOC_ID, EXYNOS5_SOC_MASK)
-IS_SAMSUNG_CPU(exynos5420, EXYNOS5420_SOC_ID, EXYNOS5_SOC_MASK)
-IS_SAMSUNG_CPU(exynos5440, EXYNOS5440_SOC_ID, EXYNOS5_SOC_MASK)
 
 #if defined(CONFIG_CPU_S3C2410) || defined(CONFIG_CPU_S3C2412) || \
     defined(CONFIG_CPU_S3C2416) || defined(CONFIG_CPU_S3C2440) || \
@@ -126,47 +110,6 @@ IS_SAMSUNG_CPU(exynos5440, EXYNOS5440_SOC_ID, EXYNOS5_SOC_MASK)
 # define soc_is_s5pv210()	0
 #endif
 
-#if defined(CONFIG_CPU_EXYNOS4210)
-# define soc_is_exynos4210()	is_samsung_exynos4210()
-#else
-# define soc_is_exynos4210()	0
-#endif
-
-#if defined(CONFIG_SOC_EXYNOS4212)
-# define soc_is_exynos4212()	is_samsung_exynos4212()
-#else
-# define soc_is_exynos4212()	0
-#endif
-
-#if defined(CONFIG_SOC_EXYNOS4412)
-# define soc_is_exynos4412()	is_samsung_exynos4412()
-#else
-# define soc_is_exynos4412()	0
-#endif
-
-#define EXYNOS4210_REV_0	(0x0)
-#define EXYNOS4210_REV_1_0	(0x10)
-#define EXYNOS4210_REV_1_1	(0x11)
-
-#if defined(CONFIG_SOC_EXYNOS5250)
-# define soc_is_exynos5250()	is_samsung_exynos5250()
-#else
-# define soc_is_exynos5250()	0
-#endif
-
-#if defined(CONFIG_SOC_EXYNOS5420)
-# define soc_is_exynos5420()	is_samsung_exynos5420()
-#else
-# define soc_is_exynos5420()	0
-#endif
-
-#if defined(CONFIG_SOC_EXYNOS5440)
-# define soc_is_exynos5440()	is_samsung_exynos5440()
-#else
-# define soc_is_exynos5440()	0
-#endif
-
-
 #define IODESC_ENT(x) { (unsigned long)S3C24XX_VA_##x, __phys_to_pfn(S3C24XX_PA_##x), S3C24XX_SZ_##x, MT_DEVICE }
 
 #ifndef KHZ
diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c
index b4f9672..7b0ea1f 100644
--- a/drivers/clk/samsung/clk-exynos4.c
+++ b/drivers/clk/samsung/clk-exynos4.c
@@ -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);
 
diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index f99cfe2..5fe84a1 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -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;
diff --git a/drivers/cpufreq/exynos-cpufreq.h b/drivers/cpufreq/exynos-cpufreq.h
index 3ddade8..4201b6d 100644
--- a/drivers/cpufreq/exynos-cpufreq.h
+++ b/drivers/cpufreq/exynos-cpufreq.h
@@ -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)
diff --git a/drivers/cpufreq/exynos4x12-cpufreq.c b/drivers/cpufreq/exynos4x12-cpufreq.c
index 466c76a..958d86f 100644
--- a/drivers/cpufreq/exynos4x12-cpufreq.c
+++ b/drivers/cpufreq/exynos4x12-cpufreq.c
@@ -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;
-- 
1.7.10.4


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

* Re: [PATCH v3 3/6] ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c
  2014-05-10  7:18 ` [PATCH v3 3/6] ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c y
@ 2014-05-11  6:52   ` Olof Johansson
  2014-05-12  2:22     ` Pankaj Dubey
  0 siblings, 1 reply; 31+ messages in thread
From: Olof Johansson @ 2014-05-11  6:52 UTC (permalink / raw)
  To: y
  Cc: linux-samsung-soc, linux-kernel, linux-arm-kernel, Kukjin Kim,
	Tomasz Figa, Arnd Bergmann, Pankaj Dubey, Russell King,
	Thomas Abraham

On Sat, May 10, 2014 at 12:18 AM,  <y@samsung.com> wrote:
> From: Pankaj Dubey <pankaj.dubey@samsung.com>
>
> 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 <linux@arm.linux.org.uk>
> CC: Thomas Abraham <thomas.abraham@linaro.org>
> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> ---
>  arch/arm/mach-exynos/exynos.c            |   52 +++++++++++++++++++-----------
>  arch/arm/plat-samsung/include/plat/cpu.h |    3 --
>  2 files changed, 33 insertions(+), 22 deletions(-)
>
> diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c
> index 09063ee..9902e52 100644
> --- a/arch/arm/mach-exynos/exynos.c
> +++ b/arch/arm/mach-exynos/exynos.c
> @@ -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)")

SAMSUNG EXYNOS5

> +       /* Maintainer: Thomas Abraham <thomas.abraham@linaro.org> */
> +       /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
> +       .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)")

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

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

* Re: [PATCH v3 6/6] ARM: EXYNOS: Refactoring to remove soc_is_exynos macros from exynos
  2014-05-10  7:18 ` [PATCH v3 6/6] ARM: EXYNOS: Refactoring to remove soc_is_exynos macros from exynos y
@ 2014-05-11  7:10   ` Olof Johansson
  2014-05-12  2:13     ` Pankaj Dubey
  0 siblings, 1 reply; 31+ messages in thread
From: Olof Johansson @ 2014-05-11  7:10 UTC (permalink / raw)
  To: y
  Cc: linux-samsung-soc, linux-kernel, linux-arm-kernel, Kukjin Kim,
	Tomasz Figa, Arnd Bergmann, Pankaj Dubey

On Sat, May 10, 2014 at 12:18 AM,  <y@samsung.com> wrote:
> From: Pankaj Dubey <pankaj.dubey@samsung.com>
>
> 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.
>
> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> ---
>  .../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
>
> diff --git a/Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt b/Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt
> new file mode 100644
> index 0000000..a496459
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt
> @@ -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>;
> +       };

This needs to go with the patch adding the driver.

> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index a4eac2f..06f14a4 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -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)
>
> diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
> index 2f8bcd0..d4c0657 100644
> --- a/arch/arm/boot/dts/exynos4.dtsi
> +++ b/arch/arm/boot/dts/exynos4.dtsi
> @@ -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).

>                 reg = <0x10000000 0x100>;
>         };
>
> diff --git a/arch/arm/boot/dts/exynos5.dtsi b/arch/arm/boot/dts/exynos5.dtsi
> index 3027e37..1d0b569 100644
> --- a/arch/arm/boot/dts/exynos5.dtsi
> +++ b/arch/arm/boot/dts/exynos5.dtsi
> @@ -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.

>                 reg = <0x10000000 0x100>;
>         };
>
> diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c
> index 9902e52..26f5e8c 100644
> --- a/arch/arm/mach-exynos/exynos.c
> +++ b/arch/arm/mach-exynos/exynos.c
> @@ -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 = {
> diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c
> index d0482c2..9d6ec84 100644
> --- a/arch/arm/mach-exynos/platsmp.c
> +++ b/arch/arm/mach-exynos/platsmp.c
> @@ -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;

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.


>         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();
>
> diff --git a/arch/arm/mach-exynos/pm.c b/arch/arm/mach-exynos/pm.c
> index 59e5604..5cb5449 100644
> --- a/arch/arm/mach-exynos/pm.c
> +++ b/arch/arm/mach-exynos/pm.c
> @@ -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();

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.


> diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c
> index b4f9672..7b0ea1f 100644
> --- a/drivers/clk/samsung/clk-exynos4.c
> +++ b/drivers/clk/samsung/clk-exynos4.c
> @@ -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.

>         if (np) {
>                 chipid_base = of_iomap(np, 0);
>
> diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
> index f99cfe2..5fe84a1 100644
> --- a/drivers/cpufreq/exynos-cpufreq.c
> +++ b/drivers/cpufreq/exynos-cpufreq.c
> @@ -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);

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

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

* Re: [PATCH v3 0/6] Introducing Exynos ChipId driver
  2014-05-10  7:18 [PATCH v3 0/6] Introducing Exynos ChipId driver y
                   ` (6 preceding siblings ...)
  2014-05-10  7:20 ` [PATCH v3 0/6] Introducing Exynos ChipId driver Pankaj Dubey
@ 2014-05-11  7:12 ` Olof Johansson
  2014-05-12  1:52   ` Pankaj Dubey
  7 siblings, 1 reply; 31+ messages in thread
From: Olof Johansson @ 2014-05-11  7:12 UTC (permalink / raw)
  To: y
  Cc: linux-samsung-soc, linux-kernel, linux-arm-kernel, Kukjin Kim,
	Tomasz Figa, Arnd Bergmann, Pankaj Dubey

Hi,

On Sat, May 10, 2014 at 12:18 AM,  <y@samsung.com> wrote:
> From: Pankaj Dubey <pankaj.dubey@samsung.com>
>
> 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

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

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

* Re: [PATCH v3 0/6] Introducing Exynos ChipId driver
  2014-05-12  1:52   ` Pankaj Dubey
@ 2014-05-12  1:51     ` Olof Johansson
  0 siblings, 0 replies; 31+ messages in thread
From: Olof Johansson @ 2014-05-12  1:51 UTC (permalink / raw)
  To: Pankaj Dubey
  Cc: linux-samsung-soc, linux-kernel, linux-arm-kernel, Kukjin Kim,
	Tomasz Figa, Arnd Bergmann

Hi,

On Sun, May 11, 2014 at 6:52 PM, Pankaj Dubey <pankaj.dubey@samsung.com> wrote:
> On 05/11/2014 04:12 PM, Olof Johansson wrote:
>>
>> Hi,
>>
>> On Sat, May 10, 2014 at 12:18 AM,  <y@samsung.com> wrote:
>>>
>>> From: Pankaj Dubey <pankaj.dubey@samsung.com>
>>>
>>> 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
>>
>> 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

Ok, I've commented on that thread now.

> 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.

> 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.

> 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

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

* Re: [PATCH v3 0/6] Introducing Exynos ChipId driver
  2014-05-11  7:12 ` [PATCH v3 0/6] Introducing Exynos ChipId driver Olof Johansson
@ 2014-05-12  1:52   ` Pankaj Dubey
  2014-05-12  1:51     ` Olof Johansson
  0 siblings, 1 reply; 31+ messages in thread
From: Pankaj Dubey @ 2014-05-12  1:52 UTC (permalink / raw)
  To: Olof Johansson
  Cc: Pankaj Dubey, linux-samsung-soc, linux-kernel, linux-arm-kernel,
	Kukjin Kim, Tomasz Figa, Arnd Bergmann

On 05/11/2014 04:12 PM, Olof Johansson wrote:
> Hi,
>
> On Sat, May 10, 2014 at 12:18 AM,  <y@samsung.com> wrote:
>> From: Pankaj Dubey <pankaj.dubey@samsung.com>
>>
>> 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
> 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.

> 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.

>
> -Olof
>


-- 
Best Regards,
Pankaj Dubey


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

* Re: [PATCH v3 6/6] ARM: EXYNOS: Refactoring to remove soc_is_exynos macros from exynos
  2014-05-11  7:10   ` Olof Johansson
@ 2014-05-12  2:13     ` Pankaj Dubey
  0 siblings, 0 replies; 31+ messages in thread
From: Pankaj Dubey @ 2014-05-12  2:13 UTC (permalink / raw)
  To: Olof Johansson
  Cc: Pankaj Dubey, linux-samsung-soc, linux-kernel, linux-arm-kernel,
	Kukjin Kim, Tomasz Figa, Arnd Bergmann

On 05/11/2014 04:10 PM, Olof Johansson wrote:
> On Sat, May 10, 2014 at 12:18 AM,  <y@samsung.com> wrote:
>> From: Pankaj Dubey <pankaj.dubey@samsung.com>
>>
>> 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.
>>
>> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
>> ---
>>   .../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
>>
>> diff --git a/Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt b/Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt
>> new file mode 100644
>> index 0000000..a496459
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt
>> @@ -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>;
>> +       };
> This needs to go with the patch adding the driver.

OK, will make this along with driver.

>
>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
>> index a4eac2f..06f14a4 100644
>> --- a/arch/arm/Kconfig
>> +++ b/arch/arm/Kconfig
>> @@ -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)
>>
>> diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
>> index 2f8bcd0..d4c0657 100644
>> --- a/arch/arm/boot/dts/exynos4.dtsi
>> +++ b/arch/arm/boot/dts/exynos4.dtsi
>> @@ -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).
>
>>                  reg = <0x10000000 0x100>;
>>          };
>>
>> diff --git a/arch/arm/boot/dts/exynos5.dtsi b/arch/arm/boot/dts/exynos5.dtsi
>> index 3027e37..1d0b569 100644
>> --- a/arch/arm/boot/dts/exynos5.dtsi
>> +++ b/arch/arm/boot/dts/exynos5.dtsi
>> @@ -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.
>
>>                  reg = <0x10000000 0x100>;
>>          };
>>
>> diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c
>> index 9902e52..26f5e8c 100644
>> --- a/arch/arm/mach-exynos/exynos.c
>> +++ b/arch/arm/mach-exynos/exynos.c
>> @@ -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 = {
>> diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c
>> index d0482c2..9d6ec84 100644
>> --- a/arch/arm/mach-exynos/platsmp.c
>> +++ b/arch/arm/mach-exynos/platsmp.c
>> @@ -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;
> 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.
>
>
>>          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();
>>
>> diff --git a/arch/arm/mach-exynos/pm.c b/arch/arm/mach-exynos/pm.c
>> index 59e5604..5cb5449 100644
>> --- a/arch/arm/mach-exynos/pm.c
>> +++ b/arch/arm/mach-exynos/pm.c
>> @@ -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();
> 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.


>
>> diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c
>> index b4f9672..7b0ea1f 100644
>> --- a/drivers/clk/samsung/clk-exynos4.c
>> +++ b/drivers/clk/samsung/clk-exynos4.c
>> @@ -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.
OK.
>
>>          if (np) {
>>                  chipid_base = of_iomap(np, 0);
>>
>> diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
>> index f99cfe2..5fe84a1 100644
>> --- a/drivers/cpufreq/exynos-cpufreq.c
>> +++ b/drivers/cpufreq/exynos-cpufreq.c
>> @@ -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);
> 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
>


-- 
Best Regards,
Pankaj Dubey


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

* Re: [PATCH v3 3/6] ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c
  2014-05-11  6:52   ` Olof Johansson
@ 2014-05-12  2:22     ` Pankaj Dubey
  0 siblings, 0 replies; 31+ messages in thread
From: Pankaj Dubey @ 2014-05-12  2:22 UTC (permalink / raw)
  To: Olof Johansson
  Cc: Pankaj Dubey, linux-samsung-soc, linux-kernel, linux-arm-kernel,
	Kukjin Kim, Tomasz Figa, Arnd Bergmann, Russell King,
	Thomas Abraham

On 05/11/2014 03:52 PM, Olof Johansson wrote:
> On Sat, May 10, 2014 at 12:18 AM,  <y@samsung.com> wrote:
>> From: Pankaj Dubey <pankaj.dubey@samsung.com>
>>
>> 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 <linux@arm.linux.org.uk>
>> CC: Thomas Abraham <thomas.abraham@linaro.org>
>> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
>> ---
>>   arch/arm/mach-exynos/exynos.c            |   52 +++++++++++++++++++-----------
>>   arch/arm/plat-samsung/include/plat/cpu.h |    3 --
>>   2 files changed, 33 insertions(+), 22 deletions(-)
>>
>> diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c
>> index 09063ee..9902e52 100644
>> --- a/arch/arm/mach-exynos/exynos.c
>> +++ b/arch/arm/mach-exynos/exynos.c
>> @@ -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)")
> SAMSUNG EXYNOS5
>
>> +       /* Maintainer: Thomas Abraham <thomas.abraham@linaro.org> */
>> +       /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
>> +       .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)")
> 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.
>

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

> -Olof
>


-- 
Best Regards,
Pankaj Dubey


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

* Re: [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver
  2014-05-10  7:20   ` [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver Pankaj Dubey
@ 2014-06-02 17:14     ` Wolfram Sang
  2014-06-10 13:35     ` Tomasz Figa
  1 sibling, 0 replies; 31+ messages in thread
From: Wolfram Sang @ 2014-06-02 17:14 UTC (permalink / raw)
  To: Pankaj Dubey
  Cc: linux-samsung-soc, linux-kernel, linux-arm-kernel, kgene.kim,
	t.figa, arnd, Rob Herring, Randy Dunlap, Russell King,
	devicetree, linux-doc, linux-i2c

[-- Attachment #1: Type: text/plain, Size: 1131 bytes --]

On Sat, May 10, 2014 at 04:20:14PM +0900, Pankaj Dubey wrote:
> 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 <robh+dt@kernel.org>
> CC: Randy Dunlap <rdunlap@infradead.org>
> CC: Wolfram Sang <wsa@the-dreams.de>
> CC: Russell King <linux@arm.linux.org.uk>
> CC: devicetree@vger.kernel.org
> CC: linux-doc@vger.kernel.org
> CC: linux-i2c@vger.kernel.org
> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>

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:

> +	regmap_update_bits(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, BIT(id), val);

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


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver
  2014-05-10  7:20   ` [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver Pankaj Dubey
  2014-06-02 17:14     ` Wolfram Sang
@ 2014-06-10 13:35     ` Tomasz Figa
  2014-06-17  4:21       ` Pankaj Dubey
  1 sibling, 1 reply; 31+ messages in thread
From: Tomasz Figa @ 2014-06-10 13:35 UTC (permalink / raw)
  To: Pankaj Dubey, linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, arnd, Rob Herring, Randy Dunlap, Wolfram Sang,
	Russell King, devicetree, linux-doc, linux-i2c

Hi Pankaj,

On 10.05.2014 09:20, Pankaj Dubey wrote:
> 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 <robh+dt@kernel.org>
> CC: Randy Dunlap <rdunlap@infradead.org>
> CC: Wolfram Sang <wsa@the-dreams.de>
> CC: Russell King <linux@arm.linux.org.uk>
> CC: devicetree@vger.kernel.org
> CC: linux-doc@vger.kernel.org
> CC: linux-i2c@vger.kernel.org
> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> ---
>  .../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?

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

[snip]

> diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
> index ae44910..e707062 100644
> --- a/drivers/i2c/busses/i2c-s3c2410.c
> +++ b/drivers/i2c/busses/i2c-s3c2410.c
> @@ -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;

typo: s/i2s/i2c/

>  };
>  
>  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

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.

> +	 * 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);

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

>  }
>  #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);

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

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

* Re: [PATCH v3 2/6] ARM: EXYNOS: Remove i2c sys configuration related code
  2014-05-10  7:20   ` [PATCH v3 2/6] ARM: EXYNOS: Remove i2c sys configuration related code Pankaj Dubey
@ 2014-06-10 13:52     ` Tomasz Figa
  0 siblings, 0 replies; 31+ messages in thread
From: Tomasz Figa @ 2014-06-10 13:52 UTC (permalink / raw)
  To: Pankaj Dubey, linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, arnd, Russell King

Hi Pankaj,

On 10.05.2014 09:20, Pankaj Dubey wrote:
> Since all these code has been moved into i2c driver, now we can
> safely remove them from machine files.
> 
> CC: Russell King <linux@arm.linux.org.uk>
> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> ---
>  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
> 
> diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c
> index 59eb1f1..09063ee 100644
> --- a/arch/arm/mach-exynos/exynos.c
> +++ b/arch/arm/mach-exynos/exynos.c
> @@ -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,

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

Reviewed-by: Tomasz Figa <t.figa@samsung.com>

Best regards,
Tomasz

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

* Re: [PATCH v3 3/6] ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c
  2014-05-10  7:20   ` [PATCH v3 3/6] ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c Pankaj Dubey
@ 2014-06-10 13:55     ` Tomasz Figa
  2014-06-10 14:04       ` Arnd Bergmann
  0 siblings, 1 reply; 31+ messages in thread
From: Tomasz Figa @ 2014-06-10 13:55 UTC (permalink / raw)
  To: Pankaj Dubey, linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, arnd, Russell King, Thomas Abraham

On 10.05.2014 09:20, Pankaj Dubey wrote:
> 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 <linux@arm.linux.org.uk>
> CC: Thomas Abraham <thomas.abraham@linaro.org>
> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> ---
>  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

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

* Re: [PATCH v3 4/6] ARM:  EXYNOS: Remove unused header inclusion from hotplug.c
  2014-05-10  7:20   ` [PATCH v3 4/6] ARM: EXYNOS: Remove unused header inclusion from hotplug.c Pankaj Dubey
@ 2014-06-10 13:56     ` Tomasz Figa
  2014-06-17  3:52       ` Pankaj Dubey
  0 siblings, 1 reply; 31+ messages in thread
From: Tomasz Figa @ 2014-06-10 13:56 UTC (permalink / raw)
  To: Pankaj Dubey, linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, arnd

Hi Pankaj,

On 10.05.2014 09:20, Pankaj Dubey wrote:
> This patch removed "plat/cpu.h" inclusion from hotplug.c as it
> is not required.
> 
> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> ---
>  arch/arm/mach-exynos/hotplug.c |    2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/arch/arm/mach-exynos/hotplug.c b/arch/arm/mach-exynos/hotplug.c
> index 0243ef3..5e19601 100644
> --- a/arch/arm/mach-exynos/hotplug.c
> +++ b/arch/arm/mach-exynos/hotplug.c
> @@ -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

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

* Re: [PATCH v3 3/6] ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c
  2014-06-10 13:55     ` Tomasz Figa
@ 2014-06-10 14:04       ` Arnd Bergmann
  0 siblings, 0 replies; 31+ messages in thread
From: Arnd Bergmann @ 2014-06-10 14:04 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Tomasz Figa, Pankaj Dubey, linux-samsung-soc, linux-kernel,
	Thomas Abraham, kgene.kim, Russell King

On Tuesday 10 June 2014 15:55:09 Tomasz Figa wrote:
> On 10.05.2014 09:20, Pankaj Dubey wrote:
> > 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 <linux@arm.linux.org.uk>
> > CC: Thomas Abraham <thomas.abraham@linaro.org>
> > Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> > ---
> >  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.

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

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

* Re: [PATCH v3 5/6] soc: samsung: exynos-chipid: Add Exynos Chipid driver support
  2014-05-10  7:20   ` [PATCH v3 5/6] soc: samsung: exynos-chipid: Add Exynos Chipid driver support Pankaj Dubey
@ 2014-06-10 14:36     ` Tomasz Figa
  0 siblings, 0 replies; 31+ messages in thread
From: Tomasz Figa @ 2014-06-10 14:36 UTC (permalink / raw)
  To: Pankaj Dubey, linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, arnd

Hi Pankaj,

On 10.05.2014 09:20, Pankaj Dubey wrote:
> 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.
> 
> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> ---
>  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
> 
> diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
> index 07a11be..86e52b1 100644
> --- a/drivers/soc/Kconfig
> +++ b/drivers/soc/Kconfig
> @@ -1,5 +1,6 @@
>  menu "SOC specific Drivers"
>  
>  source "drivers/soc/qcom/Kconfig"
> +source "drivers/soc/samsung/Kconfig"
>  
>  endmenu
> diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
> index 0f7c447..ee890aa 100644
> --- a/drivers/soc/Makefile
> +++ b/drivers/soc/Makefile
> @@ -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?

> diff --git a/drivers/soc/samsung/Kconfig b/drivers/soc/samsung/Kconfig
> new file mode 100644
> index 0000000..dacc95d
> --- /dev/null
> +++ b/drivers/soc/samsung/Kconfig
> @@ -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.

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

> +#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?

> +enum exynos_soc_revision exynos_revision;

static?

> +
> +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,
> +};
> +
> +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).

> +	},
> +	{},
> +};
> +
> +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.)

> +
> +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__);
> +
> +		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.

> diff --git a/include/linux/exynos-soc.h b/include/linux/exynos-soc.h
> new file mode 100644
> index 0000000..ebd4366
> --- /dev/null
> +++ b/include/linux/exynos-soc.h
> @@ -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.
> + */
> +
> +#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.

> +	EXYNOS4212 = 0xE4212,

Should be 0x43220.

> +	EXYNOS4412 = 0xE4412,
> +	EXYNOS5250 = 0x43520,
> +	EXYNOS5420 = 0xE5420,
> +	EXYNOS5440 = 0xE5440,
> +	EXYNOS_SOC_UNKNOWN = -1,
> +};
> +
> +/* 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

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

* Re: [PATCH v3 6/6] ARM: EXYNOS: Refactoring to remove soc_is_exynos macros from exynos
  2014-05-10  7:20   ` [PATCH v3 6/6] ARM: EXYNOS: Refactoring to remove soc_is_exynos macros from exynos Pankaj Dubey
@ 2014-06-10 14:46     ` Tomasz Figa
  0 siblings, 0 replies; 31+ messages in thread
From: Tomasz Figa @ 2014-06-10 14:46 UTC (permalink / raw)
  To: Pankaj Dubey, linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, arnd

Hi Pankaj,

On 10.05.2014 09:20, Pankaj Dubey wrote:
> 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]

> diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c
> index d0482c2..9d6ec84 100644
> --- a/arch/arm/mach-exynos/platsmp.c
> +++ b/arch/arm/mach-exynos/platsmp.c
> @@ -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))

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

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

* RE: [PATCH v3 4/6] ARM:  EXYNOS: Remove unused header inclusion from hotplug.c
  2014-06-10 13:56     ` Tomasz Figa
@ 2014-06-17  3:52       ` Pankaj Dubey
  0 siblings, 0 replies; 31+ messages in thread
From: Pankaj Dubey @ 2014-06-17  3:52 UTC (permalink / raw)
  To: 'Tomasz Figa', linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, arnd

Hi Tomasz,


> -----Original Message-----
> 
> Hi Pankaj,
> 
> On 10.05.2014 09:20, Pankaj Dubey wrote:
> > This patch removed "plat/cpu.h" inclusion from hotplug.c as it is not
> > required.
> >
> > Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> > ---
> >  arch/arm/mach-exynos/hotplug.c |    2 --
> >  1 file changed, 2 deletions(-)
> >
> > diff --git a/arch/arm/mach-exynos/hotplug.c
> > b/arch/arm/mach-exynos/hotplug.c index 0243ef3..5e19601 100644
> > --- a/arch/arm/mach-exynos/hotplug.c
> > +++ b/arch/arm/mach-exynos/hotplug.c
> > @@ -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.
> 

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

> Best regards,
> Tomasz

Thanks,
Pankaj Dubey


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

* RE: [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver
  2014-06-10 13:35     ` Tomasz Figa
@ 2014-06-17  4:21       ` Pankaj Dubey
  0 siblings, 0 replies; 31+ messages in thread
From: Pankaj Dubey @ 2014-06-17  4:21 UTC (permalink / raw)
  To: 'Tomasz Figa', linux-samsung-soc, linux-kernel, linux-arm-kernel
  Cc: kgene.kim, arnd, 'Rob Herring', 'Randy Dunlap',
	'Wolfram Sang', 'Russell King',
	devicetree, linux-doc, linux-i2c

Hi Tomasz,

> 
> Hi Pankaj,
> 
> On 10.05.2014 09:20, Pankaj Dubey wrote:
> > 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 <robh+dt@kernel.org>
> > CC: Randy Dunlap <rdunlap@infradead.org>
> > CC: Wolfram Sang <wsa@the-dreams.de>
> > CC: Russell King <linux@arm.linux.org.uk>
> > CC: devicetree@vger.kernel.org
> > CC: linux-doc@vger.kernel.org
> > CC: linux-i2c@vger.kernel.org
> > Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> > ---
> >  .../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?

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

> 
> >  drivers/i2c/busses/i2c-s3c2410.c                   |   32
> ++++++++++++++++++++
> >  5 files changed, 46 insertions(+)
> 
> [snip]
> 
> > diff --git a/drivers/i2c/busses/i2c-s3c2410.c
> > b/drivers/i2c/busses/i2c-s3c2410.c
> > index ae44910..e707062 100644
> > --- a/drivers/i2c/busses/i2c-s3c2410.c
> > +++ b/drivers/i2c/busses/i2c-s3c2410.c
> > @@ -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;
> 
> typo: s/i2s/i2c/

Oops, sorry I will correct this. 

> 
> >  };
> >
> >  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
> 
> What do you mean by "by default"? Is it a setting from the bootloader or
reset value?
> 

It's a reset value.

> Probably to ensure that the mux is set correctly, same thing should be
also added to
> hsi2c driver.
> 
> > +	 * 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);
> 
> As Wolfram pointed, val can be replaced with immediate 0 here.

OK, I will take care as per suggestion.

> 
> >  }
> >  #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);
> 
> 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.

> 
> Best regards,
> Tomasz


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

end of thread, other threads:[~2014-06-17  4:21 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-10  7:18 [PATCH v3 0/6] Introducing Exynos ChipId driver y
2014-05-10  7:18 ` [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver y
2014-05-10  7:18 ` [PATCH v3 2/6] ARM: EXYNOS: Remove i2c sys configuration related code y
2014-05-10  7:18 ` [PATCH v3 3/6] ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c y
2014-05-11  6:52   ` Olof Johansson
2014-05-12  2:22     ` Pankaj Dubey
2014-05-10  7:18 ` [PATCH v3 4/6] ARM: EXYNOS: Remove unused header inclusion from hotplug.c y
2014-05-10  7:18 ` [PATCH v3 5/6] soc: samsung: exynos-chipid: Add Exynos Chipid driver support y
2014-05-10  7:18 ` [PATCH v3 6/6] ARM: EXYNOS: Refactoring to remove soc_is_exynos macros from exynos y
2014-05-11  7:10   ` Olof Johansson
2014-05-12  2:13     ` Pankaj Dubey
2014-05-10  7:20 ` [PATCH v3 0/6] Introducing Exynos ChipId driver Pankaj Dubey
2014-05-10  7:20   ` [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver Pankaj Dubey
2014-06-02 17:14     ` Wolfram Sang
2014-06-10 13:35     ` Tomasz Figa
2014-06-17  4:21       ` Pankaj Dubey
2014-05-10  7:20   ` [PATCH v3 2/6] ARM: EXYNOS: Remove i2c sys configuration related code Pankaj Dubey
2014-06-10 13:52     ` Tomasz Figa
2014-05-10  7:20   ` [PATCH v3 3/6] ARM: EXYNOS: Remove soc_is_exynos4/5 from exynos.c Pankaj Dubey
2014-06-10 13:55     ` Tomasz Figa
2014-06-10 14:04       ` Arnd Bergmann
2014-05-10  7:20   ` [PATCH v3 4/6] ARM: EXYNOS: Remove unused header inclusion from hotplug.c Pankaj Dubey
2014-06-10 13:56     ` Tomasz Figa
2014-06-17  3:52       ` Pankaj Dubey
2014-05-10  7:20   ` [PATCH v3 5/6] soc: samsung: exynos-chipid: Add Exynos Chipid driver support Pankaj Dubey
2014-06-10 14:36     ` Tomasz Figa
2014-05-10  7:20   ` [PATCH v3 6/6] ARM: EXYNOS: Refactoring to remove soc_is_exynos macros from exynos Pankaj Dubey
2014-06-10 14:46     ` Tomasz Figa
2014-05-11  7:12 ` [PATCH v3 0/6] Introducing Exynos ChipId driver Olof Johansson
2014-05-12  1:52   ` Pankaj Dubey
2014-05-12  1:51     ` Olof Johansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).