[RFC v2] ARM: memory: da8xx-ddrctl: new driver
Create a new driver for the da8xx DDR2/mDDR controller and implement support for writing to the Peripheral Bus Burst Priority Register. Signed-off-by: Bartosz Golaszewski --- .../memory-controllers/ti-da8xx-ddrctl.txt | 20 +++ drivers/memory/Kconfig | 8 + drivers/memory/Makefile| 1 + drivers/memory/da8xx-ddrctl.c | 175 + 4 files changed, 204 insertions(+) create mode 100644 Documentation/devicetree/bindings/memory-controllers/ti-da8xx-ddrctl.txt create mode 100644 drivers/memory/da8xx-ddrctl.c diff --git a/Documentation/devicetree/bindings/memory-controllers/ti-da8xx-ddrctl.txt b/Documentation/devicetree/bindings/memory-controllers/ti-da8xx-ddrctl.txt new file mode 100644 index 000..7e271dd --- /dev/null +++ b/Documentation/devicetree/bindings/memory-controllers/ti-da8xx-ddrctl.txt @@ -0,0 +1,20 @@ +* Device tree bindings for Texas Instruments da8xx DDR2/mDDR memory controller + +The DDR2/mDDR memory controller present on Texas Instruments da8xx SoCs features +a set of registers which allow to tweak the controller's behavior. + +Documentation: +OMAP-L138 (DA850) - http://www.ti.com/lit/ug/spruh82c/spruh82c.pdf + +Required properties: + +- compatible: "ti,da850-ddr-controller" - for da850 SoC based boards +- reg: a tuple containing the base address of the memory + controller and the size of the memory area to map + +Example for da850 shown below. + +ddrctl { + compatible = "ti,da850-ddr-controller"; + reg = <0xB000 0x100>; +}; diff --git a/drivers/memory/Kconfig b/drivers/memory/Kconfig index 4b4c0c3..ec80e35 100644 --- a/drivers/memory/Kconfig +++ b/drivers/memory/Kconfig @@ -134,6 +134,14 @@ config MTK_SMI mainly help enable/disable iommu and control the power domain and clocks for each local arbiter. +config DA8XX_DDRCTL + bool "Texas Instruments da8xx DDR2/mDDR driver" + depends on ARCH_DAVINCI_DA8XX + help + This driver is for the DDR2/mDDR Memory Controller present on + Texas Instruments da8xx SoCs. It's used to tweak various memory + controller configuration options. + source "drivers/memory/samsung/Kconfig" source "drivers/memory/tegra/Kconfig" diff --git a/drivers/memory/Makefile b/drivers/memory/Makefile index b20ae38..e88097fb 100644 --- a/drivers/memory/Makefile +++ b/drivers/memory/Makefile @@ -17,6 +17,7 @@ obj-$(CONFIG_MVEBU_DEVBUS)+= mvebu-devbus.o obj-$(CONFIG_TEGRA20_MC) += tegra20-mc.o obj-$(CONFIG_JZ4780_NEMC) += jz4780-nemc.o obj-$(CONFIG_MTK_SMI) += mtk-smi.o +obj-$(CONFIG_DA8XX_DDRCTL) += da8xx-ddrctl.o obj-$(CONFIG_SAMSUNG_MC) += samsung/ obj-$(CONFIG_TEGRA_MC) += tegra/ diff --git a/drivers/memory/da8xx-ddrctl.c b/drivers/memory/da8xx-ddrctl.c new file mode 100644 index 000..66022df --- /dev/null +++ b/drivers/memory/da8xx-ddrctl.c @@ -0,0 +1,175 @@ +/* + * TI da8xx DDR2/mDDR controller driver + * + * Copyright (C) 2016 BayLibre SAS + * + * Author: + * Bartosz Golaszewski + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include + +/* + * REVISIT: Linux doesn't have a good framework for the kind of performance + * knobs this driver controls. We can't use device tree properties as it deals + * with hardware configuration rather than description. We also don't want to + * commit to maintaining some random sysfs attributes. + * + * For now we just hardcode the register values for the boards that need + * some changes (as is the case for the LCD controller on da850-lcdk - the + * first board we support here). When linux gets an appropriate framework, + * we'll easily convert the driver to it. + */ + +struct da8xx_ddrctl_config_knob { + const char *name; + u32 reg; + u32 mask; + u32 offset; +}; + +static const struct da8xx_ddrctl_config_knob da8xx_ddrctl_knobs[] = { + { + .name = "da850-pbbpr", + .reg = 0x20, + .mask = 0xff00, + .offset = 0, + }, +}; + +struct da8xx_ddrctl_setting { + const char *name; + u32 val; +}; + +struct da8xx_ddrctl_board_settings { + const char *board; + const struct da8xx_ddrctl_setting *settings; +}; + +static const struct da8xx_ddrctl_setting da850_lcdk_ddrctl_settings[] = { + { + .name = "da850-pbbpr", + .val = 0x20, + }, + { } +}; + +static const struct da8xx_ddrctl_board_settings da8xx_ddrctl_board_confs[] = { + { + .board = "ti,da850-lcdk", + .settings = da850_lcdk_ddrctl_settings, + }, +}; + +static const struct da8xx_ddrctl_config_knob *
[RFC v2] ARM: memory: da8xx-ddrctl: new driver
Kevin Hilman writes: > Bartosz Golaszewski writes: > >> Create a new driver for the da8xx DDR2/mDDR controller and implement >> support for writing to the Peripheral Bus Burst Priority Register. >> >> Signed-off-by: Bartosz Golaszewski >> --- >> .../memory-controllers/ti-da8xx-ddrctl.txt | 20 +++ >> drivers/memory/Kconfig | 8 + >> drivers/memory/Makefile| 1 + >> drivers/memory/da8xx-ddrctl.c | 175 >> + >> 4 files changed, 204 insertions(+) >> create mode 100644 >> Documentation/devicetree/bindings/memory-controllers/ti-da8xx-ddrctl.txt >> create mode 100644 drivers/memory/da8xx-ddrctl.c >> >> diff --git >> a/Documentation/devicetree/bindings/memory-controllers/ti-da8xx-ddrctl.txt >> b/Documentation/devicetree/bindings/memory-controllers/ti-da8xx-ddrctl.txt >> new file mode 100644 >> index 000..7e271dd >> --- /dev/null >> +++ >> b/Documentation/devicetree/bindings/memory-controllers/ti-da8xx-ddrctl.txt >> @@ -0,0 +1,20 @@ >> +* Device tree bindings for Texas Instruments da8xx DDR2/mDDR memory >> controller >> + >> +The DDR2/mDDR memory controller present on Texas Instruments da8xx SoCs >> features >> +a set of registers which allow to tweak the controller's behavior. >> + >> +Documentation: >> +OMAP-L138 (DA850) - http://www.ti.com/lit/ug/spruh82c/spruh82c.pdf >> + >> +Required properties: >> + >> +- compatible: "ti,da850-ddr-controller" - for da850 SoC based >> boards >> +- reg: a tuple containing the base address of the >> memory >> +controller and the size of the memory area to map >> + >> +Example for da850 shown below. >> + >> +ddrctl { >> +compatible = "ti,da850-ddr-controller"; >> +reg = <0xB000 0x100>; >> +}; > > Axel's series for the USB PHY reminded me that the PHY also has some > config registers in this same area, and his series creates a syscon for > a similar range of registers. > > Could you create a syscon for the SYSCFG0 registers, which would then > be used by ths driver and your other drivers/bus driver? Then the > binding would just reference the sysconf via phandle, and your driver > can use syscon_regmap_lookup_by_phandle() Nevermind. I though that the config register in this driver was also in SYSCFG0, but I see now that it's in the reg region of the DDR controller itself, so no syscon is needed. Kevin
[RFC v2] ARM: memory: da8xx-ddrctl: new driver
Bartosz Golaszewski writes: > Create a new driver for the da8xx DDR2/mDDR controller and implement > support for writing to the Peripheral Bus Burst Priority Register. > > Signed-off-by: Bartosz Golaszewski > --- > .../memory-controllers/ti-da8xx-ddrctl.txt | 20 +++ > drivers/memory/Kconfig | 8 + > drivers/memory/Makefile| 1 + > drivers/memory/da8xx-ddrctl.c | 175 > + > 4 files changed, 204 insertions(+) > create mode 100644 > Documentation/devicetree/bindings/memory-controllers/ti-da8xx-ddrctl.txt > create mode 100644 drivers/memory/da8xx-ddrctl.c > > diff --git > a/Documentation/devicetree/bindings/memory-controllers/ti-da8xx-ddrctl.txt > b/Documentation/devicetree/bindings/memory-controllers/ti-da8xx-ddrctl.txt > new file mode 100644 > index 000..7e271dd > --- /dev/null > +++ b/Documentation/devicetree/bindings/memory-controllers/ti-da8xx-ddrctl.txt > @@ -0,0 +1,20 @@ > +* Device tree bindings for Texas Instruments da8xx DDR2/mDDR memory > controller > + > +The DDR2/mDDR memory controller present on Texas Instruments da8xx SoCs > features > +a set of registers which allow to tweak the controller's behavior. > + > +Documentation: > +OMAP-L138 (DA850) - http://www.ti.com/lit/ug/spruh82c/spruh82c.pdf > + > +Required properties: > + > +- compatible:"ti,da850-ddr-controller" - for da850 SoC based > boards > +- reg: a tuple containing the base address of the > memory > + controller and the size of the memory area to map > + > +Example for da850 shown below. > + > +ddrctl { > + compatible = "ti,da850-ddr-controller"; > + reg = <0xB000 0x100>; > +}; Axel's series for the USB PHY reminded me that the PHY also has some config registers in this same area, and his series creates a syscon for a similar range of registers. Could you create a syscon for the SYSCFG0 registers, which would then be used by ths driver and your other drivers/bus driver? Then the binding would just reference the sysconf via phandle, and your driver can use syscon_regmap_lookup_by_phandle() > diff --git a/drivers/memory/Kconfig b/drivers/memory/Kconfig > index 4b4c0c3..ec80e35 100644 > --- a/drivers/memory/Kconfig > +++ b/drivers/memory/Kconfig > @@ -134,6 +134,14 @@ config MTK_SMI > mainly help enable/disable iommu and control the power domain and > clocks for each local arbiter. > > +config DA8XX_DDRCTL > + bool "Texas Instruments da8xx DDR2/mDDR driver" > + depends on ARCH_DAVINCI_DA8XX > + help > + This driver is for the DDR2/mDDR Memory Controller present on > + Texas Instruments da8xx SoCs. It's used to tweak various memory > + controller configuration options. > + > source "drivers/memory/samsung/Kconfig" > source "drivers/memory/tegra/Kconfig" > > diff --git a/drivers/memory/Makefile b/drivers/memory/Makefile > index b20ae38..e88097fb 100644 > --- a/drivers/memory/Makefile > +++ b/drivers/memory/Makefile > @@ -17,6 +17,7 @@ obj-$(CONFIG_MVEBU_DEVBUS) += mvebu-devbus.o > obj-$(CONFIG_TEGRA20_MC) += tegra20-mc.o > obj-$(CONFIG_JZ4780_NEMC)+= jz4780-nemc.o > obj-$(CONFIG_MTK_SMI)+= mtk-smi.o > +obj-$(CONFIG_DA8XX_DDRCTL) += da8xx-ddrctl.o > > obj-$(CONFIG_SAMSUNG_MC) += samsung/ > obj-$(CONFIG_TEGRA_MC) += tegra/ > diff --git a/drivers/memory/da8xx-ddrctl.c b/drivers/memory/da8xx-ddrctl.c > new file mode 100644 > index 000..66022df > --- /dev/null > +++ b/drivers/memory/da8xx-ddrctl.c > @@ -0,0 +1,175 @@ > +/* > + * TI da8xx DDR2/mDDR controller driver > + * > + * Copyright (C) 2016 BayLibre SAS > + * > + * Author: > + * Bartosz Golaszewski > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 as > + * published by the Free Software Foundation. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* > + * REVISIT: Linux doesn't have a good framework for the kind of performance > + * knobs this driver controls. We can't use device tree properties as it > deals > + * with hardware configuration rather than description. We also don't want to > + * commit to maintaining some random sysfs attributes. > + * > + * For now we just hardcode the register values for the boards that need > + * some changes (as is the case for the LCD controller on da850-lcdk - the > + * first board we support here). When linux gets an appropriate framework, > + * we'll easily convert the driver to it. > + */ > + > +struct da8xx_ddrctl_config_knob { > + const char *name; > + u32 reg; > + u32 mask; > + u32 offset; nit: call this shift instead, which will also map well onto the regmap accessors (which you'll use when switching to syscon.) > +}; > + > +static const struct da8xx_ddrctl_config_knob