Skip to contentSkip to conversation

Initial commit for Sony MemoryStick support

PATCH In review [email protected] 4 participants 8 messages Dec 24, 2007 – Dec 31, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Initial commit for Sony MemoryStick support

From: Alex Dubov <[email protected]>

Sony MemoryStick cards are used in many products manufactured by Sony. They are available both as storage and as IO expansion cards. Currently, only MemoryStick Pro storage cards are supported via TI FlashMedia MemoryStick interface.

---
 MAINTAINERS                         |    7 +
 drivers/Kconfig                     |    2 +
 drivers/Makefile                    |    1 +
 drivers/memstick/Kconfig            |   26 +
 drivers/memstick/Makefile           |   11 +
 drivers/memstick/core/Kconfig       |   26 +
 drivers/memstick/core/Makefile      |   11 +
 drivers/memstick/core/memstick.c    |  557 ++++++++++++++
 drivers/memstick/core/mspro_block.c | 1376 +++++++++++++++++++++++++++++++++++
 drivers/memstick/host/Kconfig       |   22 +
 drivers/memstick/host/Makefile      |   10 +
 drivers/memstick/host/tifm_ms.c     |  681 +++++++++++++++++
 drivers/misc/tifm_7xx1.c            |   17 +
 drivers/misc/tifm_core.c            |    7 +
 include/linux/memstick.h            |  286 ++++++++
 include/linux/tifm.h                |    4 +
 16 files changed, 3044 insertions(+), 0 deletions(-)
 create mode 100644 drivers/memstick/Kconfig
 create mode 100644 drivers/memstick/Makefile
 create mode 100644 drivers/memstick/core/Kconfig
 create mode 100644 drivers/memstick/core/Makefile
 create mode 100644 drivers/memstick/core/memstick.c
 create mode 100644 drivers/memstick/core/mspro_block.c
 create mode 100644 drivers/memstick/host/Kconfig
 create mode 100644 drivers/memstick/host/Makefile
 create mode 100644 drivers/memstick/host/tifm_ms.c
 create mode 100644 include/linux/memstick.h
MAINTAINERS +7 -0
index 3d567fd..16a4ab6 100644
@@ -3505,6 +3505,13 @@ L:	[email protected]
 W:	http://www.linux.it/~malattia/wiki/index.php/Sony_drivers
 S:	Maintained
 
+SONY MEMORYSTICK CARD SUPPORT
+P:	Alex Dubov
+M:	[email protected]
+L:	[email protected]
+W:	http://tifmxx.berlios.de/
+S:	Maintained
+
 SOUND
 P:	Jaroslav Kysela
 M:	[email protected]
drivers/Kconfig +2 -0
index f4076d9..dbb6a44 100644
@@ -76,6 +76,8 @@ source "drivers/usb/Kconfig"
 
 source "drivers/mmc/Kconfig"
 
+source "drivers/memstick/Kconfig"
+
 source "drivers/leds/Kconfig"
 
 source "drivers/infiniband/Kconfig"
drivers/Makefile +1 -0
index 8cb37e3..d89f2cf 100644
@@ -77,6 +77,7 @@ obj-$(CONFIG_LGUEST_GUEST)	+= lguest/
 obj-$(CONFIG_CPU_FREQ)		+= cpufreq/
 obj-$(CONFIG_CPU_IDLE)		+= cpuidle/
 obj-$(CONFIG_MMC)		+= mmc/
+obj-$(CONFIG_MEMSTICK)		+= memstick/
 obj-$(CONFIG_NEW_LEDS)		+= leds/
 obj-$(CONFIG_INFINIBAND)	+= infiniband/
 obj-$(CONFIG_SGI_SN)		+= sn/
drivers/memstick/Kconfig new file +26 -0
new file mode 100644
index 0000000..1093fdb
@@ -0,0 +1,26 @@
+#
+# MemoryStick subsystem configuration
+#
+
+menuconfig MEMSTICK
+	tristate "Sony MemoryStick card support (EXPERIMENTAL)"
+	help
+	  Sony MemoryStick is a proprietary storage/extension card protocol.
+
+	  If you want MemoryStick support, you should say Y here and also
+	  to the specific driver for your MMC interface.
+
+if MEMSTICK
+
+config MEMSTICK_DEBUG
+	bool "MemoryStick debugging"
+	help
+	  This is an option for use by developers; most people should
+	  say N here.  This enables MemoryStick core and driver debugging.
+
+
+source "drivers/memstick/core/Kconfig"
+
+source "drivers/memstick/host/Kconfig"
+
+endif # MEMSTICK
drivers/memstick/Makefile new file +11 -0
new file mode 100644
index 0000000..dc160fb
@@ -0,0 +1,11 @@
+#
+# Makefile for the kernel MemoryStick device drivers.
+#
+
+ifeq ($(CONFIG_MEMSTICK_DEBUG),y)
+	EXTRA_CFLAGS		+= -DDEBUG
+endif
+
+obj-$(CONFIG_MEMSTICK)		+= core/
+obj-$(CONFIG_MEMSTICK)		+= host/
+
drivers/memstick/core/Kconfig new file +26 -0
new file mode 100644
index 0000000..95f1814
@@ -0,0 +1,26 @@
+#
+# MemoryStick core configuration
+#
+
+comment "MemoryStick drivers"
+
+config MEMSTICK_UNSAFE_RESUME
+        bool "Allow unsafe resume (DANGEROUS)"
+        help
+          If you say Y here, the MemoryStick layer will assume that all
+          cards stayed in their respective slots during the suspend. The
+          normal behaviour is to remove them at suspend and
+          redetecting them at resume. Breaking this assumption will
+          in most cases result in data corruption.
+
+          This option is usually just for embedded systems which use
+          a MemoryStick card for rootfs. Most people should say N here.
+
+config MSPRO_BLOCK
+	tristate "MemoryStick Pro block device driver"
+	depends on BLOCK
+	help
+	  Say Y here to enable the MemoryStick Pro block device driver
+	  support. This provides a block device driver, which you can use
+	  to mount the filesystem. Almost everyone wishing MemoryStick
+	  support should say Y or M here.
drivers/memstick/core/Makefile new file +11 -0
new file mode 100644
index 0000000..8b2b529
@@ -0,0 +1,11 @@
+#
+# Makefile for the kernel MemoryStick core.
+#
+
+ifeq ($(CONFIG_MEMSTICK_DEBUG),y)
+	EXTRA_CFLAGS		+= -DDEBUG
+endif
+
+obj-$(CONFIG_MEMSTICK)		+= memstick.o
+
+obj-$(CONFIG_MSPRO_BLOCK)	+= mspro_block.o
drivers/memstick/core/memstick.c new file +557 -0

557 lines not on this page · raw message

drivers/memstick/core/mspro_block.c new file +1376 -0

1,376 lines not on this page · raw message

drivers/memstick/host/Kconfig new file +22 -0
new file mode 100644
index 0000000..c002fcc
@@ -0,0 +1,22 @@
+#
+# MemoryStick host controller drivers
+#
+
+comment "MemoryStick Host Controller Drivers"
+
+config MEMSTICK_TIFM_MS
+	tristate "TI Flash Media MemoryStick Interface support  (EXPERIMENTAL)"
+	depends on EXPERIMENTAL && PCI
+	select TIFM_CORE
+	help
+	  Say Y here if you want to be able to access MemoryStick cards with
+	  the Texas Instruments(R) Flash Media card reader, found in many
+	  laptops.
+	  This option 'selects' (turns on, enables) 'TIFM_CORE', but you
+	  probably also need appropriate card reader host adapter, such as
+	  'Misc devices: TI Flash Media PCI74xx/PCI76xx host adapter support
+	  (TIFM_7XX1)'.
+
+          To compile this driver as a module, choose M here: the
+	  module will be called tifm_ms.
+
drivers/memstick/host/Makefile new file +10 -0
new file mode 100644
index 0000000..ee66638
@@ -0,0 +1,10 @@
+#
+# Makefile for MemoryStick host controller drivers
+#
+
+ifeq ($(CONFIG_MEMSTICK_DEBUG),y)
+	EXTRA_CFLAGS		+= -DDEBUG
+endif
+
+obj-$(CONFIG_MEMSTICK_TIFM_MS)	+= tifm_ms.o
+
drivers/memstick/host/tifm_ms.c new file +681 -0

681 lines not on this page · raw message

drivers/misc/tifm_7xx1.c +17 -0
index 2d1b3df..2f0f593 100644
@@ -302,6 +302,21 @@ static int tifm_7xx1_resume(struct pci_dev *dev)
 
 #endif /* CONFIG_PM */
 
