Skip to contentSkip to conversation

Fix eSDHC host version register bug

PATCH Superseded Yangbo Lu 7 participants 40 messages May 5, 2016 – Apr 3, 2017

Subsystems (18)

v10 of 16 Superseded Latest is v16 →

lore
Share & tools
lore

Yangbo Lu

author
#0 lore raw

v10 cover Fix eSDHC host version register bug

This patchset is used to fix a host version register bug in the T4240-R1.0-R2.0 eSDHC controller. To get the SoC version and revision, it's needed to add the GUTS driver to access the global utilities registers.

So, the first four patches are to add the GUTS driver.
The following patches except the updating MAINTAINERS patch are to enable GUTS driver support to get SVR in eSDHC driver and fix host version for T4240.

Yangbo Lu (7):
Documentation: DT: update Freescale DCFG compatible
ARM64: dts: ls2080a: add device configuration node
soc: fsl: add GUTS driver for QorIQ platforms
dt: move guts devicetree doc out of powerpc directory powerpc/fsl: move mpc85xx.h to include/linux/fsl
MAINTAINERS: add entry for Freescale SoC drivers
mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0

 Documentation/devicetree/bindings/arm/fsl.txt      |   6 +-
 .../bindings/{powerpc => soc}/fsl/guts.txt         |   3 +
 MAINTAINERS                                        |  11 +-
 arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi     |   6 +
 arch/powerpc/kernel/cpu_setup_fsl_booke.S          |   2 +-
 drivers/clk/clk-qoriq.c                            |   3 +-
 drivers/i2c/busses/i2c-mpc.c                       |   2 +-
 drivers/iommu/fsl_pamu.c                           |   3 +-
 drivers/mmc/host/Kconfig                           |   1 +
 drivers/mmc/host/sdhci-of-esdhc.c                  |  23 ++++
 drivers/net/ethernet/freescale/gianfar.c           |   2 +-
 drivers/soc/Kconfig                                |   2 +-
 drivers/soc/fsl/Kconfig                            |   8 ++
 drivers/soc/fsl/Makefile                           |   1 +
 drivers/soc/fsl/guts.c                             | 119 +++++++++++++++++++
 include/linux/fsl/guts.h                           | 126 +++++++++++++--------
 .../asm/mpc85xx.h => include/linux/fsl/svr.h       |   4 +-
 17 files changed, 262 insertions(+), 60 deletions(-)
 rename Documentation/devicetree/bindings/{powerpc => soc}/fsl/guts.txt (91%)
 create mode 100644 drivers/soc/fsl/Kconfig
 create mode 100644 drivers/soc/fsl/guts.c
 rename arch/powerpc/include/asm/mpc85xx.h => include/linux/fsl/svr.h (97%)
Signature · 1 line
2.1.0.27.g96db324
author
#1 lore raw

PATCH v10 1/7 Documentation: DT: update Freescale DCFG compatible

Update Freescale DCFG compatible with 'fsl,<chip>-dcfg' instead of 'fsl,ls1021a-dcfg' to include more chips such as ls1021a, ls1043a, and ls2080a.

---
Changes for v8:
- Added this patch
Changes for v9:
- Added a list for the possible compatibles
Changes for v10:
- None

---
 Documentation/devicetree/bindings/arm/fsl.txt | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/arm/fsl.txt +5 -1
index 752a685..465cba1 100644
@@ -119,7 +119,11 @@ Freescale DCFG
 configuration and status for the device. Such as setting the secondary
 core start address and release the secondary core from holdoff and startup.
   Required properties:
-  - compatible: should be "fsl,ls1021a-dcfg"
+  - compatible: should be "fsl,<chip>-dcfg"
+    Possible compatibles:
+	"fsl,ls1021a-dcfg"
+	"fsl,ls1043a-dcfg"
+	"fsl,ls2080a-dcfg"
   - reg : should contain base address and length of DCFG memory-mapped registers
 
 Example:
Signature · 1 line
2.1.0.27.g96db324
maintainer Acked-by on v10 1/7
#2 lore raw

Re: [v10, 1/7] Documentation: DT: update Freescale DCFG compatible

Quoted 12 lines · Yangbo Lu

Update Freescale DCFG compatible with 'fsl,<chip>-dcfg' instead of 'fsl,ls1021a-dcfg' to include more chips such as ls1021a, ls1043a, and ls2080a.

---
Changes for v8:
- Added this patch
Changes for v9:
- Added a list for the possible compatibles
Changes for v10:
- None

Quoted 3 lines
---
 Documentation/devicetree/bindings/arm/fsl.txt | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
author
#3 lore raw

PATCH v10 2/7 ARM64: dts: ls2080a: add device configuration node

In reply to Yangbo Lu

Add the dts node for device configuration unit that provides general purpose configuration and status for the device.

---
Changes for v5:
- Added this patch
Changes for v6:
- None
Changes for v7:
- None
Changes for v8:
- Added 'Acked-by: Scott Wood'
Changes for v9:
- None
Changes for v10:
- None

---
 arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi +6 -0
index 9d746c6..8724cf1 100644
@@ -191,6 +191,12 @@
 			clocks = <&sysclk>;
 		};
 
