driver: fpga: xilinx-selectmap: add csi and rdwr support
Subsystems (2)
PATCH v2 1/1 driver: fpga: xilinx-selectmap: add csi and rdwr support
Add csi_b and rdwr pin support for the xilinx,selectmap driver.
In current driver the pins are configured from DTS and set to GPIOD_OUT_HIGH. This works in case you have one FPGA.
Extend this to really implement csi_b and rdwr pin function in driver, so it works with more than one FPGA.
Tested on AM625 based board with 2 FPGAs connected to GPMC.
---
Changes in v2:
- add comments from Michal
- skip check if gpio descriptor variables csi_b/rdwr_b are valid, as validate_desc() checks this in gpiod_set_value() call.
- initialize the gpio variables csi_b/rdwr_b immediately with the return value from devm_gpiod_get_optional(), so we can drop local gpio variable at all
drivers/fpga/xilinx-selectmap.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
drivers/fpga/xilinx-selectmap.c +16 -7
@@ -19,6 +19,8 @@struct xilinx_selectmap_conf {struct xilinx_fpga_core core;void __iomem *base; +struct gpio_desc *csi_b; +struct gpio_desc *rdwr_b; };#define to_xilinx_selectmap_conf (obj) \
@@ -30,16 +32,21 @@ static int xilinx_selectmap_write(struct xilinx_fpga_core *core,struct xilinx_selectmap_conf *conf =to_xilinx_selectmap_conf (core);size_t i; +gpiod_set_value (conf->csi_b,GPIOD_OUT_HIGH ); +gpiod_set_value (conf->rdwr_b,GPIOD_OUT_HIGH ); +for (i =0 ; i < count; ++i)writeb (buf[i], conf->base); +gpiod_set_value (conf->rdwr_b,GPIOD_OUT_LOW ); +gpiod_set_value (conf->csi_b,GPIOD_OUT_LOW ); +return 0 ; }static int xilinx_selectmap_probe (struct platform_device *pdev) {struct xilinx_selectmap_conf *conf; -struct gpio_desc *gpio;void __iomem *base; conf =devm_kzalloc (&pdev->dev,sizeof (*conf),GFP_KERNEL );
@@ -56,15 +63,17 @@ static int xilinx_selectmap_probe(struct platform_device *pdev) conf->base = base;/* CSI_B is active low */ - gpio =devm_gpiod_get_optional (&pdev->dev,"csi" ,GPIOD_OUT_HIGH ); -if (IS_ERR (gpio)) -return dev_err_probe (&pdev->dev,PTR_ERR (gpio), + conf->csi_b =devm_gpiod_get_optional (&pdev->dev,"csi" , +GPIOD_OUT_LOW ); +if (IS_ERR (conf->csi_b)) +return dev_err_probe (&pdev->dev,PTR_ERR (conf->csi_b),"Failed to get CSI_B gpio\n" );/* RDWR_B is active low */ - gpio =devm_gpiod_get_optional (&pdev->dev,"rdwr" ,GPIOD_OUT_HIGH ); -if (IS_ERR (gpio)) -return dev_err_probe (&pdev->dev,PTR_ERR (gpio), + conf->rdwr_b =devm_gpiod_get_optional (&pdev->dev,"rdwr" , +GPIOD_OUT_LOW ); +if (IS_ERR (conf->rdwr_b)) +return dev_err_probe (&pdev->dev,PTR_ERR (conf->rdwr_b),"Failed to get RDWR_B gpio\n" );return xilinx_core_probe (&conf->core);
---
base-commit: 58717b2a1365d06c8c64b72aa948541b53fe31eb
Signature · 1 line
2.55.0
Michal Simek
maintainerQuoted 38 lines · Heiko Schocher
Add
csi_band rdwr pin support for the xilinx,selectmap driver.In current driver the pins are configured from DTS and set to
GPIOD_OUT_HIGH. This works in case you have one FPGA.Extend this to really implement
csi_band rdwr pin function in driver, so it works with more than one FPGA.Tested on AM625 based board with 2 FPGAs connected to GPMC.
Signed-off-by Heiko Schocher <[email protected]>---
Changes in v2:
- add comments from Michal
- skip check if gpio descriptor variables csi_b/rdwr_b are valid, asvalidate_desc()checks this ingpiod_set_value()call.
- initialize the gpio variables csi_b/rdwr_b immediately with the return value fromdevm_gpiod_get_optional(), so we can drop local gpio variable at alldrivers/fpga/xilinx-selectmap.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)drivers/fpga/xilinx-selectmap.c +2
-0@@ -19,6 +19,8 @@struct xilinx_selectmap_conf {struct xilinx_fpga_core core;void __iomem *base; +struct gpio_desc *csi_b; +struct gpio_desc *rdwr_b; };#define to_xilinx_selectmap_conf (obj) \
drivers/fpga/xilinx-selectmap.c static int xilinx_selectmap_write(struct xilinx_fpga_core *core, · line 36
Quoted 5 lines
drivers/fpga/xilinx-selectmap.c +2
-0@@ -30,16 +32,21 @@ static int xilinx_selectmap_write(struct xilinx_fpga_core *core,struct xilinx_selectmap_conf *conf =to_xilinx_selectmap_conf (core);size_t i; +gpiod_set_value (conf->csi_b,GPIOD_OUT_HIGH ); +gpiod_set_value (conf->rdwr_b,GPIOD_OUT_HIGH );
I think GPIOD_OUT_HIGH/LOW is wrong in this context.
If you do "git grep gpiod_set_value" you will see that values are 0/1
Thanks,
Michal
Hello Michal,
Quoted 39 lines · Michal Simek
Quoted 36 lines · Heiko Schocher
Add
csi_band rdwr pin support for the xilinx,selectmap driver.In current driver the pins are configured from DTS and set to
GPIOD_OUT_HIGH. This works in case you have one FPGA.Extend this to really implement
csi_band rdwr pin function in driver, so it works with more than one FPGA.Tested on AM625 based board with 2 FPGAs connected to GPMC.
Signed-off-by Heiko Schocher <[email protected]>---
Changes in v2:
- add comments from Michal
- skip check if gpio descriptor variables csi_b/rdwr_b are valid, asvalidate_desc()checks this ingpiod_set_value()call.
- initialize the gpio variables csi_b/rdwr_b immediately with the return value fromdevm_gpiod_get_optional(), so we can drop local gpio variable at all
drivers/fpga/xilinx-selectmap.c| 23 ++++++++++++++++-------1 file changed, 16 insertions(+), 7 deletions(-)drivers/fpga/xilinx-selectmap.c +2
-0@@ -19,6 +19,8 @@ struct xilinx_selectmap_conf { struct xilinx_fpga_core core; void __iomem *base; + struct gpio_desc *csi_b; + struct gpio_desc *rdwr_b; }; #define to_xilinx_selectmap_conf(obj) \
Quoted 8 lines
drivers/fpga/xilinx-selectmap.c static int xilinx_selectmap_write(struct xilinx_fpga_core *core, · line 35
Quoted 5 lines
drivers/fpga/xilinx-selectmap.c +2
-0@@ -30,16 +32,21 @@ static int xilinx_selectmap_write(struct xilinx_fpga_core *core, struct xilinx_selectmap_conf *conf = to_xilinx_selectmap_conf(core); size_t i; + gpiod_set_value(conf->csi_b, GPIOD_OUT_HIGH); + gpiod_set_value(conf->rdwr_b, GPIOD_OUT_HIGH);I think GPIOD_OUT_HIGH/LOW is wrong in this context.
If you do "git grepgpiod_set_value" you will see that values are 0/1
I will change it!
Hmm.. while thinking about it... CSI_B and RDWR_B signals are defined as active low...
Doesn't it make more sense to use here
gpiod_set_raw_value()
instead, which sets the physical levels?
Thanks!
bye,
Heiko
Quoted 3 lines
Thanks,
Michal
Signature · 5 lines
Nabla Software Engineering HRB 40522 Augsburg Phone: +49 821 45592596 E-Mail: [email protected] Geschäftsführer : Stefano Babic
Quoted 7 lines · Heiko Schocher
Add
csi_band rdwr pin support for the xilinx,selectmap driver.In current driver the pins are configured from DTS and set to
GPIOD_OUT_HIGH. This works in case you have one FPGA.Extend this to really implement
csi_band rdwr pin function in driver, so it works with more than one FPGA.
Please help specify in changelog: what do csi_b, rdwr pins do? Why they now work with one FPGA but not with 2 FPGAs? How do you select which FPGA to reprogram? thanks.
Thanks,
Yilun
Hello Yilun,
Quoted 6 lines · Xu Yilun
Quoted 5 lines · Heiko Schocher
Add
csi_band rdwr pin support for the xilinx,selectmap driver.In current driver the pins are configured from DTS and set to
GPIOD_OUT_HIGH. This works in case you have one FPGA.
Quoted 6 lines
Quoted 2 lines
Extend this to really implement
csi_band rdwr pin function in driver, so it works with more than one FPGA.Please help specify in changelog: what do
csi_b, rdwr pins do? Why they now work with one FPGA but not with 2 FPGAs? How do you select which FPGA to reprogram? thanks.
I will try to add this. You find some hint here:
Documentation/devicetree/bindings/fpga/xlnx,fpga-selectmap.yaml
Thanks!
bye,
Heiko
Quoted 4 lines
Thanks,
Yilun
Signature · 5 lines
Nabla Software Engineering HRB 40522 Augsburg Phone: +49 821 45592596 E-Mail: [email protected] Geschäftsführer : Stefano Babic
Michal Simek
maintainerQuoted 51 lines · Heiko Schocher
Hello Michal,
Quoted 40 lines · Michal Simek
Quoted 37 lines · Heiko Schocher
Add
csi_band rdwr pin support for the xilinx,selectmap driver.In current driver the pins are configured from DTS and set to
GPIOD_OUT_HIGH. This works in case you have one FPGA.Extend this to really implement
csi_band rdwr pin function in driver, so it works with more than one FPGA.Tested on AM625 based board with 2 FPGAs connected to GPMC.
Signed-off-by Heiko Schocher <[email protected]>---
Changes in v2:
- add comments from Michal
- skip check if gpio descriptor variables csi_b/rdwr_b are valid, asvalidate_desc()checks this ingpiod_set_value()call.
- initialize the gpio variables csi_b/rdwr_b immediately with the return value fromdevm_gpiod_get_optional(), so we can drop local gpio variable at all
drivers/fpga/xilinx-selectmap.c| 23 ++++++++++++++++-------1 file changed, 16 insertions(+), 7 deletions(-)drivers/fpga/xilinx-selectmap.c +2
-0@@ -19,6 +19,8 @@ struct xilinx_selectmap_conf { struct xilinx_fpga_core core; void __iomem *base; + struct gpio_desc *csi_b; + struct gpio_desc *rdwr_b; }; #define to_xilinx_selectmap_conf(obj) \@@ -30,16 +32,21 @@ static int xilinx_selectmap_write(struct xilinx_fpga_coreQuoted 8 lines
drivers/fpga/xilinx-selectmap.c static int xilinx_selectmap_write(struct xilinx_fpga_core *core, · line 36
Quoted 5 lines
drivers/fpga/xilinx-selectmap.c +2
-0*core, struct xilinx_selectmap_conf *conf = to_xilinx_selectmap_conf(core); size_t i; + gpiod_set_value(conf->csi_b, GPIOD_OUT_HIGH); + gpiod_set_value(conf->rdwr_b, GPIOD_OUT_HIGH);I think GPIOD_OUT_HIGH/LOW is wrong in this context.
If you do "git grepgpiod_set_value" you will see that values are 0/1
Quoted 4 lines
I will change it!
Hmm.. while thinking about it...
CSI_BandRDWR_Bsignals are defined as active low...
I have never worked with this driver but values here should be 0 or 1. And if that means active low/high is said via DT.
GPIOD_OUT_LOW below should mean that you are starting in deassert state (if it is low/high is coming from DT). And before write you assert that line and deassert after it.
Thanks,
Michal
Hello Michal,
Quoted 53 lines · Michal Simek
Quoted 50 lines · Heiko Schocher
Hello Michal,
Quoted 47 lines · Michal Simek
Quoted 37 lines · Heiko Schocher
Add
csi_band rdwr pin support for the xilinx,selectmap driver.In current driver the pins are configured from DTS and set to
GPIOD_OUT_HIGH. This works in case you have one FPGA.Extend this to really implement
csi_band rdwr pin function in driver, so it works with more than one FPGA.Tested on AM625 based board with 2 FPGAs connected to GPMC.
Signed-off-by Heiko Schocher <[email protected]>---
Changes in v2:
- add comments from Michal
- skip check if gpio descriptor variables csi_b/rdwr_b are valid, asvalidate_desc()checks this ingpiod_set_value()call.
- initialize the gpio variables csi_b/rdwr_b immediately with the return value fromdevm_gpiod_get_optional(), so we can drop local gpio variable at all
drivers/fpga/xilinx-selectmap.c| 23 ++++++++++++++++-------1 file changed, 16 insertions(+), 7 deletions(-)drivers/fpga/xilinx-selectmap.c +2
-0@@ -19,6 +19,8 @@ struct xilinx_selectmap_conf { struct xilinx_fpga_core core; void __iomem *base; + struct gpio_desc *csi_b; + struct gpio_desc *rdwr_b; }; #define to_xilinx_selectmap_conf(obj) \drivers/fpga/xilinx-selectmap.c static int xilinx_selectmap_write(struct xilinx_fpga_core *core, · line 35
Quoted 4 lines
drivers/fpga/xilinx-selectmap.c +2
-0@@ -30,16 +32,21 @@ static int xilinx_selectmap_write(struct xilinx_fpga_core *core, struct xilinx_selectmap_conf *conf = to_xilinx_selectmap_conf(core); size_t i; + gpiod_set_value(conf->csi_b, GPIOD_OUT_HIGH); + gpiod_set_value(conf->rdwr_b, GPIOD_OUT_HIGH);I think GPIOD_OUT_HIGH/LOW is wrong in this context.
If you do "git grepgpiod_set_value" you will see that values are 0/1
Quoted 8 lines
Quoted 4 lines
I will change it!
Hmm.. while thinking about it...
CSI_BandRDWR_Bsignals are defined as active low...I have never worked with this driver but values here should be 0 or 1. And if that means active low/high is said via DT.
GPIOD_OUT_LOWbelow should mean that you are starting in deassert state (if it is low/high is coming from DT). And before write you assert that line and deassert after it.
Fine for me, I rework it, thanks!
bye,
Heiko
Quoted 5 lines
Thanks,
Michal
Signature · 5 lines
Nabla Software Engineering HRB 40522 Augsburg Phone: +49 821 45592596 E-Mail: [email protected] Geschäftsführer : Stefano Babic