Addition of Altera EDAC support.
v9 cover Addition of Altera EDAC support.
From: Thor Thayer <[email protected]>
The Altera SDRAM controller and EDAC support are added in this patch series. The SDRAM controller is an MFD so that multiple drivers can access it's registers.
Thor Thayer (3):
mfd: altera: Add Altera SDRAM Controller
edac: altera: Add Altera EDAC support.
arm: dts: Add Altera SDRAM controller bindings
.../devicetree/bindings/arm/altera/socfpga-sdr.txt | 13 + MAINTAINERS | 6 + arch/arm/boot/dts/socfpga.dtsi | 10 + drivers/edac/Kconfig | 10 + drivers/edac/Makefile | 2 + drivers/edac/altera_edac.c | 293 ++++++++++++++++++++ drivers/mfd/Kconfig | 7 + drivers/mfd/Makefile | 1 + drivers/mfd/altera-sdr.c | 162 +++++++++++ include/linux/mfd/altera-sdr.h | 102 +++++++ 10 files changed, 606 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-sdr.txt create mode 100644 drivers/edac/altera_edac.c create mode 100644 drivers/mfd/altera-sdr.c create mode 100644 include/linux/mfd/altera-sdr.h
Signature · 1 line
1.7.9.5
PATCH v9 1/3 mfd: altera: Add Altera SDRAM Controller
From: Thor Thayer <[email protected]>
Add a simple MFD for the Altera SDRAM Controller.
---
v1-8: The MFD implementation was not included in the original series.
v9: New MFD implementation.
--- MAINTAINERS | 5 ++ drivers/mfd/Kconfig | 7 ++ drivers/mfd/Makefile | 1 + drivers/mfd/altera-sdr.c | 162 ++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/altera-sdr.h | 102 +++++++++++++++++++++++++ 5 files changed, 277 insertions(+) create mode 100644 drivers/mfd/altera-sdr.c create mode 100644 include/linux/mfd/altera-sdr.h
MAINTAINERS +5 -0
@@ -1340,6 +1340,11 @@ M: Dinh Nguyen <[email protected]> S: Maintained F: drivers/clk/socfpga/ +ARM/SOCFPGA SDRAM CONTROLLER SUPPORT +M: Thor Thayer <[email protected]> +S: Maintained +F: drivers/mfd/altera-sdr.c + ARM/STI ARCHITECTURE M: Srinivas Kandagatla <[email protected]> M: Maxime Coquelin <[email protected]>
drivers/mfd/Kconfig +7 -0
@@ -719,6 +719,13 @@ config MFD_STMPE Keypad: stmpe-keypad Touchscreen: stmpe-ts +config MFD_ALTERA_SDR + bool "Altera SDRAM Controller MFD" + depends on ARCH_SOCFPGA + select MFD_CORE + help + Support for Altera SDRAM Controller (SDR) MFD. + menu "STMicroelectronics STMPE Interface Drivers" depends on MFD_STMPE
drivers/mfd/Makefile +1 -0
@@ -169,3 +169,4 @@ obj-$(CONFIG_MFD_AS3711) += as3711.o obj-$(CONFIG_MFD_AS3722) += as3722.o obj-$(CONFIG_MFD_STW481X) += stw481x.o obj-$(CONFIG_MFD_IPAQ_MICRO) += ipaq-micro.o +obj-$(CONFIG_MFD_ALTERA_SDR) += altera-sdr.o
drivers/mfd/altera-sdr.c new file +162 -0
162 lines not on this page · raw message
include/linux/mfd/altera-sdr.h new file +102 -0
102 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v9 2/3 edac: altera: Add Altera EDAC support.
In reply to [email protected]From: Thor Thayer <[email protected]>
This patch adds support for the CycloneV and ArriaV SDRAM controllers. Correction and reporting of SBEs, Panic on DBEs.
---
v2: Use the SDRAM controller registers to calculate memory size
instead of the Device Tree. Update To & Cc list. Add maintainer information.
v3: EDAC driver cleanup based on comments from Mailing list.
v4: Panic on DBE. Add macro around inject-error reads to prevent
them from being optimized out. Remove of_match_ptr since this will always use Device Tree.
v5: Addition of printk to trigger function to ensure read vars
are not optimized out.
v6: Changes to split out shared SDRAM controller reg (offset 0x00)
as a syscon device and allocate ECC specific SDRAM registers to EDAC.
v7: No changes. Bump for consistency.
v8: Alphabetize headers.
v9: Move Altera EDAC driver to use SDRAM MFD device since controller
registers are shared between different drivers.
--- MAINTAINERS | 1 + drivers/edac/Kconfig | 10 ++ drivers/edac/Makefile | 2 + drivers/edac/altera_edac.c | 293 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 306 insertions(+) create mode 100644 drivers/edac/altera_edac.c
MAINTAINERS +1 -0
@@ -1344,6 +1344,7 @@ ARM/SOCFPGA SDRAM CONTROLLER SUPPORT M: Thor Thayer <[email protected]> S: Maintained F: drivers/mfd/altera-sdr.c +F: drivers/edac/altera_edac.c ARM/STI ARCHITECTURE M: Srinivas Kandagatla <[email protected]>
drivers/edac/Kconfig +10 -0
@@ -368,4 +368,14 @@ config EDAC_OCTEON_PCI Support for error detection and correction on the Cavium Octeon family of SOCs. +config EDAC_ALTERA_MC + bool "Altera SDRAM Memory Controller EDAC" + depends on EDAC_MM_EDAC && ARCH_SOCFPGA + select MFD_ALTERA_SDR + help + Support for error detection and correction on the + Altera SDRAM memory controller. Note that the + preloader must initialize the SDRAM before loading + the kernel. + endif # EDAC
drivers/edac/Makefile +2 -0
@@ -64,3 +64,5 @@ obj-$(CONFIG_EDAC_OCTEON_PC) += octeon_edac-pc.o obj-$(CONFIG_EDAC_OCTEON_L2C) += octeon_edac-l2c.o obj-$(CONFIG_EDAC_OCTEON_LMC) += octeon_edac-lmc.o obj-$(CONFIG_EDAC_OCTEON_PCI) += octeon_edac-pci.o + +obj-$(CONFIG_EDAC_ALTERA_MC) += altera_edac.o
drivers/edac/altera_edac.c new file +293 -0
293 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v9 3/3 arm: dts: Add Altera SDRAM controller bindings
In reply to [email protected]From: Thor Thayer <[email protected]>
Add the Altera SDRAM controller bindings and device tree changes to the Altera SoC project.
---
v2: Changes to SoC SDRAM EDAC code.
v3: Implement code suggestions for SDRAM EDAC code.
v4: Remove syscon from SDRAM controller bindings.
v5: No Change, bump version for consistency.
v6: Only map the ctrlcfg register as syscon.
v7: No change. Bump for consistency.
v8: No change. Bump for consistency.
v9: Changes to support a MFD SDRAM controller with nested EDAC.
--- .../devicetree/bindings/arm/altera/socfpga-sdr.txt | 13 +++++++++++++ arch/arm/boot/dts/socfpga.dtsi | 10 ++++++++++ 2 files changed, 23 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-sdr.txt
Documentation/devicetree/bindings/arm/altera/socfpga-sdr.txt new file +13 -0
@@ -0,0 +1,13 @@ +Altera SOCFPGA SDRAM Controller +The SDRAM controller is implemented as a MFD so various drivers may +nest under this main SDRAM controller binding. + +Required properties: +- compatible : "altr,sdr"; +- reg : Should contain 1 register range(address and length) + +Example: + sdr@0xffc25000 { + compatible = "altr,sdr"; + reg = <0xffc25000 0x1000>; + };
arch/arm/boot/dts/socfpga.dtsi +10 -0
@@ -603,6 +603,16 @@ }; }; + sdr@0xffc25000 { + compatible = "altr,sdr"; + reg = <0xffc25000 0x1000>; + + sdramedac@0 { + compatible = "altr,sdram-edac"; + interrupts = <0 39 4>; + }; + }; + L2: l2-cache@fffef000 { compatible = "arm,pl310-cache"; reg = <0xfffef000 0x1000>;
Signature · 1 line
1.7.9.5
Re: [PATCHv9 1/3] mfd: altera: Add Altera SDRAM Controller
In reply to [email protected]Quoted 26 lines · tthayer at opensource.altera.com
From: Thor Thayer <[email protected]>
Add a simple MFD for the Altera SDRAM Controller.
Signed-off-by Alan Tull <[email protected]>Signed-off-by Thor Thayer <[email protected]>---
v1-8: The MFD implementation was not included in the original series.v9: New MFD implementation.
--- MAINTAINERS | 5 ++ drivers/mfd/Kconfig | 7 ++ drivers/mfd/Makefile | 1 + drivers/mfd/altera-sdr.c | 162 ++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/altera-sdr.h | 102 +++++++++++++++++++++++++ 5 files changed, 277 insertions(+) create mode 100644 drivers/mfd/altera-sdr.c create mode 100644 include/linux/mfd/altera-sdr.hMAINTAINERS +0
-0@@ -1340,6 +1340,11 @@ M: Dinh Nguyen <[email protected]> S: Maintained
MAINTAINERS M: Dinh Nguyen <[email protected]> · line 1350
Quoted 10 lines
MAINTAINERS +5
-0F: drivers/clk/socfpga/ +ARM/SOCFPGA SDRAM CONTROLLER SUPPORT +M: Thor Thayer <[email protected]> +S: Maintained +F: drivers/mfd/altera-sdr.c + ARM/STI ARCHITECTURE M: Srinivas Kandagatla <[email protected]> M: Maxime Coquelin <[email protected]>
This should be in a separate patch.
Quoted 39 lines
drivers/mfd/Kconfig +7
-0@@ -719,6 +719,13 @@ config MFD_STMPE Keypad: stmpe-keypad Touchscreen: stmpe-ts +config MFD_ALTERA_SDR + bool "Altera SDRAM Controller MFD" + depends on ARCH_SOCFPGA + select MFD_CORE + help + Support for Altera SDRAM Controller (SDR) MFD. + menu "STMicroelectronics STMPE Interface Drivers" depends on MFD_STMPEdrivers/mfd/Makefile +1
-0@@ -169,3 +169,4 @@ obj-$(CONFIG_MFD_AS3711) += as3711.o obj-$(CONFIG_MFD_AS3722) += as3722.o obj-$(CONFIG_MFD_STW481X) += stw481x.o obj-$(CONFIG_MFD_IPAQ_MICRO) += ipaq-micro.o +obj-$(CONFIG_MFD_ALTERA_SDR) += altera-sdr.odrivers/mfd/altera-sdr.c new file +6
-0@@ -0,0 +1,162 @@ +/* +* SDRAM Controller (SDR) MFD +* +* Copyright (C) 2014 Altera Corporation +* +* This program is free software; you can redistribute it and/or modify it
drivers/mfd/altera-sdr.c line 16
Quoted 10 lines
drivers/mfd/altera-sdr.c new file +10
-0+* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>.
Can you use the shorter version of the licence?
drivers/mfd/altera-sdr.c line 17
Quoted 1 line
drivers/mfd/altera-sdr.c new file +1
-0+*/
'\n' here.
drivers/mfd/altera-sdr.c line 27
Quoted 10 lines
drivers/mfd/altera-sdr.c new file +10
-0+#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/mfd/altera-sdr.h> +#include <linux/mfd/core.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/platform_device.h> + +static const struct mfd_cell altera_sdr_devs[] = { +#if defined(CONFIG_EDAC_ALTERA_MC)
No need to do this, as it will only be matched if the driver is enabled. Please remove the #iffery.
drivers/mfd/altera-sdr.c line 30
Quoted 3 lines
drivers/mfd/altera-sdr.c new file +3
-0+ { + .name = "altr_sdram_edac", + .of_compatible = "altr,sdram-edac",
What other devices will there be?
Quoted 5 lines
drivers/mfd/altera-sdr.c new file +5
-0+ }, +#endif +}; + +u32 altera_sdr_readl (struct altera_sdr *sdr,u32 reg_offset)
drivers/mfd/altera-sdr.c line 45
Quoted 10 lines
drivers/mfd/altera-sdr.c new file +10
-0+{ +return readl (sdr->reg_base + reg_offset); +} +EXPORT_SYMBOL_GPL (altera_sdr_readl); + +void altera_sdr_writel (struct altera_sdr *sdr,u32 reg_offset,u32 value) +{ +writel (value, sdr->reg_base + reg_offset); +} +EXPORT_SYMBOL_GPL (altera_sdr_writel);
Why are you abstracting these?
Might be better to use Regmap even.
drivers/mfd/altera-sdr.c line 51
Quoted 5 lines
drivers/mfd/altera-sdr.c new file +5
-0+/* Get total memory size in bytes */ +u32 altera_sdr_mem_size (struct altera_sdr *sdr) +{ +u32 size; +u32 read_reg, row, bank, col, cs, width;
Weird that size is on its own. Either place on a single line or separate them all.
Quoted 6 lines
drivers/mfd/altera-sdr.c new file +6
-0+ read_reg =altera_sdr_readl (sdr,SDR_DRAMADDRW_OFST ); +if (read_reg <0 ) +return 0 ; + + width =altera_sdr_readl (sdr,SDR_DRAMIFWIDTH_OFST ); +if (width <0 )
drivers/mfd/altera-sdr.c line 68
Quoted 10 lines
drivers/mfd/altera-sdr.c new file +10
-0+return 0 ; + + col = (read_reg &SDR_DRAMADDRW_COLBITS_MASK ) >> +SDR_DRAMADDRW_COLBITS_LSB ; + row = (read_reg &SDR_DRAMADDRW_ROWBITS_MASK ) >> +SDR_DRAMADDRW_ROWBITS_LSB ; + bank = (read_reg &SDR_DRAMADDRW_BANKBITS_MASK ) >> +SDR_DRAMADDRW_BANKBITS_LSB ; + cs = (read_reg &SDR_DRAMADDRW_CSBITS_MASK ) >> +SDR_DRAMADDRW_CSBITS_LSB ;
These would probably be better as macros.
drivers/mfd/altera-sdr.c line 81
Quoted 12 lines
drivers/mfd/altera-sdr.c new file +12
-0+/* Correct for ECC as its not addressible */ +if (width ==SDR_DRAMIFWIDTH_32B_ECC ) + width =32 ; +if (width ==SDR_DRAMIFWIDTH_16B_ECC ) + width =16 ; + +/* calculate the SDRAM size base on this info */ + size =1 << (row + bank + col); + size = size * cs * (width /8 ); +return size; +} +EXPORT_SYMBOL_GPL (altera_sdr_mem_size);
Should this really be done in here? Isn't this an SDRAM function?
Quoted 7 lines
drivers/mfd/altera-sdr.c new file +7
-0+static int altera_sdr_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct altera_sdr *sdr; +struct resource *res; +void __iomem *base; +int ret;
drivers/mfd/altera-sdr.c line 99
Quoted 10 lines
drivers/mfd/altera-sdr.c new file +10
-0+ + sdr =devm_kzalloc (dev,sizeof (*sdr),GFP_KERNEL ); +if (!sdr) +return -ENOMEM ; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) +return -ENOENT ; + + base =devm_ioremap (dev, res->start,resource_size (res));
Instead use devm_ioremap_resource(), then you can omit the error checking of platform_get_resource().
drivers/mfd/altera-sdr.c line 103
Quoted 4 lines
drivers/mfd/altera-sdr.c new file +4
-0+if (!base) +return -ENOMEM ; + + sdr->dev = &pdev->dev;
Either use 'dev' here, or remove the top line in this function and use &pdev->dev everywhere. I personally prefer the latter.
Quoted 7 lines
drivers/mfd/altera-sdr.c new file +7
-0+ sdr->reg_base = base; + + ret =mfd_add_devices (sdr->dev,0 , altera_sdr_devs, +ARRAY_SIZE (altera_sdr_devs),NULL ,0 ,NULL ); +if (ret) +dev_err (sdr->dev,"error adding devices" ); +
drivers/mfd/altera-sdr.c line 120
Quoted 10 lines
drivers/mfd/altera-sdr.c new file +10
-0+platform_set_drvdata (pdev, sdr); + +dev_dbg (dev,"Altera SDR MFD registered\n" ); + +return 0 ; +} + +static int altera_sdr_remove (struct platform_device *pdev) +{ +struct altera_sdr *sdr =platform_get_drvdata (pdev);
No need for this, just use &pdev->dev.
Quoted 4 lines
drivers/mfd/altera-sdr.c new file +4
-0+mfd_remove_devices (sdr->dev); + +return 0 ; +}
drivers/mfd/altera-sdr.c line 135
Quoted 10 lines
drivers/mfd/altera-sdr.c new file +10
-0+ +static const struct of_device_id of_altera_sdr_match[] = { + { .compatible ="altr,sdr" , }, + { }, +}; + +static const struct platform_device_id altera_sdr_ids[] = { + {"altera_sdr" , }, + { } +};
What's this for?
drivers/mfd/altera-sdr.c line 140
Quoted 4 lines
drivers/mfd/altera-sdr.c new file +4
-0+static struct platform_driver altera_sdr_driver = { + .driver = { + .name ="altera_sdr" , + .owner =THIS_MODULE ,
You can remove this line, it's taken care of for you.
drivers/mfd/altera-sdr.c line 152
Quoted 12 lines
drivers/mfd/altera-sdr.c new file +12
-0+ .of_match_table = of_altera_sdr_match, + }, + .probe = altera_sdr_probe, + .remove = altera_sdr_remove, + .id_table = altera_sdr_ids, +}; + +static int __init altera_sdr_init (void ) +{ +return platform_driver_register (&altera_sdr_driver); +} +postcore_initcall (altera_sdr_init);
Why was this chosen?
Quoted 19 lines
drivers/mfd/altera-sdr.c new file +9
-0+static void __exit altera_sdr_exit(void) +{ +platform_driver_unregister (&altera_sdr_driver); +} +module_exit (altera_sdr_exit); + +MODULE_AUTHOR ("Alan Tull <[email protected]>" ); +MODULE_DESCRIPTION ("Altera SDRAM Controller (SDR) MFD" ); +MODULE_LICENSE ("GPL v2" );include/linux/mfd/altera-sdr.h new file +4
-0@@ -0,0 +1,102 @@ +/* +* Copyright (C) 2014 Altera Corporation +* +* This program is free software; you can redistribute it and/or modify it
include/linux/mfd/altera-sdr.h line 14
Quoted 10 lines
include/linux/mfd/altera-sdr.h new file +10
-0+* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>.
Use the short version.
include/linux/mfd/altera-sdr.h line 15
Quoted 1 line
include/linux/mfd/altera-sdr.h new file +1
-0+*/
'\n' here.
Quoted 25 lines
include/linux/mfd/altera-sdr.h new file +25
-0+#ifndef __LINUX_MFD_ALTERA_SDR_H +#define __LINUX_MFD_ALTERA_SDR_H + +/* SDRAM Controller register offsets */ +#define SDR_CTLCFG_OFST 0x00 +#define SDR_DRAMADDRW_OFST 0x2C +#define SDR_DRAMIFWIDTH_OFST 0x30 +#define SDR_DRAMSTS_OFST 0x38 +#define SDR_DRAMINTR_OFST 0x3C +#define SDR_SBECOUNT_OFST 0x40 +#define SDR_DBECOUNT_OFST 0x44 +#define SDR_ERRADDR_OFST 0x48 +#define SDR_DROPCOUNT_OFST 0x4C +#define SDR_DROPADDR_OFST 0x50 +#define SDR_CTRLGRP_LOWPWREQ_OFST 0x54 +#define SDR_CTRLGRP_LOWPWRACK_OFST 0x58 + +/* SDRAM Controller CtrlCfg Register Bit Masks */ +#define SDR_CTLCFG_ECC_EN 0x400 +#define SDR_CTLCFG_ECC_CORR_EN 0x800 +#define SDR_CTLCFG_GEN_SB_ERR 0x2000 +#define SDR_CTLCFG_GEN_DB_ERR 0x4000 + +#define SDR_CTLCFG_ECC_AUTO_EN (SDR_CTLCFG_ECC_EN | \ + SDR_CTLCFG_ECC_CORR_EN)
include/linux/mfd/altera-sdr.h line 50
Quoted 10 lines
include/linux/mfd/altera-sdr.h new file +10
-0+ +/* SDRAM Controller Address Widths Field Register */ +#define SDR_DRAMADDRW_COLBITS_MASK 0x001F +#define SDR_DRAMADDRW_COLBITS_LSB 0 +#define SDR_DRAMADDRW_ROWBITS_MASK 0x03E0 +#define SDR_DRAMADDRW_ROWBITS_LSB 5 +#define SDR_DRAMADDRW_BANKBITS_MASK 0x1C00 +#define SDR_DRAMADDRW_BANKBITS_LSB 10 +#define SDR_DRAMADDRW_CSBITS_MASK 0xE000 +#define SDR_DRAMADDRW_CSBITS_LSB 13
We normally call _LSB, _SHIFT.
Quoted 38 lines
include/linux/mfd/altera-sdr.h new file +38
-0+/* SDRAM Controller Interface Data Width Defines */ +#define SDR_DRAMIFWIDTH_16B_ECC 24 +#define SDR_DRAMIFWIDTH_32B_ECC 40 + +/* SDRAM Controller DRAM Status Register Bit Masks */ +#define SDR_DRAMSTS_SBEERR 0x04 +#define SDR_DRAMSTS_DBEERR 0x08 +#define SDR_DRAMSTS_CORR_DROP 0x10 + +/* SDRAM Controller DRAM IRQ Register Bit Masks */ +#define SDR_DRAMINTR_INTREN 0x01 +#define SDR_DRAMINTR_SBEMASK 0x02 +#define SDR_DRAMINTR_DBEMASK 0x04 +#define SDR_DRAMINTR_CORRDROPMASK 0x08 +#define SDR_DRAMINTR_INTRCLR 0x10 + +/* SDRAM Controller Single Bit Error Count Register Bit Masks */ +#define SDR_SBECOUNT_COUNT_MASK 0x0F + +/* SDRAM Controller Double Bit Error Count Register Bit Masks */ +#define SDR_DBECOUNT_COUNT_MASK 0x0F + +/* SDRAM Controller ECC Error Address Register Bit Masks */ +#define SDR_ERRADDR_ADDR_MASK 0xFFFFFFFF + +/* SDRAM Controller ECC Autocorrect Drop Count Register Bit Masks */ +#define SDR_DROPCOUNT_CORRMASK 0x0F + +/* SDRAM Controller ECC AutoCorrect Error Address Register Bit Masks */ +#define SDR_DROPADDR_ADDR_MASK 0xFFFFFFFF + +#define SELFRSHREQ_POS 3 +#define SELFRSHREQ_MASK 0x8 + +#define SELFRFSHMASK_POS 4 +#define SELFRFSHMASK_MASK 0x30 + +#define SELFRFSHACK_POS 1
include/linux/mfd/altera-sdr.h line 99
Quoted 10 lines
include/linux/mfd/altera-sdr.h new file +10
-0+#define SELFRFSHACK_MASK 0x2 + +struct altera_sdr { +struct device *dev; +void __iomem *reg_base; +}; + +/* Register access API */ +u32 altera_sdr_readl (struct altera_sdr *sdr,u32 reg_offset); +void altera_sdr_writel (struct altera_sdr *sdr,u32 reg_offset,u32 value);
Regmap?
Quoted 3 lines
include/linux/mfd/altera-sdr.h new file +3
-0+u32 altera_sdr_mem_size (struct altera_sdr *sdr); + +#endif /* __LINUX_MFD_ALTERA_SDR_H */
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCHv9 1/3] mfd: altera: Add Altera SDRAM Controller
Quoted 30 lines · Lee Jones
Quoted 28 lines · On Wed, 30 Jul 2014, [email protected] wrote:
From: Thor Thayer <[email protected]>
Add a simple MFD for the Altera SDRAM Controller.
Signed-off-by Alan Tull <[email protected]>Signed-off-by Thor Thayer <[email protected]>---
v1-8: The MFD implementation was not included in the original series.v9: New MFD implementation.
--- MAINTAINERS | 5 ++ drivers/mfd/Kconfig | 7 ++ drivers/mfd/Makefile | 1 + drivers/mfd/altera-sdr.c | 162 ++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/altera-sdr.h | 102 +++++++++++++++++++++++++ 5 files changed, 277 insertions(+)create mode 100644
drivers/mfd/altera-sdr.ccreate mode 100644include/linux/mfd/altera-sdr.hMAINTAINERS +0
-0@@ -1340,6 +1340,11 @@ M: Dinh Nguyen <[email protected]> S: Maintained F: drivers/clk/socfpga/
Quoted 9 lines
MAINTAINERS M: Dinh Nguyen <[email protected]> · line 1350
Quoted 8 lines
MAINTAINERS +5
-0+ARM/SOCFPGA SDRAM CONTROLLER SUPPORT +M: Thor Thayer <[email protected]> +S: Maintained +F: drivers/mfd/altera-sdr.c + ARM/STI ARCHITECTURE M: Srinivas Kandagatla <[email protected]> M: Maxime Coquelin <[email protected]>This should be in a separate patch.
OK. Thanks for your comments and for reviewing. I will move this into a separate patch.
Quoted 42 lines
Quoted 42 lines
drivers/mfd/Kconfig +7
-0@@ -719,6 +719,13 @@ config MFD_STMPE Keypad: stmpe-keypad Touchscreen: stmpe-ts +config MFD_ALTERA_SDR + bool "Altera SDRAM Controller MFD" + depends on ARCH_SOCFPGA + select MFD_CORE + help + Support for Altera SDRAM Controller (SDR) MFD. + menu "STMicroelectronics STMPE Interface Drivers" depends on MFD_STMPEdrivers/mfd/Makefile +1
-0@@ -169,3 +169,4 @@ obj-$(CONFIG_MFD_AS3711) += as3711.o obj-$(CONFIG_MFD_AS3722) += as3722.o obj-$(CONFIG_MFD_STW481X) += stw481x.o obj-$(CONFIG_MFD_IPAQ_MICRO) += ipaq-micro.o +obj-$(CONFIG_MFD_ALTERA_SDR) += altera-sdr.odrivers/mfd/altera-sdr.c new file +9
-0@@ -0,0 +1,162 @@ +/* +* SDRAM Controller (SDR) MFD +* +* Copyright (C) 2014 Altera Corporation +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +*
Quoted 8 lines
drivers/mfd/altera-sdr.c line 16
Quoted 7 lines
drivers/mfd/altera-sdr.c new file +7
-0+* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. Can you use the shorter version of the licence?
Hi. This seems to be the shorter version of the license agreement and is fairly common in the kernel, right?
Quoted 2 lines
drivers/mfd/altera-sdr.c line 17
Quoted 1 line
drivers/mfd/altera-sdr.c new file +1
-0+*/ '\n' here.
OK.
Quoted 4 lines
Quoted 4 lines
drivers/mfd/altera-sdr.c new file +4
-0+#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/mfd/altera-sdr.h> +#include <linux/mfd/core.h>
Quoted 8 lines
drivers/mfd/altera-sdr.c line 27
Quoted 6 lines
drivers/mfd/altera-sdr.c new file +6
-0+#include <linux/module.h> +#include <linux/of.h> +#include <linux/platform_device.h> + +static const struct mfd_cell altera_sdr_devs[] = { +#if defined(CONFIG_EDAC_ALTERA_MC)No need to do this, as it will only be matched if the driver is enabled. Please remove the #iffery.
OK. Will remove.
Quoted 5 lines
drivers/mfd/altera-sdr.c line 30
Quoted 3 lines
drivers/mfd/altera-sdr.c new file +3
-0+ { + .name = "altr_sdram_edac", + .of_compatible = "altr,sdram-edac",What other devices will there be?
There will be an FPGA bridge and a power control driver that will need access to the SDR Controller registers.
Quoted 17 lines
Quoted 5 lines
drivers/mfd/altera-sdr.c new file +5
-0+ }, +#endif +}; + +u32 altera_sdr_readl (struct altera_sdr *sdr,u32 reg_offset)drivers/mfd/altera-sdr.c line 45
Quoted 10 lines
drivers/mfd/altera-sdr.c new file +10
-0+{ +return readl (sdr->reg_base + reg_offset); +} +EXPORT_SYMBOL_GPL (altera_sdr_readl); + +void altera_sdr_writel (struct altera_sdr *sdr,u32 reg_offset,u32 value) +{ +writel (value, sdr->reg_base + reg_offset); +} +EXPORT_SYMBOL_GPL (altera_sdr_writel);Why are you abstracting these?
Quoted 1 line
Might be better to use Regmap even.
regmap seems unnecessarily complex for what we're doing which is why this method was chosen.
Future drivers will access different sets of registers in the device. These drivers won't share bitfields in the same register so the MFD seemed like the best solution. Originally we implemented this using syscon but that seems to be frowned upon so we changed to using a MFD.
Quoted 7 lines
drivers/mfd/altera-sdr.c line 51
Quoted 5 lines
drivers/mfd/altera-sdr.c new file +5
-0+/* Get total memory size in bytes */ +u32 altera_sdr_mem_size (struct altera_sdr *sdr) +{ +u32 size; +u32 read_reg, row, bank, col, cs, width;Weird that size is on its own. Either place on a single line or separate them all.
OK. I will change this.
Quoted 9 lines
Quoted 9 lines
drivers/mfd/altera-sdr.c new file +9
-0+ read_reg =altera_sdr_readl (sdr,SDR_DRAMADDRW_OFST ); +if (read_reg <0 ) +return 0 ; + + width =altera_sdr_readl (sdr,SDR_DRAMIFWIDTH_OFST ); +if (width <0 ) +return 0 ; + + col = (read_reg & SDR_DRAMADDRW_COLBITS_MASK) >>
Quoted 9 lines
drivers/mfd/altera-sdr.c line 68
Quoted 7 lines
drivers/mfd/altera-sdr.c new file +7
-0+SDR_DRAMADDRW_COLBITS_LSB ; + row = (read_reg &SDR_DRAMADDRW_ROWBITS_MASK ) >> +SDR_DRAMADDRW_ROWBITS_LSB ; + bank = (read_reg &SDR_DRAMADDRW_BANKBITS_MASK ) >> +SDR_DRAMADDRW_BANKBITS_LSB ; + cs = (read_reg &SDR_DRAMADDRW_CSBITS_MASK ) >> +SDR_DRAMADDRW_CSBITS_LSB ;These would probably be better as macros.
OK. I will fix this.
Quoted 5 lines
Quoted 5 lines
drivers/mfd/altera-sdr.c new file +5
-0+/* Correct for ECC as its not addressible */ +if (width ==SDR_DRAMIFWIDTH_32B_ECC ) + width =32 ; +if (width ==SDR_DRAMIFWIDTH_16B_ECC ) + width =16 ;
Quoted 9 lines
drivers/mfd/altera-sdr.c line 81
Quoted 7 lines
drivers/mfd/altera-sdr.c new file +7
-0+ +/* calculate the SDRAM size base on this info */ + size =1 << (row + bank + col); + size = size * cs * (width /8 ); +return size; +} +EXPORT_SYMBOL_GPL (altera_sdr_mem_size);Should this really be done in here? Isn't this an SDRAM function?
This register is part of the SDRAM controller and size information may be required by the other drivers that share this memory area/need SDRAM information.
Quoted 11 lines
Quoted 11 lines
drivers/mfd/altera-sdr.c new file +11
-0+static int altera_sdr_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct altera_sdr *sdr; +struct resource *res; +void __iomem *base; +int ret; + + sdr =devm_kzalloc (dev,sizeof (*sdr),GFP_KERNEL ); +if (!sdr) +return -ENOMEM ;
Quoted 8 lines
drivers/mfd/altera-sdr.c line 99
Quoted 6 lines
drivers/mfd/altera-sdr.c new file +6
-0+ + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) +return -ENOENT ; + + base =devm_ioremap (dev, res->start,resource_size (res));Instead use
devm_ioremap_resource(), then you can omit the error checking ofplatform_get_resource().
OK. Thanks. I will make the change.
Quoted 6 lines
drivers/mfd/altera-sdr.c line 103
Quoted 4 lines
drivers/mfd/altera-sdr.c new file +4
-0+if (!base) +return -ENOMEM ; + + sdr->dev = &pdev->dev;Either use 'dev' here, or remove the top line in this function and use
&pdev->deveverywhere. I personally prefer the latter.
OK. I will use the latter.
Quoted 10 lines
Quoted 10 lines
drivers/mfd/altera-sdr.c new file +10
-0+ sdr->reg_base = base; + + ret =mfd_add_devices (sdr->dev,0 , altera_sdr_devs, +ARRAY_SIZE (altera_sdr_devs),NULL ,0 ,NULL ); +if (ret) +dev_err (sdr->dev,"error adding devices" ); + +platform_set_drvdata (pdev, sdr); + +dev_dbg (dev,"Altera SDR MFD registered\n" );
Quoted 8 lines
drivers/mfd/altera-sdr.c line 120
Quoted 7 lines
drivers/mfd/altera-sdr.c new file +7
-0+ +return 0 ; +} + +static int altera_sdr_remove (struct platform_device *pdev) +{ +struct altera_sdr *sdr =platform_get_drvdata (pdev);No need for this, just use
&pdev->dev.
OK. I will make the change.
Quoted 7 lines
Quoted 7 lines
drivers/mfd/altera-sdr.c new file +7
-0+mfd_remove_devices (sdr->dev); + +return 0 ; +} + +static const struct of_device_id of_altera_sdr_match[] = { + { .compatible ="altr,sdr" , },
Quoted 8 lines
drivers/mfd/altera-sdr.c line 135
Quoted 7 lines
drivers/mfd/altera-sdr.c new file +7
-0+ { }, +}; + +static const struct platform_device_id altera_sdr_ids[] = { + {"altera_sdr" , }, + { } +};What's this for?
We don't strictly need it because we are driven by the device tree. It can be removed it if is a problem but I'm not clear why it is a problem.
Quoted 5 lines
drivers/mfd/altera-sdr.c line 140
Quoted 4 lines
drivers/mfd/altera-sdr.c new file +4
-0+static struct platform_driver altera_sdr_driver = { + .driver = { + .name ="altera_sdr" , + .owner =THIS_MODULE ,You can remove this line, it's taken care of for you.
I will remove the .owner line.
Quoted 5 lines
Quoted 5 lines
drivers/mfd/altera-sdr.c new file +5
-0+ .of_match_table = of_altera_sdr_match, + }, + .probe = altera_sdr_probe, + .remove = altera_sdr_remove, + .id_table = altera_sdr_ids,
Quoted 8 lines
drivers/mfd/altera-sdr.c line 152
Quoted 7 lines
drivers/mfd/altera-sdr.c new file +7
-0+}; + +static int __init altera_sdr_init (void ) +{ +return platform_driver_register (&altera_sdr_driver); +} +postcore_initcall (altera_sdr_init);Why was this chosen?
We want this to happen pretty early.
Quoted 22 lines
Quoted 22 lines
drivers/mfd/altera-sdr.c new file +9
-0+static void __exit altera_sdr_exit(void) +{ +platform_driver_unregister (&altera_sdr_driver); +} +module_exit (altera_sdr_exit); + +MODULE_AUTHOR ("Alan Tull <[email protected]>" ); +MODULE_DESCRIPTION ("Altera SDRAM Controller (SDR) MFD" ); +MODULE_LICENSE ("GPL v2" );include/linux/mfd/altera-sdr.h new file +7
-0@@ -0,0 +1,102 @@ +/* +* Copyright (C) 2014 Altera Corporation +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +*
Quoted 8 lines
include/linux/mfd/altera-sdr.h line 14
Quoted 7 lines
include/linux/mfd/altera-sdr.h new file +7
-0+* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. Use the short version.
Same as above. This is the shorter version that we've been using at Altera.
Quoted 2 lines
include/linux/mfd/altera-sdr.h line 15
Quoted 1 line
include/linux/mfd/altera-sdr.h new file +1
-0+*/ '\n' here.
OK.
Quoted 28 lines
Quoted 28 lines
include/linux/mfd/altera-sdr.h new file +28
-0+#ifndef __LINUX_MFD_ALTERA_SDR_H +#define __LINUX_MFD_ALTERA_SDR_H + +/* SDRAM Controller register offsets */ +#define SDR_CTLCFG_OFST 0x00 +#define SDR_DRAMADDRW_OFST 0x2C +#define SDR_DRAMIFWIDTH_OFST 0x30 +#define SDR_DRAMSTS_OFST 0x38 +#define SDR_DRAMINTR_OFST 0x3C +#define SDR_SBECOUNT_OFST 0x40 +#define SDR_DBECOUNT_OFST 0x44 +#define SDR_ERRADDR_OFST 0x48 +#define SDR_DROPCOUNT_OFST 0x4C +#define SDR_DROPADDR_OFST 0x50 +#define SDR_CTRLGRP_LOWPWREQ_OFST 0x54 +#define SDR_CTRLGRP_LOWPWRACK_OFST 0x58 + +/* SDRAM Controller CtrlCfg Register Bit Masks */ +#define SDR_CTLCFG_ECC_EN 0x400 +#define SDR_CTLCFG_ECC_CORR_EN 0x800 +#define SDR_CTLCFG_GEN_SB_ERR 0x2000 +#define SDR_CTLCFG_GEN_DB_ERR 0x4000 + +#define SDR_CTLCFG_ECC_AUTO_EN (SDR_CTLCFG_ECC_EN | \ + SDR_CTLCFG_ECC_CORR_EN) + +/* SDRAM Controller Address Widths Field Register */ +#define SDR_DRAMADDRW_COLBITS_MASK 0x001F
Quoted 8 lines
include/linux/mfd/altera-sdr.h line 50
Quoted 7 lines
include/linux/mfd/altera-sdr.h new file +7
-0+#define SDR_DRAMADDRW_COLBITS_LSB 0 +#define SDR_DRAMADDRW_ROWBITS_MASK 0x03E0 +#define SDR_DRAMADDRW_ROWBITS_LSB 5 +#define SDR_DRAMADDRW_BANKBITS_MASK 0x1C00 +#define SDR_DRAMADDRW_BANKBITS_LSB 10 +#define SDR_DRAMADDRW_CSBITS_MASK 0xE000 +#define SDR_DRAMADDRW_CSBITS_LSB 13We normally call
_LSB,_SHIFT.
OK. I will change.
Quoted 41 lines
Quoted 41 lines
include/linux/mfd/altera-sdr.h new file +41
-0+/* SDRAM Controller Interface Data Width Defines */ +#define SDR_DRAMIFWIDTH_16B_ECC 24 +#define SDR_DRAMIFWIDTH_32B_ECC 40 + +/* SDRAM Controller DRAM Status Register Bit Masks */ +#define SDR_DRAMSTS_SBEERR 0x04 +#define SDR_DRAMSTS_DBEERR 0x08 +#define SDR_DRAMSTS_CORR_DROP 0x10 + +/* SDRAM Controller DRAM IRQ Register Bit Masks */ +#define SDR_DRAMINTR_INTREN 0x01 +#define SDR_DRAMINTR_SBEMASK 0x02 +#define SDR_DRAMINTR_DBEMASK 0x04 +#define SDR_DRAMINTR_CORRDROPMASK 0x08 +#define SDR_DRAMINTR_INTRCLR 0x10 + +/* SDRAM Controller Single Bit Error Count Register Bit Masks */ +#define SDR_SBECOUNT_COUNT_MASK 0x0F + +/* SDRAM Controller Double Bit Error Count Register Bit Masks */ +#define SDR_DBECOUNT_COUNT_MASK 0x0F + +/* SDRAM Controller ECC Error Address Register Bit Masks */ +#define SDR_ERRADDR_ADDR_MASK 0xFFFFFFFF + +/* SDRAM Controller ECC Autocorrect Drop Count Register Bit Masks */ +#define SDR_DROPCOUNT_CORRMASK 0x0F + +/* SDRAM Controller ECC AutoCorrect Error Address Register Bit Masks */ +#define SDR_DROPADDR_ADDR_MASK 0xFFFFFFFF + +#define SELFRSHREQ_POS 3 +#define SELFRSHREQ_MASK 0x8 + +#define SELFRFSHMASK_POS 4 +#define SELFRFSHMASK_MASK 0x30 + +#define SELFRFSHACK_POS 1 +#define SELFRFSHACK_MASK 0x2 + +struct altera_sdr {
Quoted 8 lines
include/linux/mfd/altera-sdr.h line 99
Quoted 7 lines
include/linux/mfd/altera-sdr.h new file +7
-0+struct device *dev; +void __iomem *reg_base; +}; + +/* Register access API */ +u32 altera_sdr_readl (struct altera_sdr *sdr,u32 reg_offset); +void altera_sdr_writel (struct altera_sdr *sdr,u32 reg_offset,u32 value);Regmap?
Same as above. This seems to be more complex than we need.
Thanks for your comments and for reviewing!
Thor
Quoted 3 lines
Quoted 3 lines
include/linux/mfd/altera-sdr.h new file +3
-0+u32 altera_sdr_mem_size (struct altera_sdr *sdr); + +#endif /* __LINUX_MFD_ALTERA_SDR_H */
Re: [PATCHv9 1/3] mfd: altera: Add Altera SDRAM Controller
Quoted 22 lines · Thor Thayer
Quoted 21 lines · Lee Jones
Quoted 19 lines · tthayer at opensource.altera.com
From: Thor Thayer <[email protected]>
Add a simple MFD for the Altera SDRAM Controller.
Signed-off-by Alan Tull <[email protected]>Signed-off-by Thor Thayer <[email protected]>---
v1-8: The MFD implementation was not included in the original series.v9: New MFD implementation.
--- MAINTAINERS | 5 ++ drivers/mfd/Kconfig | 7 ++ drivers/mfd/Makefile | 1 + drivers/mfd/altera-sdr.c | 162 ++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/altera-sdr.h | 102 +++++++++++++++++++++++++ 5 files changed, 277 insertions(+) create mode 100644 drivers/mfd/altera-sdr.c create mode 100644 include/linux/mfd/altera-sdr.h
[...]
Quoted 19 lines
Quoted 11 lines
Quoted 11 lines
+++
b/drivers/mfd/altera-sdr.cdrivers/mfd/altera-sdr.c new file +9
-0@@ -0,0 +1,162 @@ +/* +* SDRAM Controller (SDR) MFD +* +* Copyright (C) 2014 Altera Corporation +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* Quoted 8 lines
drivers/mfd/altera-sdr.c line 16
Quoted 7 lines
drivers/mfd/altera-sdr.c new file +7
-0+* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. Can you use the shorter version of the licence?
Quoted 2 lines
Hi. This seems to be the shorter version of the license agreement and is fairly common in the kernel, right?
This is the long(ish) version. Many programs have the Copyright line and the "This program is free software;" line. It'll also be a good idea to keep the link to the full licence.
[...]
Quoted 7 lines
Quoted 5 lines
drivers/mfd/altera-sdr.c line 30
Quoted 3 lines
drivers/mfd/altera-sdr.c new file +3
-0+ { + .name = "altr_sdram_edac", + .of_compatible = "altr,sdram-edac",What other devices will there be?
There will be an FPGA bridge and a power control driver that will need access to the SDR Controller registers.
Okay. Do you know when they'll be upstreamed?
Quoted 14 lines
Quoted 13 lines
drivers/mfd/altera-sdr.c line 45
Quoted 11 lines
drivers/mfd/altera-sdr.c new file +11
-0+u32 altera_sdr_readl (struct altera_sdr *sdr,u32 reg_offset) +{ +return readl (sdr->reg_base + reg_offset); +} +EXPORT_SYMBOL_GPL (altera_sdr_readl); + +void altera_sdr_writel (struct altera_sdr *sdr,u32 reg_offset,u32 value) +{ +writel (value, sdr->reg_base + reg_offset); +} +EXPORT_SYMBOL_GPL (altera_sdr_writel);Why are you abstracting these?
Quoted 1 line
Might be better to use Regmap even.
Quoted 8 lines
regmap seems unnecessarily complex for what we're doing which is why this method was chosen.
Future drivers will access different sets of registers in the device. These drivers won't share bitfields in the same register so the MFD seemed like the best solution. Originally we implemented this using syscon but that seems to be frowned upon so we changed to using a MFD.
Why was the use of syscon frowned upon? Can you link me to the thread? Writing directly to the registers sounds to me a lot worse than using infrastructure which was designed for these kinds of accesses.
If you do choose to fiddle with the registers in this manner, is there any reason why you're calling back into here, rather than using readl() and writel() directly?
Quoted 6 lines
Quoted 6 lines
drivers/mfd/altera-sdr.c line 51
Quoted 4 lines
drivers/mfd/altera-sdr.c new file +4
-0+u32 altera_sdr_mem_size (struct altera_sdr *sdr) +{ +u32 size; +u32 read_reg, row, bank, col, cs, width;Weird that size is on its own. Either place on a single line or separate them all.
Quoted 8 lines
OK. I will change this.
Quoted 7 lines
drivers/mfd/altera-sdr.c line 59
Quoted 7 lines
drivers/mfd/altera-sdr.c new file +7
-0+ read_reg =altera_sdr_readl (sdr,SDR_DRAMADDRW_OFST ); +if (read_reg <0 ) +return 0 ; + + width =altera_sdr_readl (sdr,SDR_DRAMIFWIDTH_OFST ); +if (width <0 ) +return 0 ;
u32s cant be < 0. The 'u' means 'unsigned'.
Quoted 25 lines
Quoted 10 lines
drivers/mfd/altera-sdr.c line 68
Quoted 8 lines
drivers/mfd/altera-sdr.c new file +8
-0+ col = (read_reg &SDR_DRAMADDRW_COLBITS_MASK ) >> +SDR_DRAMADDRW_COLBITS_LSB ; + row = (read_reg &SDR_DRAMADDRW_ROWBITS_MASK ) >> +SDR_DRAMADDRW_ROWBITS_LSB ; + bank = (read_reg &SDR_DRAMADDRW_BANKBITS_MASK ) >> +SDR_DRAMADDRW_BANKBITS_LSB ; + cs = (read_reg &SDR_DRAMADDRW_CSBITS_MASK ) >> +SDR_DRAMADDRW_CSBITS_LSB ;These would probably be better as macros.
OK. I will fix this.
Quoted 5 lines
Quoted 5 lines
drivers/mfd/altera-sdr.c new file +5
-0+/* Correct for ECC as its not addressible */ +if (width ==SDR_DRAMIFWIDTH_32B_ECC ) + width =32 ; +if (width ==SDR_DRAMIFWIDTH_16B_ECC ) + width =16 ;Quoted 9 lines
drivers/mfd/altera-sdr.c line 81
Quoted 7 lines
drivers/mfd/altera-sdr.c new file +7
-0+ +/* calculate the SDRAM size base on this info */ + size =1 << (row + bank + col); + size = size * cs * (width /8 ); +return size; +} +EXPORT_SYMBOL_GPL (altera_sdr_mem_size);Should this really be done in here? Isn't this an SDRAM function?
Quoted 3 lines
This register is part of the SDRAM controller and size information may be required by the other drivers that share this memory area/need SDRAM information.
Then export a function from the SDRAM driver, not from here.
[...]
Quoted 8 lines
Quoted 5 lines
drivers/mfd/altera-sdr.c line 135
Quoted 4 lines
drivers/mfd/altera-sdr.c new file +4
-0+static const struct platform_device_id altera_sdr_ids[] = { + {"altera_sdr" , }, + { } +};What's this for?
We don't strictly need it because we are driven by the device tree. It can be removed it if is a problem but I'm not clear why it is a problem.
It's a problem because it's unused, superfluous bumph. :)
[...]
Quoted 7 lines
Quoted 6 lines
drivers/mfd/altera-sdr.c line 152
Quoted 5 lines
drivers/mfd/altera-sdr.c new file +5
-0+static int __init altera_sdr_init (void ) +{ +return platform_driver_register (&altera_sdr_driver); +} +postcore_initcall (altera_sdr_init);Why was this chosen?
We want this to happen pretty early.
If you _need_ this is happen early, core_initcall() is more commonly used, but _why_ do you need it to happen this early?
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/mfd/altera-sdr.c new file +14
-0+/* +* Copyright (C) 2014 Altera Corporation +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>.
Quoted 2 lines
Quoted 1 line
Use the short version.
Same as above. This is the shorter version that we've been using at Altera.
If you read COPYING, you only require the Copyright line and a link to the full licence. In this case I'll be happy if you left in the "This program is free software;" line as well, but remove the paragraph below it.
[...]
Quoted 5 lines
Quoted 4 lines
include/linux/mfd/altera-sdr.h line 99
Quoted 3 lines
include/linux/mfd/altera-sdr.h new file +3
-0+/* Register access API */ +u32 altera_sdr_readl (struct altera_sdr *sdr,u32 reg_offset); +void altera_sdr_writel (struct altera_sdr *sdr,u32 reg_offset,u32 value);Regmap?
Same as above. This seems to be more complex than we need.
I'm not sure I believe that. Regmap is as complex or as simple as you need.
Quoted 3 lines
Thanks for your comments and for reviewing!
Thor
You're welcome. OOI, do you own a hammer? ;)
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCHv9 1/3] mfd: altera: Add Altera SDRAM Controller
Quoted 44 lines · Lee Jones
Quoted 22 lines · Thor Thayer
Quoted 21 lines · Lee Jones
Quoted 19 lines · On Wed, 30 Jul 2014, [email protected] wrote:
From: Thor Thayer <[email protected]>
Add a simple MFD for the Altera SDRAM Controller.
Signed-off-by Alan Tull <[email protected]>Signed-off-by Thor Thayer <[email protected]>---
v1-8: The MFD implementation was not included in the original series.v9: New MFD implementation.
--- MAINTAINERS | 5 ++ drivers/mfd/Kconfig | 7 ++ drivers/mfd/Makefile | 1 + drivers/mfd/altera-sdr.c | 162 ++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/altera-sdr.h | 102 +++++++++++++++++++++++++ 5 files changed, 277 insertions(+)create mode 100644
drivers/mfd/altera-sdr.ccreate mode 100644include/linux/mfd/altera-sdr.h[...]
Quoted 19 lines
Quoted 19 lines
Quoted 8 lines
+++
b/drivers/mfd/altera-sdr.cdrivers/mfd/altera-sdr.c new file +6
-0@@ -0,0 +1,162 @@ +/* +* SDRAM Controller (SDR) MFD +* +* Copyright (C) 2014 Altera Corporation +* +* This program is free software; you can redistribute it and/or modify it drivers/mfd/altera-sdr.c line 16
Quoted 10 lines
drivers/mfd/altera-sdr.c new file +10
-0+* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. Can you use the shorter version of the licence?
Quoted 7 lines
Quoted 2 lines
Hi. This seems to be the shorter version of the license agreement and is fairly common in the kernel, right?
This is the long(ish) version. Many programs have the Copyright line and the "This program is free software;" line. It'll also be a good idea to keep the link to the full licence.
[...]
Hi Lee.
Our legal department requires this header. Their reasoning is that they want to retain the rights and warranty language with the file (just in case the COPYING file changes).
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
drivers/mfd/altera-sdr.c line 30
Quoted 3 lines
drivers/mfd/altera-sdr.c new file +3
-0+ { + .name = "altr_sdram_edac", + .of_compatible = "altr,sdram-edac",What other devices will there be?
There will be an FPGA bridge and a power control driver that will need access to the SDR Controller registers.
Okay. Do you know when they'll be upstreamed?
The other drivers are waiting on this file as a pre-requisite.
Quoted 22 lines
Quoted 14 lines
Quoted 13 lines
drivers/mfd/altera-sdr.c line 45
Quoted 11 lines
drivers/mfd/altera-sdr.c new file +11
-0+u32 altera_sdr_readl (struct altera_sdr *sdr,u32 reg_offset) +{ +return readl (sdr->reg_base + reg_offset); +} +EXPORT_SYMBOL_GPL (altera_sdr_readl); + +void altera_sdr_writel (struct altera_sdr *sdr,u32 reg_offset,u32 value) +{ +writel (value, sdr->reg_base + reg_offset); +} +EXPORT_SYMBOL_GPL (altera_sdr_writel);Why are you abstracting these?
Quoted 1 line
Might be better to use Regmap even.
Quoted 8 lines
regmap seems unnecessarily complex for what we're doing which is why this method was chosen.
Future drivers will access different sets of registers in the device. These drivers won't share bitfields in the same register so the MFD seemed like the best solution. Originally we implemented this using syscon but that seems to be frowned upon so we changed to using a MFD.
Quoted 9 lines
Why was the use of syscon frowned upon? Can you link me to the thread? Writing directly to the registers sounds to me a lot worse than using infrastructure which was designed for these kinds of accesses.
If you do choose to fiddle with the registers in this manner, is there any reason why you're calling back into here, rather than using
readl()andwritel()directly?
We'd prefer to use syscon and that is what we started with. If you'd like to be our advocate, I will return to that because it was pretty clean. My primary concern is to get it upstreamed and if it is MFD then I'll make the changes.
Here are the threads.
http://marc.info/?l=linux-kernel&m=140128791902800&w=2
and
http://article.gmane.org/gmane.linux.kernel/1679601
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
drivers/mfd/altera-sdr.c line 51
Quoted 4 lines
drivers/mfd/altera-sdr.c new file +4
-0+u32 altera_sdr_mem_size (struct altera_sdr *sdr) +{ +u32 size; +u32 read_reg, row, bank, col, cs, width;Weird that size is on its own. Either place on a single line or separate them all.
OK. I will change this.
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
drivers/mfd/altera-sdr.c line 59
Quoted 7 lines
drivers/mfd/altera-sdr.c new file +7
-0+ read_reg =altera_sdr_readl (sdr,SDR_DRAMADDRW_OFST ); +if (read_reg <0 ) +return 0 ; + + width =altera_sdr_readl (sdr,SDR_DRAMIFWIDTH_OFST ); +if (width <0 ) +return 0 ;u32s cant be < 0. The 'u' means 'unsigned'.
Whoops. Good catch.
Quoted 25 lines
Quoted 25 lines
Quoted 10 lines
drivers/mfd/altera-sdr.c line 68
Quoted 8 lines
drivers/mfd/altera-sdr.c new file +8
-0+ col = (read_reg &SDR_DRAMADDRW_COLBITS_MASK ) >> +SDR_DRAMADDRW_COLBITS_LSB ; + row = (read_reg &SDR_DRAMADDRW_ROWBITS_MASK ) >> +SDR_DRAMADDRW_ROWBITS_LSB ; + bank = (read_reg &SDR_DRAMADDRW_BANKBITS_MASK ) >> +SDR_DRAMADDRW_BANKBITS_LSB ; + cs = (read_reg &SDR_DRAMADDRW_CSBITS_MASK ) >> +SDR_DRAMADDRW_CSBITS_LSB ;These would probably be better as macros.
OK. I will fix this.
Quoted 14 lines
drivers/mfd/altera-sdr.c line 81
Quoted 12 lines
drivers/mfd/altera-sdr.c new file +12
-0+/* Correct for ECC as its not addressible */ +if (width ==SDR_DRAMIFWIDTH_32B_ECC ) + width =32 ; +if (width ==SDR_DRAMIFWIDTH_16B_ECC ) + width =16 ; + +/* calculate the SDRAM size base on this info */ + size =1 << (row + bank + col); + size = size * cs * (width /8 ); +return size; +} +EXPORT_SYMBOL_GPL (altera_sdr_mem_size);Should this really be done in here? Isn't this an SDRAM function?
Quoted 4 lines
Quoted 3 lines
This register is part of the SDRAM controller and size information may be required by the other drivers that share this memory area/need SDRAM information.
Then export a function from the SDRAM driver, not from here.
We don't have an SDRAM driver. Although I could put this in the EDAC driver it would be lost to anyone else wanting this functionality so this seemed to be the logical place.
Quoted 8 lines
[...]
Quoted 5 lines
Quoted 5 lines
drivers/mfd/altera-sdr.c line 135
Quoted 4 lines
drivers/mfd/altera-sdr.c new file +4
-0+static const struct platform_device_id altera_sdr_ids[] = { + {"altera_sdr" , }, + { } +};What's this for?
Quoted 4 lines
Quoted 3 lines
We don't strictly need it because we are driven by the device tree. It can be removed it if is a problem but I'm not clear why it is a problem.
It's a problem because it's unused, superfluous bumph. :)
OK. I will remove it.
Quoted 9 lines
[...]
Quoted 6 lines
Quoted 6 lines
drivers/mfd/altera-sdr.c line 152
Quoted 5 lines
drivers/mfd/altera-sdr.c new file +5
-0+static int __init altera_sdr_init (void ) +{ +return platform_driver_register (&altera_sdr_driver); +} +postcore_initcall (altera_sdr_init);Why was this chosen?
Quoted 3 lines
Quoted 1 line
We want this to happen pretty early.
If you _need_ this is happen early,
core_initcall()is more commonly used, but _why_ do you need it to happen this early?
The syscon driver used this designation. After talking with Alan, this could be changed to a core_initcall(). However, it could also be a subsys_initcall which seems to be more common in the MFD drivers.
Quoted 23 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
+/*
+ * Copyright (C) 2014 Altera Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.Quoted 2 lines
Quoted 1 line
Use the short version.
Same as above. This is the shorter version that we've been using at Altera.
If you read COPYING, you only require the Copyright line and a link to the full licence. In this case I'll be happy if you left in the "This program is free software;" line as well, but remove the paragraph below it.
[...]
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
include/linux/mfd/altera-sdr.h line 99
Quoted 3 lines
include/linux/mfd/altera-sdr.h new file +3
-0+/* Register access API */ +u32 altera_sdr_readl (struct altera_sdr *sdr,u32 reg_offset); +void altera_sdr_writel (struct altera_sdr *sdr,u32 reg_offset,u32 value);Regmap?
Same as above. This seems to be more complex than we need.
I'm not sure I believe that. Regmap is as complex or as simple as you need.
OK. This is a moot point if we decide to go back to using syscon.
If we stick to using an MFD driver, then we can look at regmap. If we stick with MFD, the code really starts to look like syscon.
Thanks!
Quoted 5 lines
Quoted 3 lines
Thanks for your comments and for reviewing!
Thor
You're welcome. OOI, do you own a hammer? ;)
Re: [PATCHv9 1/3] mfd: altera: Add Altera SDRAM Controller
Hi!
Quoted 5 lines · Thor Thayer
Quoted 3 lines · Lee Jones
Quoted 2 lines · Thor Thayer
Quoted 1 line · Lee Jones
On Wed, 30 Jul 2014, tthayer at opensource.altera.com wrote:
[...]
Quoted 16 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/mfd/altera-sdr.c line 45
Quoted 11 lines
drivers/mfd/altera-sdr.c new file +11
-0+u32 altera_sdr_readl (struct altera_sdr *sdr,u32 reg_offset) +{ +return readl (sdr->reg_base + reg_offset); +} +EXPORT_SYMBOL_GPL (altera_sdr_readl); + +void altera_sdr_writel (struct altera_sdr *sdr,u32 reg_offset,u32 value) +{ +writel (value, sdr->reg_base + reg_offset); +} +EXPORT_SYMBOL_GPL (altera_sdr_writel);We'd prefer to use syscon and that is what we started with. If you'd like to be our advocate, I will return to that because it was pretty clean. My primary concern is to get it upstreamed and if it is MFD then I'll make the changes.
Quoted 2 lines
Here are the threads.
http://marc.info/?l=linux-kernel&m=140128791902800&w=2
The conclusion of this thread was syscon for offset 0x0, no ?! And if you decide to have new writel/readl functions, I'd prefer if you don't change the order of parameters just because. That always weirds me out, when there are vendorname_writel functions, that only change the API of writel and nothing else (not exactly the case here).
Regards,
Steffen
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Re: [PATCHv9 1/3] mfd: altera: Add Altera SDRAM Controller
In reply to Thor ThayerQuoted 24 lines · Thor Thayer
Quoted 23 lines · Lee Jones
Quoted 22 lines · Thor Thayer
Quoted 21 lines · Lee Jones
Quoted 19 lines · tthayer at opensource.altera.com
From: Thor Thayer <[email protected]>
Add a simple MFD for the Altera SDRAM Controller.
Signed-off-by Alan Tull <[email protected]>Signed-off-by Thor Thayer <[email protected]>---
v1-8: The MFD implementation was not included in the original series.v9: New MFD implementation.
--- MAINTAINERS | 5 ++ drivers/mfd/Kconfig | 7 ++ drivers/mfd/Makefile | 1 + drivers/mfd/altera-sdr.c | 162 ++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/altera-sdr.h | 102 +++++++++++++++++++++++++ 5 files changed, 277 insertions(+) create mode 100644 drivers/mfd/altera-sdr.c create mode 100644 include/linux/mfd/altera-sdr.h
[...]
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/mfd/altera-sdr.c line 45
Quoted 9 lines
drivers/mfd/altera-sdr.c new file +9
-0+return readl (sdr->reg_base + reg_offset); +} +EXPORT_SYMBOL_GPL (altera_sdr_readl); + +void altera_sdr_writel (struct altera_sdr *sdr,u32 reg_offset,u32 value) +{ +writel (value, sdr->reg_base + reg_offset); +} +EXPORT_SYMBOL_GPL (altera_sdr_writel);Why are you abstracting these?
You still didn't answer this?
Quoted 23 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
Might be better to use Regmap even.
regmap seems unnecessarily complex for what we're doing which is why this method was chosen.
Future drivers will access different sets of registers in the device. These drivers won't share bitfields in the same register so the MFD seemed like the best solution. Originally we implemented this using syscon but that seems to be frowned upon so we changed to using a MFD.
Quoted 9 lines
Why was the use of syscon frowned upon? Can you link me to the thread? Writing directly to the registers sounds to me a lot worse than using infrastructure which was designed for these kinds of accesses.
If you do choose to fiddle with the registers in this manner, is there any reason why you're calling back into here, rather than using
readl()andwritel()directly?We'd prefer to use syscon and that is what we started with. If you'd like to be our advocate, I will return to that because it was pretty clean. My primary concern is to get it upstreamed and if it is MFD then I'll make the changes.
Quoted 4 lines
Here are the threads.
http://marc.info/?l=linux-kernel&m=140128791902800&w=2
and
http://article.gmane.org/gmane.linux.kernel/1679601
Syscon looks the most appropriate to me.
[...]
Quoted 10 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
+EXPORT_SYMBOL_GPL(altera_sdr_mem_size);
Should this really be done in here? Isn't this an SDRAM function?
This register is part of the SDRAM controller and size information may be required by the other drivers that share this memory area/need SDRAM information.
Then export a function from the SDRAM driver, not from here.
We don't have an SDRAM driver. Although I could put this in the EDAC driver it would be lost to anyone else wanting this functionality so this seemed to be the logical place.
Why can't you export it from the EDAC driver?
[...]
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/mfd/altera-sdr.c line 152
Quoted 5 lines
drivers/mfd/altera-sdr.c new file +5
-0+static int __init altera_sdr_init (void ) +{ +return platform_driver_register (&altera_sdr_driver); +} +postcore_initcall (altera_sdr_init);Why was this chosen?
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
We want this to happen pretty early.
If you _need_ this is happen early,
core_initcall()is more commonly used, but _why_ do you need it to happen this early?The syscon driver used this designation. After talking with Alan, this could be changed to a
core_initcall(). However, it could also be asubsys_initcallwhich seems to be more common in the MFD drivers.
That doesn't answer my question still.
What is the reason, requirement, need for this driver to be probed so early during the boot process?
[...]
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCHv9 1/3] mfd: altera: Add Altera SDRAM Controller
In reply to Steffen TrumtrarQuoted 25 lines · Steffen Trumtrar
Hi!
Quoted 4 lines · Thor Thayer
Quoted 3 lines · Lee Jones
Quoted 2 lines · Thor Thayer
Quoted 1 line · Lee Jones
On Wed, 30 Jul 2014, [email protected] wrote:
[...]
Quoted 16 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/mfd/altera-sdr.c line 45
Quoted 11 lines
drivers/mfd/altera-sdr.c new file +11
-0+u32 altera_sdr_readl (struct altera_sdr *sdr,u32 reg_offset) +{ +return readl (sdr->reg_base + reg_offset); +} +EXPORT_SYMBOL_GPL (altera_sdr_readl); + +void altera_sdr_writel (struct altera_sdr *sdr,u32 reg_offset,u32 value) +{ +writel (value, sdr->reg_base + reg_offset); +} +EXPORT_SYMBOL_GPL (altera_sdr_writel);We'd prefer to use syscon and that is what we started with. If you'd like to be our advocate, I will return to that because it was pretty clean. My primary concern is to get it upstreamed and if it is MFD then I'll make the changes.
Quoted 7 lines
Quoted 2 lines
Here are the threads.
http://marc.info/?l=linux-kernel&m=140128791902800&w=2The conclusion of this thread was syscon for offset
0x0, no ?! And if you decide to have new writel/readl functions, I'd prefer if you don't change the order of parameters just because. That always weirds me out, when there arevendorname_writelfunctions, that only change the API of writel and nothing else (not exactly the case here).
Hi Steffen,
Yes, I see your point on the order of parameters. i will change it.
As for the syscon only at offset 0, I submitted that in version 7 & 8. It wasn't as clean as the version using syscon for the entire range. It could also require changes to the SDRAM controller binding as things are added in the future. My understanding is the bindings should not change significantly and changes are frowned upon.
After going through this exercise in a couple of different ways, I'm leaning toward using syscon for the entire SDRAM controller register range.
Is there a good reason not to use syscon on the entire register range?
Thanks,
Thor
Quoted 4 lines
Regards,
Steffen
Re: [PATCHv9 3/3] arm: dts: Add Altera SDRAM controller bindings
In reply to [email protected]Quoted 52 lines · tthayer at opensource.altera.com
From: Thor Thayer <[email protected]>
Add the Altera SDRAM controller bindings and device tree changes to the Altera SoC project.
Signed-off-by Thor Thayer <[email protected]>---
v2: Changes to SoC SDRAM EDAC code.v3: Implement code suggestions for SDRAM EDAC code.
v4: Remove syscon from SDRAM controller bindings.
v5: No Change, bump version for consistency.
v6: Only map the ctrlcfg register as syscon.
v7: No change. Bump for consistency.
v8: No change. Bump for consistency.
v9: Changes to support a MFD SDRAM controller with nested EDAC.
--- .../devicetree/bindings/arm/altera/socfpga-sdr.txt | 13 +++++++++++++ arch/arm/boot/dts/socfpga.dtsi | 10 ++++++++++ 2 files changed, 23 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/altera/socfpga-sdr.txtDocumentation/devicetree/bindings/arm/altera/socfpga-sdr.txt new file +13
-0@@ -0,0 +1,13 @@ +Altera SOCFPGA SDRAM Controller +The SDRAM controller is implemented as a MFD so various drivers may +nest under this main SDRAM controller binding. + +Required properties: +- compatible : "altr,sdr"; +- reg : Should contain 1 register range(address and length) + +Example: + sdr at 0xffc25000 { + compatible = "altr,sdr"; + reg = <0xffc25000 0x1000>; + };arch/arm/boot/dts/socfpga.dtsi +0
-0@@ -603,6 +603,16 @@ };
arch/arm/boot/dts/socfpga.dtsi line 613
Quoted 10 lines
arch/arm/boot/dts/socfpga.dtsi +8
-0}; + sdr at 0xffc25000 { + compatible = "altr,sdr"; + reg = <0xffc25000 0x1000>; + + sdramedac at 0 { + compatible = "altr,sdram-edac"; + interrupts = <0 39 4>; + };
This doesn't match the documentation, but I don't think this is a move in the right direction anyway. Because Linux has/wants an MFD driver is not a reason to add a sub node. It is a single h/w block and DT should reflect that.
Rob
Re: [PATCHv9 3/3] arm: dts: Add Altera SDRAM controller bindings
Quoted 68 lines · Rob Herring
Quoted 52 lines · On 07/30/2014 01:22 PM, [email protected] wrote:
From: Thor Thayer <[email protected]>
Add the Altera SDRAM controller bindings and device tree changes to the Altera SoC project.
Signed-off-by Thor Thayer <[email protected]>---
v2: Changes to SoC SDRAM EDAC code.v3: Implement code suggestions for SDRAM EDAC code.
v4: Remove syscon from SDRAM controller bindings.
v5: No Change, bump version for consistency.
v6: Only map the ctrlcfg register as syscon.
v7: No change. Bump for consistency.
v8: No change. Bump for consistency.
v9: Changes to support a MFD SDRAM controller with nested EDAC.
--- .../devicetree/bindings/arm/altera/socfpga-sdr.txt | 13 +++++++++++++ arch/arm/boot/dts/socfpga.dtsi | 10 ++++++++++ 2 files changed, 23 insertions(+)create mode 100644
Documentation/devicetree/bindings/arm/altera/socfpga-sdr.txtDocumentation/devicetree/bindings/arm/altera/socfpga-sdr.txt new file +13
-0@@ -0,0 +1,13 @@ +Altera SOCFPGA SDRAM Controller +The SDRAM controller is implemented as a MFD so various drivers may +nest under this main SDRAM controller binding. + +Required properties: +- compatible : "altr,sdr"; +- reg : Should contain 1 register range(address and length) + +Example: + sdr@0xffc25000 { + compatible = "altr,sdr"; + reg = <0xffc25000 0x1000>; + };arch/arm/boot/dts/socfpga.dtsi +0
-0@@ -603,6 +603,16 @@ };arch/arm/boot/dts/socfpga.dtsi line 613
Quoted 10 lines
arch/arm/boot/dts/socfpga.dtsi +8
-0}; + sdr@0xffc25000 { + compatible = "altr,sdr"; + reg = <0xffc25000 0x1000>; + + sdramedac@0 { + compatible = "altr,sdram-edac"; + interrupts = <0 39 4>; + };This doesn't match the documentation, but I don't think this is a move in the right direction anyway. Because Linux has/wants an MFD driver is not a reason to add a sub node. It is a single h/w block and DT should reflect that.
Quoted 1 line
Rob
Hi Rob,
Thanks for reviewing. After discussions with the community and internally, I reverted to using the syscon case in revision 10. I apologize for the confusion but the syscon method seems to be a cleaner solution. I submitted the sycon version on 8/11/14.
Thanks,
Thor