Subject: [Re: Question aboug hardware.h]

From: Nandana <[email-masked]>
Date: Mon, 08 May 2000 13:03:28 +0600

Subject: Re: Question aboug hardware.h
From: Nandana <[email-masked]>
To: Nicolas Pitre <[email-masked]>
Date: Mon, 08 May 2000 13:02:06 +0600

Hi,
Have someone got any idea about the method to access PCMCIA attribute space .
We tried it using io_p2v but we had segmentation faults.
Regards
Harsha

Nicolas Pitre wrote:

> On Fri, 5 May 2000, Chien-Min Lee wrote:
>
> >
> > >> However, if we use the physical address 0x91xxxxxx, after the
> > >> transform of io_p2v(0x91xxxxxx), it can not get the original physical
> > >> address by io_v2p.
> >
> > >Yes.  All the virtual->physical and physical->virtual macros are only valid
> > >for RAM areas, not general IO.
> >
> >    Does this mean that these two macros are useless!??
> >    What address type(physical or virtual) do we use to access the registers of
> >    peripheral control modules??
>
> You really don't have to bother about virtual or physical location of
> registers.  If you want to clear some GPIOs, simply use
>
>         GEDR |= (1<<x);         /* set GPIO x direction for output */
>         GPCR = (1<<x);          /* set GPIO x low */
>         val = (GPLR & (1<<y));  /* read GPIO y level (zero or not) */
>
> where x and y are your GPIO numbers.  If you want to play with the memory
> control register, simply use MECR like:
>
>         MECR = (MECR & (some_bits)) | some_other_bits;
>
> All those peripheral registers are defined in include/asm/arch/SA-1100.h.
> You should use them and not care about where and how they are mapped.
>
> Nicolas
>
> unsubscribe: body of `unsubscribe linux-arm-kernel' to [email-masked]

---

From: Nicolas Pitre <[email-masked]>
Date: Mon, 8 May 2000 15:31:52 -0400 (EDT)

> We tried it using io_p2v but we had segmentation faults.

See linux/arch/arm/mm/mm-sa1100.c.  There you'll find all physical vs
virtual mappings for all peripherals.

For example, PCMCIA 1 IO space is virtually mapped at 0xe0000000.  Then
you just need to access memory from that address (simple read or write) to
get the data.

The io_p2v macro is only used for definition inside SA-1100.h.  You
shouldn't have to use it directly.

Nicolas

Hi,

---

From: Harsha Sanjeewa <[email-masked]>
Date: Tue, 09 May 2000 16:20:14 +0600

Hi,
I am tring to read the attribute space of PCMCIA using following program.
 Even the card is inserted or not  it gives different reading in different loadings
of the module.Any idea...
-------------------------------------------------------
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif

#include <linux/module.h>
#include <linux/kernel.h>

#include <asm/io.h>

unsigned long driver_start = 0x08000000;
int driver_count = 10;
int driver_i = 0;

MODULE_PARM(driver_start, "i");
MODULE_PARM(driver_count, "i");

int init_module(void) {

    printk("<1> MECR: %x  \n", MECR);
    MECR =  (MECR & (0x00000)) |0x7fe47fff;

    for (driver_i; driver_i < driver_count; driver_i += 1 ) {
        printk("<1> %x : ",PCIO_BASE + driver_start  + driver_i);
        printk("%x \n", inb( driver_start + driver_i));
    }
    return 0;
}

void cleanup_module(void) {
    printk("<1>Clean up module\n");
}
~
-------------------------------------------------------

It really helps me if you can point out the problem with above code.

Regards,
Harsha

Nicolas Pitre wrote:

>   --------------------------------------------------------------------------------
>
> Date: Mon, 8 May 2000 13:02:06 펭
> From: Nandana Kuruwitage <[email-masked]>

unsubscribe: body of `unsubscribe linux-arm' to [email-masked]
++        Please use [email-masked] for           ++
++                        kernel-related discussions.                      ++

---

From: John G Dorsey <[email-masked]>
Date: Tue, 09 May 2000 11:30:23 -0400

>         printk("%x \n", inb( driver_start + driver_i));

Unless you have some code which deals with this elsewhere, you appear
not to be performing the power-on/reset sequence, so essentially it
doesn't matter whether you have the card physically in the socket or
not. =)

Look in the documentation for your board to see how power control works.
Essentially, you'll want to apply power, wait a little while, apply
power+reset, wait, then apply power only, and wait (at least 20ms, but
in the absence of actually checking the card ready line, just wait a
long time). Now you should be able to read attribute memory.

Some additional notes:

1. You're setting specific MECR fields for slot 1, but leaving slot 0 at
the slowest possible speed. Take a look at Card Services
(http://www.cs.cmu.edu/~wearable/software/pcmcia-arm.html) for a method
to compute the correct values.

2. To permit client driver portability for Card Services, the ISA I/O
macros in the SA-1100 kernel patches no longer apply the PCIO_BASE
offset (2.3.99-pre6-rmk1-np1 and higher, I believe). Be warned.

3. Even after you get this part to work, why rewrite all of the code
that deals with parsing CIS tuples, handling inserts/ejects, &c.?
Consider helping out with Card Services, rather than building a
hardwired driver.

-jd

---

From: Shang-te Hsu <[email-masked]>
Date: Wed, 10 May 2000 10:20:58 +0800

Harsha,

I guess you forget open the power of PCMCIA slot.
The attached file is a test program I wrote several month ago.
It can read CIS and dump to screen.
Just make and download bootimage to board. 
Hope it is useful.

Regards,

Shang-te Hsu.
Harsha Sanjeewa ¼g¹D¡G

---

From: Harsha Sanjeewa <[email-masked]>
Date: Thu, 11 May 2000 08:59:09 +0600

> virtual mappings for all peripherals.

In this file there is no physical to virtual mapping for 0x18000000 for Brutus board,
which is  used to
apply power to PCMCIA adaptor. So we insert it to to above file and it worked. Is
this should be done
or is there is another way to do it

Regards,
Harsha

---

From: Nicolas Pitre <[email-masked]>
Date: Thu, 11 May 2000 09:36:08 -0400 (EDT)

> or is there is another way to do it

There is other ways too, but this is the good one.

Nicolas

---

From: Nicolas Pitre <[email-masked]>
Date: Thu, 11 May 2000 09:43:18 -0400 (EDT)

> or is there is another way to do it

There is other ways too, but this is a good one.

Nicolas