Skip to contentSkip to conversation

Add SWIM floppy support for m68k Macs.

PATCH Superseded [email protected] 7 participants 33 messages Nov 1, 2008 – Nov 11, 2008

Subsystems (3)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add SWIM floppy support for m68k Macs.

From: Laurent Vivier <[email protected]>

This patch is a port of the driver I wrote for kernel 2.2.

It allows to read data from a floppy, but not to write to, and to eject the floppy (useful on our Mac without eject button).

I have tested it on a Quadra 800, but it is supposed to work on:

II, IIci, IIsi, IIvx, IIx, IIcx, SE/30,
PowerBook 100, PowerBook 140, PowerBook 145, PowerBook 160, PowerBook 165, PowerBook 165c, PowerBook 170, PowerBook 180, PowerBook 180c, PowerBook 190, PowerBook 190cs, PowerBook 500, Performa 460, Performa 550, LC II, LC III, LC 520, Color Classic, Color Classic II, ClassicII,
Quadra 700, Quadra 800, Quadra 650, Quadra 605, Quadra 610, Centris 610, Quadra 630, Performa 580, LC 475, LC 575,

---
 arch/m68k/mac/Makefile   |    2 
 arch/m68k/mac/config.c   |    2 
 arch/m68k/mac/swim.c     |  111 +++++
 arch/m68k/mac/via.c      |    1 
 drivers/block/Kconfig    |   16 
 drivers/block/Makefile   |    3 
 drivers/block/swim.c     |  886 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/block/swim_asm.S |  295 +++++++++++++++
 8 files changed, 1315 insertions(+), 1 deletion(-)
arch/m68k/mac/Makefile +1 -1
Index: linux-2.6/arch/m68k/mac/Makefile
===================================================================
@@ -3,4 +3,4 @@
 #
 
 obj-y		:= config.o macints.o iop.o via.o oss.o psc.o \
-			baboon.o macboing.o debug.o misc.o
+			baboon.o macboing.o debug.o misc.o swim.o
arch/m68k/mac/config.c +2 -0
Index: linux-2.6/arch/m68k/mac/config.c
===================================================================
@@ -70,6 +70,7 @@
 extern void oss_init(void);
 extern void psc_init(void);
 extern void baboon_init(void);
+extern void swim_init(void);
 
 extern void mac_mksound(unsigned int, unsigned int);
 
@@ -815,6 +816,7 @@
 	oss_init();
 	psc_init();
 	baboon_init();
+	swim_init();
 }
 
 static void __init mac_report_hardware(void)
arch/m68k/mac/swim.c new file +111 -0

111 lines not on this page · raw message

arch/m68k/mac/via.c +1 -0
Index: linux-2.6/arch/m68k/mac/via.c
===================================================================
@@ -36,6 +36,7 @@
 #include <asm/mac_psc.h>
 
 volatile __u8 *via1, *via2;
+EXPORT_SYMBOL(via1);
 int rbv_present;
 int via_alt_mapping;
 EXPORT_SYMBOL(via_alt_mapping);
drivers/block/Kconfig +16 -0
Index: linux-2.6/drivers/block/Kconfig
===================================================================
@@ -44,6 +44,22 @@
 	  If you have a SWIM-3 (Super Woz Integrated Machine 3; from Apple)
 	  floppy controller, say Y here. Most commonly found in PowerMacs.
 
+config BLK_DEV_SWIM
+	tristate "Support for SWIM Macintosh floppy"
+	depends on M68K && MAC
+	help
+           You should select this option, if you want floppy support and
+           you have one of following macintoshes:
+
+           II, IIci, IIsi, IIvx, IIx, IIcx, SE/30,
+           PowerBook 100, PowerBook 140, PowerBook 145, PowerBook 160,
+           PowerBook 165, PowerBook 165c, PowerBook 170, PowerBook 180,
+           PowerBook 180c, PowerBook 190, PowerBook 190cs, PowerBook 500,
+           Performa 460, Performa 550, LC II, LC III, LC 520, Color Classic,
+           Color Classic II, ClassicII,
+           Quadra 700, Quadra 800, Quadra 650, Quadra 605, Quadra 610,
+           Centris 610, Quadra 630, Performa 580, LC 475, LC 575,
+
 config AMIGA_Z2RAM
 	tristate "Amiga Zorro II ramdisk support"
 	depends on ZORRO
drivers/block/Makefile +3 -0
Index: linux-2.6/drivers/block/Makefile
===================================================================
@@ -6,6 +6,7 @@
 # 
 
 obj-$(CONFIG_MAC_FLOPPY)	+= swim3.o
+obj-$(CONFIG_BLK_DEV_SWIM)	+= swim_mod.o
 obj-$(CONFIG_BLK_DEV_FD)	+= floppy.o
 obj-$(CONFIG_AMIGA_FLOPPY)	+= amiflop.o
 obj-$(CONFIG_PS3_DISK)		+= ps3disk.o
@@ -32,3 +33,5 @@
 obj-$(CONFIG_BLK_DEV_HD)	+= hd.o
 
 obj-$(CONFIG_XEN_BLKDEV_FRONTEND)	+= xen-blkfront.o
+
+swim_mod-objs	:= swim.o swim_asm.o
drivers/block/swim.c new file +886 -0

886 lines not on this page · raw message

drivers/block/swim_asm.S new file +295 -0

295 lines not on this page · raw message

#1 lore raw
Quoted 5 lines · On Sat, Nov 01, 2008 at 10:43:11AM +0100, [email protected] wrote:

It allows to read data from a floppy, but not to write to, and to eject the floppy (useful on our Mac without eject button).

I have tested it on a Quadra 800, but it is supposed to work on:

Quoted 8 lines

II, IIci, IIsi, IIvx, IIx, IIcx, SE/30,
PowerBook 100, PowerBook 140, PowerBook 145, PowerBook 160, PowerBook 165, PowerBook 165c, PowerBook 170, PowerBook 180, PowerBook 180c, PowerBook 190, PowerBook 190cs, PowerBook 500, Performa 460, Performa 550, LC II, LC III, LC 520, Color Classic, Color Classic II, ClassicII,
Quadra 700, Quadra 800, Quadra 650, Quadra 605, Quadra 610, Centris 610, Quadra 630, Performa 580, LC 475, LC 575,

I just have one comment and one question. The model check looks like it will end up printing out a warning message on the AV models. You should add them explicitly to the unsupported list the way you did for the IIfx and Q900/Q950. Also, I'm not sure this driver would work on a Mac II. They didn't originally ship with a SWIM chip at all, but that was available as an upgrade. From the factory they came with the old IWM chip. It's not clear to me if the driver uses any of the SWIM features other than the capability to detect and read high density media which the old drives obviously don't do.

Other than that, it's good to see someone working on this.

Brad Boyer
[email protected]

#2 lore raw
Quoted 14 lines · Brad Boyer
Quoted 5 lines · On Sat, Nov 01, 2008 at 10:43:11AM +0100, [email protected] wrote:

It allows to read data from a floppy, but not to write to, and to eject the floppy (useful on our Mac without eject button).

I have tested it on a Quadra 800, but it is supposed to work on:

Quoted 7 lines

II, IIci, IIsi, IIvx, IIx, IIcx, SE/30, PowerBook 100, PowerBook 140, PowerBook 145, PowerBook 160, PowerBook 165, PowerBook 165c, PowerBook 170, PowerBook 180, PowerBook 180c, PowerBook 190, PowerBook 190cs, PowerBook 500, Performa 460, Performa 550, LC II, LC III, LC 520, Color Classic, Color Classic II, ClassicII, Quadra 700, Quadra 800, Quadra 650, Quadra 605, Quadra 610, Centris 610, Quadra 630, Performa 580, LC 475, LC 575,

Quoted 9 lines

I just have one comment and one question. The model check looks like it will end up printing out a warning message on the AV models. You should add them explicitly to the unsupported list the way you did for the IIfx and Q900/Q950. Also, I'm not sure this driver would work on a Mac II. They didn't originally ship with a SWIM chip at all, but that was available as an upgrade. From the factory they came with the old IWM chip. It's not clear to me if the driver uses any of the SWIM features other than the capability to detect and read high density media which the old drives obviously don't do.

I think that unless we can probe for the SWIM chip, we should put this information in arch/m68k/mac/config.c. A floppy_type member could be added to struct mac_model to clean up the init code here. That init code could then simply test macintosh_config like all the other drivers that can't or don't probe.

To avoid confusion, I'd also prefer that we don't list the names of models in the comment at the start of this file since so many models go under a variety of different names. For example http://www.mac.linux-m68k.org/status/
shows that 10 models indistinguishable for our purposes were rebadged under about 30 different names for marketing purposes.

Finn

Quoted 10 lines

Other than that, it's good to see someone working on this.

