* Re: [PATCH v3 6/8] drivers: soc: add support for exynos SROM driver
@ 2015-10-13 15:00 LABBE Corentin
2015-10-19 14:28 ` Pankaj Dubey
0 siblings, 1 reply; 3+ messages in thread
From: LABBE Corentin @ 2015-10-13 15:00 UTC (permalink / raw)
To: pankaj.dubey
Cc: linux-samsung-soc, linux-kernel, linux-arm-kernel, kgene.kim,
k.kozlowski, p.fedin, thomas.ab
+static struct exynos_srom_reg_dump *exynos_srom_alloc_reg_dump(
+ const unsigned long *rdump,
+ unsigned long nr_rdump)
+{
+ struct exynos_srom_reg_dump *rd;
+ unsigned int i;
+
+ rd = kcalloc(nr_rdump, sizeof(*rd), GFP_KERNEL);
+ if (!rd)
+ return NULL;
+
+ for (i = 0; i < nr_rdump; ++i)
+ rd[i].offset = rdump[i];
+
+ return rd;
+}
You do not free rd anywhere in your code.
+static int exynos_srom_probe(struct platform_device *pdev)
+{
+ struct device_node *np;
+ struct device *dev = &pdev->dev;
+
+ np = dev->of_node;
Are you sure that dev->of_node will be always set ?
I see lots of driver who if (dev->of_node) {}
+ exynos_srom_base = of_iomap(np, 0);
+
+ if (!exynos_srom_base) {
+ pr_err("iomap of exynos srom controller failed\n");
+ return -ENOMEM;
+ }
You can use dev_err(dev, "") insted of pr_err
+
+ exynos_srom_regs = exynos_srom_alloc_reg_dump(exynos_srom_offsets,
+ sizeof(exynos_srom_offsets));
+
+ if (!exynos_srom_regs) {
+ iounmap(exynos_srom_regs);
+ return -ENOMEM;
+ }
+
+ return 0;
+}
Instead of using a global static exynos_srom_base/exynos_srom_regs, why you do not use platform_set_drvdata() ?
Regards
LABBE Corentin
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v3 6/8] drivers: soc: add support for exynos SROM driver 2015-10-13 15:00 [PATCH v3 6/8] drivers: soc: add support for exynos SROM driver LABBE Corentin @ 2015-10-19 14:28 ` Pankaj Dubey 0 siblings, 0 replies; 3+ messages in thread From: Pankaj Dubey @ 2015-10-19 14:28 UTC (permalink / raw) To: LABBE Corentin Cc: linux-samsung-soc, linux-kernel, linux-arm-kernel@lists.infradead.org, Kukjin Kim, Krzysztof Kozłowski, p.fedin, thomas.ab@samsung.com Hi, Thanks for review. On 13 October 2015 at 20:30, LABBE Corentin <clabbe.montjoie@gmail.com> wrote: > +static struct exynos_srom_reg_dump *exynos_srom_alloc_reg_dump( > + const unsigned long *rdump, > + unsigned long nr_rdump) > +{ > + struct exynos_srom_reg_dump *rd; > + unsigned int i; > + > + rd = kcalloc(nr_rdump, sizeof(*rd), GFP_KERNEL); > + if (!rd) > + return NULL; > + > + for (i = 0; i < nr_rdump; ++i) > + rd[i].offset = rdump[i]; > + > + return rd; > +} > > You do not free rd anywhere in your code. > OK, I missed that, corrected in v4. > +static int exynos_srom_probe(struct platform_device *pdev) > +{ > + struct device_node *np; > + struct device *dev = &pdev->dev; > + > + np = dev->of_node; > > Are you sure that dev->of_node will be always set ? > I see lots of driver who if (dev->of_node) {} > Taken care in v4. > + exynos_srom_base = of_iomap(np, 0); > + > + if (!exynos_srom_base) { > + pr_err("iomap of exynos srom controller failed\n"); > + return -ENOMEM; > + } > > You can use dev_err(dev, "") insted of pr_err > Taken care in v4. > + > + exynos_srom_regs = exynos_srom_alloc_reg_dump(exynos_srom_offsets, > + sizeof(exynos_srom_offsets)); > + > + if (!exynos_srom_regs) { > + iounmap(exynos_srom_regs); > + return -ENOMEM; > + } > + > + return 0; > +} > > Instead of using a global static exynos_srom_base/exynos_srom_regs, why you do not use platform_set_drvdata() ? > OK. Taken care in v4. Posted v4 here https://lkml.org/lkml/2015/10/19/278 Thanks, Pankaj Dubey > Regards > LABBE Corentin > > -- > To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v3 0/8] Add support for Exynos SROM Controller driver @ 2015-10-13 13:13 Pankaj Dubey 2015-10-13 13:13 ` [PATCH v3 6/8] drivers: soc: add support for exynos SROM driver Pankaj Dubey 0 siblings, 1 reply; 3+ messages in thread From: Pankaj Dubey @ 2015-10-13 13:13 UTC (permalink / raw) To: linux-samsung-soc, linux-kernel, linux-arm-kernel Cc: kgene.kim, k.kozlowski, p.fedin, thomas.ab, Pankaj Dubey This patch set adds support for Exynos SROM controller DT based driver. Currently SROM register sets are used only during S2R, so driver basically added for taking care of S2R. It will help us in removing static mapping from exynos.c and other extra code handline during S2R. This patch set also updated exynos4 and exynos5 dtsi files for with device node for srom, and added binding documentation for the same. First two patches are some minor cleanup in mach-exynos. Patchset v1 was posted here[1] [1]: https://lkml.org/lkml/2015/4/29/98 Patchset v2 was posted here[2] [2]: https://lkml.org/lkml/2015/8/24/125 This patchset, I have tested on Peach-Pi (Exynos5880) based chromebook for boot and S2R functionality. Changes since v2: - Rebased to latest kgene tree. - Addressed review comments from Krzysztof Kozlowski. - Add new patch for MAINTAINER list update. - Reordered patch sequence for avoiding git bisect issues. Changes since v1: - Rebased to latest kgene tree. - Addressed review comments from Krzysztof Kozlowski. - Add two new patches for minor cleanup in exynos.c and map.h Pankaj Dubey (7): ARM: EXYNOS: remove unused static mapping of CMU for exynos5 ARM: EXYNOS: code cleanup in map.h drivers: soc: add support for exynos SROM driver ARM: EXYNOS: Remove SROM related register settings from mach-exynos ARM: dts: add SROM device node for exynos4 ARM: dts: add SROM device node for exynos5 Documentation: dt-bindings: add exynos-srom binding information Pankaj Dubey (8): ARM: EXYNOS: remove unused static mapping of CMU for exynos5 ARM: EXYNOS: code cleanup in map.h Documentation: dt-bindings: add exynos-srom binding information ARM: dts: add SROM device node for exynos4 ARM: dts: add SROM device node for exynos5 drivers: soc: add support for exynos SROM driver MAINTAINERS: add maintainers entry for drivers/soc/samsung ARM: EXYNOS: Remove SROM related register settings from mach-exynos .../bindings/arm/samsung/exynos-srom.txt | 12 ++ MAINTAINERS | 1 + arch/arm/boot/dts/exynos4.dtsi | 5 + arch/arm/boot/dts/exynos5.dtsi | 5 + arch/arm/mach-exynos/Kconfig | 2 + arch/arm/mach-exynos/exynos.c | 22 --- arch/arm/mach-exynos/include/mach/map.h | 8 -- arch/arm/mach-exynos/regs-srom.h | 53 ------- arch/arm/mach-exynos/suspend.c | 20 +-- arch/arm/plat-samsung/include/plat/map-s5p.h | 1 - drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/samsung/Kconfig | 13 ++ drivers/soc/samsung/Makefile | 1 + drivers/soc/samsung/exynos-srom.c | 153 +++++++++++++++++++++ drivers/soc/samsung/exynos-srom.h | 51 +++++++ 16 files changed, 247 insertions(+), 102 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/samsung/exynos-srom.txt delete mode 100644 arch/arm/mach-exynos/regs-srom.h create mode 100644 drivers/soc/samsung/Kconfig create mode 100644 drivers/soc/samsung/Makefile create mode 100644 drivers/soc/samsung/exynos-srom.c create mode 100644 drivers/soc/samsung/exynos-srom.h -- 2.4.5 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v3 6/8] drivers: soc: add support for exynos SROM driver 2015-10-13 13:13 [PATCH v3 0/8] Add support for Exynos SROM Controller driver Pankaj Dubey @ 2015-10-13 13:13 ` Pankaj Dubey 0 siblings, 0 replies; 3+ messages in thread From: Pankaj Dubey @ 2015-10-13 13:13 UTC (permalink / raw) To: linux-samsung-soc, linux-kernel, linux-arm-kernel Cc: kgene.kim, k.kozlowski, p.fedin, thomas.ab, Pankaj Dubey This patch adds Exynos SROM controller driver which will handle save restore of SROM registers during S2R. Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com> --- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/samsung/Kconfig | 13 ++++ drivers/soc/samsung/Makefile | 1 + drivers/soc/samsung/exynos-srom.c | 153 ++++++++++++++++++++++++++++++++++++++ drivers/soc/samsung/exynos-srom.h | 51 +++++++++++++ 6 files changed, 220 insertions(+) create mode 100644 drivers/soc/samsung/Kconfig create mode 100644 drivers/soc/samsung/Makefile create mode 100644 drivers/soc/samsung/exynos-srom.c create mode 100644 drivers/soc/samsung/exynos-srom.h diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig index 96ddecb..69107c9 100644 --- a/drivers/soc/Kconfig +++ b/drivers/soc/Kconfig @@ -2,6 +2,7 @@ menu "SOC (System On Chip) specific Drivers" source "drivers/soc/mediatek/Kconfig" source "drivers/soc/qcom/Kconfig" +source "drivers/soc/samsung/Kconfig" source "drivers/soc/sunxi/Kconfig" source "drivers/soc/ti/Kconfig" source "drivers/soc/versatile/Kconfig" diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile index 0b12d77..a623616 100644 --- a/drivers/soc/Makefile +++ b/drivers/soc/Makefile @@ -5,6 +5,7 @@ obj-$(CONFIG_MACH_DOVE) += dove/ obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/ obj-$(CONFIG_ARCH_QCOM) += qcom/ +obj-$(CONFIG_SOC_SAMSUNG) += samsung/ obj-$(CONFIG_ARCH_SUNXI) += sunxi/ obj-$(CONFIG_ARCH_TEGRA) += tegra/ obj-$(CONFIG_SOC_TI) += ti/ diff --git a/drivers/soc/samsung/Kconfig b/drivers/soc/samsung/Kconfig new file mode 100644 index 0000000..ea4bc2a --- /dev/null +++ b/drivers/soc/samsung/Kconfig @@ -0,0 +1,13 @@ +# +# SAMSUNG SoC drivers +# +menu "Samsung SOC driver support" + +config SOC_SAMSUNG + bool + +config EXYNOS_SROM + bool + depends on ARM && ARCH_EXYNOS + +endmenu diff --git a/drivers/soc/samsung/Makefile b/drivers/soc/samsung/Makefile new file mode 100644 index 0000000..9c554d5 --- /dev/null +++ b/drivers/soc/samsung/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_EXYNOS_SROM) += exynos-srom.o diff --git a/drivers/soc/samsung/exynos-srom.c b/drivers/soc/samsung/exynos-srom.c new file mode 100644 index 0000000..87bba19 --- /dev/null +++ b/drivers/soc/samsung/exynos-srom.c @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * http://www.samsung.com/ + * + * EXYNOS - SROM Controller 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/module.h> +#include <linux/of_address.h> +#include <linux/of_platform.h> +#include <linux/platform_device.h> +#include <linux/slab.h> +#include "exynos-srom.h" + +static void __iomem *exynos_srom_base; + +static const unsigned long exynos_srom_offsets[] = { + /* SROM side */ + EXYNOS_SROM_BW, + EXYNOS_SROM_BC0, + EXYNOS_SROM_BC1, + EXYNOS_SROM_BC2, + EXYNOS_SROM_BC3, +}; + +/** + * struct exynos_srom_reg_dump: register dump of SROM Controller registers. + * @offset: srom register offset from the controller base address. + * @value: the value of register under the offset. + */ +struct exynos_srom_reg_dump { + u32 offset; + u32 value; +}; + +static struct exynos_srom_reg_dump *exynos_srom_regs; + +static struct exynos_srom_reg_dump *exynos_srom_alloc_reg_dump( + const unsigned long *rdump, + unsigned long nr_rdump) +{ + struct exynos_srom_reg_dump *rd; + unsigned int i; + + rd = kcalloc(nr_rdump, sizeof(*rd), GFP_KERNEL); + if (!rd) + return NULL; + + for (i = 0; i < nr_rdump; ++i) + rd[i].offset = rdump[i]; + + return rd; +} + +static int exynos_srom_probe(struct platform_device *pdev) +{ + struct device_node *np; + struct device *dev = &pdev->dev; + + np = dev->of_node; + exynos_srom_base = of_iomap(np, 0); + + if (!exynos_srom_base) { + pr_err("iomap of exynos srom controller failed\n"); + return -ENOMEM; + } + + exynos_srom_regs = exynos_srom_alloc_reg_dump(exynos_srom_offsets, + sizeof(exynos_srom_offsets)); + + if (!exynos_srom_regs) { + iounmap(exynos_srom_regs); + return -ENOMEM; + } + + return 0; +} + +static int exynos_srom_remove(struct platform_device *pdev) +{ + iounmap(exynos_srom_base); + exynos_srom_base = NULL; + + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static void exynos_srom_save(void __iomem *base, + struct exynos_srom_reg_dump *rd, + unsigned int num_regs) +{ + for (; num_regs > 0; --num_regs, ++rd) + rd->value = readl(base + rd->offset); + +} + +static void exynos_srom_restore(void __iomem *base, + const struct exynos_srom_reg_dump *rd, + unsigned int num_regs) +{ + for (; num_regs > 0; --num_regs, ++rd) + writel(rd->value, base + rd->offset); + +} + +static int exynos_srom_suspend(struct device *dev) +{ + exynos_srom_save(exynos_srom_base, exynos_srom_regs, + ARRAY_SIZE(exynos_srom_offsets)); + + return 0; +} + +static int exynos_srom_resume(struct device *dev) +{ + exynos_srom_restore(exynos_srom_base, exynos_srom_regs, + ARRAY_SIZE(exynos_srom_offsets)); + + return 0; +} +#endif + +static const struct of_device_id of_exynos_srom_ids[] = { + { + .compatible = "samsung,exynos-srom", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, of_exynos_srom_ids); + +static SIMPLE_DEV_PM_OPS(exynos_srom_pm_ops, exynos_srom_suspend, exynos_srom_resume); + +static struct platform_driver exynos_srom_driver = { + .probe = exynos_srom_probe, + .remove = exynos_srom_remove, + .driver = { + .name = "exynos-srom", + .of_match_table = of_exynos_srom_ids, + .pm = &exynos_srom_pm_ops, + }, +}; +module_platform_driver(exynos_srom_driver); + +MODULE_AUTHOR("Pankaj Dubey <pankaj.dubey@samsung.com>"); +MODULE_DESCRIPTION("Exynos SROM Controller Driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/soc/samsung/exynos-srom.h b/drivers/soc/samsung/exynos-srom.h new file mode 100644 index 0000000..34660c6 --- /dev/null +++ b/drivers/soc/samsung/exynos-srom.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * http://www.samsung.com + * + * Exynos SROMC register definitions + * + * 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_SROM_H +#define __EXYNOS_SROM_H __FILE__ + +#define EXYNOS_SROMREG(x) (x) + +#define EXYNOS_SROM_BW EXYNOS_SROMREG(0x0) +#define EXYNOS_SROM_BC0 EXYNOS_SROMREG(0x4) +#define EXYNOS_SROM_BC1 EXYNOS_SROMREG(0x8) +#define EXYNOS_SROM_BC2 EXYNOS_SROMREG(0xc) +#define EXYNOS_SROM_BC3 EXYNOS_SROMREG(0x10) +#define EXYNOS_SROM_BC4 EXYNOS_SROMREG(0x14) +#define EXYNOS_SROM_BC5 EXYNOS_SROMREG(0x18) + +/* one register BW holds 4 x 4-bit packed settings for NCS0 - NCS3 */ + +#define EXYNOS_SROM_BW__DATAWIDTH__SHIFT 0 +#define EXYNOS_SROM_BW__ADDRMODE__SHIFT 1 +#define EXYNOS_SROM_BW__WAITENABLE__SHIFT 2 +#define EXYNOS_SROM_BW__BYTEENABLE__SHIFT 3 + +#define EXYNOS_SROM_BW__CS_MASK 0xf + +#define EXYNOS_SROM_BW__NCS0__SHIFT 0 +#define EXYNOS_SROM_BW__NCS1__SHIFT 4 +#define EXYNOS_SROM_BW__NCS2__SHIFT 8 +#define EXYNOS_SROM_BW__NCS3__SHIFT 12 +#define EXYNOS_SROM_BW__NCS4__SHIFT 16 +#define EXYNOS_SROM_BW__NCS5__SHIFT 20 + +/* applies to same to BCS0 - BCS3 */ + +#define EXYNOS_SROM_BCX__PMC__SHIFT 0 +#define EXYNOS_SROM_BCX__TACP__SHIFT 4 +#define EXYNOS_SROM_BCX__TCAH__SHIFT 8 +#define EXYNOS_SROM_BCX__TCOH__SHIFT 12 +#define EXYNOS_SROM_BCX__TACC__SHIFT 16 +#define EXYNOS_SROM_BCX__TCOS__SHIFT 24 +#define EXYNOS_SROM_BCX__TACS__SHIFT 28 + +#endif /* __EXYNOS_SROM_H */ -- 2.4.5 ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-10-19 14:29 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-10-13 15:00 [PATCH v3 6/8] drivers: soc: add support for exynos SROM driver LABBE Corentin 2015-10-19 14:28 ` Pankaj Dubey -- strict thread matches above, loose matches on Subject: below -- 2015-10-13 13:13 [PATCH v3 0/8] Add support for Exynos SROM Controller driver Pankaj Dubey 2015-10-13 13:13 ` [PATCH v3 6/8] drivers: soc: add support for exynos SROM driver Pankaj Dubey
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox