Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dpavlin
Created January 2, 2020 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpavlin/fa9e8976a2ad88c12b47abe852ecfd55 to your computer and use it in GitHub Desktop.
Save dpavlin/fa9e8976a2ad88c12b47abe852ecfd55 to your computer and use it in GitHub Desktop.
SaxonSoc GPIO I2C work-in-progress
# cd /klin/FPGA/saxonsoc/buildroot
diff --git a/board/spinal/saxon_ulx3s/linux.config b/board/spinal/saxon_ulx3s/linux.config
index 4608aeeb28..940cf271f7 100644
--- a/board/spinal/saxon_ulx3s/linux.config
+++ b/board/spinal/saxon_ulx3s/linux.config
@@ -88,3 +88,13 @@ CONFIG_MTD=y
CONFIG_MTD_SPI_NOR=y
CONFIG_MTD_M25P80=y
+# debug kernel
+CONFIG_DEBUG_FS=y
+CONFIG_DEBUG_KERNEL=y
+CONFIG_DEBUG_MISC=y
+
+# i2c-dev
+CONFIG_I2C=y
+CONFIG_I2C_CHARDEV=y
+CONFIG_I2C_GPIO=y
+
diff --git a/board/spinal/saxon_ulx3s/spinal_saxon_ulx3s.dts b/board/spinal/saxon_ulx3s/spinal_saxon_ulx3s.dts
index f6e1deb5ab..26af931521 100644
--- a/board/spinal/saxon_ulx3s/spinal_saxon_ulx3s.dts
+++ b/board/spinal/saxon_ulx3s/spinal_saxon_ulx3s.dts
@@ -82,7 +82,7 @@
gpioA: gpio@0 {
compatible = "spinal-lib,gpio-1.0";
interrupt-parent = <&plic>;
- ngpio = <24>;
+ ngpio = <31>;
interrupts = <4 5 6 7>;
reg = <0x000000 0x1000>;
gpio-controller;
@@ -170,6 +170,17 @@
};
};
};
+
+ gpioi2c1: i2c-1 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "i2c-gpio";
+ /* hardware/synthesis/ulx3s/ulx3s_v20_linux_uboot.lpf */
+ sda-gpios = <&gpioA 28 1 /* (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN) */>;
+ scl-gpios = <&gpioA 29 1 /* (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN) */>;
+ i2c-gpio,delay-us = <2>; /* ~100 kHz */
+ };
+
};
diff --git a/board/spinal/saxon_ulx3s/spinal_saxon_ulx3s_64.dts b/board/spinal/saxon_ulx3s/spinal_saxon_ulx3s_64.dts
index 37b087ab64..40278a01cd 100644
--- a/board/spinal/saxon_ulx3s/spinal_saxon_ulx3s_64.dts
+++ b/board/spinal/saxon_ulx3s/spinal_saxon_ulx3s_64.dts
@@ -82,7 +82,7 @@
gpioA: gpio@0 {
compatible = "spinal-lib,gpio-1.0";
interrupt-parent = <&plic>;
- ngpio = <24>;
+ ngpio = <31>;
interrupts = <4 5 6 7>;
reg = <0x000000 0x1000>;
gpio-controller;
# cd /klin/FPGA/saxonsoc/linux
# cd /klin/FPGA/saxonsoc/SaxonSoc
diff --git a/hardware/scala/saxon/board/ulx3s/Ulx3sLinuxUboot.scala b/hardware/scala/saxon/board/ulx3s/Ulx3sLinuxUboot.scala
index e553e10..b4a5796 100644
--- a/hardware/scala/saxon/board/ulx3s/Ulx3sLinuxUboot.scala
+++ b/hardware/scala/saxon/board/ulx3s/Ulx3sLinuxUboot.scala
@@ -126,7 +126,7 @@ object Ulx3sLinuxUbootSystem{
uartB.connectInterrupt(plic, 2)
gpioA.parameter load Gpio.Parameter(
- width = 24,
+ width = 32,
interrupt = List(0, 1, 2, 3)
)
gpioA.connectInterrupts(plic, 4)
diff --git a/hardware/synthesis/ulx3s/makefile b/hardware/synthesis/ulx3s/makefile
index c837b75..a3e6788 100644
--- a/hardware/synthesis/ulx3s/makefile
+++ b/hardware/synthesis/ulx3s/makefile
@@ -1,6 +1,6 @@
VERILOG = ../../netlist/Ulx3sLinuxUboot.v pll_linux.v
-IDCODE ?= 0x21111043 # 12f
+IDCODE ?= 0x41113043 # 12f
compile : bin/toplevel.bit
@@ -8,7 +8,7 @@ prog: bin/toplevel.bit
ujprog $<
generate:
- (cd ../../..; sbt "runMain saxon.board.ulx3s.Ulx3sLinuxUboot")
+ (cd ../../..; sbt "runMain saxon.board.ulx3s.Ulx3sLinuxUboot 64")
sim:
(cd ../../..; sbt "runMain saxon.board.ulx3s.Ulx3sLinuxUbootSystemSim")
@@ -26,7 +26,7 @@ bin/toplevel.config: bin/toplevel.json
--json $< \
--textcfg $@ \
--lpf ulx3s_v20_linux_uboot.lpf \
- --25k \
+ --85k \
--freq 50 \
--package CABGA381 \
--lpf-allow-unconstrained
diff --git a/hardware/synthesis/ulx3s/ulx3s_v20_linux_uboot.lpf b/hardware/synthesis/ulx3s/ulx3s_v20_linux_uboot.lpf
index 0661d75..3d0d840 100644
--- a/hardware/synthesis/ulx3s/ulx3s_v20_linux_uboot.lpf
+++ b/hardware/synthesis/ulx3s/ulx3s_v20_linux_uboot.lpf
@@ -307,8 +307,8 @@ LOCATE COMP "gpdi_dn[3]" SITE "B18"; # Clock -
LOCATE COMP "gpdi_ethp" SITE "A19"; # Ethernet +
LOCATE COMP "gpdi_ethn" SITE "B20"; # Ethernet -
LOCATE COMP "gpdi_cec" SITE "A18";
-LOCATE COMP "gpdi_sda" SITE "B19"; # I2C shared with RTC
-LOCATE COMP "gpdi_scl" SITE "E12"; # I2C shared with RTC C12->E12
+LOCATE COMP "system_gpioA_gpio[28]" SITE "B19"; # XXX gpdi_sda I2C shared with RTC
+LOCATE COMP "system_gpioA_gpio[29]" SITE "E12"; # XXX gpdi_scl I2C shared with RTC C12->E12
IOBUF PORT "gpdi_dp[0]" IO_TYPE=LVCMOS33D DRIVE=4;
IOBUF PORT "gpdi_dn[0]" IO_TYPE=LVCMOS33D DRIVE=4;
IOBUF PORT "gpdi_dp[1]" IO_TYPE=LVCMOS33D DRIVE=4;
@@ -320,8 +320,8 @@ IOBUF PORT "gpdi_dn[3]" IO_TYPE=LVCMOS33D DRIVE=4;
IOBUF PORT "gpdi_ethp" IO_TYPE=LVCMOS33D DRIVE=4;
IOBUF PORT "gpdi_ethn" IO_TYPE=LVCMOS33D DRIVE=4;
IOBUF PORT "gpdi_cec" PULLMODE=UP IO_TYPE=LVCMOS33 DRIVE=4;
-IOBUF PORT "gpdi_sda" PULLMODE=UP IO_TYPE=LVCMOS33 DRIVE=4;
-IOBUF PORT "gpdi_scl" PULLMODE=UP IO_TYPE=LVCMOS33 DRIVE=4;
+IOBUF PORT "system_gpioA_gpio[28]" PULLMODE=UP IO_TYPE=LVCMOS33 DRIVE=4;
+IOBUF PORT "system_gpioA_gpio[29]" PULLMODE=UP IO_TYPE=LVCMOS33 DRIVE=4;
# GPIO (default single-ended) "gpio", "ram", "gpdi" sheet
# Physical connector pins:
# cd /klin/FPGA/saxonsoc/u-boot
# cd /klin/FPGA/saxonsoc/verilator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment