resyfer commented on code in PR #18499:
URL: https://github.com/apache/nuttx/pull/18499#discussion_r2893612784


##########
boards/arm64/bcm2711/raspberrypi-4b/src/rpi4b.h:
##########
@@ -61,4 +61,57 @@ int rpi4b_sdmmc_initialize(void);
 int bcm2711_dev_gpio_init(void);
 #endif /* defined(CONFIG_DEV_GPIO) */
 
+/* == UART == */
+
+/* UART 0: GPIO 14 (ALT0=0) and GPIO 15 (ALT0=0) */
+#if (CONFIG_RPI4B_GPIO14 == 0) && (CONFIG_RPI4B_GPIO15 == 0)
+#  define RPI4B_UART0
+#endif
+
+/* UART 1: GPIO 14 (ALT5=5) and GPIO 15 (ALT5=5) */
+#if (CONFIG_RPI4B_GPIO14 == 5) && (CONFIG_RPI4B_GPIO15 == 5)
+#  define RPI4B_UART1
+#endif
+
+/* UART 2: GPIO 0 (ALT4=4) and GPIO 1 (ALT4=4) */
+#if (CONFIG_RPI4B_GPIO0 == 4) && (CONFIG_RPI4B_GPIO1 == 4)
+#  define RPI4B_UART2
+#endif
+
+/* UART 3: GPIO 4 (ALT4=4) and GPIO 5 (ALT4=4) */
+#if (CONFIG_RPI4B_GPIO4 == 4) && (CONFIG_RPI4B_GPIO5 == 4)
+#  define RPI4B_UART3
+#endif
+
+/* UART 4: GPIO 8 (ALT4=4) and GPIO 9 (ALT4=4) */
+#if (CONFIG_RPI4B_GPIO8 == 4) && (CONFIG_RPI4B_GPIO9 == 4)
+#  define RPI4B_UART4
+#endif
+
+/* UART 5: GPIO 12 (ALT4=4) and GPIO 13 (ALT4=4) */
+#if (CONFIG_RPI4B_GPIO12 == 4) && (CONFIG_RPI4B_GPIO13 == 4)
+#  define RPI4B_UART5
+#endif
+
+/* == I2C == */
+
+/* I2C 0: GPIO 0 (ALT0=0) and GPIO 1 (ALT0=0) */
+#if (CONFIG_RPI4B_GPIO0 == 0) && (CONFIG_RPI4B_GPIO1 == 0)
+#  define RPI4B_I2C0

Review Comment:
   Hi, I gave an explanation to this in this PR below. Thanks!



##########
boards/arm64/bcm2711/raspberrypi-4b/src/rpi4b_gpio.c:
##########
@@ -67,121 +66,94 @@
 struct bcm2711_gpio_dev_s
 {
   struct gpio_dev_s gpio; /* Underlying GPIO device */
-  uint8_t id;             /* The index of the pin in its list. */
+  uint8_t           pin;  /* The index of the pin in its list. */
 };
 
-/* GPIO device with interrupt capabilities on the BCM2711 */
-
-struct bcm2711_gpioint_dev_s
+enum bcm2711_gpio_pull_e
 {
-  struct bcm2711_gpio_dev_s bcm2711_gpio; /* BCM2711 GPIO device */
+  BCM2711_GPIO_PULL_NO,
+  BCM2711_GPIO_PULL_HIGH,
+  BCM2711_GPIO_PULL_LOW
 };
 
 /****************************************************************************
  * Private Function Prototypes
  ****************************************************************************/
 
-#if BOARD_NGPIOOUT > 0
-static int gpout_read(struct gpio_dev_s *dev, bool *value);
-static int gpout_write(struct gpio_dev_s *dev, bool value);
-#endif
-
-#if BOARD_NGPIOIN > 0
-static int gpin_read(struct gpio_dev_s *dev, bool *value);
-#endif
-
-#if BOARD_NGPIOINT > 0
-static int gpint_read(struct gpio_dev_s *dev, bool *value);
-static int gpint_attach(struct gpio_dev_s *dev, pin_interrupt_t callback);
-static int gpint_enable(struct gpio_dev_s *dev, bool enable);
-#endif
+static int  rpi4b_gpout_read(struct gpio_dev_s *dev, bool *value);
+static int  rpi4b_gpout_write(struct gpio_dev_s *dev, bool value);
+static int  rpi4b_gpin_read(struct gpio_dev_s *dev, bool *value);
+static void rpi4b_set_gpio_funcs(void);
+static int  rpi4b_register_gpio_output(uint8_t pin);
+static int  rpi4b_register_gpio_input(uint8_t pin);
+static void rpi4b_register_pins(void);
 
 /****************************************************************************
  * Private Data
  ****************************************************************************/
 
-#if BOARD_NGPIOOUT > 0
-
 /* GPIO operations for output pins. */
 
 static const struct gpio_operations_s gpout_ops =
 {
-    .go_read = gpout_read,
-    .go_write = gpout_write,
-    .go_attach = NULL,
-    .go_enable = NULL,
+  .go_read   = rpi4b_gpout_read,
+  .go_write  = rpi4b_gpout_write,
+  .go_attach = NULL,
+  .go_enable = NULL,
 };
 
-/* This array maps the GPIO pins used as OUTPUT */
-
-static const uint32_t g_gpiooutputs[BOARD_NGPIOOUT] =
-{
-    GPIO_OUT1,
-};
-
-/* GPIO output pin devices */
-
-static struct bcm2711_gpio_dev_s g_gpout[BOARD_NGPIOOUT];
-
-#endif /* BOARD_NGPIOOUT > 0 */
-
-#if BOARD_NGPIOIN > 0
-
 /* GPIO operations for input pins. */
 
 static const struct gpio_operations_s gpin_ops =
 {
-    .go_read = gpin_read,
-    .go_write = NULL,
-    .go_attach = NULL,
-    .go_enable = NULL,
-};
-
-/* This array maps the GPIO pins used as INTERRUPT INPUTS */
-
-static const uint32_t g_gpioinputs[BOARD_NGPIOIN] =
-{
-    GPIO_IN1,
-};
-
-/* GPIO input pin devices */
-
-static struct bcm2711_gpio_dev_s g_gpin[BOARD_NGPIOIN];
-
-#endif /* BOARD_NGPIOIN > 0 */
-
-#if BOARD_NGPIOINT > 0
-
-#warn "Missing functionality for interrupt GPIO pins."
-
-/* GPIO operations for interrupt pins. */
-
-static const struct gpio_operations_s gpint_ops =
-{
-    .go_read = gpint_read,
-    .go_write = NULL,
-    .go_attach = gpint_attach,
-    .go_enable = gpint_enable,
+  .go_read   = rpi4b_gpin_read,
+  .go_write  = NULL,
+  .go_attach = NULL,
+  .go_enable = NULL,
 };
 
-/* This array maps the GPIO pins used as INTERRUPT INPUTS */
+/* TODO: Other types of ops */
 
-static const uint32_t g_gpiointinputs[BOARD_NGPIOINT] =
-{
-    GPIO_IRQPIN1,
-};
-
-/* GPIO interrupt pin devices */
-
-static struct bcm2711_gpioint_dev_s g_gpint[BOARD_NGPIOINT];
+/* GPIO pin functions */
 
-#endif /* BOARD_NGPIOINT > 0 */
+static enum bcm2711_gpio_func_e rpi4b_gpios[RPI4B_NGPIO];
+static struct bcm2711_gpio_dev_s rpi4b_gpio_ops[RPI4B_NGPIO];
 
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
 
-#if BOARD_NGPIOOUT > 0
+static void rpi4b_set_gpio_funcs(void)
+{
+  rpi4b_gpios[0]  = (enum bcm2711_gpio_func_e) CONFIG_RPI4B_GPIO0;

Review Comment:
   Will make this change when I reach home thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to