Problem in SDIO driver Read/Write

Hi All,

I am writing a SDIO driver for a WLAN device using Win2k3 server SP1 DDK.

I am facing problem when I am trying to read and write the SDIO registers, the communication is not happening. The bus driver is not generating commands (CMD 53 and etc) for reading and writing. This is happening in both byte transfer and block transfer. But I could able to install and uninstall the driver with out any problem.

Please find the code for the byte reading.

NTSTATUS ReadDirect(PDEVICE_OBJECT fdo, long function, int Offset, unsigned short
*Data)

{

NTSTATUS status;

PSDBUS_REQUEST_PACKET sdrp = NULL;

SD_RW_DIRECT_ARGUMENT sdIoArgument;

PWDM_DEVICE_EXTENSION dx = (PWDM_DEVICE_EXTENSION)fdo->DeviceExtension;

DbgPrint (“Entering ReadDirect\n”);

sdrp = (PSDBUS_REQUEST_PACKET)ExAllocatePool(NonPagedPool,

sizeof(SDBUS_REQUEST_PACKET));

if (!sdrp) {

DbgPrint (“Error : Insufficient Memory\n”);

return STATUS_INSUFFICIENT_RESOURCES;

}

RtlZeroMemory(sdrp, sizeof(SDBUS_REQUEST_PACKET));

sdrp->RequestFunction = SDRF_DEVICE_COMMAND;

sdrp->Parameters.DeviceCommand.CmdDesc = ReadIoDirectDesc;

//

// Set up the argument and command descriptor

//

sdIoArgument.u.AsULONG =
0;

sdIoArgument.u.bits.Address = Offset; //offset = 0xa

sdIoArgument.u.bits.Function = function; // function = 1

sdrp->Parameters.DeviceCommand.Argument =

sdIoArgument.u.AsULONG;

sdrp->Parameters.DeviceCommand.Length = 1; //Byte Access

//

// submit the request

//

status = SdBusSubmitRequest(dx->BusInterface.Context, sdrp);

if (NT_SUCCESS(status)) {

// for direct IO, the data comes in the response

//*Data = sdrp->ResponseData.AsUCHAR[0];

DbgPrint (“Msg : SdBusSubmitRequest success \n”);

RtlCopyMemory (Data, sdrp->ResponseData.AsUCHAR, sizeof (unsigned short));

}

else

{

DbgPrint (“Msg : SdBusSubmitRequest Failed \n”);

}

DbgPrint (“Msg : Data Read : %d\n”, Data);

ExFreePool(sdrp);

DbgPrint (“Exiting ReadDirect \n”);

return status;

}

Can any body tell how I can solve this problem.

Please help.

Thanks,

Sundar


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Sundar,

You have not posted your ReadIoDirectDesc, but the code itself
looks reasonable as it’s virtually a verbatim paste from the DDK.
I recommend you start working with the SDIO bus analyzer.
It would help you trouble-shoot what you’re really doing or not doing.

Thanks,
-Ilya

*****
sundar wrote:

Hi All,

I am writing a SDIO driver for a WLAN device using Win2k3 server SP1 DDK.

I am facing problem when I am trying to read and write the SDIO registers,
the
communication is not happening. The bus driver is not generating commands
(CMD
53 and etc) for reading and writing. This is happening in both byte transfer
and
block transfer. But I could able to install and uninstall the driver with
out
any problem.

Please find the code for the byte reading.

NTSTATUS ReadDirect(PDEVICE_OBJECT fdo, long function, int Offset, unsigned
short
*Data)

{

NTSTATUS status;

PSDBUS_REQUEST_PACKET sdrp = NULL;

SD_RW_DIRECT_ARGUMENT sdIoArgument;

PWDM_DEVICE_EXTENSION dx =
(PWDM_DEVICE_EXTENSION)fdo->DeviceExtension;

DbgPrint (“Entering ReadDirect\n”);

sdrp = (PSDBUS_REQUEST_PACKET)ExAllocatePool(NonPagedPool,

sizeof(SDBUS_REQUEST_PACKET));

if (!sdrp) {

DbgPrint (“Error : Insufficient Memory\n”);

return STATUS_INSUFFICIENT_RESOURCES;

}

RtlZeroMemory(sdrp, sizeof(SDBUS_REQUEST_PACKET));

sdrp->RequestFunction = SDRF_DEVICE_COMMAND;

sdrp->Parameters.DeviceCommand.CmdDesc = ReadIoDirectDesc;

//

// Set up the argument and command descriptor

//

sdIoArgument.u.AsULONG =
0;

sdIoArgument.u.bits.Address = Offset; //offset = 0xa

sdIoArgument.u.bits.Function = function; // function = 1

sdrp->Parameters.DeviceCommand.Argument =

sdIoArgument.u.AsULONG;

sdrp->Parameters.DeviceCommand.Length = 1; //Byte Access

//

// submit the request

//

status = SdBusSubmitRequest(dx->BusInterface.Context, sdrp);

if (NT_SUCCESS(status)) {

// for direct IO, the data comes in the response

//*Data = sdrp->ResponseData.AsUCHAR[0];

DbgPrint (“Msg : SdBusSubmitRequest success \n”);

RtlCopyMemory (Data, sdrp->ResponseData.AsUCHAR, sizeof
(unsigned
short));

}

else

{

DbgPrint (“Msg : SdBusSubmitRequest Failed \n”);

}

DbgPrint (“Msg : Data Read : %d\n”, Data);

ExFreePool(sdrp);

DbgPrint (“Exiting ReadDirect \n”);

return status;

}

Hi IIya,

Thanks for the response. The code is same as DDK provided. The ReadIODirectDesc is also same as DDK.

While by more debugging, I have found the SDRP request for GET_PROBERTY for function number is succeeded. I could see the valid command signals through logical analyzer.

But for other operations like ReadDirectIO and ReadExtenededIO, the SDRP request was blocked after requesting. The card driver is waiting for the SDIO bus driver response. At the same time, I could not see any command signal in logical analyzer. So the SDIO bus driver is not driving commands in SDIO.

From the above, the communication between card driver, bus driver and SDIO is proper only when sending the GET_PROBERTY request. For other operations, the bus driver is not sending any SDIO commands.

Do you have any idea how I can debug further.

Thanks,
Sundar

Ilya Faenson wrote: Sundar,

You have not posted your ReadIoDirectDesc, but the code itself
looks reasonable as it’s virtually a verbatim paste from the DDK.
I recommend you start working with the SDIO bus analyzer.
It would help you trouble-shoot what you’re really doing or not doing.

Thanks,
-Ilya

*****
sundar wrote:

Hi All,

I am writing a SDIO driver for a WLAN device using Win2k3 server SP1 DDK.

I am facing problem when I am trying to read and write the SDIO registers,
the
communication is not happening. The bus driver is not generating commands
(CMD
53 and etc) for reading and writing. This is happening in both byte transfer
and
block transfer. But I could able to install and uninstall the driver with
out
any problem.

Please find the code for the byte reading.

NTSTATUS ReadDirect(PDEVICE_OBJECT fdo, long function, int Offset, unsigned
short
*Data)

{

NTSTATUS status;

PSDBUS_REQUEST_PACKET sdrp = NULL;

SD_RW_DIRECT_ARGUMENT sdIoArgument;

PWDM_DEVICE_EXTENSION dx =
(PWDM_DEVICE_EXTENSION)fdo->DeviceExtension;

DbgPrint (“Entering ReadDirect\n”);

sdrp = (PSDBUS_REQUEST_PACKET)ExAllocatePool(NonPagedPool,

sizeof(SDBUS_REQUEST_PACKET));

if (!sdrp) {

DbgPrint (“Error : Insufficient Memory\n”);

return STATUS_INSUFFICIENT_RESOURCES;

}

RtlZeroMemory(sdrp, sizeof(SDBUS_REQUEST_PACKET));

sdrp->RequestFunction = SDRF_DEVICE_COMMAND;

sdrp->Parameters.DeviceCommand.CmdDesc = ReadIoDirectDesc;

//

// Set up the argument and command descriptor

//

sdIoArgument.u.AsULONG =
0;

sdIoArgument.u.bits.Address = Offset; //offset = 0xa

sdIoArgument.u.bits.Function = function; // function = 1

sdrp->Parameters.DeviceCommand.Argument =

sdIoArgument.u.AsULONG;

sdrp->Parameters.DeviceCommand.Length = 1; //Byte Access

//

// submit the request

//

status = SdBusSubmitRequest(dx->BusInterface.Context, sdrp);

if (NT_SUCCESS(status)) {

// for direct IO, the data comes in the response

//*Data = sdrp->ResponseData.AsUCHAR[0];

DbgPrint (“Msg : SdBusSubmitRequest success \n”);

RtlCopyMemory (Data, sdrp->ResponseData.AsUCHAR, sizeof
(unsigned
short));

}

else

{

DbgPrint (“Msg : SdBusSubmitRequest Failed \n”);

}

DbgPrint (“Msg : Data Read : %d\n”, Data);

ExFreePool(sdrp);

DbgPrint (“Exiting ReadDirect \n”);

return status;

}


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@yahoo.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Sundar,

The GET_PROPERTY request just returns you a cached function number.
It just means that the bus driver init of the adapter has succeeded, i.e.
the CMD5, CMD3, CMD7 and a bunch of CMD52s have gone through.
Nothing your driver has done has worked yet.

Is it a known good hardware? I generally prefer to develop the Windows
Mobile driver first on the hardware under debug as the SDIO stacks there
(both BSquare in 4.x and MSFT in 5.x) are much more advanced than in
XP SP2 and give the developer a lot more control.

I suspect your device responds to CMD53s with the R5s rather than the R1s
while the DDK sample specifies the SDRT_1 in its extended I/O sample code.
Try using SDRT_5.

Start from writing first rather than reading. Reads are more complicated
than writes - if the hardware is well designed, reads are generally issued
from the interrupt routine callback so interrupts should be working by then.
Make sure you switch between 1-bit mode and 4-bit mode correctly via
CMD52s if required. I could go on and on.

Again, as I said before, something like the Yokogawa SDIO sniffer would
be invaluable in your debugging.

Good luck,
-llya

*****
sundar wrote:

Hi IIya,

Thanks for the response. The code is same as DDK provided. The
ReadIODirectDesc is also same as DDK.

While by more debugging, I have found the SDRP request for GET_PROBERTY
for
function number is succeeded. I could see the valid command signals through
logical analyzer.

But for other operations like ReadDirectIO and ReadExtenededIO, the SDRP
request was blocked after requesting. The card driver is waiting for the
SDIO
bus driver response. At the same time, I could not see any command signal
in
logical analyzer. So the SDIO bus driver is not driving commands in SDIO.

From the above, the communication between card driver, bus driver and SDIO
is
proper only when sending the GET_PROBERTY request. For other operations,
the
bus driver is not sending any SDIO commands.

Do you have any idea how I can debug further.

Thanks,
Sundar

Ilya Faenson wrote: Sundar,

You have not posted your ReadIoDirectDesc, but the code itself
looks reasonable as it’s virtually a verbatim paste from the DDK.
I recommend you start working with the SDIO bus analyzer.
It would help you trouble-shoot what you’re really doing or not doing.

Thanks,
-Ilya

*****
sundar wrote:

Hi All,

I am writing a SDIO driver for a WLAN device using Win2k3 server SP1 DDK.

I am facing problem when I am trying to read and write the SDIO registers,
the
communication is not happening. The bus driver is not generating commands
(CMD
53 and etc) for reading and writing. This is happening in both byte transfer
and
block transfer. But I could able to install and uninstall the driver with
out
any problem.

Please find the code for the byte reading.

< code removed>