+		dcfg: dcfg at 1e00000 {
+			compatible = "fsl,ls2080a-dcfg", "syscon";
+			reg = <0x0 0x1e00000 0x0 0x10000>;
+			little-endian;
+		};
+
 		serial0: serial at 21c0500 {
 			compatible = "fsl,ns16550", "ns16550a";
 			reg = <0x0 0x21c0500 0x0 0x100>;
Signature · 1 line
2.1.0.27.g96db324
author
#4 lore raw

PATCH v10 3/7 soc: fsl: add GUTS driver for QorIQ platforms

In reply to Yangbo Lu

The global utilities block controls power management, I/O device enabling, power-onreset(POR) configuration monitoring, alternate function selection for multiplexed signals,and clock control.

This patch adds GUTS driver to manage and access global utilities block.

---
Changes for v4:
- Added this patch
Changes for v5:
- Modified copyright info
- Changed MODULE_LICENSE to GPL
- Changed EXPORT_SYMBOL_GPL to EXPORT_SYMBOL
- Made FSL_GUTS user-invisible
- Added a complete compatible list for GUTS
- Stored guts info in file-scope variable
- Added mfspr() getting SVR
- Redefined GUTS APIs
- Called fsl_guts_init rather than using platform driver
- Removed useless parentheses
- Removed useless 'extern' key words
Changes for v6:
- Made guts thread safe in fsl_guts_init
Changes for v7:
- Removed 'ifdef' for function declaration in guts.h
Changes for v8:
- Fixes lines longer than 80 characters checkpatch issue
- Added 'Acked-by: Scott Wood'
Changes for v9:
- None
Changes for v10:
- None

---
 drivers/soc/Kconfig      |   2 +-
 drivers/soc/fsl/Kconfig  |   8 +++
 drivers/soc/fsl/Makefile |   1 +
 drivers/soc/fsl/guts.c   | 119 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/fsl/guts.h | 126 +++++++++++++++++++++++++++++------------------
 5 files changed, 207 insertions(+), 49 deletions(-)
 create mode 100644 drivers/soc/fsl/Kconfig
 create mode 100644 drivers/soc/fsl/guts.c
drivers/soc/Kconfig +1 -1
index cb58ef0..7106463 100644
@@ -2,7 +2,7 @@ menu "SOC (System On Chip) specific Drivers"
 
 source "drivers/soc/bcm/Kconfig"
 source "drivers/soc/brcmstb/Kconfig"
-source "drivers/soc/fsl/qe/Kconfig"
+source "drivers/soc/fsl/Kconfig"
 source "drivers/soc/mediatek/Kconfig"
 source "drivers/soc/qcom/Kconfig"
 source "drivers/soc/rockchip/Kconfig"
drivers/soc/fsl/Kconfig new file +8 -0
new file mode 100644
index 0000000..b313759
@@ -0,0 +1,8 @@
+#
+# Freescale SOC drivers
+#
+
+source "drivers/soc/fsl/qe/Kconfig"
+
+config FSL_GUTS
+	bool
drivers/soc/fsl/Makefile +1 -0
index 203307f..02afb7f 100644
@@ -4,3 +4,4 @@
 
 obj-$(CONFIG_QUICC_ENGINE)		+= qe/
 obj-$(CONFIG_CPM)			+= qe/
+obj-$(CONFIG_FSL_GUTS)			+= guts.o
drivers/soc/fsl/guts.c new file +119 -0

119 lines not on this page · raw message

include/linux/fsl/guts.h +78 -48

161 lines not on this page · raw message

Signature · 1 line
2.1.0.27.g96db324
#5 lore raw

Re: [v10, 3/7] soc: fsl: add GUTS driver for QorIQ platforms

Quoted 90 lines · Yangbo Lu

The global utilities block controls power management, I/O device enabling, power-onreset(POR) configuration monitoring, alternate function selection for multiplexed signals,and clock control.

This patch adds GUTS driver to manage and access global utilities block.

---
Changes for v4:
- Added this patch
Changes for v5:
- Modified copyright info
- Changed MODULE_LICENSE to GPL
- Changed EXPORT_SYMBOL_GPL to EXPORT_SYMBOL
- Made FSL_GUTS user-invisible
- Added a complete compatible list for GUTS
- Stored guts info in file-scope variable
- Added mfspr() getting SVR
- Redefined GUTS APIs
- Called fsl_guts_init rather than using platform driver
- Removed useless parentheses
- Removed useless 'extern' key words
Changes for v6:
- Made guts thread safe in fsl_guts_init
Changes for v7:
- Removed 'ifdef' for function declaration in guts.h
Changes for v8:
- Fixes lines longer than 80 characters checkpatch issue
- Added 'Acked-by: Scott Wood'
Changes for v9:
- None
Changes for v10:
- None

---
 drivers/soc/Kconfig      |   2 +-
 drivers/soc/fsl/Kconfig  |   8 +++
 drivers/soc/fsl/Makefile |   1 +
 drivers/soc/fsl/guts.c   | 119 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/fsl/guts.h | 126 +++++++++++++++++++++++++++++------------------
 5 files changed, 207 insertions(+), 49 deletions(-)
 create mode 100644 drivers/soc/fsl/Kconfig
 create mode 100644 drivers/soc/fsl/guts.c
drivers/soc/Kconfig +1 -1
index cb58ef0..7106463 100644
@@ -2,7 +2,7 @@ menu "SOC (System On Chip) specific Drivers"
 
 source "drivers/soc/bcm/Kconfig"
 source "drivers/soc/brcmstb/Kconfig"
-source "drivers/soc/fsl/qe/Kconfig"
+source "drivers/soc/fsl/Kconfig"
 source "drivers/soc/mediatek/Kconfig"
 source "drivers/soc/qcom/Kconfig"
 source "drivers/soc/rockchip/Kconfig"
drivers/soc/fsl/Kconfig new file +8 -0
new file mode 100644
index 0000000..b313759
@@ -0,0 +1,8 @@
+#
+# Freescale SOC drivers
+#
+
+source "drivers/soc/fsl/qe/Kconfig"
+
+config FSL_GUTS
+       bool
drivers/soc/fsl/Makefile +1 -0
index 203307f..02afb7f 100644
@@ -4,3 +4,4 @@
 
 obj-$(CONFIG_QUICC_ENGINE)             += qe/
 obj-$(CONFIG_CPM)                      += qe/
+obj-$(CONFIG_FSL_GUTS)                 += guts.o
drivers/soc/fsl/guts.c new file +3 -0
new file mode 100644
index 0000000..fa155e6
@@ -0,0 +1,119 @@
+/*
+ * Freescale QorIQ Platforms GUTS Driver
+ *

drivers/soc/fsl/guts.c line 13

Quoted 10 lines
drivers/soc/fsl/guts.c new file +10 -0
+ * Copyright (C) 2016 Freescale Semiconductor, Inc.
+ *
+ * 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.
+ */
+
+#include <linux/io.h>
+#include <linux/module.h>

Seems there was lots of discussion on this. If it does end up being resent, it would be nice to get the module.h and other modular stuff gone since it is a bool Kconfig.

Thanks,
Paul.
--

Quoted 7 lines
drivers/soc/fsl/guts.c new file +6 -0
+#include <linux/slab.h>
+#include <linux/mutex.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
+#include <linux/fsl/guts.h>
+
maintainer
#6 lore raw

Re: [v10, 3/7] soc: fsl: add GUTS driver for QorIQ platforms

Quoted 99 lines · Paul Gortmaker
Quoted 98 lines · Yangbo Lu

The global utilities block controls power management, I/O device enabling, power-onreset(POR) configuration monitoring, alternate function selection for multiplexed signals,and clock control.

This patch adds GUTS driver to manage and access global utilities block.

---
Changes for v4:
????????- Added this patch
Changes for v5:
????????- Modified copyright info
????????- Changed MODULE_LICENSE to GPL
????????- Changed EXPORT_SYMBOL_GPL to EXPORT_SYMBOL ????????- Made FSL_GUTS user-invisible
????????- Added a complete compatible list for GUTS ????????- Stored guts info in file-scope variable ????????- Added mfspr() getting SVR
????????- Redefined GUTS APIs
????????- Called fsl_guts_init rather than using platform driver ????????- Removed useless parentheses
????????- Removed useless 'extern' key words
Changes for v6:
????????- Made guts thread safe in fsl_guts_init Changes for v7:
????????- Removed 'ifdef' for function declaration in guts.h Changes for v8:
????????- Fixes lines longer than 80 characters checkpatch issue ????????- Added 'Acked-by: Scott Wood'
Changes for v9:
????????- None
Changes for v10:
????????- None
---

?drivers/soc/Kconfig??????|???2 +-
?drivers/soc/fsl/Kconfig??|???8 +++
?drivers/soc/fsl/Makefile |???1 +
?drivers/soc/fsl/guts.c???| 119

++++++++++++++++++++++++++++++++++++++++++++
?include/linux/fsl/guts.h | 126 +++++++++++++++++++++++++++++-------------
-----
?5 files changed, 207 insertions(+), 49 deletions(-)
?create mode 100644 drivers/soc/fsl/Kconfig
?create mode 100644 drivers/soc/fsl/guts.c

drivers/soc/Kconfig +0 -0
index cb58ef0..7106463 100644
@@ -2,7 +2,7 @@ menu "SOC (System On Chip) specific Drivers"
 

?source "drivers/soc/bcm/Kconfig"
?source "drivers/soc/brcmstb/Kconfig"

drivers/soc/Kconfig +1 -1
-source "drivers/soc/fsl/qe/Kconfig"
+source "drivers/soc/fsl/Kconfig"

?source "drivers/soc/mediatek/Kconfig"
?source "drivers/soc/qcom/Kconfig"
?source "drivers/soc/rockchip/Kconfig"

drivers/soc/fsl/Kconfig new file +8 -0
new file mode 100644
index 0000000..b313759
@@ -0,0 +1,8 @@
+#
+# Freescale SOC drivers
+#
+
+source "drivers/soc/fsl/qe/Kconfig"
+
+config FSL_GUTS
+???????bool
drivers/soc/fsl/Makefile +0 -0
index 203307f..02afb7f 100644
@@ -4,3 +4,4 @@
 

?obj-$(CONFIG_QUICC_ENGINE)?????????????+= qe/
?obj-$(CONFIG_CPM)??????????????????????+= qe/

drivers/soc/fsl/Makefile +1 -0
+obj-$(CONFIG_FSL_GUTS)?????????????????+= guts.o
drivers/soc/fsl/guts.c new file +8 -0
new file mode 100644
index 0000000..fa155e6
@@ -0,0 +1,119 @@
+/*
+ * Freescale QorIQ Platforms GUTS Driver
+ *
+ * Copyright (C) 2016 Freescale Semiconductor, Inc.
+ *
+ * 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
Quoted 8 lines

drivers/soc/fsl/guts.c line 13

Quoted 5 lines
drivers/soc/fsl/guts.c new file +5 -0
+ * (at your option) any later version.
+ */
+
+#include <linux/io.h>
+#include <linux/module.h>

Seems there was lots of discussion on this.??If it does end up being resent, it would be nice to get the module.h and other modular stuff gone since it is a bool Kconfig.

I plan to resend just the GUTS driver portion and send it through the PPC tree.

I don't see any modular stuff in there besides the linux/module.h include.

-Scott

#7 lore raw

Re: [v10, 3/7] soc: fsl: add GUTS driver for QorIQ platforms

Quoted 2 lines · [Re: [v10, 3/7] soc: fsl: add GUTS driver for QorIQ platforms] On 15/07/2016…
Quoted 1 line · Paul Gortmaker
Quoted 1 line

+source "drivers/soc/fsl/qe/Kconfig"

[...]

Quoted 35 lines
Quoted 26 lines
Quoted 26 lines
drivers/soc/fsl/Kconfig new file +3 -0
+
+config FSL_GUTS
+???????bool
drivers/soc/fsl/Makefile +0 -0
index 203307f..02afb7f 100644
@@ -4,3 +4,4 @@
 

?obj-$(CONFIG_QUICC_ENGINE)?????????????+= qe/
?obj-$(CONFIG_CPM)??????????????????????+= qe/

drivers/soc/fsl/Makefile +1 -0
+obj-$(CONFIG_FSL_GUTS)?????????????????+= guts.o
drivers/soc/fsl/guts.c new file +8 -0
new file mode 100644
index 0000000..fa155e6
@@ -0,0 +1,119 @@
+/*
+ * Freescale QorIQ Platforms GUTS Driver
+ *
+ * Copyright (C) 2016 Freescale Semiconductor, Inc.
+ *
+ * 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
Quoted 8 lines

drivers/soc/fsl/guts.c line 13

Quoted 5 lines
drivers/soc/fsl/guts.c new file +5 -0
+ * (at your option) any later version.
+ */
+
+#include <linux/io.h>
+#include <linux/module.h>

Seems there was lots of discussion on this.??If it does end up being resent, it would be nice to get the module.h and other modular stuff gone since it is a bool Kconfig.

Quoted 4 lines

I plan to resend just the GUTS driver portion and send it through the PPC tree.

I don't see any modular stuff in there besides the linux/module.h include.

Great. Normally I'm seeing the MODULE_DEVICE_TABLE and MODULE_AUTHOR and MODULE_LICENSE etc, so it has (unfortunately) become a knee jerk reaction to assume the latter follows a module.h presence... thanks for removing the extraneous include.

Paul.
--

Quoted 4 lines

-Scott

author
#8 lore raw

PATCH v10 4/7 dt: move guts devicetree doc out of powerpc directory

In reply to Yangbo Lu

Move guts devicetree doc to Documentation/devicetree/bindings/soc/fsl/ since it's used by not only PowerPC but also ARM. And add a specification for 'little-endian' property.

---
Changes for v4:
- Added this patch
Changes for v5:
- Modified the description for little-endian property
Changes for v6:
- None
Changes for v7:
- None
Changes for v8:
- Added 'Acked-by: Scott Wood'
- Added 'Acked-by: Rob Herring'
Changes for v9:
- None
Changes for v10:
- None

---
 Documentation/devicetree/bindings/{powerpc => soc}/fsl/guts.txt | 3 +++
 1 file changed, 3 insertions(+)
 rename Documentation/devicetree/bindings/{powerpc => soc}/fsl/guts.txt (91%)
Documentation/devicetree/bindings/soc/fsl/guts.txt renamed from Documentation/devicetree/bindings/powerpc/fsl/guts.txt +3 -0
similarity index 91%
rename from Documentation/devicetree/bindings/powerpc/fsl/guts.txt
rename to Documentation/devicetree/bindings/soc/fsl/guts.txt
index b71b203..07adca9 100644
@@ -25,6 +25,9 @@ Recommended properties:
  - fsl,liodn-bits : Indicates the number of defined bits in the LIODN
    registers, for those SOCs that have a PAMU device.
 
+ - little-endian : Indicates that the global utilities block is little
+   endian. The default is big endian.
+
 Examples:
 	global-utilities at e0000 {	/* global utilities block */
 		compatible = "fsl,mpc8548-guts";
Signature · 1 line
2.1.0.27.g96db324
author
#9 lore raw

PATCH v10 5/7 powerpc/fsl: move mpc85xx.h to include/linux/fsl

In reply to Yangbo Lu

Move mpc85xx.h to include/linux/fsl and rename it to svr.h as a common header file. It has been used for mpc85xx and it will be used for ARM-based SoC as well.

---
Changes for v2:
- None
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- Changed to Move mpc85xx.h to include/linux/fsl/
- Adjusted '#include <linux/fsl/svr.h>' position in file
Changes for v6:
- None
Changes for v7:
- Added 'Acked-by: Wolfram Sang' for I2C part
- Also applied to arch/powerpc/kernel/cpu_setup_fsl_booke.S
Changes for v8:
- Added 'Acked-by: Stephen Boyd' for clk part
- Added 'Acked-by: Scott Wood'
- Added 'Acked-by: Joerg Roedel' for iommu part
Changes for v9:
- None
Changes for v10:
- None

---
 arch/powerpc/kernel/cpu_setup_fsl_booke.S                     | 2 +-
 drivers/clk/clk-qoriq.c                                       | 3 +--
 drivers/i2c/busses/i2c-mpc.c                                  | 2 +-
 drivers/iommu/fsl_pamu.c                                      | 3 +--
 drivers/net/ethernet/freescale/gianfar.c                      | 2 +-
 arch/powerpc/include/asm/mpc85xx.h => include/linux/fsl/svr.h | 4 ++--
 6 files changed, 7 insertions(+), 9 deletions(-)
 rename arch/powerpc/include/asm/mpc85xx.h => include/linux/fsl/svr.h (97%)
arch/powerpc/kernel/cpu_setup_fsl_booke.S +1 -1
index 462aed9..2b0284e 100644
@@ -13,13 +13,13 @@
  *
  */
 
+#include <linux/fsl/svr.h>
 #include <asm/page.h>
 #include <asm/processor.h>
 #include <asm/cputable.h>
 #include <asm/ppc_asm.h>
 #include <asm/mmu-book3e.h>
 #include <asm/asm-offsets.h>
-#include <asm/mpc85xx.h>
 
 _GLOBAL(__e500_icache_setup)
 	mfspr	r0, SPRN_L1CSR1
drivers/clk/clk-qoriq.c +1 -2
index 7bc1c45..fc7f722 100644
@@ -13,6 +13,7 @@
 #include <linux/clk.h>
 #include <linux/clk-provider.h>
 #include <linux/fsl/guts.h>
+#include <linux/fsl/svr.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -1148,8 +1149,6 @@ bad_args:
 }
 
 #ifdef CONFIG_PPC
-#include <asm/mpc85xx.h>
-
 static const u32 a4510_svrs[] __initconst = {
 	(SVR_P2040 << 8) | 0x10,	/* P2040 1.0 */
 	(SVR_P2040 << 8) | 0x11,	/* P2040 1.1 */
drivers/i2c/busses/i2c-mpc.c +1 -1
index 48ecffe..600704c 100644
@@ -27,9 +27,9 @@
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
+#include <linux/fsl/svr.h>
 
 #include <asm/mpc52xx.h>
-#include <asm/mpc85xx.h>
 #include <sysdev/fsl_soc.h>
 
 #define DRV_NAME "mpc-i2c"
drivers/iommu/fsl_pamu.c +1 -2
index a34355f..af8fb27 100644
@@ -21,11 +21,10 @@
 #include "fsl_pamu.h"
 
 #include <linux/fsl/guts.h>
+#include <linux/fsl/svr.h>
 #include <linux/interrupt.h>
 #include <linux/genalloc.h>
 
-#include <asm/mpc85xx.h>
-
 /* define indexes for each operation mapping scenario */
 #define OMI_QMAN        0x00
 #define OMI_FMAN        0x01
drivers/net/ethernet/freescale/gianfar.c +1 -1
index d2f917a..2224b10 100644
@@ -86,11 +86,11 @@
 #include <linux/udp.h>
 #include <linux/in.h>
 #include <linux/net_tstamp.h>
+#include <linux/fsl/svr.h>
 
 #include <asm/io.h>
 #ifdef CONFIG_PPC
 #include <asm/reg.h>
-#include <asm/mpc85xx.h>
 #endif
 #include <asm/irq.h>
 #include <asm/uaccess.h>
include/linux/fsl/svr.h renamed from arch/powerpc/include/asm/mpc85xx.h +2 -2
similarity index 97%
rename from arch/powerpc/include/asm/mpc85xx.h
rename to include/linux/fsl/svr.h
index 213f3a8..8d13836 100644
@@ -9,8 +9,8 @@
  * (at your option) any later version.
  */
 
-#ifndef __ASM_PPC_MPC85XX_H
-#define __ASM_PPC_MPC85XX_H
+#ifndef FSL_SVR_H
+#define FSL_SVR_H
 
 #define SVR_REV(svr)	((svr) & 0xFF)		/* SOC design resision */
 #define SVR_MAJ(svr)	(((svr) >>  4) & 0xF)	/* Major revision field*/
Signature · 1 line
2.1.0.27.g96db324
author
#10 lore raw

PATCH v10 6/7 MAINTAINERS: add entry for Freescale SoC drivers

In reply to Yangbo Lu

Add maintainer entry for Freescale SoC drivers including the QE library and the GUTS driver now. Also add maintainer for QE library.

---
Changes for v8:
- Added this patch
Changes for v9:
- Added linux-arm mail list
- Removed GUTS driver entry
Changes for v10:
- Changed 'DRIVER' to 'DRIVERS'
- Added 'Acked-by' of Scott and Qiang

---
 MAINTAINERS | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
MAINTAINERS +10 -1
index 42e65d1..85c4b8b 100644
@@ -4622,9 +4622,18 @@ F:	drivers/net/ethernet/freescale/fec_ptp.c
 F:	drivers/net/ethernet/freescale/fec.h
 F:	Documentation/devicetree/bindings/net/fsl-fec.txt
 
+FREESCALE SOC DRIVERS
+M:	Scott Wood <[email protected]>
+L:	linuxppc-dev at lists.ozlabs.org
+L:	linux-arm-kernel at lists.infradead.org
+S:	Maintained
+F:	drivers/soc/fsl/
+F:	include/linux/fsl/
+
 FREESCALE QUICC ENGINE LIBRARY
+M:	Qiang Zhao <[email protected]>
 L:	linuxppc-dev at lists.ozlabs.org
-S:	Orphan
+S:	Maintained
 F:	drivers/soc/fsl/qe/
 F:	include/soc/fsl/*qe*.h
 F:	include/soc/fsl/*ucc*.h
Signature · 1 line
2.1.0.27.g96db324
author
#11 lore raw

PATCH v10 7/7 mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0

In reply to Yangbo Lu

The eSDHC of T4240-R1.0-R2.0 has incorrect vender version and spec version. Acturally the right version numbers should be VVN=0x13 and SVN = 0x1. This patch adds the GUTS driver support for eSDHC driver to get SVR(System version register). And fix host version to avoid that incorrect version numbers break down the ADMA data transfer.

---
Changes for v2:
- Got SVR through iomap instead of dts
Changes for v3:
- Managed GUTS through syscon instead of iomap in eSDHC driver
Changes for v4:
- Got SVR by GUTS driver instead of SYSCON
Changes for v5:
- Changed to get SVR through API fsl_guts_get_svr()
- Combined patch 4, patch 5 and patch 6 into one
Changes for v6:
- Added 'Acked-by: Ulf Hansson'
Changes for v7:
- None
Changes for v8:
- Added 'Acked-by: Scott Wood'
Changes for v9:
- None
Changes for v10:
- None

---
 drivers/mmc/host/Kconfig          |  1 +
 drivers/mmc/host/sdhci-of-esdhc.c | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+)
drivers/mmc/host/Kconfig +1 -0
index 0aa484c..e15e836 100644
@@ -143,6 +143,7 @@ config MMC_SDHCI_OF_ESDHC
 	depends on MMC_SDHCI_PLTFM
 	depends on PPC || ARCH_MXC || ARCH_LAYERSCAPE
 	select MMC_SDHCI_IO_ACCESSORS
+	select FSL_GUTS
 	help
 	  This selects the Freescale eSDHC controller support.
 
drivers/mmc/host/sdhci-of-esdhc.c +23 -0
index 3f34d35..68cc020 100644
@@ -18,6 +18,8 @@
 #include <linux/of.h>
 #include <linux/delay.h>
 #include <linux/module.h>
+#include <linux/fsl/svr.h>
+#include <linux/fsl/guts.h>
 #include <linux/mmc/host.h>
 #include "sdhci-pltfm.h"
 #include "sdhci-esdhc.h"
@@ -28,6 +30,8 @@
 struct sdhci_esdhc {
 	u8 vendor_ver;
 	u8 spec_ver;
+	u32 soc_ver;
+	u8 soc_rev;
 };
 
 /**
@@ -73,6 +77,8 @@ static u32 esdhc_readl_fixup(struct sdhci_host *host,
 static u16 esdhc_readw_fixup(struct sdhci_host *host,
 				     int spec_reg, u32 value)
 {
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host);
 	u16 ret;
 	int shift = (spec_reg & 0x2) * 8;
 
@@ -80,6 +86,13 @@ static u16 esdhc_readw_fixup(struct sdhci_host *host,
 		ret = value & 0xffff;
 	else
 		ret = (value >> shift) & 0xffff;
+
+	/* Workaround for T4240-R1.0-R2.0 eSDHC which has incorrect
+	 * vendor version and spec version information.
+	 */
+	if ((spec_reg == SDHCI_HOST_VERSION) &&
+	    (esdhc->soc_ver == SVR_T4240) && (esdhc->soc_rev <= 0x20))
+		ret = (VENDOR_V_23 << SDHCI_VENDOR_VER_SHIFT) | SDHCI_SPEC_200;
 	return ret;
 }
 
@@ -567,10 +580,20 @@ static void esdhc_init(struct platform_device *pdev, struct sdhci_host *host)
 	struct sdhci_pltfm_host *pltfm_host;
 	struct sdhci_esdhc *esdhc;
 	u16 host_ver;
+	u32 svr;
 
 	pltfm_host = sdhci_priv(host);
 	esdhc = sdhci_pltfm_priv(pltfm_host);
 
+	fsl_guts_init();
+	svr = fsl_guts_get_svr();
+	if (svr) {
+		esdhc->soc_ver = SVR_SOC_VER(svr);
+		esdhc->soc_rev = SVR_REV(svr);
+	} else {
+		dev_err(&pdev->dev, "Failed to get SVR value!\n");
+	}
+
 	host_ver = sdhci_readw(host, SDHCI_HOST_VERSION);
 	esdhc->vendor_ver = (host_ver & SDHCI_VENDOR_VER_MASK) >>
 			     SDHCI_VENDOR_VER_SHIFT;
Signature · 1 line
2.1.0.27.g96db324
#12 lore raw

Re: [v10, 7/7] mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0

drivers/mmc/host/sdhci-of-esdhc.c static void esdhc_init(struct platform_device *pdev, struct sdhci_host *host) · line 596

Quoted 11 lines · On Thursday 05 May 2016 11:12:30 Yangbo Lu wrote:
drivers/mmc/host/sdhci-of-esdhc.c +9 -0
+       fsl_guts_init();
+       svr = fsl_guts_get_svr();
+       if (svr) {
+               esdhc->soc_ver = SVR_SOC_VER(svr);
+               esdhc->soc_rev = SVR_REV(svr);
+       } else {
+               dev_err(&pdev->dev, "Failed to get SVR value!\n");
+       }
+

Sorry for jumping in again after not participating in the discussion for the past few versions.

What happened to my suggestion of making this a platform-independent interface to avoid the link time dependency?

Specifically, why not add an exported function to drivers/base/soc.c that uses glob_match() for comparing a string in the device driver to the ID of the SoC that is set by whatever SoC identifying driver the platform has?

Arnd

author
#13 lore raw

RE: [v10, 7/7] mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0

Hi Arnd,

Quoted 34 lines

-----Original Message-----
From: Arnd Bergmann [mailto:arnd at arndb.de]
Sent: Thursday, May 05, 2016 4:32 PM
To: linuxppc-dev at lists.ozlabs.org
Cc: Yangbo Lu; linux-mmc at vger.kernel.org; devicetree at vger.kernel.org; linux-arm-kernel at lists.infradead.org; linux-kernel at vger.kernel.org; linux-clk at vger.kernel.org; linux-i2c at vger.kernel.org; iommu at lists.linux- foundation.org; netdev at vger.kernel.org; Mark Rutland;
ulf.hansson at linaro.org; Russell King; Bhupesh Sharma; Joerg Roedel; Santosh Shilimkar; Yang-Leo Li; Scott Wood; Rob Herring; Claudiu Manoil; Kumar Gala; Xiaobo Xie; Qiang Zhao
Subject: Re: [v10, 7/7] mmc: sdhci-of-esdhc: fix host version for T4240- R1.0-R2.0

drivers/mmc/host/sdhci-of-esdhc.c static void esdhc_init(struct platform_device *pdev, struct sdhci_host *host) · line 596

Quoted 11 lines · On Thursday 05 May 2016 11:12:30 Yangbo Lu wrote:
drivers/mmc/host/sdhci-of-esdhc.c +9 -0
+       fsl_guts_init();
+       svr = fsl_guts_get_svr();
+       if (svr) {
+               esdhc->soc_ver = SVR_SOC_VER(svr);
+               esdhc->soc_rev = SVR_REV(svr);
+       } else {
+               dev_err(&pdev->dev, "Failed to get SVR value!\n");
+       }
+

Sorry for jumping in again after not participating in the discussion for the past few versions.

What happened to my suggestion of making this a platform-independent interface to avoid the link time dependency?

Quoted 6 lines

Specifically, why not add an exported function to drivers/base/soc.c that uses glob_match() for comparing a string in the device driver to the ID of the SoC that is set by whatever SoC identifying driver the platform has?

Arnd

[Lu Yangbo-B47093] I think this has been discussed in v6. You can find Scott's comments about this in below link.
https://patchwork.kernel.org/patch/8544501/

Thanks.

#14 lore raw

Re: [v10, 7/7] mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0

Quoted 34 lines · On Thursday 05 May 2016 09:41:32 Yangbo Lu wrote:
Quoted 34 lines

-----Original Message-----
From: Arnd Bergmann [mailto:arnd at arndb.de]
Sent: Thursday, May 05, 2016 4:32 PM
To: linuxppc-dev at lists.ozlabs.org
Cc: Yangbo Lu; linux-mmc at vger.kernel.org; devicetree at vger.kernel.org; linux-arm-kernel at lists.infradead.org; linux-kernel at vger.kernel.org; linux-clk at vger.kernel.org; linux-i2c at vger.kernel.org; iommu at lists.linux- foundation.org; netdev at vger.kernel.org; Mark Rutland;
ulf.hansson at linaro.org; Russell King; Bhupesh Sharma; Joerg Roedel; Santosh Shilimkar; Yang-Leo Li; Scott Wood; Rob Herring; Claudiu Manoil; Kumar Gala; Xiaobo Xie; Qiang Zhao
Subject: Re: [v10, 7/7] mmc: sdhci-of-esdhc: fix host version for T4240- R1.0-R2.0

drivers/mmc/host/sdhci-of-esdhc.c static void esdhc_init(struct platform_device *pdev, struct sdhci_host *host) · line 596

Quoted 11 lines · On Thursday 05 May 2016 11:12:30 Yangbo Lu wrote:
drivers/mmc/host/sdhci-of-esdhc.c +9 -0
+       fsl_guts_init();
+       svr = fsl_guts_get_svr();
+       if (svr) {
+               esdhc->soc_ver = SVR_SOC_VER(svr);
+               esdhc->soc_rev = SVR_REV(svr);
+       } else {
+               dev_err(&pdev->dev, "Failed to get SVR value!\n");
+       }
+

Sorry for jumping in again after not participating in the discussion for the past few versions.

What happened to my suggestion of making this a platform-independent interface to avoid the link time dependency?

Quoted 8 lines
Quoted 4 lines

Specifically, why not add an exported function to drivers/base/soc.c that uses glob_match() for comparing a string in the device driver to the ID of the SoC that is set by whatever SoC identifying driver the platform has?

[Lu Yangbo-B47093] I think this has been discussed in v6. You can find Scott's comments about this in below link.
https://patchwork.kernel.org/patch/8544501/

Ah, thanks for bearing with me and digging this out again. Let me follow up on Scott's older replies here then:

Quoted 10 lines
Quoted 3 lines
Quoted 3 lines

IIRC, it is the same IP block as i.MX and Arnd's point is this won't even compile on !PPC. It is things like this that prevent sharing the driver.

The whole point of using the MMIO SVR instead of the PPC SPR is so that it will work on ARM... The guts driver should build on any platform as long as OF is enabled, and if it doesn't find a node to bind to it will return 0 for SVR, and the eSDHC driver will continue (after printing an error that should be removed) without the ability to test for errata based on SVR.

It feels like a bad design to have to come up with a different method for each SoC type here when they all do the same thing and want to identify some variant of the chip to do device specific quirks.

As far as I'm concerned, every driver in drivers/soc that needs to export a symbol to be used by a device driver is an indication that we don't have the right set of abstractions yet. There are cases that are not worth abstracting because the functionality is rather obscure and only a couple of drivers for one particular chip ever need it.

Finding out the version of the SoC does not look like this case.

Quoted 5 lines
Quoted 3 lines

I think the first four patches take care of building for ARM, but the problem remains if you want to enable COMPILE_TEST as we need for certain automated checking.

What specific problem is there with COMPILE_TEST?

COMPILE_TEST is solvable here and the way it is implemented in this case (selecting FSL_GUTS from the driver) indeed looks like it works correctly, but it's still awkward that this means building the SoC specific ID stuff into the vmlinux binary for any driver that uses something like that for a particular SoC.

Quoted 11 lines
Quoted 7 lines
Quoted 2 lines

Dealing with Si revs is a common problem. We should have a common solution. There is soc_device for this purpose.

Exactly. The last time this came up, I think we agreed to implement a helper using glob_match() on the soc_device strings. Unfortunately this hasn't happened then, but I'd still prefer that over yet another vendor-specific way of dealing with the generic issue.

soc_device would require encoding the SVR as a string and then decoding the string, which is more complicated and error prone than having platform-specific code test a platform-specific number.

You already need to encode it as a string to register the soc_device, and the driver just needs to pass a glob string, so the only part that is missing is the generic function that takes the string from the driver and passes that to glob_match for the soc_device.

Quoted 2 lines

And when would it get registered on arm64, which doesn't have platform code?

Whenever the soc driver is loaded, as is the case now. The match function can return -EPROBE_DEFER if no SoC device is registered yet.

Arnd

maintainer
#15 lore raw

Re: [v10, 7/7] mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0

Quoted 32 lines · Arnd Bergmann
Quoted 19 lines · On Thursday 05 May 2016 09:41:32 Yangbo Lu wrote:
Quoted 14 lines

-----Original Message-----
From: Arnd Bergmann [mailto:arnd at arndb.de]
Sent: Thursday, May 05, 2016 4:32 PM
To: linuxppc-dev at lists.ozlabs.org
Cc: Yangbo Lu; linux-mmc at vger.kernel.org; devicetree at vger.kernel.org; linux-arm-kernel at lists.infradead.org; linux-kernel at vger.kernel.org; linux-clk at vger.kernel.org; linux-i2c at vger.kernel.org; iommu at lists.linux- foundation.org; netdev at vger.kernel.org; Mark Rutland;
ulf.hansson at linaro.org; Russell King; Bhupesh Sharma; Joerg Roedel; Santosh Shilimkar; Yang-Leo Li; Scott Wood; Rob Herring; Claudiu Manoil; Kumar Gala; Xiaobo Xie; Qiang Zhao
Subject: Re: [v10, 7/7] mmc: sdhci-of-esdhc: fix host version for T4240- R1.0-R2.0

Quoted 4 lines
Quoted 3 lines · On Thursday 05 May 2016 11:12:30 Yangbo Lu wrote:

IIRC, it is the same IP block as i.MX and Arnd's point is this won't even compile on !PPC. It is things like this that prevent sharing the driver.

Quoted 6 lines

The whole point of using the MMIO SVR instead of the PPC SPR is so that it will work on ARM... The guts driver should build on any platform as long as OF is enabled, and if it doesn't find a node to bind to it will return 0 for SVR, and the eSDHC driver will continue (after printing an error that should be removed) without the ability to test for errata based on SVR.

It feels like a bad design to have to come up with a different method for each SoC type here when they all do the same thing and want to identify some variant of the chip to do device specific quirks.

Quoted 8 lines

As far as I'm concerned, every driver in drivers/soc that needs to export a symbol to be used by a device driver is an indication that we don't have the right set of abstractions yet. There are cases that are not worth abstracting because the functionality is rather obscure and only a couple of drivers for one particular chip ever need it.

Finding out the version of the SoC does not look like this case.

I'm open to new ways of abstracting this, but can that please be discussed after these patches are merged? This patchset is fixing a problem, the existing abstraction is unappealing and not widely adopted, a new abstraction is not ready, and we're only touching code for our hardware.

Oh, and the existing abstraction isn't even "existing". I don't see any examples where soc_device is being used like this -- or even any way for a driver (the one consuming the information, not the soc "driver") to get a reference to the soc_device that's been registered short of searching for the device object by name -- and you're asking for new functionality in drivers/base/soc.c.

Quoted 11 lines
Quoted 5 lines
Quoted 3 lines

I think the first four patches take care of building for ARM, but the problem remains if you want to enable COMPILE_TEST as we need for certain automated checking.

What specific problem is there with COMPILE_TEST?

COMPILE_TEST is solvable here and the way it is implemented in this case (selecting FSL_GUTS from the driver) indeed looks like it works correctly, but it's still awkward that this means building the SoC specific ID stuff into the vmlinux binary for any driver that uses something like that for a particular SoC.

Please keep in mind that this is a Freescale-specific driver... it's not as if we're attaching this dependency to common SDHCI code.

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines

Dealing with Si revs is a common problem. We should have a common solution. There is soc_device for this purpose.

Exactly. The last time this came up, I think we agreed to implement a helper using glob_match() on the soc_device strings. Unfortunately this hasn't happened then, but I'd still prefer that over yet another vendor-specific way of dealing with the generic issue.

Quoted 5 lines
Quoted 3 lines

soc_device would require encoding the SVR as a string and then decoding the string, which is more complicated and error prone than having platform-specific code test a platform-specific number.

You already need to encode it as a string to register the soc_device,

No we don't, because we don't already register a soc_device on arm64 or ppc (and it looks like whatever does get registered on at least some relevant arm32 chips is not particularly useful).

Quoted 3 lines

and the driver just needs to pass a glob string, so the only part that is missing is the generic function that takes the string from the driver and passes that to glob_match for the soc_device.

"just"

And what would the glob look like?

I'd rather not write kernel code as if it were a shell/Perl script.

Quoted 6 lines
Quoted 2 lines

And when would it get registered on arm64, which doesn't have platform code?

Whenever the soc driver is loaded, as is the case now. The match function can return -EPROBE_DEFER if no SoC device is registered yet.

That's too late for some places where we need access to SVR, e.g. clock drivers (which use CLK_OF_DECLARE and are initialized very early, not as part of the driver model and thus can't defer). Currently we have an #ifdef CONFIG_PPC for this in drivers/clk/clk-qoriq.c... Maybe we should have done that here as well, and saved some grief. :-) At least until an erratum pops up on an ARM-based chip.

And what happens if we're running on arm32, and thus the arch code already registered an soc_device with a different (and less useful) encoding?

-Scott

author
#16 lore raw

RE: [v10, 7/7] mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0

Hi Arnd,

Any comments?
Please reply when you see the email since we want this eSDHC issue to be fixed soon.

All the patches are Freescale-specific and is to fix the eSDHC driver.
Could we let them merged first if you were talking about a new way of abstracting getting SoC version.

Thanks :)

Best regards,
Yangbo Lu

Quoted 133 lines

-----Original Message-----
From: Scott Wood [mailto:oss at buserror.net]
Sent: Wednesday, May 11, 2016 11:26 AM
To: Arnd Bergmann; linux-arm-kernel at lists.infradead.org
Cc: Yangbo Lu; linuxppc-dev at lists.ozlabs.org; Mark Rutland; devicetree at vger.kernel.org; ulf.hansson at linaro.org; Russell King; Bhupesh Sharma; netdev at vger.kernel.org; Joerg Roedel; Kumar Gala; linux- mmc at vger.kernel.org; linux-kernel at vger.kernel.org; Yang-Leo Li; iommu at lists.linux-foundation.org; Rob Herring; linux-i2c at vger.kernel.org; Claudiu Manoil; Santosh Shilimkar; Xiaobo Xie; linux-clk at vger.kernel.org; Qiang Zhao
Subject: Re: [v10, 7/7] mmc: sdhci-of-esdhc: fix host version for T4240- R1.0-R2.0

Quoted 33 lines · Arnd Bergmann
Quoted 21 lines · On Thursday 05 May 2016 09:41:32 Yangbo Lu wrote:
Quoted 16 lines

-----Original Message-----
From: Arnd Bergmann [mailto:arnd at arndb.de]
Sent: Thursday, May 05, 2016 4:32 PM
To: linuxppc-dev at lists.ozlabs.org
Cc: Yangbo Lu; linux-mmc at vger.kernel.org;
devicetree at vger.kernel.org; linux-arm-kernel at lists.infradead.org; linux-kernel at vger.kernel.org; linux-clk at vger.kernel.org; linux-i2c at vger.kernel.org; iommu at lists.linux- foundation.org; netdev at vger.kernel.org; Mark Rutland; ulf.hansson at linaro.org; Russell King; Bhupesh Sharma; Joerg Roedel; Santosh Shilimkar; Yang-Leo Li; Scott Wood; Rob Herring; Claudiu Manoil; Kumar Gala; Xiaobo Xie; Qiang Zhao
Subject: Re: [v10, 7/7] mmc: sdhci-of-esdhc: fix host version for T4240-
R1.0-R2.0

Quoted 4 lines
Quoted 3 lines · On Thursday 05 May 2016 11:12:30 Yangbo Lu wrote:

IIRC, it is the same IP block as i.MX and Arnd's point is this won't even compile on !PPC. It is things like this that prevent sharing the driver.

Quoted 6 lines

The whole point of using the MMIO SVR instead of the PPC SPR is so that it will work on ARM... The guts driver should build on any platform as long as OF is enabled, and if it doesn't find a node to bind to it will return 0 for SVR, and the eSDHC driver will continue (after printing an error that should be removed) without the ability to test for errata based on SVR.

It feels like a bad design to have to come up with a different method for each SoC type here when they all do the same thing and want to identify some variant of the chip to do device specific quirks.

Quoted 7 lines

As far as I'm concerned, every driver in drivers/soc that needs to export a symbol to be used by a device driver is an indication that we don't have the right set of abstractions yet. There are cases that are not worth abstracting because the functionality is rather obscure and only a couple of drivers for one particular chip ever need it.

Finding out the version of the SoC does not look like this case.

I'm open to new ways of abstracting this, but can that please be discussed after these patches are merged? This patchset is fixing a problem, the existing abstraction is unappealing and not widely adopted, a new abstraction is not ready, and we're only touching code for our hardware.

Oh, and the existing abstraction isn't even "existing". I don't see any examples where soc_device is being used like this -- or even any way for a driver (the one consuming the information, not the soc "driver") to get a reference to the soc_device that's been registered short of searching for the device object by name -- and you're asking for new functionality in drivers/base/soc.c.

Quoted 11 lines
Quoted 5 lines
Quoted 3 lines

I think the first four patches take care of building for ARM, but the problem remains if you want to enable COMPILE_TEST as we need for certain automated checking.

What specific problem is there with COMPILE_TEST?

COMPILE_TEST is solvable here and the way it is implemented in this case (selecting FSL_GUTS from the driver) indeed looks like it works correctly, but it's still awkward that this means building the SoC specific ID stuff into the vmlinux binary for any driver that uses something like that for a particular SoC.

Please keep in mind that this is a Freescale-specific driver... it's not as if we're attaching this dependency to common SDHCI code.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

Dealing with Si revs is a common problem. We should have a common solution. There is soc_device for this purpose.

Exactly. The last time this came up, I think we agreed to implement a helper using glob_match() on the soc_device strings. Unfortunately this hasn't happened then, but I'd still prefer that over yet another vendor-specific way of dealing with the generic

issue.

Quoted 6 lines
Quoted 4 lines

soc_device would require encoding the SVR as a string and then decoding the string, which is more complicated and error prone than having platform-specific code test a platform-specific number.

You already need to encode it as a string to register the soc_device,

No we don't, because we don't already register a soc_device on arm64 or ppc (and it looks like whatever does get registered on at least some relevant
arm32 chips is not particularly useful).

Quoted 3 lines

and the driver just needs to pass a glob string, so the only part that is missing is the generic function that takes the string from the driver and passes that to glob_match for the soc_device.

"just"

And what would the glob look like?

I'd rather not write kernel code as if it were a shell/Perl script.

Quoted 5 lines
Quoted 2 lines

And when would it get registered on arm64, which doesn't have platform code?

Whenever the soc driver is loaded, as is the case now. The match function can return -EPROBE_DEFER if no SoC device is registered yet.

That's too late for some places where we need access to SVR, e.g. clock drivers (which use CLK_OF_DECLARE and are initialized very early, not as part of the driver model and thus can't defer). Currently we have an #ifdef CONFIG_PPC for this in drivers/clk/clk-qoriq.c... Maybe we should have done that here as well, and saved some grief. :-) At least until an erratum pops up on an ARM-based chip.

And what happens if we're running on arm32, and thus the arch code already registered an soc_device with a different (and less useful) encoding?

-Scott

author
#17 lore raw

RE: [v10, 7/7] mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0

In reply to Scott Wood

Hi Uffe,

Could we merge this patchset? ...
It has been a long time to wait for Arnd's response...

Thanks a lot.

Best regards,
Yangbo Lu

Quoted 31 lines

-----Original Message-----
From: Yangbo Lu
Sent: Friday, May 20, 2016 2:06 PM
To: 'Scott Wood'; Arnd Bergmann; linux-arm-kernel at lists.infradead.org
Cc: linuxppc-dev at lists.ozlabs.org; Mark Rutland;
devicetree at vger.kernel.org; ulf.hansson at linaro.org; Russell King; Bhupesh Sharma; netdev at vger.kernel.org; Joerg Roedel; Kumar Gala; linux- mmc at vger.kernel.org; linux-kernel at vger.kernel.org; Yang-Leo Li; iommu at lists.linux-foundation.org; Rob Herring; linux-i2c at vger.kernel.org; Claudiu Manoil; Santosh Shilimkar; Xiaobo Xie; linux-clk at vger.kernel.org; Qiang Zhao
Subject: RE: [v10, 7/7] mmc: sdhci-of-esdhc: fix host version for T4240- R1.0-R2.0

Hi Arnd,

Any comments?
Please reply when you see the email since we want this eSDHC issue to be fixed soon.

All the patches are Freescale-specific and is to fix the eSDHC driver. Could we let them merged first if you were talking about a new way of abstracting getting SoC version.

Thanks :)

Best regards,
Yangbo Lu

#18 lore raw

Re: [v10, 7/7] mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0

Quoted 8 lines · Yangbo Lu

Hi Uffe,

Could we merge this patchset? ...
It has been a long time to wait for Arnd's response...

Thanks a lot.

As we are still in the merge window I won't queue anything but fixes. Let's give Arnd another week or so to respond.

Kind regards
Uffe

Quoted 36 lines

Best regards,
Yangbo Lu

Quoted 31 lines

-----Original Message-----
From: Yangbo Lu
Sent: Friday, May 20, 2016 2:06 PM
To: 'Scott Wood'; Arnd Bergmann; linux-arm-kernel at lists.infradead.org
Cc: linuxppc-dev at lists.ozlabs.org; Mark Rutland;
devicetree at vger.kernel.org; ulf.hansson at linaro.org; Russell King; Bhupesh Sharma; netdev at vger.kernel.org; Joerg Roedel; Kumar Gala; linux- mmc at vger.kernel.org; linux-kernel at vger.kernel.org; Yang-Leo Li; iommu at lists.linux-foundation.org; Rob Herring; linux-i2c at vger.kernel.org; Claudiu Manoil; Santosh Shilimkar; Xiaobo Xie; linux-clk at vger.kernel.org; Qiang Zhao
Subject: RE: [v10, 7/7] mmc: sdhci-of-esdhc: fix host version for T4240- R1.0-R2.0

Hi Arnd,

Any comments?
Please reply when you see the email since we want this eSDHC issue to be fixed soon.

All the patches are Freescale-specific and is to fix the eSDHC driver. Could we let them merged first if you were talking about a new way of abstracting getting SoC version.

Thanks :)

Best regards,
Yangbo Lu

#19 lore raw

Re: [v10, 7/7] mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0

Quoted 6 lines · CEST Ulf Hansson
Quoted 5 lines · Yangbo Lu

Hi Uffe,

Could we merge this patchset? ...
It has been a long time to wait for Arnd's response...

Quoted 6 lines
Quoted 3 lines

Thanks a lot.

As we are still in the merge window I won't queue anything but fixes. Let's give Arnd another week or so to respond.

I've got a patch series now that implements a method for matching the soc ID, see the following emails.

Arnd

#20 lore raw

PATCH 1/4 base: soc: introduce soc_device_match() interface

In reply to Ulf Hansson

We keep running into cases where device drivers want to know the exact version of the SoC a they are currently running on. In the past, this has usually been done through a vendor specific API that can be called by a driver, or by directly accessing some kind of version register that is not part of the device itself but that belongs to a global register area of the chip.

Common reasons for doing this include:

- A machine is not using devicetree or similar for passing data about on-chip devices, but just announces their presence using boot-time platform devices, and the machine code itself does not care about the revision.

- There is existing firmware or boot loaders with existing DT binaries with generic compatible strings that do not identify the particular revision of each device, but the driver knows which SoC revisions include which part

- A prerelease version of a chip has some quirks and we are using the same version of the bootloader and the DT blob on both the prerelease and the final version. An update of the DT binding seems inappropriate because that would involve maintaining multiple copies of the dts and/or bootloader.

This introduces the soc_device_match() interface that is meant to work like of_match_node() but instead of identifying the version of a device, it identifies the SoC itself using a vendor-agnostic interface.

Unlike soc_device_match(), we do not do an exact string compare but instead use glob_match() to allow wildcards in strings.

drivers/base/Kconfig +1 -0
index 246acdafedb6..fc7613cc7fd5 100644
@@ -225,6 +225,7 @@ config GENERIC_CPU_AUTOPROBE
 
 config SOC_BUS
 	bool
+	select GLOB
 
 source "drivers/base/regmap/Kconfig"
 
drivers/base/soc.c +58 -0

67 lines not on this page · raw message

include/linux/sys_soc.h +4 -0
index 2739ccb69571..02c48c76052b 100644
@@ -13,6 +13,8 @@ struct soc_device_attribute {
 	const char *family;
 	const char *revision;
 	const char *soc_id;
+
+	const void *data;
 };
 
 /**
@@ -34,4 +36,6 @@ void soc_device_unregister(struct soc_device *soc_dev);
  */
 struct device *soc_device_to_device(struct soc_device *soc);
 
+struct soc_device_attribute *soc_device_match(struct soc_device_attribute *matches);
+
 #endif /* __SOC_BUS_H */
#21 lore raw

Re: [PATCH 1/4] base: soc: introduce soc_device_match() interface

Quoted 25 lines · CEST Arnd Bergmann

We keep running into cases where device drivers want to know the exact version of the SoC a they are currently running on. In the past, this has usually been done through a vendor specific API that can be called by a driver, or by directly accessing some kind of version register that is not part of the device itself but that belongs to a global register area of the chip.

Common reasons for doing this include:

- A machine is not using devicetree or similar for passing data about on-chip devices, but just announces their presence using boot-time platform devices, and the machine code itself does not care about the revision.

- There is existing firmware or boot loaders with existing DT binaries with generic compatible strings that do not identify the particular revision of each device, but the driver knows which SoC revisions include which part

- A prerelease version of a chip has some quirks and we are using the same version of the bootloader and the DT blob on both the prerelease and the final version. An update of the DT binding seems inappropriate because that would involve maintaining multiple copies of the dts and/or bootloader.

Quoted 7 lines

This introduces the soc_device_match() interface that is meant to work like of_match_node() but instead of identifying the version of a device, it identifies the SoC itself using a vendor-agnostic interface.

Unlike soc_device_match(), we do not do an exact string compare but instead use glob_match() to allow wildcards in strings.

I'm sorry the series introduced build failures (I had done some changes after testing), here is a quick fixup. I'll resend the whole thing after someone has looked at it as none of the changes below should have any influence on the review.

Arnd

drivers/base/soc.c +3 -3
index e9623c6674a5..c38573249777 100644
@@ -173,7 +173,7 @@ module_exit(soc_bus_unregister);
 static int soc_device_match_one(struct device *dev, void *arg)
 {
 	struct soc_device *soc_dev = container_of(dev, struct soc_device, dev);
-	struct soc_device_attribute *match = arg;
+	const struct soc_device_attribute *match = arg;
 
 	if (match->machine && !glob_match(match->machine, soc_dev->attr->machine))
 		return 0;
@@ -208,7 +208,7 @@ static int soc_device_match_one(struct device *dev, void *arg)
  * soc_device_attribute to pass a structure or function pointer for
  * each entry.
  */
-struct soc_device_attribute *soc_device_match(struct soc_device_attribute *matches)
+const struct soc_device_attribute *soc_device_match(const struct soc_device_attribute *matches)
 {
 	struct device *dev;
 	int ret;
@@ -219,7 +219,7 @@ struct soc_device_attribute *soc_device_match(struct soc_device_attribute *match
 			return NULL;
 
 		dev = NULL;
-		ret = bus_for_each_dev(&soc_bus_type, dev, matches,
+		ret = bus_for_each_dev(&soc_bus_type, dev, (void *)matches,
 					 soc_device_match_one);
 	}
 
drivers/mmc/host/sdhci-of-esdhc.c +6 -4
index 1d4814fe4cb2..a7b8b05a13e8 100644
@@ -19,6 +19,8 @@
 #include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/mmc/host.h>
+#include <linux/sys_soc.h>
+
 #include "sdhci-pltfm.h"
 #include "sdhci-esdhc.h"
 
@@ -75,7 +77,6 @@ static u16 esdhc_readw_fixup(struct sdhci_host *host,
 {
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 	struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host);
-	u16 ret;
 	int shift = (spec_reg & 0x2) * 8;
 
 	if (spec_reg == SDHCI_HOST_VERSION)
@@ -565,7 +566,7 @@ static const struct sdhci_pltfm_data sdhci_esdhc_le_pdata = {
 };
 
 #define T4240_HOST_VER ((VENDOR_V_23 << SDHCI_VENDOR_VER_SHIFT) | SDHCI_SPEC_200)
-static const struct soc_device_attribute esdhc_t4240_quirk = {
+static const struct soc_device_attribute esdhc_t4240_quirk[] = {
 	/* T4240 revision < 0x20 uses vendor version 23, SDHCI version 200 */
 	{ .soc_id = "T4*(0x824000)", .revision = "0x[01]?",
 	  .data = (void *)(uintptr_t)(T4240_HOST_VER) },
@@ -576,6 +577,7 @@ static void esdhc_init(struct platform_device *pdev, struct sdhci_host *host)
 {
 	struct sdhci_pltfm_host *pltfm_host;
 	struct sdhci_esdhc *esdhc;
+	u32 host_ver;
 
 	pltfm_host = sdhci_priv(host);
 	esdhc = sdhci_pltfm_priv(pltfm_host);
@@ -583,9 +585,9 @@ static void esdhc_init(struct platform_device *pdev, struct sdhci_host *host)
 	host_ver = sdhci_readw(host, SDHCI_HOST_VERSION);
 
 	if (of_device_is_compatible(pdev->dev.of_node, "fsl,t4240-esdhc")) {
-		struct soc_device_attribute *match;
+		const struct soc_device_attribute *match;
 
-		match = soc_device_match(&esdhc_t4240_quirk);
+		match = soc_device_match(esdhc_t4240_quirk);
 		if (match)
 			host_ver = (uintptr_t)match->data;
 	}
drivers/soc/fsl/guts.c +5 -11
index 2f30698f5bcf..476969644bed 100644
@@ -34,14 +34,6 @@ static u32 fsl_guts_get_svr(struct guts *guts)
 		return ioread32be(guts->regs + GUTS_SVR);
 }
 
-static u32 fsl_guts_get_pvr(struct guts *guts)
-{
-	if (guts->little_endian)
-		return ioread32(guts->regs + GUTS_PVR);
-	else
-		return ioread32be(guts->regs + GUTS_PVR);
-}
-
 /*
  * Table for matching compatible strings, for device tree
  * guts node, for Freescale QorIQ SOCs.
@@ -76,13 +68,15 @@ static const struct of_device_id fsl_guts_of_match[] = {
 
 static void fsl_guts_init(struct device *dev, struct guts *guts)
 {
-	const struct of_device_id *id;
 	u32 svr = fsl_guts_get_svr(guts);
+	const struct of_device_id *id;
+	const char *socname;
 
 	guts->soc.family = "NXP QorIQ";
 	id = of_match_node(fsl_guts_of_match, dev->of_node);
-	guts->soc.soc_id = devm_kasprintf(dev, "%s (ver 0x%06x)" id->data,
-					  svr >> 8;
+	socname = id->data;
+	guts->soc.soc_id = devm_kasprintf(dev, GFP_KERNEL, "%s (ver 0x%06x)",
+					  socname, svr >> 8);
 	guts->soc.revision = devm_kasprintf(dev, GFP_KERNEL, "0x%02x",
 					    svr & 0xff);
 }
include/linux/sys_soc.h +1 -1
index 02c48c76052b..3dfc8714a88c 100644
@@ -36,6 +36,6 @@ void soc_device_unregister(struct soc_device *soc_dev);
  */
 struct device *soc_device_to_device(struct soc_device *soc);
 
-struct soc_device_attribute *soc_device_match(struct soc_device_attribute *matches);
+const struct soc_device_attribute *soc_device_match(const struct soc_device_attribute *matches);
 
 #endif /* __SOC_BUS_H */
#22 lore raw

PATCH 2/4 soc: fsl: add GUTS driver for QorIQ platforms

In reply to Ulf Hansson

From: Yangbo Lu <[email protected]>

The global utilities block controls power management, I/O device enabling, power-onreset(POR) configuration monitoring, alternate function selection for multiplexed signals,and clock control.

This patch adds GUTS driver to manage and access global utilities block.

[arnd turned this into a platform_driver registering a soc_device
rather than providing an ad-hoc interface for soc-id]

drivers/soc/Kconfig +1 -1
index cb58ef0d9b2c..7106463f118e 100644
@@ -2,7 +2,7 @@ menu "SOC (System On Chip) specific Drivers"
 
 source "drivers/soc/bcm/Kconfig"
 source "drivers/soc/brcmstb/Kconfig"
-source "drivers/soc/fsl/qe/Kconfig"
+source "drivers/soc/fsl/Kconfig"
 source "drivers/soc/mediatek/Kconfig"
 source "drivers/soc/qcom/Kconfig"
 source "drivers/soc/rockchip/Kconfig"
drivers/soc/fsl/Kconfig new file +15 -0
new file mode 100644
index 000000000000..33d331cac8d6
@@ -0,0 +1,15 @@
+#
+# Freescale SOC drivers
+#
+
+source "drivers/soc/fsl/qe/Kconfig"
+
+config FSL_GUTS
+	bool "NXP Layerscale SoC identification"
+	depends on PPC_FSL || SOC_LS1021A || ARCH_LAYERSCAPE || COMPILE_TEST
+	default PPC_FSL || SOC_LS1021A || ARCH_LAYERSCAPE
+	select SOC_BUS
+	help
+	  This registers a SoC device for NXP (formerly Freescale)
+	  Layerscape devices, making information about the system
+	  available in /sys/devices/soc/
drivers/soc/fsl/Makefile +1 -0
index 203307fd92c1..02afb7f980f6 100644
@@ -4,3 +4,4 @@
 
 obj-$(CONFIG_QUICC_ENGINE)		+= qe/
 obj-$(CONFIG_CPM)			+= qe/
+obj-$(CONFIG_FSL_GUTS)			+= guts.o
drivers/soc/fsl/guts.c new file +130 -0

130 lines not on this page · raw message

maintainer
#23 lore raw

Re: [PATCH 2/4] soc: fsl: add GUTS driver for QorIQ platforms

Quoted 20 lines · Arnd Bergmann
drivers/soc/fsl/guts.c new file +14 -0
new file mode 100644
index 000000000000..2f30698f5bcf
@@ -0,0 +1,130 @@
+/*
+ * Freescale QorIQ Platforms GUTS Driver
+ *
+ * Copyright (C) 2016 Freescale Semiconductor, Inc.
+ *
+ * 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.
+ */
+
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/module.h>

drivers/soc/fsl/guts.c line 24

Quoted 10 lines
drivers/soc/fsl/guts.c new file +10 -0
+#include <linux/slab.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
+#include <linux/sys_soc.h>
+
+#define GUTS_PVR	0x0a0
+#define GUTS_SVR	0x0a4
+
+struct guts {
+	void __iomem *regs;

We already have a struct to define guts. Why are you not using it? Why do you consider using it to be "abuse"? What if we want to move more guts functionality into this driver?

Quoted 9 lines
drivers/soc/fsl/guts.c new file +9 -0
+	bool little_endian;
+	struct soc_device_attribute soc;
+};
+
+static u32 fsl_guts_get_svr(struct guts *guts)
+{
+	if (guts->little_endian)
+		return ioread32(guts->regs + GUTS_SVR);
+	else

drivers/soc/fsl/guts.c line 43

Quoted 10 lines
drivers/soc/fsl/guts.c new file +10 -0
+		return ioread32be(guts->regs + GUTS_SVR);
+}
+
+static u32 fsl_guts_get_pvr(struct guts *guts)
+{
+	if (guts->little_endian)
+		return ioread32(guts->regs + GUTS_PVR);
+	else
+		return ioread32be(guts->regs + GUTS_PVR);
+}

You've removed the fallback to mfspr() on PPC, which would be helpful in some virtualized environments where we don't have the guts node (but do have other directly assigned devices). Of course, this is a consequence of the conversion into a platform device.

Quoted 9 lines
drivers/soc/fsl/guts.c new file +8 -0
+
+/*
+ * Table for matching compatible strings, for device tree
+ * guts node, for Freescale QorIQ SOCs.
+ */
+static const struct of_device_id fsl_guts_of_match[] = {
+	/* For T4 & B4 Series SOCs */
+	{ .compatible = "fsl,qoriq-device-config-1.0", .data = "T4/B4

series" },

[snip]

drivers/soc/fsl/guts.c

Quoted 1 line
drivers/soc/fsl/guts.c new file +1 -0
+	{ .compatible = "fsl,qoriq-device-config-2.0", .data = "P series"

As noted in my comment on patch 3/4, these descriptions are reversed.

They're also incomplete. t2080 has device config 2.0. t1040 is described as 2.0 though it should probably be 2.1 (or better, drop the generic compatible altogether).

drivers/soc/fsl/guts.c line 110

Quoted 9 lines
drivers/soc/fsl/guts.c new file +3 -0
+	/*
+	 * syscon devices default to little-endian, but on powerpc we have
+	 * existing device trees with big-endian maps and an absent

endianess

drivers/soc/fsl/guts.c new file +5 -0
+	 * "big-property"
+	 */
+	if (!IS_ENABLED(CONFIG_POWERPC) &&
+	    !of_property_read_bool(dev->of_node, "big-endian"))
+		guts->little_endian = true;

This is not a syscon device (Yangbo's patch to add a guts node on ls2080 is the only guts node that says "syscon", and that was a leftover from earlier revisions and should probably be removed). Even if it were, where is it documented that syscon defaults to little-endian?

Documentation/devicetree/bindings/common-properties.txt says that the individual binding specifies the default. The default for this node should be big-endian because that's what existed before there was a need to describe the endianness. And we need an update to the guts binding to specify that.

Quoted 10 lines
drivers/soc/fsl/guts.c new file +10 -0
+
+	guts->regs = devm_ioremap_resource(dev, 0);
+	if (!guts->regs) {
+		ret = -ENOMEM;
+		kfree(guts);
+		goto out;
+	}
+
+	fsl_guts_init(dev, guts);
+	ret = 0;

drivers/soc/fsl/guts.c line 130

Quoted 10 lines
drivers/soc/fsl/guts.c new file +10 -0
+out:
+	return ret;
+}
+
+static struct platform_driver fsl_soc_guts = {
+	.probe = fsl_guts_probe,
+	.driver.of_match_table = fsl_guts_of_match,
+};
+
+module_platform_driver(fsl_soc_guts);

Again, this means that the information is not available during early boot, such as in the clock driver. Thus we would not be able to convert clk-qoriq's direct mfspr(SPRN_SVR) into an soc_device_match() (or anything else that makes use of this file), nor would we be able to move its access of the guts RCW registers into this driver.

-Scott

#24 lore raw

Re: [PATCH 2/4] soc: fsl: add GUTS driver for QorIQ platforms

Quoted 27 lines · CEST Scott Wood
Quoted 26 lines · Arnd Bergmann
drivers/soc/fsl/guts.c new file +20 -0
new file mode 100644
index 000000000000..2f30698f5bcf
@@ -0,0 +1,130 @@
+/*
+ * Freescale QorIQ Platforms GUTS Driver
+ *
+ * Copyright (C) 2016 Freescale Semiconductor, Inc.
+ *
+ * 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.
+ */
+
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
+#include <linux/sys_soc.h>
+
+#define GUTS_PVR	0x0a0
Quoted 8 lines

drivers/soc/fsl/guts.c line 24

Quoted 4 lines
drivers/soc/fsl/guts.c new file +4 -0
+#define GUTS_SVR	0x0a4
+
+struct guts {
+	void __iomem *regs;

We already have a struct to define guts. Why are you not using it? Why do you consider using it to be "abuse"? What if we want to move more guts functionality into this driver?

This structure was in the original patch, I left it in there, only removed the inclusion of the powerpc header file, which seemed to be misplaced.

Quoted 16 lines
Quoted 16 lines
drivers/soc/fsl/guts.c new file +16 -0
+	bool little_endian;
+	struct soc_device_attribute soc;
+};
+
+static u32 fsl_guts_get_svr(struct guts *guts)
+{
+	if (guts->little_endian)
+		return ioread32(guts->regs + GUTS_SVR);
+	else
+		return ioread32be(guts->regs + GUTS_SVR);
+}
+
+static u32 fsl_guts_get_pvr(struct guts *guts)
+{
+	if (guts->little_endian)
+		return ioread32(guts->regs + GUTS_PVR);
Quoted 8 lines

drivers/soc/fsl/guts.c line 43

Quoted 3 lines
drivers/soc/fsl/guts.c new file +3 -0
+	else
+		return ioread32be(guts->regs + GUTS_PVR);
+}

You've removed the fallback to mfspr() on PPC, which would be helpful in some virtualized environments where we don't have the guts node (but do have other directly assigned devices). Of course, this is a consequence of the conversion into a platform device.

Right, it just didn't make any sense after the conversion. I couldn't figure out what the intention was for the fallback. Virtualized environments are an interesting case, but I'd also argue that a virtualized system is not the original SoC anyway, so reporting the physical SoC as the main system in the guest is a bit strange and we probably want to come up with a different solution there.

In soc_device, we probably want to just report the type of hypervisor in this case, which is what most users would expect there. For the specific case of the mmc driver (are there any real use cases where you'd pass on the mmc controller to a guest, as opposed to passing either an emulated block device or the mmc device on an emulated mmc host?), that means we have to come up with a different solution, but then we'd be free to work around this by modifying the DT node of the mmc device.

Quoted 9 lines
Quoted 8 lines
drivers/soc/fsl/guts.c new file +7 -0
+/*
+ * Table for matching compatible strings, for device tree
+ * guts node, for Freescale QorIQ SOCs.
+ */
+static const struct of_device_id fsl_guts_of_match[] = {
+	/* For T4 & B4 Series SOCs */
+	{ .compatible = "fsl,qoriq-device-config-1.0", .data = "T4/B4

series" },

[snip]

Quoted 7 lines

drivers/soc/fsl/guts.c

Quoted 1 line
drivers/soc/fsl/guts.c new file +1 -0
+	{ .compatible = "fsl,qoriq-device-config-2.0", .data = "P series"

As noted in my comment on patch 3/4, these descriptions are reversed.

They're also incomplete. t2080 has device config 2.0. t1040 is described as 2.0 though it should probably be 2.1 (or better, drop the generic compatible altogether).

Ok. Ideally I think we'd even look up the specific SoC names from the SVC rather than the compatible string. I just didn't have a good list for those to put in the driver.

Quoted 6 lines
Quoted 6 lines
drivers/soc/fsl/guts.c new file +3 -0
+	/*
+	 * syscon devices default to little-endian, but on powerpc we have
+	 * existing device trees with big-endian maps and an absent

endianess

drivers/soc/fsl/guts.c new file +2 -0
+	 * "big-property"
+	 */
Quoted 8 lines

drivers/soc/fsl/guts.c line 110

Quoted 3 lines
drivers/soc/fsl/guts.c new file +3 -0
+	if (!IS_ENABLED(CONFIG_POWERPC) &&
+	    !of_property_read_bool(dev->of_node, "big-endian"))
+		guts->little_endian = true;

This is not a syscon device (Yangbo's patch to add a guts node on ls2080 is the only guts node that says "syscon", and that was a leftover from earlier revisions and should probably be removed). Even if it were, where is it documented that syscon defaults to little-endian?

Documentation/devicetree/bindings/regmap/regmap.txt

We had a little screwup here, basically regmap (and by consequence, syscon) always defaulted to little-endian way before that was documented, so it's too late to change it, although I agree it would have made sense to document regmap to default to big-endian on powerpc.

Quoted 4 lines

Documentation/devicetree/bindings/common-properties.txt says that the individual binding specifies the default. The default for this node should be big-endian because that's what existed before there was a need to describe the endianness. And we need an update to the guts binding to specify that.

Good point. This proably means that specifying both the "guts" and "syscon" compatible strings implies having to also specify the endianess explicitly both ways, because otherwise we break one of the two bindings.

Quoted 18 lines
Quoted 18 lines
drivers/soc/fsl/guts.c new file +18 -0
+
+	guts->regs = devm_ioremap_resource(dev, 0);
+	if (!guts->regs) {
+		ret = -ENOMEM;
+		kfree(guts);
+		goto out;
+	}
+
+	fsl_guts_init(dev, guts);
+	ret = 0;
+out:
+	return ret;
+}
+
+static struct platform_driver fsl_soc_guts = {
+	.probe = fsl_guts_probe,
+	.driver.of_match_table = fsl_guts_of_match,
+};
Quoted 8 lines

drivers/soc/fsl/guts.c

Quoted 2 lines
drivers/soc/fsl/guts.c new file +2 -0
+
+module_platform_driver(fsl_soc_guts);

Again, this means that the information is not available during early boot, such as in the clock driver. Thus we would not be able to convert clk-qoriq's direct mfspr(SPRN_SVR) into an soc_device_match() (or anything else that makes use of this file), nor would we be able to move its access of the guts RCW registers into this driver.

Correct. Do we have a reason to convert the mfspr() though? I don't really see an improvement over the current state if we do that, and for new devices that might need the erratum workaround, we could add a DT property that would be preferred to both.

Arnd

maintainer
#25 lore raw

Re: [PATCH 2/4] soc: fsl: add GUTS driver for QorIQ platforms

Quoted 38 lines · Arnd Bergmann
Quoted 28 lines · CEST Scott Wood
Quoted 27 lines · Arnd Bergmann
drivers/soc/fsl/guts.c new file +21 -0
new file mode 100644
index 000000000000..2f30698f5bcf
@@ -0,0 +1,130 @@
+/*
+ * Freescale QorIQ Platforms GUTS Driver
+ *
+ * Copyright (C) 2016 Freescale Semiconductor, Inc.
+ *
+ * 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.
+ */
+
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
+#include <linux/sys_soc.h>
+
+#define GUTS_PVR	0x0a0
+#define GUTS_SVR	0x0a4
Quoted 8 lines

drivers/soc/fsl/guts.c line 24

Quoted 3 lines
drivers/soc/fsl/guts.c new file +3 -0
+
+struct guts {
+	void __iomem *regs;

We already have a struct to define guts. Why are you not using it? Why do
you consider using it to be "abuse"? What if we want to move more guts functionality into this driver?

Quoted 3 lines

This structure was in the original patch, I left it in there, only removed the inclusion of the powerpc header file, which seemed to be misplaced.

I'm not refering "struct guts". I'm referring to changing "struct ccsr_guts __iomem *regs" into "void __iomem *regs".

And it's not a powerpc header file.

Quoted 20 lines
Quoted 14 lines
Quoted 8 lines
drivers/soc/fsl/guts.c new file +7 -0
+/*
+ * Table for matching compatible strings, for device tree
+ * guts node, for Freescale QorIQ SOCs.
+ */
+static const struct of_device_id fsl_guts_of_match[] = {
+	/* For T4 & B4 Series SOCs */
+	{ .compatible = "fsl,qoriq-device-config-1.0", .data = "T4/B4

series" },

[snip]

Quoted 2 lines
drivers/soc/fsl/guts.c new file +1 -0
+	{ .compatible = "fsl,qoriq-device-config-2.0", .data = "P

series"

As noted in my comment on patch 3/4, these descriptions are reversed.

Quoted 5 lines

They're also incomplete. t2080 has device config 2.0. t1040 is described as
2.0 though it should probably be 2.1 (or better, drop the generic compatible
altogether).

Quoted 3 lines

Ok. Ideally I think we'd even look up the specific SoC names from the SVC rather than the compatible string. I just didn't have a good list for those to put in the driver.

The list is in arch/powerpc/include/asm/mpc85xx.h but I don't know why we need to convert it to a string in the first place.

Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
drivers/soc/fsl/guts.c new file +2 -0
+	/*
+	 * syscon devices default to little-endian, but on powerpc we

have

drivers/soc/fsl/guts.c new file +1 -0
+	 * existing device trees with big-endian maps and an absent

endianess

drivers/soc/fsl/guts.c new file +4 -0
+	 * "big-property"
+	 */
+	if (!IS_ENABLED(CONFIG_POWERPC) &&
+	    !of_property_read_bool(dev->of_node, "big-endian"))
Quoted 8 lines

drivers/soc/fsl/guts.c line 110

Quoted 1 line
drivers/soc/fsl/guts.c new file +1 -0
+		guts->little_endian = true;

This is not a syscon device (Yangbo's patch to add a guts node on ls2080 is
the only guts node that says "syscon", and that was a leftover from earlier
revisions and should probably be removed). Even if it were, where is it documented that syscon defaults to little-endian?

Quoted 5 lines

Documentation/devicetree/bindings/regmap/regmap.txt

We had a little screwup here, basically regmap (and by consequence, syscon) always defaulted to little-endian way before that was documented, so it's too late to change it,

What causes a device node to fall under the jurisdiction of regmap.txt?
Again, these nodes do not claim "syscon" compatibility.

Quoted 2 lines

although I agree it would have made sense to document regmap to default to big-endian on powerpc.

Please don't. It's enough of a mess as is; no need to start throwing in architecture ifdefs.

Quoted 10 lines
Quoted 6 lines

Documentation/devicetree/bindings/common-properties.txt says that the individual binding specifies the default. The default for this node should be
big-endian because that's what existed before there was a need to describe the
endianness. And we need an update to the guts binding to specify that.

Good point. This proably means that specifying both the "guts" and "syscon" compatible strings implies having to also specify the endianess explicitly both ways, because otherwise we break one of the two bindings.

Yes, but the node should only specify "guts".

Quoted 30 lines
Quoted 22 lines
Quoted 11 lines
drivers/soc/fsl/guts.c new file +10 -0
+
+	guts->regs = devm_ioremap_resource(dev, 0);
+	if (!guts->regs) {
+		ret = -ENOMEM;
+		kfree(guts);
+		goto out;
+	}
+
+	fsl_guts_init(dev, guts);
+	ret = 0;

drivers/soc/fsl/guts.c line 130

Quoted 10 lines
drivers/soc/fsl/guts.c new file +10 -0
+out:
+	return ret;
+}
+
+static struct platform_driver fsl_soc_guts = {
+	.probe = fsl_guts_probe,
+	.driver.of_match_table = fsl_guts_of_match,
+};
+
+module_platform_driver(fsl_soc_guts);
Quoted 7 lines

Again, this means that the information is not available during early boot, such as in the clock driver. Thus we would not be able to convert clk -qoriq's
direct mfspr(SPRN_SVR) into an soc_device_match() (or anything else that makes
use of this file), nor would we be able to move its access of the guts RCW registers into this driver.

Quoted 2 lines

Correct. Do we have a reason to convert the mfspr() though? I don't really see an improvement over the current state if we do that,

Then should we drop this patchset and put a similar PPC ifdef in
drivers/mmc/host/sdhci-of-esdhc.c?

There's also the RCW access. You said in the patch 4/4 discussion that you di dn't like any random driver ioremapping the registers...

Quoted 4 lines

and for new devices
that might need the erratum workaround, we could add a DT property that would
be preferred to both.

It's unlikely that we would know the erratum exists at the time the device tree is created. We also generally don't have separate device trees for each revision of a chip (and if we did, we'd have users that use the wrong one).

-Scott

author
#26 lore raw

RE: [PATCH 2/4] soc: fsl: add GUTS driver for QorIQ platforms

Hi Arnd,

Could you comment on these?
Thanks.

Best regards,
Yangbo Lu

Quoted 179 lines

-----Original Message-----
From: Scott Wood [mailto:oss at buserror.net]
Sent: Saturday, June 11, 2016 9:51 AM
To: Arnd Bergmann; linuxppc-dev at lists.ozlabs.org
Cc: Mark Rutland; Ulf Hansson; linux-kernel at vger.kernel.org; linux- i2c at vger.kernel.org; linux-clk at vger.kernel.org; Qiang Zhao; Russell King; Bhupesh Sharma; Joerg Roedel; Claudiu Manoil; devicetree at vger.kernel.org; Kumar Gala; Rob Herring; Santosh Shilimkar; linux-arm-
kernel at lists.infradead.org; netdev at vger.kernel.org; linux- mmc at vger.kernel.org; Xiaobo Xie; Yang-Leo Li; iommu at lists.linux- foundation.org; Yangbo Lu
Subject: Re: [PATCH 2/4] soc: fsl: add GUTS driver for QorIQ platforms

Quoted 36 lines · Arnd Bergmann
Quoted 26 lines · CEST Scott Wood
Quoted 25 lines · Arnd Bergmann
drivers/soc/fsl/guts.c new renamed from drivers/soc/fsl/guts.c +0 -0

file mode 100644 index 000000000000..2f30698f5bcf

drivers/soc/fsl/guts.c new file +20 -0
@@ -0,0 +1,130 @@
+/*
+ * Freescale QorIQ Platforms GUTS Driver
+ *
+ * Copyright (C) 2016 Freescale Semiconductor, Inc.
+ *
+ * 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.
+ */
+
+#include <linux/io.h>
+#include <linux/platform_device.h> #include <linux/module.h>
+#include <linux/slab.h> #include <linux/of_address.h> #include
+<linux/of_platform.h> #include <linux/sys_soc.h>
+
+#define GUTS_PVR	0x0a0
Quoted 8 lines

drivers/soc/fsl/guts.c line 24

Quoted 4 lines
drivers/soc/fsl/guts.c new file +4 -0
+#define GUTS_SVR	0x0a4
+
+struct guts {
+	void __iomem *regs;

We already have a struct to define guts. Why are you not using it? Why do you consider using it to be "abuse"? What if we want to move more guts functionality into this driver?

Quoted 3 lines

This structure was in the original patch, I left it in there, only removed the inclusion of the powerpc header file, which seemed to be misplaced.

I'm not refering "struct guts". I'm referring to changing "struct ccsr_guts __iomem *regs" into "void __iomem *regs".

And it's not a powerpc header file.

Quoted 14 lines
Quoted 14 lines
Quoted 8 lines
drivers/soc/fsl/guts.c new file +7 -0
+/*
+ * Table for matching compatible strings, for device tree
+ * guts node, for Freescale QorIQ SOCs.
+ */
+static const struct of_device_id fsl_guts_of_match[] = {
+	/* For T4 & B4 Series SOCs */
+	{ .compatible = "fsl,qoriq-device-config-1.0", .data = "T4/B4

series" },

[snip]

Quoted 2 lines
drivers/soc/fsl/guts.c new file +1 -0
+	{ .compatible = "fsl,qoriq-device-config-2.0", .data = "P

series"

As noted in my comment on patch 3/4, these descriptions are reversed.

Quoted 8 lines
Quoted 4 lines

They're also incomplete. t2080 has device config 2.0. t1040 is described as
2.0 though it should probably be 2.1 (or better, drop the generic compatible altogether).

Ok. Ideally I think we'd even look up the specific SoC names from the SVC rather than the compatible string. I just didn't have a good list for those to put in the driver.

The list is in arch/powerpc/include/asm/mpc85xx.h but I don't know why we need to convert it to a string in the first place.

Quoted 18 lines
Quoted 17 lines

drivers/soc/fsl/guts.c line 110

Quoted 11 lines
drivers/soc/fsl/guts.c new file +2 -0
+	/*
+	 * syscon devices default to little-endian, but on powerpc we

have

drivers/soc/fsl/guts.c new file +1 -0
+	 * existing device trees with big-endian maps and an absent

endianess

drivers/soc/fsl/guts.c new file +5 -0
+	 * "big-property"
+	 */
+	if (!IS_ENABLED(CONFIG_POWERPC) &&
+	    !of_property_read_bool(dev->of_node, "big-endian"))
+		guts->little_endian = true;

This is not a syscon device (Yangbo's patch to add a guts node on ls2080 is the only guts node that says "syscon", and that was a leftover from earlier revisions and should probably be removed). Even if it were, where is it documented that syscon defaults to little-endian?

Quoted 5 lines

Documentation/devicetree/bindings/regmap/regmap.txt

We had a little screwup here, basically regmap (and by consequence, syscon) always defaulted to little-endian way before that was documented, so it's too late to change it,

What causes a device node to fall under the jurisdiction of regmap.txt?
Again, these nodes do not claim "syscon" compatibility.

Quoted 2 lines

although I agree it would have made sense to document regmap to default to big-endian on powerpc.

Please don't. It's enough of a mess as is; no need to start throwing in architecture ifdefs.

Quoted 7 lines
Quoted 5 lines

Documentation/devicetree/bindings/common-properties.txt says that the individual binding specifies the default. The default for this node should be big-endian because that's what existed before there was a need to describe the endianness. And we need an update to the guts binding to specify that.

Good point. This proably means that specifying both the "guts" and

"syscon"

Quoted 2 lines

compatible strings implies having to also specify the endianess explicitly both ways, because otherwise we break one of the two

bindings.

Yes, but the node should only specify "guts".

Quoted 28 lines
Quoted 19 lines
Quoted 19 lines
drivers/soc/fsl/guts.c new file +18 -0
+
+	guts->regs = devm_ioremap_resource(dev, 0);
+	if (!guts->regs) {
+		ret = -ENOMEM;
+		kfree(guts);
+		goto out;
+	}
+
+	fsl_guts_init(dev, guts);
+	ret = 0;
+out:
+	return ret;
+}
+
+static struct platform_driver fsl_soc_guts = {
+	.probe = fsl_guts_probe,
+	.driver.of_match_table = fsl_guts_of_match, };
+
Quoted 8 lines
Quoted 1 line

+module_platform_driver(fsl_soc_guts);

Again, this means that the information is not available during early boot, such as in the clock driver. Thus we would not be able to convert clk -qoriq's direct mfspr(SPRN_SVR) into an soc_device_match() (or anything else that makes use of this file), nor would we be able to move its access of the guts RCW registers into this driver.

Quoted 2 lines

Correct. Do we have a reason to convert the mfspr() though? I don't really see an improvement over the current state if we do that,

Then should we drop this patchset and put a similar PPC ifdef in drivers/mmc/host/sdhci-of-esdhc.c?

There's also the RCW access. You said in the patch 4/4 discussion that you di dn't like any random driver ioremapping the registers...

Quoted 3 lines

and for new devices
that might need the erratum workaround, we could add a DT property that would be preferred to both.

It's unlikely that we would know the erratum exists at the time the device tree is created. We also generally don't have separate device trees for each revision of a chip (and if we did, we'd have users that use the wrong one).

-Scott

author
#27 lore raw

RE: [PATCH 2/4] soc: fsl: add GUTS driver for QorIQ platforms

In reply to Scott Wood

Hi Arnd,

Could you reply when you see the email?
If your method doesn?t resolve the problem, we still want to use our old patchset.

This guts driver had been discussed about one year and blocked many workaround upstream. So please help to review and comment soon.

Thanks a lot.

Best regards,
Yangbo Lu

Quoted 203 lines

-----Original Message-----
From: Yangbo Lu
Sent: Thursday, June 23, 2016 10:46 AM
To: 'Scott Wood'; Arnd Bergmann; linuxppc-dev at lists.ozlabs.org
Cc: Mark Rutland; Ulf Hansson; linux-kernel at vger.kernel.org; linux- i2c at vger.kernel.org; linux-clk at vger.kernel.org; Qiang Zhao; Russell King; Bhupesh Sharma; Joerg Roedel; Claudiu Manoil; devicetree at vger.kernel.org; Kumar Gala; Rob Herring; Santosh Shilimkar; linux-arm-
kernel at lists.infradead.org; netdev at vger.kernel.org; linux- mmc at vger.kernel.org; Xiaobo Xie; Yang-Leo Li; iommu at lists.linux- foundation.org
Subject: RE: [PATCH 2/4] soc: fsl: add GUTS driver for QorIQ platforms

Hi Arnd,

Could you comment on these?
Thanks.

Best regards,
Yangbo Lu

Quoted 50 lines

-----Original Message-----
From: Scott Wood [mailto:oss at buserror.net]
Sent: Saturday, June 11, 2016 9:51 AM
To: Arnd Bergmann; linuxppc-dev at lists.ozlabs.org
Cc: Mark Rutland; Ulf Hansson; linux-kernel at vger.kernel.org; linux- i2c at vger.kernel.org; linux-clk at vger.kernel.org; Qiang Zhao; Russell King; Bhupesh Sharma; Joerg Roedel; Claudiu Manoil; devicetree at vger.kernel.org; Kumar Gala; Rob Herring; Santosh Shilimkar; linux-arm- kernel at lists.infradead.org;
netdev at vger.kernel.org; linux- mmc at vger.kernel.org; Xiaobo Xie; Yang-Leo Li; iommu at lists.linux- foundation.org; Yangbo Lu
Subject: Re: [PATCH 2/4] soc: fsl: add GUTS driver for QorIQ platforms

Quoted 36 lines · Arnd Bergmann
Quoted 34 lines · CEST Scott Wood
Quoted 19 lines · Arnd Bergmann
drivers/soc/fsl/guts.c new renamed from drivers/soc/fsl/guts.c +0 -0

file mode 100644 index 000000000000..2f30698f5bcf

drivers/soc/fsl/guts.c new file +14 -0
@@ -0,0 +1,130 @@
+/*
+ * Freescale QorIQ Platforms GUTS Driver
+ *
+ * Copyright (C) 2016 Freescale Semiconductor, Inc.
+ *
+ * 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.
+ */
+

drivers/soc/fsl/guts.c line 24

Quoted 10 lines
drivers/soc/fsl/guts.c new file +10 -0
+#include <linux/io.h>
+#include <linux/platform_device.h> #include <linux/module.h>
+#include <linux/slab.h> #include <linux/of_address.h> #include
+<linux/of_platform.h> #include <linux/sys_soc.h>
+
+#define GUTS_PVR	0x0a0
+#define GUTS_SVR	0x0a4
+
+struct guts {
+	void __iomem *regs;

We already have a struct to define guts. Why are you not using it? Why do you consider using it to be "abuse"? What if we want to move more guts functionality into this driver?

Quoted 22 lines
Quoted 3 lines

This structure was in the original patch, I left it in there, only removed the inclusion of the powerpc header file, which seemed to be misplaced.

I'm not refering "struct guts". I'm referring to changing "struct ccsr_guts __iomem *regs" into "void __iomem *regs".

And it's not a powerpc header file.

Quoted 13 lines
Quoted 13 lines
Quoted 8 lines
drivers/soc/fsl/guts.c new file +7 -0
+/*
+ * Table for matching compatible strings, for device tree
+ * guts node, for Freescale QorIQ SOCs.
+ */
+static const struct of_device_id fsl_guts_of_match[] = {
+	/* For T4 & B4 Series SOCs */
+	{ .compatible = "fsl,qoriq-device-config-1.0", .data = "T4/B4

series" },

[snip]

Quoted 2 lines
drivers/soc/fsl/guts.c new file +1 -0
+	{ .compatible = "fsl,qoriq-device-config-2.0", .data = "P

series"

As noted in my comment on patch 3/4, these descriptions are

reversed.

Quoted 107 lines
Quoted 9 lines
Quoted 5 lines

They're also incomplete. t2080 has device config 2.0. t1040 is described as
2.0 though it should probably be 2.1 (or better, drop the generic compatible altogether).

Ok. Ideally I think we'd even look up the specific SoC names from the SVC rather than the compatible string. I just didn't have a good list for those to put in the driver.

The list is in arch/powerpc/include/asm/mpc85xx.h but I don't know why we need to convert it to a string in the first place.

Quoted 18 lines
Quoted 17 lines

drivers/soc/fsl/guts.c line 110

Quoted 11 lines
drivers/soc/fsl/guts.c new file +2 -0
+	/*
+	 * syscon devices default to little-endian, but on powerpc we

have

drivers/soc/fsl/guts.c new file +1 -0
+	 * existing device trees with big-endian maps and an absent

endianess

drivers/soc/fsl/guts.c new file +5 -0
+	 * "big-property"
+	 */
+	if (!IS_ENABLED(CONFIG_POWERPC) &&
+	    !of_property_read_bool(dev->of_node, "big-endian"))
+		guts->little_endian = true;

This is not a syscon device (Yangbo's patch to add a guts node on ls2080 is the only guts node that says "syscon", and that was a leftover from earlier revisions and should probably be removed). Even if it were, where is it documented that syscon defaults to little-endian?

Quoted 5 lines

Documentation/devicetree/bindings/regmap/regmap.txt

We had a little screwup here, basically regmap (and by consequence, syscon) always defaulted to little-endian way before that was documented, so it's too late to change it,

What causes a device node to fall under the jurisdiction of regmap.txt?
Again, these nodes do not claim "syscon" compatibility.

Quoted 2 lines

although I agree it would have made sense to document regmap to default to big-endian on powerpc.

Please don't. It's enough of a mess as is; no need to start throwing in architecture ifdefs.

Quoted 7 lines
Quoted 5 lines

Documentation/devicetree/bindings/common-properties.txt says that the individual binding specifies the default. The default for this node should be big-endian because that's what existed before there was a need to describe the endianness. And we need an update to the guts binding to specify that.

Good point. This proably means that specifying both the "guts" and

"syscon"

Quoted 2 lines

compatible strings implies having to also specify the endianess explicitly both ways, because otherwise we break one of the two

bindings.

Yes, but the node should only specify "guts".

Quoted 28 lines
Quoted 19 lines
Quoted 19 lines
drivers/soc/fsl/guts.c new file +18 -0
+
+	guts->regs = devm_ioremap_resource(dev, 0);
+	if (!guts->regs) {
+		ret = -ENOMEM;
+		kfree(guts);
+		goto out;
+	}
+
+	fsl_guts_init(dev, guts);
+	ret = 0;
+out:
+	return ret;
+}
+
+static struct platform_driver fsl_soc_guts = {
+	.probe = fsl_guts_probe,
+	.driver.of_match_table = fsl_guts_of_match, };
+
Quoted 8 lines
Quoted 1 line

+module_platform_driver(fsl_soc_guts);

Again, this means that the information is not available during early boot, such as in the clock driver. Thus we would not be able to convert clk -qoriq's direct mfspr(SPRN_SVR) into an soc_device_match() (or anything else that makes use of this file), nor would we be able to move its access of the guts RCW registers into this driver.

Quoted 2 lines

Correct. Do we have a reason to convert the mfspr() though? I don't really see an improvement over the current state if we do that,

Then should we drop this patchset and put a similar PPC ifdef in drivers/mmc/host/sdhci-of-esdhc.c?

There's also the RCW access. You said in the patch 4/4 discussion that you di dn't like any random driver ioremapping the registers...

Quoted 3 lines

and for new devices
that might need the erratum workaround, we could add a DT property that would be preferred to both.

It's unlikely that we would know the erratum exists at the time the device tree is created. We also generally don't have separate device trees for each revision of a chip (and if we did, we'd have users that use the wrong one).

-Scott

#28 lore raw

Re: [PATCH 2/4] soc: fsl: add GUTS driver for QorIQ platforms

Quoted 4 lines · CEST Yangbo Lu

Hi Arnd,
=20
Could you reply when you see the email?
If your method doesn=E2=80=99t resolve the problem, we still want to use =

our old patchset.

Quoted 2 lines

=20
This guts driver had been discussed about one year and blocked many worka=

round upstream.

Quoted 2 lines

So please help to review and comment soon.
=20

I don't really see how more discussion is going to help us here. I think I've made it pretty clear that I don't want to see another platform specific way to read an SoC revision and I've even sent a proof-of-concept patch to show how the interface can work, now it's up to you to fit the guts hardware into that and send a new patch series.

Arnd

maintainer
#29 lore raw

Re: [PATCH 2/4] soc: fsl: add GUTS driver for QorIQ platforms

Quoted 12 lines · Arnd Bergmann
Quoted 11 lines · CEST Yangbo Lu

Hi Arnd,

Could you reply when you see the email?
If your method doesn?t resolve the problem, we still want to use our old patchset.

This guts driver had been discussed about one year and blocked many workaround upstream.
So please help to review and comment soon.

Quoted 5 lines

I don't really see how more discussion is going to help us here. I think I've made it pretty clear that I don't want to see another platform specific way to read an SoC revision and I've even sent a proof-of-concept patch to show how the interface can work, now it's up to you to fit the guts hardware into that and send a new patch series.

In which relevant maintainership capacity are you NACKing it?

-Scott

author
#30 lore raw

RE: [PATCH 2/4] soc: fsl: add GUTS driver for QorIQ platforms

In reply to Arnd Bergmann

Hi Arnd,

Quoted 25 lines

-----Original Message-----
From: Arnd Bergmann [mailto:arnd at arndb.de]
Sent: Thursday, July 07, 2016 4:30 PM
To: Yangbo Lu
Cc: Scott Wood; linuxppc-dev at lists.ozlabs.org; Mark Rutland; Ulf Hansson; linux-kernel at vger.kernel.org; linux-i2c at vger.kernel.org; linux- clk at vger.kernel.org; Qiang Zhao; Russell King; Bhupesh Sharma; Joerg Roedel; Claudiu Manoil; devicetree at vger.kernel.org; Kumar Gala; Rob Herring; Santosh Shilimkar; linux-arm-kernel at lists.infradead.org; netdev at vger.kernel.org; linux-mmc at vger.kernel.org; Xiaobo Xie; Yang-Leo Li; iommu at lists.linux-foundation.org
Subject: Re: [PATCH 2/4] soc: fsl: add GUTS driver for QorIQ platforms

Quoted 4 lines · CEST Yangbo Lu

Hi Arnd,

Could you reply when you see the email?
If your method doesn?t resolve the problem, we still want to use our

old patchset.

Quoted 2 lines

This guts driver had been discussed about one year and blocked many

workaround upstream.

Quoted 2 lines

So please help to review and comment soon.

Quoted 7 lines

I don't really see how more discussion is going to help us here. I think I've made it pretty clear that I don't want to see another platform specific way to read an SoC revision and I've even sent a proof-of- concept patch to show how the interface can work, now it's up to you to fit the guts hardware into that and send a new patch series.

Arnd

I think your proof-of-concept patch is still in discussion. Some answers are needed from you to address Scott's comments on your patchset. Have you reached an agreement?

Thanks.

- Yangbo Lu

#31 lore raw

PATCH 3/4 mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0

In reply to Ulf Hansson

This is a rewrite of an earlier patch from Yangbo Lu, adding a quirk for the NXP QorIQ T4240 in the detection of the host device version.

Unfortunately, this device cannot be detected using the compatible string, as we have to support existing DTS files that use the generic "fsl,t4240-esdhc" identifier but that have other host versions that are correctly detected.

drivers/mmc/host/sdhci-of-esdhc.c +23 -5
index 3f34d354f1fc..1d4814fe4cb2 100644
@@ -73,14 +73,16 @@ static u32 esdhc_readl_fixup(struct sdhci_host *host,
 static u16 esdhc_readw_fixup(struct sdhci_host *host,
 				     int spec_reg, u32 value)
 {
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host);
 	u16 ret;
 	int shift = (spec_reg & 0x2) * 8;
 
 	if (spec_reg == SDHCI_HOST_VERSION)
-		ret = value & 0xffff;
-	else
-		ret = (value >> shift) & 0xffff;
-	return ret;
+		return esdhc->vendor_ver << SDHCI_VENDOR_VER_SHIFT |
+		       esdhc->spec_ver;
+
+	return (value >> shift) & 0xffff;
 }
 
 static u8 esdhc_readb_fixup(struct sdhci_host *host,
@@ -562,16 +564,32 @@ static const struct sdhci_pltfm_data sdhci_esdhc_le_pdata = {
 	.ops = &sdhci_esdhc_le_ops,
 };
 
+#define T4240_HOST_VER ((VENDOR_V_23 << SDHCI_VENDOR_VER_SHIFT) | SDHCI_SPEC_200)
+static const struct soc_device_attribute esdhc_t4240_quirk = {
+	/* T4240 revision < 0x20 uses vendor version 23, SDHCI version 200 */
+	{ .soc_id = "T4*(0x824000)", .revision = "0x[01]?",
+	  .data = (void *)(uintptr_t)(T4240_HOST_VER) },
+	{ },
+};
+
 static void esdhc_init(struct platform_device *pdev, struct sdhci_host *host)
 {
 	struct sdhci_pltfm_host *pltfm_host;
 	struct sdhci_esdhc *esdhc;
-	u16 host_ver;
 
 	pltfm_host = sdhci_priv(host);
 	esdhc = sdhci_pltfm_priv(pltfm_host);
 
 	host_ver = sdhci_readw(host, SDHCI_HOST_VERSION);
+
+	if (of_device_is_compatible(pdev->dev.of_node, "fsl,t4240-esdhc")) {
+		struct soc_device_attribute *match;
+
+		match = soc_device_match(&esdhc_t4240_quirk);
+		if (match)
+			host_ver = (uintptr_t)match->data;
+	}
+
 	esdhc->vendor_ver = (host_ver & SDHCI_VENDOR_VER_MASK) >>
 			     SDHCI_VENDOR_VER_SHIFT;
 	esdhc->spec_ver = host_ver & SDHCI_SPEC_VER_MASK;
maintainer
#32 lore raw

Re: [PATCH 3/4] mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0

Quoted 38 lines · Arnd Bergmann

This is a rewrite of an earlier patch from Yangbo Lu, adding a quirk for the NXP QorIQ T4240 in the detection of the host device version.

Unfortunately, this device cannot be detected using the compatible string, as we have to support existing DTS files that use the generic "fsl,t4240-esdhc" identifier but that have other host versions that are correctly detected.

drivers/mmc/host/sdhci-of renamed from drivers/mmc/host/sdhci-of-esdhc.c +0 -1
-esdhc.c

index 3f34d354f1fc..1d4814fe4cb2 100644

drivers/mmc/host/sdhci-of-esdhc.c +6 -4
@@ -73,14 +73,16 @@ static u32 esdhc_readl_fixup(struct sdhci_host *host,
 static u16 esdhc_readw_fixup(struct sdhci_host *host,
 				     int spec_reg, u32 value)
 {
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host);
 	u16 ret;
 	int shift = (spec_reg & 0x2) * 8;
 
 	if (spec_reg == SDHCI_HOST_VERSION)
-		ret = value & 0xffff;
-	else
-		ret = (value >> shift) & 0xffff;
-	return ret;
+		return esdhc->vendor_ver << SDHCI_VENDOR_VER_SHIFT |
+		       esdhc->spec_ver;
+
+	return (value >> shift) & 0xffff;
 }
 
 static u8 esdhc_readb_fixup(struct sdhci_host *host,
@@ -562,16 +564,32 @@ static const struct sdhci_pltfm_data
 sdhci_esdhc_le_pdata = {

drivers/mmc/host/sdhci-of-esdhc.c static const struct sdhci_pltfm_data · line 574

Quoted 10 lines
drivers/mmc/host/sdhci-of-esdhc.c +5 -0
 	.ops = &sdhci_esdhc_le_ops,
 };
 
+#define T4240_HOST_VER ((VENDOR_V_23 << SDHCI_VENDOR_VER_SHIFT) |
 SDHCI_SPEC_200)
+static const struct soc_device_attribute esdhc_t4240_quirk = {
+	/* T4240 revision < 0x20 uses vendor version 23, SDHCI version 200
 */
+	{ .soc_id = "T4*(0x824000)", .revision = "0x[01]?",
+	  .data = (void *)(uintptr_t)(T4240_HOST_VER) },

Why should this code need to care that the string begins with "T4"? This creates dual maintenance if that were to change. It's also broken because T4240 has compatible = "fsl,t4240-device-config", "fsl,qoriq-device-config -2.0" and thus with these patches it would incorrectly show up as "P series (0x824000)". The compatible string of this node was never meant to be a key for choosing a string to describe the system to userspace.

0x824000 is a magic number which should be represented symbolically.

If T4240 is affected, then so are the reduced-core variants T4160 and T4080, but 0x824000 doesn't match them (Yangbo's patch had the same problem). And please don't respond with "0x824*"

You also didn't strip out the E bit of SVR which indicates encryption capability and nothing else (Yangbo's patch did not have this problem because it used SVR_SOC_VER).

What happens if the revision condition is more complicated, such as <= 0x20 with 0x21 being fine? Multiple quirk entries where before we had as simple comparison?

I fail to see how this approach is an improvement (much less one that needs to hold up a patchset that is fixing a problem and is not touching any generic code). Why does this need to be a string?

-Scott

#33 lore raw

Re: [PATCH 3/4] mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0

Quoted 6 lines · CEST Scott Wood
Quoted 6 lines

+#define T4240_HOST_VER ((VENDOR_V_23 << SDHCI_VENDOR_VER_SHIFT) | SDHCI_SPEC_200)

(quoted diff) +2 -0
+static const struct soc_device_attribute esdhc_t4240_quirk = {
+     /* T4240 revision < 0x20 uses vendor version 23, SDHCI version 200

*/
+ { .soc_id = "T4*(0x824000)", .revision = "0x[01]?",

Quoted 8 lines
Quoted 1 line

+ .data = (void *)(uintptr_t)(T4240_HOST_VER) },

Why should this code need to care that the string begins with "T4"? This creates dual maintenance if that were to change. It's also broken because T4240 has compatible = "fsl,t4240-device-config", "fsl,qoriq-device-config -2.0" and thus with these patches it would incorrectly show up as "P series (0x824000)". The compatible string of this node was never meant to be a key for choosing a string to describe the system to userspace.

This is an artifact of not knowing the specific SoC name, and we can change that by looking up the name from the SVR value in the soc_device driver.

Quoted 1 line

0x824000 is a magic number which should be represented symbolically.

Sure, feel free to change the format of the soc_device string in any name, I just converted the information I had available in the comments. The only thing that is important here is that the string matches what the soc_device driver calls it.

Quoted 7 lines

If T4240 is affected, then so are the reduced-core variants T4160 and T4080, but 0x824000 doesn't match them (Yangbo's patch had the same problem). And please don't respond with "0x824*"

You also didn't strip out the E bit of SVR which indicates encryption capability and nothing else (Yangbo's patch did not have this problem because it used SVR_SOC_VER).

Ok, that should be easy enough to fix in the soc_device driver.

Quoted 3 lines

What happens if the revision condition is more complicated, such as <= 0x20 with 0x21 being fine? Multiple quirk entries where before we had as simple comparison?

I guess yes. I would really hope that there is no need to use this interface pervasively, it's really just to work around the cases where there is no way to pass the information in DT otherwise.

Quoted 3 lines

I fail to see how this approach is an improvement (much less one that needs to hold up a patchset that is fixing a problem and is not touching any generic code). Why does this need to be a string?

A string is what user space gets in /sys/devices/soc/*, and we already have code that does the same things there to work around quirks, here we just use the same interface in a completely generic way. Note that not every SoC family uses numbers in the same way, some have multiple subrevisions, some have names etc.

Arnd

maintainer
#34 lore raw

Re: [PATCH 3/4] mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0

Quoted 18 lines · Arnd Bergmann
Quoted 8 lines · CEST Scott Wood

drivers/mmc/host/sdhci-of-esdhc.c static const struct sdhci_pltfm_data sdhci_esdhc_le_pdata = { · line 571

Quoted 7 lines

+#define T4240_HOST_VER ((VENDOR_V_23 << SDHCI_VENDOR_VER_SHIFT) | SDHCI_SPEC_200)

(quoted diff) +2 -0
+static const struct soc_device_attribute esdhc_t4240_quirk = {
+     /* T4240 revision < 0x20 uses vendor version 23, SDHCI version 200

*/

drivers/mmc/host/sdhci-of-esdhc.c +2 -0
+     { .soc_id = "T4*(0x824000)", .revision = "0x[01]?",
+       .data = (void *)(uintptr_t)(T4240_HOST_VER) },
Quoted 8 lines

Why should this code need to care that the string begins with "T4"? This creates dual maintenance if that were to change. It's also broken because T4240 has compatible = "fsl,t4240-device-config", "fsl,qoriq-device-config -2.0" and thus with these patches it would incorrectly show up as "P series
(0x824000)". The compatible string of this node was never meant to be a key
for choosing a string to describe the system to userspace.

Quoted 2 lines

This is an artifact of not knowing the specific SoC name, and we can change that by looking up the name from the SVR value in the soc_device driver.

...or we could keep it simple and just match the number.

Quoted 4 lines
Quoted 1 line

0x824000 is a magic number which should be represented symbolically.

Sure, feel free to change the format of the soc_device string in any name,

That's not what I was asking for... The match should be numeric but the knowledge of what the number is should come from a symbolic #define.

Quoted 6 lines
Quoted 6 lines

If T4240 is affected, then so are the reduced-core variants T4160 and T4080,
but 0x824000 doesn't match them (Yangbo's patch had the same problem).
And
please don't respond with "0x824*"

Quoted 6 lines
Quoted 4 lines

You also didn't strip out the E bit of SVR which indicates encryption capability and nothing else (Yangbo's patch did not have this problem because
it used SVR_SOC_VER).

Ok, that should be easy enough to fix in the soc_device driver.

No, because the soc_device driver doesn't know whether the consumer of the ID cares about the E bit.

Quoted 9 lines
Quoted 5 lines

What happens if the revision condition is more complicated, such as <= 0x20
with 0x21 being fine? Multiple quirk entries where before we had as simple
comparison?

I guess yes. I would really hope that there is no need to use this interface pervasively, it's really just to work around the cases where there is no way to pass the information in DT otherwise.

How does putting it in the DT work when you have multiple versions of the same SoC, some of which have the bug and some which don't?

Quoted 7 lines
Quoted 5 lines

I fail to see how this approach is an improvement (much less one that needs to
hold up a patchset that is fixing a problem and is not touching any generic
code). Why does this need to be a string?

A string is what user space gets in /sys/devices/soc/*,

It is rare that the kernel accesses information in the exact same way that userspace does. And once we expose this to userspace we're stuck with it, so exporting anything other than a simple number is even less desirable.

Quoted 5 lines

and we already have
code that does the same things there to work around quirks, here we just use the same interface in a completely generic way. Note that not every SoC family uses numbers in the same way, some have multiple subrevisions, some have names etc.

Where is the need for a "completely generic way" for one piece of vendor -specific code to get information that is inherently specific to that vendor, that is supplied by code specific to that vendor?

-Scott

#35 lore raw

PATCH 4/4 Revert "powerpc/fsl: Move fsl_guts.h out of arch/powerpc"

In reply to Ulf Hansson

All users of this driver are PowerPC specific and the header file has no business in the global include/linux/ hierarchy, so move it back before anyone starts using it on ARM.

This reverts commit 948486544713492f00ac8a9572909101ea892cb0.

---
This part of the series is not required for the eSDHC quirk, but it restores the asm/fsl_guts.h header so it doesn't accidentally get abused for this in the future. I found two drivers outside of arch/powerpc that already accessed the registers directly, but the functions look fairly contained, and can be easily hidden in an #ifdef CONFIG_PPC

arch/powerpc/include/asm/fsl_guts.h renamed from include/linux/fsl/guts.h +4 -4
similarity index 99%
rename from include/linux/fsl/guts.h
rename to arch/powerpc/include/asm/fsl_guts.h
index 649e9171a9b3..a67413c52701 100644
@@ -12,10 +12,9 @@
  * option) any later version.
  */
 
-#ifndef __FSL_GUTS_H__
-#define __FSL_GUTS_H__
-
-#include <linux/types.h>
+#ifndef __ASM_POWERPC_FSL_GUTS_H__
+#define __ASM_POWERPC_FSL_GUTS_H__
+#ifdef __KERNEL__
 
 /**
  * Global Utility Registers.
@@ -295,3 +294,4 @@ struct ccsr_rcpm_v2 {
 };
 
 #endif
+#endif
arch/powerpc/platforms/85xx/mpc85xx_mds.c +1 -1
index f61cbe235581..00f052e9f2a2 100644
@@ -34,7 +34,6 @@
 #include <linux/of_device.h>
 #include <linux/phy.h>
 #include <linux/memblock.h>
-#include <linux/fsl/guts.h>
 
 #include <linux/atomic.h>
 #include <asm/time.h>
@@ -52,6 +51,7 @@
 #include <soc/fsl/qe/qe_ic.h>
 #include <asm/mpic.h>
 #include <asm/swiotlb.h>
+#include <asm/fsl_guts.h>
 #include "smp.h"
 
 #include "mpc85xx.h"
arch/powerpc/platforms/85xx/mpc85xx_pm_ops.c +1 -1
index f05325f0cc03..a812c0511252 100644
@@ -14,8 +14,8 @@
 #include <linux/kernel.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
-#include <linux/fsl/guts.h>
 
+#include <asm/fsl_guts.h>
 #include <asm/io.h>
 #include <asm/fsl_pm.h>
 
arch/powerpc/platforms/85xx/mpc85xx_rdb.c +1 -1
index 3f4dad133338..453ddda00fce 100644
@@ -17,7 +17,6 @@
 #include <linux/seq_file.h>
 #include <linux/interrupt.h>
 #include <linux/of_platform.h>
-#include <linux/fsl/guts.h>
 
 #include <asm/time.h>
 #include <asm/machdep.h>
@@ -28,6 +27,7 @@
 #include <asm/mpic.h>
 #include <soc/fsl/qe/qe.h>
 #include <soc/fsl/qe/qe_ic.h>
+#include <asm/fsl_guts.h>
 
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
arch/powerpc/platforms/85xx/p1022_ds.c +1 -1
index 371df822e88e..6ac986d3f8a3 100644
@@ -16,7 +16,6 @@
  * kind, whether express or implied.
  */
 
-#include <linux/fsl/guts.h>
 #include <linux/pci.h>
 #include <linux/of_platform.h>
 #include <asm/div64.h>
@@ -26,6 +25,7 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 #include <asm/udbg.h>
+#include <asm/fsl_guts.h>
 #include <asm/fsl_lbc.h>
 #include "smp.h"
 
arch/powerpc/platforms/85xx/p1022_rdk.c +1 -1
index 5087becaa8bc..680232d6ba48 100644
@@ -12,7 +12,6 @@
  * kind, whether express or implied.
  */
 
-#include <linux/fsl/guts.h>
 #include <linux/pci.h>
 #include <linux/of_platform.h>
 #include <asm/div64.h>
@@ -22,6 +21,7 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 #include <asm/udbg.h>
+#include <asm/fsl_guts.h>
 #include "smp.h"
 
 #include "mpc85xx.h"
arch/powerpc/platforms/85xx/smp.c +1 -1
index fe9f19e5e935..6bd3a292e790 100644
@@ -18,7 +18,6 @@
 #include <linux/kexec.h>
 #include <linux/highmem.h>
 #include <linux/cpu.h>
-#include <linux/fsl/guts.h>
 
 #include <asm/machdep.h>
 #include <asm/pgtable.h>
@@ -26,6 +25,7 @@
 #include <asm/mpic.h>
 #include <asm/cacheflush.h>
 #include <asm/dbell.h>
+#include <asm/fsl_guts.h>
 #include <asm/code-patching.h>
 #include <asm/cputhreads.h>
 #include <asm/fsl_pm.h>
arch/powerpc/platforms/85xx/twr_p102x.c +1 -1
index 71bc255b4324..2cac45f72d24 100644
@@ -15,7 +15,6 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/errno.h>
-#include <linux/fsl/guts.h>
 #include <linux/pci.h>
 #include <linux/of_platform.h>
 
@@ -24,6 +23,7 @@
 #include <asm/mpic.h>
 #include <soc/fsl/qe/qe.h>
 #include <soc/fsl/qe/qe_ic.h>
+#include <asm/fsl_guts.h>
 
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
arch/powerpc/platforms/86xx/mpc8610_hpcd.c +1 -1
index 957473e5c8e5..761c81476957 100644
@@ -24,7 +24,6 @@
 #include <linux/delay.h>
 #include <linux/seq_file.h>
 #include <linux/of.h>
-#include <linux/fsl/guts.h>
 
 #include <asm/time.h>
 #include <asm/machdep.h>
@@ -39,6 +38,7 @@
 #include <sysdev/fsl_pci.h>
 #include <sysdev/fsl_soc.h>
 #include <sysdev/simple_gpio.h>
+#include <asm/fsl_guts.h>
 
 #include "mpc86xx.h"
 
arch/powerpc/sysdev/fsl_rcpm.c +1 -1
index 9259a94f70e1..8af22187cb25 100644
@@ -19,7 +19,7 @@
 #include <linux/export.h>
 
 #include <asm/io.h>
-#include <linux/fsl/guts.h>
+#include <asm/fsl_guts.h>
 #include <asm/cputhreads.h>
 #include <asm/fsl_pm.h>
 #include <asm/smp.h>
drivers/clk/clk-qoriq.c +9 -1
index 58566a17944a..f311bd399672 100644
@@ -12,7 +12,6 @@
 
 #include <linux/clk.h>
 #include <linux/clk-provider.h>
-#include <linux/fsl/guts.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -21,6 +20,10 @@
 #include <linux/of.h>
 #include <linux/slab.h>
 
+#ifdef CONFIG_PPC
+#include <asm/fsl_guts.h>
+#endif
+
 #define PLL_DIV1	0
 #define PLL_DIV2	1
 #define PLL_DIV3	2
@@ -341,6 +344,8 @@ static const struct clockgen_muxinfo t4240_hwa5 = {
 	},
 };
 
+#ifdef CONFIG_PPC
+
 #define RCWSR7_FM1_CLK_SEL	0x40000000
 #define RCWSR7_FM2_CLK_SEL	0x20000000
 #define RCWSR7_HWA_ASYNC_DIV	0x04000000
@@ -408,6 +413,7 @@ static void __init p5040_init_periph(struct clockgen *cg)
 	else
 		cg->fman[1] = cg->pll[PLATFORM_PLL].div[PLL_DIV2].clk;
 }
+#endif
 
 static void __init t1023_init_periph(struct clockgen *cg)
 {
@@ -499,6 +505,7 @@ static const struct clockgen_chipinfo chipinfo[] = {
 		.pll_mask = 0x37,
 		.flags = CG_VER3 | CG_LITTLE_ENDIAN,
 	},
+#ifdef CONFIG_PPC
 	{
 		.compat = "fsl,p2041-clockgen",
 		.guts_compat = "fsl,qoriq-device-config-1.0",
@@ -559,6 +566,7 @@ static const struct clockgen_chipinfo chipinfo[] = {
 		},
 		.pll_mask = 0x0f,
 	},
+#endif
 	{
 		.compat = "fsl,t1023-clockgen",
 		.guts_compat = "fsl,t1023-device-config",
drivers/iommu/fsl_pamu.c +1 -1
index a34355fca37a..2570f2a25dc4 100644
@@ -20,11 +20,11 @@
 
 #include "fsl_pamu.h"
 
-#include <linux/fsl/guts.h>
 #include <linux/interrupt.h>
 #include <linux/genalloc.h>
 
 #include <asm/mpc85xx.h>
+#include <asm/fsl_guts.h>
 
 /* define indexes for each operation mapping scenario */
 #define OMI_QMAN        0x00
drivers/net/ethernet/freescale/fman/fman.c +8 -2
index 1de2e1e51c2b..dabee93fcadd 100644
@@ -35,7 +35,6 @@
 #include "fman.h"
 #include "fman_muram.h"
 
-#include <linux/fsl/guts.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/module.h>
@@ -46,6 +45,10 @@
 #include <linux/interrupt.h>
 #include <linux/libfdt_env.h>
 
+#ifdef CONFIG_PPC
+#include <asm/fsl_guts.h>
+#endif
+
 /* General defines */
 #define FMAN_LIODN_TBL			64	/* size of LIODN table */
 #define MAX_NUM_OF_MACS			10
@@ -1889,7 +1892,9 @@ static int fman_reset(struct fman *fman)
 			err = -EBUSY;
 
 		goto _return;
-	} else {
+	}
+#ifdef CONFIG_PPC
+	else {
 		struct device_node *guts_node;
 		struct ccsr_guts __iomem *guts_regs;
 		u32 devdisr2, reg;
@@ -1952,6 +1957,7 @@ guts_node:
 		dev_dbg(fman->dev, "%s: Didn't perform FManV3 reset due to Errata A007273!\n",
 			__func__);
 	}
+#endif
 _return:
 	return err;
 }
sound/soc/fsl/mpc8610_hpcd.c +1 -1
index ddf49f30b23f..73b2b89d4a3e 100644
@@ -12,11 +12,11 @@
 
 #include <linux/module.h>
 #include <linux/interrupt.h>
-#include <linux/fsl/guts.h>
 #include <linux/of_address.h>
 #include <linux/of_device.h>
 #include <linux/slab.h>
 #include <sound/soc.h>
+#include <asm/fsl_guts.h>
 
 #include "fsl_dma.h"
 #include "fsl_ssi.h"
sound/soc/fsl/p1022_ds.c +1 -1
index a1f780ecadf5..a24e04919f71 100644
@@ -11,12 +11,12 @@
  */
 
 #include <linux/module.h>
-#include <linux/fsl/guts.h>
 #include <linux/interrupt.h>
 #include <linux/of_address.h>
 #include <linux/of_device.h>
 #include <linux/slab.h>
 #include <sound/soc.h>
+#include <asm/fsl_guts.h>
 
 #include "fsl_dma.h"
 #include "fsl_ssi.h"
sound/soc/fsl/p1022_rdk.c +1 -1
index d4d88a8cb9c0..d8448887bfda 100644
@@ -18,12 +18,12 @@
  */
 
 #include <linux/module.h>
-#include <linux/fsl/guts.h>
 #include <linux/interrupt.h>
 #include <linux/of_address.h>
 #include <linux/of_device.h>
 #include <linux/slab.h>
 #include <sound/soc.h>
+#include <asm/fsl_guts.h>
 
 #include "fsl_dma.h"
 #include "fsl_ssi.h"
maintainer NAK
#36 lore raw

Re: [PATCH 4/4] Revert "powerpc/fsl: Move fsl_guts.h out of arch/powerpc"

Quoted 6 lines · Arnd Bergmann

All users of this driver are PowerPC specific and the header file has no business in the global include/linux/ hierarchy, so move it back before anyone starts using it on ARM.

This reverts commit 948486544713492f00ac8a9572909101ea892cb0.

Quoted 8 lines

---
This part of the series is not required for the eSDHC quirk, but it restores the asm/fsl_guts.h header so it doesn't accidentally get abused for this in the future. I found two drivers outside of arch/powerpc that already accessed the registers directly, but the functions look fairly contained, and can be easily hidden in an #ifdef CONFIG_PPC

NACK

Besides adding ifdef pollution for no good reason, this register block is used on some ARM chips as well. Why is it a problem if "anyone starts using it on ARM"?

BTW, of all the mailing lists you included on this CC, you seem to have left off the PPC list (I've added it).

-Scott

#37 lore raw

Re: [PATCH 4/4] Revert "powerpc/fsl: Move fsl_guts.h out of arch/powerpc"

Quoted 16 lines · CEST Scott Wood
Quoted 6 lines · Arnd Bergmann

All users of this driver are PowerPC specific and the header file has no business in the global include/linux/ hierarchy, so move it back before anyone starts using it on ARM.

This reverts commit 948486544713492f00ac8a9572909101ea892cb0.

Quoted 8 lines

---
This part of the series is not required for the eSDHC quirk, but it restores the asm/fsl_guts.h header so it doesn't accidentally get abused for this in the future. I found two drivers outside of arch/powerpc that already accessed the registers directly, but the functions look fairly contained, and can be easily hidden in an #ifdef CONFIG_PPC

Quoted 5 lines

NACK

Besides adding ifdef pollution for no good reason, this register block is used on some ARM chips as well. Why is it a problem if "anyone starts using it on ARM"?

It's just not a good interface when it's defined as "this is the layout of a register area that any driver can ioremap() if they can figure out the device node". It's not uncommon to have register areas like that, but normally you have at the minimum a 'syscon' device to handle locking between drivers accessing the same registers and to avoid having to map the same area multiple times.

If we need to use 'guts' registers on ARM, we can find a way to abstract them properly for the given use cases, using a syscon or a driver with exported functions, but just making a PowerPC platform specific header global to all Linux drivers by putting it into include/linux doesn't seem right.

Note that the header file uses a structure definition rather than the more common macros with register offsets, which is fine for a driver that has its own registers and abstracts them, but it doesn't really work with the regmap interface, so if we want to use it with syscon, it also needs to be rewritten.

Quoted 2 lines

BTW, of all the mailing lists you included on this CC, you seem to have left off the PPC list (I've added it).

Sorry, my mistake.

Arnd

maintainer
#38 lore raw

Re: [PATCH 4/4] Revert "powerpc/fsl: Move fsl_guts.h out of arch/powerpc"

Quoted 25 lines · Arnd Bergmann
Quoted 16 lines · CEST Scott Wood
Quoted 6 lines · Arnd Bergmann

All users of this driver are PowerPC specific and the header file has no business in the global include/linux/ hierarchy, so move it back before anyone starts using it on ARM.

This reverts commit 948486544713492f00ac8a9572909101ea892cb0.

Quoted 8 lines

---
This part of the series is not required for the eSDHC quirk, but it restores the asm/fsl_guts.h header so it doesn't accidentally get abused for this in the future. I found two drivers outside of arch/powerpc that already accessed the registers directly, but the functions look fairly contained, and can be easily hidden in an #ifdef CONFIG_PPC

Quoted 7 lines

NACK

Besides adding ifdef pollution for no good reason, this register block is used
on some ARM chips as well. Why is it a problem if "anyone starts using it on
ARM"?

Quoted 3 lines

It's just not a good interface when it's defined as "this is the layout of a register area that any driver can ioremap() if they can figure out the device node".

That's why I want to move accesses into one guts driver.

Quoted 4 lines

It's not uncommon to have register areas like that, but
normally you have at the minimum a 'syscon' device to handle locking between drivers accessing the same registers and to avoid having to map the same area multiple times.

syscon requires device tree changes.

I don't see read-modify-write operations in regmap -- how does locking around an individual, inherently-atomic load or store help?

Quoted 5 lines

If we need to use 'guts' registers on ARM, we can find a way to abstract them properly for the given use cases, using a syscon or a driver with exported functions, but just making a PowerPC platform specific header global to all Linux drivers by putting it into include/linux doesn't seem right.

Again, it's not PowerPC-specific! It started that way but then the same register block got put onto some ARM chips.

It's not global to "all Linux drivers", just the ones that choose to include an fsl-specific header.

If and when all uses of guts are moved into the guts driver, the header can be moved into drivers/soc/fsl.

Quoted 5 lines

Note that the header file uses a structure definition rather than the more common macros with register offsets, which is fine for a driver that has its own registers and abstracts them, but it doesn't really work with the regmap interface, so if we want to use it with syscon, it also needs to be rewritten.

We don't want to use it with syscon. If we did, the solution wouldn't be to move the header back to arch/powerpc, but to convert the struct into offsets.

-Scott

#39 lore raw

Re: [v10, 7/7] mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0

In reply to Arnd Bergmann

Sorry to post in this huge email bunch.

I have most probably hit an errata in Freescale T4240 for PPC_DISABLE_THREADS. I'm using Rev2 - T4240. Is this Errata required to be taken care or not? Any quick help is appreciated!

My issue: I'm running line rate of Traffic to T4240 [10G of traffic on each port of capacity of 10G]; After few hours of running of traffic, My CPU/LMP gets stuck and goes in for Hard reset. When I searched through the code and some open forums, I saw the errata listed above. I'm not sure if that errata works for me or not. I have pasted a snapshot of issue occuring in my system

============================================

During hang, with Softlock up enabled, I get prints from smp_many -> showing ‘every processor is waiting for processor 22’ ; I need to know what happened to processor 22. The processor number keep changing every time when I run the traffic.

Processor 22 goes into a deadlock state with interrupts disabled or it went into a deep idle sleep state is the issue i feel.

If its deep idle state -> a NMI should have recovered it.

But if it’s a deadlock issue with interrupt disabled then I need to know the root cause for the deadlock.

*root@A@0-1-1:~# [ 1602.261011] Current::17 waiting::22 flag::4353 [
1602.720488] Current::14 waiting::22 flag::3585 [ 1602.756404] Current::15
waiting::22 flag::3841 [ 1604.903248] Current::16 waiting::22 flag::4097 [
1619.400917] Current::14 waiting::22 flag::3585 [ 1619.517870] Current::17
waiting::22 flag::4353 [ 1619.749893] Current::15 waiting::22 flag::3841 [
1619.798453] Current::4 waiting::22 flag::1025 [ 1622.177171] Current::16
waiting::22 flag::4097 [ 1622.449412] INFO: rcu_preempt detected stalls on
CPUs/tasks: { 22} (detected by 4, t=21008 jiffies, g=101651, c=101650,
q=4713) [ 1622.460951] Task dump for CPU 22:*

*[ 1622.464275] swapper/22 R running task 0 0 1
0x00000800*

*[ 1622.471355] Call Trace:*

*[ 1622.473820] [c0000001f92b78d0] [000000000000009e] 0x9e (unreliable) [ 1622.480119] [c0000001f92b7960] [c0000001f92b7aa0] 0xc0000001f92b7aa0 [ 1622.486497] [c0000001f92b79e0] [c000000000a90275] 0xc000000000a90275 [ 1622.492878] [c0000001f92b7a60] [c000000000006f64] .do_IRQ+0x184/0x370 [ 1622.499344] [c0000001f92b7b10] [c00000000001b93c] exc_0x500_common+0xfc/0x100 [ 1622.506539] --- Exception: 501 at 0xc000000000a3e200*

*[ 1622.506539] LR = .__check_irq_replay+0x68/0x110*

*[ 1622.516388] [c0000001f92b7e00] [c0000000000bc590]

.cpu_startup_entry+0x1d0/0x350 (unreliable) [ 1622.524950]
[c0000001f92b7ed0] [c000000000a00460] .start_secondary+0x3ec/0x3f4 [

1622.532197] [c0000001f92b7f90] [c00000000000036c] .start_secondary_prolog+0x10/0x14 [ 1635.237829] Current::3 waiting::5 flag::769 [ 1636.587746] Current::14 waiting::22 flag::3585 [ 1637.082117] Current::17 waiting::22 flag::4353 [ 1637.224920] Current::4 waiting::22 flag::1025 [ 1637.268789] Current::15 waiting::22 flag::3841 [ 1640.085792] Current::16 waiting::22 flag::4097 [ 1651.093367] Current::4 waiting::22 flag::1025*

*=============================================================*

Regards,

Kiran

Quoted 119 lines · Arnd Bergmann
Quoted 7 lines · On Thursday 05 May 2016 09:41:32 Yangbo Lu wrote:
Quoted 7 lines

-----Original Message-----
From: Arnd Bergmann [mailto:[email protected]]
Sent: Thursday, May 05, 2016 4:32 PM
To: linuxppc-dev-uLR06cmDAlY/[email protected]
Cc: Yangbo Lu; [email protected]; [email protected]; linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org; [email protected]; [email protected]; [email protected];

iommu-cunTk1MwBs/[email protected]

Quoted 3 lines
Quoted 3 lines

foundation.org; [email protected]; Mark Rutland; [email protected]; Russell King; Bhupesh Sharma; Joerg Roedel; Santosh Shilimkar; Yang-Leo Li; Scott Wood; Rob Herring; Claudiu

Manoil;

Quoted 2 lines
Quoted 2 lines

Kumar Gala; Xiaobo Xie; Qiang Zhao
Subject: Re: [v10, 7/7] mmc: sdhci-of-esdhc: fix host version for

T4240-

Quoted 16 lines
Quoted 16 lines

R1.0-R2.0

Quoted 11 lines · On Thursday 05 May 2016 11:12:30 Yangbo Lu wrote:
drivers/mmc/host/sdhci-of-esdhc.c +9 -0
+       fsl_guts_init();
+       svr = fsl_guts_get_svr();
+       if (svr) {
+               esdhc->soc_ver = SVR_SOC_VER(svr);
+               esdhc->soc_rev = SVR_REV(svr);
+       } else {
+               dev_err(&pdev->dev, "Failed to get SVR value!\n");
+       }
+
Quoted 1 line
Quoted 1 line

Sorry for jumping in again after not participating in the discussion

for

Quoted 6 lines
Quoted 6 lines

the past few versions.

What happened to my suggestion of making this a platform-independent interface to avoid the link time dependency?

Specifically, why not add an exported function to drivers/base/soc.c

that

Quoted 7 lines
Quoted 3 lines

uses glob_match() for comparing a string in the device driver to the ID of the SoC that is set by whatever SoC identifying driver the platform has?

[Lu Yangbo-B47093] I think this has been discussed in v6. You can find Scott's comments about this in below link.
https://patchwork.kernel.org/patch/8544501/

Ah, thanks for bearing with me and digging this out again. Let me follow up on Scott's older replies here then:

Quoted 10 lines
Quoted 3 lines
Quoted 3 lines

IIRC, it is the same IP block as i.MX and Arnd's point is this won't even compile on !PPC. It is things like this that prevent sharing the driver.

The whole point of using the MMIO SVR instead of the PPC SPR is so that it will work on ARM... The guts driver should build on any platform as long as OF is enabled, and if it doesn't find a node to bind to it will return 0 for SVR, and the eSDHC driver will continue (after printing an error that should be removed) without the ability to test for errata based on SVR.

It feels like a bad design to have to come up with a different method for each SoC type here when they all do the same thing and want to identify some variant of the chip to do device specific quirks.

As far as I'm concerned, every driver in drivers/soc that needs to export a symbol to be used by a device driver is an indication that we don't have the right set of abstractions yet. There are cases that are not worth abstracting because the functionality is rather obscure and only a couple of drivers for one particular chip ever need it.

Finding out the version of the SoC does not look like this case.

Quoted 5 lines
Quoted 3 lines

I think the first four patches take care of building for ARM, but the problem remains if you want to enable COMPILE_TEST as we need for certain automated checking.

What specific problem is there with COMPILE_TEST?

COMPILE_TEST is solvable here and the way it is implemented in this case (selecting FSL_GUTS from the driver) indeed looks like it works correctly, but it's still awkward that this means building the SoC specific ID stuff into the vmlinux binary for any driver that uses something like that for a particular SoC.

Quoted 11 lines
Quoted 7 lines
Quoted 2 lines

Dealing with Si revs is a common problem. We should have a common solution. There is soc_device for this purpose.

Exactly. The last time this came up, I think we agreed to implement a helper using glob_match() on the soc_device strings. Unfortunately this hasn't happened then, but I'd still prefer that over yet another vendor-specific way of dealing with the generic issue.

soc_device would require encoding the SVR as a string and then decoding the string, which is more complicated and error prone than having platform-specific code test a platform-specific number.

You already need to encode it as a string to register the soc_device, and the driver just needs to pass a glob string, so the only part that is missing is the generic function that takes the string from the driver and passes that to glob_match for the soc_device.

Quoted 2 lines

And when would it get registered on arm64, which doesn't have platform code?

Whenever the soc driver is loaded, as is the case now. The match function can return -EPROBE_DEFER if no SoC device is registered yet.

Arnd
_______________________________________________
Linuxppc-dev mailing list Linuxppc-dev-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev