[PATCH v3 08/33] swim: Enable clock divider only where appropriate

From: Finn Thain

Date: Fri Sep 04 2026 - 05:37:37 EST


Some models have a 16 MHz FCLK oscillator and others 32 MHz. Put this
information into the swim device platform_data so that the driver can
correctly enable the clock divider. When this is enabled incorrectly,
nothing can be read and failures from the Error Correction Machine are
flagged in the error register.

Cc: Joshua Thompson <funaho@xxxxxxxxx>
Acked-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
Reviewed-by: Laurent Vivier <laurent@xxxxxxxxx>
Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support")
Signed-off-by: Finn Thain <fthain@xxxxxxxxxxxxxx>
---
Changed since v2:
- Code motion was split off into a separate patch.
- Use 'bool fast_fclk' instead of 'unsigned int data'.
---
arch/m68k/mac/config.c | 31 ++++++++++++++++++++++++++++++-
drivers/block/swim.c | 9 ++++++---
2 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c
index c0033f885ed4..b745cf20a71f 100644
--- a/arch/m68k/mac/config.c
+++ b/arch/m68k/mac/config.c
@@ -984,8 +984,37 @@ static int __init mac_platform_init(void)
.start = swim_base,
.end = swim_base + 0x1FFF,
};
+ bool fast_fclk = false;
+
+ /* Models in this list are supposed to run FCLK at 32 MHz */
+ switch (macintosh_config->ident) {
+ case MAC_MODEL_CCL:
+ case MAC_MODEL_CCLII:
+ case MAC_MODEL_LCIII:
+ case MAC_MODEL_Q605:
+ case MAC_MODEL_Q605_ACC:
+ case MAC_MODEL_Q610:
+ case MAC_MODEL_Q630:
+ case MAC_MODEL_Q650:
+ case MAC_MODEL_Q800:
+ case MAC_MODEL_P460:
+ case MAC_MODEL_P475:
+ case MAC_MODEL_P475F:
+ case MAC_MODEL_P520:
+ case MAC_MODEL_P550:
+ case MAC_MODEL_P575:
+ case MAC_MODEL_P588:
+ case MAC_MODEL_TV:
+ case MAC_MODEL_C610:
+ case MAC_MODEL_C650:
+ case MAC_MODEL_PB190:
+ case MAC_MODEL_PB520:
+ fast_fclk = true;
+ break;
+ }

- platform_device_register_simple("swim", -1, &swim_rsrc, 1);
+ platform_device_register_resndata(NULL, "swim", -1, &swim_rsrc, 1,
+ &fast_fclk, sizeof(fast_fclk));
}

/*
diff --git a/drivers/block/swim.c b/drivers/block/swim.c
index b8384525fc9a..1ade5c497e10 100644
--- a/drivers/block/swim.c
+++ b/drivers/block/swim.c
@@ -806,8 +806,11 @@ static void swim_set_parameters(struct swim __iomem *base)
swim_write(base, parameter, mem[i]);
}

-static int swim_floppy_init(struct swim_priv *swd)
+static int swim_floppy_init(struct platform_device *pdev)
{
+ struct swim_priv *swd = platform_get_drvdata(pdev);
+ bool *data = pdev->dev.platform_data;
+ bool fast_fclk = data && *data;
struct queue_limits lim = {
.features = BLK_FEAT_ROTATIONAL,
};
@@ -815,7 +818,7 @@ static int swim_floppy_init(struct swim_priv *swd)
int drive;
struct swim __iomem *base = swd->base;

- swim_write(base, setup, S_IBM_DRIVE | S_FCLK_DIV2);
+ swim_write(base, setup, S_IBM_DRIVE | (fast_fclk ? S_FCLK_DIV2 : 0));

swim_set_parameters(base);

@@ -931,7 +934,7 @@ static int swim_probe(struct platform_device *dev)

swd->base = swim_base;

- ret = swim_floppy_init(swd);
+ ret = swim_floppy_init(dev);
if (ret)
goto out_kfree;

--
2.52.0