This patch series mainly adds an syscon driver which is used to access
general system controller registers like FSL IOMUXC GPR and ANATOP,
after that, we convert all the exist private access general registers code to use
standard API from regmap to access registers.
Finally we remove the old mfd anatop driver which is only for anatop register
access.
The patch series is based on linus's tree 3.6-rc3 since commit 9160338.
ChangeLog v3->v4:
Only '[PATCH v4 1/7] mfd: add syscon driver based on regmap' is changed.
Dong Aisheng (7):
mfd: add syscon driver based on regmap
ARM: imx6q: add iomuxc gpr support into syscon
ARM: imx6q: add anatop support into syscon
regulator: anatop-regulator: convert to use syscon to access anatop
register
ARM: imx6q: convert to use syscon to access anatop registers
ARM: dts: imx6q: add simple-bus compatible string for anatop
mfd: anatop-mfd: remove anatop driver
Documentation/devicetree/bindings/mfd/syscon.txt | 20 ++
arch/arm/boot/dts/imx6q.dtsi | 9 +-
arch/arm/mach-imx/Kconfig | 2 +-
arch/arm/mach-imx/mach-imx6q.c | 47 ++--
drivers/mfd/Kconfig | 13 +-
drivers/mfd/Makefile | 2 +-
drivers/mfd/anatop-mfd.c | 124 ---------
drivers/mfd/syscon.c | 170 ++++++++++++
drivers/regulator/Kconfig | 2 +-
drivers/regulator/anatop-regulator.c | 30 ++-
include/linux/fsl/imx6q-iomuxc-gpr.h | 319 ++++++++++++++++++++++
include/linux/mfd/anatop.h | 40 ---
include/linux/mfd/syscon.h | 23 ++
13 files changed, 586 insertions(+), 215 deletions(-)
create mode 100644 Documentation/devicetree/bindings/mfd/syscon.txt
delete mode 100644 drivers/mfd/anatop-mfd.c
create mode 100644 drivers/mfd/syscon.c
create mode 100644 include/linux/fsl/imx6q-iomuxc-gpr.h
delete mode 100644 include/linux/mfd/anatop.h
create mode 100644 include/linux/mfd/syscon.h
From: Dong Aisheng <redacted>
Add regmap based syscon driver.
This is usually used for access misc bits in registers which does not belong
to a specific module, for example, IMX IOMUXC GPR and ANATOP.
With this driver, client can use generic regmap API to access registers
which are registered into syscon.
Reviewed-by: Mark Brown <redacted>
Acked-by: Stephen Warren <redacted>
Signed-off-by: Dong Aisheng <redacted>
---
ChangeLog:
v3->v4:
* add more description about syscon(provided by Stephen Warren) in binding doc.
* fix a minor code indent error and remove set cache type code since the cache
is disabled by default.
v2->v3:
* export regmap lookup APIs including syscon_node_to_regmap
* fix a few typo
v1->v2:
* provide a way of retrieving the regmap, suggested by Mark Brown.
* delete imx-syscon io accessors and using generic regmap API for client drivers.
* change to a more generic name for other SoCs to use.
---
Documentation/devicetree/bindings/mfd/syscon.txt | 20 +++
drivers/mfd/Kconfig | 7 +
drivers/mfd/Makefile | 1 +
drivers/mfd/syscon.c | 170 ++++++++++++++++++++++
include/linux/mfd/syscon.h | 23 +++
5 files changed, 221 insertions(+), 0 deletions(-)
@@ -0,0 +1,20 @@+* System Controller Registers R/W driver++System controller node represents a register region containing a set+of miscellaneous registers. The registers are not cohesive enough to+represent as any specific type of device. The typical use-case is for+some other node's driver, or platform-specific code, to acquire a+reference to the syscon node (e.g. by phandle, node path, or search+using a specific compatible value), interrogate the node (or associated+OS driver) to determine the location of the registers, and access the+registers directly.++Required properties:+- compatible: Should contain "syscon".+- reg: the register region can be accessed from syscon++Examples:+gpr: iomuxc-gpr at 020e0000 {+ compatible = "fsl,imx6q-iomuxc-gpr", "syscon";+ reg = <0x020e0000 0x38>;+};
@@ -993,6 +993,13 @@ config MFD_ANATOPMFDcontroller.ThiscontrollerembedsregulatorandthermaldevicesforFreescalei.MXplatforms.+configMFD_SYSCON+bool"System Controller Register R/W Based on Regmap"+selectREGMAP_MMIO+help+Selectthisoptiontoenableaccessingsystemcontrolregisters+viaregmap.+configMFD_PALMASbool"Support for the TI Palmas series chips"selectMFD_CORE
From: Dong Aisheng <redacted>
There're a few anatop registers need to be accessed by different modules.
Add anatop registers into syscon support for easy access.
Acked-by: Stephen Warren <redacted>
Signed-off-by: Dong Aisheng <redacted>
---
arch/arm/boot/dts/imx6q.dtsi | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
From: Dong Aisheng <redacted>
Using syscon to access anatop register.
Acked-by: Mark Brown <redacted>
Acked-by: Stephen Warren <redacted>
Signed-off-by: Dong Aisheng <redacted>
---
ChangeLog v2->v3:
* update to use syscon_node_to_regmap and use of_get_parent to get anatop node.
ChangeLog v1-v2:
* update to use generic regmap api
---
drivers/regulator/Kconfig | 2 +-
drivers/regulator/anatop-regulator.c | 30 ++++++++++++++++++++----------
2 files changed, 21 insertions(+), 11 deletions(-)
@@ -1,124 +0,0 @@-/*- * Anatop MFD driver- *- * Copyright (C) 2012 Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>- * Copyright (C) 2012 Linaro- *- * This program is free software; you can redistribute it and/or modify- * it under the terms of the GNU General Public License as published by- * the Free Software Foundation; either version 2 of the License, or- * (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU General Public License for more details.- *- * You should have received a copy of the GNU General Public License along- * with this program; if not, write to the Free Software Foundation, Inc.,- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.- * This program is free software; you can redistribute it and/or modify- * it under the terms of the GNU General Public License as published by- * the Free Software Foundation; either version 2 of the License, or- * (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU General Public License for more details.- *- * You should have received a copy of the GNU General Public License along- * with this program; if not, write to the Free Software Foundation, Inc.,- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.- *- */--#include <linux/io.h>-#include <linux/module.h>-#include <linux/platform_device.h>-#include <linux/of.h>-#include <linux/of_platform.h>-#include <linux/of_address.h>-#include <linux/mfd/anatop.h>--u32 anatop_read_reg(struct anatop *adata, u32 addr)-{- return readl(adata->ioreg + addr);-}-EXPORT_SYMBOL_GPL(anatop_read_reg);--void anatop_write_reg(struct anatop *adata, u32 addr, u32 data, u32 mask)-{- u32 val;-- data &= mask;-- spin_lock(&adata->reglock);- val = readl(adata->ioreg + addr);- val &= ~mask;- val |= data;- writel(val, adata->ioreg + addr);- spin_unlock(&adata->reglock);-}-EXPORT_SYMBOL_GPL(anatop_write_reg);--static const struct of_device_id of_anatop_match[] = {- { .compatible = "fsl,imx6q-anatop", },- { },-};--static int __devinit of_anatop_probe(struct platform_device *pdev)-{- struct device *dev = &pdev->dev;- struct device_node *np = dev->of_node;- void *ioreg;- struct anatop *drvdata;-- ioreg = of_iomap(np, 0);- if (!ioreg)- return -EADDRNOTAVAIL;- drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);- if (!drvdata)- return -ENOMEM;- drvdata->ioreg = ioreg;- spin_lock_init(&drvdata->reglock);- platform_set_drvdata(pdev, drvdata);- of_platform_populate(np, NULL, NULL, dev);-- return 0;-}--static int __devexit of_anatop_remove(struct platform_device *pdev)-{- struct anatop *drvdata;- drvdata = platform_get_drvdata(pdev);- iounmap(drvdata->ioreg);-- return 0;-}--static struct platform_driver anatop_of_driver = {- .driver = {- .name = "anatop-mfd",- .owner = THIS_MODULE,- .of_match_table = of_anatop_match,- },- .probe = of_anatop_probe,- .remove = of_anatop_remove,-};--static int __init anatop_init(void)-{- return platform_driver_register(&anatop_of_driver);-}-postcore_initcall(anatop_init);--static void __exit anatop_exit(void)-{- platform_driver_unregister(&anatop_of_driver);-}-module_exit(anatop_exit);--MODULE_AUTHOR("Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>");-MODULE_DESCRIPTION("ANATOP MFD driver");-MODULE_LICENSE("GPL v2");
@@ -1,40 +0,0 @@-/*- * anatop.h - Anatop MFD driver- *- * Copyright (C) 2012 Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>- * Copyright (C) 2012 Linaro- *- * This program is free software; you can redistribute it and/or modify- * it under the terms of the GNU General Public License as published by- * the Free Software Foundation; either version 2 of the License, or- * (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU General Public License for more details.- *- * You should have received a copy of the GNU General Public License- * along with this program; if not, write to the Free Software- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA- */--#ifndef __LINUX_MFD_ANATOP_H-#define __LINUX_MFD_ANATOP_H--#include <linux/spinlock.h>--/**- * anatop - MFD data- * @ioreg: ioremap register- * @reglock: spinlock for register read/write- */-struct anatop {- void *ioreg;- spinlock_t reglock;-};--extern u32 anatop_read_reg(struct anatop *, u32);-extern void anatop_write_reg(struct anatop *, u32, u32, u32);--#endif /* __LINUX_MFD_ANATOP_H */
From: Dong Aisheng <redacted>
Originally the anatop regulator devices are populated by mfd anatop driver.
Since mfd anatop driver will be deleted later, we change to populate the
regulator devices by devicetree automatically.
This will cause some warning messages as follows during boot due to device
recreation: "vdd1p1: Failed to create debugfs directory"
But it does not break any function.
Later, we will remove mfd anatop driver which can get rid of this
error message.
Acked-by: Stephen Warren <redacted>
Signed-off-by: Dong Aisheng <redacted>
---
arch/arm/boot/dts/imx6q.dtsi | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
This looks a little unnatural to me. Function syscon_node_to_regmap
becomes an API visible to clients, who might never know that np will
be put inside the API. I'm saying the client may also call of_node_put
to put the node they get.
I think of_node_put should be moved out from here and put into
syscon_node_to_regmap and syscon_regmap_lookup_by_compatible.
Regards,
Shawn
On Wed, Aug 29, 2012 at 06:56:53PM +0800, Dong Aisheng wrote:
From: Dong Aisheng <redacted>
Include headfile for easy using.
Acked-by: Stephen Warren <redacted>
Signed-off-by: Dong Aisheng <redacted>
---
arch/arm/boot/dts/imx6q.dtsi | 5 +
include/linux/fsl/imx6q-iomuxc-gpr.h | 319 ++++++++++++++++++++++++++++++++++
I assume that all the users of this header file are imx6q syscon
clients. In that case, this header belongs to mfd/syscon subsystem.
I have been told by people that it was a mistake to create
include/linux/fsl. Each header in include/linux should go to
respective subsystem sub-directory. For this particular case,
it should be include/linux/mfd or include/linux/mfd/syscon even
better, IMO.
<snip>
This looks a little unnatural to me. Function syscon_node_to_regmap
becomes an API visible to clients, who might never know that np will
be put inside the API. I'm saying the client may also call of_node_put
to put the node they get.
We probably could add a comment here for the API to avoid this happen.
I think of_node_put should be moved out from here and put into
syscon_node_to_regmap and syscon_regmap_lookup_by_compatible.
I guess no, if you want to move of_node_put into syscon_regmap_lookup_by_phandle,
then syscon_regmap_lookup_by_phandle has the same issue.
Actually i had considered your concern when writing this API...
The original purpose of doing like that is saving some duplicated 'of_node_put'
and make the API easy to use.
I searched the kernel dt code and found it existed some similar cases.
e.g: of_irq_find_parent, of_get_next_parent
So it looks to me that it may be usually to do like that for the cases that
the conversion from a node to other thing since the client may only care
about the things converted. For our case, it's regmap.
So i can't think it make too much sense for all client driver have to write
duplicated and meaningless 'of_node_put' code.
Regards
Dong Aisheng
On Fri, Aug 31, 2012 at 10:02:48AM +0800, Shawn Guo wrote:
On Wed, Aug 29, 2012 at 06:56:53PM +0800, Dong Aisheng wrote:
quoted
From: Dong Aisheng <redacted>
Include headfile for easy using.
Acked-by: Stephen Warren <redacted>
Signed-off-by: Dong Aisheng <redacted>
---
arch/arm/boot/dts/imx6q.dtsi | 5 +
include/linux/fsl/imx6q-iomuxc-gpr.h | 319 ++++++++++++++++++++++++++++++++++
I assume that all the users of this header file are imx6q syscon
clients. In that case, this header belongs to mfd/syscon subsystem.
I have been told by people that it was a mistake to create
include/linux/fsl. Each header in include/linux should go to
respective subsystem sub-directory. For this particular case,
it should be include/linux/mfd or include/linux/mfd/syscon even
better, IMO.
I like the later one if not put in include/linux/fsl. :)
On Mon, Sep 03, 2012 at 10:31:03AM +0800, Dong Aisheng wrote:
quoted
I think of_node_put should be moved out from here and put into
syscon_node_to_regmap and syscon_regmap_lookup_by_compatible.
I guess no, if you want to move of_node_put into syscon_regmap_lookup_by_phandle,
then syscon_regmap_lookup_by_phandle has the same issue.
I guess not. syscon_regmap_lookup_by_phandle itself calls of_parse_phandle,
and that's where the refcount gets incremented, so syscon_regmap_lookup_by_phandle
should be responsible for calling of_node_put to get the refcount decremented.
--
Regards,
Shawn
On Mon, Sep 03, 2012 at 11:09:01AM +0800, Shawn Guo wrote:
On Mon, Sep 03, 2012 at 10:31:03AM +0800, Dong Aisheng wrote:
quoted
quoted
I think of_node_put should be moved out from here and put into
syscon_node_to_regmap and syscon_regmap_lookup_by_compatible.
I guess no, if you want to move of_node_put into syscon_regmap_lookup_by_phandle,
then syscon_regmap_lookup_by_phandle has the same issue.
I guess not. syscon_regmap_lookup_by_phandle itself calls of_parse_phandle,
and that's where the refcount gets incremented, so syscon_regmap_lookup_by_phandle
should be responsible for calling of_node_put to get the refcount decremented.
Yes, the of_node_put will be done in syscon_node_to_regmap which is called by
syscon_regmap_lookup_by_phandle,
The reason why we do it is as i said in my last reply.
I think one known issue is that syscon_node_to_regmap may not be suitable to
be used by the driver who still wants to use the regmap node after calling the
syscon_node_to_regmap.
I still do not find such using case but i'm not sure whether it may exist.
Probably the safe way currently to do is just as you said:
Not put the node in syscon_node_to_regmap and let user decide.
Ok, i will update it.
Regards
Dong Aisheng