* Compile program using XGpio
@ 2008-10-21 14:35 Bruno Monteiro
2008-10-21 20:08 ` John Linn
0 siblings, 1 reply; 5+ messages in thread
From: Bruno Monteiro @ 2008-10-21 14:35 UTC (permalink / raw)
To: linuxppc-embedded
[-- Attachment #1: Type: text/plain, Size: 508 bytes --]
Hi all,
I'm working with a Virtex2p. I have a running system using:
- EDK 9.1
- Crosstool-ng (svn)
- linux-2.6-xlnx
- BusyBox 1.12.1
Now, i'm trying to build a small program that turn off leds. I guess it
should be something like this:
void main (void){
XGpio led;
XGpio_Initialize (&led, XPAR_LEDS_4BIT_DEVICE_ID);
XGpio_SetDataDirection(&led,1,0);
XGpio_DiscreteWrite(&led,1,0xf);
}
I want to know how to compile it (without EDK). Any suggestion?
Thanks,
Bruno Monteiro
[-- Attachment #2: Type: text/html, Size: 750 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread* RE: Compile program using XGpio 2008-10-21 14:35 Compile program using XGpio Bruno Monteiro @ 2008-10-21 20:08 ` John Linn 2008-10-23 16:58 ` Bruno Monteiro 0 siblings, 1 reply; 5+ messages in thread From: John Linn @ 2008-10-21 20:08 UTC (permalink / raw) To: Bruno Monteiro, linuxppc-embedded [-- Attachment #1: Type: text/plain, Size: 2078 bytes --] Hi Bruno, I don't think you can do what you're trying to do, unless I'm misunderstanding or just not smart enough. The EDK from Xilinx ships with drivers that are not Linux drivers. Those functions in main below are intended for a standalone (no RTOS) system such they can't just be called from a user app in Linux. You are sort of trying to create a user mode driver with what you are doing. There is a character mode gpio driver in the Xilinx git tree, git://git.xilinx.com/linux-2.6-xlnx.git that has been used previously. I don't currently test that driver as we're in the process of getting a flattened gpio driver that is not char driver ready for mainline. I plan to take a look at the char mode gpio driver today as there's another question regarding it on the list. Thanks, John ________________________________ From: linuxppc-embedded-bounces+john.linn=xilinx.com@ozlabs.org [mailto:linuxppc-embedded-bounces+john.linn=xilinx.com@ozlabs.org] On Behalf Of Bruno Monteiro Sent: Tuesday, October 21, 2008 8:36 AM To: linuxppc-embedded@ozlabs.org Subject: Compile program using XGpio Hi all, I'm working with a Virtex2p. I have a running system using: * EDK 9.1 * Crosstool-ng (svn) * linux-2.6-xlnx * BusyBox 1.12.1 Now, i'm trying to build a small program that turn off leds. I guess it should be something like this: void main (void){ XGpio led; XGpio_Initialize (&led, XPAR_LEDS_4BIT_DEVICE_ID); XGpio_SetDataDirection(&led,1,0); XGpio_DiscreteWrite(&led,1,0xf); } I want to know how to compile it (without EDK). Any suggestion? Thanks, Bruno Monteiro This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately. [-- Attachment #2: Type: text/html, Size: 8397 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Compile program using XGpio 2008-10-21 20:08 ` John Linn @ 2008-10-23 16:58 ` Bruno Monteiro 2008-10-23 17:46 ` Grant Likely 0 siblings, 1 reply; 5+ messages in thread From: Bruno Monteiro @ 2008-10-23 16:58 UTC (permalink / raw) To: John Linn; +Cc: linuxppc-embedded [-- Attachment #1: Type: text/plain, Size: 3466 bytes --] Hi, I'm a new driver writer and i'm trying to understand how to deal with XGpio. My goal is writing a small piece of code that can turn leds on and off. I think this driver should do it: #include <linux/init.h> #include <linux/module.h> #include "xgpio.h" #include "xgpio_ioctl.h" #include "xparameters.h" XGpio led; static int myteste_init(void) { XGpio_Initialize (&led, LEDs_4Bit); XGpio_SetDataDirection(&led,1,0); XGpio_DiscreteWrite(&led,1,0xf); printk (KERN_ALERT "LEDS: Turn off\n"); return 0; } static int myteste_exit(void) { XGpio_DiscreteWrite(&led,1,0x0); printk (KERN_ALERT "LEDS: Turn on\n"); return 0; } module_init(myteste_init); module_exit(myteste_exit); But i have this error: ERROR: "XGpio_SetDataDirection" [drivers/char/mytest/mytest.ko] undefined! ERROR: "XGpio_Initialize" [drivers/char/mytest/mytest.ko] undefined! ERROR: "XGpio_DiscreteWrite" [drivers/char/mytest/mytest.ko] undefined! Any suggestion? This is the makefile: EXTRA_CFLAGS += -I$(TOPDIR)/drivers/xilinx_common EXTRA_CFLAGS += -I$(TOPDIR)/drivers/char/xilinx_gpio obj-$(CONFIG_MY_TEST) := mytest.o Is there any way to use *.dts instead xparameters.h Thanks, Bruno On Tue, Oct 21, 2008 at 9:08 PM, John Linn <John.Linn@xilinx.com> wrote: > Hi Bruno, > > > > I don't think you can do what you're trying to do, unless I'm > misunderstanding or just not smart enough. > > > > The EDK from Xilinx ships with drivers that are not Linux drivers. Those > functions in main below are intended for a standalone (no RTOS) system such > they can't just be called from a user app in Linux. You are sort of trying > to create a user mode driver with what you are doing. > > > > There is a character mode gpio driver in the Xilinx git tree, git:// > git.xilinx.com/linux-2.6-xlnx.git that has been used previously. I don't > currently test that driver as we're in the process of getting a flattened > gpio driver that is not char driver ready for mainline. > > > > I plan to take a look at the char mode gpio driver today as there's another > question regarding it on the list. > > > > Thanks, > > John > > > > > ------------------------------ > > *From:* linuxppc-embedded-bounces+john.linn=xilinx.com@ozlabs.org [mailto: > linuxppc-embedded-bounces+john.linn<linuxppc-embedded-bounces%2Bjohn.linn> > =xilinx.com@ozlabs.org] *On Behalf Of *Bruno Monteiro > *Sent:* Tuesday, October 21, 2008 8:36 AM > *To:* linuxppc-embedded@ozlabs.org > *Subject:* Compile program using XGpio > > > > Hi all, > > > I'm working with a Virtex2p. I have a running system using: > > - EDK 9.1 > - Crosstool-ng (svn) > - linux-2.6-xlnx > - BusyBox 1.12.1 > > Now, i'm trying to build a small program that turn off leds. I guess it > should be something like this: > > void main (void){ > XGpio led; > XGpio_Initialize (&led, XPAR_LEDS_4BIT_DEVICE_ID); > XGpio_SetDataDirection(&led,1,0); > XGpio_DiscreteWrite(&led,1,0xf); > } > > > I want to know how to compile it (without EDK). Any suggestion? > > > Thanks, > Bruno Monteiro > > This email and any attachments are intended for the sole use of the named > recipient(s) and contain(s) confidential information that may be > proprietary, privileged or copyrighted under applicable law. If you are not > the intended recipient, do not read, copy, or forward this email message or > any attachments. Delete this email message and any attachments immediately. > [-- Attachment #2: Type: text/html, Size: 8606 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Compile program using XGpio 2008-10-23 16:58 ` Bruno Monteiro @ 2008-10-23 17:46 ` Grant Likely 2008-10-23 17:58 ` John Linn 0 siblings, 1 reply; 5+ messages in thread From: Grant Likely @ 2008-10-23 17:46 UTC (permalink / raw) To: Bruno Monteiro; +Cc: John Linn, linuxppc-embedded On Thu, Oct 23, 2008 at 10:58 AM, Bruno Monteiro <bms.monteiro@gmail.com> wrote: > Hi, > > I'm a new driver writer and i'm trying to understand how to deal with XGpio. > My goal is writing a small piece of code that can turn leds on and off. I > think this driver should do it: > > > #include <linux/init.h> > #include <linux/module.h> > > #include "xgpio.h" > #include "xgpio_ioctl.h" > #include "xparameters.h" > > XGpio led; > > static int myteste_init(void) > { > XGpio_Initialize (&led, LEDs_4Bit); > XGpio_SetDataDirection(&led,1,0); > XGpio_DiscreteWrite(&led,1,0xf); > printk (KERN_ALERT "LEDS: Turn off\n"); > > return 0; > } > > static int myteste_exit(void) > { > > XGpio_DiscreteWrite(&led,1,0x0); > printk (KERN_ALERT "LEDS: Turn on\n"); > return 0; > } > > module_init(myteste_init); > module_exit(myteste_exit); > > But i have this error: > ERROR: "XGpio_SetDataDirection" [drivers/char/mytest/mytest.ko] undefined! > ERROR: "XGpio_Initialize" [drivers/char/mytest/mytest.ko] undefined! > ERROR: "XGpio_DiscreteWrite" [drivers/char/mytest/mytest.ko] undefined! None of the XGpio functions are available in Linux. You need to use the Linux kernel memory access functions instead (in_be32() and out_be32()). You also need to use the ioremap() function to map the physical address of the GPIO block into a virtual address that the kernel can use: ie: static int myteste_init(void) { u32 __iomem *regs; regs = ioremap([address of GPIO block], 0x100); if (regs == NULL) return -ENOMEM; /* configure as output */ out_be32(regs + 4, 0); /* turn on leds */ out_be32(regs, 0); printk (KERN_ALERT "LEDS: Turn on\n"); return 0; } This is just a simple example though. You should follow the pattern of other device drivers and bind against the of_platform_bus so your device can be described in the device tree (.dts) file. Or, better yet, use the existing driver from the Xilinx linux-2.6 git tree. g. -- Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. ^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Compile program using XGpio 2008-10-23 17:46 ` Grant Likely @ 2008-10-23 17:58 ` John Linn 0 siblings, 0 replies; 5+ messages in thread From: John Linn @ 2008-10-23 17:58 UTC (permalink / raw) To: Grant Likely, Bruno Monteiro; +Cc: linuxppc-embedded Hi Bruno, If you're needing a GPIO driver (not wanting to write one) we have one in the development branch of our GIT tree that's working. This is arch/powerpc only, no arch/ppc. You could use it for turning LEDS on as I just tested it and updated the wiki to show how to use it from user space. There is also an LED driver that is in the kernel that sits on top of a GPIO driver specifically for LEDs. http://xilinx.wikidot.com/osl-gpio-driver Thanks, John > -----Original Message----- > From: Grant Likely [mailto:grant.likely@secretlab.ca] > Sent: Thursday, October 23, 2008 11:46 AM > To: Bruno Monteiro > Cc: John Linn; linuxppc-embedded@ozlabs.org > Subject: Re: Compile program using XGpio > = > On Thu, Oct 23, 2008 at 10:58 AM, Bruno Monteiro <bms.monteiro@gmail.com> wrote: > > Hi, > > > > I'm a new driver writer and i'm trying to understand how to deal with XGpio. > > My goal is writing a small piece of code that can turn leds on and off. I > > think this driver should do it: > > > > > > #include <linux/init.h> > > #include <linux/module.h> > > > > #include "xgpio.h" > > #include "xgpio_ioctl.h" > > #include "xparameters.h" > > > > XGpio led; > > > > static int myteste_init(void) > > { > > XGpio_Initialize (&led, LEDs_4Bit); > > XGpio_SetDataDirection(&led,1,0); > > XGpio_DiscreteWrite(&led,1,0xf); > > printk (KERN_ALERT "LEDS: Turn off\n"); > > > > return 0; > > } > > > > static int myteste_exit(void) > > { > > > > XGpio_DiscreteWrite(&led,1,0x0); > > printk (KERN_ALERT "LEDS: Turn on\n"); > > return 0; > > } > > > > module_init(myteste_init); > > module_exit(myteste_exit); > > > > But i have this error: > > ERROR: "XGpio_SetDataDirection" [drivers/char/mytest/mytest.ko] undefined! > > ERROR: "XGpio_Initialize" [drivers/char/mytest/mytest.ko] undefined! > > ERROR: "XGpio_DiscreteWrite" [drivers/char/mytest/mytest.ko] undefined! > = > None of the XGpio functions are available in Linux. You need to use > the Linux kernel memory access functions instead (in_be32() and > out_be32()). > = > You also need to use the ioremap() function to map the physical > address of the GPIO block into a virtual address that the kernel can > use: > = > ie: > static int myteste_init(void) > { > u32 __iomem *regs; > = > regs =3D ioremap([address of GPIO block], 0x100); > if (regs =3D=3D NULL) > return -ENOMEM; > = > /* configure as output */ > out_be32(regs + 4, 0); > /* turn on leds */ > out_be32(regs, 0); > printk (KERN_ALERT "LEDS: Turn on\n"); > return 0; > } > = > This is just a simple example though. You should follow the pattern > of other device drivers and bind against the of_platform_bus so your > device can be described in the device tree (.dts) file. > = > Or, better yet, use the existing driver from the Xilinx linux-2.6 git tree. > = > g. > = > -- > Grant Likely, B.Sc., P.Eng. > Secret Lab Technologies Ltd. This email and any attachments are intended for the sole use of the named r= ecipient(s) and contain(s) confidential information that may be proprietary= , privileged or copyrighted under applicable law. If you are not the intend= ed recipient, do not read, copy, or forward this email message or any attac= hments. Delete this email message and any attachments immediately. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-10-23 17:58 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-10-21 14:35 Compile program using XGpio Bruno Monteiro 2008-10-21 20:08 ` John Linn 2008-10-23 16:58 ` Bruno Monteiro 2008-10-23 17:46 ` Grant Likely 2008-10-23 17:58 ` John Linn
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox