Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1453351 > unrolled thread
| Started by | Peter Griffin <peter.griffin@linaro.org> |
|---|---|
| First post | 2016-08-01 19:20 +0200 |
| Last post | 2016-08-01 21:10 +0200 |
| Articles | 9 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v7 00/16] Add support for FDMA DMA controller and slim core rproc found on STi chipsets Peter Griffin <peter.griffin@linaro.org> - 2016-08-01 19:20 +0200
[PATCH v7 08/16] ARM: multi_v7_defconfig: Enable STi FDMA driver Peter Griffin <peter.griffin@linaro.org> - 2016-08-01 19:20 +0200
[PATCH v7 10/16] ARM: DT: STiH407: Add i2s_out pinctrl configuration Peter Griffin <peter.griffin@linaro.org> - 2016-08-01 19:20 +0200
[PATCH v7 06/16] ARM: STi: DT: STiH407: Add FDMA driver dt nodes. Peter Griffin <peter.griffin@linaro.org> - 2016-08-01 19:40 +0200
[PATCH v7 07/16] MAINTAINERS: Add FDMA driver files to STi section. Peter Griffin <peter.griffin@linaro.org> - 2016-08-01 19:50 +0200
[PATCH v7 12/16] ARM: DT: STiH407: Add spdif_out pinctrl config Peter Griffin <peter.griffin@linaro.org> - 2016-08-01 19:50 +0200
[PATCH v7 01/16] remoteproc: st_slim_rproc: add a slimcore rproc driver Peter Griffin <peter.griffin@linaro.org> - 2016-08-01 19:50 +0200
Re: [PATCH v7 01/16] remoteproc: st_slim_rproc: add a slimcore rproc driver Bjorn Andersson <bjorn.andersson@linaro.org> - 2016-08-10 21:30 +0200
[PATCH v7 03/16] dmaengine: st_fdma: Add STMicroelectronics FDMA DT binding documentation Peter Griffin <peter.griffin@linaro.org> - 2016-08-01 21:10 +0200
| From | Peter Griffin <peter.griffin@linaro.org> |
|---|---|
| Date | 2016-08-01 19:20 +0200 |
| Subject | [PATCH v7 00/16] Add support for FDMA DMA controller and slim core rproc found on STi chipsets |
| Message-ID | <s1p2F-MQ-3@gated-at.bofh.it> |
Hi Vinod, Bjorn, Patrice,
This patchset adds support for the Flexible Direct Memory Access (FDMA) core
found on STi chipsets from STMicroelectronics. The FDMA is a slim core CPU
with a dedicated firmware. It is a general purpose DMA controller supporting
16 independent channels and data can be moved from memory to memory or between
memory and paced latency critical real time targets.
After some discussion with the DT maintainers I've removed the firmware
name from DT, and now generate the name based on the compatible string.
This is in keeping with how most other kernel drivers request firmware, and avoids
a new DT firmware name or fdma id binding.
I've also dropped the dma xbar support for the moment, as I believe it should be
re-worked based on some of the xbar API's that TI recently added. As requested
I've also split it into smaller patches to help with a faster review.
V3 also included some updates to the ASoC st,sti-asoc-card.txt DT documentation
to make the doc align with the driver code. These patches have already been applied
and are now dropped from this series. Other changes included enabling the ASoC drivers
in multi_v7 defconfig and adding DT patches for Patrices STi DT tree to enable ASoC
on STiH407/10 based platforms using the fdma driver.
v4 includes a new slim core rproc driver for loading the slim elf firmware. This
enables us to use the generic rproc elf loading code. This has deliberately not
been implemented as a platform_driver, to avoid having to have double mappings of
I/O memory from two device drivers, and also to ensure that the DT node reflects
the actual hardware rather than Linux subsystems. The slim core is the basis
for various pieces of IP in STi chipsets and the intention is that other drivers
(e.g. demux) can also be migrated over to using the slim rproc for their
elf firmware loading and start/stop control.
v5 includes various updates from Bjorn related to the slim rproc implementation.
It also includes a patch to make rsc_table optional in remoteproc_core and various
other cleanups and review feedback from Vinod to do with the actual fdma
implementation. It also fixes a regression introduced in v4 when all drivers are
built-in spotted by Aranud.
v6 goes back to having a dummy rsc_table and fixes some kbuild warnings. However
a change is still required in rproc core when all drivers are built-in as the initial
async firmware resource table parsing can fail when built-in, which causes subsequent calls
to rproc_boot() to also fail. V6 changes this behaviour to retry rproc_fw_config_virtio()
from rproc_boot(), in cases where it previously failed, as at this point we know the
irmwaref has been successfully obtained.
v7 removes all remoteproc core changes required to get -EPROBE_DEFER working properly
when firmware resides on a rootfs and compiling as built-in. The fdma driver now relies on
the firmware being available in the initramfs when building fdma as built-in. This has
been tested and works well. If remoteproc subsystem implements a new mechanism for
firmware on late mounted root filesystems, we can migrate this driver over to use it
at that point.
regards,
Peter.
Changes since v6:
- Fix recursive Kconfig warning (Patrice)
- Fix various Intel zero day compiler warnings
- Remove all changes related to late firmware load (now relies on initramfs) (Peter)
Changes since v5:
- Remove optional rsc table and go back to dummy resource table (Bjorn)
- Retry rproc_fw_config_virtio() from rproc_boot() if previously failed (Peter)
- Fixup some kbuild warnings
- rebase on v4.7-rc5
- Remove some patches which were merged via ASoC tree
Changes since v4:
- Make rsc table optional in remoteproc (Peter)
- Various fixups to STi audio DT nodes (Arnaud)
- Bulk rename of xp70 to slim (Peter)
- Update my email to @linaro.org (Lee)
- rebase on v4.7-rc2 (Peter)
- Don't make ST_SLIM_REMOTEPROC user selectable (Bjorn)
- -EPROBE_DEFER if rproc_boot fails when allocating DMA channel (Arnaud / Peter)
- Drop some unnecessary headers (Vinod / Bjorn)
- Change to writel now we have several mappings (Bjorn)
- Remove io_res, rproc, and some unused structure fields / #define (Bjorn)
- put clks in error path, also put clks before rproc_put() (Bjorn)
- Make enum less generic (Bjorn)
- Make slim_rproc_alloc() return a st_slim_rproc reference (Bjorn)
- Alphabetical naming in Kconfig & Makefile (Vinod)
- Add FDMA prefix to REQ_CTRL* (Vinod)
- Print ret on some error paths (Vinod)
- Add some acked-by (Peter)
Changes since v3:
- Remove elf loading code from fdma driver (Vinod)
- Remove fdma_ prefix for clock names (Arnd)
- Make _xlate use dma_get_any_channel rather than request_channel (Arnd)
- Make a common function for _prep_ routines (Vinod)
- Make driver depend on COMPILE_TEST (Arnd)
- Remove unnecessary st_fdma_filter_fn (Arnd)
- Enable FDMA as a module (Arnd)
- Drop fdma_ clock prefix (Arnd)
- Fix description as well as example for st, prefix (Arnd)
- Remove string concatenation from fdma register macros to ease grep'ability (Arnd)
- Add a XP70 rproc driver for ELF firmware loading and start/stop control (Peter)
- Add myself as a author of the driver (Peter)
Changes since v2:
- Change to dma-controller (Arnd)
- Remove platform data header file and simplifiy code (Arnd)
- Remove FW_LOADER_USER_HELPER_FALLBACK and rework firmware loading to device config (Vinod)
- Use SET_RUNTIME_PM_OPS helpers (Vinod)
- Remove fdma-id dt prop and use compatibles to generate different fdma firmware names (Arnd / Lee)
- Add sti-asoc-card DT nodes and pinmux config for uniperif player & reader (Peter)
- Update sti-asoc-card DT binding documentation (Peter)
- Enable STi audio drivers in multi_v7_defconfig (Peter)
Changes since v1:
- split into smaller patches for easier / faster review (Vinod)
- new fill_hw_mode() with common code (Vinod)
- new config_reqctrl() called from *_prep() instead of device_config cb (Vinod)
- fdma-xbar support removed (Peter)
- rework firmware name mechanism so fwname isn't in DT (Peter / Lee)
- st_fdma_seg_to_mem can be static (Paul)
- EXPORT_SYMBOL st_fdma_filter_fn not required (Paul)
- s/channel/channels (vinod)
- better describe "Must be <3>" (vinod)
- sizeof(*ehdr) (vinod)
- print values on error debug (vinod)
- empty line (Vinod)
- Update to -EIO (Vinod)
- Make st_fdma tristate (Paul)
- Remove __exit tag from .remove (Maxime)
- Update MAINTAINERS rule to fdma* (Lee)
- Unit address should match reg property (Lee)
Peter Griffin (16):
remoteproc: st_slim_rproc: add a slimcore rproc driver
MAINTAINERS: Add st slim core rproc driver to STi section.
dmaengine: st_fdma: Add STMicroelectronics FDMA DT binding
documentation
dmaengine: st_fdma: Add STMicroelectronics FDMA driver header file
dmaengine: st_fdma: Add STMicroelectronics FDMA engine driver support
ARM: STi: DT: STiH407: Add FDMA driver dt nodes.
MAINTAINERS: Add FDMA driver files to STi section.
ARM: multi_v7_defconfig: Enable STi FDMA driver
ARM: multi_v7_defconfig: Enable STi and simple-card drivers.
ARM: DT: STiH407: Add i2s_out pinctrl configuration
ARM: DT: STiH407: Add i2s_in pinctrl configuration
ARM: DT: STiH407: Add spdif_out pinctrl config
ARM: STi: DT: STiH407: Add sti-sasg-codec dt node
ARM: STi: DT: STiH407: Add uniperif player dt nodes
ARM: STi: DT: STiH407: Add uniperif reader dt nodes
ARM: DT: STi: stihxxx-b2120: Add DT nodes for STi audio card
Documentation/devicetree/bindings/dma/st_fdma.txt | 87 +++
MAINTAINERS | 3 +
arch/arm/boot/dts/stih407-family.dtsi | 161 ++++
arch/arm/boot/dts/stih407-pinctrl.dtsi | 55 ++
arch/arm/boot/dts/stihxxx-b2120.dtsi | 45 ++
arch/arm/configs/multi_v7_defconfig | 4 +
drivers/dma/Kconfig | 15 +-
drivers/dma/Makefile | 1 +
drivers/dma/st_fdma.c | 880 ++++++++++++++++++++++
drivers/dma/st_fdma.h | 244 ++++++
drivers/remoteproc/Kconfig | 7 +
drivers/remoteproc/Makefile | 1 +
drivers/remoteproc/st_slim_rproc.c | 376 +++++++++
include/linux/remoteproc/st_slim_rproc.h | 53 ++
14 files changed, 1931 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/dma/st_fdma.txt
create mode 100644 drivers/dma/st_fdma.c
create mode 100644 drivers/dma/st_fdma.h
create mode 100644 drivers/remoteproc/st_slim_rproc.c
create mode 100644 include/linux/remoteproc/st_slim_rproc.h
--
1.9.1
[toc] | [next] | [standalone]
| From | Peter Griffin <peter.griffin@linaro.org> |
|---|---|
| Date | 2016-08-01 19:20 +0200 |
| Subject | [PATCH v7 08/16] ARM: multi_v7_defconfig: Enable STi FDMA driver |
| Message-ID | <s1p2G-MQ-25@gated-at.bofh.it> |
| In reply to | #1453351 |
This DMA controller is found on all STi chipsets. Signed-off-by: Peter Griffin <peter.griffin@linaro.org> Acked-by: Lee Jones <lee.jones@linaro.org> --- arch/arm/configs/multi_v7_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig index 3ac30f0..541c914 100644 --- a/arch/arm/configs/multi_v7_defconfig +++ b/arch/arm/configs/multi_v7_defconfig @@ -747,6 +747,7 @@ CONFIG_DMA_OMAP=y CONFIG_QCOM_BAM_DMA=y CONFIG_XILINX_VDMA=y CONFIG_DMA_SUN6I=y +CONFIG_ST_FDMA=m CONFIG_STAGING=y CONFIG_SENSORS_ISL29018=y CONFIG_SENSORS_ISL29028=y -- 1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Peter Griffin <peter.griffin@linaro.org> |
|---|---|
| Date | 2016-08-01 19:20 +0200 |
| Subject | [PATCH v7 10/16] ARM: DT: STiH407: Add i2s_out pinctrl configuration |
| Message-ID | <s1p2G-MQ-45@gated-at.bofh.it> |
| In reply to | #1453351 |
This patch adds the pinctrl config for the i2s_out pins
used by the uniperif player IP.
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
---
arch/arm/boot/dts/stih407-pinctrl.dtsi | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/arch/arm/boot/dts/stih407-pinctrl.dtsi b/arch/arm/boot/dts/stih407-pinctrl.dtsi
index a538ae5..0fb5c8a 100644
--- a/arch/arm/boot/dts/stih407-pinctrl.dtsi
+++ b/arch/arm/boot/dts/stih407-pinctrl.dtsi
@@ -1067,6 +1067,29 @@
};
};
+ i2s_out {
+ pinctrl_i2s_8ch_out: i2s_8ch_out{
+ st,pins {
+ mclk = <&pio33 5 ALT1 OUT>;
+ lrclk = <&pio33 7 ALT1 OUT>;
+ sclk = <&pio33 6 ALT1 OUT>;
+ data0 = <&pio33 4 ALT1 OUT>;
+ data1 = <&pio34 0 ALT1 OUT>;
+ data2 = <&pio34 1 ALT1 OUT>;
+ data3 = <&pio34 2 ALT1 OUT>;
+ };
+ };
+
+ pinctrl_i2s_2ch_out: i2s_2ch_out{
+ st,pins {
+ mclk = <&pio33 5 ALT1 OUT>;
+ lrclk = <&pio33 7 ALT1 OUT>;
+ sclk = <&pio33 6 ALT1 OUT>;
+ data0 = <&pio33 4 ALT1 OUT>;
+ };
+ };
+ };
+
serial3 {
pinctrl_serial3: serial3-0 {
st,pins {
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Peter Griffin <peter.griffin@linaro.org> |
|---|---|
| Date | 2016-08-01 19:40 +0200 |
| Subject | [PATCH v7 06/16] ARM: STi: DT: STiH407: Add FDMA driver dt nodes. |
| Message-ID | <s1pm2-Vl-23@gated-at.bofh.it> |
| In reply to | #1453351 |
These nodes are required to get the fdma driver working
on STiH407 based silicon.
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
---
arch/arm/boot/dts/stih407-family.dtsi | 52 +++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/arch/arm/boot/dts/stih407-family.dtsi b/arch/arm/boot/dts/stih407-family.dtsi
index d294e82..45cab30 100644
--- a/arch/arm/boot/dts/stih407-family.dtsi
+++ b/arch/arm/boot/dts/stih407-family.dtsi
@@ -821,5 +821,57 @@
clock-frequency = <600000000>;
st,syscfg = <&syscfg_core 0x224>;
};
+
+ /* fdma audio */
+ fdma0: dma-controller@8e20000 {
+ compatible = "st,stih407-fdma-mpe31-11", "st,slim-rproc";
+ reg = <0x8e20000 0x8000>,
+ <0x8e30000 0x3000>,
+ <0x8e37000 0x1000>,
+ <0x8e38000 0x8000>;
+ reg-names = "slimcore", "dmem", "peripherals", "imem";
+ clocks = <&clk_s_c0_flexgen CLK_FDMA>,
+ <&clk_s_c0_flexgen CLK_EXT2F_A9>,
+ <&clk_s_c0_flexgen CLK_EXT2F_A9>,
+ <&clk_s_c0_flexgen CLK_EXT2F_A9>;
+ interrupts = <GIC_SPI 5 IRQ_TYPE_NONE>;
+ dma-channels = <16>;
+ #dma-cells = <3>;
+ };
+
+ /* fdma app */
+ fdma1: dma-controller@8e40000 {
+ compatible = "st,stih407-fdma-mpe31-12", "st,slim-rproc";
+ reg = <0x8e40000 0x8000>,
+ <0x8e50000 0x3000>,
+ <0x8e57000 0x1000>,
+ <0x8e58000 0x8000>;
+ reg-names = "slimcore", "dmem", "peripherals", "imem";
+ clocks = <&clk_s_c0_flexgen CLK_FDMA>,
+ <&clk_s_c0_flexgen CLK_TX_ICN_DMU>,
+ <&clk_s_c0_flexgen CLK_TX_ICN_DMU>,
+ <&clk_s_c0_flexgen CLK_EXT2F_A9>;
+
+ interrupts = <GIC_SPI 7 IRQ_TYPE_NONE>;
+ dma-channels = <16>;
+ #dma-cells = <3>;
+ };
+
+ /* fdma free running */
+ fdma2: dma-controller@8e60000 {
+ compatible = "st,stih407-fdma-mpe31-13", "st,slim-rproc";
+ reg = <0x8e60000 0x8000>,
+ <0x8e70000 0x3000>,
+ <0x8e77000 0x1000>,
+ <0x8e78000 0x8000>;
+ reg-names = "slimcore", "dmem", "peripherals", "imem";
+ interrupts = <GIC_SPI 9 IRQ_TYPE_NONE>;
+ dma-channels = <16>;
+ #dma-cells = <3>;
+ clocks = <&clk_s_c0_flexgen CLK_FDMA>,
+ <&clk_s_c0_flexgen CLK_EXT2F_A9>,
+ <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>,
+ <&clk_s_c0_flexgen CLK_EXT2F_A9>;
+ };
};
};
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Peter Griffin <peter.griffin@linaro.org> |
|---|---|
| Date | 2016-08-01 19:50 +0200 |
| Subject | [PATCH v7 07/16] MAINTAINERS: Add FDMA driver files to STi section. |
| Message-ID | <s1pvH-YH-15@gated-at.bofh.it> |
| In reply to | #1453351 |
This patch adds the FDMA driver files to the STi section of the maintainers file. Signed-off-by: Peter Griffin <peter.griffin@linaro.org> Acked-by: Lee Jones <lee.jones@linaro.org> --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 0b35e8b..dbdba21 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1705,6 +1705,7 @@ F: drivers/char/hw_random/st-rng.c F: drivers/clocksource/arm_global_timer.c F: drivers/clocksource/clksrc_st_lpc.c F: drivers/cpufreq/sti-cpufreq.c +F: drivers/dma/st_fdma* F: drivers/i2c/busses/i2c-st.c F: drivers/media/rc/st_rc.c F: drivers/media/platform/sti/c8sectpfe/ -- 1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Peter Griffin <peter.griffin@linaro.org> |
|---|---|
| Date | 2016-08-01 19:50 +0200 |
| Subject | [PATCH v7 12/16] ARM: DT: STiH407: Add spdif_out pinctrl config |
| Message-ID | <s1pvH-YH-19@gated-at.bofh.it> |
| In reply to | #1453351 |
This patch adds the pinctrl config for the spidf out
pins used by the sasg codec IP.
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
---
arch/arm/boot/dts/stih407-pinctrl.dtsi | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/arm/boot/dts/stih407-pinctrl.dtsi b/arch/arm/boot/dts/stih407-pinctrl.dtsi
index 537db7e..598dbab 100644
--- a/arch/arm/boot/dts/stih407-pinctrl.dtsi
+++ b/arch/arm/boot/dts/stih407-pinctrl.dtsi
@@ -1114,6 +1114,14 @@
};
};
+ spdif_out {
+ pinctrl_spdif_out: spdif_out{
+ st,pins {
+ spdif_out = <&pio34 7 ALT1 OUT>;
+ };
+ };
+ };
+
serial3 {
pinctrl_serial3: serial3-0 {
st,pins {
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Peter Griffin <peter.griffin@linaro.org> |
|---|---|
| Date | 2016-08-01 19:50 +0200 |
| Subject | [PATCH v7 01/16] remoteproc: st_slim_rproc: add a slimcore rproc driver |
| Message-ID | <s1pvI-YH-23@gated-at.bofh.it> |
| In reply to | #1453351 |
slim core is used as a basis for many IPs in the STi
chipsets such as fdma and demux. To avoid duplicating
the elf loading code in each device driver a slim
rproc driver has been created.
This driver is designed to be used by other device drivers
such as fdma, or demux whose IP is based around a slim core.
The device driver can call slim_rproc_alloc() to allocate
a slim rproc and slim_rproc_put() when finished.
This driver takes care of ioremapping the slim
registers (dmem, imem, slimcore, peripherals), whose offsets
and sizes can change between IP's. It also obtains and enables
any clocks used by the device. This approach avoids having
a double mapping of the registers as slim_rproc does not register
its own platform device. It also maps well to device tree
abstraction as it allows us to have one dt node for the whole
device.
All of the generic rproc elf loading code can be reused, and
we provide start() stop() hooks to start and stop the slim
core once the firmware has been loaded. This has been tested
successfully with fdma driver.
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
---
drivers/remoteproc/Kconfig | 7 +
drivers/remoteproc/Makefile | 1 +
drivers/remoteproc/st_slim_rproc.c | 376 +++++++++++++++++++++++++++++++
include/linux/remoteproc/st_slim_rproc.h | 53 +++++
4 files changed, 437 insertions(+)
create mode 100644 drivers/remoteproc/st_slim_rproc.c
create mode 100644 include/linux/remoteproc/st_slim_rproc.h
diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 72e97d7..e9f12d0 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -86,4 +86,11 @@ config ST_REMOTEPROC
processor framework.
This can be either built-in or a loadable module.
+config ST_SLIM_REMOTEPROC
+ tristate "ST Slim remoteproc support"
+ help
+ Say y here to support firmware loading on IP based around
+ the Slim core.
+ If unsure say N.
+
endmenu
diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
index 279cb2e..37bb39a 100644
--- a/drivers/remoteproc/Makefile
+++ b/drivers/remoteproc/Makefile
@@ -12,3 +12,4 @@ obj-$(CONFIG_STE_MODEM_RPROC) += ste_modem_rproc.o
obj-$(CONFIG_WKUP_M3_RPROC) += wkup_m3_rproc.o
obj-$(CONFIG_DA8XX_REMOTEPROC) += da8xx_remoteproc.o
obj-$(CONFIG_ST_REMOTEPROC) += st_remoteproc.o
+obj-$(CONFIG_ST_SLIM_REMOTEPROC) += st_slim_rproc.o
diff --git a/drivers/remoteproc/st_slim_rproc.c b/drivers/remoteproc/st_slim_rproc.c
new file mode 100644
index 0000000..3b10d0c
--- /dev/null
+++ b/drivers/remoteproc/st_slim_rproc.c
@@ -0,0 +1,376 @@
+/*
+ * st_slim_rproc.c
+ *
+ * Copyright (C) 2016 STMicroelectronics
+ * Author: Peter Griffin <peter.griffin@linaro.org>
+ * License terms: GNU General Public License (GPL), version 2
+ */
+
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/remoteproc.h>
+#include <linux/remoteproc/st_slim_rproc.h>
+#include "remoteproc_internal.h"
+
+/* slimcore registers */
+#define SLIM_ID_OFST 0x0
+#define SLIM_VER_OFST 0x4
+
+#define SLIM_EN_OFST 0x8
+#define SLIM_EN_RUN BIT(0)
+
+#define SLIM_CLK_GATE_OFST 0xC
+#define SLIM_CLK_GATE_DIS BIT(0)
+#define SLIM_CLK_GATE_RESET BIT(2)
+
+#define SLIM_SLIM_PC_OFST 0x20
+
+/* dmem registers */
+#define SLIM_REV_ID_OFST 0x0
+#define SLIM_REV_ID_MIN_MASK GENMASK(15, 8)
+#define SLIM_REV_ID_MIN(id) ((id & SLIM_REV_ID_MIN_MASK) >> 8)
+#define SLIM_REV_ID_MAJ_MASK GENMASK(23, 16)
+#define SLIM_REV_ID_MAJ(id) ((id & SLIM_REV_ID_MAJ_MASK) >> 16)
+
+
+/* peripherals registers */
+#define SLIM_STBUS_SYNC_OFST 0xF88
+#define SLIM_STBUS_SYNC_DIS BIT(0)
+
+#define SLIM_INT_SET_OFST 0xFD4
+#define SLIM_INT_CLR_OFST 0xFD8
+#define SLIM_INT_MASK_OFST 0xFDC
+
+#define SLIM_CMD_CLR_OFST 0xFC8
+#define SLIM_CMD_MASK_OFST 0xFCC
+
+static const char *mem_names[SLIM_MEM_MAX] = {
+ [SLIM_DMEM] = "dmem",
+ [SLIM_IMEM] = "imem",
+};
+
+static int slim_clk_get(struct st_slim_rproc *slim_rproc, struct device *dev)
+{
+ int clk, err;
+
+ for (clk = 0; clk < SLIM_MAX_CLK; clk++) {
+ slim_rproc->clks[clk] = of_clk_get(dev->of_node, clk);
+ if (IS_ERR(slim_rproc->clks[clk])) {
+ err = PTR_ERR(slim_rproc->clks[clk]);
+ if (err == -EPROBE_DEFER)
+ goto err_put_clks;
+ slim_rproc->clks[clk] = NULL;
+ break;
+ }
+ }
+
+ return 0;
+
+err_put_clks:
+ while (--clk >= 0)
+ clk_put(slim_rproc->clks[clk]);
+
+ return err;
+}
+
+static void slim_clk_disable(struct st_slim_rproc *slim_rproc)
+{
+ int clk;
+
+ for (clk = 0; clk < SLIM_MAX_CLK && slim_rproc->clks[clk]; clk++)
+ clk_disable_unprepare(slim_rproc->clks[clk]);
+}
+
+static int slim_clk_enable(struct st_slim_rproc *slim_rproc)
+{
+ int clk, ret;
+
+ for (clk = 0; clk < SLIM_MAX_CLK && slim_rproc->clks[clk]; clk++) {
+ ret = clk_prepare_enable(slim_rproc->clks[clk]);
+ if (ret)
+ goto err_disable_clks;
+ }
+
+ return 0;
+
+err_disable_clks:
+ while (--clk >= 0)
+ clk_disable_unprepare(slim_rproc->clks[clk]);
+
+ return ret;
+}
+
+/**
+ * Remoteproc slim specific device handlers
+ */
+static int slim_rproc_start(struct rproc *rproc)
+{
+ struct device *dev = &rproc->dev;
+ struct st_slim_rproc *slim_rproc = rproc->priv;
+ unsigned long hw_id, hw_ver, fw_rev;
+ u32 val;
+ int ret;
+
+ ret = slim_clk_enable(slim_rproc);
+ if (ret) {
+ dev_err(dev, "Failed to enable clocks\n");
+ goto err_clk;
+ }
+
+ /* disable CPU pipeline clock & reset cpu pipeline */
+ val = SLIM_CLK_GATE_DIS | SLIM_CLK_GATE_RESET;
+ writel(val, slim_rproc->slimcore + SLIM_CLK_GATE_OFST);
+
+ /* disable SLIM core STBus sync */
+ writel(SLIM_STBUS_SYNC_DIS, slim_rproc->peri + SLIM_STBUS_SYNC_OFST);
+
+ /* enable cpu pipeline clock */
+ writel(!SLIM_CLK_GATE_DIS,
+ slim_rproc->slimcore + SLIM_CLK_GATE_OFST);
+
+ /* clear int & cmd mailbox */
+ writel(~0U, slim_rproc->peri + SLIM_INT_CLR_OFST);
+ writel(~0U, slim_rproc->peri + SLIM_CMD_CLR_OFST);
+
+ /* enable all channels cmd & int */
+ writel(~0U, slim_rproc->peri + SLIM_INT_MASK_OFST);
+ writel(~0U, slim_rproc->peri + SLIM_CMD_MASK_OFST);
+
+ /* enable cpu */
+ writel(SLIM_EN_RUN, slim_rproc->slimcore + SLIM_EN_OFST);
+
+ hw_id = readl_relaxed(slim_rproc->slimcore + SLIM_ID_OFST);
+ hw_ver = readl_relaxed(slim_rproc->slimcore + SLIM_VER_OFST);
+
+ fw_rev = readl(slim_rproc->mem[SLIM_DMEM].cpu_addr +
+ SLIM_REV_ID_OFST);
+
+ dev_info(dev, "fw rev:%ld.%ld on SLIM %ld.%ld\n",
+ SLIM_REV_ID_MAJ(fw_rev), SLIM_REV_ID_MIN(fw_rev),
+ hw_id, hw_ver);
+
+err_clk:
+ return ret;
+}
+
+static int slim_rproc_stop(struct rproc *rproc)
+{
+ struct st_slim_rproc *slim_rproc = rproc->priv;
+ u32 val;
+
+ /* mask all (cmd & int) channels */
+ writel(0UL, slim_rproc->peri + SLIM_INT_MASK_OFST);
+ writel(0UL, slim_rproc->peri + SLIM_CMD_MASK_OFST);
+
+ /* disable cpu pipeline clock */
+ writel(SLIM_CLK_GATE_DIS
+ , slim_rproc->slimcore + SLIM_CLK_GATE_OFST);
+
+ writel(!SLIM_EN_RUN, slim_rproc->slimcore + SLIM_EN_OFST);
+
+ val = readl(slim_rproc->slimcore + SLIM_EN_OFST);
+ if (val & SLIM_EN_RUN)
+ dev_warn(&rproc->dev, "Failed to disable SLIM");
+
+ slim_clk_disable(slim_rproc);
+
+ dev_dbg(&rproc->dev, "slim stopped\n");
+
+ return 0;
+}
+
+static void *slim_rproc_da_to_va(struct rproc *rproc, u64 da, int len)
+{
+ struct st_slim_rproc *slim_rproc = rproc->priv;
+ void *va = NULL;
+ int i;
+
+ for (i = 0; i < SLIM_MEM_MAX; i++) {
+ if (da != slim_rproc->mem[i].bus_addr)
+ continue;
+ /* __force to make sparse happy with type conversion */
+ va = (__force void *)slim_rproc->mem[i].cpu_addr;
+ break;
+ }
+
+ dev_dbg(&rproc->dev, "%s: da = 0x%llx len = 0x%x va = 0x%p\n",
+ __func__, da, len, va);
+
+ return va;
+}
+
+static struct rproc_ops slim_rproc_ops = {
+ .start = slim_rproc_start,
+ .stop = slim_rproc_stop,
+ .da_to_va = slim_rproc_da_to_va,
+};
+
+/**
+ * Firmware handler operations: sanity, boot address, load ...
+ */
+
+static struct resource_table empty_rsc_tbl = {
+ .ver = 1,
+ .num = 0,
+};
+
+static struct resource_table *slim_rproc_find_rsc_table(struct rproc *rproc,
+ const struct firmware *fw,
+ int *tablesz)
+{
+ if (!fw)
+ return NULL;
+
+ *tablesz = sizeof(empty_rsc_tbl);
+ return &empty_rsc_tbl;
+}
+
+static struct resource_table *slim_rproc_find_loaded_rsc_table(struct rproc *rproc,
+ const struct firmware *fw)
+{
+ if (!fw)
+ return NULL;
+
+ return &empty_rsc_tbl;
+}
+
+static struct rproc_fw_ops slim_rproc_fw_ops = {
+ .find_rsc_table = slim_rproc_find_rsc_table,
+ .find_loaded_rsc_table = slim_rproc_find_loaded_rsc_table,
+};
+
+
+/**
+ * slim_rproc_alloc() - allocate and initialise slim rproc
+ * @pdev: Pointer to the platform_device struct
+ * @fw_name: Name of firmware for rproc to use
+ *
+ * Function for allocating and initialising a slim rproc for use by
+ * device drivers whose IP is based around the slim slim core. It
+ * obtains and enables any clocks required by the slim core and also
+ * ioremaps the various IO.
+ *
+ * Returns st_slim_rproc pointer or PTR_ERR() on error.
+ */
+
+struct st_slim_rproc *slim_rproc_alloc(struct platform_device *pdev,
+ char *fw_name)
+{
+ struct device *dev = &pdev->dev;
+ struct st_slim_rproc *slim_rproc;
+ struct device_node *np = dev->of_node;
+ struct rproc *rproc;
+ struct resource *res;
+ int err, i;
+ const struct rproc_fw_ops *elf_ops;
+
+ if (WARN_ON(!np || !fw_name))
+ return ERR_PTR(-EINVAL);
+
+ if (!of_device_is_compatible(np, "st,slim-rproc"))
+ return ERR_PTR(-EINVAL);
+
+ rproc = rproc_alloc(dev, np->name, &slim_rproc_ops,
+ fw_name, sizeof(*slim_rproc));
+ if (!rproc)
+ return ERR_PTR(-ENOMEM);
+
+ rproc->has_iommu = false;
+
+ slim_rproc = rproc->priv;
+ slim_rproc->rproc = rproc;
+
+ elf_ops = rproc->fw_ops;
+ /* Use some generic elf ops */
+ slim_rproc_fw_ops.load = elf_ops->load;
+ slim_rproc_fw_ops.sanity_check = elf_ops->sanity_check;
+
+ rproc->fw_ops = &slim_rproc_fw_ops;
+
+ /* get imem and dmem */
+ for (i = 0; i < ARRAY_SIZE(mem_names); i++) {
+
+ res = platform_get_resource_byname
+ (pdev, IORESOURCE_MEM, mem_names[i]);
+
+ slim_rproc->mem[i].cpu_addr = devm_ioremap_resource(dev, res);
+ if (IS_ERR(slim_rproc->mem[i].cpu_addr)) {
+ dev_err(&pdev->dev, "devm_ioremap_resource failed\n");
+ err = PTR_ERR(slim_rproc->mem[i].cpu_addr);
+ goto err;
+ }
+ slim_rproc->mem[i].bus_addr = res->start;
+ slim_rproc->mem[i].size = resource_size(res);
+ }
+
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "slimcore");
+
+ slim_rproc->slimcore = devm_ioremap_resource(dev, res);
+ if (IS_ERR(slim_rproc->slimcore)) {
+ dev_err(&pdev->dev,
+ "devm_ioremap_resource failed for slimcore\n");
+ err = PTR_ERR(slim_rproc->slimcore);
+ goto err;
+ }
+
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "peripherals");
+
+ slim_rproc->peri = devm_ioremap_resource(dev, res);
+ if (IS_ERR(slim_rproc->peri)) {
+ dev_err(&pdev->dev, "devm_ioremap_resource failed for peri\n");
+ err = PTR_ERR(slim_rproc->peri);
+ goto err;
+ }
+
+ err = slim_clk_get(slim_rproc, dev);
+ if (err)
+ goto err;
+
+ /* Register as a remoteproc device */
+ err = rproc_add(rproc);
+ if (err) {
+ dev_err(dev, "registration of slim remoteproc failed\n");
+ goto err_clk;
+ }
+
+ return slim_rproc;
+
+err_clk:
+ for (i = 0; i < SLIM_MAX_CLK && slim_rproc->clks[i]; i++)
+ clk_put(slim_rproc->clks[i]);
+err:
+ rproc_put(rproc);
+ return ERR_PTR(err);
+}
+EXPORT_SYMBOL(slim_rproc_alloc);
+
+/**
+ * slim_rproc_put() - put slim rproc resources
+ * @slim_rproc: Pointer to the st_slim_rproc struct
+ *
+ * Function for calling respective _put() functions on
+ * slim_rproc resources.
+ *
+ */
+void slim_rproc_put(struct st_slim_rproc *slim_rproc)
+{
+ int clk;
+
+ if (!slim_rproc)
+ return;
+
+ for (clk = 0; clk < SLIM_MAX_CLK && slim_rproc->clks[clk]; clk++)
+ clk_put(slim_rproc->clks[clk]);
+
+ rproc_put(slim_rproc->rproc);
+}
+EXPORT_SYMBOL(slim_rproc_put);
+
+MODULE_AUTHOR("Peter Griffin");
+MODULE_DESCRIPTION("STMicroelectronics SLIM rproc driver");
+MODULE_LICENSE("GPL v2");
diff --git a/include/linux/remoteproc/st_slim_rproc.h b/include/linux/remoteproc/st_slim_rproc.h
new file mode 100644
index 0000000..c300b3e
--- /dev/null
+++ b/include/linux/remoteproc/st_slim_rproc.h
@@ -0,0 +1,53 @@
+/*
+ * st_slim_rproc.h
+ *
+ * Copyright (C) 2016 STMicroelectronics
+ * Author: Peter Griffin <peter.griffin@linaro.org>
+ * License terms: GNU General Public License (GPL), version 2
+ */
+#ifndef _ST_SLIM_H
+#define _ST_SLIM_H
+
+#define SLIM_MEM_MAX 2
+#define SLIM_MAX_CLK 4
+
+enum {
+ SLIM_DMEM,
+ SLIM_IMEM,
+};
+
+/**
+ * struct slim_mem - slim internal memory structure
+ * @cpu_addr: MPU virtual address of the memory region
+ * @bus_addr: Bus address used to access the memory region
+ * @size: Size of the memory region
+ */
+struct slim_mem {
+ void __iomem *cpu_addr;
+ phys_addr_t bus_addr;
+ size_t size;
+};
+
+/**
+ * struct st_slim_rproc - SLIM slim core
+ * @rproc: rproc handle
+ * @mem: slim memory information
+ * @slimcore: slim slimcore regs
+ * @peri: slim peripheral regs
+ * @clks: slim clocks
+ */
+struct st_slim_rproc {
+ struct rproc *rproc;
+ struct slim_mem mem[SLIM_MEM_MAX];
+ void __iomem *slimcore;
+ void __iomem *peri;
+
+ /* st_slim_rproc private */
+ struct clk *clks[SLIM_MAX_CLK];
+};
+
+struct st_slim_rproc *slim_rproc_alloc(struct platform_device *pdev,
+ char *fw_name);
+void slim_rproc_put(struct st_slim_rproc *slim_rproc);
+
+#endif
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Bjorn Andersson <bjorn.andersson@linaro.org> |
|---|---|
| Date | 2016-08-10 21:30 +0200 |
| Subject | Re: [PATCH v7 01/16] remoteproc: st_slim_rproc: add a slimcore rproc driver |
| Message-ID | <s4Hmq-Ul-39@gated-at.bofh.it> |
| In reply to | #1453372 |
On Mon 01 Aug 10:10 PDT 2016, Peter Griffin wrote:
Sorry for the slow response, but I have a few more (small) concerns.
[..]
> diff --git a/drivers/remoteproc/st_slim_rproc.c b/drivers/remoteproc/st_slim_rproc.c
[..]
> +static int slim_rproc_start(struct rproc *rproc)
> +{
> + struct device *dev = &rproc->dev;
> + struct st_slim_rproc *slim_rproc = rproc->priv;
> + unsigned long hw_id, hw_ver, fw_rev;
> + u32 val;
> + int ret;
> +
> + ret = slim_clk_enable(slim_rproc);
> + if (ret) {
> + dev_err(dev, "Failed to enable clocks\n");
> + goto err_clk;
Nit. just return ret here and have a static "return 0" at the bottom.
> + }
> +
> + /* disable CPU pipeline clock & reset cpu pipeline */
> + val = SLIM_CLK_GATE_DIS | SLIM_CLK_GATE_RESET;
> + writel(val, slim_rproc->slimcore + SLIM_CLK_GATE_OFST);
> +
> + /* disable SLIM core STBus sync */
> + writel(SLIM_STBUS_SYNC_DIS, slim_rproc->peri + SLIM_STBUS_SYNC_OFST);
> +
> + /* enable cpu pipeline clock */
> + writel(!SLIM_CLK_GATE_DIS,
> + slim_rproc->slimcore + SLIM_CLK_GATE_OFST);
> +
> + /* clear int & cmd mailbox */
> + writel(~0U, slim_rproc->peri + SLIM_INT_CLR_OFST);
> + writel(~0U, slim_rproc->peri + SLIM_CMD_CLR_OFST);
> +
> + /* enable all channels cmd & int */
> + writel(~0U, slim_rproc->peri + SLIM_INT_MASK_OFST);
> + writel(~0U, slim_rproc->peri + SLIM_CMD_MASK_OFST);
> +
> + /* enable cpu */
> + writel(SLIM_EN_RUN, slim_rproc->slimcore + SLIM_EN_OFST);
> +
> + hw_id = readl_relaxed(slim_rproc->slimcore + SLIM_ID_OFST);
> + hw_ver = readl_relaxed(slim_rproc->slimcore + SLIM_VER_OFST);
> +
> + fw_rev = readl(slim_rproc->mem[SLIM_DMEM].cpu_addr +
> + SLIM_REV_ID_OFST);
> +
> + dev_info(dev, "fw rev:%ld.%ld on SLIM %ld.%ld\n",
> + SLIM_REV_ID_MAJ(fw_rev), SLIM_REV_ID_MIN(fw_rev),
> + hw_id, hw_ver);
> +
> +err_clk:
> + return ret;
> +}
> +
> +static int slim_rproc_stop(struct rproc *rproc)
> +{
> + struct st_slim_rproc *slim_rproc = rproc->priv;
> + u32 val;
> +
> + /* mask all (cmd & int) channels */
> + writel(0UL, slim_rproc->peri + SLIM_INT_MASK_OFST);
> + writel(0UL, slim_rproc->peri + SLIM_CMD_MASK_OFST);
> +
> + /* disable cpu pipeline clock */
> + writel(SLIM_CLK_GATE_DIS
> + , slim_rproc->slimcore + SLIM_CLK_GATE_OFST);
Odd placement of ','
> +
> + writel(!SLIM_EN_RUN, slim_rproc->slimcore + SLIM_EN_OFST);
> +
> + val = readl(slim_rproc->slimcore + SLIM_EN_OFST);
> + if (val & SLIM_EN_RUN)
> + dev_warn(&rproc->dev, "Failed to disable SLIM");
> +
> + slim_clk_disable(slim_rproc);
> +
> + dev_dbg(&rproc->dev, "slim stopped\n");
> +
> + return 0;
> +}
> +
> +static void *slim_rproc_da_to_va(struct rproc *rproc, u64 da, int len)
> +{
> + struct st_slim_rproc *slim_rproc = rproc->priv;
> + void *va = NULL;
> + int i;
> +
> + for (i = 0; i < SLIM_MEM_MAX; i++) {
> + if (da != slim_rproc->mem[i].bus_addr)
> + continue;
Are you sure you want to enforce this being called with da == base? (I'm
not totally against it).
But you should probably double check that len is <= mem[i].size.
> + /* __force to make sparse happy with type conversion */
> + va = (__force void *)slim_rproc->mem[i].cpu_addr;
> + break;
> + }
> +
> + dev_dbg(&rproc->dev, "%s: da = 0x%llx len = 0x%x va = 0x%p\n",
> + __func__, da, len, va);
> +
> + return va;
> +}
> +
> +static struct rproc_ops slim_rproc_ops = {
> + .start = slim_rproc_start,
> + .stop = slim_rproc_stop,
> + .da_to_va = slim_rproc_da_to_va,
> +};
> +
> +/**
> + * Firmware handler operations: sanity, boot address, load ...
> + */
> +
> +static struct resource_table empty_rsc_tbl = {
> + .ver = 1,
> + .num = 0,
> +};
> +
> +static struct resource_table *slim_rproc_find_rsc_table(struct rproc *rproc,
> + const struct firmware *fw,
> + int *tablesz)
> +{
> + if (!fw)
> + return NULL;
I consider it a BUG in the core to get here with fw == NULL, so please
drop this.
> +
> + *tablesz = sizeof(empty_rsc_tbl);
> + return &empty_rsc_tbl;
> +}
> +
> +static struct resource_table *slim_rproc_find_loaded_rsc_table(struct rproc *rproc,
> + const struct firmware *fw)
> +{
> + if (!fw)
> + return NULL;
> +
fw can't be NULL, so please drop this check.
> + return &empty_rsc_tbl;
This function is supposed to return a pointer to the resource table as
it appears in the space of the running firmware, so that any vring
updates etc are visible to the remote.
As your firmware doesn't do this you should return NULL here, rather
than a pointer back to the fake resource table.
But rproc_find_loaded_rsc_table() will do the same if you omit the
reference in the fw_ops struct, so just make that NULL instead.
> +}
> +
> +static struct rproc_fw_ops slim_rproc_fw_ops = {
> + .find_rsc_table = slim_rproc_find_rsc_table,
> + .find_loaded_rsc_table = slim_rproc_find_loaded_rsc_table,
> +};
> +
> +
> +/**
> + * slim_rproc_alloc() - allocate and initialise slim rproc
> + * @pdev: Pointer to the platform_device struct
> + * @fw_name: Name of firmware for rproc to use
> + *
> + * Function for allocating and initialising a slim rproc for use by
> + * device drivers whose IP is based around the slim slim core. It
> + * obtains and enables any clocks required by the slim core and also
> + * ioremaps the various IO.
> + *
> + * Returns st_slim_rproc pointer or PTR_ERR() on error.
> + */
> +
> +struct st_slim_rproc *slim_rproc_alloc(struct platform_device *pdev,
> + char *fw_name)
> +{
> + struct device *dev = &pdev->dev;
> + struct st_slim_rproc *slim_rproc;
> + struct device_node *np = dev->of_node;
> + struct rproc *rproc;
> + struct resource *res;
> + int err, i;
> + const struct rproc_fw_ops *elf_ops;
> +
> + if (WARN_ON(!np || !fw_name))
> + return ERR_PTR(-EINVAL);
> +
> + if (!of_device_is_compatible(np, "st,slim-rproc"))
> + return ERR_PTR(-EINVAL);
> +
> + rproc = rproc_alloc(dev, np->name, &slim_rproc_ops,
> + fw_name, sizeof(*slim_rproc));
> + if (!rproc)
> + return ERR_PTR(-ENOMEM);
> +
> + rproc->has_iommu = false;
> +
> + slim_rproc = rproc->priv;
> + slim_rproc->rproc = rproc;
> +
> + elf_ops = rproc->fw_ops;
> + /* Use some generic elf ops */
> + slim_rproc_fw_ops.load = elf_ops->load;
> + slim_rproc_fw_ops.sanity_check = elf_ops->sanity_check;
> +
> + rproc->fw_ops = &slim_rproc_fw_ops;
> +
> + /* get imem and dmem */
> + for (i = 0; i < ARRAY_SIZE(mem_names); i++) {
> +
> + res = platform_get_resource_byname
> + (pdev, IORESOURCE_MEM, mem_names[i]);
This is an odd line breakage.
> +
> + slim_rproc->mem[i].cpu_addr = devm_ioremap_resource(dev, res);
> + if (IS_ERR(slim_rproc->mem[i].cpu_addr)) {
> + dev_err(&pdev->dev, "devm_ioremap_resource failed\n");
> + err = PTR_ERR(slim_rproc->mem[i].cpu_addr);
> + goto err;
> + }
> + slim_rproc->mem[i].bus_addr = res->start;
> + slim_rproc->mem[i].size = resource_size(res);
> + }
> +
> + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "slimcore");
> +
> + slim_rproc->slimcore = devm_ioremap_resource(dev, res);
> + if (IS_ERR(slim_rproc->slimcore)) {
> + dev_err(&pdev->dev,
> + "devm_ioremap_resource failed for slimcore\n");
> + err = PTR_ERR(slim_rproc->slimcore);
> + goto err;
> + }
> +
> + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "peripherals");
> +
> + slim_rproc->peri = devm_ioremap_resource(dev, res);
> + if (IS_ERR(slim_rproc->peri)) {
> + dev_err(&pdev->dev, "devm_ioremap_resource failed for peri\n");
> + err = PTR_ERR(slim_rproc->peri);
> + goto err;
> + }
> +
> + err = slim_clk_get(slim_rproc, dev);
> + if (err)
> + goto err;
> +
> + /* Register as a remoteproc device */
> + err = rproc_add(rproc);
> + if (err) {
> + dev_err(dev, "registration of slim remoteproc failed\n");
> + goto err_clk;
> + }
> +
> + return slim_rproc;
> +
> +err_clk:
> + for (i = 0; i < SLIM_MAX_CLK && slim_rproc->clks[i]; i++)
> + clk_put(slim_rproc->clks[i]);
Is there any chance to could acquire these clocks by name instead of
just picking up 4 "random" clocks from the DT node?
You are generally supposed to use clock-names and could then use
devm_clk_get() instead...
> +err:
> + rproc_put(rproc);
> + return ERR_PTR(err);
> +}
> +EXPORT_SYMBOL(slim_rproc_alloc);
> +
> +/**
> + * slim_rproc_put() - put slim rproc resources
> + * @slim_rproc: Pointer to the st_slim_rproc struct
> + *
> + * Function for calling respective _put() functions on
> + * slim_rproc resources.
> + *
> + */
> +void slim_rproc_put(struct st_slim_rproc *slim_rproc)
> +{
> + int clk;
> +
> + if (!slim_rproc)
> + return;
> +
> + for (clk = 0; clk < SLIM_MAX_CLK && slim_rproc->clks[clk]; clk++)
> + clk_put(slim_rproc->clks[clk]);
> +
You need to rproc_del() here before calling rproc_put().
> + rproc_put(slim_rproc->rproc);
> +}
> +EXPORT_SYMBOL(slim_rproc_put);
> +
> +MODULE_AUTHOR("Peter Griffin");
> +MODULE_DESCRIPTION("STMicroelectronics SLIM rproc driver");
> +MODULE_LICENSE("GPL v2");
> diff --git a/include/linux/remoteproc/st_slim_rproc.h b/include/linux/remoteproc/st_slim_rproc.h
> new file mode 100644
> index 0000000..c300b3e
> --- /dev/null
> +++ b/include/linux/remoteproc/st_slim_rproc.h
> @@ -0,0 +1,53 @@
> +/*
> + * st_slim_rproc.h
> + *
> + * Copyright (C) 2016 STMicroelectronics
> + * Author: Peter Griffin <peter.griffin@linaro.org>
> + * License terms: GNU General Public License (GPL), version 2
> + */
> +#ifndef _ST_SLIM_H
> +#define _ST_SLIM_H
> +
> +#define SLIM_MEM_MAX 2
> +#define SLIM_MAX_CLK 4
> +
> +enum {
> + SLIM_DMEM,
> + SLIM_IMEM,
> +};
> +
> +/**
> + * struct slim_mem - slim internal memory structure
> + * @cpu_addr: MPU virtual address of the memory region
> + * @bus_addr: Bus address used to access the memory region
> + * @size: Size of the memory region
> + */
> +struct slim_mem {
> + void __iomem *cpu_addr;
> + phys_addr_t bus_addr;
> + size_t size;
> +};
> +
With things like slimbus being worked on I don't think it's appropriate
to introduce public constants named SLIM_* or slim_*. Please rename
these ST_SLIM_* and st_slim_*
> +/**
> + * struct st_slim_rproc - SLIM slim core
> + * @rproc: rproc handle
> + * @mem: slim memory information
> + * @slimcore: slim slimcore regs
> + * @peri: slim peripheral regs
> + * @clks: slim clocks
> + */
> +struct st_slim_rproc {
> + struct rproc *rproc;
> + struct slim_mem mem[SLIM_MEM_MAX];
> + void __iomem *slimcore;
> + void __iomem *peri;
> +
> + /* st_slim_rproc private */
> + struct clk *clks[SLIM_MAX_CLK];
> +};
> +
> +struct st_slim_rproc *slim_rproc_alloc(struct platform_device *pdev,
> + char *fw_name);
> +void slim_rproc_put(struct st_slim_rproc *slim_rproc);
> +
> +#endif
Regards,
Bjorn
[toc] | [prev] | [next] | [standalone]
| From | Peter Griffin <peter.griffin@linaro.org> |
|---|---|
| Date | 2016-08-01 21:10 +0200 |
| Subject | [PATCH v7 03/16] dmaengine: st_fdma: Add STMicroelectronics FDMA DT binding documentation |
| Message-ID | <s1qL7-1VI-1@gated-at.bofh.it> |
| In reply to | #1453351 |
This patch adds the DT binding documentation for the FDMA constroller
found on STi based chipsets from STMicroelectronics.
Signed-off-by: Ludovic Barre <ludovic.barre@st.com>
Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Acked-by: Rob Herring <robh@kernel.org>
---
Documentation/devicetree/bindings/dma/st_fdma.txt | 87 +++++++++++++++++++++++
1 file changed, 87 insertions(+)
create mode 100644 Documentation/devicetree/bindings/dma/st_fdma.txt
diff --git a/Documentation/devicetree/bindings/dma/st_fdma.txt b/Documentation/devicetree/bindings/dma/st_fdma.txt
new file mode 100644
index 0000000..495d853
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/st_fdma.txt
@@ -0,0 +1,87 @@
+* STMicroelectronics Flexible Direct Memory Access Device Tree bindings
+
+The FDMA is a general-purpose direct memory access controller capable of
+supporting 16 independent DMA channels. It accepts up to 32 DMA requests.
+The FDMA is based on a Slim processor which requires a firmware.
+
+* FDMA Controller
+
+Required properties:
+- compatible : Should be one of
+ - st,stih407-fdma-mpe31-11, "st,slim-rproc";
+ - st,stih407-fdma-mpe31-12, "st,slim-rproc";
+ - st,stih407-fdma-mpe31-13, "st,slim-rproc";
+- reg : Should contain an entry for each name in reg-names
+- reg-names : Must contain "slimcore", "dmem", "peripherals", "imem" entries
+- interrupts : Should contain one interrupt shared by all channels
+- dma-channels : Number of channels supported by the controller
+- #dma-cells : Must be <3>. See DMA client section below
+- clocks : Must contain an entry for each clock
+See: Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+
+Example:
+
+ fdma0: dma-controller@8e20000 {
+ compatible = "st,stih407-fdma-mpe31-11", "st,slim-rproc";
+ reg = <0x8e20000 0x8000>,
+ <0x8e30000 0x3000>,
+ <0x8e37000 0x1000>,
+ <0x8e38000 0x8000>;
+ reg-names = "slimcore", "dmem", "peripherals", "imem";
+ clocks = <&clk_s_c0_flexgen CLK_FDMA>,
+ <&clk_s_c0_flexgen CLK_EXT2F_A9>,
+ <&clk_s_c0_flexgen CLK_EXT2F_A9>,
+ <&clk_s_c0_flexgen CLK_EXT2F_A9>;
+ interrupts = <GIC_SPI 5 IRQ_TYPE_NONE>;
+ dma-channels = <16>;
+ #dma-cells = <3>;
+ };
+
+* DMA client
+
+Required properties:
+- dmas: Comma separated list of dma channel requests
+- dma-names: Names of the aforementioned requested channels
+
+Each dmas request consists of 4 cells:
+1. A phandle pointing to the FDMA controller
+2. The request line number
+3. A 32bit mask specifying (see include/linux/platform_data/dma-st-fdma.h)
+ -bit 2-0: Holdoff value, dreq will be masked for
+ 0x0: 0-0.5us
+ 0x1: 0.5-1us
+ 0x2: 1-1.5us
+ -bit 17: data swap
+ 0x0: disabled
+ 0x1: enabled
+ -bit 21: Increment Address
+ 0x0: no address increment between transfers
+ 0x1: increment address between transfers
+ -bit 22: 2 STBus Initiator Coprocessor interface
+ 0x0: high priority port
+ 0x1: low priority port
+4. transfers type
+ 0 free running
+ 1 paced
+
+Example:
+
+ sti_uni_player2: sti-uni-player@2 {
+ compatible = "st,sti-uni-player";
+ status = "disabled";
+ #sound-dai-cells = <0>;
+ st,syscfg = <&syscfg_core>;
+ clocks = <&clk_s_d0_flexgen CLK_PCM_2>;
+ assigned-clocks = <&clk_s_d0_flexgen CLK_PCM_2>;
+ assigned-clock-parents = <&clk_s_d0_quadfs 2>;
+ assigned-clock-rates = <50000000>;
+ reg = <0x8D82000 0x158>;
+ interrupts = <GIC_SPI 86 IRQ_TYPE_NONE>;
+ dmas = <&fdma0 4 0 1>;
+ dai-name = "Uni Player #1 (DAC)";
+ dma-names = "tx";
+ st,uniperiph-id = <2>;
+ st,version = <5>;
+ st,mode = "PCM";
+ };
--
1.9.1
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web