Loading src/drivers/Makefile +1 −0 Original line number Original line Diff line number Diff line Loading @@ -168,5 +168,6 @@ obj-$(CONFIG_ANDROID) += android/ obj-$(CONFIG_ELPHEL393) += elphel/ obj-$(CONFIG_ELPHEL393) += elphel/ obj-$(CONFIG_ELPHELDRVONMICROZED) += elphel/ obj-$(CONFIG_ELPHELDRVONMICROZED) += elphel/ obj-$(CONFIG_ELPHEL393_EXTERNAL) += elphel/ obj-y += net/ obj-y += net/ src/drivers/ata/ahci_elphel.c +70 −0 Original line number Original line Diff line number Diff line Loading @@ -23,9 +23,16 @@ #include <linux/slab.h> #include <linux/slab.h> #include <linux/platform_device.h> #include <linux/platform_device.h> #include <linux/dma-mapping.h> #include <linux/dma-mapping.h> #include <linux/sysfs.h> #include "ahci.h" #include "ahci.h" #define DRV_NAME "elphel-ahci" #define DRV_NAME "elphel-ahci" /* * FPGA bitstream control address and bit mask. These are used to check whether * bitstream is loaded or not. */ #define BITSTREAM_CTRL_ADDR 0xf800700c #define BITSTREAM_CTRL_BIT 0x4 /* Property names from device tree, these are specific for the controller */ /* Property names from device tree, these are specific for the controller */ #define PROP_NAME_CLB_OFFS "clb_offs" #define PROP_NAME_CLB_OFFS "clb_offs" Loading @@ -35,6 +42,9 @@ static struct ata_port_operations ahci_elphel_ops; static const struct ata_port_info ahci_elphel_port_info; static const struct ata_port_info ahci_elphel_port_info; static struct scsi_host_template ahci_platform_sht; static struct scsi_host_template ahci_platform_sht; static const struct of_device_id ahci_elphel_of_match[]; static const struct of_device_id ahci_elphel_of_match[]; static const struct attribute_group dev_attr_root_group; static bool load_driver = false; struct elphel_ahci_priv { struct elphel_ahci_priv { u32 clb_offs; u32 clb_offs; Loading @@ -42,6 +52,48 @@ struct elphel_ahci_priv { u32 base_addr; u32 base_addr; }; }; static ssize_t set_load_flag(struct device *dev, struct device_attribute *attr, const char *buff, size_t buff_sz) { load_driver = true; return buff_sz; } static int bitstream_loaded(u32 *ptr) { u32 val = ioread32(ptr); if (val & BITSTREAM_CTRL_BIT) return 1; else return 0; } static void elphel_defer_load(struct device *dev) { bool check_flag = true; u32 *ctrl_ptr = ioremap_nocache(BITSTREAM_CTRL_ADDR, 4); dev_info(dev, "AHCI driver loading is deferred. Load bitstream and write 1 into " "/sys/devices/soc0/amba@0/80000000.elphel-ahci/load_module to continue\n"); while (check_flag) { if (load_driver) { if (bitstream_loaded(ctrl_ptr)) { check_flag = false; } else { dev_err(dev, "FPGA bitstream is not loaded or bitstream " "does not contain AHCI controller\n"); load_driver = false; } } else { msleep(1000); } } load_driver = false; iounmap(ctrl_ptr); } // What about port_stop and freeing/unmapping ? // What about port_stop and freeing/unmapping ? // Or at least check if it is re-started and memory is already allocated/mapped // Or at least check if it is re-started and memory is already allocated/mapped static int elphel_port_start(struct ata_port *ap) static int elphel_port_start(struct ata_port *ap) Loading Loading @@ -132,6 +184,13 @@ static int elphel_drv_probe(struct platform_device *pdev) const struct of_device_id *match; const struct of_device_id *match; unsigned int reg_val; unsigned int reg_val; if (&dev->kobj) { ret = sysfs_create_group(&dev->kobj, &dev_attr_root_group); if (ret < 0) return ret; } elphel_defer_load(dev); dev_info(&pdev->dev, "probing Elphel AHCI driver"); dev_info(&pdev->dev, "probing Elphel AHCI driver"); dpriv = devm_kzalloc(dev, sizeof(struct elphel_ahci_priv), GFP_KERNEL); dpriv = devm_kzalloc(dev, sizeof(struct elphel_ahci_priv), GFP_KERNEL); Loading Loading @@ -166,6 +225,7 @@ static int elphel_drv_probe(struct platform_device *pdev) static int elphel_drv_remove(struct platform_device *pdev) static int elphel_drv_remove(struct platform_device *pdev) { { dev_info(&pdev->dev, "removing Elphel AHCI driver"); dev_info(&pdev->dev, "removing Elphel AHCI driver"); sysfs_remove_group(&pdev->dev.kobj, &dev_attr_root_group); ata_platform_remove_one(pdev); ata_platform_remove_one(pdev); return 0; return 0; Loading Loading @@ -231,6 +291,16 @@ static void elphel_qc_prep(struct ata_queued_cmd *qc) AHCI_CMD_TBL_AR_SZ, DMA_TO_DEVICE); AHCI_CMD_TBL_AR_SZ, DMA_TO_DEVICE); } } static DEVICE_ATTR(load_module, S_IWUSR | S_IWGRP, NULL, set_load_flag); static struct attribute *root_dev_attrs[] = { &dev_attr_load_module.attr, NULL }; static const struct attribute_group dev_attr_root_group = { .attrs = root_dev_attrs, .name = NULL, }; static struct ata_port_operations ahci_elphel_ops = { static struct ata_port_operations ahci_elphel_ops = { .inherits = &ahci_ops, .inherits = &ahci_ops, .port_start = elphel_port_start, .port_start = elphel_port_start, Loading src/drivers/elphel/Kconfig +7 −0 Original line number Original line Diff line number Diff line Loading @@ -20,4 +20,11 @@ config ELPHEL393_INIT default y default y help help If unsure, say Y. If unsure, say Y. config ELPHEL393_EXTERNAL tristate "Compile some Elphel drivers as external modules" default m help If unsure, say Y. endmenu endmenu src/drivers/elphel/Makefile +3 −0 Original line number Original line Diff line number Diff line Loading @@ -6,3 +6,6 @@ obj-$(CONFIG_ELPHEL393) += elphel393-pwr.o obj-$(CONFIG_ELPHEL393) += elphel393-mem.o obj-$(CONFIG_ELPHEL393) += elphel393-mem.o obj-$(CONFIG_ELPHELDRVONMICROZED) += elphel393-mem.o obj-$(CONFIG_ELPHELDRVONMICROZED) += elphel393-mem.o obj-$(CONFIG_ELPHEL393_INIT) += elphel393-init.o obj-$(CONFIG_ELPHEL393_INIT) += elphel393-init.o fpgajtag-y := fpgajtag353.o x393.o obj-$(CONFIG_ELPHEL393_EXTERNAL) += fpgajtag.o No newline at end of file src/drivers/elphel/fpgajtag353.c 0 → 100644 +1400 −0 File added.Preview size limit exceeded, changes collapsed. Show changes Loading
src/drivers/Makefile +1 −0 Original line number Original line Diff line number Diff line Loading @@ -168,5 +168,6 @@ obj-$(CONFIG_ANDROID) += android/ obj-$(CONFIG_ELPHEL393) += elphel/ obj-$(CONFIG_ELPHEL393) += elphel/ obj-$(CONFIG_ELPHELDRVONMICROZED) += elphel/ obj-$(CONFIG_ELPHELDRVONMICROZED) += elphel/ obj-$(CONFIG_ELPHEL393_EXTERNAL) += elphel/ obj-y += net/ obj-y += net/
src/drivers/ata/ahci_elphel.c +70 −0 Original line number Original line Diff line number Diff line Loading @@ -23,9 +23,16 @@ #include <linux/slab.h> #include <linux/slab.h> #include <linux/platform_device.h> #include <linux/platform_device.h> #include <linux/dma-mapping.h> #include <linux/dma-mapping.h> #include <linux/sysfs.h> #include "ahci.h" #include "ahci.h" #define DRV_NAME "elphel-ahci" #define DRV_NAME "elphel-ahci" /* * FPGA bitstream control address and bit mask. These are used to check whether * bitstream is loaded or not. */ #define BITSTREAM_CTRL_ADDR 0xf800700c #define BITSTREAM_CTRL_BIT 0x4 /* Property names from device tree, these are specific for the controller */ /* Property names from device tree, these are specific for the controller */ #define PROP_NAME_CLB_OFFS "clb_offs" #define PROP_NAME_CLB_OFFS "clb_offs" Loading @@ -35,6 +42,9 @@ static struct ata_port_operations ahci_elphel_ops; static const struct ata_port_info ahci_elphel_port_info; static const struct ata_port_info ahci_elphel_port_info; static struct scsi_host_template ahci_platform_sht; static struct scsi_host_template ahci_platform_sht; static const struct of_device_id ahci_elphel_of_match[]; static const struct of_device_id ahci_elphel_of_match[]; static const struct attribute_group dev_attr_root_group; static bool load_driver = false; struct elphel_ahci_priv { struct elphel_ahci_priv { u32 clb_offs; u32 clb_offs; Loading @@ -42,6 +52,48 @@ struct elphel_ahci_priv { u32 base_addr; u32 base_addr; }; }; static ssize_t set_load_flag(struct device *dev, struct device_attribute *attr, const char *buff, size_t buff_sz) { load_driver = true; return buff_sz; } static int bitstream_loaded(u32 *ptr) { u32 val = ioread32(ptr); if (val & BITSTREAM_CTRL_BIT) return 1; else return 0; } static void elphel_defer_load(struct device *dev) { bool check_flag = true; u32 *ctrl_ptr = ioremap_nocache(BITSTREAM_CTRL_ADDR, 4); dev_info(dev, "AHCI driver loading is deferred. Load bitstream and write 1 into " "/sys/devices/soc0/amba@0/80000000.elphel-ahci/load_module to continue\n"); while (check_flag) { if (load_driver) { if (bitstream_loaded(ctrl_ptr)) { check_flag = false; } else { dev_err(dev, "FPGA bitstream is not loaded or bitstream " "does not contain AHCI controller\n"); load_driver = false; } } else { msleep(1000); } } load_driver = false; iounmap(ctrl_ptr); } // What about port_stop and freeing/unmapping ? // What about port_stop and freeing/unmapping ? // Or at least check if it is re-started and memory is already allocated/mapped // Or at least check if it is re-started and memory is already allocated/mapped static int elphel_port_start(struct ata_port *ap) static int elphel_port_start(struct ata_port *ap) Loading Loading @@ -132,6 +184,13 @@ static int elphel_drv_probe(struct platform_device *pdev) const struct of_device_id *match; const struct of_device_id *match; unsigned int reg_val; unsigned int reg_val; if (&dev->kobj) { ret = sysfs_create_group(&dev->kobj, &dev_attr_root_group); if (ret < 0) return ret; } elphel_defer_load(dev); dev_info(&pdev->dev, "probing Elphel AHCI driver"); dev_info(&pdev->dev, "probing Elphel AHCI driver"); dpriv = devm_kzalloc(dev, sizeof(struct elphel_ahci_priv), GFP_KERNEL); dpriv = devm_kzalloc(dev, sizeof(struct elphel_ahci_priv), GFP_KERNEL); Loading Loading @@ -166,6 +225,7 @@ static int elphel_drv_probe(struct platform_device *pdev) static int elphel_drv_remove(struct platform_device *pdev) static int elphel_drv_remove(struct platform_device *pdev) { { dev_info(&pdev->dev, "removing Elphel AHCI driver"); dev_info(&pdev->dev, "removing Elphel AHCI driver"); sysfs_remove_group(&pdev->dev.kobj, &dev_attr_root_group); ata_platform_remove_one(pdev); ata_platform_remove_one(pdev); return 0; return 0; Loading Loading @@ -231,6 +291,16 @@ static void elphel_qc_prep(struct ata_queued_cmd *qc) AHCI_CMD_TBL_AR_SZ, DMA_TO_DEVICE); AHCI_CMD_TBL_AR_SZ, DMA_TO_DEVICE); } } static DEVICE_ATTR(load_module, S_IWUSR | S_IWGRP, NULL, set_load_flag); static struct attribute *root_dev_attrs[] = { &dev_attr_load_module.attr, NULL }; static const struct attribute_group dev_attr_root_group = { .attrs = root_dev_attrs, .name = NULL, }; static struct ata_port_operations ahci_elphel_ops = { static struct ata_port_operations ahci_elphel_ops = { .inherits = &ahci_ops, .inherits = &ahci_ops, .port_start = elphel_port_start, .port_start = elphel_port_start, Loading
src/drivers/elphel/Kconfig +7 −0 Original line number Original line Diff line number Diff line Loading @@ -20,4 +20,11 @@ config ELPHEL393_INIT default y default y help help If unsure, say Y. If unsure, say Y. config ELPHEL393_EXTERNAL tristate "Compile some Elphel drivers as external modules" default m help If unsure, say Y. endmenu endmenu
src/drivers/elphel/Makefile +3 −0 Original line number Original line Diff line number Diff line Loading @@ -6,3 +6,6 @@ obj-$(CONFIG_ELPHEL393) += elphel393-pwr.o obj-$(CONFIG_ELPHEL393) += elphel393-mem.o obj-$(CONFIG_ELPHEL393) += elphel393-mem.o obj-$(CONFIG_ELPHELDRVONMICROZED) += elphel393-mem.o obj-$(CONFIG_ELPHELDRVONMICROZED) += elphel393-mem.o obj-$(CONFIG_ELPHEL393_INIT) += elphel393-init.o obj-$(CONFIG_ELPHEL393_INIT) += elphel393-init.o fpgajtag-y := fpgajtag353.o x393.o obj-$(CONFIG_ELPHEL393_EXTERNAL) += fpgajtag.o No newline at end of file
src/drivers/elphel/fpgajtag353.c 0 → 100644 +1400 −0 File added.Preview size limit exceeded, changes collapsed. Show changes