From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Tue, 07 Feb 2023 02:07:52 +0100 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pPCSf-00GWIN-HI for lore@lore.pengutronix.de; Tue, 07 Feb 2023 02:07:52 +0100 Received: from bombadil.infradead.org ([2607:7c80:54:3::133]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pPCSc-0007Js-0z for lore@pengutronix.de; Tue, 07 Feb 2023 02:07:51 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=sNbNvlSIBnPJ0V3O/LdgdAzt1D9bnEbVcb4UcGWqYAE=; b=mU1XSlpW4AaBAU+09SYzUePGSF yxr1cqp8bEbTZsa8TE5YX2Q6kQ++pSVId2U8ciyU+I5qA/VhkhmH4hb3n+yMf2BQY0TWL+UuqZVWY 1tNuz9B4d+pe0a7O57cb4Ar7hqmmdBIbpLqLhLsRATcgz93P0wXLmCWD8SGXAJ19MqoEe86FMJHhQ Fgas24/1Eugzk5e6F8uU60SZwjpLdkPthkY/1r4Bg+x0yTWMWEs/KlgLvqHXfbIiCgLFye+SMet8z lt3R2ZihIWX6Fr5GEMKMJYSETJWOiESJUx2AsL9YSoAegTpJaDnDlFf4qZU8Dp25qq42EcQAiOAbH KxYT+lxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pPCRO-00AKMr-3J; Tue, 07 Feb 2023 01:06:34 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pPCRE-00AKIl-CC for barebox@lists.infradead.org; Tue, 07 Feb 2023 01:06:27 +0000 Received: by mail-ej1-x635.google.com with SMTP id sa10so8885407ejc.9 for ; Mon, 06 Feb 2023 17:06:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sNbNvlSIBnPJ0V3O/LdgdAzt1D9bnEbVcb4UcGWqYAE=; b=gwbECVYxZGumZo7O5h5ijhZz7Jn/corCDrjtxLYxbjQd+nrwnkLcNh1PsdV/mo4gJw 5BfFYXOALuIRxKuuqZ/awDwePWcfWJnhLtns1yN/9vacQUfqyM8enGukpikQ5XwbnBZU JE6yyuWbZI0Ji8kBkCpPpljcH+oB0fXBG2BpW1/I+hS1DlM0XB6pW9AiDqEp5XLPbKTU rLjJteQMa48dcsLmqRjFe09io7F1qcXK+QlDLlLPuny8HgCIkQ9HEkLxvTm2Se5p2JoQ xhIgU8nuyqNgVzLzOz8se7Kr+eDDJlOkaXVqxhsKQHfFzlXaM1K05G2D5nuf3g4e6YZ2 x8gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sNbNvlSIBnPJ0V3O/LdgdAzt1D9bnEbVcb4UcGWqYAE=; b=Sx1KiZe9G+IQRxYXM5v8xpVKhHvwrv2JwOmhp7TxTId3mKdsR1TRxtsQyIwfoqVBG+ DFzOz3EiKE4O1c5TQzkdMuzc/Kk83KkY8zDETVsgoNli+4Mz5kdF5+kzzers6+FLRZSV kzFdn9PxK/apH0ixVpVTLQyUakMmEY3cZVYu6XfFUEf90Gtl8baWgg8hN3BBuQ+pJ3VX raCopQ9cFOTlmCES146RESOR2uUY1WmNfv5+y7+3+IcwKGGGtVbvnXpNBnauU1ZxMMXs tkImlUGUgF5RfJeuRUGetfjGMXB6lMwsZhJYZGpGmpWwhTlXSlCRgAPTQryZ3hG3qC3u BZTg== X-Gm-Message-State: AO0yUKW+VQbx9RrrIZtj7bgjVrtDIPrghJ4v+9ZO5Y1czDFh9ezgm4EC Iz7Peva+RwbNAL16SIH1hBtB7pDv85s= X-Google-Smtp-Source: AK7set/rj1zlUeRnxfsmjL3DpEd/onTIx3YJQj1IkK8fg3qIOC4m6ueFcClb8VHdp8C7QLJiaGyhWw== X-Received: by 2002:a17:906:8052:b0:87f:2d81:1d28 with SMTP id x18-20020a170906805200b0087f2d811d28mr1326557ejw.66.1675731982112; Mon, 06 Feb 2023 17:06:22 -0800 (PST) Received: from localhost.localdomain (ip-78-45-34-87.bb.vodafone.cz. [78.45.34.87]) by smtp.gmail.com with ESMTPSA id f18-20020a170906391200b0088a9e083318sm6078754eje.168.2023.02.06.17.06.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 17:06:21 -0800 (PST) From: =?UTF-8?q?Daniel=20Br=C3=A1t?= To: barebox@lists.infradead.org Cc: =?UTF-8?q?Daniel=20Br=C3=A1t?= Date: Tue, 7 Feb 2023 02:05:23 +0100 Message-Id: <20230207010525.2693-4-danek.brat@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230207010525.2693-1-danek.brat@gmail.com> References: <20230207010525.2693-1-danek.brat@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230206_170624_447964_8BF70EAE X-CRM114-Status: GOOD ( 25.90 ) X-BeenThere: barebox@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "barebox" X-SA-Exim-Connect-IP: 2607:7c80:54:3::133 X-SA-Exim-Mail-From: barebox-bounces+lore=pengutronix.de@lists.infradead.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-3.9 required=4.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Subject: [PATCH 3/5] ARM: rpi: rework rpi board init code X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) Rework of init for various rpi board variants. Primarily, ethernet and usb init have been generalized to better cover different variations and handling of board leds changed from adding and registering 'gpio_led' structures to fixing them in the device tree. This change also required moving the board init code from 'late_platform_driver' to 'coredevice_platform_driver' which in turn ment calling 'rpi_env_init' from separate late_initcall. Signed-off-by: Daniel BrĂ¡t --- arch/arm/boards/raspberry-pi/rpi-common.c | 414 ++++++++++------------ arch/arm/dts/bcm2711-rpi-4.dts | 5 + arch/arm/dts/bcm2835-rpi.dts | 1 + arch/arm/dts/bcm2836-rpi-2.dts | 4 + arch/arm/dts/bcm2837-rpi-3.dts | 5 + 5 files changed, 199 insertions(+), 230 deletions(-) diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c index a8f180ae92..9bf6e0334d 100644 --- a/arch/arm/boards/raspberry-pi/rpi-common.c +++ b/arch/arm/boards/raspberry-pi/rpi-common.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -45,19 +46,21 @@ static const char * const boot_mode_names[] = { [0x7] = "http", }; -struct rpi_priv; struct rpi_machine_data { - int (*init)(struct rpi_priv *priv); u8 hw_id; #define RPI_OLD_SCHEMA BIT(0) +#define RPI_SET_ETHADDR BIT(1) +#define RPI_SET_USB_OTG BIT(2) +#define RPI_LED_PWR_INV BIT(3) +#define RPI_LED_PWR_EXP BIT(4) +#define RPI_LED_ACT_INV BIT(5) +#define RPI_LED_ACT_EXP BIT(6) +#define RPI_LED_ANY_EXP (RPI_LED_PWR_EXP | RPI_LED_ACT_EXP) +#define RPI_LED_PWR_EXP_INV (RPI_LED_PWR_EXP | RPI_LED_PWR_INV) +#define RPI_LED_ACT_EXP_INV (RPI_LED_ACT_EXP | RPI_LED_ACT_INV) u8 flags; -}; - -struct rpi_priv { - struct device *dev; - const struct rpi_machine_data *dcfg; - unsigned int hw_id; - const char *name; + int pwr_led_gpio; + int act_led_gpio; }; static void rpi_set_serial_number(void) @@ -83,91 +86,74 @@ static void rpi_set_ethaddr(void) eth_register_ethaddr(0, mac); } -static void rpi_set_usbotg(const char *alias) +static void rpi_set_usbotg(void) { struct device_node *usb; - usb = of_find_node_by_alias(NULL, alias); + usb = of_find_node_by_alias(NULL, "usb0"); if (usb) of_property_write_string(usb, "dr_mode", "otg"); } -static struct gpio_led rpi_leds[] = { - { - .gpio = -EINVAL, - .led = { - .name = "ACT", - }, - }, { - .gpio = -EINVAL, - .led = { - .name = "PWR", - }, - }, -}; - -static void rpi_add_led(void) +static int of_rpi_led_set_gpio(struct device_node *led, u32 pin, + bool exp, bool inv) { - int i; - struct gpio_led *l; - - for (i = 0; i < ARRAY_SIZE(rpi_leds); i++) { - l = &rpi_leds[i]; - - if (gpio_is_valid(l->gpio)) - led_gpio_register(l); - } - - l = &rpi_leds[0]; - if (gpio_is_valid(l->gpio)) - led_set_trigger(LED_TRIGGER_HEARTBEAT, &l->led); -} + u32 gpios_prop[3]; + struct device_node *gpio; -static int rpi_b_init(struct rpi_priv *priv) -{ - rpi_leds[0].gpio = 16; - rpi_leds[0].active_low = 1; - rpi_set_ethaddr(); - - return 0; -} - -static int rpi_b_plus_init(struct rpi_priv *priv) -{ - rpi_leds[0].gpio = 47; - rpi_leds[1].gpio = 35; - rpi_set_ethaddr(); + if (!led) + return -ENODEV; - return 0; -} + gpio = of_find_node_by_alias(NULL, exp ? "expgpio0" : "gpio0"); + if (!gpio) + return -ENODEV; -static int rpi_0_init(struct rpi_priv *priv) -{ - rpi_leds[0].gpio = 47; - rpi_set_usbotg("usb0"); + gpios_prop[0] = gpio->phandle; + gpios_prop[1] = pin; + gpios_prop[2] = inv ? GPIO_ACTIVE_LOW : GPIO_ACTIVE_HIGH; - return 0; + return of_property_write_u32_array(led, "gpios", gpios_prop, 3); } -static int rpi_0_w_init(struct rpi_priv *priv) +static void rpi_add_leds(const struct rpi_machine_data *dcfg) { - struct device_node *np; - int ret; + int flags, led_pwr, led_act, led_cnt; + struct device_node *leds, *l; - rpi_0_init(priv); + if (!IS_ENABLED(CONFIG_OFDEVICE) || !IS_ENABLED(CONFIG_LED_GPIO_OF)) + return; - np = of_find_node_by_path("/chosen"); - if (!np) - return -ENODEV; + leds = of_find_node_by_path("/leds"); + if (!leds) + return; - if (!of_device_enable_and_register_by_alias("serial1")) - return -ENODEV; + led_cnt = 0; + flags = dcfg->flags; + led_pwr = dcfg->pwr_led_gpio; + led_act = dcfg->act_led_gpio; + + l = of_get_child_by_name(leds, "led-pwr"); + if (l) { + if (led_pwr >= 0 && !of_rpi_led_set_gpio(l, led_pwr, + flags & RPI_LED_PWR_EXP, + flags & RPI_LED_PWR_INV)) + led_cnt++; + else + of_delete_node(l); + } - ret = of_property_write_string(np, "stdout-path", "serial1:115200n8"); - if (ret) - return ret; + l = of_get_child_by_name(leds, "led-act"); + if (l) { + if (led_act >= 0 && !of_rpi_led_set_gpio(l, led_act, + flags & RPI_LED_ACT_EXP, + flags & RPI_LED_ACT_INV)) + led_cnt++; + else + of_delete_node(l); + } - return of_device_disable_by_alias("serial0"); + if (led_cnt) + of_device_enable_and_register(leds); } static int rpi_mem_init(void) @@ -213,6 +199,7 @@ static int rpi_env_init(void) return 0; } +late_initcall(rpi_env_init); /* Some string properties in fdt passed to us from vc may be * malformed by not being null terminated, so just create and @@ -390,15 +377,22 @@ static void rpi_set_kernel_name(void) { } } -static const struct rpi_machine_data *rpi_get_dcfg(struct rpi_priv *priv) +static void rpi_set_hostname(struct device_d *dev) { - const struct rpi_machine_data *dcfg; + const char *name, *ptr; + char *hostname; - dcfg = of_device_get_match_data(priv->dev); - if (!dcfg) { - dev_err(priv->dev, "Unknown board. Not applying fixups\n"); - return NULL; - } + name = of_device_get_match_compatible(dev); + ptr = strchr(name, ','); + hostname = basprintf("rpi-%s", ptr ? ptr + 1 : name); + barebox_set_hostname(hostname); + free(hostname); +} + +static const struct rpi_machine_data *rpi_get_dcfg(const struct rpi_machine_data *dcfg) +{ + int ret; + u32 board_rev; /* Comments from u-boot: * For details of old-vs-new scheme, see: @@ -412,22 +406,26 @@ static const struct rpi_machine_data *rpi_get_dcfg(struct rpi_priv *priv) * http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=20594 */ + ret = rpi_get_board_rev(); + if (ret < 0) + return ERR_PTR(ret); + board_rev = ret; + for (; dcfg->hw_id != U8_MAX; dcfg++) { - if (priv->hw_id & 0x800000) { - if (dcfg->hw_id != ((priv->hw_id >> 4) & 0xff)) + if (board_rev & BIT(23)) { + if (dcfg->hw_id != ((board_rev >> 4) & 0xff)) continue; } else { if (!(dcfg->flags & RPI_OLD_SCHEMA)) continue; - if (dcfg->hw_id != (priv->hw_id & 0xff)) + if (dcfg->hw_id != (board_rev & 0xff)) continue; } return dcfg; } - dev_err(priv->dev, "dcfg 0x%x for board_id doesn't match DT compatible\n", - priv->hw_id); + pr_err("dcfg 0x%x for board_id doesn't match DT compatible\n", board_rev); return ERR_PTR(-ENODEV); } @@ -435,42 +433,32 @@ static int rpi_devices_probe(struct device *dev) { const struct rpi_machine_data *dcfg; struct regulator *reg; - struct rpi_priv *priv; - const char *name, *ptr; - char *hostname; - int ret; - priv = xzalloc(sizeof(*priv)); - priv->dev = dev; + dcfg = of_device_get_match_data(dev); + if (!dcfg) + dev_err(dev, "Unknown board, not applying fixups\n"); + else { + dcfg = rpi_get_dcfg(dcfg); + if (IS_ERR(dcfg)) + return PTR_ERR(dcfg); - ret = rpi_get_board_rev(); - if (ret < 0) - goto free_priv; + rpi_add_leds(dcfg); - priv->hw_id = ret; + if (dcfg->flags & RPI_SET_ETHADDR) + rpi_set_ethaddr(); - dcfg = rpi_get_dcfg(priv); - if (IS_ERR(dcfg)) - goto free_priv; + if (dcfg->flags & RPI_SET_USB_OTG) + rpi_set_usbotg(); + } - rpi_set_serial_number(); - /* construct short recognizable host name */ - name = of_device_get_match_compatible(priv->dev); - ptr = strchr(name, ','); - hostname = basprintf("rpi-%s", ptr ? ptr + 1 : name); - barebox_set_hostname(hostname); - free(hostname); + rpi_set_serial_number(); + rpi_set_hostname(dev); + rpi_set_kernel_name(); - rpi_add_led(); bcm2835_register_fb(); armlinux_set_architecture(MACH_TYPE_BCM2708); - rpi_env_init(); rpi_vc_fdt(); - rpi_set_kernel_name(); - - if (dcfg && dcfg->init) - dcfg->init(priv); reg = regulator_get_name("bcm2835_usb"); if (IS_ERR(reg)) @@ -479,134 +467,95 @@ static int rpi_devices_probe(struct device *dev) regulator_enable(reg); return 0; - -free_priv: - kfree(priv); - return ret; } +#define RPI_ENTRY(_id, _pwr, _act, _flags) \ + { \ + .hw_id = _id, \ + .pwr_led_gpio = _pwr, \ + .act_led_gpio = _act, \ + .flags = _flags, \ + } + +#define RPI_ENTRY_OLD(_id, _pwr, _act, _flags) \ + RPI_ENTRY(_id, _pwr, _act, (_flags) | RPI_OLD_SCHEMA) + +#if IS_ENABLED(CONFIG_MACH_RPI) static const struct rpi_machine_data rpi_1_ids[] = { - { - .hw_id = BCM2835_BOARD_REV_A_7, - .flags = RPI_OLD_SCHEMA, - }, { - .hw_id = BCM2835_BOARD_REV_A_8, - .flags = RPI_OLD_SCHEMA, - }, { - .hw_id = BCM2835_BOARD_REV_A_9, - .flags = RPI_OLD_SCHEMA, - }, { - .hw_id = BCM2835_BOARD_REV_A, - }, { - .hw_id = BCM2835_BOARD_REV_A_PLUS_12, - .flags = RPI_OLD_SCHEMA, - }, { - .hw_id = BCM2835_BOARD_REV_A_PLUS_15, - .flags = RPI_OLD_SCHEMA, - }, { - .hw_id = BCM2835_BOARD_REV_A_PLUS, - }, { - .hw_id = BCM2835_BOARD_REV_B_I2C1_4, - .flags = RPI_OLD_SCHEMA, - }, { - .hw_id = BCM2835_BOARD_REV_B_I2C1_5, - .flags = RPI_OLD_SCHEMA, - }, { - .hw_id = BCM2835_BOARD_REV_B_I2C1_6, - .flags = RPI_OLD_SCHEMA, - }, { - .hw_id = BCM2835_BOARD_REV_B, - }, { - .hw_id = BCM2835_BOARD_REV_B_I2C0_2, - .flags = RPI_OLD_SCHEMA, - }, { - .hw_id = BCM2835_BOARD_REV_B_I2C0_3, - .flags = RPI_OLD_SCHEMA, - }, { - .hw_id = BCM2835_BOARD_REV_B_REV2_d, - .flags = RPI_OLD_SCHEMA, - .init = rpi_b_init, - }, { - .hw_id = BCM2835_BOARD_REV_B_REV2_e, - .flags = RPI_OLD_SCHEMA, - .init = rpi_b_init, - }, { - .hw_id = BCM2835_BOARD_REV_B_REV2_f, - .flags = RPI_OLD_SCHEMA, - .init = rpi_b_init, - }, { - .hw_id = BCM2835_BOARD_REV_B_PLUS_10, - .flags = RPI_OLD_SCHEMA, - .init = rpi_b_plus_init, - }, { - .hw_id = BCM2835_BOARD_REV_B_PLUS_13, - .flags = RPI_OLD_SCHEMA, - .init = rpi_b_plus_init, - }, { - .hw_id = BCM2835_BOARD_REV_B_PLUS, - .init = rpi_b_plus_init, - }, { - .hw_id = BCM2835_BOARD_REV_CM_11, - .flags = RPI_OLD_SCHEMA, - }, { - .hw_id = BCM2835_BOARD_REV_CM_14, - .flags = RPI_OLD_SCHEMA, - }, { - .hw_id = BCM2835_BOARD_REV_CM1, - }, { - .hw_id = BCM2835_BOARD_REV_ZERO, - .init = rpi_0_init, - }, { - .hw_id = BCM2835_BOARD_REV_ZERO_W, - .init = rpi_0_w_init, - }, { - .hw_id = U8_MAX - }, + /* + * New style of revision codes schemas + * Let's keep those first since they are probably more common + */ + RPI_ENTRY(BCM2835_BOARD_REV_A, -1, 16, RPI_LED_ACT_INV), + RPI_ENTRY(BCM2835_BOARD_REV_A_PLUS, 35, 47, RPI_LED_ACT_INV), + RPI_ENTRY(BCM2835_BOARD_REV_B, -1, 16, RPI_LED_ACT_INV | RPI_SET_ETHADDR), + RPI_ENTRY(BCM2835_BOARD_REV_B_PLUS, 35, 47, RPI_SET_ETHADDR), + RPI_ENTRY(BCM2835_BOARD_REV_CM1, -1, 47, RPI_LED_ACT_INV), + RPI_ENTRY(BCM2835_BOARD_REV_ZERO, -1, 47, RPI_SET_USB_OTG), + RPI_ENTRY(BCM2835_BOARD_REV_ZERO_W, -1, 47, RPI_SET_USB_OTG | RPI_LED_ACT_INV), + /* + * Old style of revision codes + */ + /* Raspberry Pi A */ + RPI_ENTRY_OLD(BCM2835_BOARD_REV_A_7, -1, 16, RPI_LED_ACT_INV), + RPI_ENTRY_OLD(BCM2835_BOARD_REV_A_8, -1, 16, RPI_LED_ACT_INV), + RPI_ENTRY_OLD(BCM2835_BOARD_REV_A_9, -1, 16, RPI_LED_ACT_INV), + /* Raspberry Pi A+ */ + RPI_ENTRY_OLD(BCM2835_BOARD_REV_A_PLUS_12, 35, 47, RPI_LED_ACT_INV), + RPI_ENTRY_OLD(BCM2835_BOARD_REV_A_PLUS_15, 35, 47, RPI_LED_ACT_INV), + /* Raspberry Pi B */ + RPI_ENTRY_OLD(BCM2835_BOARD_REV_B_I2C1_4, -1, 16, RPI_LED_ACT_INV | RPI_SET_ETHADDR), + RPI_ENTRY_OLD(BCM2835_BOARD_REV_B_I2C1_5, -1, 16, RPI_LED_ACT_INV | RPI_SET_ETHADDR), + RPI_ENTRY_OLD(BCM2835_BOARD_REV_B_I2C1_6, -1, 16, RPI_LED_ACT_INV | RPI_SET_ETHADDR), + RPI_ENTRY_OLD(BCM2835_BOARD_REV_B_I2C0_2, -1, 16, RPI_LED_ACT_INV | RPI_SET_ETHADDR), + RPI_ENTRY_OLD(BCM2835_BOARD_REV_B_I2C0_3, -1, 16, RPI_LED_ACT_INV | RPI_SET_ETHADDR), + RPI_ENTRY_OLD(BCM2835_BOARD_REV_B_REV2_d, -1, 16, RPI_LED_ACT_INV | RPI_SET_ETHADDR), + RPI_ENTRY_OLD(BCM2835_BOARD_REV_B_REV2_e, -1, 16, RPI_LED_ACT_INV | RPI_SET_ETHADDR), + RPI_ENTRY_OLD(BCM2835_BOARD_REV_B_REV2_f, -1, 16, RPI_LED_ACT_INV | RPI_SET_ETHADDR), + /* Raspberry Pi B+ */ + RPI_ENTRY_OLD(BCM2835_BOARD_REV_B_PLUS_10, 35, 47, RPI_SET_ETHADDR), + RPI_ENTRY_OLD(BCM2835_BOARD_REV_B_PLUS_13, 35, 47, RPI_SET_ETHADDR), + /* Raspberry Pi CM1 */ + RPI_ENTRY_OLD(BCM2835_BOARD_REV_CM_11, -1, 47, RPI_LED_ACT_INV), + RPI_ENTRY_OLD(BCM2835_BOARD_REV_CM_14, -1, 47, RPI_LED_ACT_INV), + /* sentinel */ + { .hw_id = U8_MAX } }; +#endif +#if IS_ENABLED(CONFIG_MACH_RPI2) static const struct rpi_machine_data rpi_2_ids[] = { - { - .hw_id = BCM2836_BOARD_REV_2_B, - .init = rpi_b_plus_init, - }, { - .hw_id = U8_MAX - }, + RPI_ENTRY(BCM2836_BOARD_REV_2_B, 35, 47, RPI_SET_ETHADDR), + /* sentinel */ + { .hw_id = U8_MAX } }; +#endif +#if IS_ENABLED(CONFIG_MACH_RPI3) | IS_ENABLED(CONFIG_MACH_RPI_CM3) static const struct rpi_machine_data rpi_3_ids[] = { - { - .hw_id = BCM2837B0_BOARD_REV_3A_PLUS, - .init = rpi_b_plus_init, - }, { - .hw_id = BCM2837_BOARD_REV_3_B, - .init = rpi_b_init, - }, { - .hw_id = BCM2837B0_BOARD_REV_3B_PLUS, - .init = rpi_b_plus_init, - }, { - .hw_id = BCM2837_BOARD_REV_CM3, - }, { - .hw_id = BCM2837B0_BOARD_REV_CM3_PLUS, - }, { - .hw_id = BCM2837B0_BOARD_REV_ZERO_2, - }, { - .hw_id = U8_MAX - }, + RPI_ENTRY(BCM2837B0_BOARD_REV_3A_PLUS, 2, 29, RPI_LED_PWR_EXP_INV), + RPI_ENTRY(BCM2837_BOARD_REV_3_B, -1, 2, RPI_SET_ETHADDR | RPI_LED_ACT_EXP), + RPI_ENTRY(BCM2837B0_BOARD_REV_3B_PLUS, 2, 29, RPI_SET_ETHADDR | RPI_LED_PWR_EXP_INV), + RPI_ENTRY(BCM2837_BOARD_REV_CM3, -1, -1, 0), + RPI_ENTRY(BCM2837B0_BOARD_REV_CM3_PLUS, -1, -1, 0), + RPI_ENTRY(BCM2837B0_BOARD_REV_ZERO_2, -1, 29, RPI_LED_ACT_INV | RPI_SET_USB_OTG), + /* sentinel */ + { .hw_id = U8_MAX } }; +#endif +#if IS_ENABLED(CONFIG_MACH_RPI4) static const struct rpi_machine_data rpi_4_ids[] = { - { - .hw_id = BCM2711_BOARD_REV_4_B, - }, { - .hw_id = BCM2711_BOARD_REV_400, - }, { - .hw_id = BCM2711_BOARD_REV_CM4, - }, { - .hw_id = U8_MAX - }, + RPI_ENTRY(BCM2711_BOARD_REV_4_B, 2, 42, RPI_LED_PWR_EXP_INV | RPI_SET_ETHADDR), + RPI_ENTRY(BCM2711_BOARD_REV_400, 42, -1, RPI_SET_ETHADDR), + RPI_ENTRY(BCM2711_BOARD_REV_CM4, 2, 42, RPI_LED_PWR_EXP_INV | RPI_SET_ETHADDR), + /* sentinel */ + { .hw_id = U8_MAX } }; +#endif static const struct of_device_id rpi_of_match[] = { +#if IS_ENABLED(CONFIG_MACH_RPI) /* BCM2835 based Boards */ { .compatible = "raspberrypi,model-a", .data = rpi_1_ids }, { .compatible = "raspberrypi,model-a-plus", .data = rpi_1_ids }, @@ -618,23 +567,28 @@ static const struct of_device_id rpi_of_match[] = { { .compatible = "raspberrypi,compute-module", .data = rpi_1_ids }, { .compatible = "raspberrypi,model-zero", .data = rpi_1_ids }, { .compatible = "raspberrypi,model-zero-w", .data = rpi_1_ids }, - +#endif +#if IS_ENABLED(CONFIG_MACH_RPI2) /* BCM2836 based Boards */ { .compatible = "raspberrypi,2-model-b", .data = rpi_2_ids }, - +#endif +#if IS_ENABLED(CONFIG_MACH_RPI3) /* BCM2837 based Boards */ { .compatible = "raspberrypi,3-model-a-plus", .data = rpi_3_ids }, { .compatible = "raspberrypi,3-model-b", .data = rpi_3_ids }, { .compatible = "raspberrypi,3-model-b-plus", .data = rpi_3_ids }, { .compatible = "raspberrypi,model-zero-2-w", .data = rpi_3_ids }, +#endif +#if IS_ENABLED(CONFIG_MACH_RPI_CM3) { .compatible = "raspberrypi,3-compute-module", .data = rpi_3_ids }, { .compatible = "raspberrypi,3-compute-module-lite", .data = rpi_3_ids }, - +#endif +#if IS_ENABLED(CONFIG_MACH_RPI4) /* BCM2711 based Boards */ { .compatible = "raspberrypi,4-model-b", .data = rpi_4_ids }, { .compatible = "raspberrypi,4-compute-module", .data = rpi_4_ids }, { .compatible = "raspberrypi,400", .data = rpi_4_ids }, - +#endif { /* sentinel */ }, }; BAREBOX_DEEP_PROBE_ENABLE(rpi_of_match); @@ -644,4 +598,4 @@ static struct driver rpi_board_driver = { .probe = rpi_devices_probe, .of_compatible = DRV_OF_COMPAT(rpi_of_match), }; -late_platform_driver(rpi_board_driver); +coredevice_platform_driver(rpi_board_driver); diff --git a/arch/arm/dts/bcm2711-rpi-4.dts b/arch/arm/dts/bcm2711-rpi-4.dts index 3c0caa73f8..e61514b236 100644 --- a/arch/arm/dts/bcm2711-rpi-4.dts +++ b/arch/arm/dts/bcm2711-rpi-4.dts @@ -1,5 +1,10 @@ #include +&{/aliases} { + gpio0 = &gpio; + expgpio0 = &expgpio; +}; + &{/memory@0} { reg = <0x0 0x0 0x0>; }; diff --git a/arch/arm/dts/bcm2835-rpi.dts b/arch/arm/dts/bcm2835-rpi.dts index 8d352a457d..f403b5485c 100644 --- a/arch/arm/dts/bcm2835-rpi.dts +++ b/arch/arm/dts/bcm2835-rpi.dts @@ -2,6 +2,7 @@ &{/aliases} { usb0 = &usb; + gpio0 = &gpio; }; &{/memory@0} { diff --git a/arch/arm/dts/bcm2836-rpi-2.dts b/arch/arm/dts/bcm2836-rpi-2.dts index c9106515ee..f211445e3b 100644 --- a/arch/arm/dts/bcm2836-rpi-2.dts +++ b/arch/arm/dts/bcm2836-rpi-2.dts @@ -1,5 +1,9 @@ #include +&{/aliases} { + gpio0 = &gpio; +}; + &{/memory@0} { reg = <0x0 0x0>; }; diff --git a/arch/arm/dts/bcm2837-rpi-3.dts b/arch/arm/dts/bcm2837-rpi-3.dts index 38d673aec4..588b77cd78 100644 --- a/arch/arm/dts/bcm2837-rpi-3.dts +++ b/arch/arm/dts/bcm2837-rpi-3.dts @@ -1,5 +1,10 @@ #include +&{/aliases} { + gpio0 = &gpio; + expgpio0 = &expgpio; +}; + &{/memory@0} { reg = <0x0 0x0>; }; -- 2.34.1