Brad Boyer
[email protected]

--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 5 lines · Finn Thain

I think that unless we can probe for the SWIM chip, we should put this information in arch/m68k/mac/config.c. A floppy_type member could be added to struct mac_model to clean up the init code here. That init code could then simply test macintosh_config like all the other drivers that can't or don't probe.

I didn't think about it when I commented earlier, but I agree with this suggestion. I think there are 5 types we need to put in the table:

MAC_FLOPPY_IWM
MAC_FLOPPY_SWIM_ADDR1
MAC_FLOPPY_SWIM_ADDR2
MAC_FLOPPY_SWIM_IOP
MAC_FLOPPY_AV

We don't have to use this exact naming, but this is the basic categories, and this driver should handle number 2 and 3 (and maybe 1).

Brad Boyer
[email protected]

#4 lore raw
In reply to Brad Boyer
Quoted 16 lines · Brad Boyer
Quoted 6 lines · On Sat, Nov 01, 2008 at 10:43:11AM +0100, [email protected] wrote:

It allows to read data from a floppy, but not to write to, and to eject the
floppy (useful on our Mac without eject button).

I have tested it on a Quadra 800, but it is supposed to work on:

Quoted 8 lines

II, IIci, IIsi, IIvx, IIx, IIcx, SE/30,
PowerBook 100, PowerBook 140, PowerBook 145, PowerBook 160, PowerBook 165, PowerBook 165c, PowerBook 170, PowerBook 180, PowerBook 180c, PowerBook 190, PowerBook 190cs, PowerBook 500, Performa 460, Performa 550, LC II, LC III, LC 520, Color Classic, Color Classic II, ClassicII,
Quadra 700, Quadra 800, Quadra 650, Quadra 605, Quadra 610, Centris 610, Quadra 630, Performa 580, LC 475, LC 575,

Quoted 4 lines

I just have one comment and one question. The model check looks like it will end up printing out a warning message on the AV models. You should add them explicitly to the unsupported list the way you did for the IIfx and Q900/Q950. Also, I'm not sure this driver would

OK

Quoted 6 lines

work on a Mac II. They didn't originally ship with a SWIM chip at all, but that was available as an upgrade. From the factory they came with the old IWM chip. It's not clear to me if the driver uses any of the SWIM features other than the capability to detect and read high density media which the old drives obviously don't do.

I don't have MacII to test. But this driver needs a SWIM chip to work.

Regards,
Laurent
----------------------- Laurent Vivier ---------------------- "The best way to predict the future is to invent it."
- Alan Kay

--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

Hi,

Quoted 8 lines · Laurent Vivier
Quoted 5 lines

work on a Mac II. They didn't originally ship with a SWIM chip at all, but that was available as an upgrade. From the factory they came with the old IWM chip. It's not clear to me if the driver uses any of the SWIM features other than the capability to detect and read high density media which the old drives obviously don't do.

I don't have MacII to test. But this driver needs a SWIM chip to work.

I have a mac II, but I upgraded the SWIM chip, IIRC. I think I upgraded only one of the two drives to high density, but that shouldn't affect you I suppose, since the problem would be the chip. I'll look in my spare parts bin.

Riccardo

#6 lore raw
Quoted 4 lines · Riccardo

I have a mac II, but I upgraded the SWIM chip, IIRC. I think I upgraded only one of the two drives to high density, but that shouldn't affect you I suppose, since the problem would be the chip. I'll look in my spare parts bin.

I'm curious about how the chip update appears on the II. Does this system now show up as a IIx? My understanding is that the upgrade kit included a new set of ROM chips that include the same bits as the ones from the IIx. Hopefully there's a logical way to detect this upgrade, but it would be interesting to know if the update changes the gestalt ID.

Brad Boyer
[email protected]

#7 lore raw
Quoted 11 lines · Brad Boyer
Quoted 4 lines · Riccardo

I have a mac II, but I upgraded the SWIM chip, IIRC. I think I upgraded only one of the two drives to high density, but that shouldn't affect you I suppose, since the problem would be the chip. I'll look in my spare parts bin.

I'm curious about how the chip update appears on the II. Does this system now show up as a IIx? My understanding is that the upgrade kit included a new set of ROM chips that include the same bits as the ones from the IIx. Hopefully there's a logical way to detect this upgrade, but it would be interesting to know if the update changes the gestalt ID.

Under Mac 7.1 it gets definitively recognized as Mac II. I definitively have a SWIM, since one of my two floppies reads HD disks, I checked

Penguin says my gestalt is 6, Mac II

A clue for the MacII is the 68020 CPU + FPU + MMU, AFAIK the only apple machine with these specs.

I tried to boot a current 2.6.18 kernel just for fun, it goes past the letter screen and dumps stack after recognizing the TOBY frame buffer card and attempting to init it.

Riccardo

PS: I didn't use this mac since many months, it first stasrted up, but then refusedfurther boots with the sad mac sound and no video output. REmoving components trying to isolate the problem didn't help. When I put al back together with no luck, a last attempt made it boot. Any ideas? I see no visible damage on the motherboard, the batteries still have some juice left...

#8 lore raw
Quoted 7 lines · Riccardo

Under Mac 7.1 it gets definitively recognized as Mac II. I definitively have a SWIM, since one of my two floppies reads HD disks, I checked

Penguin says my gestalt is 6, Mac II

A clue for the MacII is the 68020 CPU + FPU + MMU, AFAIK the only apple machine with these specs.

That definitely answers my question. Thank you.

Quoted 6 lines

PS: I didn't use this mac since many months, it first stasrted up, but then refusedfurther boots with the sad mac sound and no video output. REmoving components trying to isolate the problem didn't help. When I put al back together with no luck, a last attempt made it boot. Any ideas? I see no visible damage on the motherboard, the batteries still have some juice left...

It's hard to say what might be the problem. The symptoms of a bad battery are quite a bit different. This almost sounds more like a bad video card to me. Do you have a different one you can try? A lot of older macs refuse to boot without video.

Brad Boyer
[email protected]

#9 lore raw

Brad,

Quoted 11 lines · Brad Boyer
Quoted 7 lines · Riccardo

Under Mac 7.1 it gets definitively recognized as Mac II. I definitively have a SWIM, since one of my two floppies reads HD disks, I checked

Penguin says my gestalt is 6, Mac II

A clue for the MacII is the 68020 CPU + FPU + MMU, AFAIK the only apple machine with these specs.

That definitely answers my question. Thank you.

true. But if the gestalt remains 6 even with a HD drive chip, how can you detect it?

- original IWM 800k drives
- SWIM with 800k drives or mixed drives
- SWIM with only 1.4k drives

I'm in the second situation, btw.

Riccardo

#10 lore raw
Quoted 9 lines · Riccardo

true. But if the gestalt remains 6 even with a HD drive chip, how can you detect it?

- original IWM 800k drives
- SWIM with 800k drives or mixed drives
- SWIM with only 1.4k drives

I'm in the second situation, btw.

We can definitely detect the difference between the second and third options, since the SWIM chip can detect the type of each drive that is connected. The driver detects the media type, but I don't recall if it explicitly checked the drive type. The swim_iop driver did that (and not much else) so the chip has the capability.

Telling which chip is installed may be the hardest part, although the SWIM chip has a compatibility mode. As mentioned in another email, there is a procedure to change the mode the chip is in. If this method does something predictable on the IWM chip that doesn't put the chip into a bad state, then we can probably detect which chip is actually installed reliably. It might be interesting to disassemble the drivers in the updated ROM to see if it can cope with the IWM chip for people that tried the new ROM with the old floppy controller.

Brad Boyer
[email protected]

#11 lore raw
In reply to Riccardo
Quoted 16 lines · Riccardo
Quoted 6 lines · Brad Boyer
Quoted 4 lines · Riccardo

I have a mac II, but I upgraded the SWIM chip, IIRC. I think I upgraded only one of the two drives to high density, but that shouldn't affect you I suppose, since the problem would be the chip. I'll look in my spare parts bin.

Quoted 6 lines

I'm curious about how the chip update appears on the II. Does this system now show up as a IIx? My understanding is that the upgrade kit included a new set of ROM chips that include the same bits as the ones from the IIx. Hopefully there's a logical way to detect this upgrade, but it would be interesting to know if the update changes the gestalt ID.

Quoted 7 lines

Under Mac 7.1 it gets definitively recognized as Mac II. I definitively have a SWIM, since one of my two floppies reads HD disks, I checked

Penguin says my gestalt is 6, Mac II

A clue for the MacII is the 68020 CPU + FPU + MMU, AFAIK the only apple machine with these specs.

