Add initialization of clock for StarFive JH7110 SoC
Subsystems (4)
v6 cover Add initialization of clock for StarFive JH7110 SoC
Hi,
This patchset adds initial rudimentary support for the StarFive Quad SPI controller driver. And this driver will be used in StarFive's VisionFive 2 board. In 6.4, the QSPI_AHB and QSPI_APB clocks changed from the default ON state to the default OFF state, so these clocks need to be enabled in the driver.At the same time, dts patch is added to this series.
Changes v5->v4:
- Rebased to v6.4rc4.
- Dropped the Reported-by tags.
Changes v4->v5:
- Rebased to v6.5rc2.
- Changed the way to initialization the clocks.
- Changed the layout for the SPI flash.
Changes v3->v4:
- Added minItems for clocks.
- Added clock names property.
- Fixed formatting issues.
Changes v2->v3:
- Rebased to v6.4rc6.
- Renamed the clock names.
- Changed the variable definition type.
Changes v1->v2:
- Renamed the clock names.
- Specified a different array of clocks.
- Used clk_bulk_ APIs.
The patch series is based on v6.5rc4.
William Qiu (3):
dt-bindings: qspi: cdns,qspi-nor: Add clocks for StarFive JH7110 SoC
spi: cadence-quadspi: Add clock configuration for StarFive JH7110 QSPI
riscv: dts: starfive: Add QSPI controller node for StarFive JH7110 SoC
.../bindings/spi/cdns,qspi-nor.yaml | 12 +++- .../jh7110-starfive-visionfive-2.dtsi | 36 ++++++++++ arch/riscv/boot/dts/starfive/jh7110.dtsi | 19 ++++++ drivers/spi/spi-cadence-quadspi.c | 67 +++++++++++++++++++ 4 files changed, 133 insertions(+), 1 deletion(-)
--
2.34.1
PATCH v6 1/3 dt-bindings: qspi: cdns,qspi-nor: Add clocks for StarFive JH7110 SoC
The QSPI controller needs three clock items to work properly on StarFive JH7110 SoC, so there is need to change the maxItems's value to 3.
--- .../devicetree/bindings/spi/cdns,qspi-nor.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml +11 -1
@@ -86,7 +86,17 @@ properties: maxItems: 1 clocks: - maxItems: 1 + minItems: 1 + maxItems: 3 + + clock-names: + oneOf: + - items: + - const: ref + - items: + - const: ref + - const: ahb + - const: apb cdns,fifo-depth: description:
Signature · 1 line
2.34.1
PATCH v6 2/3 spi: cadence-quadspi: Add clock configuration for StarFive JH7110 QSPI
In reply to William QiuAdd JH7110's clock initialization code to the driver.
--- drivers/spi/spi-cadence-quadspi.c | 67 +++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+)
drivers/spi/spi-cadence-quadspi.c +67 -0
@@ -47,6 +47,12 @@#define CQSPI_OP_WIDTH (part) ((part).nbytes ? ilog2((part).buswidth) : 0) +enum { +CLK_QSPI_APB =0 , +CLK_QSPI_AHB , +CLK_QSPI_NUM , +}; +struct cqspi_st ;struct cqspi_flash_pdata {
@@ -64,6 +70,7 @@ struct cqspi_st {struct platform_device *pdev;struct spi_master *master;struct clk *clk; +struct clk *clks[CLK_QSPI_NUM ];unsigned int sclk;void __iomem *iobase;
@@ -92,6 +99,8 @@ struct cqspi_st {bool wr_completion;bool slow_sram;bool apb_ahb_hazard; + +bool is_jh7110;/* Flag for StarFive JH7110 SoC */ };struct cqspi_driver_platdata {
@@ -100,6 +109,8 @@ struct cqspi_driver_platdata {int (*indirect_read_dma)(struct cqspi_flash_pdata *f_pdata,u_char *rxbuf,loff_t from_addr,size_t n_rx);u32 (*get_dma_status)(struct cqspi_st *cqspi); +int (*jh7110_clk_init)(struct platform_device *pdev, +struct cqspi_st *cqspi); };/* Operation timeout value */
@@ -1630,6 +1641,51 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi)return 0 ; } +static int cqspi_jh7110_clk_init (struct platform_device *pdev,struct cqspi_st *cqspi) +{ +static struct clk_bulk_data qspiclk[] = { + { .id ="apb" }, + { .id ="ahb" }, + }; + +int ret =0 ; + + ret =devm_clk_bulk_get (&pdev->dev,ARRAY_SIZE (qspiclk), qspiclk); +if (ret) { +dev_err (&pdev->dev,"%s: failed to get qspi clocks\n" , __func__); +return ret; + } + + cqspi->clks[CLK_QSPI_APB ] = qspiclk[0 ].clk; + cqspi->clks[CLK_QSPI_AHB ] = qspiclk[1 ].clk; + + ret =clk_prepare_enable (cqspi->clks[CLK_QSPI_APB ]); +if (ret) { +dev_err (&pdev->dev,"%s: failed to enable CLK_QSPI_APB\n" , __func__); +return ret; + } + + ret =clk_prepare_enable (cqspi->clks[CLK_QSPI_AHB ]); +if (ret) { +dev_err (&pdev->dev,"%s: failed to enable CLK_QSPI_AHB\n" , __func__); + goto disable_apb_clk; + } + + cqspi->is_jh7110 = true; + +return 0 ; + +disable_apb_clk: +clk_disable_unprepare (cqspi->clks[CLK_QSPI_APB ]); + +return ret; +} + +static void cqspi_jh7110_disable_clk (struct platform_device *pdev,struct cqspi_st *cqspi) +{ +clk_disable_unprepare (cqspi->clks[CLK_QSPI_AHB ]); +clk_disable_unprepare (cqspi->clks[CLK_QSPI_APB ]); +}static int cqspi_probe (struct platform_device *pdev) {const struct cqspi_driver_platdata *ddata;
@@ -1655,6 +1711,7 @@ static int cqspi_probe(struct platform_device *pdev) cqspi->pdev = pdev; cqspi->master = master; + cqspi->is_jh7110 = false;platform_set_drvdata (pdev, cqspi);/* Obtain configuration from OF. */
@@ -1766,6 +1823,12 @@ static int cqspi_probe(struct platform_device *pdev)if (ddata->quirks &CQSPI_NEEDS_APB_AHB_HAZARD_WAR ) cqspi->apb_ahb_hazard = true; +if (ddata->jh7110_clk_init) { + ret =cqspi_jh7110_clk_init (pdev, cqspi); +if (ret) + goto probe_clk_failed; + } +if (of_device_is_compatible (pdev->dev.of_node,"xlnx,versal-ospi-1.0" )) { ret =dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 ));
@@ -1830,6 +1893,9 @@ static void cqspi_remove(struct platform_device *pdev)clk_disable_unprepare (cqspi->clk); +if (cqspi->is_jh7110) +cqspi_jh7110_disable_clk (pdev, cqspi); +pm_runtime_put_sync (&pdev->dev);pm_runtime_disable (&pdev->dev); }
@@ -1897,6 +1963,7 @@ static const struct cqspi_driver_platdata versal_ospi = {static const struct cqspi_driver_platdata jh7110_qspi = { .quirks =CQSPI_DISABLE_DAC_MODE , + .jh7110_clk_init = cqspi_jh7110_clk_init, };static const struct cqspi_driver_platdata pensando_cdns_qspi = {
Signature · 1 line
2.34.1
PATCH v6 3/3 riscv: dts: starfive: Add QSPI controller node for StarFive JH7110 SoC
In reply to William QiuAdd the quad spi controller node for the StarFive JH7110 SoC.
--- .../jh7110-starfive-visionfive-2.dtsi | 36 +++++++++++++++++++ arch/riscv/boot/dts/starfive/jh7110.dtsi | 19 ++++++++++ 2 files changed, 55 insertions(+)
arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2.dtsi +36 -0
@@ -143,6 +143,42 @@ &i2c6 { status = "okay"; }; +&qspi { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + nor_flash: flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + cdns,read-delay = <5>; + spi-max-frequency = <12000000>; + cdns,tshsl-ns = <1>; + cdns,tsd2d-ns = <1>; + cdns,tchsh-ns = <1>; + cdns,tslch-ns = <1>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + spl@0 { + reg = <0x0 0x80000>; + }; + uboot-env@f0000 { + reg = <0xf0000 0x10000>; + }; + uboot@100000 { + reg = <0x100000 0x400000>; + }; + reserved-data@600000 { + reg = <0x600000 0x1000000>; + }; + }; + }; +}; + &sysgpio { i2c0_pins: i2c0-0 { i2c-pins {
arch/riscv/boot/dts/starfive/jh7110.dtsi +19 -0
@@ -473,6 +473,25 @@ i2c6: i2c@12060000 { status = "disabled"; }; + qspi: spi@13010000 { + compatible = "starfive,jh7110-qspi", "cdns,qspi-nor"; + reg = <0x0 0x13010000 0x0 0x10000>, + <0x0 0x21000000 0x0 0x400000>; + interrupts = <25>; + clocks = <&syscrg JH7110_SYSCLK_QSPI_REF>, + <&syscrg JH7110_SYSCLK_QSPI_AHB>, + <&syscrg JH7110_SYSCLK_QSPI_APB>; + clock-names = "ref", "ahb", "apb"; + resets = <&syscrg JH7110_SYSRST_QSPI_APB>, + <&syscrg JH7110_SYSRST_QSPI_AHB>, + <&syscrg JH7110_SYSRST_QSPI_REF>; + reset-names = "qspi", "qspi-ocp", "rstc_ref"; + cdns,fifo-depth = <256>; + cdns,fifo-width = <4>; + cdns,trigger-address = <0x0>; + status = "disabled"; + }; + syscrg: clock-controller@13020000 { compatible = "starfive,jh7110-syscrg"; reg = <0x0 0x13020000 0x0 0x10000>;
Signature · 1 line
2.34.1
Mark Brown
maintainerRe: (subset) [PATCH v6 0/3] Add initialization of clock for StarFive JH7110 SoC
In reply to William QiuQuoted 8 lines · William Qiu
This patchset adds initial rudimentary support for the StarFive Quad SPI controller driver. And this driver will be used in StarFive's VisionFive 2 board. In 6.4, the
QSPI_AHBandQSPI_APBclocks changed from the default ON state to the default OFF state, so these clocks need to be enabled in the driver.At the same time, dts patch is added to this series.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/3] dt-bindings: qspi: cdns,qspi-nor: Add clocks for StarFive JH7110 SoC
commit: 0d2b6a1b8515204924b9174ae0135e1f4ff29b21
[2/3] spi: cadence-quadspi: Add clock configuration for StarFive JH7110 QSPI
commit: 33f1ef6d4eb6bca726608ed939c9fd94d96ceefdAll being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: (subset) [PATCH v6 0/3] Add initialization of clock for StarFive JH7110 SoC
In reply to William QiuFrom: Conor Dooley <[email protected]>
Quoted 8 lines · William Qiu
This patchset adds initial rudimentary support for the StarFive Quad SPI controller driver. And this driver will be used in StarFive's VisionFive 2 board. In 6.4, the
QSPI_AHBandQSPI_APBclocks changed from the default ON state to the default OFF state, so these clocks need to be enabled in the driver.At the same time, dts patch is added to this series.[...]
Applied to riscv-dt-for-next, thanks!
[3/3] riscv: dts: starfive: Add QSPI controller node for StarFive JH7110 SoC
https://git.kernel.org/conor/c/fc3d49f970d2
Thanks,
Conor.