Update of /cvsroot/linuxdc/linux-sh-dc/drivers/mtd/maps
In directory usw-pr-cvs1:/tmp/cvs-serv8706/drivers/mtd/maps
Modified Files:
vmu-flash.c
Log Message:
Further updates to VMU Flash driver
Index: vmu-flash.c
===================================================================
RCS file: /cvsroot/linuxdc/linux-sh-dc/drivers/mtd/maps/vmu-flash.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- vmu-flash.c 28 Aug 2002 00:02:53 -0000 1.4
+++ vmu-flash.c 30 Aug 2002 23:31:52 -0000 1.5
@@ -26,16 +26,29 @@
#define VMU_BLOCK_SIZE 0x200 /* Standard VMU block is 512 bytes */
/* Maple Device */
-static struct maple_device *vmu_flash_mdev __initdata = NULL;
+struct maple_device *vmu_flash_mdev __initdata = NULL;
/* MTD Information */
-static struct mtd_info *vmu_flash_mtd = NULL;
+struct mtd_info *vmu_flash_mtd = NULL;
+
+/* Instance variables - not statics */
+struct mapleq *lastmq;
+struct maple_driver dc_flashmap_driver;
+
+int flash_queried = 0;
-/* Persistent result */
-static struct mapleq *lastmq;
-static struct maple_driver dc_flashmap_driver;
char *block_buffer = NULL;
-int waken_up = 1;
+/* Memory card details */
+typedef struct memcard_s {
+ long partitions;
+ long blocks;
+ long writecnt;
+ long readcnt;
+ long removable;
+} memcard_t;
+
+
+
/* VMU Block */
typedef struct block_s {
@@ -417,8 +430,22 @@
static void dc_flashmap_callback(struct maple_driver_data *data)
{
-
struct mapleq *mq = &data->mq;
+
+ if (flash_queried == 0) {
+ if (mq->recvbuf[0] == 5) {
+ int res = mq->recvbuf[0];
+
+ lastmq = mq;
+ flash_queried = 1;
+ wake_up_interruptible(&wq_mq); /* Wake sleeping code */
+ return;
+ }
+ }
+
+
+
+
if (mq->recvbuf[0] == 8) {
/* int res = mq->recvbuf[0];
@@ -453,7 +480,58 @@
{
printk
("Registering VMU Flash mapping and loading VMU Flash driver\n");
- /* Look for the flash */
+
+ /* What are the characteristics of the flash we have? */
+
+
+ struct mapleq *mqu = (struct mapleq *) &(d->mq);
+ mqu->command = 1;
+ mqu->length = 0;
+
+
+ mqu->sendbuf = mqu->recvbuf;
+ if (maple_add_packet(mqu) != 0) {
+ printk(KERN_WARNING
+ "VMU FLASH: Could not add packet to query device\n");
+ return -1;
+ }
+
+ lastmq = NULL;
+
+ do {
+ interruptible_sleep_on_timeout(&wq_mq, 1);
+ } while (lastmq == NULL);
+
+
+ /* Read off the flash data */
+ unsigned long basic_flash_data =
+ be32_to_cpu(((unsigned long *) (lastmq->recvbuf))[4]);
+ /* Create a permanent record */
+
+ /* With thanks to Marcus Comstedt */
+
+ memcard_t *card = kmalloc(sizeof(memcard_t), GFP_KERNEL);
+ card->partitions = ((basic_flash_data >> 24) & 0xff) + 1;
+ printk("\tFlash device has %ld partitions\n", card->partitions);
+ card->blocks = (((basic_flash_data >> 16) & 0xff) + 1) << 5;
+ printk("\tFlash device has %ld blocks \n", card->blocks);
+ card->writecnt = (basic_flash_data >> 12) & 0xf;
+ printk("\tFlash device has write count of %ld\n", card->writecnt);
+ card->readcnt = (basic_flash_data >> 8) & 0xf;
+ printk("\tFlash device has read count of %ld\n", card->readcnt);
+ card->removable = (basic_flash_data >> 7) & 1;
+ printk("\tFlash device removable status is %ld\n",
+ card->removable);
+
+
+
+ d->private_data = card;
+
+ lastmq = NULL;
+ /* Now query each flash partition */
+
+
+ /* Register the flash with mtd subsystem */
if (!vmu_flash_mtd) {
/* Populate a mtd_info */
vmu_flash_mtd = kmalloc(1000, GFP_KERNEL);
@@ -487,6 +565,7 @@
return -1;
}
+
/* Create the cache */
vmu_cache = kmalloc(64, GFP_KERNEL);
vmu_cache->buffer = kmalloc(512, GFP_KERNEL);
@@ -518,13 +597,15 @@
kfree(vmu_cache->buffer);
vmu_cache->valid = 0;
kfree(vmu_cache);
+ kfree((struct memcard_t *) d->private_data);
+ flash_queried = 0;
}
/***********Maple device*****************/
-static struct maple_driver dc_flashmap_driver = {
+struct maple_driver dc_flashmap_driver = {
function:MAPLE_FUNC_MEMCARD,
name:"VMU Flash Memory",
connect:dc_flashmap_connect,
|