Introducing Exynos ChipId driver
Subsystems (9)
v2 cover Introducing Exynos ChipId driver
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.
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
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: Moving I2C interrupt re-configuration code into i2c
driver
ARM: EXYNOS: Move SYS_I2C_CFG register save/restore to i2c driver
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_exynosXXXX 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 | 10 +- 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 | 35 +++++ 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, 359 insertions(+), 210 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt delete mode 100644 arch/arm/mach-exynos/regs-sys.h create mode 100644 drivers/soc/samsung/Kconfig create mode 100644 drivers/soc/samsung/Makefile create mode 100644 drivers/soc/samsung/exynos-chipid.c create mode 100644 include/linux/exynos-soc.h
Signature · 1 line
1.7.10.4
PATCH v2 1/6 i2c: s3c2410: Moving I2C interrupt re-configuration code into i2c driver
Let's move I2C interrupt re-configuration code from machine file exynos.c to I2C driver. Since only Exynos5250, and Exynos5420 need to do this, added syscon based phandle to i2c device nodes of respective SoC DT files.
--- .../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 +++ arch/arm/mach-exynos/exynos.c | 26 ------------------- drivers/i2c/busses/i2c-s3c2410.c | 27 ++++++++++++++++++++ 6 files changed, 41 insertions(+), 26 deletions(-)
Documentation/devicetree/bindings/arm/samsung/sysreg.txt +1 -0
@@ -3,6 +3,7 @@ SAMSUNG S5P/Exynos SoC series System Registers (SYSREG) Properties: - compatible : should contain "samsung,<chip name>-sysreg", "syscon"; For Exynos4 SoC series it should be "samsung,exynos4-sysreg", "syscon"; + For Exynos5 SoC series it should be "samsung,exynos5-sysreg", "syscon"; - reg : offset and length of the register set. Example:
arch/arm/boot/dts/exynos5.dtsi +5 -0
@@ -99,4 +99,9 @@ #size-cells = <0>; status = "disabled"; }; + + sys_reg: syscon@10050000 { + compatible = "samsung,exynos5-sysreg", "syscon"; + reg = <0x10050000 0x400>; + }; };
arch/arm/boot/dts/exynos5250.dtsi +4 -0
@@ -285,6 +285,7 @@ clock-names = "i2c"; pinctrl-names = "default"; pinctrl-0 = <&i2c0_bus>; + samsung,syscon-phandle = <&sys_reg>; status = "disabled"; };
@@ -298,6 +299,7 @@ clock-names = "i2c"; pinctrl-names = "default"; pinctrl-0 = <&i2c1_bus>; + samsung,syscon-phandle = <&sys_reg>; status = "disabled"; };
@@ -311,6 +313,7 @@ clock-names = "i2c"; pinctrl-names = "default"; pinctrl-0 = <&i2c2_bus>; + samsung,syscon-phandle = <&sys_reg>; status = "disabled"; };
@@ -324,6 +327,7 @@ clock-names = "i2c"; pinctrl-names = "default"; pinctrl-0 = <&i2c3_bus>; + samsung,syscon-phandle = <&sys_reg>; status = "disabled"; };
arch/arm/boot/dts/exynos5420.dtsi +4 -0
@@ -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"; };
arch/arm/mach-exynos/exynos.c +0 -26
@@ -293,32 +293,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 ())
drivers/i2c/busses/i2c-s3c2410.c +27 -0
@@ -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,7 @@ struct s3c24xx_i2c {#if defined(CONFIG_ARM_S3C24XX_CPUFREQ )struct notifier_block freq_transition;#endif +struct regmap *sysreg; };static struct platform_device_id s3c24xx_driver_ids[] = {
@@ -1075,6 +1081,8 @@ static void s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) { struct s3c2410_platform_i2c *pdata = i2c->pdata; +unsigned int tmp; +int id;if (!np)return ;
@@ -1084,6 +1092,25 @@ 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)) { + i2c->sysreg =NULL ; +/* As this is not compulsary do not return error */ +pr_info ("i2c-%d skipping re-configuration of interrutps\n" , id); +return ; + } +regmap_read (i2c->sysreg,EXYNOS5_SYS_I2C_CFG , &tmp); +regmap_write (i2c->sysreg,EXYNOS5_SYS_I2C_CFG , tmp & ~(0x1 << id)); }#else static void
Signature · 1 line
1.7.10.4
Re: [PATCH v2 1/6] i2c: s3c2410: Moving I2C interrupt re-configuration code into i2c driver
Hi Pankaj,
Quoted 204 lines · Pankaj Dubey
Let's move I2C interrupt re-configuration code from machine file
exynos.cto I2C driver. Since only Exynos5250, and Exynos5420 need to do this, added syscon based phandle to i2c device nodes of respective SoC DT files.CC Rob Herring <[email protected]>CC Randy Dunlap <[email protected]>CC Wolfram Sang <[email protected]>CC Russell King <[email protected]>CC devicetree at vger.kernel.orgCC linux-doc at vger.kernel.orgCC linux-i2c at vger.kernel.orgSigned-off-by Pankaj Dubey <[email protected]>--- .../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 +++ arch/arm/mach-exynos/exynos.c | 26 ------------------- drivers/i2c/busses/i2c-s3c2410.c | 27 ++++++++++++++++++++ 6 files changed, 41 insertions(+), 26 deletions(-)Documentation/devicetree/bindings/arm/samsung/sysreg.txt +1
-0@@ -3,6 +3,7 @@ SAMSUNG S5P/Exynos SoC series System Registers (SYSREG) Properties: - compatible : should contain "samsung,<chip name>-sysreg", "syscon"; For Exynos4 SoC series it should be "samsung,exynos4-sysreg", "syscon"; + For Exynos5 SoC series it should be "samsung,exynos5-sysreg", "syscon"; - reg : offset and length of the register set. Example:arch/arm/boot/dts/exynos5.dtsi +5
-0@@ -99,4 +99,9 @@ #size-cells = <0>; status = "disabled"; }; + + sys_reg: syscon at 10050000 { + compatible = "samsung,exynos5-sysreg", "syscon"; + reg = <0x10050000 0x400>; + }; };arch/arm/boot/dts/exynos5250.dtsi +4
-0@@ -285,6 +285,7 @@ clock-names = "i2c"; pinctrl-names = "default"; pinctrl-0 = <&i2c0_bus>; + samsung,syscon-phandle = <&sys_reg>; status = "disabled"; };@@ -298,6 +299,7 @@ clock-names = "i2c"; pinctrl-names = "default"; pinctrl-0 = <&i2c1_bus>; + samsung,syscon-phandle = <&sys_reg>; status = "disabled"; };@@ -311,6 +313,7 @@ clock-names = "i2c"; pinctrl-names = "default"; pinctrl-0 = <&i2c2_bus>; + samsung,syscon-phandle = <&sys_reg>; status = "disabled"; };@@ -324,6 +327,7 @@ clock-names = "i2c"; pinctrl-names = "default"; pinctrl-0 = <&i2c3_bus>; + samsung,syscon-phandle = <&sys_reg>; status = "disabled"; };arch/arm/boot/dts/exynos5420.dtsi +4
-0@@ -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"; };arch/arm/mach-exynos/exynos.c +0
-26@@ -293,32 +293,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 ())drivers/i2c/busses/i2c-s3c2410.c +11
-0@@ -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,7 @@ struct s3c24xx_i2c {#if defined(CONFIG_ARM_S3C24XX_CPUFREQ )struct notifier_block freq_transition;#endif +struct regmap *sysreg; };static struct platform_device_id s3c24xx_driver_ids[] = {@@ -1075,6 +1081,8 @@ static void s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) { struct s3c2410_platform_i2c *pdata = i2c->pdata; +unsigned int tmp; +int id;if (!np)return ;@@ -1084,6 +1092,25 @@ 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
drivers/i2c/busses/i2c-s3c2410.c s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) · line 1107
Quoted 10 lines
drivers/i2c/busses/i2c-s3c2410.c +10
-0+* interrupts for 4-channel HS-I2C controller are enabled. +* If node for first four channels of legacy i2c controller +* are available then re-configure the interrupts via the +* system register. +*/ + id =of_alias_get_id (np,"i2c" ); + i2c->sysreg =syscon_regmap_lookup_by_phandle (np, +"samsung,syscon-phandle" ); +if (IS_ERR (i2c->sysreg)) { + i2c->sysreg =NULL ;
NULL shouldn't be considered for pointers using the ERR_PTR() convention, so you should just preserve the value returned by syscon_regmap_lookup_by_phandle() here.
Also, the driver seems to do this only once in probe, so maybe you should simply use a local variable here, without storing the regmap in i2c struct.
drivers/i2c/busses/i2c-s3c2410.c s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) · line 1108
Quoted 1 line
drivers/i2c/busses/i2c-s3c2410.c +1
-0+/* As this is not compulsary do not return error */
Is it? Will the driver work normally without interrupts in this case?
Also, typo: s/compulsary/compulsory/
drivers/i2c/busses/i2c-s3c2410.c s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) · line 1113
Quoted 5 lines
drivers/i2c/busses/i2c-s3c2410.c +5
-0+pr_info ("i2c-%d skipping re-configuration of interrutps\n" , id); +return ; + } +regmap_read (i2c->sysreg,EXYNOS5_SYS_I2C_CFG , &tmp); +regmap_write (i2c->sysreg,EXYNOS5_SYS_I2C_CFG , tmp & ~(0x1 << id));
You could use regmap_update_bits() [1] here instead, with mask set to BIT(id) and val set to 0.
[1] http://lxr.free-electrons.com/source/drivers/base/regmap/regmap.c#L1977
Best regards,
Tomasz
Re: [PATCH v2 1/6] i2c: s3c2410: Moving I2C interrupt re-configuration code into i2c driver
Hi Tomasz,
Thanks for review.
Quoted 216 lines · Tomasz Figa
Hi Pankaj,
Quoted 213 lines · Pankaj Dubey
Let's move I2C interrupt re-configuration code from machine file
exynos.cto I2C driver. Since only Exynos5250, and Exynos5420 need to do this, added syscon based phandle to i2c device nodes of respective SoC DT files.CC Rob Herring <[email protected]>CC Randy Dunlap <[email protected]>CC Wolfram Sang <[email protected]>CC Russell King <[email protected]>Signed-off-by Pankaj Dubey <[email protected]>--- .../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 +++ arch/arm/mach-exynos/exynos.c | 26 ------------------- drivers/i2c/busses/i2c-s3c2410.c | 27 ++++++++++++++++++++ 6 files changed, 41 insertions(+), 26 deletions(-)Documentation/devicetree/bindings/arm/samsung/sysreg.txt +1
-0@@ -3,6 +3,7 @@ SAMSUNG S5P/Exynos SoC series System Registers (SYSREG) Properties: - compatible : should contain "samsung,<chip name>-sysreg", "syscon"; For Exynos4 SoC series it should be "samsung,exynos4-sysreg", "syscon"; + For Exynos5 SoC series it should be "samsung,exynos5-sysreg", "syscon"; - reg : offset and length of the register set.Example:
arch/arm/boot/dts/exynos5.dtsi +5
-0@@ -99,4 +99,9 @@ #size-cells = <0>; status = "disabled"; }; + + sys_reg: syscon@10050000 { + compatible = "samsung,exynos5-sysreg", "syscon"; + reg = <0x10050000 0x400>; + }; };arch/arm/boot/dts/exynos5250.dtsi +4
-0@@ -285,6 +285,7 @@ clock-names = "i2c"; pinctrl-names = "default"; pinctrl-0 = <&i2c0_bus>; + samsung,syscon-phandle = <&sys_reg>; status = "disabled"; };@@ -298,6 +299,7 @@ clock-names = "i2c"; pinctrl-names = "default"; pinctrl-0 = <&i2c1_bus>; + samsung,syscon-phandle = <&sys_reg>; status = "disabled"; };@@ -311,6 +313,7 @@ clock-names = "i2c"; pinctrl-names = "default"; pinctrl-0 = <&i2c2_bus>; + samsung,syscon-phandle = <&sys_reg>; status = "disabled"; };@@ -324,6 +327,7 @@ clock-names = "i2c"; pinctrl-names = "default"; pinctrl-0 = <&i2c3_bus>; + samsung,syscon-phandle = <&sys_reg>; status = "disabled"; };arch/arm/boot/dts/exynos5420.dtsi +4
-0@@ -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"; };arch/arm/mach-exynos/exynos.c +0
-26@@ -293,32 +293,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 ())drivers/i2c/busses/i2c-s3c2410.c +15
-0@@ -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,7 @@ struct s3c24xx_i2c {#if defined(CONFIG_ARM_S3C24XX_CPUFREQ )struct notifier_block freq_transition;#endif +struct regmap *sysreg; };static struct platform_device_id s3c24xx_driver_ids[] = {@@ -1075,6 +1081,8 @@ static void s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) { struct s3c2410_platform_i2c *pdata = i2c->pdata; +unsigned int tmp; +int id;if (!np)return ;@@ -1084,6 +1092,25 @@ 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.
Quoted 8 lines
drivers/i2c/busses/i2c-s3c2410.c s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) · line 1107
Quoted 6 lines
drivers/i2c/busses/i2c-s3c2410.c +6
-0+*/ + id =of_alias_get_id (np,"i2c" ); + i2c->sysreg =syscon_regmap_lookup_by_phandle (np, +"samsung,syscon-phandle" ); +if (IS_ERR (i2c->sysreg)) { + i2c->sysreg =NULL ;NULL shouldn't be considered for pointers using the
ERR_PTR()convention, so you should just preserve the value returned bysyscon_regmap_lookup_by_phandle()here.
OK.
Quoted 2 lines
Also, the driver seems to do this only once in probe, so maybe you should simply use a local variable here, without storing the regmap in i2c struct.
It will be used in suspend/resume in next patch.
Quoted 5 lines
drivers/i2c/busses/i2c-s3c2410.c s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) · line 1108
Quoted 2 lines
drivers/i2c/busses/i2c-s3c2410.c +1
-0+/* As this is not compulsary do not return error */ Is it? Will the driver work normally without interrupts in this case?
If you see original code in exynos.c and also comment just before this code section this needs to be taken care only for first four i2c channels and for Exynos5 SoC family. So accordingly I added phandle property only to first four i2c device nodes in DT. So for rest i2c channels it is not required.
Quoted 1 line
Also, typo: s/compulsary/compulsory/
Will correct.
Quoted 10 lines
drivers/i2c/busses/i2c-s3c2410.c s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) · line 1113
Quoted 6 lines
drivers/i2c/busses/i2c-s3c2410.c +5
-0+pr_info ("i2c-%d skipping re-configuration of interrutps\n" , id); +return ; + } +regmap_read (i2c->sysreg,EXYNOS5_SYS_I2C_CFG , &tmp); +regmap_write (i2c->sysreg,EXYNOS5_SYS_I2C_CFG , tmp & ~(0x1 << id));You could use
regmap_update_bits()[1] here instead, with mask set to BIT(id) and val set to 0.[1] http://lxr.free-electrons.com/source/drivers/base/regmap/regmap.c#L1977
Thanks for suggestion will use this.
Quoted 4 lines
Best regards,
Tomasz
Signature · 2 lines
Best Regards, Pankaj Dubey
PATCH v2 2/6 ARM: EXYNOS: Move SYS_I2C_CFG register save/restore to i2c driver
In reply to Pankaj DubeyLet's move SYS_I2C_CFG register save/restore during s2r into i2c driver. This will help in removing static iodesc based mapping from exynos.c. Also will help in removing SoC specific checks in pm.c making it more independent of such macros.
--- arch/arm/mach-exynos/exynos.c | 12 +----------- arch/arm/mach-exynos/include/mach/map.h | 3 --- arch/arm/mach-exynos/pm.c | 10 ---------- arch/arm/mach-exynos/regs-sys.h | 22 ---------------------- drivers/i2c/busses/i2c-s3c2410.c | 8 ++++++++ 5 files changed, 9 insertions(+), 46 deletions(-) delete mode 100644 arch/arm/mach-exynos/regs-sys.h
arch/arm/mach-exynos/exynos.c +1 -11
@@ -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 ,
arch/arm/mach-exynos/include/mach/map.h +0 -3
@@ -25,9 +25,6 @@#define EXYNOS_PA_CHIPID 0x10000000 -#define EXYNOS4_PA_SYSCON 0x10010000 -#define EXYNOS5_PA_SYSCON 0x10050100 -#define EXYNOS4_PA_CMU 0x10030000#define EXYNOS5_PA_CMU 0x10010000
arch/arm/mach-exynos/pm.c +0 -10
@@ -37,7 +37,6 @@#include "common.h" #include "regs-pmu.h" -#include "regs-sys.h" #include "exynos-pmu.h" static struct regmap *pmu_regmap;
@@ -52,10 +51,6 @@ struct exynos_wkup_irq {u32 mask; }; -static struct sleep_save exynos5_sys_save[] = { -SAVE_ITEM (EXYNOS5_SYS_I2C_CFG ), -}; -static struct sleep_save exynos_core_save[] = {/* SROM side */ SAVE_ITEM (S5P_SROM_BW ),
@@ -211,7 +206,6 @@ static void exynos_pm_prepare(void)s3c_pm_do_save (exynos_core_save,ARRAY_SIZE (exynos_core_save));if (soc_is_exynos5250 ()) { -s3c_pm_do_save (exynos5_sys_save,ARRAY_SIZE (exynos5_sys_save));/* Disable USE_RETENTION of JPEG_MEM_OPTION */ regmap_read (pmu_regmap,EXYNOS5_JPEG_MEM_OPTION , &tmp); tmp &= ~EXYNOS5_OPTION_USE_RETENTION ;
@@ -296,10 +290,6 @@ static void exynos_pm_resume(void)regmap_write (pmu_regmap,S5P_PAD_RET_EBIA_OPTION , (1 <<28 ));regmap_write (pmu_regmap,S5P_PAD_RET_EBIB_OPTION , (1 <<28 )); -if (soc_is_exynos5250 ()) -s3c_pm_do_restore (exynos5_sys_save, -ARRAY_SIZE (exynos5_sys_save)); -s3c_pm_do_restore_core (exynos_core_save,ARRAY_SIZE (exynos_core_save));if (!soc_is_exynos5250 ())
arch/arm/mach-exynos/regs-sys.h deleted +0 -22
@@ -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 */
drivers/i2c/busses/i2c-s3c2410.c +8 -0
@@ -133,6 +133,7 @@ struct s3c24xx_i2c {struct notifier_block freq_transition;#endif struct regmap *sysreg; +unsigned int syc_cfg; };static struct platform_device_id s3c24xx_driver_ids[] = {
@@ -1293,6 +1294,9 @@ static int s3c24xx_i2c_suspend_noirq(struct device *dev)struct platform_device *pdev =to_platform_device (dev);struct s3c24xx_i2c *i2c =platform_get_drvdata (pdev); +if (i2c->sysreg) +regmap_read (i2c->sysreg,EXYNOS5_SYS_I2C_CFG , &i2c->syc_cfg); + i2c->suspended =1 ;return 0 ;
@@ -1304,6 +1308,10 @@ static int s3c24xx_i2c_resume(struct device *dev)struct s3c24xx_i2c *i2c =platform_get_drvdata (pdev); i2c->suspended =0 ; + +if (i2c->sysreg) +regmap_write (i2c->sysreg, i2c->syc_cfg,EXYNOS5_SYS_I2C_CFG ); +clk_prepare_enable (i2c->clk);s3c24xx_i2c_init (i2c);clk_disable_unprepare (i2c->clk);
Signature · 1 line
1.7.10.4
Re: [PATCH v2 2/6] ARM: EXYNOS: Move SYS_I2C_CFG register save/restore to i2c driver
Hi Pankaj,
Quoted 17 lines · Pankaj Dubey
Let's move
SYS_I2C_CFGregister save/restore during s2r into i2c driver. This will help in removing static iodesc based mapping fromexynos.c. Also will help in removing SoC specific checks inpm.cmaking it more independent of such macros.CC Wolfram Sang <[email protected]>CC Russell King <[email protected]>CC linux-i2c at vger.kernel.orgSigned-off-by Pankaj Dubey <[email protected]>--- arch/arm/mach-exynos/exynos.c | 12 +----------- arch/arm/mach-exynos/include/mach/map.h | 3 --- arch/arm/mach-exynos/pm.c | 10 ---------- arch/arm/mach-exynos/regs-sys.h | 22 ---------------------- drivers/i2c/busses/i2c-s3c2410.c | 8 ++++++++ 5 files changed, 9 insertions(+), 46 deletions(-)delete mode 100644
arch/arm/mach-exynos/regs-sys.h
[snip]
drivers/i2c/busses/i2c-s3c2410.c struct s3c24xx_i2c { · line 136
Quoted 9 lines
drivers/i2c/busses/i2c-s3c2410.c +1
-0@@ -133,6 +133,7 @@ struct s3c24xx_i2c {struct notifier_block freq_transition;#endif struct regmap *sysreg; +unsigned int syc_cfg;
I suspect this is a typo, as the name syc_cfg looks a bit strange. Shouldn't it be sys_i2c_cfg?
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_suspend_noirq(struct device *dev) · line 1297
Quoted 8 lines
drivers/i2c/busses/i2c-s3c2410.c +1
-0};static struct platform_device_id s3c24xx_driver_ids[] = {@@ -1293,6 +1294,9 @@ static int s3c24xx_i2c_suspend_noirq(struct device *dev)struct platform_device *pdev =to_platform_device (dev);struct s3c24xx_i2c *i2c =platform_get_drvdata (pdev); +if (i2c->sysreg)
IS_ERR() should be used.
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_suspend_noirq(struct device *dev) · line 1298
Quoted 1 line
drivers/i2c/busses/i2c-s3c2410.c +1
-0+regmap_read (i2c->sysreg,EXYNOS5_SYS_I2C_CFG , &i2c->syc_cfg);
Aha, so this is where the reference to the regmap gets used outside the probe. I'd say that changes to the i2c driver from this patch should be squashed with previous patch and this patch should contain only arch changes to remove old code.
However, I wonder if this is really the right approach to this, as now you have save and restore duplicated for every instance of s3c24xx-i2c IP block. If there are no bits other than interrupt mux selectors in this registers then I guess this is fine (I can't look it up in the documentation at the moment), but otherwise you can end-up with multiple paths doing read-modify-write to this register in parallel possibly with different values.
Needless to say, this isn't very elegant, but I'm not opposed too much, as I can't really think of anything better right now.
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_resume(struct device *dev) · line 1314
Quoted 12 lines
drivers/i2c/busses/i2c-s3c2410.c +5
-0+ i2c->suspended =1 ;return 0 ;@@ -1304,6 +1308,10 @@ static int s3c24xx_i2c_resume(struct device *dev)struct s3c24xx_i2c *i2c =platform_get_drvdata (pdev); i2c->suspended =0 ; + +if (i2c->sysreg) +regmap_write (i2c->sysreg, i2c->syc_cfg,EXYNOS5_SYS_I2C_CFG ); +
I'd say this should be happening before setting i2c->suspended to 0 to account for possible i2c transfers being requested in parallel. Also see patch [1].
[1] https://lkml.org/lkml/2014/4/11/632
Best regards,
Tomasz
Re: [PATCH v2 2/6] ARM: EXYNOS: Move SYS_I2C_CFG register save/restore to i2c driver
Quoted 23 lines · Tomasz Figa
Hi Pankaj,
Quoted 17 lines · Pankaj Dubey
Let's move
SYS_I2C_CFGregister save/restore during s2r into i2c driver. This will help in removing static iodesc based mapping fromexynos.c. Also will help in removing SoC specific checks inpm.cmaking it more independent of such macros.CC Wolfram Sang <[email protected]>CC Russell King <[email protected]>Signed-off-by Pankaj Dubey <[email protected]>--- arch/arm/mach-exynos/exynos.c | 12 +----------- arch/arm/mach-exynos/include/mach/map.h | 3 --- arch/arm/mach-exynos/pm.c | 10 ---------- arch/arm/mach-exynos/regs-sys.h | 22 ---------------------- drivers/i2c/busses/i2c-s3c2410.c | 8 ++++++++ 5 files changed, 9 insertions(+), 46 deletions(-)delete mode 100644
arch/arm/mach-exynos/regs-sys.h[snip]
Quoted 11 lines
drivers/i2c/busses/i2c-s3c2410.c struct s3c24xx_i2c { · line 136
Quoted 9 lines
drivers/i2c/busses/i2c-s3c2410.c +1
-0@@ -133,6 +133,7 @@ struct s3c24xx_i2c {struct notifier_block freq_transition;#endif struct regmap *sysreg; +unsigned int syc_cfg;I suspect this is a typo, as the name
syc_cfglooks a bit strange. Shouldn't it besys_i2c_cfg?
Oops. Will correct it in next version.
Quoted 9 lines
Quoted 9 lines
drivers/i2c/busses/i2c-s3c2410.c +0
-0};static struct platform_device_id s3c24xx_driver_ids[] = {@@ -1293,6 +1294,9 @@ static int s3c24xx_i2c_suspend_noirq(struct device *dev)struct platform_device *pdev =to_platform_device (dev);struct s3c24xx_i2c *i2c =platform_get_drvdata (pdev);
Quoted 7 lines
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_suspend_noirq(struct device · line 1298
Quoted 1 line
drivers/i2c/busses/i2c-s3c2410.c +1
-0+if (i2c->sysreg)
IS_ERR()should be used.drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_suspend_noirq(struct device *dev) · line 1298
Quoted 1 line
drivers/i2c/busses/i2c-s3c2410.c +1
-0+regmap_read (i2c->sysreg,EXYNOS5_SYS_I2C_CFG , &i2c->syc_cfg);Aha, so this is where the reference to the regmap gets used outside the probe. I'd say that changes to the i2c driver from this patch should be squashed with previous patch and this patch should contain only arch changes to remove old code.
OK, in next version I will update accordingly.
Quoted 2 lines
However, I wonder if this is really the right approach to this, as now you have save and restore duplicated for every instance of s3c24xx-i2c IP block. If there are no bits other than interrupt mux selectors in this registers then I guess this is fine (I can't look it up in the documentation at the moment), but otherwise you can end-up with multiple paths doing read-modify-write to this register in parallel possibly with different values.
SYS_I2C_CFG for exynos5250 has only bits for mux selectors for i2c.
Quoted 18 lines
Needless to say, this isn't very elegant, but I'm not opposed too much, as I can't really think of anything better right now.
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_resume(struct device *dev) · line 1314
Quoted 12 lines
drivers/i2c/busses/i2c-s3c2410.c +1
-0+ i2c->suspended =1 ;return 0;drivers/i2c/busses/i2c-s3c2410.c +4
-0@@ -1304,6 +1308,10 @@ static int s3c24xx_i2c_resume(struct device *dev)struct s3c24xx_i2c *i2c =platform_get_drvdata (pdev); i2c->suspended =0 ; + +if (i2c->sysreg) +regmap_write (i2c->sysreg, i2c->syc_cfg,EXYNOS5_SYS_I2C_CFG ); +I'd say this should be happening before setting
i2c->suspendedto 0 to account for possible i2c transfers being requested in parallel. Also see patch [1].
Quoted 1 line
OK, will move this before i2c->suspended = 0.
If possible please review other patches also in this series so that I can update whole series with addressing all review comments.
Quoted 4 lines
Best regards,
Tomasz
Signature · 2 lines
Best Regards, Pankaj Dubey
PATCH v2 3/6 ARM: EXYNOS: remove soc_is_exynos4/5 from exynos.c
In reply to Pankaj DubeyThis 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.
--- arch/arm/mach-exynos/exynos.c | 52 +++++++++++++++++++----------- arch/arm/plat-samsung/include/plat/cpu.h | 3 -- 2 files changed, 33 insertions(+), 22 deletions(-)
arch/arm/mach-exynos/exynos.c +33 -19
@@ -202,20 +202,6 @@ static const struct of_device_id exynos_dt_pmu_match[] = { {}, }; -/* -* exynos_map_io -* -* register the standard cpu IO areas -*/ -static void __init exynos_map_io (void ) -{ -if (soc_is_exynos4 ()) -iotable_init (exynos4_iodesc,ARRAY_SIZE (exynos4_iodesc)); - -if (soc_is_exynos5 ()) -iotable_init (exynos5_iodesc,ARRAY_SIZE (exynos5_iodesc)); -} -static void __init exynos_init_io (void ) {debug_ll_io_init ();
@@ -224,8 +210,18 @@ static void __init exynos_init_io(void)/* detect cpu id and rev. */ s5p_init_cpu (S5P_VA_CHIPID ); +} + +static void __init exynos5_init_io (void ) +{ +exynos_init_io (); +iotable_init (exynos5_iodesc,ARRAY_SIZE (exynos5_iodesc)); +} -exynos_map_io (); +static void __init exynos4_init_io (void ) +{ +exynos_init_io (); +iotable_init (exynos4_iodesc,ARRAY_SIZE (exynos4_iodesc)); }struct bus_type exynos_subsys = {
@@ -293,11 +289,15 @@ static void __init exynos_dt_machine_init(void)of_platform_populate (NULL , of_default_bus_match_table,NULL ,NULL ); } -static char const *exynos_dt_compat[]__initconst = { +static char const *exynos4_dt_compat[]__initconst = {"samsung,exynos4" ,"samsung,exynos4210" ,"samsung,exynos4212" ,"samsung,exynos4412" , +NULL +}; + +static char const *exynos5_dt_compat[]__initconst = {"samsung,exynos5" ,"samsung,exynos5250" ,"samsung,exynos5420" ,
@@ -321,15 +321,29 @@ static void __init exynos_reserve(void)#endif } -DT_MACHINE_START (EXYNOS_DT ,"SAMSUNG EXYNOS (Flattened Device Tree)" ) +DT_MACHINE_START (EXYNOS5_DT ,"SAMSUNG EXYNOS (Flattened Device Tree)" ) +/* Maintainer: Thomas Abraham <[email protected]> */ +/* Maintainer: Kukjin Kim <[email protected]> */ + .smp = smp_ops(exynos_smp_ops), + .map_io = exynos5_init_io, + .init_early = exynos_firmware_init, + .init_machine = exynos_dt_machine_init, + .init_late = exynos_init_late, + .dt_compat = exynos5_dt_compat, + .restart = exynos_restart, + .reserve = exynos_reserve, +MACHINE_END + + +DT_MACHINE_START (EXYNOS4_DT ,"SAMSUNG EXYNOS (Flattened Device Tree)" )/* Maintainer: Thomas Abraham <[email protected]> */ /* Maintainer: Kukjin Kim <[email protected]> */ .smp =smp_ops (exynos_smp_ops), - .map_io = exynos_init_io, + .map_io = exynos4_init_io, .init_early = exynos_firmware_init, .init_machine = exynos_dt_machine_init, .init_late = exynos_init_late, - .dt_compat = exynos_dt_compat, + .dt_compat = exynos4_dt_compat, .restart = exynos_restart, .reserve = exynos_reserve,MACHINE_END
arch/arm/plat-samsung/include/plat/cpu.h +0 -3
@@ -166,9 +166,6 @@ IS_SAMSUNG_CPU(exynos5440, EXYNOS5440_SOC_ID, EXYNOS5_SOC_MASK)# define soc_is_exynos5440 () 0#endif -#define soc_is_exynos4 () (soc_is_exynos4210() || soc_is_exynos4212() || \ - soc_is_exynos4412()) -#define soc_is_exynos5 () (soc_is_exynos5250() || soc_is_exynos5420())#define IODESC_ENT (x) { (unsigned long)S3C24XX_VA_##x, __phys_to_pfn(S3C24XX_PA_##x), S3C24XX_SZ_##x, MT_DEVICE }
Signature · 1 line
1.7.10.4
PATCH v2 4/6 ARM: EXYNOS: remove unused header inclusion from hotplug.c
In reply to Pankaj DubeyThis patch removed "plat/cpu.h" inclusion from hotplug.c as it is not required.
--- arch/arm/mach-exynos/hotplug.c | 2 -- 1 file changed, 2 deletions(-)
arch/arm/mach-exynos/hotplug.c +0 -2
@@ -19,8 +19,6 @@#include <asm/cp15.h> #include <asm/smp_plat.h> -#include <plat/cpu.h> -#include "common.h" #include "regs-pmu.h"
Signature · 1 line
1.7.10.4
PATCH v2 5/6 soc: samsung: exynos-chipid: Add Exynos Chipid driver support
In reply to Pankaj DubeyExynos SoCs have Chipid, for identification of product IDs and SoC revistions. Till now we are using static macros such as soc_is_exynosxxxx and #ifdefs for run time identification of SoCs and their revisions. This is leading to add new Kconfig, soc_is_exynosXXXX definitions each time new SoC support is getting added. So this driver intends to provide initialization code all these functionalites and thus helping in removing macros.
--- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/samsung/Kconfig | 10 +++ drivers/soc/samsung/Makefile | 1 + drivers/soc/samsung/exynos-chipid.c | 166 +++++++++++++++++++++++++++++++++++ include/linux/exynos-soc.h | 46 ++++++++++ 6 files changed, 225 insertions(+) create mode 100644 drivers/soc/samsung/Kconfig create mode 100644 drivers/soc/samsung/Makefile create mode 100644 drivers/soc/samsung/exynos-chipid.c create mode 100644 include/linux/exynos-soc.h
drivers/soc/Kconfig +1 -0
@@ -1,5 +1,6 @@ menu "SOC specific Drivers" source "drivers/soc/qcom/Kconfig" +source "drivers/soc/samsung/Kconfig" endmenu
drivers/soc/Makefile +1 -0
@@ -3,3 +3,4 @@ # obj-$(CONFIG_ARCH_QCOM) += qcom/ +obj-$(CONFIG_ARCH_EXYNOS) += samsung/
drivers/soc/samsung/Kconfig new file +10 -0
@@ -0,0 +1,10 @@ + +# SAMSUNG Soc drivers +# +config EXYNOS_CHIPID + tristate "Support Exynos CHIPID" + default y + select SOC_BUS + depends on ARCH_EXYNOS || ARM64 + help + If you say Y here you get support for the Exynos CHIP id.
drivers/soc/samsung/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_EXYNOS_CHIPID) += exynos-chipid.o
drivers/soc/samsung/exynos-chipid.c new file +166 -0
166 lines not on this page · raw message
include/linux/exynos-soc.h new file +46 -0
46 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v2 6/6 ARM: EXYNOS: Refactoring to remove soc_is_exynosXXXX macros from exynos
In reply to Pankaj DubeyThis patch enables chipid driver for ARCH_EXYNOS and refactors machine code as well as exynos cpufreq driver code for using chipid driver for identification of SoC ID and SoC rev.
This patch also updates DT binding information in exynos4 and exynos5 dtsi file. As to differentiate product id bit-mask we need separate compatible string for exynos4 and exynos5. Hoping this will be helpful in future as bit-mask and bit-shift bit may differ. Added binding information as well.
--- .../bindings/arm/samsung/exynos-chipid.txt | 21 ++++++++ arch/arm/Kconfig | 1 + arch/arm/boot/dts/exynos4.dtsi | 2 +- arch/arm/boot/dts/exynos5.dtsi | 2 +- arch/arm/mach-exynos/exynos.c | 47 ++++------------ arch/arm/mach-exynos/platsmp.c | 10 ++-- 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, 60 insertions(+), 123 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt
Documentation/devicetree/bindings/arm/samsung/exynos-chipid.txt new file +21 -0
@@ -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 at 10000000 { + compatible = "samsung,exynos4210-chipid", "samsung,exynos4-chipid"; + reg = <0x10000000 0x100>; + };
arch/arm/Kconfig +1 -0
@@ -856,6 +856,7 @@ config ARCH_EXYNOS select SRAM select USE_OF select MFD_SYSCON + select EXYNOS_CHIPID help Support for SAMSUNG's EXYNOS SoCs (EXYNOS4/5)
arch/arm/boot/dts/exynos4.dtsi +1 -1
@@ -46,7 +46,7 @@ }; chipid at 10000000 { - compatible = "samsung,exynos4210-chipid"; + compatible = "samsung,exynos4210-chipid", "samsung,exynos4-chipid"; reg = <0x10000000 0x100>; };
arch/arm/boot/dts/exynos5.dtsi +1 -1
@@ -19,7 +19,7 @@ interrupt-parent = <&gic>; chipid at 10000000 { - compatible = "samsung,exynos4210-chipid"; + compatible = "samsung,exynos4210-chipid", "samsung,exynos5-chipid"; reg = <0x10000000 0x100>; };
arch/arm/mach-exynos/exynos.c +9 -38
90 lines not on this page · raw message
arch/arm/mach-exynos/platsmp.c +6 -4
@@ -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"
@@ -67,7 +67,8 @@ static int __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;
@@ -78,9 +79,9 @@ static inline void __iomem *cpu_boot_reg(int cpu)void __iomem *boot_reg; boot_reg =cpu_boot_reg_base (); -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; }
@@ -261,6 +262,7 @@ static void __init exynos_smp_init_cpus(void)static void __init exynos_smp_prepare_cpus (unsigned int max_cpus) {int i; +early_exynos_chipid_init (); pmu_base =pmu_base_addr ();
arch/arm/mach-exynos/pm.c +13 -13
@@ -22,13 +22,13 @@#include <linux/err.h> #include <linux/clk.h> #include <linux/regmap.h> +#include <linux/exynos-soc.h> #include <asm/cacheflush.h> #include <asm/hardware/cache-l2x0.h> #include <asm/smp_scu.h> #include <asm/suspend.h> -#include <plat/cpu.h> #include <plat/pm-common.h> #include <plat/pll.h> #include <plat/regs-srom.h>
@@ -82,7 +82,7 @@ static int exynos_irq_set_wake(struct irq_data *data, unsigned int state) {const struct exynos_wkup_irq *wkup_irq; -if (soc_is_exynos5250 ()) +if (is_soc_id_compatible (EXYNOS5250 )) wkup_irq = exynos5250_wkup_irq;else wkup_irq = exynos4_wkup_irq;
@@ -101,11 +101,11 @@ static int exynos_irq_set_wake(struct irq_data *data, unsigned int state)return -ENOENT ; } -#define EXYNOS_BOOT_VECTOR_ADDR (samsung_rev() == EXYNOS4210_REV_1_1 ? \ - S5P_INFORM7 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \ +#define EXYNOS_BOOT_VECTOR_ADDR (is_soc_rev_compatible(EXYNOS4210_REV_1_1) ? \ + S5P_INFORM7 : (is_soc_rev_compatible(EXYNOS4210_REV_1_0) ? \ 0x24 : S5P_INFORM0)) -#define EXYNOS_BOOT_VECTOR_FLAG (samsung_rev() == EXYNOS4210_REV_1_1 ? \ - S5P_INFORM6 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \ +#define EXYNOS_BOOT_VECTOR_FLAG (is_soc_rev_compatible(EXYNOS4210_REV_1_1) ? \ + S5P_INFORM6 : (is_soc_rev_compatible(EXYNOS4210_REV_1_0) ? \ 0x20 : S5P_INFORM1))#define S5P_CHECK_AFTR 0xFCBA0D10
@@ -119,7 +119,7 @@ static void exynos_set_wakeupmask(long mask)static void exynos_cpu_set_boot_vector (long flags) { -if (samsung_rev () ==EXYNOS4210_REV_1_0 ) { +if (is_soc_rev_compatible (EXYNOS4210_REV_1_0 )) {__raw_writel (virt_to_phys (exynos_cpu_resume),S5P_VA_SYSRAM +EXYNOS_BOOT_VECTOR_ADDR );__raw_writel (flags,S5P_VA_SYSRAM +EXYNOS_BOOT_VECTOR_FLAG );
@@ -183,7 +183,7 @@ static int exynos_cpu_suspend(unsigned long arg)outer_flush_all ();#endif -if (soc_is_exynos5250 ()) +if (is_soc_id_compatible (EXYNOS5250 ))flush_cache_all ();/* issue the standby signal into the pm unit. */
@@ -205,7 +205,7 @@ static void exynos_pm_prepare(void)s3c_pm_do_save (exynos_core_save,ARRAY_SIZE (exynos_core_save)); -if (soc_is_exynos5250 ()) { +if (is_soc_id_compatible (EXYNOS5250 )) {/* Disable USE_RETENTION of JPEG_MEM_OPTION */ regmap_read (pmu_regmap,EXYNOS5_JPEG_MEM_OPTION , &tmp); tmp &= ~EXYNOS5_OPTION_USE_RETENTION ;
@@ -243,7 +243,7 @@ static int exynos_pm_suspend(void) tmp = (S5P_USE_STANDBY_WFI0 |S5P_USE_STANDBY_WFE0 );regmap_write (pmu_regmap,S5P_CENTRAL_SEQ_OPTION , tmp); -if (!soc_is_exynos5250 ()) +if (!is_soc_id_compatible (EXYNOS5250 ))exynos_cpu_save_register ();return 0 ;
@@ -277,7 +277,7 @@ static void exynos_pm_resume(void)if (exynos_pm_central_resume ()) goto early_wakeup; -if (!soc_is_exynos5250 ()) +if (!is_soc_id_compatible (EXYNOS5250 ))exynos_cpu_restore_register ();/* For release retention */
@@ -292,7 +292,7 @@ static void exynos_pm_resume(void)s3c_pm_do_restore_core (exynos_core_save,ARRAY_SIZE (exynos_core_save)); -if (!soc_is_exynos5250 ()) +if (!is_soc_id_compatible (EXYNOS5250 ))scu_enable (S5P_VA_SCU ); early_wakeup:
@@ -385,7 +385,7 @@ static int exynos_cpu_pm_notifier(struct notifier_block *self,case CPU_PM_EXIT :if (cpu ==0 ) { -if (!soc_is_exynos5250 ()) +if (!is_soc_id_compatible (EXYNOS5250 ))scu_enable (S5P_VA_SCU );exynos_cpu_restore_register ();exynos_pm_central_resume ();
arch/arm/plat-samsung/include/plat/cpu.h +0 -57
75 lines not on this page · raw message
drivers/clk/samsung/clk-exynos4.c +1 -1
@@ -1030,7 +1030,7 @@ static unsigned long exynos4_get_xom(void)void __iomem *chipid_base;struct device_node *np; - np =of_find_compatible_node (NULL ,NULL ,"samsung,exynos4210-chipid" ); + np =of_find_compatible_node (NULL ,NULL ,"samsung,exynos4-chipid" );if (np) { chipid_base =of_iomap (np,0 );
drivers/cpufreq/exynos-cpufreq.c +4 -5
@@ -17,8 +17,7 @@#include <linux/regulator/consumer.h> #include <linux/cpufreq.h> #include <linux/platform_device.h> - -#include <plat/cpu.h> +#include <linux/exynos-soc.h> #include "exynos-cpufreq.h"
@@ -163,11 +162,11 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)if (!exynos_info)return -ENOMEM ; -if (soc_is_exynos4210 ()) +if (is_soc_id_compatible (EXYNOS4210 )) ret =exynos4210_cpufreq_init (exynos_info); -else if (soc_is_exynos4212 () ||soc_is_exynos4412 ()) +else if (is_soc_id_compatible (EXYNOS4212 ) ||is_soc_id_compatible (EXYNOS4412 )) ret =exynos4x12_cpufreq_init (exynos_info); -else if (soc_is_exynos5250 ()) +else if (is_soc_id_compatible (EXYNOS5250 )) ret =exynos5250_cpufreq_init (exynos_info);else return 0 ;
drivers/cpufreq/exynos-cpufreq.h +0 -1
@@ -68,7 +68,6 @@ static inline int exynos5250_cpufreq_init(struct exynos_dvfs_info *info) }#endif -#include <plat/cpu.h> #include <mach/map.h> #define EXYNOS4_CLKSRC_CPU (S5P_VA_CMU + 0x14200)
drivers/cpufreq/exynos4x12-cpufreq.c +3 -2
@@ -16,6 +16,7 @@#include <linux/io.h> #include <linux/slab.h> #include <linux/cpufreq.h> +#include <linux/exynos-soc.h> #include "exynos-cpufreq.h"
@@ -115,7 +116,7 @@ static void exynos4x12_set_clkdiv(unsigned int div_index) tmp = apll_freq_4x12[div_index].clk_div_cpu1;__raw_writel (tmp,EXYNOS4_CLKDIV_CPU1 ); -if (soc_is_exynos4212 ()) +if (is_soc_id_compatible (EXYNOS4212 )) stat_cpu1 =0x11 ;else stat_cpu1 =0x111 ;
@@ -184,7 +185,7 @@ int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info)if (IS_ERR (mout_apll)) goto err_mout_apll; -if (soc_is_exynos4212 ()) +if (is_soc_id_compatible (EXYNOS4212 )) apll_freq_4x12 = apll_freq_4212;else apll_freq_4x12 = apll_freq_4412;
Signature · 1 line
1.7.10.4