Re: [U-Boot] [PATCH v4 6/6] PPC 85xx: Add qemu-ppce500 machine

2014-04-28 Thread York Sun
On 04/28/2014 02:27 PM, Alexander Graf wrote:
>> I am thinking to add back "#ifdef CONFIG_QEMU_E500" you had for your v3 and
>> earlier version for the above change. Do you have any concerns?
>>
>> The reason I am proposing this is to use generic board architecture.
>> gd->fdt_blob is used by some other functions to detect if device tree exists.
>> Your change takes r3 from entry and treat it as device tree. It is not the 
>> case
>> for a normal metal SoC. I need to clear this variable.
> 
> No complaints at all from me here :)
> 

Thanks. I will submit a patch to fix it.

York


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 6/6] PPC 85xx: Add qemu-ppce500 machine

2014-04-28 Thread Alexander Graf


> Am 28.04.2014 um 20:40 schrieb York Sun :
> 
>> On 02/20/2014 04:52 AM, Alexander Graf wrote:
>> For KVM we have a special PV machine type called "ppce500". This machine
>> is inspired by the MPC8544DS board, but implements a lot less features
>> than that one.
>> 
>> It also provides more PCI slots and is supposed to be enumerated by
>> device tree only.
>> 
>> This patch adds support for the generic ppce500 machine and tries to
>> rely solely on device tree for device enumeration.
>> 
>> Signed-off-by: Alexander Graf 
>> 
>> ---
>> 
>> v3 -> v4:
>> 
>>  - use new tlb map syntax
>>  - check that tlb map mapped everything
>>  - always save/restore r3 for cpu_init_early_f
>>  - remove CONFIG_DYNAMIC_CCSRBAR
>>  - make init_tlbs weak and remove all init_tlbs_dynamic() cruft
>>  - always map fdt to fixed virtual address
>>  - fold together AS=1 fdt map functions
>>  - use tlb_map_range for CCSR map
>>  - search for PCI based on device type rather than compatible
>>  - remove unnecessary cast
>>  - call get_linear_ram_size directly
>>  - override get_tbclk with timebase-frequency fetching code
>> ---
> 
> 
> 
>> diff --git a/arch/powerpc/cpu/mpc85xx/cpu_init_early.c 
>> b/arch/powerpc/cpu/mpc85xx/cpu_init_early.c
>> index 993b8b8..998781b 100644
>> --- a/arch/powerpc/cpu/mpc85xx/cpu_init_early.c
>> +++ b/arch/powerpc/cpu/mpc85xx/cpu_init_early.c
>> @@ -79,7 +79,7 @@ void setup_ifc(void)
>> #endif
>> 
>> /* We run cpu_init_early_f in AS = 1 */
>> -void cpu_init_early_f(void)
>> +void cpu_init_early_f(void *fdt)
>> {
>>u32 mas0, mas1, mas2, mas3, mas7;
>>int i;
>> @@ -102,6 +102,12 @@ void cpu_init_early_f(void)
>>for (i = 0; i < sizeof(gd_t); i++)
>>((char *)gd)[i] = 0;
>> 
>> +/*
>> + * CONFIG_SYS_CCSRBAR_PHYS below may use gd->fdt_blob on ePAPR systems,
>> + * so we need to populate it before it accesses it.
>> + */
>> +gd->fdt_blob = fdt;
>> +
> 
> Alex,
> 
> I am thinking to add back "#ifdef CONFIG_QEMU_E500" you had for your v3 and
> earlier version for the above change. Do you have any concerns?
> 
> The reason I am proposing this is to use generic board architecture.
> gd->fdt_blob is used by some other functions to detect if device tree exists.
> Your change takes r3 from entry and treat it as device tree. It is not the 
> case
> for a normal metal SoC. I need to clear this variable.

No complaints at all from me here :)

Alex

> 
> York
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 6/6] PPC 85xx: Add qemu-ppce500 machine

2014-04-28 Thread York Sun
On 02/20/2014 04:52 AM, Alexander Graf wrote:
> For KVM we have a special PV machine type called "ppce500". This machine
> is inspired by the MPC8544DS board, but implements a lot less features
> than that one.
> 
> It also provides more PCI slots and is supposed to be enumerated by
> device tree only.
> 
> This patch adds support for the generic ppce500 machine and tries to
> rely solely on device tree for device enumeration.
> 
> Signed-off-by: Alexander Graf 
> 
> ---
> 
> v3 -> v4:
> 
>   - use new tlb map syntax
>   - check that tlb map mapped everything
>   - always save/restore r3 for cpu_init_early_f
>   - remove CONFIG_DYNAMIC_CCSRBAR
>   - make init_tlbs weak and remove all init_tlbs_dynamic() cruft
>   - always map fdt to fixed virtual address
>   - fold together AS=1 fdt map functions
>   - use tlb_map_range for CCSR map
>   - search for PCI based on device type rather than compatible
>   - remove unnecessary cast
>   - call get_linear_ram_size directly
>   - override get_tbclk with timebase-frequency fetching code
> ---



> diff --git a/arch/powerpc/cpu/mpc85xx/cpu_init_early.c 
> b/arch/powerpc/cpu/mpc85xx/cpu_init_early.c
> index 993b8b8..998781b 100644
> --- a/arch/powerpc/cpu/mpc85xx/cpu_init_early.c
> +++ b/arch/powerpc/cpu/mpc85xx/cpu_init_early.c
> @@ -79,7 +79,7 @@ void setup_ifc(void)
>  #endif
>  
>  /* We run cpu_init_early_f in AS = 1 */
> -void cpu_init_early_f(void)
> +void cpu_init_early_f(void *fdt)
>  {
>   u32 mas0, mas1, mas2, mas3, mas7;
>   int i;
> @@ -102,6 +102,12 @@ void cpu_init_early_f(void)
>   for (i = 0; i < sizeof(gd_t); i++)
>   ((char *)gd)[i] = 0;
>  
> + /*
> +  * CONFIG_SYS_CCSRBAR_PHYS below may use gd->fdt_blob on ePAPR systems,
> +  * so we need to populate it before it accesses it.
> +  */
> + gd->fdt_blob = fdt;
> +

Alex,

I am thinking to add back "#ifdef CONFIG_QEMU_E500" you had for your v3 and
earlier version for the above change. Do you have any concerns?

The reason I am proposing this is to use generic board architecture.
gd->fdt_blob is used by some other functions to detect if device tree exists.
Your change takes r3 from entry and treat it as device tree. It is not the case
for a normal metal SoC. I need to clear this variable.

York

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 6/6] PPC 85xx: Add qemu-ppce500 machine

2014-04-11 Thread Alexander Graf


On 19.03.14 19:49, York Sun wrote:

On 02/20/2014 07:59 AM, Scott Wood wrote:

On Thu, 2014-02-20 at 13:52 +0100, Alexander Graf wrote:

diff --git a/arch/powerpc/cpu/mpc85xx/cpu.c b/arch/powerpc/cpu/mpc85xx/cpu.c
index 3e99b07..51f2085 100644
--- a/arch/powerpc/cpu/mpc85xx/cpu.c
+++ b/arch/powerpc/cpu/mpc85xx/cpu.c
@@ -272,6 +272,7 @@ int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
  #ifndef CONFIG_SYS_FSL_TBCLK_DIV
  #define CONFIG_SYS_FSL_TBCLK_DIV 8
  #endif
+__attribute__((weak))
  unsigned long get_tbclk (void)
  {
unsigned long tbclk_div = CONFIG_SYS_FSL_TBCLK_DIV;

It's not a big deal, but we do have __weak available.


+static void map_fdt_as(int esel)
+{
+   u32 mas0, mas1, mas2, mas3, mas7;
+   uint64_t fdt_phys = get_fdt_phys();
+   unsigned long fdt_phys_tlb = fdt_phys & ~0xful;
+   unsigned long fdt_virt_tlb = (ulong)get_fdt_virt() & ~0xful;
+
+   mas0 = MAS0_TLBSEL(1) | MAS0_ESEL(10);

Shouldn't you use the esel parameter here?


Are you going to address this comment with a new version?


Yes :).


Alex

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 6/6] PPC 85xx: Add qemu-ppce500 machine

2014-03-19 Thread York Sun
On 02/20/2014 07:59 AM, Scott Wood wrote:
> On Thu, 2014-02-20 at 13:52 +0100, Alexander Graf wrote:
>> diff --git a/arch/powerpc/cpu/mpc85xx/cpu.c b/arch/powerpc/cpu/mpc85xx/cpu.c
>> index 3e99b07..51f2085 100644
>> --- a/arch/powerpc/cpu/mpc85xx/cpu.c
>> +++ b/arch/powerpc/cpu/mpc85xx/cpu.c
>> @@ -272,6 +272,7 @@ int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char 
>> * const argv[])
>>  #ifndef CONFIG_SYS_FSL_TBCLK_DIV
>>  #define CONFIG_SYS_FSL_TBCLK_DIV 8
>>  #endif
>> +__attribute__((weak))
>>  unsigned long get_tbclk (void)
>>  {
>>  unsigned long tbclk_div = CONFIG_SYS_FSL_TBCLK_DIV;
> 
> It's not a big deal, but we do have __weak available.
> 
>> +static void map_fdt_as(int esel)
>> +{
>> +u32 mas0, mas1, mas2, mas3, mas7;
>> +uint64_t fdt_phys = get_fdt_phys();
>> +unsigned long fdt_phys_tlb = fdt_phys & ~0xful;
>> +unsigned long fdt_virt_tlb = (ulong)get_fdt_virt() & ~0xful;
>> +
>> +mas0 = MAS0_TLBSEL(1) | MAS0_ESEL(10);
> 
> Shouldn't you use the esel parameter here?
> 

Are you going to address this comment with a new version?

York


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 6/6] PPC 85xx: Add qemu-ppce500 machine

2014-02-20 Thread Scott Wood
On Thu, 2014-02-20 at 13:52 +0100, Alexander Graf wrote:
> diff --git a/arch/powerpc/cpu/mpc85xx/cpu.c b/arch/powerpc/cpu/mpc85xx/cpu.c
> index 3e99b07..51f2085 100644
> --- a/arch/powerpc/cpu/mpc85xx/cpu.c
> +++ b/arch/powerpc/cpu/mpc85xx/cpu.c
> @@ -272,6 +272,7 @@ int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char 
> * const argv[])
>  #ifndef CONFIG_SYS_FSL_TBCLK_DIV
>  #define CONFIG_SYS_FSL_TBCLK_DIV 8
>  #endif
> +__attribute__((weak))
>  unsigned long get_tbclk (void)
>  {
>   unsigned long tbclk_div = CONFIG_SYS_FSL_TBCLK_DIV;

It's not a big deal, but we do have __weak available.

> +static void map_fdt_as(int esel)
> +{
> + u32 mas0, mas1, mas2, mas3, mas7;
> + uint64_t fdt_phys = get_fdt_phys();
> + unsigned long fdt_phys_tlb = fdt_phys & ~0xful;
> + unsigned long fdt_virt_tlb = (ulong)get_fdt_virt() & ~0xful;
> +
> + mas0 = MAS0_TLBSEL(1) | MAS0_ESEL(10);

Shouldn't you use the esel parameter here?

-Scott


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 6/6] PPC 85xx: Add qemu-ppce500 machine

2014-02-20 Thread Alexander Graf
For KVM we have a special PV machine type called "ppce500". This machine
is inspired by the MPC8544DS board, but implements a lot less features
than that one.

It also provides more PCI slots and is supposed to be enumerated by
device tree only.

This patch adds support for the generic ppce500 machine and tries to
rely solely on device tree for device enumeration.

Signed-off-by: Alexander Graf 

---

v1 -> v2:

  - Write device tree offset directly into global variable
  - use r4 rather than r2 for that
  - access fdt directly from in-memory copy
  - remove unneeded header includes
  - clean up pci enumeration
  - coding style fixes
  - populate and only use fdt_addr_r
  - remove unused exported functions
  - remove unused TLB0 entries
  - make TLB1 I/O maps non-executable
  - remove unused defines in board header
  - make -kernel boot variables more clear
  - remove TLB0 invalidation
  - use tlb1.14 for temporary as=1 map
  - use CONFIG_SYS_MPC85XX_NO_RESETVEC
  - store fdt pointer in gd through cpu_init_early_f()
  - replace fixup_tlb1() with dynamic TLB creation hook

v2 -> v3:

  - merge dt patches into this one
  - Document and rename CONFIG_SYS_USE_DYNAMIC_TLBS
  - remove CONFIG_DDR_SPD
  - Reduce PCI message to only base address
  - Map AS=1 fdt behind CCSRBAR
  - Use CONFIG_SYS_CCSR_DO_NOT_RELOCATE
  - remove unnecessary ccsr map
  - s/cell size/cell count/
  - add temporary map define
  - use fdt_get_base_address() to find region
  - use new APIs
  - remove myfdt helpers

v3 -> v4:

  - use new tlb map syntax
  - check that tlb map mapped everything
  - always save/restore r3 for cpu_init_early_f
  - remove CONFIG_DYNAMIC_CCSRBAR
  - make init_tlbs weak and remove all init_tlbs_dynamic() cruft
  - always map fdt to fixed virtual address
  - fold together AS=1 fdt map functions
  - use tlb_map_range for CCSR map
  - search for PCI based on device type rather than compatible
  - remove unnecessary cast
  - call get_linear_ram_size directly
  - override get_tbclk with timebase-frequency fetching code
---
 arch/powerpc/cpu/mpc85xx/Makefile   |2 +
 arch/powerpc/cpu/mpc85xx/cpu.c  |4 +-
 arch/powerpc/cpu/mpc85xx/cpu_init_early.c   |8 +-
 arch/powerpc/cpu/mpc85xx/start.S|   11 +
 arch/powerpc/cpu/mpc85xx/tlb.c  |1 +
 arch/powerpc/include/asm/config_mpc85xx.h   |4 +
 board/freescale/qemu-ppce500/Makefile   |9 +
 board/freescale/qemu-ppce500/qemu-ppce500.c |  345 +++
 boards.cfg  |1 +
 include/configs/qemu-ppce500.h  |  203 
 10 files changed, 586 insertions(+), 2 deletions(-)
 create mode 100644 board/freescale/qemu-ppce500/Makefile
 create mode 100644 board/freescale/qemu-ppce500/qemu-ppce500.c
 create mode 100644 include/configs/qemu-ppce500.h

diff --git a/arch/powerpc/cpu/mpc85xx/Makefile 
b/arch/powerpc/cpu/mpc85xx/Makefile
index ef7637a..4094785 100644
--- a/arch/powerpc/cpu/mpc85xx/Makefile
+++ b/arch/powerpc/cpu/mpc85xx/Makefile
@@ -102,7 +102,9 @@ obj-y   += cpu.o
 obj-y  += cpu_init.o
 obj-y  += cpu_init_early.o
 obj-y  += interrupts.o
+ifneq ($(CONFIG_QEMU_E500),y)
 obj-y  += speed.o
+endif
 obj-y  += tlb.o
 obj-y  += traps.o
 
diff --git a/arch/powerpc/cpu/mpc85xx/cpu.c b/arch/powerpc/cpu/mpc85xx/cpu.c
index 3e99b07..51f2085 100644
--- a/arch/powerpc/cpu/mpc85xx/cpu.c
+++ b/arch/powerpc/cpu/mpc85xx/cpu.c
@@ -272,6 +272,7 @@ int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * 
const argv[])
 #ifndef CONFIG_SYS_FSL_TBCLK_DIV
 #define CONFIG_SYS_FSL_TBCLK_DIV 8
 #endif
+__attribute__((weak))
 unsigned long get_tbclk (void)
 {
unsigned long tbclk_div = CONFIG_SYS_FSL_TBCLK_DIV;
@@ -338,7 +339,8 @@ void mpc85xx_reginfo(void)
!defined(CONFIG_SYS_INIT_L2_ADDR)
 phys_size_t initdram(int board_type)
 {
-#if defined(CONFIG_SPD_EEPROM) || defined(CONFIG_DDR_SPD)
+#if defined(CONFIG_SPD_EEPROM) || defined(CONFIG_DDR_SPD) || \
+   defined(CONFIG_QEMU_E500)
return fsl_ddr_sdram_size();
 #else
return (phys_size_t)CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
diff --git a/arch/powerpc/cpu/mpc85xx/cpu_init_early.c 
b/arch/powerpc/cpu/mpc85xx/cpu_init_early.c
index 993b8b8..998781b 100644
--- a/arch/powerpc/cpu/mpc85xx/cpu_init_early.c
+++ b/arch/powerpc/cpu/mpc85xx/cpu_init_early.c
@@ -79,7 +79,7 @@ void setup_ifc(void)
 #endif
 
 /* We run cpu_init_early_f in AS = 1 */
-void cpu_init_early_f(void)
+void cpu_init_early_f(void *fdt)
 {
u32 mas0, mas1, mas2, mas3, mas7;
int i;
@@ -102,6 +102,12 @@ void cpu_init_early_f(void)
for (i = 0; i < sizeof(gd_t); i++)
((char *)gd)[i] = 0;
 
+   /*
+* CONFIG_SYS_CCSRBAR_PHYS below may use gd->fdt_blob on ePAPR systems,
+* so we need to populate it before it accesses it.
+*/
+   gd->fdt_blob = fdt;
+
mas0 = MAS0_TLBSEL(1) | MAS0_ESEL(13);
mas1 = MAS1_VALID | MAS1_TID(0) | MAS1_TS | MAS1_TSIZ