/* Reads PE internal program memory (IMEM) from the host through indirect access registers.  */
u32 pe_pmem_read(int id, u32 addr, u8 size)
/* Reads PE internal program memory (IMEM) from the host through indirect access registers.  */
u32 pe_pmem_read(int id, u32 addr, u8 size)
{
	u32 offset = addr & 0x3;
	u32 mask = 0xffffffff >> ((4 - size) << 3);
	u32 val;
	addr = pe[id].pmem_base_addr | ((addr & ~0x3) & (pe[id].pmem_size - 1))
		| PE_MEM_ACCESS_READ | PE_MEM_ACCESS_IMEM |
		PE_MEM_ACCESS_BYTE_ENABLE(offset, size);
	writel(addr, pe[id].mem_access_addr);
	val = be32_to_cpu(readl(pe[id].mem_access_rdata));
	return (val >> (offset << 3)) & mask;
}