* [PATCH 0/3] Rockchip: generalize GRF setup
@ 2016-05-23 14:58 Heiko Stuebner
[not found] ` <1464015539-19521-1-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
0 siblings, 1 reply; 12+ messages in thread
From: Heiko Stuebner @ 2016-05-23 14:58 UTC (permalink / raw)
To: linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, Heiko Stuebner,
arnd-r2nGTMty4D4, shawn.lin-TNX95d0MmH7DzftRWevZcw,
dianders-F7+t8E8rja9g9hUCZPvPmw, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
olof-nZhT3qVonbNeoWH0uzbU5w, wxt-TNX95d0MmH7DzftRWevZcw
The General register files contain a big bunch of settings for various
components. Things like the automatic sdmmc/jtag switch may even affect
us in a bad way, while that property (and possibly others) are not even
part of the dw_mmc controller itself.
And while the rk3288 could still carry adaptions to these defaults
in its mach files, this is no longer possible on the arm64 socs, while
things like the jtag-switch from above still can affect us there.
So introduce a separate driver that binds to the already set soc-
specific grf compatibles and does the necessary setup for things.
It could also take over handling the grf pclk so that we don't have
to have the clock-framework keep control of it, as disabling causes
havok on the system.
Heiko Stuebner (3):
dt-bindings: add used but undocumented rockchip grf compatible values
soc: rockchip: add driver handling grf setup
ARM: rockchip: drop jtag/mmc switch handling
.../devicetree/bindings/soc/rockchip/grf.txt | 4 +
arch/arm/mach-rockchip/rockchip.c | 12 --
drivers/soc/rockchip/Kconfig | 10 ++
drivers/soc/rockchip/Makefile | 1 +
drivers/soc/rockchip/grf.c | 138 +++++++++++++++++++++
5 files changed, 153 insertions(+), 12 deletions(-)
create mode 100644 drivers/soc/rockchip/grf.c
--
2.6.4
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/3] dt-bindings: add used but undocumented rockchip grf compatible values
[not found] ` <1464015539-19521-1-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
@ 2016-05-23 14:58 ` Heiko Stuebner
[not found] ` <1464015539-19521-2-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2016-05-23 14:58 ` [PATCH 2/3] soc: rockchip: add driver handling grf setup Heiko Stuebner
2016-05-23 14:58 ` [PATCH 3/3] ARM: rockchip: drop rk3288 jtag/mmc switch handling Heiko Stuebner
2 siblings, 1 reply; 12+ messages in thread
From: Heiko Stuebner @ 2016-05-23 14:58 UTC (permalink / raw)
To: linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, Heiko Stuebner,
arnd-r2nGTMty4D4, shawn.lin-TNX95d0MmH7DzftRWevZcw,
dianders-F7+t8E8rja9g9hUCZPvPmw, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
olof-nZhT3qVonbNeoWH0uzbU5w, wxt-TNX95d0MmH7DzftRWevZcw
There are some more General Register Files used in devicetree files
already, but as of now undocumented in the binding document, fix that.
Signed-off-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
---
Documentation/devicetree/bindings/soc/rockchip/grf.txt | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/bindings/soc/rockchip/grf.txt b/Documentation/devicetree/bindings/soc/rockchip/grf.txt
index 013e71a..c6e62cb 100644
--- a/Documentation/devicetree/bindings/soc/rockchip/grf.txt
+++ b/Documentation/devicetree/bindings/soc/rockchip/grf.txt
@@ -5,11 +5,13 @@ is composed of many registers for system control.
From RK3368 SoCs, the GRF is divided into two sections,
- GRF, used for general non-secure system,
+- SGRF, used for general secure system,
- PMUGRF, used for always on system
Required Properties:
- compatible: GRF should be one of the followings
+ - "rockchip,rk3036-grf", "syscon": for rk3036
- "rockchip,rk3066-grf", "syscon": for rk3066
- "rockchip,rk3188-grf", "syscon": for rk3188
- "rockchip,rk3228-grf", "syscon": for rk3228
@@ -19,6 +21,8 @@ Required Properties:
- compatible: PMUGRF should be one of the followings
- "rockchip,rk3368-pmugrf", "syscon": for rk3368
- "rockchip,rk3399-pmugrf", "syscon": for rk3399
+- compatible: SGRF should be one of the following
+ - "rockchip,rk3288-sgrf", "syscon": for rk3288
- reg: physical base address of the controller and length of memory mapped
region.
--
2.6.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/3] soc: rockchip: add driver handling grf setup
[not found] ` <1464015539-19521-1-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2016-05-23 14:58 ` [PATCH 1/3] dt-bindings: add used but undocumented rockchip grf compatible values Heiko Stuebner
@ 2016-05-23 14:58 ` Heiko Stuebner
[not found] ` <1464015539-19521-3-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2016-05-23 14:58 ` [PATCH 3/3] ARM: rockchip: drop rk3288 jtag/mmc switch handling Heiko Stuebner
2 siblings, 1 reply; 12+ messages in thread
From: Heiko Stuebner @ 2016-05-23 14:58 UTC (permalink / raw)
To: linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, Heiko Stuebner,
arnd-r2nGTMty4D4, shawn.lin-TNX95d0MmH7DzftRWevZcw,
dianders-F7+t8E8rja9g9hUCZPvPmw, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
olof-nZhT3qVonbNeoWH0uzbU5w, wxt-TNX95d0MmH7DzftRWevZcw
The General Register Files are an area of registers containing a lot
of single-bit settings for numerous components as well full components
like usbphy control. Therefore all used components are accessed
via the syscon provided by the grf nodes or from the sub-devices
created through the simple-mfd created from the grf node.
Some settings are not used by anything but will need to be set up
according to expectations on the kernel side.
Best example is the force_jtag setting, which defaults to on and
results in the soc switching the pin-outputs between jtag and sdmmc
automatically depending on the card-detect status. This conflicts
heavily with how the dw_mmc driver expects to do its work and also
with the clock-controller, which has most likely deactivated the
jtag clock due to it being unused.
So far the handling of this setting was living in the mach-rockchip
code for the arm32-based rk3288 but that of course doesn't work
for arm64 socs and would also look ugly for further arm32 socs.
So introduce a top-level driver for the grf that handles these
settings that need to be a certain way but nobody cares about.
Signed-off-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
---
drivers/soc/rockchip/Kconfig | 10 +++
drivers/soc/rockchip/Makefile | 1 +
drivers/soc/rockchip/grf.c | 138 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 149 insertions(+)
create mode 100644 drivers/soc/rockchip/grf.c
diff --git a/drivers/soc/rockchip/Kconfig b/drivers/soc/rockchip/Kconfig
index 7140ff8..20da55d 100644
--- a/drivers/soc/rockchip/Kconfig
+++ b/drivers/soc/rockchip/Kconfig
@@ -3,6 +3,16 @@ if ARCH_ROCKCHIP || COMPILE_TEST
#
# Rockchip Soc drivers
#
+
+config ROCKCHIP_GRF
+ bool
+ default y
+ help
+ The General Register Files are a central component providing
+ special additional settings registers for a lot of soc-components.
+ In a lot of cases there also need to be default settings initialized
+ to make some of them conform to expectations of the kernel.
+
config ROCKCHIP_PM_DOMAINS
bool "Rockchip generic power domain"
depends on PM
diff --git a/drivers/soc/rockchip/Makefile b/drivers/soc/rockchip/Makefile
index 3d73d06..c851fa0 100644
--- a/drivers/soc/rockchip/Makefile
+++ b/drivers/soc/rockchip/Makefile
@@ -1,4 +1,5 @@
#
# Rockchip Soc drivers
#
+obj-$(CONFIG_ROCKCHIP_GRF) += grf.o
obj-$(CONFIG_ROCKCHIP_PM_DOMAINS) += pm_domains.o
diff --git a/drivers/soc/rockchip/grf.c b/drivers/soc/rockchip/grf.c
new file mode 100644
index 0000000..25a1fd3
--- /dev/null
+++ b/drivers/soc/rockchip/grf.c
@@ -0,0 +1,138 @@
+/*
+ * Rockchip Generic Register Files setup
+ *
+ * Copyright (c) 2016 Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
+ *
+ * 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/err.h>
+#include <linux/regmap.h>
+#include <linux/mfd/syscon.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+
+#define HIWORD_UPDATE(val, mask, shift) \
+ ((val) << (shift) | (mask) << ((shift) + 16))
+
+struct rockchip_grf_value {
+ const char *desc;
+ u32 reg;
+ u32 val;
+};
+
+struct rockchip_grf_info {
+ const struct rockchip_grf_value *values;
+ int num_values;
+};
+
+#define RK3036_GRF_SOC_CON0 0x140
+
+static const struct rockchip_grf_value rk3036_defaults[] = {
+ /*
+ * Disable auto jtag/sdmmc switching that causes issues with the
+ * clock-framework and the mmc controllers making them unreliable.
+ */
+ { "jtag switching", RK3036_GRF_SOC_CON0, HIWORD_UPDATE(0, 1, 11) },
+};
+
+static const struct rockchip_grf_info rk3036_grf = {
+ .values = rk3036_defaults,
+ .num_values = ARRAY_SIZE(rk3036_defaults),
+};
+
+#define RK3288_GRF_SOC_CON0 0x244
+
+static const struct rockchip_grf_value rk3288_defaults[] = {
+ { "jtag switching", RK3288_GRF_SOC_CON0, HIWORD_UPDATE(0, 1, 12) },
+};
+
+static const struct rockchip_grf_info rk3288_grf = {
+ .values = rk3288_defaults,
+ .num_values = ARRAY_SIZE(rk3288_defaults),
+};
+
+#define RK3399_GRF_SOC_CON7 0xe21c
+
+static const struct rockchip_grf_value rk3399_defaults[] = {
+ { "jtag switching", RK3399_GRF_SOC_CON7, HIWORD_UPDATE(0, 1, 12) },
+
+};
+
+static const struct rockchip_grf_info rk3399_grf = {
+ .values = rk3399_defaults,
+ .num_values = ARRAY_SIZE(rk3399_defaults),
+};
+
+static const struct of_device_id rockchip_grf_dt_match[] = {
+ {
+ .compatible = "rockchip,rk3036-grf",
+ .data = (void *)&rk3036_grf,
+ }, {
+ .compatible = "rockchip,rk3288-grf",
+ .data = (void *)&rk3288_grf,
+ }, {
+ .compatible = "rockchip,rk3399-grf",
+ .data = (void *)&rk3399_grf,
+ },
+ { /* sentinel */ },
+};
+
+static int rockchip_grf_probe(struct platform_device *pdev)
+{
+ const struct rockchip_grf_info *grf_info;
+ const struct of_device_id *match;
+ struct device *dev = &pdev->dev;
+ struct regmap *grf;
+ int i;
+
+ if (!dev->of_node)
+ return -ENODEV;
+
+ match = of_match_device(rockchip_grf_dt_match, dev);
+ if (!match || !match->data) {
+ dev_err(dev, "missing grf data\n");
+ return -EINVAL;
+ }
+
+ grf_info = match->data;
+
+ grf = syscon_node_to_regmap(dev->of_node);
+ if (IS_ERR(grf)) {
+ dev_err(dev, "rockchip: could not get grf syscon\n");
+ return PTR_ERR(grf);
+ }
+
+ for (i = 0; i < grf_info->num_values; i++) {
+ const struct rockchip_grf_value *val = &grf_info->values[i];
+
+ dev_dbg(dev, "adjusting %s in 0x%x to 0x%x\n",
+ val->desc, val->reg, val->val);
+ regmap_write(grf, val->reg, val->val);
+ }
+
+ return 0;
+}
+
+static struct platform_driver rockchip_grf_driver = {
+ .probe = rockchip_grf_probe,
+ .driver = {
+ .name = "rockchip-grf",
+ .of_match_table = rockchip_grf_dt_match,
+ /*
+ * The General Register Files are a central component
+ * accessed by numerous ip blocks and we're setting
+ * defaults which should only happen once.
+ */
+ .suppress_bind_attrs = true,
+ },
+};
+
+static int __init rockchip_grf_drv_register(void)
+{
+ return platform_driver_register(&rockchip_grf_driver);
+}
+postcore_initcall(rockchip_grf_drv_register);
--
2.6.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/3] ARM: rockchip: drop rk3288 jtag/mmc switch handling
[not found] ` <1464015539-19521-1-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2016-05-23 14:58 ` [PATCH 1/3] dt-bindings: add used but undocumented rockchip grf compatible values Heiko Stuebner
2016-05-23 14:58 ` [PATCH 2/3] soc: rockchip: add driver handling grf setup Heiko Stuebner
@ 2016-05-23 14:58 ` Heiko Stuebner
[not found] ` <1464015539-19521-4-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2 siblings, 1 reply; 12+ messages in thread
From: Heiko Stuebner @ 2016-05-23 14:58 UTC (permalink / raw)
To: linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: dianders-F7+t8E8rja9g9hUCZPvPmw, olof-nZhT3qVonbNeoWH0uzbU5w,
arnd-r2nGTMty4D4, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
devicetree-u79uwXL29TY76Z2rM5mHXA, wxt-TNX95d0MmH7DzftRWevZcw,
shawn.lin-TNX95d0MmH7DzftRWevZcw, Heiko Stuebner
We moved that functionality to a more generic place where it can also
be used for other socs, so drop it from architecture code.
Signed-off-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
---
arch/arm/mach-rockchip/rockchip.c | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/arch/arm/mach-rockchip/rockchip.c b/arch/arm/mach-rockchip/rockchip.c
index beb71da..e7b2aa7 100644
--- a/arch/arm/mach-rockchip/rockchip.c
+++ b/arch/arm/mach-rockchip/rockchip.c
@@ -29,13 +29,11 @@
#include "core.h"
#include "pm.h"
-#define RK3288_GRF_SOC_CON0 0x244
#define RK3288_TIMER6_7_PHYS 0xff810000
static void __init rockchip_timer_init(void)
{
if (of_machine_is_compatible("rockchip,rk3288")) {
- struct regmap *grf;
void __iomem *reg_base;
/*
@@ -54,16 +52,6 @@ static void __init rockchip_timer_init(void)
} else {
pr_err("rockchip: could not map timer7 registers\n");
}
-
- /*
- * Disable auto jtag/sdmmc switching that causes issues
- * with the mmc controllers making them unreliable
- */
- grf = syscon_regmap_lookup_by_compatible("rockchip,rk3288-grf");
- if (!IS_ERR(grf))
- regmap_write(grf, RK3288_GRF_SOC_CON0, 0x10000000);
- else
- pr_err("rockchip: could not get grf syscon\n");
}
of_clk_init(NULL);
--
2.6.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] soc: rockchip: add driver handling grf setup
[not found] ` <1464015539-19521-3-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
@ 2016-05-23 20:46 ` Doug Anderson
2016-05-24 2:22 ` Shawn Lin
1 sibling, 0 replies; 12+ messages in thread
From: Doug Anderson @ 2016-05-23 20:46 UTC (permalink / raw)
To: Heiko Stuebner
Cc: open list:ARM/Rockchip SoC...,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Olof Johansson, Arnd Bergmann, Rob Herring,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Caesar Wang,
Shawn Lin
Heiko,
On Mon, May 23, 2016 at 7:58 AM, Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> wrote:
> +struct rockchip_grf_info {
> + const struct rockchip_grf_value *values;
> + int num_values;
> +};
> +
> +#define RK3036_GRF_SOC_CON0 0x140
> +
> +static const struct rockchip_grf_value rk3036_defaults[] = {
Worth saving the little bit of space by marking several of these
structures as __initconst ?
> +#define RK3399_GRF_SOC_CON7 0xe21c
> +
> +static const struct rockchip_grf_value rk3399_defaults[] = {
> + { "jtag switching", RK3399_GRF_SOC_CON7, HIWORD_UPDATE(0, 1, 12) },
> +
> +};
nit: extra blank line in rk3399_defaults?
> +static int rockchip_grf_probe(struct platform_device *pdev)
> +{
> + const struct rockchip_grf_info *grf_info;
> + const struct of_device_id *match;
> + struct device *dev = &pdev->dev;
> + struct regmap *grf;
> + int i;
> +
> + if (!dev->of_node)
> + return -ENODEV;
> +
> + match = of_match_device(rockchip_grf_dt_match, dev);
> + if (!match || !match->data) {
> + dev_err(dev, "missing grf data\n");
> + return -EINVAL;
> + }
> +
> + grf_info = match->data;
> +
> + grf = syscon_node_to_regmap(dev->of_node);
> + if (IS_ERR(grf)) {
> + dev_err(dev, "rockchip: could not get grf syscon\n");
> + return PTR_ERR(grf);
> + }
> +
> + for (i = 0; i < grf_info->num_values; i++) {
> + const struct rockchip_grf_value *val = &grf_info->values[i];
> +
> + dev_dbg(dev, "adjusting %s in 0x%x to 0x%x\n",
optional-nitty-nit saves a character: s/0x%x/%#x/
...or even force to 4 hex digits: %#6x
> + val->desc, val->reg, val->val);
> + regmap_write(grf, val->reg, val->val);
Dunno if we care, but regmap_write() does return an error. Presumably
it might return an error here if you somehow specified an offset that
was outside of the range for the GRF?
-Doug
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] ARM: rockchip: drop rk3288 jtag/mmc switch handling
[not found] ` <1464015539-19521-4-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
@ 2016-05-23 20:47 ` Doug Anderson
2016-05-24 2:09 ` Shawn Lin
1 sibling, 0 replies; 12+ messages in thread
From: Doug Anderson @ 2016-05-23 20:47 UTC (permalink / raw)
To: Heiko Stuebner
Cc: open list:ARM/Rockchip SoC...,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Olof Johansson, Arnd Bergmann, Rob Herring,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Caesar Wang,
Shawn Lin
Heiko,
On Mon, May 23, 2016 at 7:58 AM, Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> wrote:
> We moved that functionality to a more generic place where it can also
> be used for other socs, so drop it from architecture code.
>
> Signed-off-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
> ---
> arch/arm/mach-rockchip/rockchip.c | 12 ------------
> 1 file changed, 12 deletions(-)
Reviewed-by: Douglas Anderson <dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] dt-bindings: add used but undocumented rockchip grf compatible values
[not found] ` <1464015539-19521-2-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
@ 2016-05-23 20:47 ` Doug Anderson
2016-05-23 21:38 ` Rob Herring
2016-05-24 2:05 ` Shawn Lin
2 siblings, 0 replies; 12+ messages in thread
From: Doug Anderson @ 2016-05-23 20:47 UTC (permalink / raw)
To: Heiko Stuebner
Cc: open list:ARM/Rockchip SoC...,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Olof Johansson, Arnd Bergmann, Rob Herring,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Caesar Wang,
Shawn Lin
Heiko,
On Mon, May 23, 2016 at 7:58 AM, Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> wrote:
> There are some more General Register Files used in devicetree files
> already, but as of now undocumented in the binding document, fix that.
>
> Signed-off-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
> ---
> Documentation/devicetree/bindings/soc/rockchip/grf.txt | 4 ++++
> 1 file changed, 4 insertions(+)
Reviewed-by: Douglas Anderson <dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] dt-bindings: add used but undocumented rockchip grf compatible values
[not found] ` <1464015539-19521-2-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2016-05-23 20:47 ` Doug Anderson
@ 2016-05-23 21:38 ` Rob Herring
2016-05-24 2:05 ` Shawn Lin
2 siblings, 0 replies; 12+ messages in thread
From: Rob Herring @ 2016-05-23 21:38 UTC (permalink / raw)
To: Heiko Stuebner
Cc: linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
dianders-F7+t8E8rja9g9hUCZPvPmw, olof-nZhT3qVonbNeoWH0uzbU5w,
arnd-r2nGTMty4D4, devicetree-u79uwXL29TY76Z2rM5mHXA,
wxt-TNX95d0MmH7DzftRWevZcw, shawn.lin-TNX95d0MmH7DzftRWevZcw
On Mon, May 23, 2016 at 04:58:57PM +0200, Heiko Stuebner wrote:
> There are some more General Register Files used in devicetree files
> already, but as of now undocumented in the binding document, fix that.
>
> Signed-off-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
> ---
> Documentation/devicetree/bindings/soc/rockchip/grf.txt | 4 ++++
> 1 file changed, 4 insertions(+)
Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] dt-bindings: add used but undocumented rockchip grf compatible values
[not found] ` <1464015539-19521-2-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2016-05-23 20:47 ` Doug Anderson
2016-05-23 21:38 ` Rob Herring
@ 2016-05-24 2:05 ` Shawn Lin
2 siblings, 0 replies; 12+ messages in thread
From: Shawn Lin @ 2016-05-24 2:05 UTC (permalink / raw)
To: Heiko Stuebner, linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: shawn.lin-TNX95d0MmH7DzftRWevZcw, dianders-F7+t8E8rja9g9hUCZPvPmw,
olof-nZhT3qVonbNeoWH0uzbU5w, arnd-r2nGTMty4D4,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, devicetree-u79uwXL29TY76Z2rM5mHXA,
wxt-TNX95d0MmH7DzftRWevZcw
在 2016/5/23 22:58, Heiko Stuebner 写道:
> There are some more General Register Files used in devicetree files
> already, but as of now undocumented in the binding document, fix that.
>
> Signed-off-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
> ---
Reviewed-by: Shawn Lin <shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
> Documentation/devicetree/bindings/soc/rockchip/grf.txt | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/soc/rockchip/grf.txt b/Documentation/devicetree/bindings/soc/rockchip/grf.txt
> index 013e71a..c6e62cb 100644
> --- a/Documentation/devicetree/bindings/soc/rockchip/grf.txt
> +++ b/Documentation/devicetree/bindings/soc/rockchip/grf.txt
> @@ -5,11 +5,13 @@ is composed of many registers for system control.
>
> From RK3368 SoCs, the GRF is divided into two sections,
> - GRF, used for general non-secure system,
> +- SGRF, used for general secure system,
> - PMUGRF, used for always on system
>
> Required Properties:
>
> - compatible: GRF should be one of the followings
> + - "rockchip,rk3036-grf", "syscon": for rk3036
> - "rockchip,rk3066-grf", "syscon": for rk3066
> - "rockchip,rk3188-grf", "syscon": for rk3188
> - "rockchip,rk3228-grf", "syscon": for rk3228
> @@ -19,6 +21,8 @@ Required Properties:
> - compatible: PMUGRF should be one of the followings
> - "rockchip,rk3368-pmugrf", "syscon": for rk3368
> - "rockchip,rk3399-pmugrf", "syscon": for rk3399
> +- compatible: SGRF should be one of the following
> + - "rockchip,rk3288-sgrf", "syscon": for rk3288
> - reg: physical base address of the controller and length of memory mapped
> region.
>
>
--
Best Regards
Shawn Lin
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] ARM: rockchip: drop rk3288 jtag/mmc switch handling
[not found] ` <1464015539-19521-4-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2016-05-23 20:47 ` Doug Anderson
@ 2016-05-24 2:09 ` Shawn Lin
1 sibling, 0 replies; 12+ messages in thread
From: Shawn Lin @ 2016-05-24 2:09 UTC (permalink / raw)
To: Heiko Stuebner, linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: shawn.lin-TNX95d0MmH7DzftRWevZcw, dianders-F7+t8E8rja9g9hUCZPvPmw,
olof-nZhT3qVonbNeoWH0uzbU5w, arnd-r2nGTMty4D4,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, devicetree-u79uwXL29TY76Z2rM5mHXA,
wxt-TNX95d0MmH7DzftRWevZcw
在 2016/5/23 22:58, Heiko Stuebner 写道:
> We moved that functionality to a more generic place where it can also
> be used for other socs, so drop it from architecture code.
>
> Signed-off-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
It looks good to drop this Soc related setting from
architecture code.
Reviewed-by: Shawn Lin <shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
> ---
> arch/arm/mach-rockchip/rockchip.c | 12 ------------
> 1 file changed, 12 deletions(-)
>
> diff --git a/arch/arm/mach-rockchip/rockchip.c b/arch/arm/mach-rockchip/rockchip.c
> index beb71da..e7b2aa7 100644
> --- a/arch/arm/mach-rockchip/rockchip.c
> +++ b/arch/arm/mach-rockchip/rockchip.c
> @@ -29,13 +29,11 @@
> #include "core.h"
> #include "pm.h"
>
> -#define RK3288_GRF_SOC_CON0 0x244
> #define RK3288_TIMER6_7_PHYS 0xff810000
>
> static void __init rockchip_timer_init(void)
> {
> if (of_machine_is_compatible("rockchip,rk3288")) {
> - struct regmap *grf;
> void __iomem *reg_base;
>
> /*
> @@ -54,16 +52,6 @@ static void __init rockchip_timer_init(void)
> } else {
> pr_err("rockchip: could not map timer7 registers\n");
> }
> -
> - /*
> - * Disable auto jtag/sdmmc switching that causes issues
> - * with the mmc controllers making them unreliable
> - */
> - grf = syscon_regmap_lookup_by_compatible("rockchip,rk3288-grf");
> - if (!IS_ERR(grf))
> - regmap_write(grf, RK3288_GRF_SOC_CON0, 0x10000000);
> - else
> - pr_err("rockchip: could not get grf syscon\n");
> }
>
> of_clk_init(NULL);
>
--
Best Regards
Shawn Lin
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] soc: rockchip: add driver handling grf setup
[not found] ` <1464015539-19521-3-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2016-05-23 20:46 ` Doug Anderson
@ 2016-05-24 2:22 ` Shawn Lin
[not found] ` <6a6e87ee-688d-90a3-2407-22847bd80971-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
1 sibling, 1 reply; 12+ messages in thread
From: Shawn Lin @ 2016-05-24 2:22 UTC (permalink / raw)
To: Heiko Stuebner, linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: shawn.lin-TNX95d0MmH7DzftRWevZcw, dianders-F7+t8E8rja9g9hUCZPvPmw,
olof-nZhT3qVonbNeoWH0uzbU5w, arnd-r2nGTMty4D4,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, devicetree-u79uwXL29TY76Z2rM5mHXA,
wxt-TNX95d0MmH7DzftRWevZcw
Hi Heiko,
On 2016/5/23 22:58, Heiko Stuebner wrote:
> The General Register Files are an area of registers containing a lot
> of single-bit settings for numerous components as well full components
> like usbphy control. Therefore all used components are accessed
> via the syscon provided by the grf nodes or from the sub-devices
> created through the simple-mfd created from the grf node.
>
> Some settings are not used by anything but will need to be set up
> according to expectations on the kernel side.
>
> Best example is the force_jtag setting, which defaults to on and
> results in the soc switching the pin-outputs between jtag and sdmmc
> automatically depending on the card-detect status. This conflicts
> heavily with how the dw_mmc driver expects to do its work and also
> with the clock-controller, which has most likely deactivated the
> jtag clock due to it being unused.
I agree we should disable force_jtag for real product. But on my local
branch we add a callback to parse a tag from cmdline. Sometime it's
useful for debugging in case of we need to setup JTAG for reproducing
and comfirming serious issue in which state the CPU cannot reponse to
any console input or FIQ-debug triggering.
Should we need it for upstream as you move all related code in this
new driver? I'm not sure.
>
> So far the handling of this setting was living in the mach-rockchip
> code for the arm32-based rk3288 but that of course doesn't work
> for arm64 socs and would also look ugly for further arm32 socs.
>
> So introduce a top-level driver for the grf that handles these
> settings that need to be a certain way but nobody cares about.
>
> Signed-off-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
> ---
> drivers/soc/rockchip/Kconfig | 10 +++
> drivers/soc/rockchip/Makefile | 1 +
> drivers/soc/rockchip/grf.c | 138 ++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 149 insertions(+)
> create mode 100644 drivers/soc/rockchip/grf.c
>
> diff --git a/drivers/soc/rockchip/Kconfig b/drivers/soc/rockchip/Kconfig
> index 7140ff8..20da55d 100644
> --- a/drivers/soc/rockchip/Kconfig
> +++ b/drivers/soc/rockchip/Kconfig
> @@ -3,6 +3,16 @@ if ARCH_ROCKCHIP || COMPILE_TEST
> #
> # Rockchip Soc drivers
> #
> +
> +config ROCKCHIP_GRF
> + bool
> + default y
> + help
> + The General Register Files are a central component providing
> + special additional settings registers for a lot of soc-components.
> + In a lot of cases there also need to be default settings initialized
> + to make some of them conform to expectations of the kernel.
> +
> config ROCKCHIP_PM_DOMAINS
> bool "Rockchip generic power domain"
> depends on PM
> diff --git a/drivers/soc/rockchip/Makefile b/drivers/soc/rockchip/Makefile
> index 3d73d06..c851fa0 100644
> --- a/drivers/soc/rockchip/Makefile
> +++ b/drivers/soc/rockchip/Makefile
> @@ -1,4 +1,5 @@
> #
> # Rockchip Soc drivers
> #
> +obj-$(CONFIG_ROCKCHIP_GRF) += grf.o
> obj-$(CONFIG_ROCKCHIP_PM_DOMAINS) += pm_domains.o
> diff --git a/drivers/soc/rockchip/grf.c b/drivers/soc/rockchip/grf.c
> new file mode 100644
> index 0000000..25a1fd3
> --- /dev/null
> +++ b/drivers/soc/rockchip/grf.c
> @@ -0,0 +1,138 @@
> +/*
> + * Rockchip Generic Register Files setup
> + *
> + * Copyright (c) 2016 Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
> + *
> + * 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/err.h>
> +#include <linux/regmap.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/of_device.h>
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +
> +#define HIWORD_UPDATE(val, mask, shift) \
> + ((val) << (shift) | (mask) << ((shift) + 16))
> +
> +struct rockchip_grf_value {
> + const char *desc;
> + u32 reg;
> + u32 val;
> +};
> +
> +struct rockchip_grf_info {
> + const struct rockchip_grf_value *values;
> + int num_values;
> +};
> +
> +#define RK3036_GRF_SOC_CON0 0x140
> +
> +static const struct rockchip_grf_value rk3036_defaults[] = {
> + /*
> + * Disable auto jtag/sdmmc switching that causes issues with the
> + * clock-framework and the mmc controllers making them unreliable.
> + */
> + { "jtag switching", RK3036_GRF_SOC_CON0, HIWORD_UPDATE(0, 1, 11) },
> +};
> +
> +static const struct rockchip_grf_info rk3036_grf = {
> + .values = rk3036_defaults,
> + .num_values = ARRAY_SIZE(rk3036_defaults),
> +};
> +
> +#define RK3288_GRF_SOC_CON0 0x244
> +
> +static const struct rockchip_grf_value rk3288_defaults[] = {
> + { "jtag switching", RK3288_GRF_SOC_CON0, HIWORD_UPDATE(0, 1, 12) },
> +};
> +
> +static const struct rockchip_grf_info rk3288_grf = {
> + .values = rk3288_defaults,
> + .num_values = ARRAY_SIZE(rk3288_defaults),
> +};
> +
> +#define RK3399_GRF_SOC_CON7 0xe21c
> +
> +static const struct rockchip_grf_value rk3399_defaults[] = {
> + { "jtag switching", RK3399_GRF_SOC_CON7, HIWORD_UPDATE(0, 1, 12) },
> +
> +};
> +
> +static const struct rockchip_grf_info rk3399_grf = {
> + .values = rk3399_defaults,
> + .num_values = ARRAY_SIZE(rk3399_defaults),
> +};
> +
> +static const struct of_device_id rockchip_grf_dt_match[] = {
> + {
> + .compatible = "rockchip,rk3036-grf",
> + .data = (void *)&rk3036_grf,
> + }, {
> + .compatible = "rockchip,rk3288-grf",
> + .data = (void *)&rk3288_grf,
> + }, {
> + .compatible = "rockchip,rk3399-grf",
> + .data = (void *)&rk3399_grf,
> + },
> + { /* sentinel */ },
> +};
> +
> +static int rockchip_grf_probe(struct platform_device *pdev)
> +{
> + const struct rockchip_grf_info *grf_info;
> + const struct of_device_id *match;
> + struct device *dev = &pdev->dev;
> + struct regmap *grf;
> + int i;
> +
> + if (!dev->of_node)
> + return -ENODEV;
> +
> + match = of_match_device(rockchip_grf_dt_match, dev);
> + if (!match || !match->data) {
> + dev_err(dev, "missing grf data\n");
> + return -EINVAL;
> + }
> +
> + grf_info = match->data;
> +
> + grf = syscon_node_to_regmap(dev->of_node);
> + if (IS_ERR(grf)) {
> + dev_err(dev, "rockchip: could not get grf syscon\n");
> + return PTR_ERR(grf);
> + }
> +
> + for (i = 0; i < grf_info->num_values; i++) {
> + const struct rockchip_grf_value *val = &grf_info->values[i];
> +
> + dev_dbg(dev, "adjusting %s in 0x%x to 0x%x\n",
> + val->desc, val->reg, val->val);
> + regmap_write(grf, val->reg, val->val);
> + }
> +
> + return 0;
> +}
> +
> +static struct platform_driver rockchip_grf_driver = {
> + .probe = rockchip_grf_probe,
> + .driver = {
> + .name = "rockchip-grf",
> + .of_match_table = rockchip_grf_dt_match,
> + /*
> + * The General Register Files are a central component
> + * accessed by numerous ip blocks and we're setting
> + * defaults which should only happen once.
> + */
> + .suppress_bind_attrs = true,
> + },
> +};
> +
> +static int __init rockchip_grf_drv_register(void)
> +{
> + return platform_driver_register(&rockchip_grf_driver);
> +}
> +postcore_initcall(rockchip_grf_drv_register);
>
--
Best Regards
Shawn Lin
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] soc: rockchip: add driver handling grf setup
[not found] ` <6a6e87ee-688d-90a3-2407-22847bd80971-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
@ 2016-05-24 13:07 ` Heiko Stuebner
0 siblings, 0 replies; 12+ messages in thread
From: Heiko Stuebner @ 2016-05-24 13:07 UTC (permalink / raw)
To: Shawn Lin
Cc: linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
dianders-F7+t8E8rja9g9hUCZPvPmw, olof-nZhT3qVonbNeoWH0uzbU5w,
arnd-r2nGTMty4D4, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
devicetree-u79uwXL29TY76Z2rM5mHXA, wxt-TNX95d0MmH7DzftRWevZcw
Am Dienstag, 24. Mai 2016, 10:22:09 schrieb Shawn Lin:
> Hi Heiko,
>
> On 2016/5/23 22:58, Heiko Stuebner wrote:
> > The General Register Files are an area of registers containing a lot
> > of single-bit settings for numerous components as well full components
> > like usbphy control. Therefore all used components are accessed
> > via the syscon provided by the grf nodes or from the sub-devices
> > created through the simple-mfd created from the grf node.
> >
> > Some settings are not used by anything but will need to be set up
> > according to expectations on the kernel side.
> >
> > Best example is the force_jtag setting, which defaults to on and
> > results in the soc switching the pin-outputs between jtag and sdmmc
> > automatically depending on the card-detect status. This conflicts
> > heavily with how the dw_mmc driver expects to do its work and also
> > with the clock-controller, which has most likely deactivated the
> > jtag clock due to it being unused.
>
> I agree we should disable force_jtag for real product. But on my local
> branch we add a callback to parse a tag from cmdline. Sometime it's
> useful for debugging in case of we need to setup JTAG for reproducing
> and comfirming serious issue in which state the CPU cannot reponse to
> any console input or FIQ-debug triggering.
>
> Should we need it for upstream as you move all related code in this
> new driver? I'm not sure.
This driver really _should not_ become a catchall for settings stuff.
I.e. the jtag/sdmmc switch handles the automatic switching done inside the
soc based on the card-detect state. Which confuses the dw_mmc driver.
If I'm reading that correctly in the TRM, jtag on Rockchip SoCs is part of
the coresight infrastructure - in the DAP block.
There are generic drivers + devicetree bindings for (I think most) coresight
blocks existing now, but I haven't found anything related to the DAP itself.
In theory I'd think real handling of jtag pins/clocks should be done
somewhere in that area and and if jtag is to be used,it could then be set up
using in-kernel mechanics, like disabling sdmmc that claims the shared pins
and enabling the jtag pinctrl and clocks.
This could even be doable at runtime via devicetree overlays.
Most likely way out of scope for now, but that is where I would imagine this
stuff to be.
Heiko
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2016-05-24 13:07 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-23 14:58 [PATCH 0/3] Rockchip: generalize GRF setup Heiko Stuebner
[not found] ` <1464015539-19521-1-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2016-05-23 14:58 ` [PATCH 1/3] dt-bindings: add used but undocumented rockchip grf compatible values Heiko Stuebner
[not found] ` <1464015539-19521-2-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2016-05-23 20:47 ` Doug Anderson
2016-05-23 21:38 ` Rob Herring
2016-05-24 2:05 ` Shawn Lin
2016-05-23 14:58 ` [PATCH 2/3] soc: rockchip: add driver handling grf setup Heiko Stuebner
[not found] ` <1464015539-19521-3-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2016-05-23 20:46 ` Doug Anderson
2016-05-24 2:22 ` Shawn Lin
[not found] ` <6a6e87ee-688d-90a3-2407-22847bd80971-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2016-05-24 13:07 ` Heiko Stuebner
2016-05-23 14:58 ` [PATCH 3/3] ARM: rockchip: drop rk3288 jtag/mmc switch handling Heiko Stuebner
[not found] ` <1464015539-19521-4-git-send-email-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2016-05-23 20:47 ` Doug Anderson
2016-05-24 2:09 ` Shawn Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox