X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=board%2Fraspberrypi%2Frpi%2Frpi.c;h=e367ba3092458f7b3bdbb75573999c530cf6b72b;hb=58e1fdb051c469049d8ed8b31f229470de4d0562;hp=c1985fd41839e24cdd345e8b78992f9143c0a013;hpb=382bee57f19b4454e2015bc19a010bc2d0ab9337;p=oweals%2Fu-boot.git diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c index c1985fd418..e367ba3092 100644 --- a/board/raspberrypi/rpi/rpi.c +++ b/board/raspberrypi/rpi/rpi.c @@ -1,16 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0 /* * (C) Copyright 2012-2016 Stephen Warren - * - * SPDX-License-Identifier: GPL-2.0 */ #include -#include #include #include +#include #include #include #include +#include #include #include #include @@ -24,11 +24,15 @@ #include #endif #include +#include DECLARE_GLOBAL_DATA_PTR; -/* From lowlevel_init.S */ -extern unsigned long fw_dtb_pointer; +/* Assigned in lowlevel_init.S + * Push the variable into the .data section so that it + * does not get cleared later. + */ +unsigned long __section(".data") fw_dtb_pointer; /* TODO(sjg@chromium.org): Move these to the msg.c file */ struct msg_get_arm_mem { @@ -68,14 +72,7 @@ struct msg_get_clock_rate { #endif /* - * http://raspberryalphaomega.org.uk/2013/02/06/automatic-raspberry-pi-board-revision-detection-model-a-b1-and-b2/ - * http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=32733 - * http://git.drogon.net/?p=wiringPi;a=blob;f=wiringPi/wiringPi.c;h=503151f61014418b9c42f4476a6086f75cd4e64b;hb=refs/heads/master#l922 - * - * In http://lists.denx.de/pipermail/u-boot/2016-January/243752.html - * ("[U-Boot] [PATCH] rpi: fix up Model B entries") Dom Cobley at the RPi - * Foundation stated that the following source was accurate: - * https://github.com/AndrewFromMelbourne/raspberry_pi_revision + * https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md */ struct rpi_model { const char *name; @@ -90,11 +87,36 @@ static const struct rpi_model rpi_model_unknown = { }; static const struct rpi_model rpi_models_new_scheme[] = { + [0x0] = { + "Model A", + DTB_DIR "bcm2835-rpi-a.dtb", + false, + }, + [0x1] = { + "Model B", + DTB_DIR "bcm2835-rpi-b.dtb", + true, + }, + [0x2] = { + "Model A+", + DTB_DIR "bcm2835-rpi-a-plus.dtb", + false, + }, + [0x3] = { + "Model B+", + DTB_DIR "bcm2835-rpi-b-plus.dtb", + true, + }, [0x4] = { "2 Model B", DTB_DIR "bcm2836-rpi-2-b.dtb", true, }, + [0x6] = { + "Compute Module", + DTB_DIR "bcm2835-rpi-cm.dtb", + false, + }, [0x8] = { "3 Model B", DTB_DIR "bcm2837-rpi-3-b.dtb", @@ -105,6 +127,36 @@ static const struct rpi_model rpi_models_new_scheme[] = { DTB_DIR "bcm2835-rpi-zero.dtb", false, }, + [0xA] = { + "Compute Module 3", + DTB_DIR "bcm2837-rpi-cm3.dtb", + false, + }, + [0xC] = { + "Zero W", + DTB_DIR "bcm2835-rpi-zero-w.dtb", + false, + }, + [0xD] = { + "3 Model B+", + DTB_DIR "bcm2837-rpi-3-b-plus.dtb", + true, + }, + [0xE] = { + "3 Model A+", + DTB_DIR "bcm2837-rpi-3-a-plus.dtb", + false, + }, + [0x10] = { + "Compute Module 3+", + DTB_DIR "bcm2837-rpi-cm3.dtb", + false, + }, + [0x11] = { + "4 Model B", + DTB_DIR "bcm2711-rpi-4-b.dtb", + true, + }, }; static const struct rpi_model rpi_models_old_scheme[] = { @@ -200,30 +252,6 @@ static uint32_t rev_scheme; static uint32_t rev_type; static const struct rpi_model *model; -#ifdef CONFIG_ARM64 -static struct mm_region bcm2837_mem_map[] = { - { - .virt = 0x00000000UL, - .phys = 0x00000000UL, - .size = 0x3f000000UL, - .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | - PTE_BLOCK_INNER_SHARE - }, { - .virt = 0x3f000000UL, - .phys = 0x3f000000UL, - .size = 0x01000000UL, - .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | - PTE_BLOCK_NON_SHARE | - PTE_BLOCK_PXN | PTE_BLOCK_UXN - }, { - /* List terminator */ - 0, - } -}; - -struct mm_region *mem_map = bcm2837_mem_map; -#endif - int dram_init(void) { ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_arm_mem, msg, 1); @@ -243,11 +271,24 @@ int dram_init(void) return 0; } +#ifdef CONFIG_OF_BOARD +int dram_init_banksize(void) +{ + int ret; + + ret = fdtdec_setup_memory_banksize(); + if (ret) + return ret; + + return fdtdec_setup_mem_size_base(); +} +#endif + static void set_fdtfile(void) { const char *fdtfile; - if (getenv("fdtfile")) + if (env_get("fdtfile")) return; fdtfile = model->fdtfile; @@ -260,13 +301,13 @@ static void set_fdtfile(void) */ static void set_fdt_addr(void) { - if (getenv("fdt_addr")) + if (env_get("fdt_addr")) return; if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC) return; - setenv_hex("fdt_addr", fw_dtb_pointer); + env_set_hex("fdt_addr", fw_dtb_pointer); } /* @@ -287,7 +328,7 @@ static void set_usbethaddr(void) if (!model->has_onboard_eth) return; - if (getenv("usbethaddr")) + if (env_get("usbethaddr")) return; BCM2835_MBOX_INIT_HDR(msg); @@ -300,10 +341,10 @@ static void set_usbethaddr(void) return; } - eth_setenv_enetaddr("usbethaddr", msg->get_mac_address.body.resp.mac); + eth_env_set_enetaddr("usbethaddr", msg->get_mac_address.body.resp.mac); - if (!getenv("ethaddr")) - env_set("ethaddr", getenv("usbethaddr")); + if (!env_get("ethaddr")) + env_set("ethaddr", env_get("usbethaddr")); return; } @@ -330,7 +371,7 @@ static void set_serial_number(void) int ret; char serial_string[17] = { 0 }; - if (getenv("serial#")) + if (env_get("serial#")) return; BCM2835_MBOX_INIT_HDR(msg); @@ -343,7 +384,7 @@ static void set_serial_number(void) return; } - snprintf(serial_string, sizeof(serial_string), "%016" PRIx64, + snprintf(serial_string, sizeof(serial_string), "%016llx", msg->get_board_serial.body.resp.serial); env_set("serial#", serial_string); } @@ -414,54 +455,11 @@ static void get_board_rev(void) printf("RPI %s (0x%x)\n", model->name, revision); } -#ifndef CONFIG_PL01X_SERIAL -static bool rpi_is_serial_active(void) -{ - int serial_gpio = 15; - struct udevice *dev; - - /* - * The RPi3 disables the mini uart by default. The easiest way to find - * out whether it is available is to check if the RX pin is muxed. - */ - - if (uclass_first_device(UCLASS_GPIO, &dev) || !dev) - return true; - - if (bcm2835_gpio_get_func_id(dev, serial_gpio) != BCM2835_GPIO_ALT5) - return false; - - return true; -} - -/* Disable mini-UART I/O if it's not pinmuxed to our pins. - * The firmware only enables it if explicitly done in config.txt: enable_uart=1 - */ -static void rpi_disable_inactive_uart(void) -{ - struct udevice *dev; - struct bcm283x_mu_serial_platdata *plat; - - if (uclass_get_device_by_driver(UCLASS_SERIAL, - DM_GET_DRIVER(serial_bcm283x_mu), - &dev) || !dev) - return; - - if (!rpi_is_serial_active()) { - plat = dev_get_platdata(dev); - plat->disabled = true; - } -} -#endif - int board_init(void) { #ifdef CONFIG_HW_WATCHDOG hw_watchdog_init(); #endif -#ifndef CONFIG_PL01X_SERIAL - rpi_disable_inactive_uart(); -#endif get_board_rev();