Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIM3U support #57871

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions boards/arm/gardena_rm_sim3u/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2023 GARDENA GmbH
#
# SPDX-License-Identifier: Apache-2.0

zephyr_library()
zephyr_library_sources(board.c)
8 changes: 8 additions & 0 deletions boards/arm/gardena_rm_sim3u/Kconfig.board
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2023 GARDENA GmbH
#
# SPDX-License-Identifier: Apache-2.0

config BOARD_GARDENA_RM_SIM3U
bool "GARDENA SIM3U radio module"
depends on SOC_SERIES_SIM3U
select SOC_PART_NUMBER_SIM3U167_B_GM
10 changes: 10 additions & 0 deletions boards/arm/gardena_rm_sim3u/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2023 GARDENA GmbH
#
# SPDX-License-Identifier: Apache-2.0

if BOARD_GARDENA_RM_SIM3U

config BOARD
default "gardena_rm_sim3u"

endif # BOARD_GARDENA_RM_SIM3U
106 changes: 106 additions & 0 deletions boards/arm/gardena_rm_sim3u/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* Copyright (c) 2023 GARDENA GmbH
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/drivers/gpio.h>
#include <zephyr/init.h>

static const struct gpio_dt_spec diversity_mode_gpio =
GPIO_DT_SPEC_GET(DT_NODELABEL(gardena_antenna), diversity_mode_gpios);
static const struct gpio_dt_spec diversity_state_gpio =
GPIO_DT_SPEC_GET(DT_NODELABEL(gardena_antenna), diversity_state_gpios);
static const struct gpio_dt_spec antenna_control_gpio =
GPIO_DT_SPEC_GET(DT_NODELABEL(gardena_antenna), antenna_control_gpios);
static const struct gpio_dt_spec antenna_input_gpio =
GPIO_DT_SPEC_GET(DT_NODELABEL(gardena_antenna), antenna_input_gpios);

struct led_mirror {
struct gpio_dt_spec source;
struct gpio_dt_spec destination;
struct gpio_callback callback;
};

static struct led_mirror led_mirrors[] = {
{
.source = GPIO_DT_SPEC_GET(DT_NODELABEL(gardena_antenna), led_red_input_gpios),
.destination = GPIO_DT_SPEC_GET(DT_NODELABEL(led_red), gpios),
},
{
.source = GPIO_DT_SPEC_GET(DT_NODELABEL(gardena_antenna), led_green_input_gpios),
.destination = GPIO_DT_SPEC_GET(DT_NODELABEL(led_green), gpios),
},
{
.source = GPIO_DT_SPEC_GET(DT_NODELABEL(gardena_antenna), led_blue_input_gpios),
.destination = GPIO_DT_SPEC_GET(DT_NODELABEL(led_blue), gpios),
},
};

static void led_mirror_callback_handler(const struct device *port, struct gpio_callback *cb,
gpio_port_pins_t pins)
{
ARG_UNUSED(port);
ARG_UNUSED(pins);

struct led_mirror *led_mirror = CONTAINER_OF(cb, struct led_mirror, callback);

gpio_pin_set_dt(&led_mirror->destination, gpio_pin_get_dt(&led_mirror->source));
}

static int board_init(void)
{
if (!device_is_ready(diversity_mode_gpio.port)) {
return -ENODEV;
}
if (!device_is_ready(diversity_state_gpio.port)) {
return -ENODEV;
}
if (!device_is_ready(antenna_control_gpio.port)) {
return -ENODEV;
}
if (!device_is_ready(antenna_input_gpio.port)) {
return -ENODEV;
}

/* inactive: manual, active: auto */
gpio_pin_configure_dt(&diversity_mode_gpio, GPIO_OUTPUT_INACTIVE);

/* In manual mode: diversity pin state */
gpio_pin_configure_dt(&diversity_state_gpio, GPIO_OUTPUT_INACTIVE);

/* inactive: external, active: internal */
gpio_pin_configure_dt(&antenna_control_gpio, GPIO_OUTPUT_ACTIVE);

/* Main MCU requests specific antenna. Ignored for now
* inactive: external, active: internal
*/
gpio_pin_configure_dt(&antenna_input_gpio, GPIO_INPUT);

for (size_t index = 0; index < ARRAY_SIZE(led_mirrors); index += 1) {
struct led_mirror *led_mirror = &led_mirrors[index];

if (!device_is_ready(led_mirror->source.port)) {
continue;
}
if (!device_is_ready(led_mirror->destination.port)) {
continue;
}

gpio_pin_configure_dt(&led_mirror->source, GPIO_INPUT);
gpio_pin_configure_dt(&led_mirror->destination, GPIO_OUTPUT);

gpio_init_callback(&led_mirror->callback, led_mirror_callback_handler,
BIT(led_mirror->source.pin));
gpio_add_callback(led_mirror->source.port, &led_mirror->callback);

gpio_pin_interrupt_configure_dt(&led_mirror->source, GPIO_INT_EDGE_BOTH);

/* Initially apply mirror just in case */
led_mirror_callback_handler(NULL, &led_mirror->callback, 0);
}

return 0;
}

SYS_INIT(board_init, PRE_KERNEL_2, 0);
5 changes: 5 additions & 0 deletions boards/arm/gardena_rm_sim3u/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2023 GARDENA GmbH
#
# SPDX-License-Identifier: Apache-2.0

include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
37 changes: 37 additions & 0 deletions boards/arm/gardena_rm_sim3u/gardena_rm_sim3u-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2023 GARDENA GmbH
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/dt-bindings/pinctrl/si32-pinctrl.h>

&pinctrl {
usart0_default: usart0_default {
group1 {
pinmux = <SI32_MUX(USART0_TX, 0, 0)>,
<SI32_MUX(USART0_RTS, 0, 2)>;
output-enable;
};
group2 {
pinmux = <SI32_MUX(USART0_RX, 0, 1)>,
<SI32_MUX(USART0_CTS, 0, 3)>;
input-enable;
};
};

spi2_default: spi2_default {
group1 {
pinmux = <SI32_MUX(SPI2_SCK, 3, 6)>,
<SI32_MUX(SPI2_MOSI, 3, 8)>,
<SI32_MUX(SPI2_NSS, 3, 9)>;
output-enable;
};

group2 {
pinmux = <SI32_MUX(SPI2_MISO, 3, 7)>;
input-enable;
};
};
};

148 changes: 148 additions & 0 deletions boards/arm/gardena_rm_sim3u/gardena_rm_sim3u.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/*
* Copyright (c) 2023 GARDENA GmbH
*
* SPDX-License-Identifier: Apache-2.0
*/

/dts-v1/;
#include <silabs/sim3u167bgm.dtsi>
#include <zephyr/dt-bindings/gpio/silabs-si32-hd-gpio.h>
#include "gardena_rm_sim3u-pinctrl.dtsi"

/ {
model = "GARDENA sim3u radio module";
compatible = "gardena,rm_sim3u", "silabs,sim3u";

chosen {
zephyr,console = &usart0;
zephyr,shell-uart = &usart0;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
};

leds {
compatible = "gpio-leds";
status = "okay";

led_red: led_red {
gpios = <&gpio4 0 (GPIO_ACTIVE_LOW | SI32_GPIO_DS_ENABLE_CURRENT_LIMIT)>;
label = "Red LED 0";
};
led_green: led_green {
gpios = <&gpio4 1 (GPIO_ACTIVE_LOW | SI32_GPIO_DS_ENABLE_CURRENT_LIMIT)>;
label = "Green LED 0";
};
led_blue: led_blue {
gpios = <&gpio4 2 (GPIO_ACTIVE_LOW | SI32_GPIO_DS_ENABLE_CURRENT_LIMIT)>;
label = "Blue LED 0";
};
};

gardena_antenna: gardena_antenna {
compatible = "gardena,antenna";
diversity-mode-gpios = <&gpio2 14 GPIO_ACTIVE_HIGH>;
diversity-state-gpios = <&gpio2 10 GPIO_ACTIVE_HIGH>;
antenna-control-gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>;
antenna-input-gpios = <&gpio1 8 GPIO_ACTIVE_HIGH>;

led-red-input-gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>;
led-green-input-gpios = <&gpio0 5 GPIO_ACTIVE_HIGH>;
led-blue-input-gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>;
};
};

&cpu0 {
clock-frequency = <76953600>;
};

&pll0 {
status = "okay";
};

&clk_ahb {
clocks = <&pll0>;
status = "okay";
};

&clk_apb {
divider = <2>;
status = "okay";
};

&usart0 {
current-speed = <115200>;
pinctrl-0 = <&usart0_default>;
pinctrl-names = "default";
hw-flow-control;
status = "okay";
};

&gpio0 {
status = "okay";
};

&gpio1 {
status = "okay";
};

&gpio2 {
disable-pullups;
status = "okay";
};

&gpio3 {
status = "okay";
};

&gpio4 {
nchannel-current-limit = <7>;
pchannel-current-limit = <15>;
enable-bias;
low-power-port-mode;
enable-drivers;
status = "okay";
};

&spi2 {
pinctrl-0 = <&spi2_default>;
pinctrl-names = "default";
status = "ok";

si4467@0 {
compatible = "silabs,si4467";
spi-max-frequency = <2000000>;
xtal-frequency = <26000000>;
reg = <0>;
gpio-0-gpios = <&gpio2 4 GPIO_ACTIVE_HIGH>;
gpio-1-gpios = <&gpio2 5 GPIO_ACTIVE_HIGH>;
gpio-2-gpios = <&gpio2 6 GPIO_ACTIVE_HIGH>;
gpio-3-gpios = <&gpio2 7 GPIO_ACTIVE_HIGH>;

sdn-gpios = <&gpio3 4 GPIO_ACTIVE_HIGH>;
nirq-gpios = <&gpio3 5 GPIO_ACTIVE_LOW>;

rx-enable-gpios = <&gpio4 4 (GPIO_ACTIVE_HIGH | SI32_GPIO_DS_ENABLE_CURRENT_LIMIT)>;
tx-enable-gpios = <&gpio4 5 (GPIO_ACTIVE_HIGH | SI32_GPIO_DS_ENABLE_CURRENT_LIMIT)>;
};

};

&flash0 {
status = "okay";

partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

slot0_partition: partition@0 {
label = "image-0";
reg = <0x00000000 DT_SIZE_K(1664)>;
};

storage_partition: partition@250000 {
label = "storage";
reg = <0x00030000 DT_SIZE_K(64)>;
};
};
};
16 changes: 16 additions & 0 deletions boards/arm/gardena_rm_sim3u/gardena_rm_sim3u.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2023 GARDENA GmbH
#
# SPDX-License-Identifier: Apache-2.0

identifier: gardena_rm_sim3u
name: GARDENA sim3u radio module
type: mcu
arch: arm
ram: 32
flash: 256
toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- gpio
13 changes: 13 additions & 0 deletions boards/arm/gardena_rm_sim3u/gardena_rm_sim3u_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CONFIG_SOC_SERIES_SIM3U=y

# enable uart driver
CONFIG_SERIAL=y

# enable console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y

# enable GPIO
CONFIG_GPIO=y

CONFIG_SPI=y
21 changes: 21 additions & 0 deletions boards/arm/gardena_rm_sim3u/support/openocd.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2023 GARDENA GmbH
#
# SPDX-License-Identifier: Apache-2.0

source [find interface/ftdi/olimex-arm-usb-tiny-h.cfg]
source [find interface/ftdi/olimex-arm-jtag-swd.cfg]

source [find target/sim3x.cfg]

reset_config none separate

$_TARGETNAME configure -event gdb-attach {
echo "Debugger attaching: halting execution"
reset halt
gdb_breakpoint_override hard
}

$_TARGETNAME configure -event gdb-detach {
echo "Debugger detaching: resuming execution"
resume
}
3 changes: 3 additions & 0 deletions drivers/clock_control/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF_DRIVER_CALIBRATION nrf_clo
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_RV32M1_PCC clock_control_rv32m1_pcc.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_INFINEON_CAT1 clock_control_ifx_cat1.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_SAM clock_control_sam_pmc.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_SI32_PLL clock_control_si32_pll.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_SI32_AHB clock_control_si32_ahb.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_SI32_APB clock_control_si32_apb.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_SMARTBOND clock_control_smartbond.c)


Expand Down
2 changes: 2 additions & 0 deletions drivers/clock_control/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ source "drivers/clock_control/Kconfig.gd32"

source "drivers/clock_control/Kconfig.sam"

source "drivers/clock_control/Kconfig.si32"

source "drivers/clock_control/Kconfig.smartbond"

endif # CLOCK_CONTROL
Loading