Skip to content

Commit 6d1fbfe

Browse files
committed
conf/p0soc: 1.update spi0 iomux and clk; 2.upadte dts node for spi dma mode.
Signed-off-by: guibing <guibing@nucleisys.com>
1 parent 0d08b47 commit 6d1fbfe

2 files changed

Lines changed: 59 additions & 3 deletions

File tree

conf/p0soc/nuclei_rv64imafdc.dts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,12 +597,16 @@
597597
compatible = "nuclei,spi0";
598598
reg = <0xf 0x9c200000 0x0 0x1000>;
599599
interrupt-parent = <&plic0>;
600-
interrupts = <26>;
600+
interrupts = <24>;
601601
num-cs = <1>;
602+
603+
dmas = <&acc_udma0 1 20>, <&acc_udma0 1 21>;
604+
dma-names = "tx", "rx";
605+
602606
#address-cells = <1>;
603607
#size-cells = <0>;
604608
clocks = <&hfclk>;
605-
status = "okay";
609+
status = "disabled";
606610

607611
flash@0 {
608612
compatible = "jedec,spi-nor";
@@ -692,14 +696,15 @@
692696
interrupt-parent = <&plic0>;
693697
interrupts = <1>;
694698
#mbox-cells = <1>;
699+
status = "disabled";
695700
};
696701

697702
rpmsg: rpmsg@7e100000{
698703
compatible = "nuclei,rpmsg";
699704
mboxes = <&idu 0>;
700705
reg = <0x0 0x7E100000 0x0 0x10000>;
701706
memory-region = <&rpmsg_dma_reserved>;
702-
status = "okay";
707+
status = "disabled";
703708
};
704709

705710
sysrst@f90030ff0 {

conf/p0soc/opensbi/customsoc.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,25 @@ static const struct fdt_match nuclei_customsoc_match[] = {
2626
#define NUCLEI_IOMUX_BASE 0xf9ca00000ULL
2727
#define NUCLEI_SYS_MISC_BASE 0xf9c880000ULL
2828

29+
30+
#define QSPI0_CS_0_HS_SEL 1
31+
#define QSPI0_DQ_0_HS_SEL 1
32+
#define QSPI0_DQ_1_HS_SEL 1
33+
#define QSPI0_SCK_HS_SEL 1
34+
#define QSPI0_SCK_IOF_OVAL 4
35+
#define QSPI0_SCK_IOF_IVAL 4
36+
#define QSPI0_CS_0_IOF_OVAL 0
37+
#define QSPI0_CS_0_IOF_IVAL 0
38+
#define QSPI0_DQ_0_IOF_OVAL 5
39+
#define QSPI0_DQ_0_IOF_IVAL 5
40+
#define QSPI0_DQ_1_IOF_OVAL 1
41+
#define QSPI0_DQ_1_IOF_IVAL 1
42+
43+
#define QSPI0_SCK_PAD_SEL 4
44+
#define QSPI0_CS_0_PAD_SEL 0
45+
#define QSPI0_DQ_0_PAD_SEL 5
46+
#define QSPI0_DQ_1_PAD_SEL 1
47+
2948
#define I2C0_SCL_IOF_IVAL 60
3049
#define I2C0_SCL_IOF_OVAL 60
3150
#define I2C0_SDA_IOF_IVAL 61
@@ -412,6 +431,16 @@ void config_iomux_i2c0(void)
412431
iomux_ls_iof_pullup_cfg(NUCLEI_IOMUX_BASE, I2C0_SDA_PAD_SEL, 0);
413432
}
414433

434+
void config_iomux_spi0(void)
435+
{
436+
iomux_ls_iof_oval_cfg(NUCLEI_IOMUX_BASE, QSPI0_SCK_IOF_OVAL, QSPI0_SCK_PAD_SEL, QSPI0_SCK_HS_SEL);
437+
iomux_ls_iof_oval_cfg(NUCLEI_IOMUX_BASE, QSPI0_CS_0_IOF_OVAL, QSPI0_CS_0_PAD_SEL, QSPI0_CS_0_HS_SEL);
438+
iomux_ls_iof_ival_cfg(NUCLEI_IOMUX_BASE, QSPI0_DQ_0_IOF_IVAL, QSPI0_DQ_0_PAD_SEL, QSPI0_DQ_0_HS_SEL);
439+
iomux_ls_iof_oval_cfg(NUCLEI_IOMUX_BASE, QSPI0_DQ_0_IOF_OVAL, QSPI0_DQ_0_PAD_SEL, QSPI0_DQ_0_HS_SEL);
440+
iomux_ls_iof_ival_cfg(NUCLEI_IOMUX_BASE, QSPI0_DQ_1_IOF_IVAL, QSPI0_DQ_1_PAD_SEL, QSPI0_DQ_1_HS_SEL);
441+
iomux_ls_iof_oval_cfg(NUCLEI_IOMUX_BASE, QSPI0_DQ_1_IOF_OVAL, QSPI0_DQ_1_PAD_SEL, QSPI0_DQ_1_HS_SEL);
442+
}
443+
415444
static int nuclei_customsoc_final_init(bool cold_boot,
416445
const struct fdt_match *match)
417446
{
@@ -518,6 +547,28 @@ static int nuclei_customsoc_final_init(bool cold_boot,
518547
val = readl((void *)(NUCLEI_SYS_MISC_BASE + 0x2c));
519548
val |= (1 << 0) | (1 << 2);
520549
writel(val, (void *)(NUCLEI_SYS_MISC_BASE + 0x2c));
550+
551+
config_iomux_spi0();
552+
/* enable spi0 clk */
553+
val = readl((void *)(NUCLEI_SYS_MISC_BASE + 0x40));
554+
val |= (1 << 28);
555+
writel(val, (void *)(NUCLEI_SYS_MISC_BASE + 0x40));
556+
/* reset spi0 */
557+
val = readl((void *)(NUCLEI_SYS_MISC_BASE + 0x20));
558+
val &= ~(1 << 28);
559+
writel(val, (void *)(NUCLEI_SYS_MISC_BASE + 0x20));
560+
val |= (1 << 28);
561+
writel(val, (void *)(NUCLEI_SYS_MISC_BASE + 0x20));
562+
/* spi0 bus clk 200/2=100M */
563+
val = readl((void *)(NUCLEI_SYS_MISC_BASE + 0x238));
564+
val &= ~0xff;
565+
val |= 1;
566+
writel(val, (void *)(NUCLEI_SYS_MISC_BASE + 0x238));
567+
/* spi0 kernel clk 200/2=100M */
568+
val = readl((void *)(NUCLEI_SYS_MISC_BASE + 0x23C));
569+
val &= ~0xff;
570+
val |= 1;
571+
writel(val, (void *)(NUCLEI_SYS_MISC_BASE + 0x23C));
521572
}
522573

523574
// Check mcfg_info.tee to see whether tee present

0 commit comments

Comments
 (0)