From: Vladimir Oltean Date: Sun, 14 Mar 2021 10:19:38 +0200 Subject: [PATCH v3 20/22] ppc: qemu: Create a virtual memory mapping of the platform bus In-Reply-To: <20210314051510.26628-21-bmeng.cn@gmail.com> References: <20210314051510.26628-1-bmeng.cn@gmail.com> <20210314051510.26628-21-bmeng.cn@gmail.com> Message-ID: <20210314081938.hhcpjdcc544if7mw@skbuf> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Sun, Mar 14, 2021 at 01:15:08PM +0800, Bin Meng wrote: > QEMU ppce500 target can dynamically instantiate an eTSEC device on > a platform bus if "-device eTSEC" is given to QEMU. It is presented > as a "simple-bus" in the device tree, with an additional compatible > string "qemu,platform". > > Let's create a virtual memory mapping for it in misc_init_r(), in > preparation to adding eTSEC support. > > Signed-off-by: Bin Meng > > --- > +static int platform_bus_map_region(ulong map_addr, phys_addr_t paddr, > + phys_size_t size) Function could have been void (minor detail). > +{ > + /* Align map_addr */ > + map_addr += size - 1; > + map_addr &= ~(size - 1); > + > + /* Map virtual memory for range */ > + assert(!tlb_map_range(map_addr, paddr, size, TLB_MAP_IO)); > + > + return 0; > +} > + > int misc_init_r(void) > { > struct udevice *dev; > @@ -148,6 +163,22 @@ int misc_init_r(void) > */ > disable_tlb(find_tlb_idx((void *)CONFIG_SYS_TMPVIRT, 1)); > > + /* > + * Detect the presence of the platform bus node, and > + * create a virtual memory mapping for it. > + */ > + for (ret = uclass_find_first_device(UCLASS_SIMPLE_BUS, &dev); > + dev; > + ret = uclass_find_next_device(&dev)) { > + if (device_is_compatible(dev, "qemu,platform")) { > + struct simple_bus_plat *plat = dev_get_uclass_plat(dev); > + > + platform_bus_map_region(CONFIG_PLATFORM_BUS_MAP_ADDR, > + plat->target, plat->size); > + break; > + } > + } > + > return 0; > } Reviewed-by: Vladimir Oltean