+static int tifm_7xx1_dummy_has_ms_pif(struct tifm_adapter *fm,
+				      struct tifm_dev *sock)
+{
+	return 0;
+}
+
+static int tifm_7xx1_has_ms_pif(struct tifm_adapter *fm, struct tifm_dev *sock)
+{
+	if (((fm->num_sockets == 4) && (sock->socket_id == 2))
+	    || ((fm->num_sockets == 2) && (sock->socket_id == 0)))
+		return 1;
+
+	return 0;
+}
+
 static int tifm_7xx1_probe(struct pci_dev *dev,
 			   const struct pci_device_id *dev_id)
 {
@@ -336,6 +351,7 @@ static int tifm_7xx1_probe(struct pci_dev *dev,
 
 	INIT_WORK(&fm->media_switcher, tifm_7xx1_switch_media);
 	fm->eject = tifm_7xx1_eject;
+	fm->has_ms_pif = tifm_7xx1_has_ms_pif;
 	pci_set_drvdata(dev, fm);
 
 	fm->addr = ioremap(pci_resource_start(dev, 0),
@@ -377,6 +393,7 @@ static void tifm_7xx1_remove(struct pci_dev *dev)
 	int cnt;
 
 	fm->eject = tifm_7xx1_dummy_eject;
+	fm->has_ms_pif = tifm_7xx1_dummy_has_ms_pif;
 	writel(TIFM_IRQ_SETALL, fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
 	mmiowb();
 	free_irq(dev->irq, fm);
drivers/misc/tifm_core.c +7 -0
index 8f77949..ca63452 100644
@@ -284,6 +284,13 @@ void tifm_eject(struct tifm_dev *sock)
 }
 EXPORT_SYMBOL(tifm_eject);
 
+int tifm_has_ms_pif(struct tifm_dev *sock)
+{
+	struct tifm_adapter *fm = dev_get_drvdata(sock->dev.parent);
+	return fm->has_ms_pif(fm, sock);
+}
+EXPORT_SYMBOL(tifm_has_ms_pif);
+
 int tifm_map_sg(struct tifm_dev *sock, struct scatterlist *sg, int nents,
 		int direction)
 {
include/linux/memstick.h new file +286 -0

204 lines not on this page · raw message

include/linux/tifm.h +4 -0
index 6b3a318..46672c6 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.5.3.6

Part of the diff is not shown here. View the raw message.

Tested-by on v1 1/1
#1 lore raw

Mostly just stylistic comments from me here.

Quoted 8 lines · On Monday 24 December 2007 03:06:37 [email protected] wrote:

From: Alex Dubov <[email protected]>

Sony MemoryStick cards are used in many products manufactured by Sony. They are available both as storage and as IO expansion cards. Currently, only MemoryStick Pro storage cards are supported via TI FlashMedia MemoryStick interface.

For MemoryStick Pro on my TI7421 card reader (since my old MemoryStick card and camera have disappeared somewhere, so I cannot currently test that):

However, my only concerns are that:

1) tifm_ms was not autoloaded
2) On loading tifm_ms, only memstick was autoloaded - mspro_block was not.

Although, whether this is an issue with userspace (ie. udev) not dealing with the modules properly, I don't know.

drivers/memstick/core/memstick.c line 2

Quoted 5 lines
drivers/memstick/core/memstick.c new file +2 -0
@@ -0,0 +1,557 @@
+/*
+ *  memstick.c - Sony MemoryStick support

File names in comments are now frowned upon - there was a thread on this in October on LKML:

http://lkml.org/lkml/2007/10/12/524

Also, before Andrew gets in with this - you should run this through checkpatch, as there are a few errors it throws up (mostly foo* and C99 comments).

-Carlos

Signature · 3 lines
E-Mail: [email protected]
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D
#2 lore raw
Quoted 7 lines · Carlos Corbacho
Quoted 6 lines · On Monday 24 December 2007 03:06:37 [email protected] wrote:

From: Alex Dubov <[email protected]>

Sony MemoryStick cards are used in many products manufactured by Sony. They are available both as storage and as IO expansion cards. Currently, only MemoryStick Pro storage cards are supported via TI FlashMedia MemoryStick interface.

Actually... my MS slot on PCG-U3 is recognized through usb_storage.

#3 lore raw
Quoted 10 lines · On Monday 31 December 2007 00:31:12 Jan Engelhardt wrote:
Quoted 7 lines · Carlos Corbacho
Quoted 6 lines · On Monday 24 December 2007 03:06:37 [email protected] wrote:

From: Alex Dubov <[email protected]>

Sony MemoryStick cards are used in many products manufactured by Sony. They are available both as storage and as IO expansion cards. Currently, only MemoryStick Pro storage cards are supported via TI FlashMedia MemoryStick interface.

Actually... my MS slot on PCG-U3 is recognized through usb_storage.

Then consider yourself very lucky - some laptop manufacturers play nice and the card reader identifies itself, and works as, a USB mass storage device; so it works out of the box with no extra drivers needed for either the card reader, or the flash memory card.

The Texas Instruments chip/ card reader that Alex's work here is currently aimed at does not - it has a completely proprietary, so called "FlashMedia" chip/ interface that talks to MMC/ SD, MemoryStick (/ Pro), and SmartMedia/ xD cards, of which TI have refused to release any specs.

Yes, this chip doesn't even use sdhci for communicating with MMC/ SD cards - tifm_sd (Alex's previous work on the MMC/ SD front for this TI chip) handles that.

MemoryStick support is more complicated in this case than MMC/ SD, given that on top of TI refusing to release specs for their own FlashMedia chips, Sony will also not release any specs on MemoryStick cards; the same is also true of xD with Olympus and Fuji.

-Carlos

Signature · 3 lines
E-Mail: [email protected]
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D
maintainer
#4 lore raw
In reply to Jan Engelhardt
Quoted 12 lines · --- Jan Engelhardt
Quoted 7 lines · Carlos Corbacho
Quoted 6 lines · On Monday 24 December 2007 03:06:37 [email protected] wrote:

From: Alex Dubov <[email protected]>

Sony MemoryStick cards are used in many products manufactured by Sony. They are available both as storage and as IO expansion cards. Currently, only MemoryStick Pro storage cards are supported via TI FlashMedia MemoryStick interface.

Actually... my MS slot on PCG-U3 is recognized through usb_storage.

USB storage type controllers have firmware that translates native MS protocol into USB storage (scsi-like) one. We are talking here about native protocol support, needed for dumb controllers.

      ____________________________________________________________________________________

Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping

maintainer
#5 lore raw
In reply to Carlos Corbacho
Quoted 8 lines

However, my only concerns are that:

1) tifm_ms was not autoloaded
2) On loading tifm_ms, only memstick was autoloaded - mspro_block was not.

Although, whether this is an issue with userspace (ie. udev) not dealing with the modules properly, I don't know.

This is exactly the same as with tifm_sd module if you noticed.

First, there are no modaliases for tifm (I was thinking to add them later, when at least two card types are supported, if at all), so the appropriate udev rule should be added (similar to the sd one).

Second, it is impossible to guess in advance, which type of card is put into slot (Pro, legacy or IO of either sort). Same as mmc_block, actually. The only way to get it autoloaded, is, again, with appropriate udev rule (uevent is emitted when card type is detected).

      ____________________________________________________________________________________

Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping

#6 lore raw
Quoted 1 line · On Monday 31 December 2007 01:01:08 Alex Dubov wrote:

This is exactly the same as with tifm_sd module if you noticed.

Unfortunately not, I've really never used tifm_sd as I don't have any MMC/ SD cards.

Quoted 2 lines

Second, it is impossible to guess in advance, which type of card is put into slot (Pro, legacy or IO of either sort).

I imagined this to be the case.

Quoted 3 lines

Same as mmc_block, actually.
The only way to get it autoloaded, is, again, with appropriate udev rule (uevent is emitted when card type is detected).

So do we require changes to the userspace udev rules here, or just some use of modalias in the drivers?

-Carlos

Signature · 3 lines
E-Mail: [email protected]
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D
maintainer
#7 lore raw
Quoted 4 lines · --- Carlos Corbacho

So do we require changes to the userspace udev rules here, or just some use of modalias in the drivers?

It was handled by whoever manages the distro's udev rules until now. Here's the example:

https://lists.ubuntu.com/archives/ubuntu-patches/2007-September/012537.html

      ____________________________________________________________________________________

Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs