Re: [PATCH 03/31] swim: Enable the drive when probing
Laurent Vivier <[email protected]>
| Newsgroups | org.kernel.vger.linux-block,org.kernel.vger.linux-kernel,org.kernel.vger.linux-m68k |
|---|---|
| Message-ID | <[email protected]> |
Le 16/07/2026 à 12:02, Finn Thain a écrit :
> According to the ISM spec, the MOTON bit "causes the Enable 1 and Enable 2
> signals to be turned on to the drive." It doesn't actually turn on the
> motor. When selecting a drive, enable MOTON. Disable it upon eject or
> release. This fixes detection of the Sony FDHD drive.
>
> Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support")
> Signed-off-by: Finn Thain <[email protected]>
> ---
> drivers/block/swim.c | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
Reviewed-by: Laurent Vivier <[email protected]>
> diff --git a/drivers/block/swim.c b/drivers/block/swim.c
> index 2c52a210f4a6..2a400e544959 100644
> --- a/drivers/block/swim.c
> +++ b/drivers/block/swim.c
> @@ -154,8 +154,9 @@ struct iwm {
> /*----------------------------------------------------------------------------*/
>
> enum drive_location {
> - INTERNAL_DRIVE = 0x02,
> - EXTERNAL_DRIVE = 0x04,
> + NO_DRIVE = 0,
> + INTERNAL_DRIVE = BIT(1),
> + EXTERNAL_DRIVE = BIT(2),
> };
>
> enum media_type {
> @@ -311,9 +312,15 @@ static inline void swim_drive(struct swim __iomem *base,
> if (location == INTERNAL_DRIVE) {
> swim_write(base, mode0, EXTERNAL_DRIVE); /* clear drive 1 bit */
> swim_write(base, mode1, INTERNAL_DRIVE); /* set drive 0 bit */
> + swim_write(base, mode1, MOTON);
> } else if (location == EXTERNAL_DRIVE) {
> swim_write(base, mode0, INTERNAL_DRIVE); /* clear drive 0 bit */
> swim_write(base, mode1, EXTERNAL_DRIVE); /* set drive 1 bit */
> + swim_write(base, mode1, MOTON);
> + } else {
> + swim_write(base, mode0, INTERNAL_DRIVE);
> + swim_write(base, mode0, EXTERNAL_DRIVE);
> + swim_write(base, mode0, MOTON);
> }
> }
>
> @@ -447,6 +454,7 @@ static int floppy_eject(struct floppy_state *fs)
> swim_drive(base, fs->location);
> swim_motor(base, OFF);
> swim_eject(base);
> + swim_drive(base, NO_DRIVE);
>
> fs->disk_in = 0;
> fs->ejected = 1;
> @@ -652,8 +660,10 @@ static int floppy_open(struct gendisk *disk, blk_mode_t mode)
> else if (fs->ref_count > 0)
> --fs->ref_count;
>
> - if (fs->ref_count == 0)
> + if (fs->ref_count == 0) {
> swim_motor(base, OFF);
> + swim_drive(base, NO_DRIVE);
> + }
> return err;
> }
>
> @@ -682,6 +692,7 @@ static void floppy_release(struct gendisk *disk)
> if (fs->ref_count == 0) {
> swim_drive(base, fs->location);
> swim_motor(base, OFF);
> + swim_drive(base, NO_DRIVE);
> }
> mutex_unlock(&swim_mutex);
> }
> @@ -804,6 +815,7 @@ static int swim_floppy_init(struct swim_priv *swd)
> if (swim_readbit(base, DRIVE_PRESENT) &&
> !swim_readbit(base, ONEMEG_DRIVE))
> swim_add_floppy(swd, EXTERNAL_DRIVE);
> + swim_drive(base, NO_DRIVE);
>
> /* register floppy drives */
>