Skip to content

Commit

Permalink
add bitbang i2c5 & bitbang spi4
Browse files Browse the repository at this point in the history
  • Loading branch information
0x754C committed May 15, 2024
1 parent 20a606b commit 9af3db7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@
};
};

&spi0 {
status = "okay";
};

&spi1 {
status = "okay";
};
Expand All @@ -125,6 +129,10 @@
status = "okay";
};

&spi3 {
status = "okay";
};

&dac {
status = "okay";
/delete-property/ mute-gpio-r;
Expand All @@ -145,6 +153,29 @@
/ {
model = "LicheeRv Nano";

spi4: spi4@gpio {
compatible = "spi-gpio";
sck-gpio = <&porta 22 0>;
miso-gpio = <&porta 23 0>;
mosi-gpio = <&porta 25 0>;
cs-gpio = <&porta 24 0>;
num-chipselects = <1>;
status = "okay";

spidev@0 {
compatible = "spidev";
reg = <0>;
};
};

i2c5: i2c5@gpio {
compatible = "i2c-gpio";
scl-gpios = <&porta 15 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
sda-gpios = <&porta 27 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
i2c-gpio,delay-us = <5>;
status = "okay";
};

gpio-keys {
compatible = "gpio-keys";
key-user {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ CONFIG_I2C=y
CONFIG_I2C_CHARDEV=y
CONFIG_I2C_MUX=y
CONFIG_I2C_DESIGNWARE_PLATFORM=y
CONFIG_I2C_GPIO=y
# CONFIG_PTP_1588_CLOCK is not set
CONFIG_PINCTRL=y
CONFIG_CVITEK_PINCTRL_CV1835=y
Expand Down
10 changes: 10 additions & 0 deletions build/boards/sg200x/sg2002_licheervnano_sd/u-boot/cvi_board_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ int cvi_board_init(void)
mmio_write_32(0x05027078, 0x11);// Unlock PWR_GPIO[3]
mmio_write_32(0x0502707c, 0x11);// Unlock PWR_GPIO[4]

// bitbang i2c
mmio_write_32(0x0300103C, 0x03); // GPIOA 15 GPIO_MODE
mmio_write_32(0x03001058, 0x03); // GPIOA 27 GPIO_MODE

// bitbang spi
mmio_write_32(0x03001060, 0x03); // GPIOA 24 GPIO_MODE
mmio_write_32(0x0300105C, 0x03); // GPIOA 23 GPIO_MODE
mmio_write_32(0x03001054, 0x03); // GPIOA 25 GPIO_MODE
mmio_write_32(0x03001050, 0x03); // GPIOA 22 GPIO_MODE

// wait hardware bootup
suck_loop(50);
user_led_off();
Expand Down
3 changes: 3 additions & 0 deletions linux_5.10/drivers/i2c/i2c-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#define I2C2 "i2c@04020000"
#define I2C3 "i2c@04030000"
#define I2C4 "i2c@04040000"
#define I2C5 "i2c5@gpio"
#endif

/*
Expand Down Expand Up @@ -680,6 +681,8 @@ static int i2cdev_attach_adapter(struct device *dev, void *dummy)
adap->i2c_idx = 3;
if (!strcmp(adap->dev.of_node->full_name, I2C4))
adap->i2c_idx = 4;
if (!strcmp(adap->dev.of_node->full_name, I2C5))
adap->i2c_idx = 5;

dev_set_name(&i2c_dev->dev, "i2c-%d", adap->i2c_idx);
#else
Expand Down

0 comments on commit 9af3db7

Please sign in to comment.