diff --git a/kernel/Makefile b/kernel/Makefile index a586c36220dea40672c9e91516fcb7158e136b1f..0383bf7fe62f837feb848c568fc0855a78f34894 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 7fa9731f61851f4a4589edb497e15919b34c54ec..f9c829c254fbf862b64be0da17d4194fa9b6e74e 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 0000000000000000000000000000000000000000..31d923142f422045667a099a0e0bbf78d10d33d7 --- /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 0000000000000000000000000000000000000000..700f450fe0640f33f27558758e8773d13d103ed2 --- /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 d072989d836494e59c8deaf26cf691abcbc397ba..4906829d3db16ff2846b39a61f9d2cc3c62b5eb6 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__ */