From f4432bc84827cce85d62fb82dafa5e7858d06506 Mon Sep 17 00:00:00 2001 From: Alessandro Rubini <rubini@gnudd.com> Date: Tue, 24 Jul 2012 13:35:13 +0200 Subject: [PATCH] setup spec-gpio, but there's no code yet --- kernel/Makefile | 10 ++++++---- kernel/spec-fmc.c | 2 ++ kernel/spec-gpio-no.c | 17 +++++++++++++++++ kernel/spec-gpio.c | 15 +++++++++++++++ kernel/spec.h | 8 +++++++- 5 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 kernel/spec-gpio-no.c create mode 100644 kernel/spec-gpio.c diff --git a/kernel/Makefile b/kernel/Makefile index a586c36..0383bf7 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -8,10 +8,12 @@ obj-m += spec.o obj-m += fmc-trivial.o obj-m += wr-nic.o -spec-objs = spec-pci.o -spec-objs += spec-fmc.o -spec-objs += spec-i2c.o -spec-objs += loader-ll.o +spec-y = spec-pci.o +spec-y += spec-fmc.o +spec-y += spec-i2c.o +spec-y += loader-ll.o +spec-y += spec-gpio-no.o +spec-$(CONFIG_GPIOLIB) += spec-gpio.o all modules: $(MAKE) -C $(LINUX) M=$(shell /bin/pwd) modules diff --git a/kernel/spec-fmc.c b/kernel/spec-fmc.c index 7fa9731..f9c829c 100644 --- a/kernel/spec-fmc.c +++ b/kernel/spec-fmc.c @@ -184,6 +184,7 @@ int spec_fmc_create(struct spec_dev *spec) ret = fmc_device_register(fmc); if (ret) goto out_irq; + spec_gpio_init(fmc); /* May fail, we don't care */ return ret; out_irq: @@ -196,6 +197,7 @@ out_free: void spec_fmc_destroy(struct spec_dev *spec) { + spec_gpio_exit(spec->fmc); fmc_device_unregister(spec->fmc); spec_irq_exit(spec->fmc); spec_i2c_exit(spec->fmc); diff --git a/kernel/spec-gpio-no.c b/kernel/spec-gpio-no.c new file mode 100644 index 0000000..31d9231 --- /dev/null +++ b/kernel/spec-gpio-no.c @@ -0,0 +1,17 @@ +#include <linux/kernel.h> +#include <linux/fmc.h> +#include "spec.h" +/* + * If the host computer has no gpiolib, this default will apply + */ +int __weak spec_gpio_init(struct fmc_device *fmc) +{ + printk("%s - %s\n", __FILE__, __func__); + return 0; +} +void __weak spec_gpio_exit(struct fmc_device *fmc) +{ + printk("%s - %s\n", __FILE__, __func__); +} + + diff --git a/kernel/spec-gpio.c b/kernel/spec-gpio.c new file mode 100644 index 0000000..700f450 --- /dev/null +++ b/kernel/spec-gpio.c @@ -0,0 +1,15 @@ + +#include <linux/kernel.h> +#include <linux/gpio.h> +#include <linux/fmc.h> +#include "spec.h" + +int spec_gpio_init(struct fmc_device *fmc) +{ + printk("%%s - %s\n", __FILE__, __func__); +} + +void spec_gpio_exit(struct fmc_device *fmc) +{ + printk("%s - %s\n", __FILE__, __func__); +} diff --git a/kernel/spec.h b/kernel/spec.h index d072989..4906829 100644 --- a/kernel/spec.h +++ b/kernel/spec.h @@ -13,6 +13,7 @@ #include <linux/firmware.h> #include <linux/completion.h> #include <linux/fmc.h> +#include <linux/gpio.h> #define PCI_VENDOR_ID_CERN 0x10dc #define PCI_DEVICE_ID_SPEC 0x018d @@ -35,6 +36,7 @@ struct spec_dev { struct fmc_device *fmc; int irq_count; /* for mezzanine use too */ struct completion compl; + struct gpio_chip *gpio; }; /* Registers for GN4124 access */ @@ -118,9 +120,13 @@ static inline void gennum_mask_val(struct spec_dev *spec, extern int spec_fmc_create(struct spec_dev *spec); extern void spec_fmc_destroy(struct spec_dev *spec); -/* Function in spec-i2c.c, used by spec-fmc.c */ +/* Functions in spec-i2c.c, used by spec-fmc.c */ extern int spec_i2c_init(struct fmc_device *fmc); extern void spec_i2c_exit(struct fmc_device *fmc); +/* Functions in spec-gpio.c */ +extern int spec_gpio_init(struct fmc_device *fmc); +extern void spec_gpio_exit(struct fmc_device *fmc); + #endif /* __SPEC_H__ */ -- GitLab