One way around this (if we can't probe for SWIM vs. IWM), is install "I Wish I Were" and set the Gestalt ID to 7 (Mac IIx). It works on my Daystar '030 Mac II; it may work for you too.

Quoted 3 lines

I tried to boot a current 2.6.18 kernel just for fun, it goes past the letter screen and dumps stack after recognizing the TOBY frame buffer card and attempting to init it.

I've seen this with more recent kernels. Not sure about 2.6.18. It happens because a proc file is registered twice by the nubus probe code. It is only a cosmetic problem, but I have been working on a patch for it.

You may want to try Stephen's daily build,

http://people.debian.org/~smarenka/m68k/kernel/linux-image-2.6.26-1-mac_2.6.26-9_m68k.deb

Quoted 9 lines

Riccardo

PS: I didn't use this mac since many months, it first stasrted up, but then refusedfurther boots with the sad mac sound and no video output. REmoving components trying to isolate the problem didn't help. When I put al back together with no luck, a last attempt made it boot. Any ideas? I see no visible damage on the motherboard, the batteries still have some juice left...

My machine does that sometimes too. I blame the aging powersupply/capacitors (either too slow to reach a stable voltage or too quick to come out of reset) but I'm guessing.

Finn

Quoted 6 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#13 lore raw
In reply to Brad Boyer
Quoted 11 lines · Brad Boyer
Quoted 4 lines · Riccardo

I have a mac II, but I upgraded the SWIM chip, IIRC. I think I upgraded only one of the two drives to high density, but that shouldn't affect you I suppose, since the problem would be the chip. I'll look in my spare parts bin.

I'm curious about how the chip update appears on the II. Does this system now show up as a IIx? My understanding is that the upgrade kit included a new set of ROM chips that include the same bits as the ones from the IIx. Hopefully there's a logical way to detect this upgrade, but it would be interesting to know if the update changes the gestalt ID.

You would detect an upgraded ROM by reading the ROM, I imagine. In Genie, it's at /sys/mac/rom.

By the way, does anyone know how to calculate a ROM checksum, or will I have to reverse-engineer CopyROM or somesuch?

Josh

#14 lore raw
Quoted 8 lines · Joshua Juran
Quoted 4 lines · Brad Boyer

On Tue, Nov 04, 2008 at 07:34:41PM +0100, Riccardo wrote:

Hopefully there's a logical way to detect this upgrade, but it would be interesting to know if the update changes the gestalt ID.

You would detect an upgraded ROM by reading the ROM, I imagine.

Good point. But I think we'd need the ROM base to be supplied by Penguin? Or even just the ROM checksum.

Quoted 3 lines

In Genie, it's at /sys/mac/rom.
By the way, does anyone know how to calculate a ROM checksum, or will I have to reverse-engineer CopyROM or somesuch?

I assumed that CopyROM etc did not validate anything, they just reported the checksum contained in the ROM (first 4 bytes). The code must be part of the POST though, since a bad rom checksum is a sad mac error. So you could reverse engineer that. But IIRC there is a card ROM checksum algorithm given in Designing Card and Drivers for the Mac II and Mac SE. It's probably the same algorithm. I don't have access to my copy at the moment.

Finn

Quoted 9 lines

Josh

--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#15 lore raw
Quoted 6 lines · Finn Thain
Quoted 4 lines · Joshua Juran
Quoted 2 lines · Brad Boyer

On Tue, Nov 04, 2008 at 07:34:41PM +0100, Riccardo wrote:

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Hopefully there's a logical way to detect this upgrade, but it would be interesting to know if the update changes the gestalt ID.

You would detect an upgraded ROM by reading the ROM, I imagine.

Good point. But I think we'd need the ROM base to be supplied by Penguin? Or even just the ROM checksum.

It's probably a good idea for the kernel to know the address and size of the ROM, and given those (or just the former) it can determine the checksum. Penguin can get these from low memory and Gestalt() respectively. EMILE can too iff they're set up in ROM -- I don't know.

Quoted 5 lines
Quoted 2 lines

By the way, does anyone know how to calculate a ROM checksum, or will I have to reverse-engineer CopyROM or somesuch?

I assumed that CopyROM etc did not validate anything, they just reported the checksum contained in the ROM (first 4 bytes).

Oh. Red herring, then. So for our purposes it's just a magic number, and the "checksum" algorithm would be:

	inline unsigned long checksum( const void* rom, unsigned long size )
	{
		return *(const unsigned long*) rom;
	}

:-)

Quoted 6 lines

The code must be part
of the POST though, since a bad rom checksum is a sad mac error. So you could reverse engineer that. But IIRC there is a card ROM checksum algorithm given in Designing Card and Drivers for the Mac II and Mac SE. It's probably the same algorithm. I don't have access to my copy at the moment.

Might be interesting, but not necessary -- if we really wanted to verify the ROM was intact we could use any checksum algorithm we wished, with a table mapping one to the other.

But one of these days I should spend some quality time disassembling ROM anyway.

Josh

#16 lore raw
Quoted 9 lines · Joshua Juran
Quoted 7 lines · Finn Thain
Quoted 5 lines · Joshua Juran
Quoted 3 lines · Brad Boyer

On Tue, Nov 04, 2008 at 07:34:41PM +0100, Riccardo wrote:

Hopefully there's a logical way to detect this upgrade

...

Quoted 3 lines

It's probably a good idea for the kernel to know the address and size of the ROM

No need (the less code the better).

And passing just a checksum from the bootloader is still an awful hack compared to probing for IWM or SWIM on a Mac II.

Finn

#17 lore raw
Quoted 16 lines · Finn Thain
Quoted 9 lines · Joshua Juran
Quoted 7 lines · Finn Thain
Quoted 5 lines · Joshua Juran
Quoted 3 lines · Brad Boyer

On Tue, Nov 04, 2008 at 07:34:41PM +0100, Riccardo wrote:

Hopefully there's a logical way to detect this upgrade

...

Quoted 1 line
Quoted 8 lines
Quoted 3 lines

It's probably a good idea for the kernel to know the address and size of
the ROM

No need (the less code the better).

And passing just a checksum from the bootloader is still an awful hack compared to probing for IWM or SWIM on a Mac II.

The SWIM chip can act like an IWM one and there is a procedure to know in which mode it is.

If we suppose the SWIM chip on MacII is at the same address than the IWM one, we should be able to use this procedure to know if it is an IWM or a SWIM.

Regards,
Laurent
----------------------- Laurent Vivier ---------------------- "The best way to predict the future is to invent it."
- Alan Kay

--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#18 lore raw
Quoted 2 lines · Laurent Vivier

The SWIM chip can act like an IWM one and there is a procedure to know in which mode it is.

That is good to know. Hopefully that can also be used to detect which chip it is, possibly by checking for a mode change failure.

Quoted 3 lines

If we suppose the SWIM chip on MacII is at the same address than the IWM one, we should be able to use this procedure to know if it is an IWM or a SWIM.

It would have to be the same address, since the address decoding logic is part of the bus interface circuits on 68k macs. Each IO chip just has a chip select and a few address lines based on what I've seen.

Brad Boyer
[email protected]

#19 lore raw
In reply to [email protected]

Nice work!

Critique follows.

Quoted 13 lines · On Sat, 1 Nov 2008, [email protected] wrote:

Index: linux-2.6/arch/m68k/mac/config.c
===================================================================

arch/m68k/mac/config.c +1 -0
@@ -70,6 +70,7 @@
 extern void oss_init(void);
 extern void psc_init(void);
 extern void baboon_init(void);
+extern void swim_init(void);
 
 extern void mac_mksound(unsigned int, unsigned int);
 

arch/m68k/mac/config.c line 820

Quoted 5 lines
arch/m68k/mac/config.c +1 -0
@@ -815,6 +816,7 @@
 	oss_init();
 	psc_init();
 	baboon_init();
+	swim_init();
 }

It would reduce coupling if config.c didn't need to know about the floppy drive... I suspect that the initialisation can be simplified with device_initcall.

Quoted 5 lines
arch/m68k/mac/config.c +0 -0
 static void __init mac_report_hardware(void)

Index: linux-2.6/arch/m68k/mac/swim.c
===================================================================

arch/m68k/mac/swim.c new file +0 -0

...

arch/m68k/mac/swim.c line 31

Quoted 2 lines
arch/m68k/mac/swim.c new file +2 -0
+#define writePhase	*(SWIMBase + 0x0800)
+#define readPhase	*(SWIMBase + 0x1800)

These are unused.

...

arch/m68k/mac/swim.c line 103

Quoted 3 lines
arch/m68k/mac/swim.c new file +3 -0
+	default:
+		SWIMBase = NULL;
+		printk("SWIM: unknown Macintosh: report to maintainer !\n");

If macintosh_config->ident is not in mac_data_table, config.c prints "Detected Macintosh model: Unknown", so there's no need to repeat it here.

...

drivers/block/swim.c line 2

Quoted 7 lines

Index: linux-2.6/drivers/block/swim.c
===================================================================

drivers/block/swim.c new file +2 -0
@@ -0,0 +1,886 @@
+/*
+ * Driver for SWIM (Sander. Woz Integrated Machine) floppy controller

Sander Woz Integrated Machine, also known as Super Woz Integrated Machine.

...

drivers/block/swim.c line 151

Quoted 10 lines
drivers/block/swim.c new file +10 -0
+
+/* bits in mode register */
+
+#define CLFIFO		0x01
+#define ENBL1		0x02
+#define ENBL2		0x04
+#define ACTION		0x08
+#define	WRITE_MODE	0x10
+#define	HEDSEL		0x20
+#define	MOTON		0x80

Extra tabs. HEAD_SEL? MOTOR_ON?

...

drivers/block/swim.c line 293

Quoted 4 lines
drivers/block/swim.c new file +4 -0
+
+static inline void swim_head(head_t head)
+{
+	/* FIXME: IWM reads bits SEL, CA2, CA1 to wait drive ready... */

By SEL, do you mean VIA1A_vHeadSel or the chip register? I wonder if CA1 and CA2 were used for the floppy on 68000 macs... CA1 and CA2 are timers on the Macs we support. Guide to Mac Family hardware might be able to clarify this a bit.

Quoted 6 lines
drivers/block/swim.c new file +6 -0
+
+	/* wait drive is ready */
+
+	if (head == UPPER_HEAD)
+		swim_select(READ_DATA_1);
+	else if (head == LOWER_HEAD)

drivers/block/swim.c line 309

Quoted 10 lines
drivers/block/swim.c new file +10 -0
+		swim_select(READ_DATA_0);
+}
+
+static inline int swim_step(void)
+{
+	int wait;
+
+	swim_action(STEP);
+
+	for (wait = 0; wait < 80; wait++) {

Should this loop counter be referred to HZ too?

drivers/block/swim.c line 520

Quoted 8 lines

...

drivers/block/swim.c new file +7 -0
+
+static struct floppy_struct floppy_type[4] = {
+	{    0, 0,0, 0,0,0x00,0x00,0x00,0x00,NULL },	/*  0 no testing    */
+	{  720, 9,1,80,0,0x2A,0x02,0xDF,0x50,NULL },	/*  3 360KB SS 3.5" */
+	{ 1440, 9,2,80,0,0x2A,0x02,0xDF,0x50,NULL },	/*  4 720KB 3.5"    */
+	{ 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,NULL },    /*  7 1.44MB 3.5"   */
+};

The last 3 entries are unused...

Quoted 10 lines
drivers/block/swim.c new file +10 -0
+
+static int get_floppy_geometry(int drive, int type, struct floppy_struct **g)
+{
+	struct floppy_state *fs;
+	fs = &unit[drive];
+
+	if (drive > floppy_count)
+		return -ENODEV;
+
+	if (type >= ARRAY_SIZE(floppy_type))

drivers/block/swim.c line 540

Quoted 10 lines
drivers/block/swim.c new file +10 -0
+		return -EINVAL;
+
+	if (type)
+		*g = &floppy_type[type];
+	else if (fs->type == HD_MEDIA) /* High-Density media */
+		*g = &floppy_type[3];
+	else if (fs->head_number == 2) /* double-sided */
+		*g = &floppy_type[2];
+	else
+		*g = &floppy_type[1];

...since type is always 0. I wonder how we should deal with 400K and 800K floppies. It's academic I guess.

...

drivers/block/swim.c line 848

Quoted 4 lines
drivers/block/swim.c new file +4 -0
+
+static int __init swim_init(void)
+{
+	printk(KERN_INFO "Inserting SWIM floppy driver\n");

Is this for debugging purposes? I'd prefer to avoid the log spam.

drivers/block/swim.c line 857

Quoted 9 lines
drivers/block/swim.c new file +9 -0
+
+	if (base) {
+		printk(KERN_INFO "SWIM: Setting SWIMBase to 0x%p\n", base);
+		SWIMBase = (struct swim *)base;
+	}
+
+	return swim_floppy_init();
+}
+module_init(swim_init)

Can we elimiate the additions to arch/m68k/mac and merge the init routine from arch/m68k/mac/swim.c with this one by making it a device_initcall?

Regards,
Finn

#20 lore raw
Quoted 3 lines · Finn Thain

Nice work!

Thank you.

Quoted 18 lines

Critique follows.

Quoted 14 lines · On Sat, 1 Nov 2008, [email protected] wrote:

Index: linux-2.6/arch/m68k/mac/config.c
===================================================================
--- linux-2.6.orig/arch/m68k/mac/config.c 2008-11-01
06:13:53.000000000 +0100
+++ linux-2.6/arch/m68k/mac/config.c 2008-11-01 06:14:39.000000000
+0100

arch/m68k/mac/config.c +1 -0
@@ -70,6 +70,7 @@
 extern void oss_init(void);
 extern void psc_init(void);
 extern void baboon_init(void);
+extern void swim_init(void);
 
 extern void mac_mksound(unsigned int, unsigned int);
 
Quoted 11 lines

arch/m68k/mac/config.c line 820

Quoted 6 lines
arch/m68k/mac/config.c +1 -0
@@ -815,6 +816,7 @@
 	oss_init();
 	psc_init();
 	baboon_init();
+	swim_init();
 }

It would reduce coupling if config.c didn't need to know about the floppy
drive... I suspect that the initialisation can be simplified with device_initcall.

OK.

Quoted 9 lines
Quoted 8 lines
arch/m68k/mac/config.c +0 -0
 static void __init mac_report_hardware(void)

Index: linux-2.6/arch/m68k/mac/swim.c
===================================================================

arch/m68k/mac/swim.c new file +1 -0
+0100

...

Quoted 4 lines

arch/m68k/mac/swim.c line 31

Quoted 2 lines
arch/m68k/mac/swim.c new file +2 -0
+#define writePhase	*(SWIMBase + 0x0800)
+#define readPhase	*(SWIMBase + 0x1800)

These are unused.

OK

Quoted 11 lines

...

arch/m68k/mac/swim.c line 103

Quoted 3 lines
arch/m68k/mac/swim.c new file +3 -0
+	default:
+		SWIMBase = NULL;
+		printk("SWIM: unknown Macintosh: report to maintainer !\n");

If macintosh_config->ident is not in mac_data_table, config.c prints "Detected Macintosh model: Unknown", so there's no need to repeat it here.

...

Quoted 13 lines
Quoted 9 lines

Index: linux-2.6/drivers/block/swim.c
===================================================================

drivers/block/swim.c new file +3 -0
+0100
@@ -0,0 +1,886 @@
+/*
+ * Driver for SWIM (Sander. Woz Integrated Machine) floppy  

controller

Sander Woz Integrated Machine, also known as Super Woz Integrated Machine.

OK

Quoted 13 lines

...

drivers/block/swim.c line 151

Quoted 10 lines
drivers/block/swim.c new file +10 -0
+
+/* bits in mode register */
+
+#define CLFIFO		0x01
+#define ENBL1		0x02
+#define ENBL2		0x04
+#define ACTION		0x08
+#define	WRITE_MODE	0x10
+#define	HEDSEL		0x20
+#define	MOTON		0x80

Extra tabs.

OK

Quoted 1 line

HEAD_SEL? MOTOR_ON?

Yes

Quoted 14 lines

...

drivers/block/swim.c line 293

Quoted 4 lines
drivers/block/swim.c new file +4 -0
+
+static inline void swim_head(head_t head)
+{
+	/* FIXME: IWM reads bits SEL, CA2, CA1 to wait drive ready... */

By SEL, do you mean VIA1A_vHeadSel or the chip register? I wonder if CA1
and CA2 were used for the floppy on 68000 macs... CA1 and CA2 are timers
on the Macs we support. Guide to Mac Family hardware might be able to clarify this a bit.

I check that.

Quoted 10 lines
Quoted 10 lines
drivers/block/swim.c new file +10 -0
+
+	/* wait drive is ready */
+
+	if (head == UPPER_HEAD)
+		swim_select(READ_DATA_1);
+	else if (head == LOWER_HEAD)
+		swim_select(READ_DATA_0);
+}
+
+static inline int swim_step(void)
Quoted 8 lines

drivers/block/swim.c line 309

Quoted 6 lines
drivers/block/swim.c new file +6 -0
+{
+	int wait;
+
+	swim_action(STEP);
+
+	for (wait = 0; wait < 80; wait++) {

Should this loop counter be referred to HZ too?

I check that, too.

Quoted 14 lines
Quoted 11 lines

...

drivers/block/swim.c new file +6 -0
+
+static struct floppy_struct floppy_type[4] = {
+	{    0, 0,0, 0,0,0x00,0x00,0x00,0x00,NULL },	/*  0 no testing    */
+	{  720, 9,1,80,0,0x2A,0x02,0xDF,0x50,NULL },	/*  3 360KB SS 3.5" */
+	{ 1440, 9,2,80,0,0x2A,0x02,0xDF,0x50,NULL },	/*  4 720KB 3.5"    */
+	{ 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,NULL },    /*  7 1.44MB  

3.5" */
+};

The last 3 entries are unused...

You're wrong...

Quoted 17 lines
Quoted 17 lines
drivers/block/swim.c new file +2 -0
+
+static int get_floppy_geometry(int drive, int type, struct  

floppy_struct **g)

drivers/block/swim.c new file +14 -0
+{
+	struct floppy_state *fs;
+	fs = &unit[drive];
+
+	if (drive > floppy_count)
+		return -ENODEV;
+
+	if (type >= ARRAY_SIZE(floppy_type))
+		return -EINVAL;
+
+	if (type)
+		*g = &floppy_type[type];
+	else if (fs->type == HD_MEDIA) /* High-Density media */
+		*g = &floppy_type[3];
Quoted 8 lines

drivers/block/swim.c line 540

Quoted 4 lines
drivers/block/swim.c new file +4 -0
+	else if (fs->head_number == 2) /* double-sided */
+		*g = &floppy_type[2];
+	else
+		*g = &floppy_type[1];

...since type is always 0. I wonder how we should deal with 400K and 800K
floppies. It's academic I guess

type is always 0, but floppy_type[] is used with values 3, 2 and 1.

Well, as I've not a lot of time, I'm working only on the MFM support (to read floppy written on a PC)

Quoted 9 lines

...

drivers/block/swim.c line 848

Quoted 4 lines
drivers/block/swim.c new file +4 -0
+
+static int __init swim_init(void)
+{
+	printk(KERN_INFO "Inserting SWIM floppy driver\n");

Is this for debugging purposes? I'd prefer to avoid the log spam.

OK

Quoted 6 lines
Quoted 6 lines
drivers/block/swim.c new file +6 -0
+
+	if (base) {
+		printk(KERN_INFO "SWIM: Setting SWIMBase to 0x%p\n", base);
+		SWIMBase = (struct swim *)base;
+	}
+
Quoted 8 lines

drivers/block/swim.c line 857

Quoted 3 lines
drivers/block/swim.c new file +3 -0
+	return swim_floppy_init();
+}
+module_init(swim_init)

Can we elimiate the additions to arch/m68k/mac and merge the init routine
from arch/m68k/mac/swim.c with this one by making it a device_initcall?

I try this.

Regards,
Laurent
----------------------- Laurent Vivier ---------------------- "The best way to predict the future is to invent it."
- Alan Kay

--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#21 lore raw
In reply to [email protected]
Quoted 3 lines · On Sat, 1 Nov 2008, [email protected] wrote:

From: Laurent Vivier <[email protected]>

This patch is a port of the driver I wrote for kernel 2.2.

Please run scripts/checkpatch.pl on your patch and fix the errors/warnings.

Quoted 24 lines
arch/m68k/mac/swim.c new file +21 -0
@@ -0,0 +1,111 @@
+/*
+ * Driver for SWIM (Sander. Woz Integrated Machine) floppy controller
+ *
+ * Copyright (C) 2004,2008 Laurent Vivier <[email protected]>
+ *
+ * based on netBSD IWM driver (c) 1997, 1998 Hauke Fath.
+ * based  on Alastair Bridgewater SWIM analysis, 2001
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * 2004-09-02 (lv) - Initial implementation
+ * 2008-10-30 (lv) - Port to kernel 2.6
+ */
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/init.h>

arch/m68k/mac/swim.c line 31

Quoted 10 lines
arch/m68k/mac/swim.c new file +10 -0
+#include <linux/module.h>
+
+#include <asm/macintosh.h>
+#include <asm/mac_via.h>
+
+volatile __u8 *SWIMBase;
+EXPORT_SYMBOL(SWIMBase);
+
+#define writePhase	*(SWIMBase + 0x0800)
+#define readPhase	*(SWIMBase + 0x1800)

These two definitions are not used in this file?

Quoted 69 lines
arch/m68k/mac/swim.c new file +69 -0
+/*
+ * According to IWM netBSD driver, there are four kinds of SWIM:
+ *
+ * - QUADRA, QUADRA2, P580 -> SWIM base address is VIA1 + 0x1E000;
+ * - II, PB, LC		   -> SWIM base address is VIA1 + 0x16000;
+ * - IIfx, Q900, Q950	   -> managed by IOP driver
+ * - AV			   -> not managed
+ *
+ */
+
+void __init swim_init(void)
+{
+	switch(macintosh_config->ident)
+	{
+	case MAC_MODEL_Q700:
+	case MAC_MODEL_Q800:
+	case MAC_MODEL_Q650:
+	case MAC_MODEL_Q605:
+	case MAC_MODEL_Q605_ACC:
+	case MAC_MODEL_Q610:
+	case MAC_MODEL_Q630:
+	case MAC_MODEL_P475:
+	case MAC_MODEL_P475F:
+	case MAC_MODEL_P575:
+	case MAC_MODEL_P588:
+		SWIMBase =  (__u8*)(VIA1_BASE + 0x1E000);
+		break;
+	case MAC_MODEL_II:
+	case MAC_MODEL_IIX:
+	case MAC_MODEL_IICX:
+	case MAC_MODEL_SE30:
+	case MAC_MODEL_PB140:
+	case MAC_MODEL_PB145:
+	case MAC_MODEL_PB160:
+	case MAC_MODEL_PB165:
+	case MAC_MODEL_PB165C:
+	case MAC_MODEL_PB170:
+	case MAC_MODEL_PB180:
+	case MAC_MODEL_PB180C:
+	case MAC_MODEL_PB190:
+	case MAC_MODEL_PB520:
+	case MAC_MODEL_PB150:
+	case MAC_MODEL_PB210:
+	case MAC_MODEL_PB230:
+	case MAC_MODEL_PB250:
+	case MAC_MODEL_PB270C:
+	case MAC_MODEL_PB280:
+	case MAC_MODEL_PB280C:
+	case MAC_MODEL_IICI:
+	case MAC_MODEL_IISI:
+	case MAC_MODEL_IIVI:
+	case MAC_MODEL_IIVX:
+	case MAC_MODEL_P600:
+	case MAC_MODEL_P460:
+	case MAC_MODEL_P550:
+	case MAC_MODEL_TV:
+	case MAC_MODEL_LCII:
+	case MAC_MODEL_LCIII:
+	case MAC_MODEL_P520:
+	case MAC_MODEL_CLII:
+	case MAC_MODEL_CCL:
+		SWIMBase =  (__u8*)(VIA1_BASE + 0x16000);
+		break;
+	case MAC_MODEL_IIFX:
+	case MAC_MODEL_Q900:
+	case MAC_MODEL_Q950:
+		SWIMBase = NULL;
+		break;
+	default:

arch/m68k/mac/swim.c line 111

Quoted 10 lines
arch/m68k/mac/swim.c new file +10 -0
+		SWIMBase = NULL;
+		printk("SWIM: unknown Macintosh: report to maintainer !\n");
+		break;
+	}
+
+	if (SWIMBase == NULL)
+		return;
+
+	printk("SWIM floppy controller base at 0x%p\n", SWIMBase);
+}

The preferred way to do this these days is to create a platform device with a struct resource that points to the SWIMBase.

drivers/block/swim.c line 780

Quoted 10 lines
drivers/block/swim.c new file +7 -0
 
+static int __init swim_floppy_init(void)
+{
+	int err;
+	int drive;
+
+	if (SWIMBase == NULL)
+		return 0;

And the actual driver should become a platform driver, that is bound automatically to the platform device, if it exists.

drivers/block/swim_asm.S line 5

Quoted 9 lines

===================================================================

drivers/block/swim_asm.S new file +5 -0
@@ -0,0 +1,295 @@
+/*
+ * low-level functions for the SWIM floppy controller
+ *
+ * needs assembly language because is very timing dependent
+ * this controller exists only on macintosh 680x0 based

Do you still need this to be written in assembly?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#22 lore raw
Quoted 7 lines · Geert Uytterhoeven
Quoted 3 lines · On Sat, 1 Nov 2008, [email protected] wrote:

From: Laurent Vivier <[email protected]>

This patch is a port of the driver I wrote for kernel 2.2.

Please run scripts/checkpatch.pl on your patch and fix the errors/ warnings.

I promise, next time, I'll do.

Quoted 32 lines
Quoted 32 lines
arch/m68k/mac/swim.c new file +3 -0
+0100
@@ -0,0 +1,111 @@
+/*
+ * Driver for SWIM (Sander. Woz Integrated Machine) floppy  

controller
+ *
+ * Copyright (C) 2004,2008 Laurent Vivier <[email protected]>
+ *
+ * based on netBSD IWM driver (c) 1997, 1998 Hauke Fath.
+ * based on Alastair Bridgewater SWIM analysis, 2001
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * 2004-09-02 (lv) - Initial implementation
+ * 2008-10-30 (lv) - Port to kernel 2.6
+ */

arch/m68k/mac/swim.c new file +9 -0
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/init.h>
+#include <linux/module.h>
+
+#include <asm/macintosh.h>
+#include <asm/mac_via.h>
Quoted 8 lines

arch/m68k/mac/swim.c line 31

Quoted 6 lines
arch/m68k/mac/swim.c new file +6 -0
+
+volatile __u8 *SWIMBase;
+EXPORT_SYMBOL(SWIMBase);
+
+#define writePhase	*(SWIMBase + 0x0800)
+#define readPhase	*(SWIMBase + 0x1800)

These two definitions are not used in this file?

I remove them

Quoted 77 lines
Quoted 77 lines
arch/m68k/mac/swim.c new file +75 -0
+/*
+ * According to IWM netBSD driver, there are four kinds of SWIM:
+ *
+ * - QUADRA, QUADRA2, P580 -> SWIM base address is VIA1 + 0x1E000;
+ * - II, PB, LC		   -> SWIM base address is VIA1 + 0x16000;
+ * - IIfx, Q900, Q950	   -> managed by IOP driver
+ * - AV			   -> not managed
+ *
+ */
+
+void __init swim_init(void)
+{
+	switch(macintosh_config->ident)
+	{
+	case MAC_MODEL_Q700:
+	case MAC_MODEL_Q800:
+	case MAC_MODEL_Q650:
+	case MAC_MODEL_Q605:
+	case MAC_MODEL_Q605_ACC:
+	case MAC_MODEL_Q610:
+	case MAC_MODEL_Q630:
+	case MAC_MODEL_P475:
+	case MAC_MODEL_P475F:
+	case MAC_MODEL_P575:
+	case MAC_MODEL_P588:
+		SWIMBase =  (__u8*)(VIA1_BASE + 0x1E000);
+		break;
+	case MAC_MODEL_II:
+	case MAC_MODEL_IIX:
+	case MAC_MODEL_IICX:
+	case MAC_MODEL_SE30:
+	case MAC_MODEL_PB140:
+	case MAC_MODEL_PB145:
+	case MAC_MODEL_PB160:
+	case MAC_MODEL_PB165:
+	case MAC_MODEL_PB165C:
+	case MAC_MODEL_PB170:
+	case MAC_MODEL_PB180:
+	case MAC_MODEL_PB180C:
+	case MAC_MODEL_PB190:
+	case MAC_MODEL_PB520:
+	case MAC_MODEL_PB150:
+	case MAC_MODEL_PB210:
+	case MAC_MODEL_PB230:
+	case MAC_MODEL_PB250:
+	case MAC_MODEL_PB270C:
+	case MAC_MODEL_PB280:
+	case MAC_MODEL_PB280C:
+	case MAC_MODEL_IICI:
+	case MAC_MODEL_IISI:
+	case MAC_MODEL_IIVI:
+	case MAC_MODEL_IIVX:
+	case MAC_MODEL_P600:
+	case MAC_MODEL_P460:
+	case MAC_MODEL_P550:
+	case MAC_MODEL_TV:
+	case MAC_MODEL_LCII:
+	case MAC_MODEL_LCIII:
+	case MAC_MODEL_P520:
+	case MAC_MODEL_CLII:
+	case MAC_MODEL_CCL:
+		SWIMBase =  (__u8*)(VIA1_BASE + 0x16000);
+		break;
+	case MAC_MODEL_IIFX:
+	case MAC_MODEL_Q900:
+	case MAC_MODEL_Q950:
+		SWIMBase = NULL;
+		break;
+	default:
+		SWIMBase = NULL;
+		printk("SWIM: unknown Macintosh: report to maintainer !\n");
+		break;
+	}
+
+	if (SWIMBase == NULL)
Quoted 8 lines

arch/m68k/mac/swim.c line 111

Quoted 4 lines
arch/m68k/mac/swim.c new file +4 -0
+		return;
+
+	printk("SWIM floppy controller base at 0x%p\n", SWIMBase);
+}

The preferred way to do this these days is to create a platform device with a
struct resource that points to the SWIMBase.

Is this what Finn explains also in his answer ?
If so, I agree.

Quoted 17 lines

drivers/block/swim.c line 780

Quoted 13 lines
drivers/block/swim.c new file +8 -0
+0100
 
+static int __init swim_floppy_init(void)
+{
+	int err;
+	int drive;
+
+	if (SWIMBase == NULL)
+		return 0;

And the actual driver should become a platform driver, that is bound automatically to the platform device, if it exists.

Quoted 12 lines

drivers/block/swim_asm.S line 5

Quoted 10 lines

===================================================================

drivers/block/swim_asm.S new file +0 -0

06:14:39.000000000 +0100

drivers/block/swim_asm.S new file +5 -0
@@ -0,0 +1,295 @@
+/*
+ * low-level functions for the SWIM floppy controller
+ *
+ * needs assembly language because is very timing dependent
+ * this controller exists only on macintosh 680x0 based

Do you still need this to be written in assembly?

I don't know. But initially they were written in C and was too slow to handle data on slow macintoshes.

Thank you for your comments.

Regards,
Laurent
----------------------- Laurent Vivier ---------------------- "The best way to predict the future is to invent it."
- Alan Kay

--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#23 lore raw
Quoted 7 lines · Laurent Vivier
Quoted 3 lines · Geert Uytterhoeven

The preferred way to do this these days is to create a platform device with a
struct resource that points to the SWIMBase.

Is this what Finn explains also in his answer ?
If so, I agree.

Not exactly. What Finn suggested is to match the way we handle many of the other on-board things like ADB and SCSI. What Geert suggests is a much more recent way to do things that we generally haven't done for Mac-only drivers. I think Finn used it for the new Sonic ethernet driver because we share it with other systems. The code in macsonic.c also has the extra complexity from having both NuBus and on-board hardware to support, and NuBus also hasn't been updated to the new driver model.

Finn's suggestion of using the macintosh_config entry and data table is the easiest way to get it working, but Geert's method would move to the real device/driver model that most other systems are using now. Ideally this would be a macio driver instead of a platform driver in my opinion, but I haven't finished getting the macio bus code working on m68k.

Brad Boyer
[email protected]

--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#24 lore raw
Quoted 15 lines · Brad Boyer
Quoted 5 lines · Laurent Vivier
Quoted 2 lines · Geert Uytterhoeven

The preferred way to do this these days is to create a platform device with a struct resource that points to the SWIMBase.

Is this what Finn explains also in his answer ? If so, I agree.

Not exactly. What Finn suggested is to match the way we handle many of the other on-board things like ADB and SCSI. What Geert suggests is a much more recent way to do things that we generally haven't done for Mac-only drivers. I think Finn used it for the new Sonic ethernet driver because we share it with other systems. The code in macsonic.c also has the extra complexity from having both NuBus and on-board hardware to support, and NuBus also hasn't been updated to the new driver model.

Quoted 3 lines

Finn's suggestion of using the macintosh_config entry and data table is the easiest way to get it working, but Geert's method would move to the real device/driver model that most other systems are using now.

I agree with Geert. Ignore my comment about device_initcall -- I was looking at via-cuda.c but that is not a good example. drivers/scsi/mac_esp.c is a better example.

esp_mac_probe checks the macintosh_config entry. That and esp_mac_remove are the platform device entry points Geert referred to. The module entry points are mac_esp_init and mac_esp_exit. I think you could use either of the platform device probe routine or the module init routine to set the base address.

Finn

Quoted 12 lines

Ideally this would be a macio driver instead of a platform driver in my opinion, but I haven't finished getting the macio bus code working on m68k.

Brad Boyer
[email protected]

--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#25 lore raw
Quoted 32 lines · Finn Thain
Quoted 18 lines · Brad Boyer
Quoted 5 lines · Laurent Vivier
Quoted 2 lines · Geert Uytterhoeven

The preferred way to do this these days is to create a platform device with a struct resource that points to the SWIMBase.

Is this what Finn explains also in his answer ? If so, I agree.

Not exactly. What Finn suggested is to match the way we handle many of
the other on-board things like ADB and SCSI. What Geert suggests is a much more recent way to do things that we generally haven't done for Mac-only drivers. I think Finn used it for the new Sonic ethernet driver
because we share it with other systems. The code in macsonic.c also has
the extra complexity from having both NuBus and on-board hardware to support, and NuBus also hasn't been updated to the new driver model.

Quoted 5 lines

Finn's suggestion of using the macintosh_config entry and data table is
the easiest way to get it working, but Geert's method would move to the
real device/driver model that most other systems are using now.

I agree with Geert. Ignore my comment about device_initcall -- I was looking at via-cuda.c but that is not a good example. drivers/scsi/mac_esp.c is a better example.

Quoted 9 lines

esp_mac_probe checks the macintosh_config entry. That and esp_mac_remove
are the platform device entry points Geert referred to. The module entry
points are mac_esp_init and mac_esp_exit. I think you could use either of
the platform device probe routine or the module init routine to set the
base address.

Ok, thank you for this detailled explanation. Now, I understand better what I have to do.

Regards,
Laurent
----------------------- Laurent Vivier ---------------------- "The best way to predict the future is to invent it."
- Alan Kay

--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#26 lore raw
In reply to Finn Thain
Quoted 24 lines · Finn Thain
Quoted 15 lines · Brad Boyer
Quoted 5 lines · Laurent Vivier

Le 2 nov. 08 � 09:54, Geert Uytterhoeven a �crit :

Quoted 2 lines

The preferred way to do this these days is to create a platform device with a struct resource that points to the SWIMBase.

Is this what Finn explains also in his answer ? If so, I agree.

Not exactly. What Finn suggested is to match the way we handle many of the other on-board things like ADB and SCSI. What Geert suggests is a much more recent way to do things that we generally haven't done for Mac-only drivers. I think Finn used it for the new Sonic ethernet driver because we share it with other systems. The code in macsonic.c also has the extra complexity from having both NuBus and on-board hardware to support, and NuBus also hasn't been updated to the new driver model.

Quoted 3 lines

Finn's suggestion of using the macintosh_config entry and data table is the easiest way to get it working, but Geert's method would move to the real device/driver model that most other systems are using now.

I agree with Geert. Ignore my comment about device_initcall -- I was looking at via-cuda.c but that is not a good example. drivers/scsi/mac_esp.c is a better example.

Quoted 5 lines

esp_mac_probe checks the macintosh_config entry. That and esp_mac_remove are the platform device entry points Geert referred to. The module entry points are mac_esp_init and mac_esp_exit. I think you could use either of the platform device probe routine or the module init routine to set the base address.

Ideally, the _probe() routine should not look at the bits in macintosh_config, but only at the platform device and its resources.

The creation of the platform device should be moved to arch/m68k/mac/config, which would create the platform device, and only if the bits in macintosh_config indicate that the hardware is present. The actual value of swim_base can be stored in a struct resource linked to the platform device.

So far the only platform device for m68k (not in mainline) is Michael's EtherNAT driver, cfr. arch/m68k/atari/config.c. Note that that one registers the platform device unconditionally, as there's no magic predictor for its presence in the firmware or machine tables.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#27 lore raw
Quoted 53 lines · Geert Uytterhoeven
Quoted 30 lines · Finn Thain
Quoted 19 lines · Brad Boyer
Quoted 5 lines · Laurent Vivier
Quoted 2 lines · Geert Uytterhoeven

The preferred way to do this these days is to create a platform device with a struct resource that points to the SWIMBase.

Is this what Finn explains also in his answer ? If so, I agree.

Not exactly. What Finn suggested is to match the way we handle many of
the other on-board things like ADB and SCSI. What Geert suggests is a
much more recent way to do things that we generally haven't done for Mac-only drivers. I think Finn used it for the new Sonic ethernet driver
because we share it with other systems. The code in macsonic.c also has
the extra complexity from having both NuBus and on-board hardware to support, and NuBus also hasn't been updated to the new driver model.

Quoted 5 lines

Finn's suggestion of using the macintosh_config entry and data table is
the easiest way to get it working, but Geert's method would move to the
real device/driver model that most other systems are using now.

I agree with Geert. Ignore my comment about device_initcall -- I was looking at via-cuda.c but that is not a good example. drivers/scsi/mac_esp.c is a better example.

Quoted 9 lines

esp_mac_probe checks the macintosh_config entry. That and esp_mac_remove
are the platform device entry points Geert referred to. The module entry
points are mac_esp_init and mac_esp_exit. I think you could use either of
the platform device probe routine or the module init routine to set the
base address.

Ideally, the _probe() routine should not look at the bits in macintosh_config,
but only at the platform device and its resources.

The creation of the platform device should be moved to arch/m68k/mac/ config,
which would create the platform device, and only if the bits in macintosh_config indicate that the hardware is present. The actual value of
swim_base can be stored in a struct resource linked to the platform device.

Quoted 7 lines

So far the only platform device for m68k (not in mainline) is Michael's
EtherNAT driver, cfr. arch/m68k/atari/config.c. Note that that one registers
the platform device unconditionally, as there's no magic predictor for its
presence in the firmware or machine tables.

OK, I'll copy what is done for ethernat driver.
Thank you for the explanation.

Laurent
----------------------- Laurent Vivier ---------------------- "The best way to predict the future is to invent it."
- Alan Kay

--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#28 lore raw
In reply to Geert Uytterhoeven

Hi,

Quoted 4 lines

So far the only platform device for m68k (not in mainline) is Michael's EtherNAT driver, cfr. arch/m68k/atari/config.c. Note that that one registers the platform device unconditionally, as there's no magic predictor for its presence in the firmware or machine tables.

There's no magic predictor, but as I know what address to poke in order to probe for a potential EtherNAT, the device register could be conditionalized (and the hwreg_present() call removed from the driver). As soon as I have untangled myself from the SCSI code, and the intricacies of building Debian kernel images :-(

Michael

#29 lore raw
In reply to Geert Uytterhoeven
Quoted 6 lines · Geert Uytterhoeven
Quoted 5 lines · Finn Thain

I agree with Geert. Ignore my comment about device_initcall -- I was looking at via-cuda.c but that is not a good example. drivers/scsi/mac_esp.c is a better example.

Quoted 8 lines
Quoted 5 lines

esp_mac_probe checks the macintosh_config entry. That and esp_mac_remove are the platform device entry points Geert referred to. The module entry points are mac_esp_init and mac_esp_exit. I think you could use either of the platform device probe routine or the module init routine to set the base address.

Ideally, the _probe() routine should not look at the bits in macintosh_config, but only at the platform device and its resources.

Makes sense.

Quoted 2 lines

The creation of the platform device should be moved to arch/m68k/mac/config

That means adding #if CONFIG_BLK_DEV_SWIM to config.c.

It also makes drivers/block/swim.c less cohesive.

Quoted 4 lines

which would create the platform device, and only if the bits in macintosh_config indicate that the hardware is present. The actual value of swim_base can be stored in a struct resource linked to the platform device.

I'm probably missing something here, but I can see some benefit in doing this only in the absence of a global macintosh_config.

But if you didn't have a global macintosh_config, several parts of macintosh_config (especially macintosh_config->ident) would end up duplicated in each of the struct resources for the platform devices, no?

Would you explain it is we gain from moving platform init routines into config.c? I can only see disadvantages.

Finn

Quoted 9 lines

So far the only platform device for m68k (not in mainline) is Michael's EtherNAT driver, cfr. arch/m68k/atari/config.c. Note that that one registers the platform device unconditionally, as there's no magic predictor for its presence in the firmware or machine tables.

Gr{oetje,eeting}s,

Geert

#30 lore raw
Quoted 15 lines · Finn Thain
Quoted 5 lines · Geert Uytterhoeven
Quoted 4 lines · Finn Thain

I agree with Geert. Ignore my comment about device_initcall -- I was looking at via-cuda.c but that is not a good example. drivers/scsi/mac_esp.c is a better example.

Quoted 8 lines
Quoted 5 lines

esp_mac_probe checks the macintosh_config entry. That and esp_mac_remove are the platform device entry points Geert referred to. The module entry points are mac_esp_init and mac_esp_exit. I think you could use either of the platform device probe routine or the module init routine to set the base address.

Ideally, the _probe() routine should not look at the bits in macintosh_config, but only at the platform device and its resources.

Quoted 6 lines

Makes sense.

Quoted 2 lines

The creation of the platform device should be moved to arch/m68k/mac/config

That means adding #if CONFIG_BLK_DEV_SWIM to config.c.

No, its creation code should not depend on any config option (except CONFIG_MAC :-). This means the platform device will always be created when the physical hardware is present.

Quoted 1 line

It also makes drivers/block/swim.c less cohesive.

When the device framework was introduced, platform devices and platform drivers were handled in the driver (source file) itself. Later it was realized this was actually a mistake, and the platform devices and platform drivers were separated.

Quoted 11 lines
Quoted 4 lines

which would create the platform device, and only if the bits in macintosh_config indicate that the hardware is present. The actual value of swim_base can be stored in a struct resource linked to the platform device.

I'm probably missing something here, but I can see some benefit in doing this only in the absence of a global macintosh_config.

But if you didn't have a global macintosh_config, several parts of macintosh_config (especially macintosh_config->ident) would end up duplicated in each of the struct resources for the platform devices, no?

You need some logic to device whether to create a platform device or not. On Mac, the logical way is to look in the macintosh_config table.

On Amiga, you would use

    if (AMIGAHW_PRESENT(AMI_XXX))
	platform_device_register{,_simple}(...);

Converting the existing Amiga drivers is somewhere on my todo-list (since a just way too long time)...

Quoted 2 lines

Would you explain it is we gain from moving platform init routines into config.c? I can only see disadvantages.

The device framework is the recommended way to handle devices and drivers across all Linux platforms.

All existing platform devices show up under /sys/devices/platform/. Based on this information, the device entry in /dev can be created automatically, and the corresponding platform driver loadable kernel modules can be loaded automatically.

E.g. you no longer have to specify in /etc/modules.conf which floppy driver to load. Currently you have to choose one of:

alias block-major-2 amiflop
alias block-major-2 ataflop
alias block-major-2 swim3

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#31 lore raw
Quoted 18 lines · Geert Uytterhoeven
Quoted 17 lines · Finn Thain
Quoted 5 lines · Geert Uytterhoeven
Quoted 4 lines · Finn Thain

I agree with Geert. Ignore my comment about device_initcall -- I was looking at via-cuda.c but that is not a good example. drivers/scsi/mac_esp.c is a better example.

Quoted 8 lines
Quoted 5 lines

esp_mac_probe checks the macintosh_config entry. That and esp_mac_remove are the platform device entry points Geert referred to. The module entry points are mac_esp_init and mac_esp_exit. I think you could use either of the platform device probe routine or the module init routine to set the base address.

Ideally, the _probe() routine should not look at the bits in macintosh_config, but only at the platform device and its resources.

Makes sense.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

The creation of the platform device should be moved to arch/m68k/mac/config

That means adding #if CONFIG_BLK_DEV_SWIM to config.c.

No, its creation code should not depend on any config option (except CONFIG_MAC :-). This means the platform device will always be created when the physical hardware is present.

So we create a global platform device pointer for every possible mac device regardless of whether they're enabled in Kconfig or not?

(Not that I'm not going to complain about a few bytes if the benefit outweighs the disadvantages. I'm just trying to understand both.)

Quoted 6 lines
Quoted 1 line

It also makes drivers/block/swim.c less cohesive.

When the device framework was introduced, platform devices and platform drivers were handled in the driver (source file) itself. Later it was realized this was actually a mistake, and the platform devices and platform drivers were separated.

I've heard that "mistake" mentioned before, but I've never heard an explanation (i.e. why this might be a problem for say, macmace, mac_sonic or mac_esp -- or swim).

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

which would create the platform device, and only if the bits in macintosh_config indicate that the hardware is present. The actual value of swim_base can be stored in a struct resource linked to the platform device.

I'm probably missing something here, but I can see some benefit in doing this only in the absence of a global macintosh_config.

Quoted 7 lines
Quoted 4 lines

But if you didn't have a global macintosh_config, several parts of macintosh_config (especially macintosh_config->ident) would end up duplicated in each of the struct resources for the platform devices, no?

You need some logic to device whether to create a platform device or not. On Mac, the logical way is to look in the macintosh_config table.

Well, I can some the benefit as long as that logic doesn't leak out of config.c, as it does now.

Quoted 7 lines

On Amiga, you would use

    if (AMIGAHW_PRESENT(AMI_XXX))
	platform_device_register{,_simple}(...);

Converting the existing Amiga drivers is somewhere on my todo-list (since a just way too long time)...

I guess there must be an example somewhere I can look at to try to understand this?

Quoted 11 lines
Quoted 2 lines

Would you explain it is we gain from moving platform init routines into config.c? I can only see disadvantages.

The device framework is the recommended way to handle devices and drivers across all Linux platforms.

All existing platform devices show up under /sys/devices/platform/. Based on this information, the device entry in /dev can be created automatically, and the corresponding platform driver loadable kernel modules can be loaded automatically.

Quoted 6 lines

E.g. you no longer have to specify in /etc/modules.conf which floppy driver to load. Currently you have to choose one of:

alias block-major-2 amiflop
alias block-major-2 ataflop
alias block-major-2 swim3

Fair enough, but doesn't the patch you objected to already do that?

Finn

Quoted 11 lines

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#32 lore raw
Quoted 22 lines · Finn Thain
Quoted 21 lines · Geert Uytterhoeven
Quoted 20 lines · Finn Thain
Quoted 5 lines · Geert Uytterhoeven
Quoted 4 lines · Finn Thain

I agree with Geert. Ignore my comment about device_initcall -- I was looking at via-cuda.c but that is not a good example. drivers/scsi/mac_esp.c is a better example.

Quoted 8 lines
Quoted 5 lines

esp_mac_probe checks the macintosh_config entry. That and esp_mac_remove are the platform device entry points Geert referred to. The module entry points are mac_esp_init and mac_esp_exit. I think you could use either of the platform device probe routine or the module init routine to set the base address.

Ideally, the _probe() routine should not look at the bits in macintosh_config, but only at the platform device and its resources.

Makes sense.

Quoted 2 lines

The creation of the platform device should be moved to arch/m68k/mac/config

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

That means adding #if CONFIG_BLK_DEV_SWIM to config.c.

No, its creation code should not depend on any config option (except CONFIG_MAC :-). This means the platform device will always be created when the physical hardware is present.

So we create a global platform device pointer for every possible mac device regardless of whether they're enabled in Kconfig or not?

What do you mean by `global'? I hope not global variable.

Quoted 5 lines

(Not that I'm not going to complain about a few bytes if the benefit outweighs the disadvantages. I'm just trying to understand both.)

Quoted 2 lines
Quoted 1 line

It also makes drivers/block/swim.c less cohesive.

Quoted 8 lines
Quoted 4 lines

When the device framework was introduced, platform devices and platform drivers were handled in the driver (source file) itself. Later it was realized this was actually a mistake, and the platform devices and platform drivers were separated.

I've heard that "mistake" mentioned before, but I've never heard an explanation (i.e. why this might be a problem for say, macmace, mac_sonic or mac_esp -- or swim).

It doesn't give you much (any?) benefit compared to the old pre-platform device scheme. As the platform device is created in the driver source, it's not created before the actual driver module is loaded. Hence no autoloading based on sysfs, as there's no sysfs entry before the driver has been loaded.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

which would create the platform device, and only if the bits in macintosh_config indicate that the hardware is present. The actual value of swim_base can be stored in a struct resource linked to the platform device.

I'm probably missing something here, but I can see some benefit in doing this only in the absence of a global macintosh_config.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

But if you didn't have a global macintosh_config, several parts of macintosh_config (especially macintosh_config->ident) would end up duplicated in each of the struct resources for the platform devices, no?

You need some logic to device whether to create a platform device or

                           ^^^^^^
			   sorry, decide
Quoted 7 lines
Quoted 1 line

not. On Mac, the logical way is to look in the macintosh_config table.

Well, I can some the benefit as long as that logic doesn't leak out of config.c, as it does now.

Quoted 2 lines

On Amiga, you would use

Quoted 8 lines
Quoted 5 lines
    if (AMIGAHW_PRESENT(AMI_XXX))
	platform_device_register{,_simple}(...);

Converting the existing Amiga drivers is somewhere on my todo-list (since a just way too long time)...

I guess there must be an example somewhere I can look at to try to understand this?

`git grep platform_device_register arch/{arm,mips}' can give lots of examples. The creation of those platform devices is handled under arch/, while the actual platform drivers are under drivers/.

Quoted 11 lines
Quoted 11 lines
Quoted 2 lines

Would you explain it is we gain from moving platform init routines into config.c? I can only see disadvantages.

The device framework is the recommended way to handle devices and drivers across all Linux platforms.

All existing platform devices show up under /sys/devices/platform/. Based on this information, the device entry in /dev can be created automatically, and the corresponding platform driver loadable kernel modules can be loaded automatically.

Quoted 8 lines
Quoted 6 lines

E.g. you no longer have to specify in /etc/modules.conf which floppy driver to load. Currently you have to choose one of:

alias block-major-2 amiflop
alias block-major-2 ataflop
alias block-major-2 swim3

Fair enough, but doesn't the patch you objected to already do that?

It doesn't handle the module alias problem, as the platform device is created by the driver module.

BTW, `objecting' is a bit harsh: I added Laurent's driver to my m68k tree anyway. But getting it into mainline is a different thing. People already complained about our still existing combined platform device/driver drivers last time I just fixed a minor bug.

So new drivers should adhere to the `right' platform driver framework.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds