Skip to content

Commit

Permalink
drivers: sgpio: npcm4xx: enable npcm4xx sgpio
Browse files Browse the repository at this point in the history
To use the npcm4xx sgpio function, one has to:

1. Disable the jtag node in the device tree.
2. Enable CONFIG_SGPIO_NPCM4XX.
3. Enable sgpio0/1 nodes in the device tree.

Signed-off-by: Tyrone Ting <[email protected]>
  • Loading branch information
warp5tw authored and maxdog988 committed Mar 27, 2024
1 parent ed963ee commit 95b2700
Show file tree
Hide file tree
Showing 11 changed files with 1,144 additions and 0 deletions.
8 changes: 8 additions & 0 deletions boards/arm/npcm400f_evb/fun_def_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,11 @@ FUN_DEFINE(DT_NODELABEL(pinctrl_i3c5_default), I3C6_SCL, I3C6_SDA)
FUN_DEFINE(DT_NODELABEL(pinctrl_usbd_phy_iclk), USBD_PHY_ICLK)
FUN_DEFINE(DT_NODELABEL(pinctrl_usbd_phy_xclk), USBD_PHY_XCLK)
#endif

#if DT_NODE_HAS_STATUS(DT_NODELABEL(sgpio0), okay) && CONFIG_SGPIO_NPCM4XX
FUN_DEFINE(DT_NODELABEL(pinctrl_sgpio0_default), IOX1_LDSH, IOX1_DOUT, IOX1_DIN, IOX1_SCLK)
#endif

#if DT_NODE_HAS_STATUS(DT_NODELABEL(sgpio1), okay) && CONFIG_SGPIO_NPCM4XX
FUN_DEFINE(DT_NODELABEL(pinctrl_sgpio1_default), IOX2_LDSH, IOX2_DOUT, IOX2_DIN, IOX2_SCLK)
#endif
326 changes: 326 additions & 0 deletions boards/arm/npcm400f_evb/npcm400f_evb.dts
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,329 @@
tms-gpios = <&gpiof 3 (GPIO_PUSH_PULL | GPIO_ACTIVE_HIGH)>;
status = "okay";
};

&sgpio0 {
status = "disabled";
sgpio0_0: sgpio0_0 {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO0_0";
pin-offset = <0>;
};

sgpio0_1: sgpio0_1 {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO0_1";
pin-offset = <8>;
};

sgpio0_2: sgpio0_2 {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO0_2";
pin-offset = <16>;
};

sgpio0_3: sgpio0_3 {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO0_3";
pin-offset = <24>;
};

sgpio0_4: sgpio0_4 {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO0_4";
pin-offset = <32>;
};

sgpio0_5: sgpio0_5 {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO0_5";
pin-offset = <40>;
};

sgpio0_6: sgpio0_6 {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO0_6";
pin-offset = <48>;
};

sgpio0_7: sgpio0_7 {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO0_7";
pin-offset = <56>;
};

sgpio0_8: sgpio0_8 {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO0_8";
pin-offset = <64>;
};

sgpio0_9: sgpio0_9 {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO0_9";
pin-offset = <72>;
};

sgpio0_a: sgpio0_a {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO0_a";
pin-offset = <80>;
};

sgpio0_b: sgpio0_b {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO0_b";
pin-offset = <88>;
};

sgpio0_c: sgpio0_c {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO0_c";
pin-offset = <96>;
};

sgpio0_d: sgpio0_d {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO0_d";
pin-offset = <104>;
};

sgpio0_e: sgpio0_e {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO0_e";
pin-offset = <112>;
};

sgpio0_f: sgpio0_f {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO0_f";
pin-offset = <120>;
};
};

&sgpio1 {
status = "disabled";
sgpio1_0: sgpio1_0 {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO1_0";
pin-offset = <0>;
};

sgpio1_1: sgpio1_1 {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO1_1";
pin-offset = <8>;
};

sgpio1_2: sgpio1_2 {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO1_2";
pin-offset = <16>;
};

sgpio1_3: sgpio1_3 {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO1_3";
pin-offset = <24>;
};

sgpio1_4: sgpio1_4 {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO1_4";
pin-offset = <32>;
};

sgpio1_5: sgpio1_5 {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO1_5";
pin-offset = <40>;
};

sgpio1_6: sgpio1_6 {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO1_6";
pin-offset = <48>;
};

sgpio1_7: sgpio1_7 {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO1_7";
pin-offset = <56>;
};

sgpio1_8: sgpio1_8 {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO1_8";
pin-offset = <64>;
};

sgpio1_9: sgpio1_9 {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO1_9";
pin-offset = <72>;
};

sgpio1_a: sgpio1_a {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO1_a";
pin-offset = <80>;
};

sgpio1_b: sgpio1_b {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO1_b";
pin-offset = <88>;
};

sgpio1_c: sgpio1_c {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO1_c";
pin-offset = <96>;
};

sgpio1_d: sgpio1_d {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO1_d";
pin-offset = <104>;
};

sgpio1_e: sgpio1_e {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO1_e";
pin-offset = <112>;
};

sgpio1_f: sgpio1_f {
#gpio-cells = <2>;
gpio-controller;
ngpios = <8>;
interrupt-controller;
#interrupt-cells = <2>;
label = "SGPIO1_f";
pin-offset = <120>;
};
};
3 changes: 3 additions & 0 deletions boards/arm/npcm400f_evb/npcm400f_evb_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,6 @@ CONFIG_USB_DC_NPCM4XX=y
CONFIG_JTAG=y
CONFIG_JTAG_SHELL=y
CONFIG_JTAG_NPCM4XX=y

# SGPIO Driver
CONFIG_SGPIO_NPCM4XX=n
1 change: 1 addition & 0 deletions drivers/gpio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ zephyr_library_sources_ifdef(CONFIG_GPIO_LPC11U6X gpio_lpc11u6x.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_XLNX_AXI gpio_xlnx_axi.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_NPCX gpio_npcx.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_NPCM4XX gpio_npcm4xx.c)
zephyr_library_sources_ifdef(CONFIG_SGPIO_NPCM4XX gpio_npcm4xx_sgpio.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_EMUL gpio_emul.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_PSOC6 gpio_psoc6.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_PCAL6408A gpio_pcal6408a.c)
Expand Down
15 changes: 15 additions & 0 deletions drivers/gpio/Kconfig.npcm4xx
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,18 @@ config GPIO_NPCM4XX
This option enables the GPIO driver for NPCM4XX family of
processors.
Say y if you wish to use GPIO on NPCM4XX MCU.

config SGPIO_NPCM4XX
bool "Nuvoton NPCM4XX sgpio driver"
depends on SOC_FAMILY_NPCM4XX
help
This option enables the SGPIO driver for NPCM4XX family of
processors.
Say y if you wish to use SGPIO on NPCM4XX MCU.

config GPIO_NPCM4XX_SGPIO_INIT_PRIORITY
int "Init priority"
depends on SGPIO_NPCM4XX
default 60
help
Device driver initialization priority.
Loading

0 comments on commit 95b2700

Please sign in to comment.