* [PATCH 00/10] add mcf54415 DAC driver
@ 2026-05-04 17:16 Angelo Dureghello
2026-05-04 17:16 ` [PATCH 01/10] m68k: mcf5441x: fix clocks numbering Angelo Dureghello
` (10 more replies)
0 siblings, 11 replies; 21+ messages in thread
From: Angelo Dureghello @ 2026-05-04 17:16 UTC (permalink / raw)
To: Greg Ungerer, Geert Uytterhoeven, Steven King, Arnd Bergmann,
Maxime Coquelin, Alexandre Torgue, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko
Cc: Greg Ungerer, linux-m68k, linux-kernel, linux-stm32,
linux-arm-kernel, linux-iio, Angelo Dureghello
This patchset adds a minimalistic DAC driver for the NXP mcf54415/6/7/8
builtin DACs.
Currently the driver enables the raw write only. Feature as dma, sync, or
format are not supoprted for this version.
Additional options suppoerted by the DAC module will be added to the driver
later on, as needed.
The same patchset prepares the m68k/coldfire architecture to support
the driver.
---
Angelo Dureghello (10):
m68k: mcf5441x: fix clocks numbering
m68k: mcf5441x: add clock for DAC channel 1
m68k: mcf5441x: setup DAC clock name as per driver name
m68k: defconfig: update stmark2 defconfig
m68k: add DAC modules base addresses
m68k: mcf5441x: add CCM registers
m68k: mcf5441x: add CCR MISCCR2 bitfields
m68k: stmark2: add mcf5441x DAC platform devices
m68k: stmark2: enable DACs outputs
iio: dac: add mcf54415 DAC
arch/m68k/coldfire/m5441x.c | 21 ++--
arch/m68k/coldfire/stmark2.c | 42 ++++++++
arch/m68k/configs/stmark2_defconfig | 2 +
arch/m68k/include/asm/m5441xsim.h | 40 ++++++++
drivers/iio/dac/Kconfig | 10 ++
drivers/iio/dac/Makefile | 1 +
drivers/iio/dac/mcf54415_dac.c | 200 ++++++++++++++++++++++++++++++++++++
7 files changed, 307 insertions(+), 9 deletions(-)
---
base-commit: 8b4b975922f607411217c81942e82f1d206ebc61
change-id: 20260430-wip-stmark2-dac-7060f49dd94f
Best regards,
--
Angelo Dureghello <adureghello@baylibre.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 01/10] m68k: mcf5441x: fix clocks numbering
2026-05-04 17:16 [PATCH 00/10] add mcf54415 DAC driver Angelo Dureghello
@ 2026-05-04 17:16 ` Angelo Dureghello
2026-05-04 17:16 ` [PATCH 02/10] m68k: mcf5441x: add clock for DAC channel 1 Angelo Dureghello
` (9 subsequent siblings)
10 siblings, 0 replies; 21+ messages in thread
From: Angelo Dureghello @ 2026-05-04 17:16 UTC (permalink / raw)
To: Greg Ungerer, Geert Uytterhoeven, Steven King, Arnd Bergmann,
Maxime Coquelin, Alexandre Torgue, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko
Cc: Greg Ungerer, linux-m68k, linux-kernel, linux-stm32,
linux-arm-kernel, linux-iio, Angelo Dureghello
From: Angelo Dureghello <adureghello@baylibre.com>
Fix clocks numbering, set correct values for eport and DAC,
as per RM Rev 5, 05/2018, table 9.5.
Fixes: bea8bcb12da09 ("m68knommu: Add support for the Coldfire m5441x.")
Fixes: 007f84ede6e3e ("m68k: coldfire: remove private clk_get/clk_put")
Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
---
arch/m68k/coldfire/m5441x.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/arch/m68k/coldfire/m5441x.c b/arch/m68k/coldfire/m5441x.c
index 7a25cfc7ac07..ac9c17d0ee64 100644
--- a/arch/m68k/coldfire/m5441x.c
+++ b/arch/m68k/coldfire/m5441x.c
@@ -41,9 +41,9 @@ DEFINE_CLK(0, "mcfpit.0", 32, MCF_BUSCLK);
DEFINE_CLK(0, "mcfpit.1", 33, MCF_BUSCLK);
DEFINE_CLK(0, "mcfpit.2", 34, MCF_BUSCLK);
DEFINE_CLK(0, "mcfpit.3", 35, MCF_BUSCLK);
-DEFINE_CLK(0, "mcfeport.0", 37, MCF_CLK);
-DEFINE_CLK(0, "mcfadc.0", 38, MCF_CLK);
-DEFINE_CLK(0, "mcfdac.0", 39, MCF_CLK);
+DEFINE_CLK(0, "mcfeport.0", 36, MCF_CLK);
+DEFINE_CLK(0, "mcfadc.0", 37, MCF_CLK);
+DEFINE_CLK(0, "mcfdac.0", 38, MCF_CLK);
DEFINE_CLK(0, "mcfrtc.0", 42, MCF_CLK);
DEFINE_CLK(0, "mcfsim.0", 43, MCF_CLK);
DEFINE_CLK(0, "mcfusb-otg.0", 44, MCF_CLK);
@@ -103,9 +103,9 @@ static struct clk_lookup m5411x_clk_lookup[] = {
CLKDEV_INIT("mcfpit.1", NULL, &__clk_0_33),
CLKDEV_INIT("mcfpit.2", NULL, &__clk_0_34),
CLKDEV_INIT("mcfpit.3", NULL, &__clk_0_35),
- CLKDEV_INIT("mcfeport.0", NULL, &__clk_0_37),
- CLKDEV_INIT("mcfadc.0", NULL, &__clk_0_38),
- CLKDEV_INIT("mcfdac.0", NULL, &__clk_0_39),
+ CLKDEV_INIT("mcfeport.0", NULL, &__clk_0_36),
+ CLKDEV_INIT("mcfadc.0", NULL, &__clk_0_37),
+ CLKDEV_INIT("mcfdac.0", NULL, &__clk_0_38),
CLKDEV_INIT("mcfrtc.0", NULL, &__clk_0_42),
CLKDEV_INIT("mcfsim.0", NULL, &__clk_0_43),
CLKDEV_INIT("mcfusb-otg.0", NULL, &__clk_0_44),
@@ -156,7 +156,7 @@ static struct clk * const enable_clks[] __initconst = {
&__clk_0_27, /* uart3 */
&__clk_0_33, /* pit.1 */
- &__clk_0_37, /* eport */
+ &__clk_0_36, /* eport */
&__clk_0_48, /* pll */
&__clk_0_51, /* esdhc */
@@ -174,8 +174,8 @@ static struct clk * const disable_clks[] __initconst = {
&__clk_0_32, /* pit.0 */
&__clk_0_34, /* pit.2 */
&__clk_0_35, /* pit.3 */
- &__clk_0_38, /* adc */
- &__clk_0_39, /* dac */
+ &__clk_0_37, /* adc */
+ &__clk_0_38, /* dac.0 */
&__clk_0_44, /* usb otg */
&__clk_0_45, /* usb host */
&__clk_0_47, /* ssi.0 */
--
2.54.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 02/10] m68k: mcf5441x: add clock for DAC channel 1
2026-05-04 17:16 [PATCH 00/10] add mcf54415 DAC driver Angelo Dureghello
2026-05-04 17:16 ` [PATCH 01/10] m68k: mcf5441x: fix clocks numbering Angelo Dureghello
@ 2026-05-04 17:16 ` Angelo Dureghello
2026-05-04 17:16 ` [PATCH 03/10] m68k: mcf5441x: setup DAC clock name as per driver name Angelo Dureghello
` (8 subsequent siblings)
10 siblings, 0 replies; 21+ messages in thread
From: Angelo Dureghello @ 2026-05-04 17:16 UTC (permalink / raw)
To: Greg Ungerer, Geert Uytterhoeven, Steven King, Arnd Bergmann,
Maxime Coquelin, Alexandre Torgue, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko
Cc: Greg Ungerer, linux-m68k, linux-kernel, linux-stm32,
linux-arm-kernel, linux-iio, Angelo Dureghello
From: Angelo Dureghello <adureghello@baylibre.com>
Add missing clock for mcf5441x DAC channel 1.
Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
---
arch/m68k/coldfire/m5441x.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/m68k/coldfire/m5441x.c b/arch/m68k/coldfire/m5441x.c
index ac9c17d0ee64..5c33d3896cf7 100644
--- a/arch/m68k/coldfire/m5441x.c
+++ b/arch/m68k/coldfire/m5441x.c
@@ -44,6 +44,7 @@ DEFINE_CLK(0, "mcfpit.3", 35, MCF_BUSCLK);
DEFINE_CLK(0, "mcfeport.0", 36, MCF_CLK);
DEFINE_CLK(0, "mcfadc.0", 37, MCF_CLK);
DEFINE_CLK(0, "mcfdac.0", 38, MCF_CLK);
+DEFINE_CLK(0, "mcfdac.1", 39, MCF_CLK);
DEFINE_CLK(0, "mcfrtc.0", 42, MCF_CLK);
DEFINE_CLK(0, "mcfsim.0", 43, MCF_CLK);
DEFINE_CLK(0, "mcfusb-otg.0", 44, MCF_CLK);
@@ -106,6 +107,7 @@ static struct clk_lookup m5411x_clk_lookup[] = {
CLKDEV_INIT("mcfeport.0", NULL, &__clk_0_36),
CLKDEV_INIT("mcfadc.0", NULL, &__clk_0_37),
CLKDEV_INIT("mcfdac.0", NULL, &__clk_0_38),
+ CLKDEV_INIT("mcfdac.1", NULL, &__clk_0_39),
CLKDEV_INIT("mcfrtc.0", NULL, &__clk_0_42),
CLKDEV_INIT("mcfsim.0", NULL, &__clk_0_43),
CLKDEV_INIT("mcfusb-otg.0", NULL, &__clk_0_44),
@@ -176,6 +178,7 @@ static struct clk * const disable_clks[] __initconst = {
&__clk_0_35, /* pit.3 */
&__clk_0_37, /* adc */
&__clk_0_38, /* dac.0 */
+ &__clk_0_39, /* dac.1 */
&__clk_0_44, /* usb otg */
&__clk_0_45, /* usb host */
&__clk_0_47, /* ssi.0 */
--
2.54.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 03/10] m68k: mcf5441x: setup DAC clock name as per driver name
2026-05-04 17:16 [PATCH 00/10] add mcf54415 DAC driver Angelo Dureghello
2026-05-04 17:16 ` [PATCH 01/10] m68k: mcf5441x: fix clocks numbering Angelo Dureghello
2026-05-04 17:16 ` [PATCH 02/10] m68k: mcf5441x: add clock for DAC channel 1 Angelo Dureghello
@ 2026-05-04 17:16 ` Angelo Dureghello
2026-05-04 17:16 ` [PATCH 04/10] m68k: defconfig: update stmark2 defconfig Angelo Dureghello
` (7 subsequent siblings)
10 siblings, 0 replies; 21+ messages in thread
From: Angelo Dureghello @ 2026-05-04 17:16 UTC (permalink / raw)
To: Greg Ungerer, Geert Uytterhoeven, Steven King, Arnd Bergmann,
Maxime Coquelin, Alexandre Torgue, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko
Cc: Greg Ungerer, linux-m68k, linux-kernel, linux-stm32,
linux-arm-kernel, linux-iio, Angelo Dureghello
From: Angelo Dureghello <adureghello@baylibre.com>
Later in this patchset, the mcf54415 DAC driver is added.
Considering some other different ColdFire cpu DACs exists, the DAC driver
is named as "mcf54415_dac", related to the mcf5441x family SoCs with
DACs (mcf54415/6/7/8).
So updating DAC clock names to bind with proper driver name.
Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
---
arch/m68k/coldfire/m5441x.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/m68k/coldfire/m5441x.c b/arch/m68k/coldfire/m5441x.c
index 5c33d3896cf7..b21638844fd4 100644
--- a/arch/m68k/coldfire/m5441x.c
+++ b/arch/m68k/coldfire/m5441x.c
@@ -43,8 +43,8 @@ DEFINE_CLK(0, "mcfpit.2", 34, MCF_BUSCLK);
DEFINE_CLK(0, "mcfpit.3", 35, MCF_BUSCLK);
DEFINE_CLK(0, "mcfeport.0", 36, MCF_CLK);
DEFINE_CLK(0, "mcfadc.0", 37, MCF_CLK);
-DEFINE_CLK(0, "mcfdac.0", 38, MCF_CLK);
-DEFINE_CLK(0, "mcfdac.1", 39, MCF_CLK);
+DEFINE_CLK(0, "mcf54415_dac.0", 38, MCF_CLK);
+DEFINE_CLK(0, "mcf54415_dac.1", 39, MCF_CLK);
DEFINE_CLK(0, "mcfrtc.0", 42, MCF_CLK);
DEFINE_CLK(0, "mcfsim.0", 43, MCF_CLK);
DEFINE_CLK(0, "mcfusb-otg.0", 44, MCF_CLK);
@@ -106,8 +106,8 @@ static struct clk_lookup m5411x_clk_lookup[] = {
CLKDEV_INIT("mcfpit.3", NULL, &__clk_0_35),
CLKDEV_INIT("mcfeport.0", NULL, &__clk_0_36),
CLKDEV_INIT("mcfadc.0", NULL, &__clk_0_37),
- CLKDEV_INIT("mcfdac.0", NULL, &__clk_0_38),
- CLKDEV_INIT("mcfdac.1", NULL, &__clk_0_39),
+ CLKDEV_INIT("mcf54415_dac.0", NULL, &__clk_0_38),
+ CLKDEV_INIT("mcf54415_dac.1", NULL, &__clk_0_39),
CLKDEV_INIT("mcfrtc.0", NULL, &__clk_0_42),
CLKDEV_INIT("mcfsim.0", NULL, &__clk_0_43),
CLKDEV_INIT("mcfusb-otg.0", NULL, &__clk_0_44),
--
2.54.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 04/10] m68k: defconfig: update stmark2 defconfig
2026-05-04 17:16 [PATCH 00/10] add mcf54415 DAC driver Angelo Dureghello
` (2 preceding siblings ...)
2026-05-04 17:16 ` [PATCH 03/10] m68k: mcf5441x: setup DAC clock name as per driver name Angelo Dureghello
@ 2026-05-04 17:16 ` Angelo Dureghello
2026-05-04 17:16 ` [PATCH 05/10] m68k: add DAC modules base addresses Angelo Dureghello
` (6 subsequent siblings)
10 siblings, 0 replies; 21+ messages in thread
From: Angelo Dureghello @ 2026-05-04 17:16 UTC (permalink / raw)
To: Greg Ungerer, Geert Uytterhoeven, Steven King, Arnd Bergmann,
Maxime Coquelin, Alexandre Torgue, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko
Cc: Greg Ungerer, linux-m68k, linux-kernel, linux-stm32,
linux-arm-kernel, linux-iio, Angelo Dureghello
From: Angelo Dureghello <adureghello@baylibre.com>
Update stmark2 defconfig enabling MCF5441X DACs.
Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
---
arch/m68k/configs/stmark2_defconfig | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/m68k/configs/stmark2_defconfig b/arch/m68k/configs/stmark2_defconfig
index b3fb95f73a95..3941113bc60b 100644
--- a/arch/m68k/configs/stmark2_defconfig
+++ b/arch/m68k/configs/stmark2_defconfig
@@ -76,6 +76,8 @@ CONFIG_DMADEVICES=y
CONFIG_MCF_EDMA=y
# CONFIG_VIRTIO_MENU is not set
# CONFIG_VHOST_MENU is not set
+CONFIG_IIO=y
+CONFIG_MCF54415_DAC=y
CONFIG_EXT2_FS=y
CONFIG_EXT2_FS_XATTR=y
CONFIG_EXT2_FS_POSIX_ACL=y
--
2.54.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 05/10] m68k: add DAC modules base addresses
2026-05-04 17:16 [PATCH 00/10] add mcf54415 DAC driver Angelo Dureghello
` (3 preceding siblings ...)
2026-05-04 17:16 ` [PATCH 04/10] m68k: defconfig: update stmark2 defconfig Angelo Dureghello
@ 2026-05-04 17:16 ` Angelo Dureghello
2026-05-04 17:16 ` [PATCH 06/10] m68k: mcf5441x: add CCM registers Angelo Dureghello
` (5 subsequent siblings)
10 siblings, 0 replies; 21+ messages in thread
From: Angelo Dureghello @ 2026-05-04 17:16 UTC (permalink / raw)
To: Greg Ungerer, Geert Uytterhoeven, Steven King, Arnd Bergmann,
Maxime Coquelin, Alexandre Torgue, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko
Cc: Greg Ungerer, linux-m68k, linux-kernel, linux-stm32,
linux-arm-kernel, linux-iio, Angelo Dureghello
From: Angelo Dureghello <adureghello@baylibre.com>
Add DAC controller 0 and 1 base addresses.
Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
---
arch/m68k/include/asm/m5441xsim.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/m68k/include/asm/m5441xsim.h b/arch/m68k/include/asm/m5441xsim.h
index f48cf63bd782..f5acc962bb95 100644
--- a/arch/m68k/include/asm/m5441xsim.h
+++ b/arch/m68k/include/asm/m5441xsim.h
@@ -191,6 +191,11 @@
#define MCFEPORT_EPPAR 0xfc090000
#define MCFEPORT_EPIER 0xfc090003
#define MCFEPORT_EPFR 0xfc090006
+/*
+ * DAC Modules.
+ */
+#define MCFDAC_BASE0 0xfc098000
+#define MCFDAC_BASE1 0xfc09c000
/*
* RTC Module.
*/
--
2.54.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 06/10] m68k: mcf5441x: add CCM registers
2026-05-04 17:16 [PATCH 00/10] add mcf54415 DAC driver Angelo Dureghello
` (4 preceding siblings ...)
2026-05-04 17:16 ` [PATCH 05/10] m68k: add DAC modules base addresses Angelo Dureghello
@ 2026-05-04 17:16 ` Angelo Dureghello
2026-05-04 17:16 ` [PATCH 07/10] m68k: mcf5441x: add CCR MISCCR2 bitfields Angelo Dureghello
` (4 subsequent siblings)
10 siblings, 0 replies; 21+ messages in thread
From: Angelo Dureghello @ 2026-05-04 17:16 UTC (permalink / raw)
To: Greg Ungerer, Geert Uytterhoeven, Steven King, Arnd Bergmann,
Maxime Coquelin, Alexandre Torgue, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko
Cc: Greg Ungerer, linux-m68k, linux-kernel, linux-stm32,
linux-arm-kernel, linux-iio, Angelo Dureghello
From: Angelo Dureghello <adureghello@baylibre.com>
Add CCM module register offsets.
Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
---
arch/m68k/include/asm/m5441xsim.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/arch/m68k/include/asm/m5441xsim.h b/arch/m68k/include/asm/m5441xsim.h
index f5acc962bb95..9ce2cbb05316 100644
--- a/arch/m68k/include/asm/m5441xsim.h
+++ b/arch/m68k/include/asm/m5441xsim.h
@@ -125,6 +125,26 @@
#define MCFPM_PPMHR1 0xfc040038
#define MCFPM_PPMLR1 0xfc04003c
#define MCFPM_LPCR 0xec090007
+
+/*
+ * Chip Configuration Module (CCM).
+ */
+#define MCF_CCM_CCR 0xec090004
+#define MCF_CCM_RCON 0xec090008
+#define MCF_CCM_CIR 0xec09000a
+#define MCF_CCM_MISCCR 0xec09000e
+#define MCF_CCM_CDRH 0xec090010
+#define MCF_CCM_CDRL 0xec090012
+#define MCF_CCM_UOCSR 0xec090014
+#define MCF_CCM_UHCSR 0xec090016
+#define MCF_CCM_MISCCR3 0xec090018
+#define MCF_CCM_MISCCR2 0xec09001a
+#define MCF_CCM_ADCTSR 0xec09001c
+#define MCF_CCM_DACTSR 0xec09001e
+#define MCF_CCM_SBFSR 0xec090020
+#define MCF_CCM_SBFCR 0xec090022
+#define MCF_CCM_FNACR 0xec090024
+
/*
* UART module.
*/
--
2.54.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 07/10] m68k: mcf5441x: add CCR MISCCR2 bitfields
2026-05-04 17:16 [PATCH 00/10] add mcf54415 DAC driver Angelo Dureghello
` (5 preceding siblings ...)
2026-05-04 17:16 ` [PATCH 06/10] m68k: mcf5441x: add CCM registers Angelo Dureghello
@ 2026-05-04 17:16 ` Angelo Dureghello
2026-05-04 17:16 ` [PATCH 08/10] m68k: stmark2: add mcf5441x DAC platform devices Angelo Dureghello
` (3 subsequent siblings)
10 siblings, 0 replies; 21+ messages in thread
From: Angelo Dureghello @ 2026-05-04 17:16 UTC (permalink / raw)
To: Greg Ungerer, Geert Uytterhoeven, Steven King, Arnd Bergmann,
Maxime Coquelin, Alexandre Torgue, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko
Cc: Greg Ungerer, linux-m68k, linux-kernel, linux-stm32,
linux-arm-kernel, linux-iio, Angelo Dureghello
From: Angelo Dureghello <adureghello@baylibre.com>
Add CCR MISCCR2 register bitfields.
Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
---
arch/m68k/include/asm/m5441xsim.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/arch/m68k/include/asm/m5441xsim.h b/arch/m68k/include/asm/m5441xsim.h
index 9ce2cbb05316..93f7943d5550 100644
--- a/arch/m68k/include/asm/m5441xsim.h
+++ b/arch/m68k/include/asm/m5441xsim.h
@@ -145,6 +145,21 @@
#define MCF_CCM_SBFCR 0xec090022
#define MCF_CCM_FNACR 0xec090024
+/* Bit definitions and macros for MCF_CCM_MISCCR2 */
+#define MCF_CCM_MISCCR2_ULPI BIT(0)
+#define MCF_CCM_MISCCR2_FB_HALF BIT(1)
+#define MCF_CCM_MISCCR2_ADC3_EN BIT(2)
+#define MCF_CCM_MISCCR2_ADC7_EN BIT(3)
+#define MCF_CCM_MISCCR2_ADC_EN BIT(4)
+#define MCF_CCM_MISCCR2_DAC0_SEL BIT(5)
+#define MCF_CCM_MISCCR2_DAC1_SEL BIT(6)
+#define MCF_CCM_MISCCR2_DCC_BYP BIT(7)
+#define MCF_CCM_MISCCR2_PLL_MODE GENMASK(9, 7)
+#define MCF_CCM_MISCCR2_SWT_SCR BIT(12)
+#define MCF_CCM_MISCCR2_RGPIO_HALF BIT(13)
+#define MCF_CCM_MISCCR2_DDR2_CLK BIT(14)
+#define MCF_CCM_MISCCR2_EXTCLK_BYP BIT(15)
+
/*
* UART module.
*/
--
2.54.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 08/10] m68k: stmark2: add mcf5441x DAC platform devices
2026-05-04 17:16 [PATCH 00/10] add mcf54415 DAC driver Angelo Dureghello
` (6 preceding siblings ...)
2026-05-04 17:16 ` [PATCH 07/10] m68k: mcf5441x: add CCR MISCCR2 bitfields Angelo Dureghello
@ 2026-05-04 17:16 ` Angelo Dureghello
2026-05-04 17:28 ` Arnd Bergmann
2026-05-05 8:31 ` Andy Shevchenko
2026-05-04 17:16 ` [PATCH 09/10] m68k: stmark2: enable DACs outputs Angelo Dureghello
` (2 subsequent siblings)
10 siblings, 2 replies; 21+ messages in thread
From: Angelo Dureghello @ 2026-05-04 17:16 UTC (permalink / raw)
To: Greg Ungerer, Geert Uytterhoeven, Steven King, Arnd Bergmann,
Maxime Coquelin, Alexandre Torgue, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko
Cc: Greg Ungerer, linux-m68k, linux-kernel, linux-stm32,
linux-arm-kernel, linux-iio, Angelo Dureghello
From: Angelo Dureghello <adureghello@baylibre.com>
Add mcf5441x DAC platform devices.
Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
---
arch/m68k/coldfire/stmark2.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/arch/m68k/coldfire/stmark2.c b/arch/m68k/coldfire/stmark2.c
index 85502b81175e..30da9bcbfd63 100644
--- a/arch/m68k/coldfire/stmark2.c
+++ b/arch/m68k/coldfire/stmark2.c
@@ -94,8 +94,42 @@ static struct platform_device dspi_spi0_device = {
},
};
+static struct resource dspi_dac0_resource[] = {
+ [0] = {
+ .start = MCFDAC_BASE0,
+ .end = MCFDAC_BASE0 + 0xFF,
+ .flags = IORESOURCE_MEM,
+ },
+};
+
+/* DAC controller, id = bus number */
+static struct platform_device dac0_device = {
+ .name = "mcf54415_dac",
+ .id = 0,
+ .num_resources = ARRAY_SIZE(dspi_dac0_resource),
+ .resource = dspi_dac0_resource,
+};
+
+static struct resource dspi_dac1_resource[] = {
+ [0] = {
+ .start = MCFDAC_BASE1,
+ .end = MCFDAC_BASE1 + 0xFF,
+ .flags = IORESOURCE_MEM,
+ },
+};
+
+/* DAC controller, id = bus number */
+static struct platform_device dac1_device = {
+ .name = "mcf54415_dac",
+ .id = 1,
+ .num_resources = ARRAY_SIZE(dspi_dac1_resource),
+ .resource = dspi_dac1_resource,
+};
+
static struct platform_device *stmark2_devices[] __initdata = {
&dspi_spi0_device,
+ &dac0_device,
+ &dac1_device,
};
/*
--
2.54.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 09/10] m68k: stmark2: enable DACs outputs
2026-05-04 17:16 [PATCH 00/10] add mcf54415 DAC driver Angelo Dureghello
` (7 preceding siblings ...)
2026-05-04 17:16 ` [PATCH 08/10] m68k: stmark2: add mcf5441x DAC platform devices Angelo Dureghello
@ 2026-05-04 17:16 ` Angelo Dureghello
2026-05-05 2:12 ` Greg Ungerer
2026-05-05 8:32 ` Andy Shevchenko
2026-05-04 17:16 ` [PATCH 10/10] iio: dac: add mcf54415 DAC Angelo Dureghello
2026-05-04 19:57 ` [PATCH 00/10] add mcf54415 DAC driver Angelo Dureghello
10 siblings, 2 replies; 21+ messages in thread
From: Angelo Dureghello @ 2026-05-04 17:16 UTC (permalink / raw)
To: Greg Ungerer, Geert Uytterhoeven, Steven King, Arnd Bergmann,
Maxime Coquelin, Alexandre Torgue, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko
Cc: Greg Ungerer, linux-m68k, linux-kernel, linux-stm32,
linux-arm-kernel, linux-iio, Angelo Dureghello
From: Angelo Dureghello <adureghello@baylibre.com>
Enabled DAC0 and DAC1 outpus disabling shared ADC inputs on ADC3 and ADC7.
Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
---
arch/m68k/coldfire/stmark2.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/m68k/coldfire/stmark2.c b/arch/m68k/coldfire/stmark2.c
index 30da9bcbfd63..8fdfb9415cd7 100644
--- a/arch/m68k/coldfire/stmark2.c
+++ b/arch/m68k/coldfire/stmark2.c
@@ -137,6 +137,8 @@ static struct platform_device *stmark2_devices[] __initdata = {
*/
static int __init init_stmark2(void)
{
+ uint16_t val;
+
/* DSPI0, all pins as DSPI, and using CS1 */
__raw_writeb(0x80, MCFGPIO_PAR_DSPIOWL);
__raw_writeb(0xfc, MCFGPIO_PAR_DSPIOWH);
@@ -149,6 +151,12 @@ static int __init init_stmark2(void)
/* CAN pads */
__raw_writeb(0x50, MCFGPIO_PAR_CANI2C);
+ /* Enable DAC0 and 1 */
+ val = __raw_readw(MCF_CCM_MISCCR2);
+ val &= ~(MCF_CCM_MISCCR2_ADC3_EN | MCF_CCM_MISCCR2_ADC7_EN);
+ val |= MCF_CCM_MISCCR2_DAC0_SEL | MCF_CCM_MISCCR2_DAC1_SEL;
+ __raw_writew(val, MCF_CCM_MISCCR2);
+
platform_add_devices(stmark2_devices, ARRAY_SIZE(stmark2_devices));
spi_register_board_info(stmark2_board_info,
--
2.54.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 10/10] iio: dac: add mcf54415 DAC
2026-05-04 17:16 [PATCH 00/10] add mcf54415 DAC driver Angelo Dureghello
` (8 preceding siblings ...)
2026-05-04 17:16 ` [PATCH 09/10] m68k: stmark2: enable DACs outputs Angelo Dureghello
@ 2026-05-04 17:16 ` Angelo Dureghello
2026-05-04 17:27 ` Arnd Bergmann
` (2 more replies)
2026-05-04 19:57 ` [PATCH 00/10] add mcf54415 DAC driver Angelo Dureghello
10 siblings, 3 replies; 21+ messages in thread
From: Angelo Dureghello @ 2026-05-04 17:16 UTC (permalink / raw)
To: Greg Ungerer, Geert Uytterhoeven, Steven King, Arnd Bergmann,
Maxime Coquelin, Alexandre Torgue, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko
Cc: Greg Ungerer, linux-m68k, linux-kernel, linux-stm32,
linux-arm-kernel, linux-iio, Angelo Dureghello
From: Angelo Dureghello <adureghello@baylibre.com>
Add basic version of mcf54415 DAC driver. DAC is embedded in the cpu and
DAC configuration registers are mapped in the internal IO address space.
The DAC accepts a 12-bit digital signal and creates a monotonic 12-bit
analog output varying from ~DAC_VREFL to ~DAC_VREFH. The DAC module
consists of a conversion unit, an output amplifier, and the associated
digital control blocks. DAC_VREFL and DAC_VREFH defaults respectivley to
0 and 0xfff.
This initial version of the driver is minimalistic, "output raw" only, to
be extended in the future. DMA and external sync are disabled, default mode
is high speed, default format is right-justified 12bit on 16bit word.
Basic tests done on stmark2 mcf54415-based board, voltage check on DAC0:
/sys/bus/iio/devices/iio:device0 # ls
name out_voltage_raw subsystem
out_conversion_mode out_voltage_scale uevent
/sys/bus/iio/devices/iio:device0 # cat name
mcf54415_dac.0
/sys/bus/iio/devices/iio:device0 #
echo 4095 > out_voltage_raw => voltage abt 3.3V by oscilloscope
echo 4096 > out_voltage_raw => roll over to 0V
echo 0 > out_voltage_raw => voltage is 0V
echo 2048 > out_voltage_raw => voltage is abt 1.7V, mid scale
Same behavior for /sys/bus/iio/devices/iio:device1.
Generated a sine wave by shell script, sine shape is good.
Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
---
drivers/iio/dac/Kconfig | 10 +++
drivers/iio/dac/Makefile | 1 +
drivers/iio/dac/mcf54415_dac.c | 200 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 211 insertions(+)
diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig
index cd4870b65415..17550e99cfdd 100644
--- a/drivers/iio/dac/Kconfig
+++ b/drivers/iio/dac/Kconfig
@@ -516,6 +516,16 @@ config MAX5821
Say yes here to build support for Maxim MAX5821
10 bits DAC.
+config MCF54415_DAC
+ tristate "NXP MCF54415 DAC driver"
+ depends on M5441x
+ help
+ Say yes here to build support for NXP MCF54415
+ 12bit DAC.
+
+ To compile this driver as a module, choose M here: the module
+ will be called mcf54415_dac.
+
config MCP4725
tristate "MCP4725/6 DAC driver"
depends on I2C
diff --git a/drivers/iio/dac/Makefile b/drivers/iio/dac/Makefile
index 2a80bbf4e80a..1cb93e83d0eb 100644
--- a/drivers/iio/dac/Makefile
+++ b/drivers/iio/dac/Makefile
@@ -51,6 +51,7 @@ obj-$(CONFIG_MAX517) += max517.o
obj-$(CONFIG_MAX22007) += max22007.o
obj-$(CONFIG_MAX5522) += max5522.o
obj-$(CONFIG_MAX5821) += max5821.o
+obj-$(CONFIG_MCF54415_DAC) += mcf54415_dac.o
obj-$(CONFIG_MCP4725) += mcp4725.o
obj-$(CONFIG_MCP4728) += mcp4728.o
obj-$(CONFIG_MCP47FEB02) += mcp47feb02.o
diff --git a/drivers/iio/dac/mcf54415_dac.c b/drivers/iio/dac/mcf54415_dac.c
new file mode 100644
index 000000000000..4031a5dc1f9d
--- /dev/null
+++ b/drivers/iio/dac/mcf54415_dac.c
@@ -0,0 +1,200 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * NXP mcf54415 DAC driver
+ *
+ * Copyright 2026 BayLibre - adureghello@baylibre.com
+ */
+
+#include <linux/bitfield.h>
+#include <linux/bits.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/platform_device.h>
+
+#include <linux/iio/iio.h>
+
+#define MCF54415_DAC_CR 0x00
+#define MCF54415_DAC_CR_PDN BIT(0)
+#define MCF54415_DAC_CR_HSLS BIT(6)
+#define MCF54415_DAC_CR_WMLVL GENMASK(9, 8)
+#define MCF54415_DAC_CR_FILT BIT(12)
+
+#define MCF54415_DAC_DATA 0x02
+
+#define MCF54415_DAC_READY_US 12
+
+struct mcf54415_dac {
+ struct clk *clk;
+ struct device *dev;
+ void __iomem *regs;
+};
+
+static void mcf54415_dac_init(struct mcf54415_dac *info)
+{
+ int val;
+
+ /* Keeping defaults and enable DAC (bit 0 set to 0) */
+ val = MCF54415_DAC_CR_FILT;
+ val |= FIELD_PREP(MCF54415_DAC_CR_WMLVL, 1);
+
+ writew(val, info->regs + MCF54415_DAC_CR);
+
+ /* DAC is ready after 12us, from RM table 40-3 */
+ fsleep(MCF54415_DAC_READY_US);
+}
+
+static void mcf54415_dac_exit(void *data)
+{
+ struct mcf54415_dac *info = data;
+ int val;
+
+ val = readw(info->regs + MCF54415_DAC_CR);
+ val |= MCF54415_DAC_CR_PDN;
+ writew(val, info->regs + MCF54415_DAC_CR);
+}
+
+#define MCF54415_DAC_CHAN { \
+ .type = IIO_VOLTAGE, \
+ .output = 1, \
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
+}
+
+static const struct iio_chan_spec mcf54415_dac_iio_channels[] = {
+ MCF54415_DAC_CHAN
+};
+
+static int mcf54415_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int *val, int *val2,
+ long mask)
+{
+ struct mcf54415_dac *info = iio_priv(indio_dev);
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ *val = readw(info->regs + MCF54415_DAC_DATA);
+ return IIO_VAL_INT;
+ case IIO_CHAN_INFO_SCALE:
+ /* Reference voltage as per ColdFire datasheet is 3.3V */
+ *val = 3300 /* mV */;
+ *val2 = 12;
+ return IIO_VAL_FRACTIONAL_LOG2;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int mcf54415_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int val, int val2,
+ long mask)
+{
+ struct mcf54415_dac *info = iio_priv(indio_dev);
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ writew(val, info->regs + MCF54415_DAC_DATA);
+ return 0;
+
+ default:
+ return -EINVAL;
+ }
+}
+
+static const struct iio_info mcf54415_dac_iio_info = {
+ .read_raw = &mcf54415_read_raw,
+ .write_raw = &mcf54415_write_raw,
+};
+
+static int mcf54415_dac_probe(struct platform_device *pdev)
+{
+ struct iio_dev *indio_dev;
+ struct mcf54415_dac *info;
+ int ret;
+
+ indio_dev = devm_iio_device_alloc(&pdev->dev,
+ sizeof(struct mcf54415_dac));
+ if (!indio_dev)
+ return -ENOMEM;
+
+ info = iio_priv(indio_dev);
+ info->dev = &pdev->dev;
+
+ info->regs = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(info->regs))
+ return dev_err_probe(&pdev->dev, PTR_ERR(info->regs),
+ "failed to get io regs\n");
+
+ info->clk = devm_clk_get_enabled(&pdev->dev, "dac");
+ if (IS_ERR(info->clk))
+ return dev_err_probe(&pdev->dev, PTR_ERR(info->clk),
+ "failed getting clock\n");
+
+ platform_set_drvdata(pdev, indio_dev);
+
+ indio_dev->name = dev_name(&pdev->dev);
+ indio_dev->info = &mcf54415_dac_iio_info;
+ indio_dev->modes = INDIO_DIRECT_MODE;
+ indio_dev->channels = mcf54415_dac_iio_channels;
+ indio_dev->num_channels = ARRAY_SIZE(mcf54415_dac_iio_channels);
+
+ mcf54415_dac_init(info);
+
+ ret = devm_add_action_or_reset(&pdev->dev, mcf54415_dac_exit, info);
+ if (ret)
+ return ret;
+
+ ret = devm_iio_device_register(&pdev->dev, indio_dev);
+ if (ret)
+ dev_err(&pdev->dev, "couldn't register the device\n");
+
+ return ret;
+}
+
+static int mcf54415_dac_suspend(struct device *dev)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct mcf54415_dac *info = iio_priv(indio_dev);
+
+ mcf54415_dac_exit(info);
+ clk_disable_unprepare(info->clk);
+
+ return 0;
+}
+
+static int mcf54415_dac_resume(struct device *dev)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct mcf54415_dac *info = iio_priv(indio_dev);
+ int ret;
+
+ ret = clk_prepare_enable(info->clk);
+ if (ret)
+ return ret;
+
+ mcf54415_dac_init(info);
+
+ return 0;
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(mcf54415_dac_pm_ops, mcf54415_dac_suspend,
+ mcf54415_dac_resume);
+
+static struct platform_driver mcf54415_dac_driver = {
+ .probe = mcf54415_dac_probe,
+ .driver = {
+ .name = "mcf54415_dac",
+ .pm = pm_sleep_ptr(&mcf54415_dac_pm_ops),
+ },
+};
+module_platform_driver(mcf54415_dac_driver);
+
+MODULE_AUTHOR("Angelo Dureghello <angelo@kernel-space.org>");
+MODULE_DESCRIPTION("NXP MCF54415 DAC driver");
+MODULE_LICENSE("GPL");
--
2.54.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 10/10] iio: dac: add mcf54415 DAC
2026-05-04 17:16 ` [PATCH 10/10] iio: dac: add mcf54415 DAC Angelo Dureghello
@ 2026-05-04 17:27 ` Arnd Bergmann
2026-05-05 2:06 ` Greg Ungerer
2026-05-04 19:13 ` Nuno Sá
2026-05-05 8:45 ` Andy Shevchenko
2 siblings, 1 reply; 21+ messages in thread
From: Arnd Bergmann @ 2026-05-04 17:27 UTC (permalink / raw)
To: Angelo Dureghello, Greg Ungerer, Geert Uytterhoeven, Steven King,
Maxime Coquelin, Alexandre Torgue, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko
Cc: Greg Ungerer, linux-m68k, linux-kernel, linux-stm32,
linux-arm-kernel, linux-iio, Angelo Dureghello
On Mon, May 4, 2026, at 19:16, Angelo Dureghello wrote:
> +static void mcf54415_dac_exit(void *data)
> +{
> + struct mcf54415_dac *info = data;
> + int val;
> +
> + val = readw(info->regs + MCF54415_DAC_CR);
> + val |= MCF54415_DAC_CR_PDN;
> + writew(val, info->regs + MCF54415_DAC_CR);
> +}
We've recently discussed changing the MMIO accessors on coldfire
to behave like all the other ones, which makes readw() and writew()
have an implicit byteswap. An additional driver means one more
place to change during the conversion. Maybe you can use the
new mcf_readw()/mcf_writew() helpers that Greg has started
introducing? Those will keep using native big-endian register
definitions.
Arnd
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 08/10] m68k: stmark2: add mcf5441x DAC platform devices
2026-05-04 17:16 ` [PATCH 08/10] m68k: stmark2: add mcf5441x DAC platform devices Angelo Dureghello
@ 2026-05-04 17:28 ` Arnd Bergmann
2026-05-05 8:31 ` Andy Shevchenko
1 sibling, 0 replies; 21+ messages in thread
From: Arnd Bergmann @ 2026-05-04 17:28 UTC (permalink / raw)
To: Angelo Dureghello, Greg Ungerer, Geert Uytterhoeven, Steven King,
Maxime Coquelin, Alexandre Torgue, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko
Cc: Greg Ungerer, linux-m68k, linux-kernel, linux-stm32,
linux-arm-kernel, linux-iio, Angelo Dureghello
On Mon, May 4, 2026, at 19:16, Angelo Dureghello wrote:
> @@ -94,8 +94,42 @@ static struct platform_device dspi_spi0_device = {
...
> +static struct resource dspi_dac1_resource[] = {
> + [0] = {
This looks like the name has a copy-paste error: this is not
related to the 'dspi' controller at all but is just the dac, right?
Arnd
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 10/10] iio: dac: add mcf54415 DAC
2026-05-04 17:16 ` [PATCH 10/10] iio: dac: add mcf54415 DAC Angelo Dureghello
2026-05-04 17:27 ` Arnd Bergmann
@ 2026-05-04 19:13 ` Nuno Sá
2026-05-05 8:45 ` Andy Shevchenko
2 siblings, 0 replies; 21+ messages in thread
From: Nuno Sá @ 2026-05-04 19:13 UTC (permalink / raw)
To: Angelo Dureghello, Greg Ungerer, Geert Uytterhoeven, Steven King,
Arnd Bergmann, Maxime Coquelin, Alexandre Torgue,
Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
Cc: Greg Ungerer, linux-m68k, linux-kernel, linux-stm32,
linux-arm-kernel, linux-iio, Angelo Dureghello
Hi Angelo,
Minor stuff from me
On Mon, 2026-05-04 at 19:16 +0200, Angelo Dureghello wrote:
> From: Angelo Dureghello <adureghello@baylibre.com>
>
> Add basic version of mcf54415 DAC driver. DAC is embedded in the cpu and
> DAC configuration registers are mapped in the internal IO address space.
>
> The DAC accepts a 12-bit digital signal and creates a monotonic 12-bit
> analog output varying from ~DAC_VREFL to ~DAC_VREFH. The DAC module
> consists of a conversion unit, an output amplifier, and the associated
> digital control blocks. DAC_VREFL and DAC_VREFH defaults respectivley to
> 0 and 0xfff.
>
> This initial version of the driver is minimalistic, "output raw" only, to
> be extended in the future. DMA and external sync are disabled, default mode
> is high speed, default format is right-justified 12bit on 16bit word.
>
> Basic tests done on stmark2 mcf54415-based board, voltage check on DAC0:
>
> /sys/bus/iio/devices/iio:device0 # ls
> name out_voltage_raw subsystem
> out_conversion_mode out_voltage_scale uevent
>
> /sys/bus/iio/devices/iio:device0 # cat name
> mcf54415_dac.0
>
> /sys/bus/iio/devices/iio:device0 #
>
> echo 4095 > out_voltage_raw => voltage abt 3.3V by oscilloscope
> echo 4096 > out_voltage_raw => roll over to 0V
> echo 0 > out_voltage_raw => voltage is 0V
> echo 2048 > out_voltage_raw => voltage is abt 1.7V, mid scale
>
> Same behavior for /sys/bus/iio/devices/iio:device1.
>
> Generated a sine wave by shell script, sine shape is good.
>
Not sure if the above example belongs to the commit message. I would just write a
small doc if you really want to document the above. We're now seeing more docs for
IIO drivers.
> Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
> ---
> drivers/iio/dac/Kconfig | 10 +++
> drivers/iio/dac/Makefile | 1 +
> drivers/iio/dac/mcf54415_dac.c | 200 +++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 211 insertions(+)
>
> diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig
> index cd4870b65415..17550e99cfdd 100644
> --- a/drivers/iio/dac/Kconfig
> +++ b/drivers/iio/dac/Kconfig
> @@ -516,6 +516,16 @@ config MAX5821
> Say yes here to build support for Maxim MAX5821
> 10 bits DAC.
>
> +config MCF54415_DAC
> + tristate "NXP MCF54415 DAC driver"
> + depends on M5441x
> + help
> + Say yes here to build support for NXP MCF54415
> + 12bit DAC.
> +
> + To compile this driver as a module, choose M here: the module
> + will be called mcf54415_dac.
> +
> config MCP4725
> tristate "MCP4725/6 DAC driver"
> depends on I2C
> diff --git a/drivers/iio/dac/Makefile b/drivers/iio/dac/Makefile
> index 2a80bbf4e80a..1cb93e83d0eb 100644
> --- a/drivers/iio/dac/Makefile
> +++ b/drivers/iio/dac/Makefile
> @@ -51,6 +51,7 @@ obj-$(CONFIG_MAX517) += max517.o
> obj-$(CONFIG_MAX22007) += max22007.o
> obj-$(CONFIG_MAX5522) += max5522.o
> obj-$(CONFIG_MAX5821) += max5821.o
> +obj-$(CONFIG_MCF54415_DAC) += mcf54415_dac.o
> obj-$(CONFIG_MCP4725) += mcp4725.o
> obj-$(CONFIG_MCP4728) += mcp4728.o
> obj-$(CONFIG_MCP47FEB02) += mcp47feb02.o
> diff --git a/drivers/iio/dac/mcf54415_dac.c b/drivers/iio/dac/mcf54415_dac.c
> new file mode 100644
> index 000000000000..4031a5dc1f9d
> --- /dev/null
> +++ b/drivers/iio/dac/mcf54415_dac.c
> @@ -0,0 +1,200 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * NXP mcf54415 DAC driver
> + *
> + * Copyright 2026 BayLibre - adureghello@baylibre.com
> + */
> +
> +#include <linux/bitfield.h>
> +#include <linux/bits.h>
> +#include <linux/clk.h>
> +#include <linux/delay.h>
> +#include <linux/io.h>
> +#include <linux/module.h>
> +#include <linux/mutex.h>
> +#include <linux/platform_device.h>
> +
> +#include <linux/iio/iio.h>
> +
> +#define MCF54415_DAC_CR 0x00
> +#define MCF54415_DAC_CR_PDN BIT(0)
> +#define MCF54415_DAC_CR_HSLS BIT(6)
> +#define MCF54415_DAC_CR_WMLVL GENMASK(9, 8)
> +#define MCF54415_DAC_CR_FILT BIT(12)
> +
> +#define MCF54415_DAC_DATA 0x02
> +
> +#define MCF54415_DAC_READY_US 12
> +
> +struct mcf54415_dac {
> + struct clk *clk;
> + struct device *dev;
> + void __iomem *regs;
> +};
> +
> +static void mcf54415_dac_init(struct mcf54415_dac *info)
> +{
> + int val;
> +
> + /* Keeping defaults and enable DAC (bit 0 set to 0) */
> + val = MCF54415_DAC_CR_FILT;
> + val |= FIELD_PREP(MCF54415_DAC_CR_WMLVL, 1);
> +
> + writew(val, info->regs + MCF54415_DAC_CR);
> +
> + /* DAC is ready after 12us, from RM table 40-3 */
> + fsleep(MCF54415_DAC_READY_US);
> +}
> +
> +static void mcf54415_dac_exit(void *data)
> +{
> + struct mcf54415_dac *info = data;
> + int val;
> +
> + val = readw(info->regs + MCF54415_DAC_CR);
> + val |= MCF54415_DAC_CR_PDN;
> + writew(val, info->regs + MCF54415_DAC_CR);
> +}
> +
> +#define MCF54415_DAC_CHAN { \
> + .type = IIO_VOLTAGE, \
> + .output = 1, \
> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
> + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
> +}
> +
> +static const struct iio_chan_spec mcf54415_dac_iio_channels[] = {
> + MCF54415_DAC_CHAN
> +};
> +
> +static int mcf54415_read_raw(struct iio_dev *indio_dev,
> + struct iio_chan_spec const *chan,
> + int *val, int *val2,
> + long mask)
> +{
> + struct mcf54415_dac *info = iio_priv(indio_dev);
> +
> + switch (mask) {
> + case IIO_CHAN_INFO_RAW:
> + *val = readw(info->regs + MCF54415_DAC_DATA);
> + return IIO_VAL_INT;
> + case IIO_CHAN_INFO_SCALE:
> + /* Reference voltage as per ColdFire datasheet is 3.3V */
> + *val = 3300 /* mV */;
> + *val2 = 12;
> + return IIO_VAL_FRACTIONAL_LOG2;
> + default:
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +
> +static int mcf54415_write_raw(struct iio_dev *indio_dev,
> + struct iio_chan_spec const *chan,
> + int val, int val2,
> + long mask)
> +{
> + struct mcf54415_dac *info = iio_priv(indio_dev);
> +
> + switch (mask) {
> + case IIO_CHAN_INFO_RAW:
> + writew(val, info->regs + MCF54415_DAC_DATA);
> + return 0;
> +
No need for the new line.
> + default:
> + return -EINVAL;
> + }
> +}
> +
> +static const struct iio_info mcf54415_dac_iio_info = {
> + .read_raw = &mcf54415_read_raw,
> + .write_raw = &mcf54415_write_raw,
> +};
> +
> +static int mcf54415_dac_probe(struct platform_device *pdev)
> +{
> + struct iio_dev *indio_dev;
> + struct mcf54415_dac *info;
> + int ret;
> +
> + indio_dev = devm_iio_device_alloc(&pdev->dev,
> + sizeof(struct mcf54415_dac));
Slight preference for sizeof(*info)
> + if (!indio_dev)
> + return -ENOMEM;
> +
> + info = iio_priv(indio_dev);
> + info->dev = &pdev->dev;
> +
> + info->regs = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(info->regs))
> + return dev_err_probe(&pdev->dev, PTR_ERR(info->regs),
> + "failed to get io regs\n");
> +
> + info->clk = devm_clk_get_enabled(&pdev->dev, "dac");
> + if (IS_ERR(info->clk))
> + return dev_err_probe(&pdev->dev, PTR_ERR(info->clk),
> + "failed getting clock\n");
> +
> + platform_set_drvdata(pdev, indio_dev);
> +
>
> + indio_dev->name = dev_name(&pdev->dev);
Just use "mcf54415".
> + indio_dev->info = &mcf54415_dac_iio_info;
> + indio_dev->modes = INDIO_DIRECT_MODE;
> + indio_dev->channels = mcf54415_dac_iio_channels;
> + indio_dev->num_channels = ARRAY_SIZE(mcf54415_dac_iio_channels);
> +
> + mcf54415_dac_init(info);
> +
> + ret = devm_add_action_or_reset(&pdev->dev, mcf54415_dac_exit, info);
> + if (ret)
> + return ret;
> +
> + ret = devm_iio_device_register(&pdev->dev, indio_dev);
> + if (ret)
> + dev_err(&pdev->dev, "couldn't register the device\n");
> +
I would just return devm_iio_device_register();
- Nuno Sá
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 00/10] add mcf54415 DAC driver
2026-05-04 17:16 [PATCH 00/10] add mcf54415 DAC driver Angelo Dureghello
` (9 preceding siblings ...)
2026-05-04 17:16 ` [PATCH 10/10] iio: dac: add mcf54415 DAC Angelo Dureghello
@ 2026-05-04 19:57 ` Angelo Dureghello
10 siblings, 0 replies; 21+ messages in thread
From: Angelo Dureghello @ 2026-05-04 19:57 UTC (permalink / raw)
To: Angelo Dureghello
Cc: Greg Ungerer, Geert Uytterhoeven, Steven King, Arnd Bergmann,
Maxime Coquelin, Alexandre Torgue, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Greg Ungerer,
linux-m68k, linux-kernel, linux-stm32, linux-arm-kernel,
linux-iio
Hi,
just seen i sent with git send-email configured with my private email.
Will fix the sender email to BayLibre in v2.
Regards,
angelo
On 04.05.2026 19:16, Angelo Dureghello wrote:
> This patchset adds a minimalistic DAC driver for the NXP mcf54415/6/7/8
> builtin DACs.
>
> Currently the driver enables the raw write only. Feature as dma, sync, or
> format are not supoprted for this version.
>
> Additional options suppoerted by the DAC module will be added to the driver
> later on, as needed.
>
> The same patchset prepares the m68k/coldfire architecture to support
> the driver.
>
> ---
> Angelo Dureghello (10):
> m68k: mcf5441x: fix clocks numbering
> m68k: mcf5441x: add clock for DAC channel 1
> m68k: mcf5441x: setup DAC clock name as per driver name
> m68k: defconfig: update stmark2 defconfig
> m68k: add DAC modules base addresses
> m68k: mcf5441x: add CCM registers
> m68k: mcf5441x: add CCR MISCCR2 bitfields
> m68k: stmark2: add mcf5441x DAC platform devices
> m68k: stmark2: enable DACs outputs
> iio: dac: add mcf54415 DAC
>
> arch/m68k/coldfire/m5441x.c | 21 ++--
> arch/m68k/coldfire/stmark2.c | 42 ++++++++
> arch/m68k/configs/stmark2_defconfig | 2 +
> arch/m68k/include/asm/m5441xsim.h | 40 ++++++++
> drivers/iio/dac/Kconfig | 10 ++
> drivers/iio/dac/Makefile | 1 +
> drivers/iio/dac/mcf54415_dac.c | 200 ++++++++++++++++++++++++++++++++++++
> 7 files changed, 307 insertions(+), 9 deletions(-)
> ---
> base-commit: 8b4b975922f607411217c81942e82f1d206ebc61
> change-id: 20260430-wip-stmark2-dac-7060f49dd94f
>
> Best regards,
> --
> Angelo Dureghello <adureghello@baylibre.com>
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 10/10] iio: dac: add mcf54415 DAC
2026-05-04 17:27 ` Arnd Bergmann
@ 2026-05-05 2:06 ` Greg Ungerer
2026-05-05 5:54 ` Angelo Dureghello
0 siblings, 1 reply; 21+ messages in thread
From: Greg Ungerer @ 2026-05-05 2:06 UTC (permalink / raw)
To: Arnd Bergmann, Angelo Dureghello, Geert Uytterhoeven, Steven King,
Maxime Coquelin, Alexandre Torgue, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko
Cc: Greg Ungerer, linux-m68k, linux-kernel, linux-stm32,
linux-arm-kernel, linux-iio, Angelo Dureghello
On 5/5/26 03:27, Arnd Bergmann wrote:
> On Mon, May 4, 2026, at 19:16, Angelo Dureghello wrote:
>
>> +static void mcf54415_dac_exit(void *data)
>> +{
>> + struct mcf54415_dac *info = data;
>> + int val;
>> +
>> + val = readw(info->regs + MCF54415_DAC_CR);
>> + val |= MCF54415_DAC_CR_PDN;
>> + writew(val, info->regs + MCF54415_DAC_CR);
>> +}
>
> We've recently discussed changing the MMIO accessors on coldfire
> to behave like all the other ones, which makes readw() and writew()
> have an implicit byteswap. An additional driver means one more
> place to change during the conversion. Maybe you can use the
> new mcf_readw()/mcf_writew() helpers that Greg has started
> introducing? Those will keep using native big-endian register
> definitions.
Yes, please :-)
Those newly introduced mcf_readX/mcf_writeX are in the for-next branch
of the m68knommu git tree now, they have not hit mainline yet, hopefully
in the next merge cycle.
Somewhat related, I will have patches out for the other affected drivers
over the next few days.
Regards
Greg
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 09/10] m68k: stmark2: enable DACs outputs
2026-05-04 17:16 ` [PATCH 09/10] m68k: stmark2: enable DACs outputs Angelo Dureghello
@ 2026-05-05 2:12 ` Greg Ungerer
2026-05-05 8:32 ` Andy Shevchenko
1 sibling, 0 replies; 21+ messages in thread
From: Greg Ungerer @ 2026-05-05 2:12 UTC (permalink / raw)
To: Angelo Dureghello, Geert Uytterhoeven, Steven King, Arnd Bergmann,
Maxime Coquelin, Alexandre Torgue, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko
Cc: Greg Ungerer, linux-m68k, linux-kernel, linux-stm32,
linux-arm-kernel, linux-iio, Angelo Dureghello
Hi Angelo,
On 5/5/26 03:16, Angelo Dureghello wrote:
> From: Angelo Dureghello <adureghello@baylibre.com>
>
> Enabled DAC0 and DAC1 outpus disabling shared ADC inputs on ADC3 and ADC7.
>
> Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
> ---
> arch/m68k/coldfire/stmark2.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/arch/m68k/coldfire/stmark2.c b/arch/m68k/coldfire/stmark2.c
> index 30da9bcbfd63..8fdfb9415cd7 100644
> --- a/arch/m68k/coldfire/stmark2.c
> +++ b/arch/m68k/coldfire/stmark2.c
> @@ -137,6 +137,8 @@ static struct platform_device *stmark2_devices[] __initdata = {
> */
> static int __init init_stmark2(void)
> {
> + uint16_t val;
> +
> /* DSPI0, all pins as DSPI, and using CS1 */
> __raw_writeb(0x80, MCFGPIO_PAR_DSPIOWL);
> __raw_writeb(0xfc, MCFGPIO_PAR_DSPIOWH);
> @@ -149,6 +151,12 @@ static int __init init_stmark2(void)
> /* CAN pads */
> __raw_writeb(0x50, MCFGPIO_PAR_CANI2C);
>
> + /* Enable DAC0 and 1 */
> + val = __raw_readw(MCF_CCM_MISCCR2);
> + val &= ~(MCF_CCM_MISCCR2_ADC3_EN | MCF_CCM_MISCCR2_ADC7_EN);
> + val |= MCF_CCM_MISCCR2_DAC0_SEL | MCF_CCM_MISCCR2_DAC1_SEL;
> + __raw_writew(val, MCF_CCM_MISCCR2);
> +
> platform_add_devices(stmark2_devices, ARRAY_SIZE(stmark2_devices));
>
> spi_register_board_info(stmark2_board_info,
Same comment applies here with regards using mcfreadX/mcf_writeX as to the
driver itself. Uses of __raw_readX and __raw_writeX will be changed in the
very near future to use mcf_readX/mcf_writeX.
See the those patches at:
https://lore.kernel.org/linux-m68k/209d0653-6386-4b64-9e15-e358f84453ab@app.fastmail.com/T/#t
Regards
Greg
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 10/10] iio: dac: add mcf54415 DAC
2026-05-05 2:06 ` Greg Ungerer
@ 2026-05-05 5:54 ` Angelo Dureghello
0 siblings, 0 replies; 21+ messages in thread
From: Angelo Dureghello @ 2026-05-05 5:54 UTC (permalink / raw)
To: Greg Ungerer, Arnd Bergmann, Geert Uytterhoeven, Steven King,
Maxime Coquelin, Alexandre Torgue, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko
Cc: Greg Ungerer, linux-m68k, linux-kernel, linux-stm32,
linux-arm-kernel, linux-iio, Angelo Dureghello
Hi Greg, Arnd,
On 5/5/26 04:06, Greg Ungerer wrote:
>
> On 5/5/26 03:27, Arnd Bergmann wrote:
>> On Mon, May 4, 2026, at 19:16, Angelo Dureghello wrote:
>>
>>> +static void mcf54415_dac_exit(void *data)
>>> +{
>>> + struct mcf54415_dac *info = data;
>>> + int val;
>>> +
>>> + val = readw(info->regs + MCF54415_DAC_CR);
>>> + val |= MCF54415_DAC_CR_PDN;
>>> + writew(val, info->regs + MCF54415_DAC_CR);
>>> +}
>>
>> We've recently discussed changing the MMIO accessors on coldfire
>> to behave like all the other ones, which makes readw() and writew()
>> have an implicit byteswap. An additional driver means one more
>> place to change during the conversion. Maybe you can use the
>> new mcf_readw()/mcf_writew() helpers that Greg has started
>> introducing? Those will keep using native big-endian register
>> definitions.
>
> Yes, please :-)
> Those newly introduced mcf_readX/mcf_writeX are in the for-next branch
> of the m68knommu git tree now, they have not hit mainline yet, hopefully
> in the next merge cycle.
>
> Somewhat related, I will have patches out for the other affected drivers
> over the next few days.
ack,
sure, will do, also understanding properly the thing, since was out from m68k
for some time.>
> Regards
> Greg
>
thanks,
regards,
angelo>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 08/10] m68k: stmark2: add mcf5441x DAC platform devices
2026-05-04 17:16 ` [PATCH 08/10] m68k: stmark2: add mcf5441x DAC platform devices Angelo Dureghello
2026-05-04 17:28 ` Arnd Bergmann
@ 2026-05-05 8:31 ` Andy Shevchenko
1 sibling, 0 replies; 21+ messages in thread
From: Andy Shevchenko @ 2026-05-05 8:31 UTC (permalink / raw)
To: Angelo Dureghello
Cc: Greg Ungerer, Geert Uytterhoeven, Steven King, Arnd Bergmann,
Maxime Coquelin, Alexandre Torgue, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Greg Ungerer,
linux-m68k, linux-kernel, linux-stm32, linux-arm-kernel,
linux-iio, Angelo Dureghello
On Mon, May 04, 2026 at 07:16:46PM +0200, Angelo Dureghello wrote:
> Add mcf5441x DAC platform devices.
...
> +static struct resource dspi_dac0_resource[] = {
> + [0] = {
> + .start = MCFDAC_BASE0,
> + .end = MCFDAC_BASE0 + 0xFF,
> + .flags = IORESOURCE_MEM,
> + },
> +};
ioport.h has a lot of DEFINE_RES() macros. Please, choose the best fit in each
case and use them.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 09/10] m68k: stmark2: enable DACs outputs
2026-05-04 17:16 ` [PATCH 09/10] m68k: stmark2: enable DACs outputs Angelo Dureghello
2026-05-05 2:12 ` Greg Ungerer
@ 2026-05-05 8:32 ` Andy Shevchenko
1 sibling, 0 replies; 21+ messages in thread
From: Andy Shevchenko @ 2026-05-05 8:32 UTC (permalink / raw)
To: Angelo Dureghello
Cc: Greg Ungerer, Geert Uytterhoeven, Steven King, Arnd Bergmann,
Maxime Coquelin, Alexandre Torgue, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Greg Ungerer,
linux-m68k, linux-kernel, linux-stm32, linux-arm-kernel,
linux-iio, Angelo Dureghello
On Mon, May 04, 2026 at 07:16:47PM +0200, Angelo Dureghello wrote:
> Enabled DAC0 and DAC1 outpus disabling shared ADC inputs on ADC3 and ADC7.
...
> + uint16_t val;
Why not proper kernel type?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 10/10] iio: dac: add mcf54415 DAC
2026-05-04 17:16 ` [PATCH 10/10] iio: dac: add mcf54415 DAC Angelo Dureghello
2026-05-04 17:27 ` Arnd Bergmann
2026-05-04 19:13 ` Nuno Sá
@ 2026-05-05 8:45 ` Andy Shevchenko
2 siblings, 0 replies; 21+ messages in thread
From: Andy Shevchenko @ 2026-05-05 8:45 UTC (permalink / raw)
To: Angelo Dureghello
Cc: Greg Ungerer, Geert Uytterhoeven, Steven King, Arnd Bergmann,
Maxime Coquelin, Alexandre Torgue, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Greg Ungerer,
linux-m68k, linux-kernel, linux-stm32, linux-arm-kernel,
linux-iio, Angelo Dureghello
On Mon, May 04, 2026 at 07:16:48PM +0200, Angelo Dureghello wrote:
> Add basic version of mcf54415 DAC driver. DAC is embedded in the cpu and
> DAC configuration registers are mapped in the internal IO address space.
>
> The DAC accepts a 12-bit digital signal and creates a monotonic 12-bit
> analog output varying from ~DAC_VREFL to ~DAC_VREFH. The DAC module
> consists of a conversion unit, an output amplifier, and the associated
> digital control blocks. DAC_VREFL and DAC_VREFH defaults respectivley to
> 0 and 0xfff.
>
> This initial version of the driver is minimalistic, "output raw" only, to
> be extended in the future. DMA and external sync are disabled, default mode
> is high speed, default format is right-justified 12bit on 16bit word.
The below doesn't make much sense in the commit message (author must contribute
the tested code), but for the record in the comments block it might be useful
when one digs the lore ML archives.
> Basic tests done on stmark2 mcf54415-based board, voltage check on DAC0:
>
> /sys/bus/iio/devices/iio:device0 # ls
> name out_voltage_raw subsystem
> out_conversion_mode out_voltage_scale uevent
>
> /sys/bus/iio/devices/iio:device0 # cat name
> mcf54415_dac.0
>
> /sys/bus/iio/devices/iio:device0 #
>
> echo 4095 > out_voltage_raw => voltage abt 3.3V by oscilloscope
> echo 4096 > out_voltage_raw => roll over to 0V
> echo 0 > out_voltage_raw => voltage is 0V
> echo 2048 > out_voltage_raw => voltage is abt 1.7V, mid scale
>
> Same behavior for /sys/bus/iio/devices/iio:device1.
>
> Generated a sine wave by shell script, sine shape is good.
^^^ See above.
> Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
> ---
Put that here.
...
> +#include <linux/bitfield.h>
> +#include <linux/bits.h>
> +#include <linux/clk.h>
> +#include <linux/delay.h>
> +#include <linux/io.h>
> +#include <linux/module.h>
> +#include <linux/mutex.h>
> +#include <linux/platform_device.h>
Follow IWYU. At least the headers for __iomem, ARRAY_SIZE() are missing.
...
> + int val;
Why signed?
> + /* Keeping defaults and enable DAC (bit 0 set to 0) */
> + val = MCF54415_DAC_CR_FILT;
> + val |= FIELD_PREP(MCF54415_DAC_CR_WMLVL, 1);
Why two lines?
val = MCF54415_DAC_CR_FILT | FIELD_PREP(MCF54415_DAC_CR_WMLVL, 1);
even fits 80 limit.
> + writew(val, info->regs + MCF54415_DAC_CR);
> +
> + /* DAC is ready after 12us, from RM table 40-3 */
> + fsleep(MCF54415_DAC_READY_US);
...
> +#define MCF54415_DAC_CHAN { \
Move { to a separate line.
> + .type = IIO_VOLTAGE, \
> + .output = 1, \
> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
> + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
> +}
...
> +static const struct iio_chan_spec mcf54415_dac_iio_channels[] = {
> + MCF54415_DAC_CHAN
Use trailing commas when it's not a terminator.
> +};
...
> +static int mcf54415_read_raw(struct iio_dev *indio_dev,
> + struct iio_chan_spec const *chan,
> + int *val, int *val2,
> + long mask)
> +{
> + struct mcf54415_dac *info = iio_priv(indio_dev);
> +
> + switch (mask) {
> + case IIO_CHAN_INFO_RAW:
> + *val = readw(info->regs + MCF54415_DAC_DATA);
> + return IIO_VAL_INT;
> + case IIO_CHAN_INFO_SCALE:
> + /* Reference voltage as per ColdFire datasheet is 3.3V */
> + *val = 3300 /* mV */;
> + *val2 = 12;
> + return IIO_VAL_FRACTIONAL_LOG2;
> + default:
> + return -EINVAL;
> + }
> + return 0;
Dead code.
> +}
...
> +static int mcf54415_write_raw(struct iio_dev *indio_dev,
> + struct iio_chan_spec const *chan,
> + int val, int val2,
> + long mask)
One line.
> +{
> + struct mcf54415_dac *info = iio_priv(indio_dev);
> +
> + switch (mask) {
> + case IIO_CHAN_INFO_RAW:
> + writew(val, info->regs + MCF54415_DAC_DATA);
> + return 0;
> +
Already mentioned: Stray blank line.
> + default:
> + return -EINVAL;
> + }
> +}
...
> + indio_dev = devm_iio_device_alloc(&pdev->dev,
> + sizeof(struct mcf54415_dac));
Use
struct device *dev = &pdev->dev;
to make it neater. Also it's more robust to use sizeof(*).
indio_dev = devm_iio_device_alloc(dev, sizeof(*info));
> + if (!indio_dev)
> + return -ENOMEM;
...
> +static DEFINE_SIMPLE_DEV_PM_OPS(mcf54415_dac_pm_ops, mcf54415_dac_suspend,
> + mcf54415_dac_resume);
Use logical split:
static DEFINE_SIMPLE_DEV_PM_OPS(mcf54415_dac_pm_ops,
mcf54415_dac_suspend,
mcf54415_dac_resume);
OR
static DEFINE_SIMPLE_DEV_PM_OPS(mcf54415_dac_pm_ops,
mcf54415_dac_suspend, mcf54415_dac_resume);
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2026-05-05 8:45 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-04 17:16 [PATCH 00/10] add mcf54415 DAC driver Angelo Dureghello
2026-05-04 17:16 ` [PATCH 01/10] m68k: mcf5441x: fix clocks numbering Angelo Dureghello
2026-05-04 17:16 ` [PATCH 02/10] m68k: mcf5441x: add clock for DAC channel 1 Angelo Dureghello
2026-05-04 17:16 ` [PATCH 03/10] m68k: mcf5441x: setup DAC clock name as per driver name Angelo Dureghello
2026-05-04 17:16 ` [PATCH 04/10] m68k: defconfig: update stmark2 defconfig Angelo Dureghello
2026-05-04 17:16 ` [PATCH 05/10] m68k: add DAC modules base addresses Angelo Dureghello
2026-05-04 17:16 ` [PATCH 06/10] m68k: mcf5441x: add CCM registers Angelo Dureghello
2026-05-04 17:16 ` [PATCH 07/10] m68k: mcf5441x: add CCR MISCCR2 bitfields Angelo Dureghello
2026-05-04 17:16 ` [PATCH 08/10] m68k: stmark2: add mcf5441x DAC platform devices Angelo Dureghello
2026-05-04 17:28 ` Arnd Bergmann
2026-05-05 8:31 ` Andy Shevchenko
2026-05-04 17:16 ` [PATCH 09/10] m68k: stmark2: enable DACs outputs Angelo Dureghello
2026-05-05 2:12 ` Greg Ungerer
2026-05-05 8:32 ` Andy Shevchenko
2026-05-04 17:16 ` [PATCH 10/10] iio: dac: add mcf54415 DAC Angelo Dureghello
2026-05-04 17:27 ` Arnd Bergmann
2026-05-05 2:06 ` Greg Ungerer
2026-05-05 5:54 ` Angelo Dureghello
2026-05-04 19:13 ` Nuno Sá
2026-05-05 8:45 ` Andy Shevchenko
2026-05-04 19:57 ` [PATCH 00/10] add mcf54415 DAC driver Angelo Dureghello
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox