From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from po-out-1718.google.com (po-out-1718.google.com [72.14.252.158]) by ozlabs.org (Postfix) with ESMTP id AC89BDE2A8 for ; Tue, 3 Jun 2008 20:05:54 +1000 (EST) Received: by po-out-1718.google.com with SMTP id y22so4323473pof.4 for ; Tue, 03 Jun 2008 03:05:53 -0700 (PDT) Message-ID: <388e90610806030305i1b2a7c32j9bdac3209f8c1993@mail.gmail.com> Date: Tue, 3 Jun 2008 12:05:52 +0200 From: "Ludovic Desroches" To: "A. Nolson" Subject: Re: How accessing to my IP registers from Linux In-Reply-To: <48450B7C.2010000@gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_3079_28295658.1212487552568" References: <388e90610806030023x4a2c1077hfbabb49b95853bd0@mail.gmail.com> <48450B7C.2010000@gmail.com> Cc: linuxppc-embedded@ozlabs.org List-Id: Linux on Embedded PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , ------=_Part_3079_28295658.1212487552568 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Thanks for your answer, unfortunately it doesn't work. I'm doing this : static unsigned int *virtual_base =3D 0; static unsigned long mem_addr =3D 0x70001e00; static unsigned long mem_size =3D 0x100; static unsigned int reg3 =3D 0; static int __init gpio_init(void) { printk("<1>gpio: init_module\n"); if(check_mem_region(mem_addr,mem_size)) { printk("gpio: memory already in use\n"); return -EBUSY; } // request memory for the device request_mem_region(mem_addr,mem_size,"gpio"); // remap virtual_base =3D ioremap_nocache(mem_addr,mem_size); printk("ioremap: Virtual Address %08x\n",(unsigned int)virtual_base); printk("Physical Address %08x\n",(unsigned int)virt_to_phys(virtual_base)); if( virtual_base=3D=3D0 ) { printk("ioremap failed\n"); return -EBUSY ; } else { reg3 =3D XIo_Out32(virtual_base); printk("Result of GPIO_DATA =3D %08x\n",reg3) ; reg3 =3D XIo_Out32(virtual_base+4); printk("Result of GPIO_TRI =3D %08x\n",reg3) ; printk("Xio_Out32\n"); XIo_Out32(virtual_base, 0x00); } return 0; } the result is : gpio: init_module ioremap: Virtual Address c500ee00 Physical Address 0500ee00 Xio_Out32 The LEDs stay ON. I find strange having physical address different from the physical adress I wanted to map. Can I have a problem with my MMU ? As othe= r devices are working, I am not sure it's the MMU for exemple during boot : eth0: Xilinx 10/100 EMAC at 0x80400000 mapped to 0xC5020000, irq=3D1 and Ethernet is working so the MMU seems to be ok. Thanks Ludovic Desroches 2008/6/3 A. Nolson : > Hi, > > I have recently developed a similar driver for that. Your IO memory > remapping should look like similar to this in your module_init: > > ------- > > if ( (lcd_remap_address =3D (u32) ioremap(LCD_BASE, LCD_END - LCD_BASE = +1 > )) =3D=3D 0) { > printk(KERN_ERR "Couldn't ioremap memory at 0x%08lX\n", > (unsigned long) LCD_BASE); > return -EFAULT; } > // Configure the IO as outputs > XIo_Out32(lcd_remap_address + 0x4,0x00); > ------- > /A > > Ludovic Desroches wrote: > >> >> Hi, >> >> >> I have put xilinx kernel on my board : a memec FX12 based on a Virtex 4 >> FX. Everything thing is OK, I have my serial console, Ethernet is also O= K. >> >> I have to make some drivers. For example one for the LCD screen. It is m= y >> first driver so I want to try with something easier like LEDs. I know th= ere >> is a driver from Xilinx but I want to do it by myself. Moreover it is on= ly a >> file to adapt Xilinx standelone driver for Kernel. >> >> >> I try to read and to write the registers of my GPIO IP which is working,= I >> have made some tests in standelone. How accessing to these registers ? >> >> I have tried with this for example but without success : >> >> ptr =3D ioremap_nocache(0x70001e00,0x00000004); >> printk("GPIO_DATA (readl): %u\n",readl(ptr)); >> >> >> readl, outl, ioread32 : same result. >> >> >> Thanks >> >> >> Best Regards >> >> >> -- >> Ludovic Desroches >> Ing=E9nieur ESIEE 2008 >> mobile : 06 19 21 02 08 >> http://www.odulo.net >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Linuxppc-embedded mailing list >> Linuxppc-embedded@ozlabs.org >> https://ozlabs.org/mailman/listinfo/linuxppc-embedded >> > > --=20 Ludovic Desroches Ing=E9nieur ESIEE 2008 mobile : 06 19 21 02 08 http://www.odulo.net ------=_Part_3079_28295658.1212487552568 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Thanks for your answer, unfortunately it doesn't work. I'm doing th= is :

static unsigned int *virtual_base =3D 0;
static unsigned lon= g mem_addr =3D 0x70001e00;
static unsigned long mem_size =3D 0x100;
s= tatic unsigned int reg3 =3D 0;

static int __init gpio_init(void) {

    printk(&q= uot;<1>gpio: init_module\n");
    if(check_mem= _region(mem_addr,mem_size))
    {
    &= nbsp;   printk("gpio: memory already in use\n");
        return -EBUSY;
    = }
    // request memory for the device
  &nb= sp; request_mem_region(mem_addr,mem_size,"gpio");
  =   // remap
    virtual_base =3D ioremap_nocache(mem_= addr,mem_size);
    printk("ioremap: Virtual Address= %08x\n",(unsigned int)virtual_base);
    printk("Physical Address %08x\n",(unsigned int= )virt_to_phys(virtual_base));
    if( virtual_base=3D=3D0= )
    {
        printk(= "ioremap failed\n");
        ret= urn -EBUSY ;
    }
    else
    {
        reg3 =3D= XIo_Out32(virtual_base);
        printk(&= quot;Result of GPIO_DATA =3D %08x\n",reg3) ;
    &nb= sp;   reg3 =3D XIo_Out32(virtual_base+4);
    &= nbsp;   printk("Result of GPIO_TRI =3D %08x\n",reg3) ;<= br>
        printk("Xio_Out32\n");<= br>        XIo_Out32(virtual_base, 0x00);
=     }
    return 0;
}

the result= is :

gpio: init_module
ioremap: Virtual Address c500ee00
Phy= sical Address 0500ee00
Xio_Out32

The LEDs stay ON. I find strange having physical address d= ifferent from the physical adress I wanted to map. Can I have a problem wit= h my MMU ? As other devices are working, I am not sure it's the MMU for= exemple during boot : eth0: Xilinx 10/100 EMAC at 0x80400000 mapped to 0xC= 5020000, irq=3D1 and Ethernet is working so the MMU seems to be ok.


Thanks

Ludovic Desroches


2008/6/3 A. Nolson <alohanono@= gmail.com>:
Hi,

I have recently developed a similar driver for that. Your IO memory remappi= ng should look like similar to this in your module_init:

-------

  if ( (lcd_remap_address =3D (u32) ioremap(LCD_BASE, LCD_END - LCD_B= ASE +1 )) =3D=3D 0) {
      printk(KERN_ERR "Couldn't ioremap memory at = 0x%08lX\n",
             (unsigned long) LCD_BASE);=
      return -EFAULT;         }
    // Configure the IO as outputs
  XIo_Out32(lcd_remap_address  + 0x4,0x00);      =    
-------
/A

Ludovic Desroches wrote:
<= div class=3D"Wj3C7c">
Hi,

 
I have put xilinx kernel on my board : a memec FX12 based on a Virtex 4 FX.= Everything thing is OK, I have my serial console, Ethernet is also OK.

I have to make some drivers. For example one for the LCD screen. It is my f= irst driver so I want to try with something easier like LEDs. I know there = is a driver from Xilinx but I want to do it by myself. Moreover it is only = a file to adapt Xilinx standelone driver for Kernel.

 
I try to read and to write the registers of my GPIO IP which is working, I = have made some tests in standelone. How accessing to these registers ?

I have tried with this for example but without success :

   ptr =3D ioremap_nocache(0x70001e00,0x00000004);
   printk("GPIO_DATA (readl): %u\n",readl(ptr));

   
readl, outl, ioread32 : same result.

 
Thanks

 
Best Regards


--
Ludovic Desroches
Ing=E9nieur ESIEE 2008
mobile : 06 19 21 02 08
http://www.odulo.net=
------------------------------------------------------------------------
_______________________________________________
Linuxppc-embedded mailing list
Linuxppc-= embedded@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded




--
Ludovic Desroches
In= g=E9nieur ESIEE 2008
mobile : 06 19 21 02 08
http://www.odulo.net ------=_Part_3079_28295658.1212487552568--