* [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver [not found] <1399706287-13919-1-git-send-email-y@samsung.com> @ 2014-05-10 7:18 ` y [not found] ` <1399706419-13976-1-git-send-email-pankaj.dubey@samsung.com> 1 sibling, 0 replies; 5+ 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] 5+ messages in thread
[parent not found: <1399706419-13976-1-git-send-email-pankaj.dubey@samsung.com>]
* [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver [not found] ` <1399706419-13976-1-git-send-email-pankaj.dubey@samsung.com> @ 2014-05-10 7:20 ` Pankaj Dubey 2014-06-02 17:14 ` Wolfram Sang [not found] ` <1399706419-13976-2-git-send-email-pankaj.dubey-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> 0 siblings, 2 replies; 5+ messages in thread From: Pankaj Dubey @ 2014-05-10 7:20 UTC (permalink / raw) To: linux-samsung-soc, linux-kernel, linux-arm-kernel Cc: devicetree, kgene.kim, Russell King, arnd, Wolfram Sang, Pankaj Dubey, t.figa, Randy Dunlap, linux-doc, Rob Herring, 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] 5+ messages in thread
* Re: [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver 2014-05-10 7:20 ` Pankaj Dubey @ 2014-06-02 17:14 ` Wolfram Sang [not found] ` <1399706419-13976-2-git-send-email-pankaj.dubey-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> 1 sibling, 0 replies; 5+ 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] 5+ messages in thread
[parent not found: <1399706419-13976-2-git-send-email-pankaj.dubey-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>]
* Re: [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver [not found] ` <1399706419-13976-2-git-send-email-pankaj.dubey-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> @ 2014-06-10 13:35 ` Tomasz Figa 2014-06-17 4:21 ` Pankaj Dubey 0 siblings, 1 reply; 5+ messages in thread From: Tomasz Figa @ 2014-06-10 13:35 UTC (permalink / raw) To: Pankaj Dubey, linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r Cc: kgene.kim-Sze3O3UU22JBDgjK7y7TUQ, arnd-r2nGTMty4D4, Rob Herring, Randy Dunlap, Wolfram Sang, Russell King, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-doc-u79uwXL29TY76Z2rM5mHXA, linux-i2c-u79uwXL29TY76Z2rM5mHXA 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-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> > CC: Randy Dunlap <rdunlap-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org> > CC: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org> > CC: Russell King <linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org> > CC: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > CC: linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > CC: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > Signed-off-by: Pankaj Dubey <pankaj.dubey-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> > --- > .../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] 5+ 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; 5+ 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] 5+ messages in thread
end of thread, other threads:[~2014-06-17 4:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1399706287-13919-1-git-send-email-y@samsung.com>
2014-05-10 7:18 ` [PATCH v3 1/6] i2c: s3c2410: Handle i2c sys_cfg register in i2c driver y
[not found] ` <1399706419-13976-1-git-send-email-pankaj.dubey@samsung.com>
2014-05-10 7:20 ` Pankaj Dubey
2014-06-02 17:14 ` Wolfram Sang
[not found] ` <1399706419-13976-2-git-send-email-pankaj.dubey-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2014-06-10 13:35 ` Tomasz Figa
2014-06-17 4:21 ` Pankaj Dubey
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).